Exemplo n.º 1
0
 function test_adding_node()
 {
     $n = new Navigation();
     $blog_node = (object) array('data' => 'Blog', 'attr' => (object) array('id' => 'blog', 'sort' => 0));
     /**
      * Add blog page.
      */
     $n->add($blog_node, 'index');
     /**
      * Should have second id now:
      *
      * index
      * - blog
      */
     $this->assertEquals($n->get_all_ids(), array('index', 'blog'));
     // Remove and re-add index
     $n->remove('index');
     $this->assertEquals($n->get_all_ids(), array());
     $n->add('index');
     $index_node = $n->node('index');
     $expected_index = (object) array('data' => 'Home', 'attr' => (object) array('id' => 'index', 'sort' => 0));
     /*
      * Should have index node with title 'Home' from the database.
      */
     $this->assertEquals($expected_index, $index_node);
 }
Exemplo n.º 2
0
 public function testNavOverwrite()
 {
     $defaults = Navigation::getDefaults();
     Hash::merge($defaults, array('title' => 'Permissions', 'url' => array('admin' => true, 'plugin' => 'acl', 'controller' => 'acl_permissions', 'action' => 'index'), 'weight' => 30));
     $item = array('title' => 'Permissions', 'url' => array('admin' => true, 'plugin' => 'acl_extras', 'controller' => 'acl_extras_permissions', 'action' => 'index'), 'weight' => 30);
     Navigation::add('users.children.permissions', $item);
     $items = Navigation::items();
     $expected = Hash::merge($defaults, array('title' => 'Permissions', 'url' => array('admin' => true, 'plugin' => 'acl_extras', 'controller' => 'acl_extras_permissions', 'action' => 'index'), 'weight' => 30));
     $this->assertEquals($expected, $items['users']['children']['permissions']);
 }
 public function createComponentNavigation($name)
 {
     $navigation = new Navigation();
     // nastavení překladače (nepovinné)
     $navigation->setTranslator(new MyTranslator());
     // nastavení šablony (nepovinné)
     $navigation->setTemplate('/cesta/k/sablone.phtml');
     $navigation->getRoot()->label = 'Homepage';
     $navigation->add('Articles', $this->link('Articles:default'));
 }
Exemplo n.º 4
0
 public function controllerConstructClasses(CakeEvent $Event)
 {
     $Event->result['components'][] = 'RequestHandler';
     $default = array('plugin' => 'webmaster', 'controller' => 'webmaster', 'action' => 'robots');
     $link = sprintf('<a href="%s">%s</a>', Router::url($default), __d('webmaster', "Create it now"));
     $filename = '`robots.txt`';
     $Event->result = Hash::merge((array) $Event->result, array('alertMessages' => array('robots.success' => array('message' => __d('webmaster', "Your %s file was successfully updated.", $filename), 'redirect' => Router::url(array_merge($default, array('action' => 'dashboard')))), 'robots.fail' => array('message' => __d('webmaster', "There was a problem updating your %s file", $filename), 'level' => 'error'), 'robots.exists' => array('message' => __d('webmaster', "A %s was already manually created in your application's webroot. " . "To dynamically manage it, you will need to delete it first.", $filename), 'level' => 'error', 'redirect' => true, 'dismiss' => true), 'robots.invalid' => array('message' => __d('webmaster', "Your %s file does not exist. %s.", $filename, $link), 'level' => 'warning', 'redirect' => null, 'dismiss' => true))));
     Navigation::add('Admin.webmaster', array('access' => 'User.admin', 'title' => __d('webmaster', "Webmaster"), 'url' => array('plugin' => 'webmaster', 'controller' => 'webmaster', 'action' => 'index', 'prefix' => 'admin', 'admin' => true), 'weight' => 9090));
     Navigation::add('Admin.webmaster.children.manage_robots', array('access' => 'User.admin', 'title' => __d('webmaster', "Manage Robots"), 'url' => array('plugin' => 'webmaster', 'controller' => 'webmaster', 'action' => 'robots', 'prefix' => 'admin', 'admin' => true), 'weight' => 1000));
     Navigation::add('Admin.webmaster.children.robots', array('access' => 'User.admin', 'title' => __d('webmaster', "Preview Robots"), 'url' => Router::url('/robots.txt', true), 'weight' => 2000, 'htmlAttributes' => array('a' => array('target' => '_blank'))));
     Navigation::add('Admin.webmaster.children.sitemap', array('access' => 'User.admin', 'title' => __d('webmaster', "Preview Sitemap"), 'url' => Router::url('/sitemap.xml', true), 'weight' => 3000, 'htmlAttributes' => array('a' => array('target' => '_blank'))));
 }
Exemplo n.º 5
0
 *	Toggle plugin admin
 *  http://api.jquery.com/slidetoggle
 *
 *  Generates content, that slide-toggles further content on click.
 *
 *	@package    Monstra
 *  @subpackage Plugins
 *	@author     Andreas Müller | devmount <*****@*****.**>
 *	@license    MIT
 *  @link       https://github.com/devmount-monstra/toggle
 *
 */
// Add plugin styles and scripts
Javascript::add('plugins/toggle/js/toggle.admin.js', 'backend', 11);
// Admin Navigation: add new item to 'extends' section
Navigation::add(__('Toggle', 'toggle'), 'extends', 'toggle', 10);
/**
 * Toggle class
 * 
 */
class ToggleAdmin extends Backend
{
    /**
     * main toggle admin function
     */
    public static function main()
    {
        // handle option form submit
        if (Request::post('toggle_options')) {
            if (Security::check(Request::post('csrf'))) {
                Option::update('toggle_duration', (int) Request::post('toggle_duration'));
<?php

// Add plugin navigation link
Navigation::add(__('Snippets', 'snippets'), 'extends', 'snippets', 3);
Dashboard::addNewItem('snippets', __('Snippets', 'snippets'), 'index.php?id=snippets&action=add_snippet', 3);
/**
 * Snippets Admin Class
 */
class SnippetsAdmin extends Backend
{
    /**
     * Snippets admin function
     */
    public static function main()
    {
        // Init vars
        $snippets_path = STORAGE . DS . 'snippets' . DS;
        $snippets_list = array();
        $errors = array();
        // Check for get actions
        // -------------------------------------
        if (Request::get('action')) {
            // Switch actions
            // -------------------------------------
            switch (Request::get('action')) {
                // Add snippet
                // -------------------------------------
                case "add_snippet":
                    if (Request::post('add_snippets') || Request::post('add_snippets_and_exit')) {
                        if (Security::check(Request::post('csrf'))) {
                            if (trim(Request::post('name')) == '') {
Exemplo n.º 7
0
    header('WWW-Authenticate: Basic realm="Navigation"');
    header('HTTP/1.0 401 Unauthorized');
    echo json_encode($res);
    return;
}
$error = false;
$out = null;
$nav = new Navigation();
switch ($this->params[0]) {
    case 'add':
        $id = $_POST['page'];
        $parent = $_POST['parent'];
        if ($parent === 'false') {
            $parent = false;
        }
        if ($nav->add($id, $parent) && $nav->save()) {
            $out = array('msg' => sprintf('Page %s added to tree under %s.', $id, $parent), 'page' => $id, 'parent' => $parent);
        } else {
            $error = $nav->error;
        }
        break;
    case 'move':
        $id = $_POST['page'];
        $ref = $_POST['ref'];
        $pos = $_POST['pos'];
        if ($nav->move($id, $ref, $pos) && $nav->save()) {
            $out = array('msg' => sprintf('Page %s moved to %s %s.', $id, $pos, $ref), 'page' => $id, 'ref' => $ref, 'pos' => $pos);
        } else {
            $error = $nav->error;
        }
        break;
<?php

// Add plugin navigation link
Navigation::add(__('Blocks', 'blocks'), 'content', 'blocks', 2);
Dashboard::addNewItem('blocks', __('Blocks', 'blocks'), 'index.php?id=blocks&action=add_block', 2);
/**
 * Blocks Admin Class
 */
class BlocksAdmin extends Backend
{
    /**
     * Blocks admin function
     */
    public static function main()
    {
        // Init vars
        $blocks_path = STORAGE . DS . 'blocks' . DS;
        $blocks_list = array();
        $errors = array();
        // Check for get actions
        // -------------------------------------
        if (Request::get('action')) {
            // Switch actions
            // -------------------------------------
            switch (Request::get('action')) {
                // Add block
                // -------------------------------------
                case "add_block":
                    if (Request::post('add_blocks') || Request::post('add_blocks_and_exit')) {
                        if (Security::check(Request::post('csrf'))) {
                            if (trim(Request::post('name')) == '') {
<?php

// Add plugin navigation link
Navigation::add(__('Information', 'information'), 'system', 'information', 6);
/**
 * Information Admin Class
 */
class InformationAdmin extends Backend
{
    /**
     * Information main function
     */
    public static function main()
    {
        // Init vars
        $php_modules = array();
        // Get array with the names of all modules compiled and loaded
        $php_modules = get_loaded_extensions();
        // Display view
        View::factory('box/information/views/backend/index')->assign('php_modules', $php_modules)->display();
    }
}
<?php

Stylesheet::add('plugins/box/filesmanager/css/style.css', 'backend', 11);
Javascript::add('plugins/box/filesmanager/js/fileuploader.js', 'backend', 11);
Javascript::add('plugins/box/plugins/js/plugins.js', 'backend', 11);
// Add plugin navigation link
Navigation::add(__('Plugins', 'plugins'), 'extends', 'plugins', 1);
// Add action on admin_pre_render hook
Action::add('admin_pre_render', 'PluginsAdmin::_readmeLoadAjax');
/**
 * Plugins Admin
 */
class PluginsAdmin extends Backend
{
    /**
     * Plugins admin
     */
    public static function main()
    {
        // Get siteurl
        $site_url = Option::get('siteurl');
        // Get installed plugin from $plugins array
        $installed_plugins = Plugin::$plugins;
        // Get installed users plugins
        $_users_plugins = array();
        foreach (Plugin::$plugins as $plugin) {
            if ($plugin['privilege'] !== 'box') {
                $_users_plugins[] = $plugin['id'];
            }
        }
        // Get plugins table
Exemplo n.º 11
0
 *
 *	@package    Monstra
 *  @subpackage Plugins
 *	@author     Andreas Müller | devmount <*****@*****.**>
 *	@license    MIT
 *  @link       https://github.com/devmount-monstra/events
 *
 */
// Add plugin styles and scripts
Stylesheet::add('plugins/events/css/events.admin.css', 'backend', 11);
Javascript::add('plugins/events/js/events.admin.js', 'backend', 11);
// lib: Image Picker http://rvera.github.io/image-picker/
Stylesheet::add('plugins/events/lib/image-picker/image-picker.css', 'backend', 11);
Javascript::add('plugins/events/lib/image-picker/image-picker.js', 'backend', 11);
// Admin Navigation: add new item
Navigation::add(__('Events', 'events'), 'content', 'events', 10);
// Add action on admin_pre_render hook
Action::add('admin_pre_render', 'EventsAdmin::_getAjaxData');
// register repository classes
require_once 'repositories/repository.events.php';
require_once 'repositories/repository.categories.php';
require_once 'repositories/repository.locations.php';
/**
 * Events class
 *
 */
class EventsAdmin extends Backend
{
    /**
     * Ajax: get Event by ID
     */
Exemplo n.º 12
0
<?php

// Add plugin navigation link
Navigation::add(__('Themes', 'themes'), 'extends', 'themes', 2);
/**
 * Themes Admin Class
 */
class ThemesAdmin extends Backend
{
    /**
     * Themes plugin admin
     */
    public static function main()
    {
        // Get current themes
        $current_site_theme = Option::get('theme_site_name');
        $current_admin_theme = Option::get('theme_admin_name');
        // Init vars
        $themes_site = Themes::getSiteThemes();
        $themes_admin = Themes::getAdminThemes();
        $templates = Themes::getTemplates();
        $chunks = Themes::getChunks();
        $styles = Themes::getStyles();
        $scripts = Themes::getScripts();
        $errors = array();
        $chunk_path = THEMES_SITE . DS . $current_site_theme . DS;
        $template_path = THEMES_SITE . DS . $current_site_theme . DS;
        $style_path = THEMES_SITE . DS . $current_site_theme . DS . 'css' . DS;
        $script_path = THEMES_SITE . DS . $current_site_theme . DS . 'js' . DS;
        // Save site theme
        if (Request::post('save_site_theme')) {
Exemplo n.º 13
0
<?php

// Add plugin navigation link
Navigation::add(__('Backups', 'backup'), 'system', 'backup', 3);
/**
 * Backup Admin Class
 */
class BackupAdmin extends Backend
{
    /**
     * Backup admin
     */
    public static function main()
    {
        $backups_path = ROOT . DS . 'backups';
        // Create backup
        // -------------------------------------
        if (Request::post('create_backup')) {
            if (Security::check(Request::post('csrf'))) {
                @set_time_limit(0);
                @ini_set("memory_limit", "512M");
                $zip = Zip::factory();
                // Add storage folder
                $zip->readDir(STORAGE . DS, false);
                // Add public folder
                $zip->readDir(ROOT . DS . 'public' . DS, false);
                // Add plugins folder
                $zip->readDir(PLUGINS . DS, false, null, array(PLUGINS . DS . 'box'));
                if ($zip->archive($backups_path . DS . Date::format(time(), "Y-m-d-H-i-s") . '.zip')) {
                    Notification::set('success', __('Backup was created', 'backup'));
                } else {
Exemplo n.º 14
0
<?php

// Add plugin navigation link
Navigation::add(__('Slider', 'slider'), 'content', 'slider', 4);
/**
 * Slider Admin Class
 */
class SliderAdmin extends Backend
{
    /**
     * Slider table
     *
     * @var object
     */
    public static $slider = null;
    /**
     * Main
     */
    public static function main()
    {
        // Get slider table
        SliderAdmin::$slider = new Table('slider');
        // Get pages table
        $pages = new Table('pages');
        // Create target array
        $slider_item_target_array = array('' => '', '_blank' => '_blank', '_parent' => '_parent', '_top' => '_top');
        // Create order array
        $slider_item_order_array = range(0, 40);
        // Check for get actions
        // ---------------------------------------------
        if (Request::get('action')) {
Exemplo n.º 15
0
<?php

// Add plugin navigation link
Navigation::add(__('Users', 'users'), 'system', 'users', 2);
/**
 * Users Admin Class
 */
class UsersAdmin extends Backend
{
    /**
     * Users admin
     */
    public static function main()
    {
        // Users roles
        $roles = array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users'));
        // Get uses table
        $users = new Table('users');
        if (Option::get('users_frontend_registration') === 'true') {
            $users_frontend_registration = true;
        } else {
            $users_frontend_registration = false;
        }
        if (Request::post('users_frontend_submit')) {
            if (Security::check(Request::post('csrf'))) {
                if (Request::post('users_frontend_registration')) {
                    $users_frontend_registration = 'true';
                } else {
                    $users_frontend_registration = 'false';
                }
                if (Option::update('users_frontend_registration', $users_frontend_registration)) {
<?php

// Add Plugin Javascript
Stylesheet::add('plugins/box/filesmanager/css/style.css', 'backend', 11);
Javascript::add('plugins/box/filesmanager/js/fileuploader.js', 'backend', 11);
Javascript::add('plugins/box/filesmanager/js/filesmanager.js', 'backend', 11);
// Add plugin navigation link
Navigation::add(__('Files', 'filesmanager'), 'content', 'filesmanager', 3);
/**
 * Filesmanager Admin Class
 */
class FilesmanagerAdmin extends Backend
{
    /**
     * Main function
     */
    public static function main()
    {
        // Array of forbidden types
        $forbidden_types = array('html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'shtml', 'jhtml', 'pl', 'py', 'cgi', 'sh', 'ksh', 'bsh', 'c', 'htaccess', 'htpasswd', 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl', 'empty');
        // Array of image types
        $image_types = array('jpg', 'png', 'bmp', 'gif', 'tif');
        // Get Site url
        $site_url = Option::get('siteurl');
        // Init vars
        if (Request::get('path')) {
            $path = Request::get('path');
        } else {
            $path = 'uploads/';
        }
        // Add slash if not exists
<?php

$objNavigation = new Navigation($this->objLanguage);
$call = $this->objUrl->get('call');
if (!empty($call)) {
    switch ($call) {
        case 'add':
            $message = '<div class="confirmation confirmation-warning">';
            $message .= $this->objLanguage->labels[65];
            $message .= '</div>';
            if ($_POST && !empty($_POST['type']) && !empty($_POST['page'])) {
                $type = $_POST['type'];
                $page = $_POST['page'];
                if ($objNavigation->add($type, $page)) {
                    $message = '<div class="confirmation">';
                    $message .= $this->objLanguage->labels[66];
                    $message .= '</div>';
                }
            }
            echo json_encode(array('message' => $message));
            break;
        case 'order':
            $array = $_POST['rows'];
            if (!empty($array)) {
                $error = array();
                $list = explode("&", $array);
                $out = array();
                if (!empty($list)) {
                    foreach ($list as $row) {
                        $element = explode("=", $row);
                        if (!empty($element)) {
Exemplo n.º 18
0
<?php

// Add plugin navigation link
Navigation::add(__('Pages', 'pages'), 'content', 'pages', 1);
Dashboard::addNewItem('pages', __('Page', 'pages'), 'index.php?id=pages&action=add_page', 1);
// Add action on admin_pre_render hook
Action::add('admin_pre_render', 'PagesAdmin::_pageExpandAjax');
/**
 * Pages Admin Class
 */
class PagesAdmin extends Backend
{
    /**
     * Pages tables
     *
     * @var object
     */
    public static $pages = null;
    /**
     * _pageExpandAjax
     */
    public static function _pageExpandAjax()
    {
        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')));
                Request::shutdown();
            } else {
                die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
            }
<?php

// Admin Navigation: add new item
Navigation::add(__('Sandbox', 'sandbox'), 'content', 'sandbox', 10);
// Add actions
Action::add('admin_themes_extra_index_template_actions', 'SandboxAdmin::formComponent');
Action::add('admin_themes_extra_actions', 'SandboxAdmin::formComponentSave');
/**
 * Sandbox admin class
 */
class SandboxAdmin extends Backend
{
    /**
     * Main Sandbox admin function
     */
    public static function main()
    {
        //
        // Do something here...
        //
        // Check for get actions
        // -------------------------------------
        if (Request::get('action')) {
            // Switch actions
            // -------------------------------------
            switch (Request::get('action')) {
                // Plugin action
                // -------------------------------------
                case "add":
                    //
                    // Do something here...
Exemplo n.º 20
0
<?php

// Add plugin navigation link
Navigation::add(__('Menu', 'menu'), 'content', 'menu', 4);
/**
 * Menu Admin Class
 */
class MenuAdmin extends Backend
{
    /**
     * Menu table
     *
     * @var object
     */
    public static $menu = null;
    /**
     * Main
     */
    public static function main()
    {
        // Get menu table
        MenuAdmin::$menu = new Table('menu');
        // Get pages table
        $pages = new Table('pages');
        // Create target array
        $menu_item_target_array = array('' => '', '_blank' => '_blank', '_parent' => '_parent', '_top' => '_top');
        // Create order array
        $menu_item_order_array = range(0, 40);
        // Check for get actions
        // ---------------------------------------------
        if (Request::get('action')) {
Exemplo n.º 21
0
<?php

// Admin Navigation: add new item
Navigation::add(__('Emails', 'emails'), 'system', 'emails', 5);
/**
 * Emails admin class
 */
class EmailsAdmin extends Backend
{
    /**
     * Main Emails admin function
     */
    public static function main()
    {
        // Init vars
        $email_templates_path = STORAGE . DS . 'emails' . DS;
        $email_templates_list = array();
        // Check for get actions
        // -------------------------------------
        if (Request::get('action')) {
            // Switch actions
            // -------------------------------------
            switch (Request::get('action')) {
                // Plugin action
                // -------------------------------------
                case "edit_email_template":
                    if (Request::post('edit_email_template') || Request::post('edit_email_template_and_exit')) {
                        if (Security::check(Request::post('csrf'))) {
                            // Save Email Template
                            File::setContent(STORAGE . DS . 'emails' . DS . Request::post('email_template_name') . '.email.php', Request::post('content'));
                            Notification::set('success', __('Your changes to the email template <i>:name</i> have been saved.', 'emails', array(':name' => Request::post('email_template_name'))));
<?php

/**
 *	System plugin
 *
 *	@package Monstra
 *  @subpackage Plugins
 *	@author Romanenko Sergey / Awilum
 *	@copyright 2012-2014 Romanenko Sergey / Awilum
 *	@version 1.0.0
 *
 */
// Register plugin
Plugin::register(__FILE__, __('System', 'system'), __('System plugin', 'system'), '1.0.0', 'Awilum', 'http://monstra.org/', null, 'box');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
    // Admin top navigation
    Navigation::add(__('Welcome, :username', 'system', array(':username' => Session::get('user_login'))), 'top', 'users&action=edit&user_id=' . Session::get('user_id'), 1, Navigation::TOP, false);
    Navigation::add(__('View Site', 'system'), 'top', Option::get('siteurl'), 2, Navigation::TOP, true);
    Navigation::add(__('Log Out', 'users'), 'top', '&logout=do', 3, Navigation::TOP, false);
    if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
        Navigation::add(__('Settings', 'system'), 'system', 'system', 1);
    }
}
Plugin::Admin('system', 'box');