public function __construct($tpl_name) { $this->name = $tpl_name; $this->dir = PageSmith::pageTplDir() . $this->name; $this->file = $this->dir . '/structure.xml'; $this->page_path = sprintf('page_templates/%s/', $this->name); if (!is_file($this->file)) { return; } $this->loadTemplate($tpl_name); }
/** * Displays the page layout and lets user enter text fields, blocks, etc. */ public function pageLayout() { javascript('jquery'); javascript('jquery_ui'); javascript('ckeditor'); Layout::addStyle('pagesmith', 'admin.css'); Layout::addJSHeader('<script type="text/javascript" src="' . PHPWS_SOURCE_HTTP . 'mod/pagesmith/javascript/pageedit/script.js"></script>', 'pageedit'); Layout::addStyle('pagesmith'); $page = $this->ps->page; $pg_tpl_name =& $page->_tpl->name; $this->ps->killSaved($page->id); if (!empty($page->_content)) { foreach ($page->_content as $key => $cnt) { if (!PageSmith::checkLorum($cnt)) { $_SESSION['PS_Page'][$page->id][$key] = $cnt; } } } $form = new PHPWS_Form('pagesmith'); $form->addHidden('module', 'pagesmith'); $form->addHidden('aop', 'post_page'); $form->addHidden('tpl', $page->template); $form->addHidden('pid', $page->parent_page); $template_list = $this->ps->getTemplateList(); $form->addSelect('template_list', $template_list); $form->setMatch('template_list', $page->template); $form->addSubmit('change_tpl', dgettext('pagesmith', 'Change template')); if ($page->id) { $form->addHidden('id', $page->id); } if (empty($page->_tpl) || $page->_tpl->error) { $this->ps->content = dgettext('pagesmith', 'Unable to load page template.'); return; } $form->addSubmit('submit', dgettext('pagesmith', 'Save page')); $form->setClass('submit', 'btn btn-success'); $page->loadKey(); if ($page->_key->id && $page->_key->show_after) { $publish_date = $page->_key->show_after; } else { $publish_date = time(); } $this->pageTemplateForm($form); $tpl = $form->getTemplate(); $tpl['PUBLISH_DATE_LABEL'] = 'Show page after this date and time'; $tpl['PUBLISH_VALUE'] = strftime('%Y-%m-%dT%H:%M:%S', $publish_date); $tpl['PAGE_TITLE'] = $page->title; $jsvars['page_title_input'] = 'pagesmith_title'; $jsvars['page_title_id'] = sprintf('%s-page-title', $pg_tpl_name); javascriptMod('pagesmith', 'pagetitle', $jsvars); $tpl['HIDE_CHECK'] = $page->hide_title ? 'checked="checked"' : null; if (!empty($page->_orphans)) { $tpl['ORPHAN_LINK'] = sprintf('<a href="%s#orphans">%s</a>', PHPWS_Core::getCurrentUrl(), dgettext('pagesmith', 'Orphans')); $tpl['ORPHANS'] = $this->listOrphans($page->_orphans); } // We wrap the textarea in a form just so ckeditor will allow use of the "Save" button. $modal = new \Modal('edit-section', '<form><textarea id="block-edit-textarea"></textarea></form>', dgettext('pagesmith', 'Edit text area')); $modal->addButton('<button id="save-page" class="btn btn-success">' . dgettext('pagesmith', 'Save') . '</button>'); $modal->setWidthPercentage(90); $tpl['CONTENT_MODAL'] = $modal->__toString(); $title_modal = new \Modal('edit-title', '<input class="form-control" type="text" id="page-title-input" name="page_title" value="" />', dgettext('pagesmith', 'Edit page title')); $title_modal->addButton('<button id="save-title" class="btn btn-success">' . dgettext('pagesmith', 'Save') . '</button>'); $tpl['TITLE_MODAL'] = $title_modal->__toString(); $this->ps->content = PHPWS_Template::process($tpl, 'pagesmith', 'page_form.tpl'); }
public function setSaved() { if (!PageSmith::checkLorum($this->content)) { $_SESSION['PS_Page'][$this->pid][$this->secname] =& $this->content; } }
private function pageLinks(&$tpl) { $db = new PHPWS_DB('ps_page'); if (version_compare(\PageSmith::getVersion(), '1.10.0', '>=')) { $db->addWhere('deleted', 0); } $db->addColumn('id'); $db->addColumn('page_order'); $db->setIndexBy('page_order'); $db->addOrder('page_order asc'); if ($this->parent_page) { $db->addWhere('id', $this->parent_page); $db->addWhere('parent_page', $this->parent_page, null, 'or'); } else { $db->addWhere('parent_page', $this->id); } $pages = $db->select('col'); if (PHPWS_Error::logIfError($pages) || empty($pages)) { return; } if (!$this->parent_page) { array_unshift($pages, $this->id); } if ($this->page_order) { $prev_page = $pages[$this->page_order - 1]; } else { $prev_page = 0; } foreach ($pages as $page_no => $id) { if ($page_no == 0 && $prev_page) { $link = new PHPWS_Link('<span><<</span> ' . dgettext('pagesmith', 'Previous'), 'pagesmith', array('id' => $prev_page)); $links[] = $link->get(); } if ($id == $this->id) { $links[] = $page_no + 1; if (isset($pages[$page_no + 1])) { $next_page = $pages[$page_no + 1]; } else { $next_page = null; } } else { $link = new PHPWS_Link($page_no + 1, 'pagesmith', array('id' => $id)); $link->setRewrite(); $links[] = $link->get(); } } if ($next_page) { $link->setLabel(dgettext('pagesmith', 'Next') . ' <span>>></span>'); $link->setValue('id', $next_page); $links[] = $link->get(); } $tpl['PAGE_LINKS'] = implode(' | ', $links); }
<?php /** * @version $Id$ * @author Matthew McNaney <mcnaney at gmail dot com> */ if (!defined('PHPWS_SOURCE_DIR')) { include '../../core/conf/404.html'; exit; } PHPWS_Core::initModClass('pagesmith', 'PageSmith.php'); $pageSmith = new PageSmith(); if (isset($_REQUEST['uop'])) { $pageSmith->user(); } elseif (isset($_REQUEST['aop'])) { $pageSmith->admin(); } elseif (!empty($_GET['id'])) { $pageSmith->viewPage(); } else { PHPWS_Core::errorPage('404'); }