Example #1
0
 /**
  * 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');
 }
Example #2
0
 public function setSaved()
 {
     if (!PageSmith::checkLorum($this->content)) {
         $_SESSION['PS_Page'][$this->pid][$this->secname] =& $this->content;
     }
 }