コード例 #1
0
 /**
  * This is a proxy function.  It determines what step of the wizard we are on and acts appropriately
  *
  * @access	protected
  * @return	void
  */
 protected function _wizardProxy()
 {
     //-----------------------------------------
     // If it's a different type - proxy there
     //-----------------------------------------
     if ($this->request['fileType'] == 'css' or $this->request['fileType'] == 'js') {
         return $this->easyForm('add', $this->request['fileType']);
     }
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $sessionId = $this->request['wizard_session'] ? IPSText::md5Clean($this->request['wizard_session']) : md5(uniqid(microtime(), true));
     $session = array('wizard_step' => 0, 'wizard_id' => $sessionId, 'wizard_started' => time(), 'wizard_ipb_wrapper' => $this->settings['ccs_use_ipb_wrapper']);
     if ($this->request['wizard_session']) {
         $session = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'ccs_page_wizard', 'where' => "wizard_id='{$sessionId}'"));
     } else {
         $this->DB->insert('ccs_page_wizard', $session);
     }
     $session['wizard_step'] = $this->request['step'] ? $this->request['step'] : 0;
     //-----------------------------------------
     // Got stuff to save?
     //-----------------------------------------
     if ($session['wizard_step'] > 0 and !$this->request['continuing']) {
         $session = $this->_storeSubmittedData($session);
     }
     //-----------------------------------------
     // Proxy off to appropriate function
     //-----------------------------------------
     $step = $session['wizard_step'] + 1;
     $step = $step > 0 ? $step : 1;
     $_func = "wizard_step_" . $step;
     $additional = array();
     switch ($step) {
         //-----------------------------------------
         // Step 1: Grab folders and templates for form
         //-----------------------------------------
         case 1:
             $additional['folders'] = array();
             $additional['templates'] = array();
             //-----------------------------------------
             // Get templates
             //-----------------------------------------
             $this->DB->build(array('select' => '*', 'from' => 'ccs_page_templates', 'order' => 'template_name ASC'));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 $additional['templates'][] = array($r['template_id'], $r['template_name']);
             }
             //-----------------------------------------
             // Get folders
             //-----------------------------------------
             $folders = array();
             $this->DB->build(array('select' => '*', 'from' => 'ccs_folders'));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 $additional['folders'][] = array($r['folder_path'], $r['folder_path']);
             }
             //-----------------------------------------
             // Edit content only by default
             //-----------------------------------------
             if (!$session['wizard_edit_id']) {
                 $session['wizard_content_only'] = 1;
             }
             break;
             //-----------------------------------------
             // Step 2: Show the appropriate editor
             //-----------------------------------------
         //-----------------------------------------
         // Step 2: Show the appropriate editor
         //-----------------------------------------
         case 2:
             //-----------------------------------------
             // If we are not editing content only, not
             //	editing an existing page, and have a
             //	template id, get it as default content
             //-----------------------------------------
             if (!$session['wizard_content_only'] and !$session['wizard_edit_id'] and $session['wizard_template']) {
                 $template = $this->DB->buildAndFetch(array('select' => 'template_content', 'from' => 'ccs_page_templates', 'where' => 'template_id=' . intval($session['wizard_template'])));
                 $session['wizard_content'] = $template['template_content'];
             }
             //-----------------------------------------
             // Sort parse for editor
             //-----------------------------------------
             if ($session['wizard_type'] == 'bbcode') {
                 IPSText::getTextClass('bbcode')->bypass_badwords = 1;
                 IPSText::getTextClass('bbcode')->parse_smilies = 1;
                 IPSText::getTextClass('bbcode')->parse_html = 1;
                 IPSText::getTextClass('bbcode')->parse_nl2br = 1;
                 IPSText::getTextClass('bbcode')->parse_bbcode = 1;
                 IPSText::getTextClass('bbcode')->parsing_section = 'global';
                 if ($session['wizard_previous_type'] != 'bbcode') {
                     $session['wizard_content'] = IPSText::getTextClass('bbcode')->preDbParse($session['wizard_content']);
                 }
                 if (IPSText::getTextClass('editor')->method == 'rte') {
                     $content = IPSText::getTextClass('bbcode')->convertForRTE($session['wizard_content']);
                 } else {
                     $content = IPSText::getTextClass('bbcode')->preEditParse($session['wizard_content']);
                 }
                 $editor_area = IPSText::getTextClass('editor')->showEditor($content, 'content');
             } else {
                 if ($session['wizard_previous_type'] == 'bbcode') {
                     $session['wizard_content'] = html_entity_decode($session['wizard_content'], ENT_QUOTES);
                 }
                 $editor_area = $this->registry->output->formTextarea("content", htmlspecialchars($session['wizard_content']), 100, 30, "content", "style='width:100%;'");
             }
             $additional['editor'] = $editor_area;
             break;
             //-----------------------------------------
             // Step 4: Permissions
             //-----------------------------------------
         //-----------------------------------------
         // Step 4: Permissions
         //-----------------------------------------
         case 4:
             if ($session['wizard_perms'] == '*' or !$session['wizard_edit_id']) {
                 $additional['all_masks'] = 1;
             } else {
                 $additional['masks'] = explode(',', $session['wizard_perms']);
             }
             $additional['avail_masks'] = array();
             $this->DB->build(array('select' => '*', 'from' => 'forum_perms', 'order' => 'perm_name ASC'));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 $additional['avail_masks'][] = array($r['perm_id'], $r['perm_name']);
             }
             break;
             //-----------------------------------------
             // Step 5: Save to DB, destroy wizard session,
             //	show complete page
             //-----------------------------------------
         //-----------------------------------------
         // Step 5: Save to DB, destroy wizard session,
         //	show complete page
         //-----------------------------------------
         case 5:
             $page = array('page_name' => $session['wizard_name'], 'page_seo_name' => $session['wizard_seo_name'], 'page_description' => $session['wizard_description'], 'page_folder' => $session['wizard_folder'], 'page_type' => $session['wizard_type'], 'page_last_edited' => time(), 'page_template_used' => $session['wizard_template'], 'page_content' => $session['wizard_content'], 'page_view_perms' => $session['wizard_perms'], 'page_cache_ttl' => $session['wizard_cache_ttl'], 'page_content_only' => $session['wizard_content_only'], 'page_meta_keywords' => $session['wizard_meta_keywords'], 'page_meta_description' => $session['wizard_meta_description'], 'page_content_type' => 'page', 'page_ipb_wrapper' => $session['wizard_ipb_wrapper']);
             if ($page['page_cache_ttl']) {
                 require_once IPSLib::getAppDir('ccs') . '/sources/pages.php';
                 $pageBuilder = new pageBuilder($this->registry);
                 $page['page_cache'] = $pageBuilder->recachePage($page);
                 $page['page_cache_last'] = time();
             }
             if ($session['wizard_edit_id']) {
                 $this->DB->update('ccs_pages', $page, 'page_id=' . $session['wizard_edit_id']);
                 $page['page_id'] = $session['wizard_edit_id'];
             } else {
                 $this->DB->insert('ccs_pages', $page);
                 $page['page_id'] = $this->DB->getInsertId();
             }
             $this->DB->delete('ccs_page_wizard', "wizard_id='{$session['wizard_id']}'");
             $session = array_merge($session, $page);
             break;
     }
     $this->registry->output->html .= $this->html->{$_func}($session, $additional);
 }
コード例 #2
0
 /**
  * Recache a page
  *
  * @access	public
  * @param	array		[$page]		Override page data
  * @param	bool		[$return]	Return content instead of storing it
  * @return	void
  */
 public function recachePage($page = array(), $return = false)
 {
     if (!count($page)) {
         $id = intval($this->request['page']);
         $page = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'ccs_pages', 'where' => 'page_id=' . $id));
     }
     //-----------------------------------------
     // Get page builder
     //-----------------------------------------
     require_once IPSLib::getAppDir('ccs') . '/sources/pages.php';
     $pageBuilder = new pageBuilder($this->registry);
     $content = $pageBuilder->recachePage($page);
     //-----------------------------------------
     // Return or update
     //-----------------------------------------
     if (!$return and $page['page_id']) {
         $this->DB->update('ccs_pages', array('page_cache' => $content, 'page_cache_last' => time()), 'page_id=' . intval($page['page_id']));
     } else {
         return $content;
     }
     $this->registry->output->global_message = $this->lang->words['page_recached'];
     $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . '&module=pages&section=list');
 }