Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nyankod/pusakacms
Browse files Browse the repository at this point in the history
  • Loading branch information
yllumi committed Dec 30, 2014
2 parents 846d1c3 + 8889a4e commit 9029898
Show file tree
Hide file tree
Showing 17 changed files with 61 additions and 35 deletions.
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@

define('VIEWPATH', $view_folder);

define('SITE_FOLDER', 'sites/');

// load Composer libraries
include_once './system/vendor/autoload.php';
Expand Down
25 changes: 24 additions & 1 deletion system/application/config/pusaka.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,27 @@
| Default to false.
|
*/
$config['subsite_domain'] = false;
$config['subsite_domain'] = false;

/*
|--------------------------------------------------------------------------
| post term
|--------------------------------------------------------------------------
|
| what term you want to use to represent post slug
|
*/
$config['post_term'] = 'blog';

/*
|--------------------------------------------------------------------------
| content folders
|--------------------------------------------------------------------------
|
| content folders path relatives to each site folder
|
*/
$config['page_folder'] = 'content/pages/';
$config['post_folder'] = 'content/posts/';
$config['label_folder'] = 'content/labels/';
$config['nav_folder'] = 'content/navs/';
2 changes: 1 addition & 1 deletion system/application/config/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

$config['theme_locations'] = array(
'system/themes/',
'sites/'.SITE_SLUG.'/themes/'
SITE_FOLDER.SITE_SLUG.'/themes/'
);

/*
Expand Down
8 changes: 4 additions & 4 deletions system/application/core/Admin_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public function __construct()
// set theme
$this->template->set_theme($this->config->item('admin_theme'));

if(file_exists('sites/'.SITE_SLUG.'/users/admin.json')){
$admin = json_decode(file_get_contents('sites/'.SITE_SLUG.'/users/admin.json'), true);
if(file_exists(SITE_FOLDER.SITE_SLUG.'/users/admin.json')){
$admin = json_decode(file_get_contents(SITE_FOLDER.SITE_SLUG.'/users/admin.json'), true);
if(isset($admin['password']) && $admin['password'] == 'password')
$this->template->set('warning', 'Change your default admin password to secure one in <a href="'.site_url('panel/users/edit/admin').'"><strong>Users settings</strong></a> page first.');
}
Expand All @@ -25,8 +25,8 @@ function logged_in(){
}

protected function _force_login($username){
if(file_exists('sites/'.SITE_SLUG.'/users/'.$username.'.json')){
$data = json_decode(file_get_contents('sites/'.SITE_SLUG.'/users/'.$username.'.json'), true);
if(file_exists(SITE_FOLDER.SITE_SLUG.'/users/'.$username.'.json')){
$data = json_decode(file_get_contents(SITE_FOLDER.SITE_SLUG.'/users/'.$username.'.json'), true);

$this->session->set_userdata(SITE_SLUG.'_username', $data['username']);
$this->session->set_userdata(SITE_SLUG.'_role', $data['role']);
Expand Down
24 changes: 13 additions & 11 deletions system/application/core/MY_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,27 @@ public function __construct()
parent::__construct();

$this->output->enable_profiler(false);

// Set timezone
date_default_timezone_set('Asia/Jakarta');

$sitepath = 'sites/'.SITE_SLUG.'/';
define('SITE_PATH', SITE_FOLDER.SITE_SLUG.'/');

// check if main config file exist
if(!file_exists(($sitepath.'config/site.json'))){
if(!file_exists((SITE_PATH.'config/site.json'))){
show_error('site.json config file for your site is not found. Please create it first.');
}
if(!file_exists(($sitepath.'config/system.json'))){
if(!file_exists((SITE_PATH.'config/system.json'))){
show_error('system.json config file for your site is not found. Please create it first.');
}

// get all config file
$config_file = array_filter(scandir($sitepath.'config'), function($user){
$config_file = array_filter(scandir(SITE_PATH.'config'), function($user){
return (strpos($user, '.json'));
});

foreach ($config_file as $confile) {
$config = json_decode(file_get_contents($sitepath.'config/'.$confile), true);
$config = json_decode(file_get_contents(SITE_PATH.'config/'.$confile), true);
foreach ($config as $key => $value) {
$this->config->set_item($key, $value);
$this->data[$key] = $value;
Expand All @@ -47,15 +48,16 @@ public function __construct()

$this->config->set_item('page_title', $this->config->item('site_name'));

if(! defined('PAGE_FOLDER')) define('PAGE_FOLDER', $sitepath.'content/pages/');
if(! defined('POST_FOLDER')) define('POST_FOLDER', $sitepath.'content/posts/');
if(! defined('LABEL_FOLDER')) define('LABEL_FOLDER', $sitepath.'content/labels/');
if(! defined('NAV_FOLDER')) define('NAV_FOLDER', $sitepath.'content/navs/');
if(! defined('SITE_PATH')) define('SITE_PATH', $sitepath);
if(! defined('POST_TERM')) define('POST_TERM', $this->config->item('post_term')?$this->config->item('post_term'):'blog');
if(! defined('PAGE_FOLDER')) define('PAGE_FOLDER', SITE_PATH.$this->config->item('page_folder'));
if(! defined('POST_FOLDER')) define('POST_FOLDER', SITE_PATH.$this->config->item('post_folder'));
if(! defined('LABEL_FOLDER')) define('LABEL_FOLDER', SITE_PATH.$this->config->item('label_folder'));
if(! defined('NAV_FOLDER')) define('NAV_FOLDER', SITE_PATH.$this->config->item('nav_folder'));

if(! defined('POST_TERM')) define('POST_TERM', $this->config->item('post_term'));

if(! defined('PLUGIN_FOLDER')) define('PLUGIN_FOLDER', 'system/plugins/');

// support compatibility with php < 5.3
if(! defined('JSON_PRETTY_PRINT')) define('JSON_PRETTY_PRINT', 128);
}

Expand Down
4 changes: 2 additions & 2 deletions system/application/helpers/template_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function get_theme_url($url = '') {
if ( ! function_exists('get_content_image'))
{
function get_image_content($file = false, $attr = '') {
$url = base_url().'sites/'.SITE_SLUG.'/content/files/'.$file;
$url = base_url().SITE_FOLDER.SITE_SLUG.'/content/files/'.$file;

return '<img src="'.$url.'" '.$attr.' />';
}
Expand All @@ -104,7 +104,7 @@ function get_image_content($file = false, $attr = '') {
if ( ! function_exists('get_content_file'))
{
function get_content_file($file = false) {
$url = base_url().'sites/'.SITE_SLUG.'/content/files/'.$file;
$url = base_url().SITE_FOLDER.SITE_SLUG.'/content/files/'.$file;

return $url;
}
Expand Down
6 changes: 3 additions & 3 deletions system/application/hooks/MyHookClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function multisite()
$segments = explode('/', $uri);

if(isset($segments[1]) && !empty($segments[1])) {
if(is_dir('sites/'.$segments[1]))
if(is_dir(SITE_FOLDER.$segments[1]))
define('SITE_SLUG', $segments[1]);
else
show_error('Site not found');
Expand All @@ -25,8 +25,8 @@ function multisite()

// then it is a online server with real domain
else {
if(file_exists('sites/_domain/'.$domain.'.conf'))
define('SITE_SLUG', trim(@file_get_contents('sites/_domain/'.$domain.'.conf')));
if(file_exists(SITE_FOLDER.'_domain/'.$domain.'.conf'))
define('SITE_SLUG', trim(@file_get_contents(SITE_FOLDER.'_domain/'.$domain.'.conf')));
else
show_error('Site not configured yet');
}
Expand Down
2 changes: 1 addition & 1 deletion system/application/libraries/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function initialize($config = array())
if ($this->_theme_locations === array())
{
// Let's use this obvious default
$this->_theme_locations = array('sites/themes/');
$this->_theme_locations = array(SITE_FOLDER.'themes/');
}

// No asset locations set in config?
Expand Down
8 changes: 4 additions & 4 deletions system/modules/cms/controllers/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ function update_domain($site = null)
{
if(!$site) show_error('which site domain must be update?');

if(file_exists('sites/'.$site.'/CNAME')){
$domain = @file_get_contents('sites/'.$site.'/CNAME');
if(write_file('sites/_domain/'.$domain.'.conf', $site)){
if(file_exists(SITE_FOLDER.$site.'/CNAME')){
$domain = @file_get_contents(SITE_FOLDER.$site.'/CNAME');
if(write_file(SITE_FOLDER.'_domain/'.$domain.'.conf', $site)){
header("Content-Type:text/plain");
echo "Domain setting for site $site updated.";
}
else
show_error('Writing domain configuration file failed. /sites/_domain/ folder must be writable.');
show_error('Writing domain configuration file failed. '.SITE_FOLDER.'_domain/ folder must be writable.');
} else
show_error('CNAME file not found');
}
Expand Down
2 changes: 1 addition & 1 deletion system/modules/panel/controllers/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Auth extends Admin_Controller {
function __construct(){
parent::__construct();

$this->users_path = 'sites/'.SITE_SLUG.'/users/';
$this->users_path = SITE_FOLDER.SITE_SLUG.'/users/';
}

function index()
Expand Down
8 changes: 4 additions & 4 deletions system/modules/panel/controllers/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function __construct(){

$this->export_location = ($this->config->item('export_location'))
? $this->config->item('export_location')
: 'sites/'.SITE_SLUG.'/html_output';
: SITE_FOLDER.SITE_SLUG.'/html_output';
}

function index()
Expand Down Expand Up @@ -62,10 +62,10 @@ function copy_files()
? $this->input->post('location')
: $this->export_location;

if(!file_exists($this->export_location.'/sites/'.SITE_SLUG.'/content/'))
mkdir($this->export_location.'/sites/'.SITE_SLUG.'/content/', 0777, true);
if(!file_exists($this->export_location.'/'.SITE_FOLDER.SITE_SLUG.'/content/'))
mkdir($this->export_location.'/'.SITE_FOLDER.SITE_SLUG.'/content/', 0777, true);

recurse_copy('sites/'.SITE_SLUG.'/content/files', $this->export_location.'/sites/'.SITE_SLUG.'/content/files');
recurse_copy(SITE_FOLDER.SITE_SLUG.'/content/files', $this->export_location.'/'.SITE_FOLDER.SITE_SLUG.'/content/files');

echo '{"status":"success", "message":"Files content copied."}';
}
Expand Down
2 changes: 1 addition & 1 deletion system/modules/panel/controllers/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function __construct(){

if(! $this->logged_in()) redirect('panel/login');

$this->files_path = 'sites/'. SITE_SLUG .'/content/files';
$this->files_path = SITE_FOLDER. SITE_SLUG .'/content/files';

if(!is_readable($this->files_path) || !is_writable($this->files_path))
show_error('Set folder '.$this->files_path.' and its contents readable and writable first.');
Expand Down
2 changes: 1 addition & 1 deletion system/modules/panel/controllers/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function __construct(){

if(! $this->logged_in()) redirect('panel/login');

$this->config_path = 'sites/'.SITE_SLUG.'/config/';
$this->config_path = SITE_FOLDER.SITE_SLUG.'/config/';

if(!is_readable($this->config_path) || !is_writable($this->config_path))
show_error('Set folder '.$this->config_path.' and its contents readable and writable first.');
Expand Down
2 changes: 1 addition & 1 deletion system/modules/panel/controllers/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function __construct(){

if(! $this->logged_in()) redirect('panel/login');

$this->users_path = 'sites/'. SITE_SLUG .'/users/';
$this->users_path = SITE_FOLDER. SITE_SLUG .'/users/';

if(!is_readable($this->users_path) || !is_writable($this->users_path))
show_error('Set folder '.$this->users_path.' and its contents readable and writable first.');
Expand Down
Empty file.
Empty file.
Empty file.

0 comments on commit 9029898

Please sign in to comment.