protected function initPage() { // If no page id, we have a problem $page_id = $this->getRequest()->getParam("pid"); // If the page does not exist, we have a problem $pages = new Pages(); if ($page = $pages->getPage($page_id)) { $this->_page = $page; } // get the page properties if ($page) { $this->_page_properties = new PagesProperties(array(PagesProperties::KEY => $page['id'])); $this->view->page_id = $this->_page['id']; $this->view->page_title = $this->_page['title']; } else { $this->view->page_id = false; } // Get the tab for further use if ($tab = (int) $this->getRequest()->getParam("tab")) { $this->view->tab = $tab; } // Prepare the view $this->_helper->layout->setLayoutPath($this->_root . '/application/public/views/layouts/')->setlayout('default'); $this->view->page_class = $this->_prefix; }
public function listAction() { $pages = new Pages($this->getSiteId()); foreach ($this->existConstants as $key => $const) { if ($const['c_name'] == 'un404page' || $const['c_name'] == 'loginPage') { $page = $pages->getPage($const['c_value']); $this->existConstants[$key]['c_value'] = $page->address['uri_address']; } } $this->tplVars['consts']['consts'] = $this->existConstants; array_push($this->tplVars['page_css'], 'pages.css'); array_push($this->viewIncludes, 'constants/listConstants.tpl'); }
public function editAction() { if ($this->_hasParam('id')) { $pageId = $this->_getParam('id'); $content = new Content($this->getSiteId(), $pageId); $pages = new Pages($this->getSiteId()); $page = $pages->getPage($pageId); $html = ''; $this->renderBlocksHTML($content, $html); // $this->tplVars['page_js'][] = 'tiny_mce/tiny_mce.js'; $this->tplVars['page_js'][] = 'jquery-1.8.3.js'; //italiano, 21/09/2015 $this->tplVars['page_js'][] = 'colorbox.js'; $this->tplVars['page_js'][] = 'jquery.scroll.js'; $this->tplVars['page_js'][] = 'content.js'; $this->tplVars['page_js'][] = 'jquery.filetree.js'; $this->tplVars['page_js'][] = 'jquery.dimensions.js'; $this->tplVars['page_js'][] = 'browser.js'; $this->tplVars['page_js'][] = 'ui.core.min.js'; $this->tplVars['page_js'][] = 'ui.draggable.min.js'; $this->tplVars['page_js'][] = 'ui.droppable.min.js'; $this->tplVars['page_css'][] = 'browser.css'; $this->tplVars['page_css'][] = 'jquery_file_tree.css'; $this->tplVars['page_css'][] = 'colorbox.css'; $this->tplVars['content']['siteHostname'] = $this->getNCSiteHostname(); $this->tplVars['content']['pageAddress'] = $page->address['uri_address']; $this->tplVars['content']['pageId'] = $pageId; $this->tplVars['content']['cached'] = $content->chekingCacheFile($page->address['uri_address']); $this->tplVars['content']['blocksList'] = $html; $this->tplVars['header']['actions']['names'][] = array('name' => 'params', 'menu_name' => 'Edit page', 'params' => array('id' => $pageId)); $this->tplVars['header']['actions']['names'][] = array('name' => 'meta', 'menu_name' => 'Edit page meta', 'params' => array('id' => $pageId)); $this->tplVars['header']['actions']['names'][] = array('name' => 'edit', 'menu_name' => 'Edit content', 'params' => array('id' => $pageId)); array_push($this->viewIncludes, 'content/blocks/blocksList.tpl'); } }
<?php /** * Breadcrumb Plugin * Based on idea from https://github.com/tovic/breadcrumb-plugin-for-fansoro-cms * * @package Fansoro * @subpackage Plugins * @author Pavel Belousov / pafnuty * @version 1.1.0 * @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-breadcrumb/blob/master/LICENSE MIT */ Action::add('breadcrumb', function () { // Configuration data $config = Config::get('plugins.breadcrumb'); // Get current URI segments $paths = Url::getUriSegments(); // Count total paths $total_paths = count($paths); // Path lifter $lift = ''; // Breadcrumb's data $data = []; for ($i = 0; $i < $total_paths; $i++) { $lift .= '/' . $paths[$i]; $page = Pages::getPage(file_exists(STORAGE_PATH . '/pages/' . $lift . '/index.md') || file_exists(STORAGE_PATH . '/pages/' . $lift . '.md') ? $lift : '404'); $data[Url::getBase() . $lift] = ['title' => $page['title'], 'current' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase() . $lift, '/')]; } $template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme')); $template->display('/plugins/breadcrumb/breadcrumb.tpl', ['home' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase(), '/') ? true : Url::getBase(), 'config' => $config, 'branch' => $data]); });
* Template: api.tpl * Link blog: api?action=blog * link by page:api?action=contact */ Action::add('Api', function () { //print_r(json_encode(Config::getConfig(),true)); if (Request::get('type')) { cors(); Request::setHeaders('Content-Type: application/json; charset=' . Config::get('system.charset')); $result = ''; switch (Request::get('type')) { case 'page': // api?type=page&name=blog/hello get all if (Request::get('name')) { // get page name $p = @Pages::getPage(Request::get('name')); $title = isset($p['title']) ? $p['title'] : ''; $date = isset($p['date']) ? $p['date'] : ''; $slug = isset($p['slug']) ? $p['slug'] : ''; $url = isset($p['url']) ? $p['url'] : ''; $tag = isset($p['tag']) ? $p['tag'] : ''; $thumbnail = isset($p['thumbnail']) ? $p['thumbnail'] : ''; $template = isset($p['template']) ? $p['template'] : ''; $summary = isset($p['summary']) ? $p['summary'] : ''; $content = isset($p['content']) ? $p['content'] : ''; $keywords = isset($p['keywords']) ? $p['keywords'] : ''; $description = isset($p['description']) ? $p['description'] : ''; // api?type=page&name=blog/hello&filter=title get only title if (Request::get('filter')) { switch (Request::get('filter')) { // api?type=page&name=blog/hello&filter=title
public function deleteAction() { // Get, check and setup the parameters $page_id = $this->getRequest()->getParam("id"); // Do we own the page ? $pages = new Pages(); if (!($page = $pages->getPage($page_id))) { throw new Stuffpress_Exception("Unknown page with id {$page_id}"); } if ($page['user_id'] != $this->_application->user->id) { throw new Stuffpress_AccessDeniedException("Not the owner of page {$page_id}"); } $pages->deletePage($page_id); // Delete the page properties $properties = new PagesProperties(array(Properties::KEY => $page_id)); $properties->deleteAllProperties(); return $this->_helper->json->sendJson(false); }