Example #1
0
 /**
  * @ignore
  */
 private static function _expand_filename($in)
 {
     $smarty = \Smarty_CMS::get_instance();
     $config = \cms_config::get_instance();
     $smarty->assign('root_url', $config['root_url']);
     $smarty->assign('root_path', $config['root_path']);
     return trim($smarty->fetch('string:' . $in));
 }
 /**
  * @ignore
  */
 public function InitializeFrontend()
 {
     $smarty = \Smarty_CMS::get_instance();
     if (!$smarty) {
         return;
     }
     // register our functions.
     $smarty->register_function('cghm_config_set', '\\CGHeadMaster\\smarty_plugins::cghm_config_set');
     $smarty->register_function('cghm_set', '\\CGHeadMaster\\smarty_plugins::cghm_set');
     $smarty->register_function('cghm_unset', '\\CGHeadMaster\\smarty_plugins::cghm_unset');
     $smarty->register_function('cghm_hide', '\\CGHeadMaster\\smarty_plugins::cghm_hide');
     $smarty->register_function('cghm_render', '\\CGHeadMaster\\smarty_plugins::cghm_render');
     // load standard fields
     $files = $this->get_module_files('config', 'fields.ini');
     if (!count($files)) {
         throw new \RuntimeException('Could not find field definition file(s) named fields.ini');
     }
     $files = array_reverse($files);
     $this->_fields = array();
     foreach ($files as $file) {
         $tmp = parse_ini_file($file, TRUE);
         if (count($tmp)) {
             $this->_fields = array_merge($this->_fields, $tmp);
         }
     }
     // load the cgsm_config vars
     $sysconfig = \cms_config::get_instance();
     $fn = $sysconfig['root_path'] . '/config.php';
     include $fn;
     unset($sysconfig);
     $this->_config = array();
     foreach ($config as $key => $val) {
         if (!startswith($key, 'cghm_')) {
             continue;
         }
         $this->_config[$key] = $val;
     }
 }
 /**
  * get_instance method
  *
  * @return object $this
  */
 public static function &get_instance()
 {
     if (!is_object(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 /**
  * Dummy default plugin handler for smarty.
  *
  * @access private
  * @internal
  */
 public function defaultPluginHandler($name, $type, $template, &$callback, &$script, &$cachable)
 {
     if ($type == 'compiler') {
         $callback = array(__CLASS__, '_dflt_plugin');
         $cachable = false;
         return TRUE;
     }
     return parent::defaultPluginHandler($name, $type, $template, $callback, $script, $cachable);
 }
Example #5
0
 /**
  * Get a handle to the CMS Smarty object. If it does not yet
  * exist, this method will instantiate it. As of version 1.8,
  * CMS Made Simple uses version 2.6.25 of Smarty.
  *
  * @final
  * @see Smarty_CMS
  * @link http://www.smarty.net/manual/en/
  * @return Smarty_CMS handle to the Smarty object
  */
 public function &GetSmarty()
 {
     return Smarty_CMS::get_instance();
 }
 /**
  * A convenience method to generate a new smarty template object given a resource string,
  * and a prefix.  This method will also automatically assign a few common smarty variables
  * to the new scope.
  *
  * Note: the parent smarty scope depends on how this function is called.  If called directly from a module action for the same module
  *  the parent will be the current smarty scope.  If called from any method that is using a different module than the
  *  action module, then the parent scope will be the global smarty scope.
  *
  * @param string $template_name The desired template name.
  * @param string $prefix an optional prefix for database templates.
  * @param string $cache_id An optional smarty cache id.
  * @param string $compile_id An optional smarty compile id.
  * @return object
  */
 public function CreateSmartyTemplate($template_name, $prefix = null, $cache_id = null, $compile_id = null)
 {
     $smarty = null;
     if (version_compare(CMS_VERSION, '2.0.1') >= 0) {
         $smarty = $this->GetActionTemplateObject();
     }
     if (!$smarty) {
         $smarty = Smarty_CMS::get_instance();
     }
     $mod = $smarty->getTemplateVars('mod');
     $tpl = $smarty->createTemplate($this->CGGetTemplateResource($template_name, $prefix), $cache_id, $compile_id, $smarty);
     // for convenience, I assign a few smarty variables.
     $tpl->assign($this->GetName(), $this);
     $tpl->assign('mod', $this);
     if ($actionid = $smarty->getTemplateVars('actionid')) {
         $tpl->assign('actionid', $actionid);
     }
     if ($actionparams = $smarty->getTemplateVars('actionparams')) {
         $tpl->assign('actionparams', $actionparams);
     }
     return $tpl;
 }
 /**
  * Get a handle to the CMS Smarty object. If it does not yet
  * exist, this method will instantiate it. As of version 1.8,
  * CMS Made Simple uses version 2.6.25 of Smarty.
  *
  * @final
  * @see Smarty_CMS
  * @link http://www.smarty.net/manual/en/
  * @return Smarty_CMS handle to the Smarty object
  */
 public function &GetSmarty()
 {
     /* Check to see if a Smarty object has been instantiated yet,
     	  and, if not, go ahead an create the instance. */
     return Smarty_CMS::get_instance();
 }
Example #8
0
     foreach ($_POST["additional_editors"] as $addt_user_id) {
         $the_blob->AddAuthor($addt_user_id);
     }
 }
 #Perform the edithtmlblob_pre callback
 foreach ($gCms->modules as $key => $value) {
     if ($gCms->modules[$key]['installed'] == true && $gCms->modules[$key]['active'] == true) {
         $gCms->modules[$key]['object']->EditHtmlBlobPre($blobobj);
     }
 }
 Events::SendEvent('Core', 'EditGlobalContentPre', array('global_content' => &$the_blob));
 $result = $the_blob->save();
 if ($result) {
     audit($the_blob->id, $the_blob->name, 'Edited Global Content Block');
     #Clear cache
     $smarty = new Smarty_CMS($config);
     $smarty->clear_all_cache();
     $smarty->clear_compiled_tpl();
     #Perform the edithtmlblob_post callback
     foreach ($gCms->modules as $key => $value) {
         if ($gCms->modules[$key]['installed'] == true && $gCms->modules[$key]['active'] == true) {
             $gCms->modules[$key]['object']->EditHtmlBlobPost($the_blob);
         }
     }
     Events::SendEvent('Core', 'EditGlobalContentPost', array('global_content' => &$the_blob));
     if (!isset($_POST['apply'])) {
         redirect('listhtmlblobs.php' . $urlext);
         return;
     }
 } else {
     $error .= "<li>" . lang('errorinsertingblob') . "</li>";