diff --git a/engine/Monstra.php b/engine/Monstra.php index 80d8127..59d0ff9 100644 --- a/engine/Monstra.php +++ b/engine/Monstra.php @@ -224,7 +224,11 @@ class Monstra /** * Init I18n */ - I18n::init(Option::get('language')); + if (BACKEND) { + I18n::init('admin', Option::get('language')); + } else { + I18n::init('site', Site::getCurrentSiteLocale()); + } /** * Init Plugins API @@ -235,7 +239,7 @@ class Monstra * Init Notification service */ Notification::init(); - + /** * Init site module */ @@ -315,6 +319,7 @@ class Monstra if (count($namespaces = Dir::scan(CACHE)) > 0) foreach ($namespaces as $namespace) Dir::delete(CACHE . DS . $namespace); } + /** * Initialize Monstra Engine * diff --git a/engine/Plugin/I18n.php b/engine/Plugin/I18n.php index 99058f4..daac8e8 100644 --- a/engine/Plugin/I18n.php +++ b/engine/Plugin/I18n.php @@ -75,9 +75,9 @@ class I18n * * @param string $dir Plugins directory */ - public static function init($locale) + public static function init($namespace = 'default', $locale) { - if ( ! isset(self::$instance)) self::$instance = new I18n($locale); + if ( ! isset(self::$instance)) self::$instance = new I18n($namespace, $locale); return self::$instance; } @@ -94,13 +94,13 @@ class I18n /** * Construct */ - protected function __construct($locale) + protected function __construct($namespace = 'default', $locale) { // Redefine arguments $locale = (string) $locale; // Get lang table for current locale - $lang_table = Cache::get('i18n', $locale); + $lang_table = Cache::get('i18n_'.$namespace, $locale); // If lang_table is empty then create new if (! $lang_table) { @@ -136,7 +136,7 @@ class I18n } // Save lang table for current locale - Cache::put('i18n', $locale, $lang_table); + Cache::put('i18n_'.$namespace, $locale, $lang_table); // Update dictionary I18n::$dictionary = $lang_table; diff --git a/engine/Site.php b/engine/Site.php index b9edf05..abe3969 100644 --- a/engine/Site.php +++ b/engine/Site.php @@ -221,4 +221,38 @@ class Site return __('Powered by', 'system').' Monstra ' . Monstra::VERSION; } + /** + * + */ + public static function getLocales() { + $language_files = File::scan(PLUGINS_BOX . DS . 'system' . DS . 'languages' . DS, '.lang.php'); + foreach ($language_files as $language) { + $parts = explode('.', $language); + $languages_array[$parts[0]] = I18n::$locales[$parts[0]]; + } + return $languages_array; + } + + /** + * + */ + public static function getDefaultSiteLocale() { + return Option::get('site_language'); + } + + /** + * + */ + public static function getCurrentSiteLocale() { + $site_locales = Site::getLocales(); + + + if (Uri::segment(0) && array_key_exists(Uri::segment(0), $site_locales)) { + return Uri::segment(0); + } else { + $site_locale = Cookie::get('site_locale'); + return !empty($site_locale) ? $site_locale : Option::get('site_language'); + } + + } } diff --git a/favicon.ico b/favicon.ico index 68dec5c..07297b2 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/index.php b/index.php index 1a75460..d106612 100644 --- a/index.php +++ b/index.php @@ -38,6 +38,18 @@ if (file_exists('install.php')) { // Load Engine init file require_once ROOT. DS . 'engine'. DS . '_init.php'; + + /* + $pages = new Table('pages'); + $pages_list = $pages->select(null, 'all'); + + foreach($pages_list as $page) { + $pages->update($page['id'], array('locale' => 'en')); + } + */ + +// Option::add('site_language', 'ru'); + // Check for maintenance mod if ('on' == Option::get('maintenance_status')) { diff --git a/plugins/blog/blog.plugin.php b/plugins/blog/blog.plugin.php index 6d06f28..4be4746 100644 --- a/plugins/blog/blog.plugin.php +++ b/plugins/blog/blog.plugin.php @@ -64,14 +64,17 @@ class Blog { * * @return string */ - public static function breadcrumbs() { + public static function breadcrumbs($locale = '') { + + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + $current_page = Pages::$requested_page; $parent_page = ''; if ($current_page !== 'error404') { - $page = Pages::$pages->select('[slug="'.$current_page.'"]', null); + $page = Pages::$pages->select('[slug="'.$current_page.'" and locale="'.$locale.'"]', null); if (trim($page['parent']) !== '') { $parent = true; - $parent_page = Pages::$pages->select('[slug="'.$page['parent'].'"]', null); + $parent_page = Pages::$pages->select('[slug="'.$page['parent'].'" and locale="'.$locale.'"]', null); } else { $parent = false; } @@ -96,16 +99,18 @@ class Blog { * * @return array */ - public static function getTagsArray($slug = null) { + public static function getTagsArray($slug = null, $locale='') { // Init vars $tags = array(); $tags_string = ''; + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + if ($slug == null) { - $posts = Pages::$pages->select('[parent="'.Blog::$parent_page_name.'" and status="published"]', 'all'); + $posts = Pages::$pages->select('[parent="'.Blog::$parent_page_name.'" and status="published" and locale="'.$locale.'"]', 'all'); } else { - $posts = Pages::$pages->select('[parent="'.Blog::$parent_page_name.'" and status="published" and slug="'.$slug.'"]', 'all'); + $posts = Pages::$pages->select('[parent="'.Blog::$parent_page_name.'" and status="published" and slug="'.$slug.'" and locale="'.$locale.'"]', 'all'); } foreach($posts as $post) { @@ -151,16 +156,18 @@ class Blog { * @param integer $num Number of posts to show * @return string */ - public static function getPosts($nums = 10) { + public static function getPosts($nums = 10, $locale = '') { + + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; // Get page param $page = (Request::get('page')) ? (int)Request::get('page') : 1; if (Request::get('tag')) { - $query = '[parent="'.Blog::$parent_page_name.'" and status="published" and contains(tags, "'.Request::get('tag').'")]'; + $query = '[parent="'.Blog::$parent_page_name.'" and status="published" and locale="'.$locale.'" and contains(tags, "'.Request::get('tag').'")]'; Notification::set('tag', Request::get('tag')); } else { - $query = '[parent="'.Blog::$parent_page_name.'" and status="published"]'; + $query = '[parent="'.Blog::$parent_page_name.'" and status="published" and locale="'.$locale.'"]'; Notification::clean(); } @@ -183,12 +190,14 @@ class Blog { if ($start < 0) $start = 0; // Get posts and sort by DESC - $posts = Pages::$pages->select($query, $nums, $start, array('slug', 'title', 'author', 'date'), 'date', 'DESC'); + $posts = Pages::$pages->select($query, $nums, $start, array('slug', 'title', 'author', 'date', 'locale', 'template'), 'date', 'DESC'); // Loop foreach($posts as $key => $post) { $post_short = explode("{cut}", Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $post['id'] . '.page.txt'))); $posts[$key]['content'] = Filter::apply('content', $post_short[0]); + $posts[$key]['slug'] = $posts[$key]['slug']; + $posts[$key]['locale'] = ($posts[$key]['locale'] == Site::getCurrentSiteLocale()) ? '' : $posts[$key]['locale'].'/'; } // Display view @@ -216,10 +225,12 @@ class Blog { * @param integer $num Number of posts to show * @return string */ - public static function getPostsBlock($nums = 10) { + public static function getPostsBlock($nums = 10, $locale = '') { + + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; // XPath Query - $query = '[parent="'.Blog::$parent_page_name.'" and status="published"]'; + $query = '[parent="'.Blog::$parent_page_name.'" and status="published" and locale="'.$locale.'"]'; // Get posts and sort by DESC $posts = Pages::$pages->select($query, $nums, 0, array('slug', 'title', 'author', 'date'), 'date', 'DESC'); @@ -247,14 +258,16 @@ class Blog { * * @return string */ - public static function getRelatedPosts($limit = null) { + public static function getRelatedPosts($limit = null, $locale = '') { + + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; $related_posts = array(); $tags = Blog::getTagsArray(Page::slug()); foreach($tags as $tag) { - $query = '[parent="'.Blog::$parent_page_name.'" and status="published" and contains(tags, "'.$tag.'") and slug!="'.Page::slug().'"]'; + $query = '[parent="'.Blog::$parent_page_name.'" and locale="'.$locale.'" and status="published" and contains(tags, "'.$tag.'") and slug!="'.Page::slug().'"]'; if ($result = Arr::subvalSort(Pages::$pages->select($query, ($limit == null) ? 'all' : (int)$limit), 'date', 'DESC')) { $related_posts = $result; @@ -303,9 +316,11 @@ class Blog { * * @return string */ - public static function getPostBeforeCut($slug) { + public static function getPostBeforeCut($slug, $locale = '') { - $page = Pages::$pages->select('[slug="'.$slug.'"]', null); + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + + $page = Pages::$pages->select('[slug="'.$slug.'" and locale="'.$locale.'"]', null); // Get post $post = explode("{cut}", Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt'))); @@ -327,9 +342,11 @@ class Blog { * * @return string */ - public static function getPostAfterCut($slug) { + public static function getPostAfterCut($slug, $locale = '') { - $page = Pages::$pages->select('[slug="'.$slug.'"]', null); + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + + $page = Pages::$pages->select('[slug="'.$slug.'" and locale="'.$locale.'"]', null); // Get post $post = explode("{cut}", Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt'))); diff --git a/plugins/blog/views/frontend/index.view.php b/plugins/blog/views/frontend/index.view.php index c9cec0a..2f6b338 100644 --- a/plugins/blog/views/frontend/index.view.php +++ b/plugins/blog/views/frontend/index.view.php @@ -1,5 +1,5 @@ -

+

/
diff --git a/plugins/box/pages/pages.admin.php b/plugins/box/pages/pages.admin.php index fbc9e4d..8be6b29 100755 --- a/plugins/box/pages/pages.admin.php +++ b/plugins/box/pages/pages.admin.php @@ -19,6 +19,13 @@ class PagesAdmin extends Backend */ public static $pages = null; + /** + * Locale + * + * @var string + */ + public static $locale_to_edit = ''; + /** * _pageExpandAjax */ @@ -27,7 +34,7 @@ class PagesAdmin extends Backend if (Request::post('page_slug')) { if (Security::check(Request::post('token'))) { $pages = new Table('pages'); - $pages->updateWhere('[slug="'.Request::post('page_slug').'"]', array('expand' => Request::post('page_expand'))); + $pages->updateWhere('[slug="'.Request::post('page_slug').'" and locale="'.PagesAdmin::$locale_to_edit.'"]', array('expand' => Request::post('page_expand'))); Request::shutdown(); } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } @@ -45,6 +52,23 @@ class PagesAdmin extends Backend $errors = array(); + if (Request::get('locale_to_edit')) { + if (Security::check(Request::get('token'))) { + if (Arr::keyExists(Site::getLocales(), Request::get('locale_to_edit'))) { + Cookie::set('locale_to_edit', Request::get('locale_to_edit')); + Request::redirect(Site::url().'/admin/index.php?id=pages'); + } + } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } + } + + if (Cookie::get('locale_to_edit')) { + $locale_to_edit = Cookie::get('locale_to_edit'); + } else { + $locale_to_edit = Site::getDefaultSiteLocale(); + } + + PagesAdmin::$locale_to_edit = $locale_to_edit; + $pages = new Table('pages'); PagesAdmin::$pages = $pages; @@ -106,6 +130,7 @@ class PagesAdmin extends Backend 'keywords' => $orig_page['keywords'], 'tags' => $orig_page['tags'], 'date' => $orig_page['date'], + 'locale' => $orig_page['locale'], 'author' => $orig_page['author']))) { // Get cloned page ID @@ -149,7 +174,7 @@ class PagesAdmin extends Backend //-------------- if (trim(Request::post('page_name')) == '') $errors['pages_empty_name'] = __('Required field', 'pages'); if (trim(Request::post('page_title')) == '') $errors['pages_empty_title'] = __('Required field', 'pages'); - if (count($pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'"]')) != 0) $errors['pages_exists'] = __('This page already exists', 'pages'); + if (count($pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'" and locale="'.$locale_to_edit.'"]')) != 0) $errors['pages_exists'] = __('This page already exists', 'pages'); // Prepare date if (Valid::date(Request::post('page_date'))) { @@ -179,6 +204,7 @@ class PagesAdmin extends Backend 'keywords' => Request::post('page_keywords'), 'tags' => Request::post('page_tags'), 'date' => $date, + 'locale' => $locale_to_edit, 'author' => $author))) { // Get inserted page ID @@ -287,7 +313,7 @@ class PagesAdmin extends Backend // Validate //-------------- if (trim(Request::post('page_name')) == '') $errors['pages_empty_name'] = __('Required field', 'pages'); - if ((count($pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'"]')) != 0) and (Security::safeName(Request::post('page_old_name'), '-', true) !== Security::safeName(Request::post('page_name'), '-', true))) $errors['pages_exists'] = __('This page already exists', 'pages'); + if ((count($pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'" and locale="'.$locale_to_edit.'"]')) != 0) and (Security::safeName(Request::post('page_old_name'), '-', true) !== Security::safeName(Request::post('page_name'), '-', true))) $errors['pages_exists'] = __('This page already exists', 'pages'); if (trim(Request::post('page_title')) == '') $errors['pages_empty_title'] = __('Required field', 'pages'); // Save fields @@ -328,7 +354,7 @@ class PagesAdmin extends Backend } } - if ($pages->updateWhere('[slug="'.Request::get('name').'"]', + if ($pages->updateWhere('[slug="'.Request::get('name').'" and locale="'.$locale_to_edit.'"]', array('slug' => Security::safeName(Request::post('page_name'), '-', true), 'template' => Request::post('templates'), 'parent' => $parent_page, @@ -342,6 +368,7 @@ class PagesAdmin extends Backend 'status' => Request::post('status'), 'access' => Request::post('access'), 'date' => $date, + 'locale' => $locale_to_edit, 'author' => $author))) { File::setContent(STORAGE . DS . 'pages' . DS . Request::post('page_id') . '.page.txt', XML::safe(Request::post('editor'))); @@ -353,7 +380,7 @@ class PagesAdmin extends Backend } else { - if ($pages->updateWhere('[slug="'.Request::get('name').'"]', + if ($pages->updateWhere('[slug="'.Request::get('name').'" and locale="'.$locale_to_edit.'"]', array('slug' => Security::safeName(Request::post('page_name'), '-', true), 'template' => Request::post('templates'), 'parent' => $parent_page, @@ -367,6 +394,7 @@ class PagesAdmin extends Backend 'status' => Request::post('status'), 'access' => Request::post('access'), 'date' => $date, + 'locale' => $locale_to_edit, 'author' => $author))) { File::setContent(STORAGE . DS . 'pages' . DS . Request::post('page_id') . '.page.txt', XML::safe(Request::post('editor'))); @@ -412,7 +440,15 @@ class PagesAdmin extends Backend $templates_array[basename($file,'.template.php')] = basename($file, '.template.php'); } - $page = $pages->select('[slug="'.Request::get('name').'"]', null); + if (Request::get('name') == 'error404') { + $page = $pages->select('[slug="'.Request::get('name').'" and locale="'.$locale_to_edit.'"]', null); + if (count($page) == 0) { + + } + } else { + $page = $pages->select('[slug="'.Request::get('name').'" and locale="'.$locale_to_edit.'"]', null); + } + if ($page) { @@ -488,7 +524,7 @@ class PagesAdmin extends Backend if (Security::check(Request::get('token'))) { // Get specific page - $page = $pages->select('[slug="'.Request::get('name').'"]', null); + $page = $pages->select('[slug="'.Request::get('name').'" and locale="'.$locale_to_edit.'"]', null); // Delete page and update fields if ($pages->deleteWhere('[slug="'.$page['slug'].'" ]')) { @@ -524,7 +560,7 @@ class PagesAdmin extends Backend if (Security::check(Request::get('token'))) { - $pages->updateWhere('[slug="'.Request::get('slug').'"]', array('access' => Request::get('access'))); + $pages->updateWhere('[slug="'.Request::get('slug').'" and locale="'.$locale_to_edit.'"]', array('access' => Request::get('access'))); // Run delete extra actions Action::run('admin_pages_action_update_access'); @@ -548,7 +584,7 @@ class PagesAdmin extends Backend if (Security::check(Request::get('token'))) { - $pages->updateWhere('[slug="'.Request::get('slug').'"]', array('status' => Request::get('status'))); + $pages->updateWhere('[slug="'.Request::get('slug').'" and locale="'.$locale_to_edit.'"]', array('status' => Request::get('status'))); // Run delete extra actions Action::run('admin_pages_action_update_status'); @@ -578,7 +614,7 @@ class PagesAdmin extends Backend $count = 0; // Get pages - $pages_list = $pages->select(null, 'all', null, array('slug', 'title', 'status', 'date', 'author', 'expand', 'access', 'parent', 'template', 'tags')); + $pages_list = $pages->select('[locale="'.$locale_to_edit.'"]', 'all', null, array('slug', 'title', 'status', 'date', 'author', 'expand', 'access', 'parent', 'template', 'tags', 'locale')); // Loop foreach ($pages_list as $page) { @@ -595,6 +631,7 @@ class PagesAdmin extends Backend $pages_array[$count]['expand'] = $page['expand']; $pages_array[$count]['slug'] = $page['slug']; $pages_array[$count]['tags'] = $page['tags']; + $pages_array[$count]['locale'] = $page['locale']; $pages_array[$count]['template']= $page['template']; if (isset($page['parent'])) { @@ -605,7 +642,7 @@ class PagesAdmin extends Backend if ($c_p != '') { - $_page = $pages->select('[slug="'.$page['parent'].'"]', null); + $_page = $pages->select('[slug="'.$page['parent'].'" and locale="'.$locale_to_edit.'"]', null); if (isset($_page['title'])) { $_title = $_page['title']; diff --git a/plugins/box/pages/pages.plugin.php b/plugins/box/pages/pages.plugin.php index 88afb07..13ff671 100644 --- a/plugins/box/pages/pages.plugin.php +++ b/plugins/box/pages/pages.plugin.php @@ -57,6 +57,13 @@ class Pages extends Frontend */ public static $requested_page = null; + /** + * Locale + * + * @var string + */ + public static $locale = ''; + /** * Main function */ @@ -77,7 +84,16 @@ class Pages extends Frontend $requested_page = Pages::lowLoader(Uri::segments()); Pages::$requested_page = $requested_page; - return Pages::$pages->select('[slug="'.$requested_page.'"]', null); + if($requested_page == 'error404') { + $page = Pages::$pages->select('[slug="'.$requested_page.'" and locale="'.Pages::$locale.'"]', null); + if(count($page) == 0) { + $page = Pages::$pages->select('[slug="'.$requested_page.'" and locale="'.Site::getDefaultSiteLocale().'"]', null); + } + } else { + $page = Pages::$pages->select('[slug="'.$requested_page.'" and locale="'.Pages::$locale.'"]', null); + } + + return $page; } /** @@ -91,14 +107,34 @@ class Pages extends Frontend { $defpage = Option::get('defaultpage'); + if (Arr::keyExists(Site::getLocales(), $data[0])) { + $locale = $data[0]; + if ($locale == Site::getDefaultSiteLocale()) { + if ((isset($data[2])) && ($data[2] != '')) { + Request::redirect(Site::url().'/'.$data[1].'/'.$data[2], 301); + } else { + Request::redirect(Site::url().'/'.(isset($data[1]) ? $data[1] : '') , 301); + } + } + $data[0] = isset($data[1]) ? $data[1] : ''; + $data[1] = isset($data[2]) ? $data[2] : ''; + if ($data[0] == '') unset($data[0]); + if ($data[1] == '') unset($data[1]); + } else { + $locale = Site::getDefaultSiteLocale(); + } + + Pages::$locale = $locale; + Cookie::set('site_locale', $locale); + // If data count 2 then it has Parent/Child if (count($data) >= 2) { // If exists parent file - if (count(Pages::$pages->select('[slug="'.$data[0].'"]')) !== 0) { + if (count(Pages::$pages->select('[slug="'.$data[0].'" and locale="'.$locale.'"]')) !== 0) { // Get child file and get parent page name - $child_page = Pages::$pages->select('[slug="'.$data[1].'"]', null); + $child_page = Pages::$pages->select('[slug="'.$data[1].'" and locale="'.$locale.'"]', null); // If child page parent is not empty then get his parent if (count($child_page) == 0) { @@ -150,15 +186,17 @@ class Pages extends Frontend } } else { // Only parent page come + if (empty($data[0])) { $id = $defpage; } else { + // Get current page - $current_page = Pages::$pages->select('[slug="'.$data[0].'"]', null); - + $current_page = Pages::$pages->select('[slug="'.$data[0].'" and locale="'.$locale.'"]', null); + // Hack For old Monstra $current_page['access'] = (isset($current_page['access'])) ? $current_page['access'] : 'public' ; @@ -176,7 +214,7 @@ class Pages extends Frontend if ($c_p !== '') { if ($c_p == $data[0]) { - if (count(Pages::$pages->select('[slug="'.$data[0].'"]', null)) != 0) { + if (count(Pages::$pages->select('[slug="'.$data[0].'"] and locale="'.$locale.'"]', null)) != 0) { if ((($current_page['status'] == 'published') or (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor')))) and @@ -194,17 +232,17 @@ class Pages extends Frontend $id = 'error404'; Response::status(404); } - } else { + } else { $id = 'error404'; Response::status(404); } - } else { + } else { $id = 'error404'; Response::status(404); } } else { - if (count(Pages::$pages->select('[slug="'.$data[0].'"]', null)) != 0) { + if (count(Pages::$pages->select('[slug="'.$data[0].'" and locale="'.$locale.'"]', null)) != 0) { if ((($current_page['status'] == 'published') or (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor')))) and ($current_page['access'] == 'public')) { @@ -217,11 +255,12 @@ class Pages extends Frontend $id = $data[0]; - } else { + } else { $id = 'error404'; Response::status(404); } } else { + $id = 'error404'; Response::status(404); } @@ -248,11 +287,13 @@ class Pages extends Frontend * * @return string */ - public static function content($slug = '') + public static function content($slug = '', $locale = '') { if ( ! empty($slug)) { - $page = Table::factory('pages')->select('[slug="'.$slug.'"]', null); + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + + $page = Table::factory('pages')->select('[slug="'.$slug.'" and locale="'.$locale.'"]', null); if ( ! empty($page)) { @@ -318,17 +359,19 @@ class Pages extends Frontend /** * Get pages */ - public static function getPages() + public static function getPages($locale = '') { // Init vars $pages_array = array(); $count = 0; + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + // Get pages table $pages = new Table('pages'); // Get Pages List - $pages_list = $pages->select('[slug!="error404" and status="published"]'); + $pages_list = $pages->select('[slug!="error404" and status="published" and locale="'.$locale.'"]'); foreach ($pages_list as $page) { @@ -337,6 +380,7 @@ class Pages extends Frontend $pages_array[$count]['parent'] = $page['parent']; $pages_array[$count]['date'] = $page['date']; $pages_array[$count]['author'] = $page['author']; + $pages_array[$count]['locale'] = $page['locale']; $pages_array[$count]['slug'] = ($page['slug'] == Option::get('defaultpage')) ? '' : $page['slug'] ; if (isset($page['parent'])) { @@ -346,7 +390,7 @@ class Pages extends Frontend } if ($c_p != '') { - $_page = $pages->select('[slug="'.$page['parent'].'"]', null); + $_page = $pages->select('[slug="'.$page['parent'].'" and locale="'.$locale.'"]', null); if (isset($_page['title'])) { $_title = $_page['title']; @@ -414,9 +458,10 @@ class Page extends Pages * @param string $parent Parent page * @return array */ - public static function children($parent) + public static function children($parent, $locale = '') { - return Pages::$pages->select('[parent="'.(string) $parent.'"]', 'all'); + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + return Pages::$pages->select('[parent="'.(string) $parent.'" and locale="'.$locale.'"]', 'all'); } /** @@ -427,9 +472,11 @@ class Page extends Pages * * */ - public static function available() + public static function available($locale = '') { - $pages = Pages::$pages->select('[parent="'.Pages::$requested_page.'"]', 'all'); + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; + + $pages = Pages::$pages->select('[parent="'.Pages::$requested_page.'" and locale="'.$locale.'"]', 'all'); // Display view View::factory('box/pages/views/frontend/available_pages') @@ -445,16 +492,17 @@ class Page extends Pages * * */ - public static function breadcrumbs() + public static function breadcrumbs($locale = '') { if (Uri::command() == 'pages') { + $locale = ($locale == '') ? Site::getCurrentSiteLocale() : $locale; $current_page = Pages::$requested_page; $parent_page = ''; if ($current_page !== 'error404') { - $page = Pages::$pages->select('[slug="'.$current_page.'"]', null); + $page = Pages::$pages->select('[slug="'.$current_page.'" and locale="'.$locale.'"]', null); if (trim($page['parent']) !== '') { $parent = true; - $parent_page = Pages::$pages->select('[slug="'.$page['parent'].'"]', null); + $parent_page = Pages::$pages->select('[slug="'.$page['parent'].'" and locale="'.$locale.'"]', null); } else { $parent = false; } diff --git a/plugins/box/pages/views/backend/index.view.php b/plugins/box/pages/views/backend/index.view.php index a8e9a4e..ff2f1e8 100755 --- a/plugins/box/pages/views/backend/index.view.php +++ b/plugins/box/pages/views/backend/index.view.php @@ -9,6 +9,20 @@ Html::anchor(__('Edit 404 Page', 'pages'), 'index.php?id=pages&action=edit_page&name=error404', array('title' => __('Create New Page', 'pages'), 'class' => 'btn btn-phone btn-default')) ); ?> +   +
+ + +
@@ -39,7 +53,7 @@ rel="children_" > select('[parent="'.(string) $page['slug'].'"]', 'all')) > 0) { + if (count(PagesAdmin::$pages->select('[parent="'.(string) $page['slug'].'" and locale="'.PagesAdmin::$locale_to_edit.'"]', 'all')) > 0) { if (isset($page['expand']) && $page['expand'] == '1') { echo '+'; } else { @@ -50,10 +64,11 @@ '_blank', 'rel' => 'children_'.$_parent)); + echo $dash.Html::anchor(Html::toText($page['title']), $site_url.'/'.$page_locale.$parent.$page['slug'], array('target' => '_blank', 'rel' => 'children_'.$_parent)); ?> diff --git a/plugins/box/system/system.admin.php b/plugins/box/system/system.admin.php index b1372aa..d472054 100755 --- a/plugins/box/system/system.admin.php +++ b/plugins/box/system/system.admin.php @@ -57,7 +57,8 @@ class SystemAdmin extends Backend // Get all pages $pages_array = array(); - $pages_list = $pages->select('[slug!="error404" and parent="" and status="published"]'); + $pages_list = $pages->select('[slug!="error404" and parent="" and locale="'.Site::getDefaultSiteLocale().'" and status="published"]'); + foreach ($pages_list as $page) { $pages_array[$page['slug']] = Html::toText($page['title']); } @@ -131,6 +132,7 @@ class SystemAdmin extends Backend 'timezone' => Request::post('system_timezone'), 'system_email' => Request::post('system_email'), 'language' => Request::post('system_language'), + 'site_language' => Request::post('site_language'), 'maintenance_message' => Request::post('site_maintenance_message'))); Notification::set('success', __('Your changes have been saved.', 'system')); diff --git a/plugins/box/system/system.plugin.php b/plugins/box/system/system.plugin.php index 33b6469..d5b1fa5 100644 --- a/plugins/box/system/system.plugin.php +++ b/plugins/box/system/system.plugin.php @@ -34,4 +34,4 @@ if (Session::exists('user_role') && in_array(Session::get('user_role'), array('a } -Plugin::Admin('system', 'box'); +Plugin::Admin('system', 'box'); \ No newline at end of file diff --git a/plugins/box/system/views/backend/index.view.php b/plugins/box/system/views/backend/index.view.php index ee1fb72..fd0341d 100755 --- a/plugins/box/system/views/backend/index.view.php +++ b/plugins/box/system/views/backend/index.view.php @@ -80,12 +80,20 @@
'form-control')) ); ?>
+ 'form-control')) + ); + ?> +
+
- + + http://localhost/projects/monstra-cms/blog + 2014-08-17 + weekly + 1.0 + + + http://localhost/projects/monstra-cms/blog/begin + 2014-08-18 + weekly + 0.5 + + + http://localhost/projects/monstra-cms/ + 2014-08-17 + weekly + 1.0 + + + http://localhost/projects/monstra-cms/download + 2014-08-16 + weekly + 1.0 + + + http://localhost/projects/monstra-cms/download/system + 2014-08-17 + weekly + 0.5 + + + http://localhost/projects/monstra-cms/users + 2015-01-08 + weekly + 1.0 + + \ No newline at end of file diff --git a/storage/database/options.table.xml b/storage/database/options.table.xml index 67b37a8..d8ecc0a 100644 --- a/storage/database/options.table.xml +++ b/storage/database/options.table.xml @@ -1,2 +1,2 @@ -211527510b419sitenameSitename25fe7b20ebbkeywordsSite keywords32996da0de2descriptionSite description44056d724b8sloganSite slogan5620d3e963edefaultpagehome66c9cd389f6siteurlhttp://example.org/72db8769b1etimezoneKwajalein8a0b440adcelanguageen9d7bd60ad05maintenance_statusoff10c415980d92maintenance_message<h1>Monstra :: Maintenance mode</h1>114c4e8f0aa8theme_site_namedefault124c4e8f0aa8theme_admin_namedefault124c4e8f0aa8users_frontend_registrationtrue18f469fc791ccaptcha_installedtrue19f119fc791csystem_emailadmin@admin.com20f119fc121cstyles_version121f119fc133cjavascript_version1 \ No newline at end of file +221527510b419sitenameTest25fe7b20ebbkeywordsSite keywords32996da0de2descriptionSite description44056d724b8sloganSite slogan5620d3e963edefaultpagehome66c9cd389f6siteurlhttp://localhost/projects/monstra-cms72db8769b1etimezoneKwajalein8a0b440adcelanguageen9d7bd60ad05maintenance_statusoff10c415980d92maintenance_message<h1>Monstra :: Maintenance mode</h1>114c4e8f0aa8theme_site_namedefault124c4e8f0aa8theme_admin_namedefault124c4e8f0aa8users_frontend_registrationtrue18f469fc791ccaptcha_installedtrue19f119fc791csystem_emailadmin@admin.com20f119fc121cstyles_version121f119fc133cjavascript_version1223f15e35cd1site_languageru diff --git a/storage/database/pages.table.xml b/storage/database/pages.table.xml index 272a2c3..8226bea 100644 --- a/storage/database/pages.table.xml +++ b/storage/database/pages.table.xml @@ -1,2 +1,2 @@ -4