<?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(__('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')) == '') {
<?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.');
            }