Exemplo n.º 1
0
function pagesmith_install(&$content)
{
    PHPWS_Core::initModClass('pagesmith', 'PS_Page.php');
    PHPWS_Core::initModClass('pagesmith', 'PS_Text.php');
    $page = new PS_Page();
    $page->setTitle('Welcome to phpWebSite!');
    $page->template = 'text_only';
    $page->front_page = 1;
    $page->save();
    $section = new PS_Text();
    $section->pid = $page->id;
    $section->content = '<p>Thank you for installing phpWebSite.
	Its developers hope you enjoy it.</p><p>
	The page you are reading was created under
	<a href="./index.php?module=pagesmith&aop=menu&authkey=be5c993fffbc1193e3763d43ef5b2c78">PageSmith</a>
	, which can be found in the <a href="index.php?module=controlpanel&command=panel_view">Control Panel</a> under the Content Tab.</p><p>
	PageSmith has many default templates to get you started. If you are comfortable with HTML, you may wish to just use the "Text Only"
	 template under the "No image" category.</p><p>This particular page was added to the home page by using the "
	 Show as home page" option found in the MiniAdmin or the "List" tab under the PageSmith administrative options. You may edit this page or remove it from the List view as well.</p>';
    $section->secname = 'text1';
    $section->sectype = 'text';
    $section->save($page->key_id);
    return true;
}
Exemplo n.º 2
0
 public function loadSections($form_mode = false, $filler = true)
 {
     PHPWS_Core::initModClass('pagesmith', 'PS_Text.php');
     PHPWS_Core::initModClass('pagesmith', 'PS_Block.php');
     if (empty($this->_tpl)) {
         $this->loadTemplate();
     }
     if (empty($this->_tpl->structure)) {
         PHPWS_Error::log(PS_PG_TPL_ERROR, 'pagesmith', 'PS_Page::loadSections', $this->_tpl->file);
         throw new \Exception('Page template missing:' . $this->_tpl->file);
     }
     foreach ($this->_tpl->structure as $section_xml) {
         switch ($section_xml['TYPE']) {
             case 'image':
             case 'document':
             case 'media':
             case 'block':
                 $section = new PS_Block();
                 $section->pid = $this->id;
                 break;
             default:
                 $section = new PS_Text();
                 $section->pid = $this->id;
         }
         $section->plugSection($section_xml, $this->id);
         if ($form_mode && $filler) {
             $section->loadFiller();
         }
         $this->_sections[$section->secname] = $section;
     }
     if ($this->id) {
         // load sections from database
         // load sections should handle template
         $text_db = new PHPWS_DB('ps_text');
         $block_db = new PHPWS_DB('ps_block');
         $text_db->addWhere('pid', $this->id);
         $block_db->addWhere('pid', $this->id);
         $text_db->setIndexBy('secname');
         $block_db->setIndexBy('secname');
         $text_sections = $text_db->select();
         $block_sections = $block_db->select();
         if (!empty($text_sections)) {
             foreach ($text_sections as $secname => $section) {
                 if (isset($this->_sections[$secname])) {
                     PHPWS_Core::plugObject($this->_sections[$secname], $section);
                     // we don't want smarttags parsed
                     $this->_content[$secname] = $this->_sections[$secname]->getContent(!$form_mode);
                 } elseif (!empty($section['content'])) {
                     $this->_orphans[$secname] = $section;
                 } else {
                     $db = \Database::newDB();
                     $db->setConditional($db->addTable('ps_text')->getFieldConditional('id', $section['id']));
                     $db->delete();
                 }
             }
         }
         if (!empty($block_sections)) {
             foreach ($block_sections as $secname => $section) {
                 if (isset($this->_sections[$secname])) {
                     if ($this->_sections[$secname]->width) {
                         $default_w = $this->_sections[$secname]->width;
                     }
                     if ($this->_sections[$secname]->height) {
                         $default_h = $this->_sections[$secname]->height;
                     }
                     PHPWS_Core::plugObject($this->_sections[$secname], $section);
                     if ($this->_sections[$secname]->width && !empty($default_w)) {
                         $this->_sections[$secname]->width = $default_w;
                     }
                     if ($this->_sections[$secname]->height && !empty($default_h)) {
                         $this->_sections[$secname]->height = $default_h;
                     }
                     if ($form_mode && $this->_sections[$secname]->type_id) {
                         //reload the image form if the image is set
                         $this->_sections[$secname]->loadFiller();
                     }
                     $this->_content[$secname] = $this->_sections[$secname]->getContent();
                 } elseif ($section['type_id'] > 0) {
                     $this->_orphans[$secname] = $section;
                 } else {
                     $db = \Database::newDB();
                     $db->setConditional($db->addTable('ps_block')->getFieldConditional('id', $section['id']));
                     $db->delete();
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public function postHeader()
 {
     PHPWS_Core::initModClass('pagesmith', 'PS_Text.php');
     $header = strip_tags($_POST['header'], PS_ALLOWED_HEADER_TAGS);
     $section = new PS_Text();
     $section->pid = $_POST['pid'];
     $section->secname = $_POST['section_name'];
     $section->content = PHPWS_Text::parseInput($header);
     $section->setSaved();
     $vars['cnt_section_name'] = $_POST['tpl'] . '-' . $_POST['section_name'];
     //$vars['hdn_section_name'] = sprintf('pagesmith_%s', $_POST['section_name']);
     $vars['content'] = addslashes(PHPWS_Text::parseOutput($section->content));
     $vars['hidden_value'] = $section->content;
     Layout::nakedDisplay(javascriptMod('pagesmith', 'update', $vars));
 }