mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-15 01:24:40 +02:00
Add Monstra from HG Commit 683dcb70c4cc
This commit is contained in:
11
plugins/box/pages/install/pages.manifest.xml
Normal file
11
plugins/box/pages/install/pages.manifest.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<plugin_location>plugins/box/pages/pages.plugin.php</plugin_location>
|
||||
<plugin_status>active</plugin_status>
|
||||
<plugin_priority>1</plugin_priority>
|
||||
<plugin_name>Pages</plugin_name>
|
||||
<plugin_description>Pages managment plugin</plugin_description>
|
||||
<plugin_version>1.0.0</plugin_version>
|
||||
<plugin_author>Awilum</plugin_author>
|
||||
<plugin_author_uri>http://monstra.org/</plugin_author_uri>
|
||||
</root>
|
47
plugins/box/pages/languages/en.lang.php
Normal file
47
plugins/box/pages/languages/en.lang.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'pages' => array(
|
||||
'Pages' => 'Pages',
|
||||
'Pages manager' => 'Pages manager',
|
||||
'Content' => 'Content',
|
||||
'Create new page' => 'Create new page',
|
||||
'New page' => 'New page',
|
||||
'Edit page' => 'Edit page',
|
||||
'Date' => 'Date',
|
||||
'Clone' => 'Clone',
|
||||
'Edit' => 'Edit',
|
||||
'Delete' => 'Delete',
|
||||
'Delete page: :page' => 'Delete page: :page',
|
||||
'Title' => 'Title',
|
||||
'Name' => 'Name',
|
||||
'Author' => 'Author',
|
||||
'Name (slug)' => 'Name (slug)',
|
||||
'Description' => 'Description',
|
||||
'Keywords' => 'Keywords',
|
||||
'Parent' => 'Parent',
|
||||
'Template' => 'Template',
|
||||
'Year' => 'Year',
|
||||
'Day' => 'day',
|
||||
'Month' => 'Month',
|
||||
'Hour' => 'Hour',
|
||||
'Minute' => 'Minute',
|
||||
'Second' => 'Second',
|
||||
'This field should not be empty' => 'This field should not be empty',
|
||||
'This page already exists' => 'This page already exists',
|
||||
'Extra' => 'Extra',
|
||||
'Save' => 'Save',
|
||||
'Save and exit' => 'Save and exit',
|
||||
'Your changes to the page <i>:page</i> have been saved.' => 'Your changes to the page <i> :page </i> have been saved.',
|
||||
'The page <i>:page</i> cloned.' => 'The page <i>:page</i> cloned.',
|
||||
'Status' => 'Status',
|
||||
'Actions' => 'Actions',
|
||||
'Add' => 'Add',
|
||||
'Published' => 'Published',
|
||||
'Draft' => 'Draft',
|
||||
'Published on' => 'Published on',
|
||||
'Edit 404 page' => 'Edit 404 page',
|
||||
'Page <i>:page</i> deleted' => 'Page <i>:page</i> deleted',
|
||||
'Search Engines Robots' => 'Search Engines Robots',
|
||||
)
|
||||
);
|
47
plugins/box/pages/languages/ru.lang.php
Normal file
47
plugins/box/pages/languages/ru.lang.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'pages' => array(
|
||||
'Pages' => 'Страницы',
|
||||
'Pages manager' => 'Менеджер страниц',
|
||||
'Content' => 'Контент',
|
||||
'Create new page' => 'Создать новую страницу',
|
||||
'New page' => 'Новая страница',
|
||||
'Edit page' => 'Редактирование страницы',
|
||||
'Date' => 'Дата',
|
||||
'Clone' => 'Клонировать',
|
||||
'Edit' => 'Редактировать',
|
||||
'Delete' => 'Удалить',
|
||||
'Delete page: :page' => 'Удалить страницу: :page',
|
||||
'Title' => 'Заголовок',
|
||||
'Name' => 'Название',
|
||||
'Author' => 'Автор',
|
||||
'Name (slug)' => 'Название (slug)',
|
||||
'Description' => 'Описание',
|
||||
'Keywords' => 'Ключевые слова',
|
||||
'Parent' => 'Родитель',
|
||||
'Template' => 'Шаблон',
|
||||
'Year' => 'Год',
|
||||
'Day' => 'День',
|
||||
'Month' => 'Месяц',
|
||||
'Hours' => 'Час',
|
||||
'Minute' => 'Минута',
|
||||
'Second' => 'Секунда',
|
||||
'This field should not be empty' => 'Это поле не должно быть пустым',
|
||||
'This page already exists' => 'Такая страница уже существует',
|
||||
'Extra' => 'Дополнительно',
|
||||
'Save' => 'Сохранить',
|
||||
'Save and exit' => 'Сохранить и выйти',
|
||||
'Your changes to the page <i>:page</i> have been saved.' => 'Ваши изменения к странице <i>:page</i> были сохранены.',
|
||||
'The page <i>:page</i> cloned.' => 'Страница <i>:page</i> клонирована.',
|
||||
'Status' => 'Статус',
|
||||
'Actions' => 'Действия',
|
||||
'Add' => 'Добавить',
|
||||
'Published' => 'Опубликовано',
|
||||
'Draft' => 'Черновик',
|
||||
'Published on' => 'Опубликовано',
|
||||
'Edit 404 page' => 'Редактировать страницу 404',
|
||||
'Page <i>:page</i> deleted' => 'Страница <i>:page</i> удалена',
|
||||
'Search Engines Robots' => 'Поисковые роботы',
|
||||
),
|
||||
);
|
499
plugins/box/pages/pages.admin.php
Normal file
499
plugins/box/pages/pages.admin.php
Normal file
@@ -0,0 +1,499 @@
|
||||
<?php
|
||||
|
||||
|
||||
Navigation::add(__('Pages', 'pages'), 'content', 'pages', 1);
|
||||
|
||||
|
||||
class PagesAdmin extends Backend {
|
||||
|
||||
/**
|
||||
* Pages admin function
|
||||
*/
|
||||
public static function main() {
|
||||
|
||||
$current_theme = Option::get('theme_site_name');
|
||||
$site_url = Option::get('siteurl');
|
||||
|
||||
$templates_path = THEMES_SITE;
|
||||
|
||||
$errors = array();
|
||||
|
||||
$pages = new Table('pages');
|
||||
$users = new Table('users');
|
||||
|
||||
$user = $users->select('[id='.Session::get('user_id').']', null);
|
||||
|
||||
$user['firstname'] = Html::toText($user['firstname']);
|
||||
$user['lastname'] = Html::toText($user['lastname']);
|
||||
|
||||
// Page author
|
||||
if (isset($user['firstname']) && trim($user['firstname']) !== '') {
|
||||
if (trim($user['lastname']) !== '') $lastname = ' '.$user['lastname']; else $lastname = '';
|
||||
$author = $user['firstname'] . $lastname;
|
||||
} else {
|
||||
$author = Session::get('user_login');
|
||||
}
|
||||
|
||||
|
||||
// Status array
|
||||
$status_array = array('published' => __('Published', 'pages'),
|
||||
'draft' => __('Draft', 'pages'));
|
||||
|
||||
|
||||
// Check for get actions
|
||||
// ---------------------------------------------
|
||||
if (Request::get('action')) {
|
||||
|
||||
// Switch actions
|
||||
// -----------------------------------------
|
||||
switch (Request::get('action')) {
|
||||
|
||||
// Clone page
|
||||
// -------------------------------------
|
||||
case "clone_page":
|
||||
|
||||
// Generate rand page name
|
||||
$rand_page_name = Request::get('name').'_clone_'.date("Ymd_His");
|
||||
|
||||
// Get original page
|
||||
$orig_page = $pages->select('[slug="'.Request::get('name').'"]', null);
|
||||
|
||||
// Clone page
|
||||
if($pages->insert(array('slug' => $rand_page_name,
|
||||
'template' => $orig_page['template'],
|
||||
'parent' => $orig_page['parent'],
|
||||
'robots_index' => $orig_page['robots_index'],
|
||||
'robots_follow'=> $orig_page['robots_follow'],
|
||||
'status' => $orig_page['status'],
|
||||
'title' => $rand_page_name,
|
||||
'description' => $orig_page['description'],
|
||||
'keywords' => $orig_page['keywords'],
|
||||
'date' => $orig_page['date'],
|
||||
'author' => $orig_page['author']))) {
|
||||
|
||||
// Get cloned page ID
|
||||
$last_id = $pages->lastId();
|
||||
|
||||
// Save cloned page content
|
||||
File::setContent(STORAGE . DS . 'pages' . DS . $last_id . '.page.txt',
|
||||
File::getContent(STORAGE . DS . 'pages' . DS . $orig_page['id'] . '.page.txt'));
|
||||
|
||||
// Send notification
|
||||
Notification::set('success', __('The page <i>:page</i> cloned.', 'pages', array(':page' => Security::safeName(Request::get('name'), '-', true))));
|
||||
}
|
||||
|
||||
// Run add extra actions
|
||||
Action::run('admin_pages_action_clone');
|
||||
|
||||
// Redirect
|
||||
Request::redirect('index.php?id=pages');
|
||||
break;
|
||||
|
||||
// Add page
|
||||
// -------------------------------------
|
||||
case "add_page":
|
||||
|
||||
// Add page
|
||||
if (Request::post('add_page') || Request::post('add_page_and_exit')) {
|
||||
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
// Get pages parent
|
||||
if (Request::post('pages') == '0') {
|
||||
$parent_page = '';
|
||||
} else {
|
||||
$parent_page = Request::post('pages');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Validate
|
||||
//--------------
|
||||
if (trim(Request::post('page_name')) == '') $errors['pages_empty_name'] = __('This field should not be empty', 'pages');
|
||||
|
||||
$page = $pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'"]');
|
||||
|
||||
if (count($page) != 0) $errors['pages_exists'] = __('This page already exists', 'pages');
|
||||
if (trim(Request::post('page_title')) == '') $errors['pages_empty_title'] = __('This field should not be empty', 'pages');
|
||||
|
||||
// Generate date
|
||||
$date = mktime(Request::post('hour'),
|
||||
Request::post('minute'),
|
||||
Request::post('second'),
|
||||
Request::post('month'),
|
||||
Request::post('day'),
|
||||
Request::post('year'));
|
||||
|
||||
if (Request::post('robots_index')) $robots_index = 'noindex'; else $robots_index = 'index';
|
||||
if (Request::post('robots_follow')) $robots_follow = 'nofollow'; else $robots_follow = 'follow';
|
||||
|
||||
// If no errors then try to save
|
||||
if (count($errors) == 0) {
|
||||
|
||||
// Insert new page
|
||||
if($pages->insert(array('slug' => Security::safeName(Request::post('page_name'), '-', true),
|
||||
'template' => Request::post('templates'),
|
||||
'parent' => $parent_page,
|
||||
'status' => Request::post('status'),
|
||||
'robots_index' => $robots_index,
|
||||
'robots_follow'=> $robots_follow,
|
||||
'title' => Request::post('page_title'),
|
||||
'description' => Request::post('page_description'),
|
||||
'keywords' => Request::post('page_keywords'),
|
||||
'date' => $date,
|
||||
'author' => $author))) {
|
||||
|
||||
// Get inserted page ID
|
||||
$last_id = $pages->lastId();
|
||||
|
||||
// Save content
|
||||
File::setContent(STORAGE . DS . 'pages' . DS . $last_id . '.page.txt', XML::safe(Request::post('editor')));
|
||||
|
||||
// Send notification
|
||||
Notification::set('success', __('Your changes to the page <i>:page</i> have been saved.', 'pages', array(':page' => Security::safeName(Request::post('page_title'), '-', true))));
|
||||
}
|
||||
|
||||
// Run add extra actions
|
||||
Action::run('admin_pages_action_add');
|
||||
|
||||
// Redirect
|
||||
if (Request::post('add_page_and_exit')) {
|
||||
Request::redirect('index.php?id=pages');
|
||||
} else {
|
||||
Request::redirect('index.php?id=pages&action=edit_page&name='.Security::safeName(Request::post('page_name'), '-', true));
|
||||
}
|
||||
}
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
|
||||
}
|
||||
|
||||
// Get all pages
|
||||
$pages_list = $pages->select('[slug!="error404" and parent=""]');
|
||||
$pages_array[] = '-none-';
|
||||
foreach ($pages_list as $page) {
|
||||
$pages_array[$page['slug']] = $page['title'];
|
||||
}
|
||||
|
||||
// Get all templates
|
||||
$templates_list = File::scan($templates_path, '.template.php');
|
||||
foreach ($templates_list as $file) {
|
||||
$templates_array[basename($file, '.template.php')] = basename($file, '.template.php');
|
||||
}
|
||||
|
||||
// Save fields
|
||||
if (Request::post('pages')) $parent_page = Request::post('pages'); else $parent_page = '';
|
||||
if (Request::post('page_name')) $post_name = Request::post('page_name'); else $post_name = '';
|
||||
if (Request::post('page_title')) $post_title = Request::post('page_title'); else $post_title = '';
|
||||
if (Request::post('page_keywords')) $post_keywords = Request::post('page_keywords'); else $post_keywords = '';
|
||||
if (Request::post('page_description')) $post_description = Request::post('page_description'); else $post_description = '';
|
||||
if (Request::post('editor')) $post_content = Request::post('editor'); else $post_content = '';
|
||||
if (Request::post('templates')) $post_template = Request::post('templates'); else $post_template = 'index';
|
||||
if (Request::post('robots_index')) $post_robots_index = true; else $post_robots_index = false;
|
||||
if (Request::post('robots_follow')) $post_robots_follow = true; else $post_robots_follow = false;
|
||||
if (Request::post('parent_page')) {
|
||||
$post_template = Request::post('pages');
|
||||
} else {
|
||||
if(Request::get('parent_page')) {
|
||||
$parent_page = trim(Request::get('parent_page'));
|
||||
}
|
||||
}
|
||||
//--------------
|
||||
|
||||
// Generate date
|
||||
$date = explode('-', Date::format(time(), 'Y-m-d-H-i-s'));
|
||||
|
||||
// Display view
|
||||
View::factory('box/pages/views/backend/add')
|
||||
->assign('post_name', $post_name)
|
||||
->assign('post_title', $post_title)
|
||||
->assign('post_description', $post_description)
|
||||
->assign('post_keywords', $post_keywords)
|
||||
->assign('post_content', $post_content)
|
||||
->assign('pages_array', $pages_array)
|
||||
->assign('parent_page', $parent_page)
|
||||
->assign('templates_array', $templates_array)
|
||||
->assign('post_template', $post_template)
|
||||
->assign('status_array', $status_array)
|
||||
->assign('date', $date)
|
||||
->assign('post_robots_index', $post_robots_index)
|
||||
->assign('post_robots_follow', $post_robots_follow)
|
||||
->assign('errors', $errors)
|
||||
->display();
|
||||
|
||||
break;
|
||||
|
||||
// Edit page
|
||||
// -------------------------------------
|
||||
case "edit_page":
|
||||
|
||||
if (Request::post('edit_page') || Request::post('edit_page_and_exit')) {
|
||||
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
// Get pages parent
|
||||
if (Request::post('pages') == '0') {
|
||||
$parent_page = '';
|
||||
} else {
|
||||
$parent_page = Request::post('pages');
|
||||
}
|
||||
// Save field
|
||||
$post_parent = Request::post('pages');
|
||||
|
||||
|
||||
// Validate
|
||||
//--------------
|
||||
if (trim(Request::post('page_name')) == '') $errors['pages_empty_name'] = __('This field should not be empty', 'pages');
|
||||
|
||||
$_page = $pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'"]');
|
||||
|
||||
if ((count($_page) != 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'] = __('This field should not be empty', 'pages');
|
||||
|
||||
// Save fields
|
||||
if (Request::post('page_name')) $post_name = Request::post('page_name'); else $post_name = '';
|
||||
if (Request::post('page_title')) $post_title = Request::post('page_title'); else $post_title = '';
|
||||
if (Request::post('page_keywords')) $post_keywords = Request::post('page_keywords'); else $post_keywords = '';
|
||||
if (Request::post('page_description')) $post_description = Request::post('page_description'); else $post_description = '';
|
||||
if (Request::post('editor')) $post_content = Request::post('editor'); else $post_content = '';
|
||||
if (Request::post('templates')) $post_template = Request::post('templates'); else $post_template = 'index';
|
||||
if (Request::post('robots_index')) $post_robots_index = true; else $post_robots_index = false;
|
||||
if (Request::post('robots_follow')) $post_robots_follow = true; else $post_robots_follow = false;
|
||||
//--------------
|
||||
|
||||
// Generate date
|
||||
$date = mktime(Request::post('hour'),
|
||||
Request::post('minute'),
|
||||
Request::post('second'),
|
||||
Request::post('month'),
|
||||
Request::post('day'),
|
||||
Request::post('year'));
|
||||
|
||||
if (Request::post('robots_index')) $robots_index = 'noindex'; else $robots_index = 'index';
|
||||
if (Request::post('robots_follow')) $robots_follow = 'nofollow'; else $robots_follow = 'follow';
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
// Update parents in all childrens
|
||||
if ((Security::safeName(Request::post('page_name'), '-', true)) !== (Security::safeName(Request::post('page_old_name'), '-', true)) and (Request::post('old_parent') == '')) {
|
||||
|
||||
$pages->updateWhere('[parent="'.Request::get('name').'"]', array('parent' => Text::translitIt(trim(Request::post('page_name')))));
|
||||
|
||||
if ($pages->updateWhere('[slug="'.Request::get('name').'"]',
|
||||
array('slug' => Security::safeName(Request::post('page_name'), '-', true),
|
||||
'template' => Request::post('templates'),
|
||||
'parent' => $parent_page,
|
||||
'title' => Request::post('page_title'),
|
||||
'description' => Request::post('page_description'),
|
||||
'keywords' => Request::post('page_keywords'),
|
||||
'robots_index' => $robots_index,
|
||||
'robots_follow'=> $robots_follow,
|
||||
'status' => Request::post('status'),
|
||||
'date' => $date,
|
||||
'author' => $author))) {
|
||||
|
||||
File::setContent(STORAGE . DS . 'pages' . DS . Request::post('page_id') . '.page.txt', XML::safe(Request::post('editor')));
|
||||
Notification::set('success', __('Your changes to the page <i>:page</i> have been saved.', 'pages', array(':page' => Security::safeName(Request::post('page_title'), '-', true))));
|
||||
}
|
||||
|
||||
// Run edit extra actions
|
||||
Action::run('admin_pages_action_edit');
|
||||
|
||||
} else {
|
||||
|
||||
if ($pages->updateWhere('[slug="'.Request::get('name').'"]',
|
||||
array('slug' => Security::safeName(Request::post('page_name'), '-', true),
|
||||
'template' => Request::post('templates'),
|
||||
'parent' => $parent_page,
|
||||
'title' => Request::post('page_title'),
|
||||
'description' => Request::post('page_description'),
|
||||
'keywords' => Request::post('page_keywords'),
|
||||
'robots_index' => $robots_index,
|
||||
'robots_follow'=> $robots_follow,
|
||||
'status' => Request::post('status'),
|
||||
'date' => $date,
|
||||
'author' => $author))) {
|
||||
|
||||
File::setContent(STORAGE . DS . 'pages' . DS . Request::post('page_id') . '.page.txt', XML::safe(Request::post('editor')));
|
||||
Notification::set('success', __('Your changes to the page <i>:page</i> have been saved.', 'pages', array(':page' => Security::safeName(Request::post('page_title'), '-', true))));
|
||||
}
|
||||
|
||||
// Run edit extra actions
|
||||
Action::run('admin_pages_action_edit');
|
||||
}
|
||||
|
||||
// Redirect
|
||||
if (Request::post('edit_page_and_exit')) {
|
||||
Request::redirect('index.php?id=pages');
|
||||
} else {
|
||||
Request::redirect('index.php?id=pages&action=edit_page&name='.Security::safeName(Request::post('page_name'), '-', true));
|
||||
}
|
||||
}
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
}
|
||||
|
||||
|
||||
// Get all pages
|
||||
$pages_list = $pages->select();
|
||||
$pages_array[] = '-none-';
|
||||
// Foreach pages find page whithout parent
|
||||
foreach ($pages_list as $page) {
|
||||
if (isset($page['parent'])) {
|
||||
$c_p = $page['parent'];
|
||||
} else {
|
||||
$c_p = '';
|
||||
}
|
||||
if ($c_p == '') {
|
||||
// error404 is system "constant" and no child for it
|
||||
if ($page['slug'] !== 'error404' && $page['slug'] !== Request::get('name')) {
|
||||
$pages_array[$page['slug']] = $page['title'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get all templates
|
||||
$templates_list = File::scan($templates_path,'.template.php');
|
||||
foreach ($templates_list as $file) {
|
||||
$templates_array[basename($file,'.template.php')] = basename($file, '.template.php');
|
||||
}
|
||||
|
||||
|
||||
$page = $pages->select('[slug="'.Request::get('name').'"]', null);
|
||||
|
||||
if ($page) {
|
||||
|
||||
$page_content = File::getContent(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt');
|
||||
|
||||
// Safe fields or load fields
|
||||
if (Request::post('page_name')) $slug_to_edit = Request::post('page_name'); else $slug_to_edit = $page['slug'];
|
||||
if (Request::post('page_title')) $title_to_edit = Request::post('page_title'); else $title_to_edit = $page['title'];
|
||||
if (Request::post('page_description')) $description_to_edit = Request::post('page_description'); else $description_to_edit = $page['description'];
|
||||
if (Request::post('page_keywords')) $keywords_to_edit = Request::post('page_keywords'); else $keywords_to_edit = $page['keywords'];
|
||||
if (Request::post('editor')) $to_edit = Request::post('editor'); else $to_edit = Text::toHtml($page_content);
|
||||
|
||||
if (Request::post('robots_index')) $post_robots_index = true; else if ($page['robots_index'] == 'noindex') $post_robots_index = true; else $post_robots_index = false;
|
||||
if (Request::post('robots_follow')) $post_robots_follow = true; else if ($page['robots_follow'] == 'nofollow') $post_robots_follow = true; else $post_robots_follow = false;
|
||||
|
||||
if (Request::post('pages')) {
|
||||
// Get pages parent
|
||||
if (post('pages') == '-none-') {
|
||||
$parent_page = '';
|
||||
} else {
|
||||
$parent_page = Request::post('pages');
|
||||
}
|
||||
// Save field
|
||||
$parent_page = Request::post('pages');
|
||||
} else {
|
||||
$parent_page = $page['parent'];
|
||||
}
|
||||
if (Request::post('templates')) $template = Request::post('templates'); else $template = $page['template'];
|
||||
if (Request::post('status')) $status = Request::post('status'); else $status = $page['status'];
|
||||
|
||||
$date = explode('-', Date::format($page['date'],'Y-m-d-H-i-s'));
|
||||
|
||||
// Display view
|
||||
View::factory('box/pages/views/backend/edit')
|
||||
->assign('slug_to_edit', $slug_to_edit)
|
||||
->assign('title_to_edit', $title_to_edit)
|
||||
->assign('description_to_edit', $description_to_edit)
|
||||
->assign('keywords_to_edit', $keywords_to_edit)
|
||||
->assign('page', $page)
|
||||
->assign('to_edit', $to_edit)
|
||||
->assign('pages_array', $pages_array)
|
||||
->assign('parent_page', $parent_page)
|
||||
->assign('templates_array', $templates_array)
|
||||
->assign('template', $template)
|
||||
->assign('status_array', $status_array)
|
||||
->assign('status', $status)
|
||||
->assign('date', $date)
|
||||
->assign('post_robots_index', $post_robots_index)
|
||||
->assign('post_robots_follow', $post_robots_follow)
|
||||
->assign('errors', $errors)
|
||||
->display();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Delete page
|
||||
// -------------------------------------
|
||||
case "delete_page":
|
||||
|
||||
// Error 404 page can not be removed
|
||||
if (Request::get('name') !== 'error404') {
|
||||
|
||||
// Get page title, delete page and update <parent> fields
|
||||
$page = $pages->select('[slug="'.Request::get('name').'"]', null);
|
||||
|
||||
if ($pages->deleteWhere('[slug="'.Request::get('name').'" ]')) {
|
||||
$pages->updateWhere('[parent="'.Request::get('name').'"]', array('parent' => ''));
|
||||
File::delete(STORAGE . DS . 'pages' . DS . $page['id'] . '.page.txt');
|
||||
Notification::set('success', __('Page <i>:page</i> deleted', 'pages', array(':page' => Html::toText($page['title']))));
|
||||
}
|
||||
|
||||
// Run delete extra actions
|
||||
Action::run('admin_pages_action_delete');
|
||||
|
||||
// Redirect
|
||||
Request::redirect('index.php?id=pages');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Its mean that you can add your own actions for this plugin
|
||||
Action::run('admin_pages_extra_actions');
|
||||
|
||||
} else { // Load main template
|
||||
|
||||
|
||||
$pages_list = $pages->select(null, 'all', null, array('slug', 'title', 'status', 'date', 'author', 'parent'));
|
||||
|
||||
$pages_array = array();
|
||||
|
||||
$count = 0;
|
||||
foreach ($pages_list as $page) {
|
||||
|
||||
$pages_array[$count]['title'] = $page['title'];
|
||||
$pages_array[$count]['parent'] = $page['parent'];
|
||||
$pages_array[$count]['status'] = $status_array[$page['status']];
|
||||
$pages_array[$count]['date'] = $page['date'];
|
||||
$pages_array[$count]['author'] = $page['author'];
|
||||
$pages_array[$count]['slug'] = $page['slug'];
|
||||
|
||||
if (isset($page['parent'])) {
|
||||
$c_p = $page['parent'];
|
||||
} else {
|
||||
$c_p = '';
|
||||
}
|
||||
|
||||
if ($c_p != '') {
|
||||
$_page = $pages->select('[slug="'.$page['parent'].'"]', null);
|
||||
|
||||
if (isset($_page['title'])) {
|
||||
$_title = $_page['title'];
|
||||
} else {
|
||||
$_title = '';
|
||||
}
|
||||
$pages_array[$count]['sort'] = $_title . ' ' . $page['title'];
|
||||
} else {
|
||||
$pages_array[$count]['sort'] = $page['title'];
|
||||
}
|
||||
$_title = '';
|
||||
$count++;
|
||||
}
|
||||
|
||||
// Sort pages
|
||||
$pages = Arr::subvalSort($pages_array, 'sort');
|
||||
|
||||
// Display view
|
||||
View::factory('box/pages/views/backend/index')
|
||||
->assign('pages', $pages)
|
||||
->assign('site_url', $site_url)
|
||||
->display();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
392
plugins/box/pages/pages.plugin.php
Normal file
392
plugins/box/pages/pages.plugin.php
Normal file
@@ -0,0 +1,392 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Pages plugin
|
||||
*
|
||||
* @package Monstra
|
||||
* @subpackage Plugins
|
||||
* @author Romanenko Sergey / Awilum
|
||||
* @copyright 2012 Romanenko Sergey / Awilum
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Register plugin
|
||||
Plugin::register( __FILE__,
|
||||
__('Pages' , 'pages'),
|
||||
__('Pages manager', 'pages'),
|
||||
'1.0.0',
|
||||
'Awilum',
|
||||
'http://monstra.org/',
|
||||
'pages',
|
||||
'box');
|
||||
|
||||
|
||||
|
||||
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
|
||||
|
||||
// Include Admin
|
||||
Plugin::Admin('pages', 'box');
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Pages extends Frontend {
|
||||
|
||||
|
||||
/**
|
||||
* Current page data
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public static $page = null;
|
||||
|
||||
|
||||
/**
|
||||
* Pages tables
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public static $pages = null;
|
||||
|
||||
|
||||
/**
|
||||
* Requested page
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $requested_page = null;
|
||||
|
||||
|
||||
/**
|
||||
* Main function
|
||||
*/
|
||||
public static function main() {
|
||||
if (BACKEND == false) {
|
||||
$pages = new Table('pages');
|
||||
Pages::$pages = $pages;
|
||||
|
||||
$page = Pages::pageLoader();
|
||||
Pages::$page = $page;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Page loader
|
||||
*
|
||||
* @param boolean $return_data data
|
||||
* @return array
|
||||
*/
|
||||
public static function pageLoader($return_data = true) {
|
||||
$requested_page = Pages::lowLoader(Uri::segments());
|
||||
Pages::$requested_page = $requested_page;
|
||||
return Pages::$pages->select('[slug="'.$requested_page.'"]', null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load current page
|
||||
*
|
||||
* @global string $defpage default page
|
||||
* @param array $data uri
|
||||
* @return string
|
||||
*/
|
||||
public static function lowLoader($data) {
|
||||
|
||||
$defpage = Option::get('defaultpage');
|
||||
|
||||
// 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) {
|
||||
|
||||
// Get child file and get parent page name
|
||||
$child_page = Pages::$pages->select('[slug="'.$data[1].'"]', null);
|
||||
|
||||
// If child page parent is not empty then get his parent
|
||||
if (count($child_page) == 0) {
|
||||
$c_p = '';
|
||||
} else {
|
||||
if ($child_page['parent'] != '') {
|
||||
$c_p = $child_page['parent'];
|
||||
} else {
|
||||
$c_p = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Check is child_parent -> request parent
|
||||
if ($c_p == $data[0]) {
|
||||
// Checking only for the parent and one child, the remaining issue 404
|
||||
if (count($data) < 3) {
|
||||
$id = $data[1]; // Get real request page
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else { // Only parent page come
|
||||
if(empty($data[0])) {
|
||||
|
||||
$id = $defpage;
|
||||
|
||||
} else {
|
||||
|
||||
// Get current page
|
||||
$current_page = Pages::$pages->select('[slug="'.$data[0].'"]', null);
|
||||
|
||||
if (count($current_page) != 0) {
|
||||
if ($current_page['parent'] != '') {
|
||||
$c_p = $current_page['parent'];
|
||||
} else {
|
||||
$c_p = '';
|
||||
}
|
||||
} else {
|
||||
$c_p = '';
|
||||
}
|
||||
|
||||
// Check if this page has parent
|
||||
if ($c_p !== '') {
|
||||
if ($c_p == $data[0]) {
|
||||
if (count(Pages::$pages->select('[slug="'.$data[0].'"]', null)) != 0) {
|
||||
if (($current_page['status'] == 'published') or (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor')))) {
|
||||
$id = $data[0];
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else {
|
||||
if (count(Pages::$pages->select('[slug="'.$data[0].'"]', null)) != 0) {
|
||||
if (($current_page['status'] == 'published') or (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor')))) {
|
||||
$id = $data[0];
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
} else {
|
||||
$id = 'error404';
|
||||
Response::status(404);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return page name/id to load
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pages template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function template() {
|
||||
if (Pages::$page['template'] == '') return 'index'; else return Pages::$page['template'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pages contents
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function content() {
|
||||
return Text::toHtml(File::getContent(STORAGE . DS . 'pages' . DS . Pages::$page['id'] . '.page.txt'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pages title
|
||||
*
|
||||
* <code>
|
||||
* echo Page::title();
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function title() {
|
||||
return Pages::$page['title'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pages Description
|
||||
*
|
||||
* <code>
|
||||
* echo Page::description();
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function description() {
|
||||
return Pages::$page['description'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pages Keywords
|
||||
*
|
||||
* <code>
|
||||
* echo Page::keywords();
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function keywords() {
|
||||
return Pages::$page['keywords'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Page extends Pages {
|
||||
|
||||
|
||||
/**
|
||||
* Get date of current page
|
||||
*
|
||||
* <code>
|
||||
* echo Page::date();
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function date() {
|
||||
return Date::format(Pages::$page['date'], 'Y-m-d');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get author of current page
|
||||
*
|
||||
* <code>
|
||||
* echo Page::author();
|
||||
* </code>
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function author() {
|
||||
return Pages::$page['author'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get children pages for a specific parent page
|
||||
*
|
||||
* <code>
|
||||
* $pages = Page::children('page');
|
||||
* </code>
|
||||
*
|
||||
* @param string $parent Parent page
|
||||
* @return array
|
||||
*/
|
||||
public static function children($parent) {
|
||||
return Pages::$pages->select('[parent="'.(string)$parent.'"]', 'all');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the available children pages for requested page.
|
||||
*
|
||||
* <code>
|
||||
* echo Page::available();
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public static function available() {
|
||||
$pages = Pages::$pages->select('[parent="'.Pages::$requested_page.'"]', 'all');
|
||||
|
||||
// Display view
|
||||
View::factory('box/pages/views/frontend/available_pages')
|
||||
->assign('pages', $pages)
|
||||
->display();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get page breadcrumbs
|
||||
*
|
||||
* <code>
|
||||
* echo Page::breadcrumbs();
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public static function breadcrumbs() {
|
||||
$current_page = Pages::$requested_page;
|
||||
if ($current_page !== 'error404') {
|
||||
$page = Pages::$pages->select('[slug="'.$current_page.'"]', null);
|
||||
if (trim($page['parent']) !== '') {
|
||||
$parent = true;
|
||||
$parent_page = Pages::$pages->select('[slug="'.$page['parent'].'"]', null);
|
||||
} else {
|
||||
$parent = false;
|
||||
}
|
||||
|
||||
// Display view
|
||||
View::factory('box/pages/views/frontend/breadcrumbs')
|
||||
->assign('current_page', $current_page)
|
||||
->assign('page', $page)
|
||||
->assign('parent', $parent)
|
||||
->assign('parent_page', $parent_page)
|
||||
->display();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get page url
|
||||
*
|
||||
* <code>
|
||||
* echo Page::url();
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public static function url() {
|
||||
return Option::get('siteurl').Pages::$page['slug'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get page slug
|
||||
*
|
||||
* <code>
|
||||
* echo Page::slug();
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public static function slug() {
|
||||
return Pages::$page['slug'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get page meta robots
|
||||
*
|
||||
* <code>
|
||||
* echo Page::robots();
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public static function robots() {
|
||||
return (Pages::$page !== null) ? Pages::$page['robots_index'].', '.Pages::$page['robots_follow'] : '';
|
||||
}
|
||||
|
||||
}
|
133
plugins/box/pages/views/backend/add.view.php
Normal file
133
plugins/box/pages/views/backend/add.view.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<h2><?php echo __('New page', 'pages'); ?></h2>
|
||||
<br />
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
<?php if (isset($errors['pages_empty_name']) or isset($errors['pages_exists'])) $error_class1 = 'error'; else $error_class1 = ''; ?>
|
||||
<?php if (isset($errors['pages_empty_title'])) $error_class2 = 'error'; else $error_class2 = ''; ?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::open(null, array('class' => 'form-horizontal'))
|
||||
);
|
||||
?>
|
||||
|
||||
<?php echo (Form::hidden('csrf', Security::token())); ?>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::label('page_name', __('Name (slug)', 'pages'))
|
||||
);
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::input('page_name', $post_name, array('class' => 'span6'))
|
||||
);
|
||||
|
||||
if (isset($errors['pages_empty_name'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['pages_empty_name'].'</span>';
|
||||
if (isset($errors['pages_exists'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['pages_exists'].'</span>';
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Html::br(2).
|
||||
Form::label('page_title', __('Title', 'pages'))
|
||||
);
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::input('page_title', $post_title, array('class' => 'span6'))
|
||||
);
|
||||
if (isset($errors['pages_empty_title'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['pages_empty_title'].'</span>';
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Html::br(2).
|
||||
Form::label('page_description', __('Description', 'pages')).
|
||||
Form::input('page_description', $post_description, array('class' => 'span8')).
|
||||
Html::br(2).
|
||||
Form::label('page_keywords', __('Keywords', 'pages')).
|
||||
Form::input('page_keywords', $post_keywords, array('class' => 'span8'))
|
||||
);
|
||||
?>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<?php Action::run('admin_editor', array(Html::toText($post_content))); ?>
|
||||
|
||||
<br />
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span4">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('pages', __('Parent', 'pages')).
|
||||
Form::select('pages', $pages_array, $parent_page)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('templates', __('Template', 'pages')).
|
||||
Form::select('templates', $templates_array, $post_template)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('status', __('Status', 'pages')).
|
||||
Form::select('status', $status_array, 'published')
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8">
|
||||
<?php
|
||||
echo (
|
||||
Form::label(__('Published on', 'pages'), __('Published on', 'pages')).
|
||||
Form::input('year', $date[0], array('class' => 'input-mini')). ' ' .
|
||||
Form::input('month', $date[1], array('class' => 'input-mini')). ' ' .
|
||||
Form::input('day', $date[2], array('class' => 'input-mini')). ' <span style="color:gray;">@</span> '.
|
||||
Form::input('minute', $date[3], array('class' => 'input-mini')). ' : '.
|
||||
Form::input('second', $date[4], array('class' => 'input-mini'))
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('robots', __('Search Engines Robots', 'pages')).
|
||||
'no Index'.Html::nbsp().Form::checkbox('robots_index', 'index', $post_robots_index).Html::nbsp(2).
|
||||
'no Follow'.Html::nbsp().Form::checkbox('robots_follow', 'follow', $post_robots_follow)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::submit('add_page_and_exit', __('Save and exit', 'pages'), array('class' => 'btn')).Html::nbsp(2).
|
||||
Form::submit('add_page', __('Save', 'pages'), array('class' => 'btn')).
|
||||
Form::close()
|
||||
);
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
171
plugins/box/pages/views/backend/edit.view.php
Normal file
171
plugins/box/pages/views/backend/edit.view.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<h2>
|
||||
<?php
|
||||
if (Request::get('name') == 'error404') {
|
||||
echo __('Edit 404 page', 'pages');
|
||||
} else {
|
||||
echo __('Edit page', 'pages');
|
||||
}
|
||||
?>
|
||||
</h2>
|
||||
|
||||
<br />
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
<?php if (isset($errors['pages_empty_name'])) $error_class1 = 'error'; else $error_class1 = ''; ?>
|
||||
<?php if (isset($errors['pages_exists'])) $error_class1 = 'error'; else $error_class1 = ''; ?>
|
||||
<?php if (isset($errors['pages_empty_title'])) $error_class2 = 'error'; else $error_class2 = ''; ?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::open(null, array('class' => 'form-horizontal'))
|
||||
);
|
||||
?>
|
||||
|
||||
<?php echo (Form::hidden('csrf', Security::token())); ?>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::hidden('page_old_name', Request::get('name'))
|
||||
);
|
||||
if (Request::get('name') !== 'error404') {
|
||||
echo (
|
||||
Form::label('page_name', __('Name (slug)', 'pages'))
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
if (Request::get('name') == 'error404') {
|
||||
echo Form::hidden('page_name', $slug_to_edit);
|
||||
} else {
|
||||
echo (
|
||||
Form::input('page_name', $slug_to_edit, array('class' => 'span6'))
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($errors['pages_empty_name'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['pages_empty_name'].'</span>';
|
||||
if (isset($errors['pages_exists'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['pages_exists'].'</span>';
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Html::br(2).
|
||||
Form::label('page_title', __('Title', 'pages'))
|
||||
);
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::input('page_title', $title_to_edit, array('class' => 'span6'))
|
||||
);
|
||||
if (isset($errors['pages_empty_title'])) echo Html::nbsp(3).'<span style="color:red">'.$errors['pages_empty_title'].'</span>';
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Html::br(2).
|
||||
Form::label('page_description', __('Description', 'pages')).
|
||||
Form::input('page_description', $description_to_edit, array('class' => 'span8')).
|
||||
Html::br(2).
|
||||
Form::label('page_keywords', __('Keywords', 'pages')).
|
||||
Form::input('page_keywords', $keywords_to_edit, array('class' => 'span8')).
|
||||
Form::hidden('old_parent', $page['parent']).
|
||||
Form::hidden('page_id', $page['id'])
|
||||
);
|
||||
?>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<?php Action::run('admin_editor', array(Html::toText($to_edit))); ?>
|
||||
|
||||
<br />
|
||||
|
||||
<div class="row-fluid">
|
||||
<?php
|
||||
if (Request::get('name') == 'error404') {
|
||||
echo Form::hidden('pages', $parent_page);
|
||||
} else {
|
||||
?>
|
||||
<div class="span4">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('pages', __('Parent', 'pages')).
|
||||
Form::select('pages', $pages_array, $parent_page)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if (Request::get('name') != 'error404') { ?>
|
||||
<div class="span4">
|
||||
<?php } else { ?>
|
||||
<div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
echo (
|
||||
Form::label('templates', __('Template', 'pages')).
|
||||
Form::select('templates', $templates_array, $template)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
if(Request::get('name') == 'error404') {
|
||||
echo Form::hidden('status', $status);
|
||||
} else {
|
||||
?>
|
||||
<div class="span4">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('status', __('Status', 'pages')).
|
||||
Form::select('status', $status_array, $status)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span8">
|
||||
<?php
|
||||
echo (
|
||||
Form::label(__('Published on', 'pages'), __('Published on', 'pages')).
|
||||
Form::input('year', $date[0], array('class' => 'input-mini')). ' ' .
|
||||
Form::input('month', $date[1], array('class' => 'input-mini')). ' ' .
|
||||
Form::input('day', $date[2], array('class' => 'input-mini')). ' @ '.
|
||||
Form::input('minute', $date[3], array('class' => 'input-mini')). ' : '.
|
||||
Form::input('second', $date[4], array('class' => 'input-mini'))
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<?php
|
||||
echo (
|
||||
Form::label('robots', __('Search Engines Robots', 'pages')).
|
||||
'no Index'.Html::nbsp().Form::checkbox('robots_index', 'index', $post_robots_index).Html::nbsp(2).
|
||||
'no Follow'.Html::nbsp().Form::checkbox('robots_follow', 'follow', $post_robots_follow)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Form::submit('edit_page_and_exit', __('Save and exit', 'pages'), array('class' => 'btn')).Html::nbsp(2).
|
||||
Form::submit('edit_page', __('Save', 'pages'), array('class' => 'btn')).
|
||||
Form::close()
|
||||
);
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
91
plugins/box/pages/views/backend/index.view.php
Normal file
91
plugins/box/pages/views/backend/index.view.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<div class="row-fluid">
|
||||
|
||||
<div class="span12">
|
||||
|
||||
<h2><?php echo __('Pages', 'pages'); ?></h2>
|
||||
<br />
|
||||
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
|
||||
|
||||
<?php
|
||||
echo (
|
||||
Html::anchor(__('Create new page', 'pages'), 'index.php?id=pages&action=add_page', array('title' => __('Create new page', 'pages'), 'class' => 'btn default btn-small')). Html::nbsp(3).
|
||||
Html::anchor(__('Edit 404 page', 'pages'), 'index.php?id=pages&action=edit_page&name=error404', array('title' => __('Create new page', 'pages'), 'class' => 'btn default btn-small'))
|
||||
);
|
||||
?>
|
||||
|
||||
|
||||
<br /><br />
|
||||
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?php echo __('Name', 'pages'); ?></td>
|
||||
<td><?php echo __('Author', 'pages'); ?></td>
|
||||
<td><?php echo __('Status', 'pages'); ?></td>
|
||||
<td><?php echo __('Date', 'pages'); ?></td>
|
||||
<td width="40%"><?php echo __('Actions', 'pages'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (count($pages) != 0) {
|
||||
foreach ($pages as $page) {
|
||||
if ($page['parent'] != '') { $dash = Html::arrow('right').' '; } else { $dash = ""; }
|
||||
?>
|
||||
<?php if ($page['parent'] == '') $parent_style=''; else $parent_style = ''; ?>
|
||||
<?php if ($page['slug'] != 'error404') { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
if ($page['parent'] != '') {
|
||||
$parent = $page['parent'].'/';
|
||||
} else {
|
||||
$parent = '';
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if ($page['parent'] != '') echo ' ';
|
||||
?>
|
||||
<?php echo $dash.Html::anchor(Html::toText($page['title']), $site_url.$parent.$page['slug'], array('target' => '_blank')); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $page['author']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $page['status']; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo Date::format($page['date'], "j.n.Y"); ?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group">
|
||||
<?php echo Html::anchor(__('Edit', 'pages'), 'index.php?id=pages&action=edit_page&name='.$page['slug'], array('class' => 'btn btn-actions')); ?>
|
||||
<a class="btn dropdown-toggle btn-actions" data-toggle="dropdown" href="#" style="font-family:arial;"><span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php if ($page['parent'] == '') { ?>
|
||||
<li><a href="index.php?id=pages&action=add_page&parent_page=<?php echo $page['slug']; ?>" title="<?php echo __('Create new page', 'pages'); ?>"><?php echo __('Add', 'pages'); ?></a></li>
|
||||
<?php } ?>
|
||||
<li><?php echo Html::anchor(__('Clone', 'pages'), 'index.php?id=pages&action=clone_page&name='.$page['slug'], array('title' => __('Clone', 'pages'))); ?></li>
|
||||
</ul>
|
||||
<?php echo Html::anchor(__('Delete', 'pages'),
|
||||
'index.php?id=pages&action=delete_page&name='.$page['slug'],
|
||||
array('class' => 'btn btn-actions btn-actions-default', 'onclick' => "return confirmDelete('".__("Delete page: :page", 'pages', array(':page' => Html::toText($page['title'])))."')"));
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,5 @@
|
||||
<ul>
|
||||
<?php foreach ($pages as $page) { ?>
|
||||
<li><a href="<?php echo $page['parent'].'/'.$page['slug']; ?>"><?php echo $page['title']; ?></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
5
plugins/box/pages/views/frontend/breadcrumbs.view.php
Normal file
5
plugins/box/pages/views/frontend/breadcrumbs.view.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php if ($parent) { ?>
|
||||
<a href="<?php echo Site::url().$page['parent']; ?>"><?php echo $parent_page['title']; ?></a> <span>→</span> <a href="<?php echo Site::url().$page['parent'].'/'.$page['slug']; ?>"><?php echo $page['title']; ?></a>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo Site::url().$page['slug']; ?>"><?php echo $page['title']; ?></a>
|
||||
<?php } ?>
|
Reference in New Issue
Block a user