Inserts an error message into the errors list.
public trigger_error ( string $p_message, object $p_smarty = null ) | ||
$p_message | string | |
$p_smarty | object |
public function __toString() { $className = get_class($this); if (strncasecmp($className, 'Meta', 4) == 0) { $className = strtolower(substr($className, 4)); } CampTemplate::trigger_error("Invalid use of object of type '$className'. Use \$campsite->${className}->[property_name] to display a property of this object."); return null; }
/** * Campsite blogcomment_form block plugin * * Type: block * Name: blogcomment_form * Purpose: Provides a form for an blog comment * * @param string * $p_params * @param string * $p_smarty * @param string * $p_content * * @return * */ function smarty_block_blogcomment_form($p_params, $p_content, &$p_smarty, &$p_repeat) { if (!isset($p_content)) { return ''; } require_once $p_smarty->_get_plugin_filepath('shared','escape_special_chars'); // gets the context variable $campsite = $p_smarty->get_template_vars('gimme'); if (!is_object($campsite->blogentry) || !$campsite->blogentry->identifier) { return ''; } $url = $campsite->url; $url->uri_parameter = ""; $template = null; if (isset($p_params['template'])) { $template = new MetaTemplate($p_params['template']); if (!$template->defined) { CampTemplate::trigger_error('invalid template "' . $p_params['template'] . '" specified in the blog comment form'); return false; } } elseif (is_numeric($url->get_parameter('tpl'))) { $template = $campsite->default_template; } if (!isset($p_params['submit_button'])) { $p_params['submit_button'] = 'Submit'; } if (!isset($p_params['html_code']) || empty($p_params['html_code'])) { $p_params['html_code'] = ''; } if (!isset($p_params['button_html_code']) || empty($p_params['button_html_code'])) { $p_params['button_html_code'] = ''; } if (isset($template)) { $url->uri_parameter = "template " . str_replace(' ', "\\ ", $template->name); } $html = "<form name=\"blogcomment\" action=\"" . $url->uri_path . "\" method=\"post\" " .$p_params['html_code'].">\n"; $html .= "<input type=\"hidden\" name=\"f_blogentry_id\" value=\"{$campsite->blogentry->identifier}\" />\n"; if (isset($template)) { $html .= "<input type=\"hidden\" name=\"tpl\" value=\"" . $template->identifier . "\" />\n"; } foreach ($campsite->url->form_parameters as $param) { if ($param['name'] == 'tpl') { continue; } $html .= '<input type="hidden" name="'.$param['name'] .'" value="'.htmlentities($param['value'])."\" />\n"; } $html .= $p_content; $html .= "<input type=\"submit\" name=\"f_submit_blogcomment\" " ."id=\"blogcomment_submit\" value=\"" .smarty_function_escape_special_chars($p_params['submit_button']) ."\" " . $p_params['button_html_code'] . " />\n"; if (isset($p_params['preview_button']) && !empty($p_params['preview_button'])) { $html .= "<input type=\"submit\" name=\"f_preview_blogcomment\" " ."id=\"blogcomment_preview\" value=\"" .smarty_function_escape_special_chars($p_params['preview_button']) ."\" " . $p_params['button_html_code'] . " />\n"; } $html .= "</form>\n"; return $html; } // fn smarty_block_blogcomment_form
/** * Renders the document. * * Displays the document after parsing it. * * @param array $p_params * * @return void */ public function render($p_params) { $siteinfo = array(); $context = $p_params['context']; $template = $p_params['template']; $siteinfo['info_message'] = isset($p_params['info_message']) ? $p_params['info_message'] : null; $siteinfo['error_message'] = isset($p_params['error_message']) ? $p_params['error_message'] : null; $siteinfo['templates_path'] = isset($p_params['templates_dir']) ? $p_params['templates_dir'] : CS_TEMPLATES_DIR; $siteinfo['title'] = $this->getTitle(); $siteinfo['content_type'] = $this->getMetaTag('Content-Type', true); $siteinfo['generator'] = $this->getGenerator(); $siteinfo['keywords'] = $this->getMetaTag('keywords'); $siteinfo['description'] = $this->getMetaTag('description'); if (!file_exists(CS_PATH_SITE.DIR_SEP.$siteinfo['templates_path'].DIR_SEP.$template) || $template === false) { if (empty($template)) { $siteinfo['error_message'] = "No template set for display."; } else { $siteinfo['error_message'] = "The template '$template' does not exist in the templates directory."; } $template = CS_SYS_TEMPLATES_DIR.DIR_SEP.'_campsite_error.tpl'; $siteinfo['templates_path'] = CS_TEMPLATES_DIR; } $tpl = CampTemplate::singleton(); $tpl->template_dir = $siteinfo['templates_path']; $subdir = $this->m_config->getSetting('SUBDIR'); if (!empty($subdir)) { $siteinfo['templates_path'] = substr($subdir, 1) . '/' . $siteinfo['templates_path']; } $tpl->assign('gimme', $context); $tpl->assign('siteinfo', $siteinfo); // on template caching add additional info if (SystemPref::Get('TemplateCacheHandler')) { $uri = CampSite::GetURIInstance(); $tpl->campsiteVector = $uri->getCampsiteVector(); $templateObj = new Template($template); $tpl->cache_lifetime = (int)$templateObj->getCacheLifetime(); } try { $tpl->display($template); } catch (Exception $ex) { CampTemplate::trigger_error($ex->getMessage(), $tpl); } } // fn render
/** * Process the image options given in the old format (for compatibility): * [<image_number> [<image_ratio>]] * or: * [<image_number> [width <image_width> | height <image_height>] * @param integer $p_imageNo * @param array $p_params */ private function processOldImageOptions(&$p_imageNo, array $p_params) { $p_imageNo = isset($p_params[0]) ? array_shift($p_params) : null; if(isset($p_params[0]) && is_numeric($p_params[0])) { $this->m_buildQueryArray['ImageRatio'] = $p_params[0]; } else { while (isset($p_params[0])) { $option = strtolower(array_shift($p_params)); if ($option != 'width' && $option != 'height') { CampTemplate::trigger_error("Invalid image attribute '$option' in URL statement."); break; } if (isset($p_params[0]) && is_numeric($p_params[0])) { $option_value = array_shift($p_params); } else { CampTemplate::trigger_error("Value not set for '$option' image attribute in URL statement."); break; } $param = 'Image' . ucfirst($option); $this->m_buildQueryArray[$param] = $option_value; } } }