/**
  * Not part of the api
  */
 private function _get_items_array($selItems = array())
 {
     $AdvancedContent =& cms_utils::get_module('AdvancedContent');
     $items = array();
     if ($this->GetBlockProperty('items') != '') {
         foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('items')) as $key => $val) {
             $items[$key]['id'] = munge_string_to_url(trim($val));
             $items[$key]['label'] = trim($val);
             if ($this->GetBlockProperty('translate_labels')) {
                 $items[$key]['label'] = $AdvancedContent->lang($items[$key]['label']);
             }
             $items[$key]['value'] = $items[$key]['label'];
             $items[$key]['selected'] = in_array($items[$key]['label'], $selItems);
         }
     }
     if ($this->GetBlockProperty('values') != '') {
         foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('values')) as $key => $val) {
             $items[$key]['value'] = trim($val);
             if ($this->GetBlockProperty('translate_values')) {
                 $items[$key]['value'] = $AdvancedContent->lang($items[$key]['value']);
             }
             $items[$key]['selected'] = in_array($items[$key]['value'], $selItems);
             if (!isset($items[$key]['label'])) {
                 $items[$key]['label'] = $items[$key]['value'];
             }
         }
     }
     return $items;
 }
 /**
  * Given a dataref object, find and instantiate a LinkDefinitionGenerator
  * that can generate links for this type of dataref
  *
  * @param DataRef $dataref
  * @return LinkDefinitionGenerator
  */
 public function get_generator(DataRef $dataref)
 {
     if (strtolower($dataref->key1) == 'page' && (int) $dataref->key2 > 0) {
         $dataref->key3 = $dataref->key2;
         $dataref->key2 = 'Page';
         $dataref->key1 = 'Core';
     }
     if (in_array($dataref->key1, array('Core', 'core', 'CORE', 'CMSMS'))) {
         $obj = new CoreLinkDefinitionGenerator();
         $obj->set_dataref($dataref);
         return $obj;
     }
     // assume key1 is a module name
     $mod = \cms_utils::get_module($dataref->key1);
     if (is_object($mod)) {
         $str = $dataref->key1 . '\\LinkDefinitionGenerator';
         if (class_exists($str)) {
             $obj = new $str();
             $obj->set_dataref($dataref);
             return $obj;
         }
         $str = $dataref->key1 . '_LinkDefinitionGenerator';
         if (class_exists($str)) {
             $obj = new $str();
             $obj->set_dataref($dataref);
             return $obj;
         }
     }
     throw new \RuntimeException('Could not find an appropriate link generator for data definitions of type ' . $dataref->key1);
 }
 public function GetBlockTypeProperties($access = 'backend')
 {
     if ($access == 'backend') {
         $AdvancedContent =& cms_utils::get_module('AdvancedContent');
         $multi_input_ids = $this->content_obj->CleanArray(explode(',', $this->GetBlockProperty('inputs')));
         $multiInput_props = $this->content_obj->GetBlockTypeProperties('multi_input');
         foreach ($multi_input_ids as $k1 => $multi_input_id) {
             if (!isset($multiInput_props[$multi_input_id])) {
                 $multiInput_props = array_merge($multiInput_props, $AdvancedContent->GetMultiInputFull($multi_input_ids));
                 if (!isset($multiInput_props[$multi_input_id])) {
                     continue;
                 }
                 $multiInput_props[$multi_input_id]['template'] = $AdvancedContent->GetTemplate($multiInput_props[$multi_input_id]['tpl_name']);
                 $matches = array();
                 $result = preg_match_all(AC_BLOCK_PATTERN, $multiInput_props[$multi_input_id]['input_fields'], $matches);
                 if ($result && count($matches[1]) > 0) {
                     foreach ($matches[1] as $k2 => $wholetag) {
                         if (!($inputBlock = $this->content_obj->CreateContentBlock($wholetag))) {
                             continue;
                         }
                         if ($inputBlock->GetBlockProperty('type') == 'multi_input') {
                             continue;
                             # ToDo: display message?
                         }
                         $multiInput_props[$multi_input_id]['elements'][$k2] = $inputBlock;
                     }
                 }
             }
         }
         return $multiInput_props;
     }
 }
 private static function ExportExaCSS($mod)
 {
     $db = cmsms()->GetDb();
     $ExaCSS = cms_utils::get_module('ExaCSS');
     if ($ExaCSS == false) {
         return;
     }
     // Création du sous-dossier
     $subdir = "ExaCSS";
     te_base::CreateSubDir($mod, $subdir);
     // Récupération du répertoire d'exportation
     $cache_path = te_base::GetCachePath($mod);
     // Récupération de l'extension du fichier
     $stylesheet_extension = $mod->GetPreference('stylesheet_extension');
     // Récupération de la liste des feuilles de styles
     $stylesheets = ExaCSSstylesheet::Get();
     $stylesheets = $stylesheets['list'];
     // Exportation de chaque feuille de style dans des fichiers séparés
     foreach ($stylesheets as $stylesheet) {
         $fname = cms_join_path($cache_path, $subdir, te_base::escapeFilename("style_" . $stylesheet['name']) . '.' . $stylesheet_extension);
         $fp = fopen($fname, 'w');
         // Conversion du CRLF vers le LF pour la compatibilité Unix
         fwrite($fp, te_base::escapeContent($stylesheet['content']));
         fclose($fp);
         // Rendre chaque fichier disponible en écriture
         chmod($fname, 0666);
         // Modifier la date du fichier avec la date de modification du CSS
         touch($fname, $db->UnixTimeStamp($stylesheet['date_modification']));
     }
     // Récupération de la liste des feuilles de variables
     $variables = ExaCSSvariable::Get();
     $variables = $variables['list'];
     // Exportation de chaque feuille de variables dans des fichiers séparés
     foreach ($variables as $variable) {
         $fname = cms_join_path($cache_path, $subdir, te_base::escapeFilename("variable_" . $variable['name']) . '.' . $stylesheet_extension);
         $fp = fopen($fname, 'w');
         // Conversion du CRLF vers le LF pour la compatibilité Unix
         fwrite($fp, te_base::escapeContent($variable['content']));
         fclose($fp);
         // Rendre chaque fichier disponible en écriture
         chmod($fname, 0666);
         // Modifier la date du fichier avec la date de modification du CSS
         touch($fname, $db->UnixTimeStamp($variable['date_modification']));
     }
     // Récupération de la liste des feuilles de mixins
     $mixins = ExaCSSmixin::Get();
     $mixins = $mixins['list'];
     // Exportation de chaque feuille de mixins dans des fichiers séparés
     foreach ($mixins as $mixin) {
         $fname = cms_join_path($cache_path, $subdir, te_base::escapeFilename("mixin_" . $mixin['name']) . '.' . $stylesheet_extension);
         $fp = fopen($fname, 'w');
         // Conversion du CRLF vers le LF pour la compatibilité Unix
         fwrite($fp, te_base::escapeContent($mixin['content']));
         fclose($fp);
         // Rendre chaque fichier disponible en écriture
         chmod($fname, 0666);
         // Modifier la date du fichier avec la date de modification du CSS
         touch($fname, $db->UnixTimeStamp($mixin['date_modification']));
     }
 }
 /**
  * Takes an exception message of the form [module]%%key[%%suffix]
  * and format a language string
  *
  * @param string $str The exception message
  * @param int $code The exception code
  * @param \Exception $parent a parent exception
  */
 public function __construct($str = '', $code = 0, \Exception $parent = null)
 {
     if (strpos($str, '%%')) {
         $parts = explode('%%', $str, 3);
         if (count($parts) > 1) {
             $module = trim($parts[0]);
             $key = trim($parts[1]);
             if (!$module) {
                 $module = cge_tmpdata::get('module');
                 if (!$module) {
                     $smarty = cmsms()->GetSmarty();
                     $obj = $smarty->get_template_vars('mod');
                     if (is_object($obj)) {
                         $module = $obj->GetName();
                     }
                 }
             }
             if ($module && $key) {
                 $mod = \cms_utils::get_module($module);
                 if ($mod) {
                     $str = $mod->Lang($key);
                 }
                 if (isset($parts[2]) && $parts[2]) {
                     $str .= ' ' . $parts[2];
                 }
             }
         }
     }
     parent::__construct($str, $code, $parent);
 }
 public function on_success($time = '')
 {
     if (!$time) {
         $time = time();
     }
     $mod = cms_utils::get_module('CGSmartImage');
     $mod->SetPreference('clearcache_lastrun', $time);
 }
 function GetModuleInstance()
 {
     $mod = cms_utils::get_module($this->ModuleName());
     if ($mod) {
         return $mod;
     }
     return 'ModuleName() not defined properly';
 }
    public static function get_categories($id, $params, $returnid = -1)
    {
        $db = cmsms()->GetDb();
        $depth = 1;
        $query = '
		SELECT news_category_id, news_category_name, hierarchy, long_name 
		FROM ' . cms_db_prefix() . 'module_news_categories 
		WHERE hierarchy not like \'\'
	';
        if (isset($params['category']) && $params['category'] != '') {
            $categories = explode(',', $params['category']);
            $query .= ' AND (';
            $count = 0;
            foreach ($categories as $onecat) {
                if ($count > 0) {
                    $query .= ' OR ';
                }
                if (strpos($onecat, '|') !== FALSE || strpos($onecat, '*') !== FALSE) {
                    $query .= "upper(long_name) like upper('" . trim(str_replace('*', '%', $onecat)) . "')";
                } else {
                    $query .= "news_category_name = '" . trim($onecat) . "'";
                }
                $count++;
            }
            $query .= ') ';
        }
        $query .= ' ORDER by hierarchy';
        $dbresult = $db->Execute($query);
        $rowcounter = 0;
        while ($dbresult && ($row = $dbresult->FetchRow())) {
            $q2 = "SELECT COUNT(news_id) as cnt FROM " . cms_db_prefix() . "module_news WHERE news_category_id=?";
            if (isset($params['showarchive']) && $params['showarchive'] == true) {
                $q2 .= " AND (end_time < " . $db->DBTimeStamp(time()) . ") ";
            } else {
                $q2 .= " AND ((" . $db->IfNull('end_time', $db->DBTimeStamp(1)) . " = " . $db->DBTimeStamp(1) . ") OR (end_time > " . $db->DBTimeStamp(time()) . ")) ";
            }
            $q2 .= ' AND status = \'published\'';
            $dbres2 = $db->Execute($q2, array($row['news_category_id']));
            $count = $dbres2->FetchRow();
            $row['index'] = $rowcounter++;
            $row['count'] = $count['cnt'];
            $row['prevdepth'] = $depth;
            $depth = count(explode('.', $row['hierarchy']));
            $row['depth'] = $depth;
            // changes so that parameters supplied to the tag
            // gets carried down through the links
            // screw pretty urls
            $parms = $params;
            unset($parms['browsecat']);
            unset($parms['category']);
            $parms['category_id'] = $row['news_category_id'];
            $pageid = isset($params['detailpage']) && $params['detailpage'] != '' ? $params['detailpage'] : $returnid;
            $mod = cms_utils::get_module('News');
            $row['url'] = $mod->CreateLink($id, 'default', $pageid, $row['news_category_name'], $parms, '', true);
            $items[] = $row;
        }
        return $items;
    }
 public function __construct($module_name)
 {
     $this->_module_name = trim($module_name);
     $this->_mod = \cms_utils::get_module($module_name);
     if (!$this->_mod) {
         throw new \RuntimeException(cgex_lang('err_modulenotfound', $module_name));
     }
     $dir = $this->_mod->GetModulePath();
     $this->_cdat = $dir . '/_c1.dat';
     $this->_ddat = $dir . '/_d1.dat';
 }
function _cgcalDeleteField($field_oldname)
{
    $db = cmsms()->GetDb();
    $mod = cms_utils::get_module('CGCalendar');
    $fields_table_name = $mod->fields_table_name;
    $event_field_values_table_name = $mod->event_field_values_table_name;
    $sql = "DELETE FROM \${$event_field_values_table_name} where field_name='{$field_oldname}'";
    $db->Execute($sql);
    $sql = "DELETE FROM {$fields_table_name} where field_name='{$field_oldname}'";
    $db->Execute($sql);
}
Beispiel #11
0
 private function _get_canonical()
 {
     if (!isset($this->_meta['canonical'])) {
         $tmp = $this->news_url;
         if ($tmp == '') {
             $aliased_title = munge_string_to_url($this->title);
             $tmp = 'news/' . $this->id . '/' . $this->returnid . "/{$aliased_title}";
         }
         $mod = cms_utils::get_module('News');
         $canonical = $mod->create_url($this->_inid, 'detail', $this->returnid, $this->params, false, false, $tmp);
         $this->_meta['canonical'] = $canonical;
     }
     return $this->_meta['canonical'];
 }
 public function GetBlockInput()
 {
     $AdvancedContent =& cms_utils::get_module('AdvancedContent');
     if ($this->GetBlockProperty('module') == '') {
         return $AdvancedContent->lang('error_insufficient_blockparams', 'module', $this->GetBlockProperty('name'));
     }
     if (!($module =& $AdvancedContent->GetModuleInstance($this->GetBlockProperty('module')))) {
         return $AdvancedContent->lang('error_loading_module', $this->GetBlockProperty('module'), $this->GetBlockProperty('name'));
     }
     if (!$module->HasCapability('contentblocks')) {
         return $AdvancedContent->lang('error_contentblock_support', $this->GetBlockProperty('module'), $this->GetBlockProperty('name'));
     }
     return $module->GetContentBlockInput($this->GetBlockProperty('id'), $this->content_obj->GetPropertyValue($this->GetBlockProperty('id')), $this->GetBlockProperty('params'), $this->GetBlockProperty('adding'));
 }
 public static function load($libname)
 {
     $mod = cms_utils::get_module(MOD_CGEXTENSIONS);
     if ($libname == 'cg_cmsms') {
         // gotta return code.
         $config = cms_config::get_instance();
         $tpl = $mod->CreateSmartyTemplate('jquery.cg_cmsms.tpl');
         $tpl->assign('mod', $mod);
         $tpl->assign('config', $config);
         $code = $tpl->fetch();
         $obj = new StdClass();
         $obj->code = $code;
         return $obj;
     }
 }
 /**
  * Private method to find available tasks.  This method will look in the lib/tasks directory
  * for tack files, and also ask modules for tasks that they support.  Modules exporting tasks
  * should create and return a task object.
  *
  * @return void
  */
 private static function get_tasks()
 {
     if (!is_object(self::$_tasks)) {
         self::$_tasks = new ArrayObject();
     }
     // 1.  Get task objects from files.
     $gCms = cmsms();
     $dir = $gCms->config['root_path'] . '/lib/tasks';
     $tmp = new DirectoryIterator($dir);
     $iterator = new RegexIterator($tmp, '/class\\..+task\\.php$/');
     foreach ($iterator as $match) {
         $tmp = explode('.', basename($match->current()));
         if (is_array($tmp) && count($tmp) == 4) {
             $classname = $tmp[1] . 'Task';
             require_once $dir . '/' . $match->current();
             $obj = new $classname();
             if ($obj instanceof CmsRegularTask) {
                 self::$_tasks->append($obj);
             }
         }
     }
     // 2.  Get task objects from modules.
     $opts = $gCms->GetModuleOperations();
     $modules = $opts->get_modules_with_capability('tasks');
     if (!$modules) {
         return;
     }
     foreach ($modules as $one) {
         if (!is_object($one)) {
             $one = cms_utils::get_module($one);
         }
         if (!method_exists($one, 'get_tasks')) {
             continue;
         }
         $tasks = $one->get_tasks();
         if ($tasks) {
             if (!is_array($tasks)) {
                 $tmp = array($tasks);
                 $tasks = $tmp;
             }
             foreach ($tasks as $onetask) {
                 if (is_object($onetask) && $onetask instanceof CmsRegularTask) {
                     self::$_tasks->append($onetask);
                 }
             }
         }
     }
 }
 public static function cgsi_getimages($params, $content, &$smarty, $repeat)
 {
     if (!$content) {
         return;
     }
     $mod = cms_utils::get_module('CGSmartImage');
     $old_errorval = libxml_use_internal_errors(true);
     $dom = new CGDomDocument();
     $dom->strictErrorChecking = FALSE;
     $dom->validateOnParse = FALSE;
     if (function_exists('mb_convert_encoding')) {
         $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
     }
     $dom->loadHTML($content);
     $imgs = $dom->GetElementsByTagName('img');
     if (is_object($imgs) && $imgs->length) {
         $out = array();
         for ($i = 0; $i < $imgs->length; $i++) {
             $node = $imgs->item($i);
             $sxe = simplexml_import_dom($node);
             $rec = array();
             $rec['tag'] = $sxe->asXML();
             foreach ($sxe->attributes() as $name => $value) {
                 $value = (string) $value;
                 if ($value == '') {
                     continue;
                 }
                 $rec[$name] = $value;
             }
             $out[] = $rec;
         }
         if (isset($params['assign'])) {
             $smarty->assign($params['assign'], $out);
         }
     }
     $imagesonly = cms_to_bool(get_parameter_value($params, 'imagesonly'));
     $nocontent = cms_to_bool(get_parameter_value($params, 'nocontent'));
     if (!$nocontent) {
         if ($imagesonly) {
             $content = '';
             foreach ($out as $rec) {
                 $content .= $rec['tag'];
             }
         }
         return $content;
     }
 }
 public function __construct($input)
 {
     $mod = cms_utils::get_module('CGSmartImage');
     $this->_loc = $mod->GetPreference('croptofit_default_loc', 'c');
     if (cge_array::is_hash($input)) {
         if (isset($input['width'])) {
             $this->_dest_w = (int) $input['width'];
             $this->_dest_h = (int) $input['height'];
         } else {
             if (isset($input['w'])) {
                 $this->_dest_w = (int) $input['w'];
                 $this->_dest_h = (int) $input['h'];
             }
         }
         if (isset($input['color']) && $input['color'] != '') {
             $this->_color = strtolower($input['color']);
         }
         if (isset($input['alpha'])) {
             $this->_alpha = (int) $input['alpha'];
         }
     } else {
         if (is_array($input)) {
             if (count($input) >= 2) {
                 $this->_dest_w = (int) trim($input[0]);
                 $this->_dest_h = (int) trim($input[1]);
                 if (count($input) >= 3) {
                     if ($input[2] != '') {
                         $this->_color = strtolower($input[2]);
                     }
                     if (count($input) >= 4) {
                         if ($input[3] != '') {
                             $this->_alpha = (int) $input[3];
                         }
                     }
                 }
             }
         }
     }
     $this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w);
     $this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h);
     $this->_alpha = max(0, min(127, $this->_alpha));
     // todo: convert color name into rgb.
     if ($this->_dest_h <= 0 || $this->_dest_w <= 0) {
         throw new Exception('Invalid values specified for Croptofit filter constructor');
     }
 }
function smarty_function_anchor($params, &$template)
{
    $smarty = $template->smarty;
    $gCms = cmsms();
    $content = cms_utils::get_current_content();
    if (!is_object($content)) {
        return;
    }
    // Added by Russ for class, tabindex and title for anchor 2006/07/19
    $class = "";
    $title = "";
    $tabindex = "";
    $accesskey = "";
    if (isset($params['class'])) {
        $class = ' class="' . $params['class'] . '"';
    }
    if (isset($params['title'])) {
        $title = ' title="' . $params['title'] . '"';
    }
    if (isset($params['tabindex'])) {
        $tabindex = ' tabindex="' . $params['tabindex'] . '"';
    }
    if (isset($params['accesskey'])) {
        $accesskey = ' accesskey="' . $params['accesskey'] . '"';
    }
    // End of first part added by Russ 2006/07/19
    $url = $content->GetURL() . '#' . trim($params['anchor']);
    $url = str_replace('&amp;', '***', $url);
    $url = str_replace('&', '&amp;', $url);
    $url = str_replace('***', '&amp;', $url);
    if (isset($params['onlyhref']) && ($params['onlyhref'] == '1' || $params['onlyhref'] == 'true')) {
        // Note if you set 'onlyheref' that is what you get - no class or title or tabindex or text
        $tmp = $url;
    } else {
        // Line replaced by Russ
        //	echo '<a href="'.$url.'">'.$params['text'].'</a>';
        // Line replaced with -  by Russ to reflect class and title for anchor 2006/07/19
        $tmp = '<a href="' . $url . '"' . $class . $title . $tabindex . $accesskey . '>' . $params['text'] . '</a>';
        // End of second part added by Russ 2006/07/19
    }
    if (isset($params['assign'])) {
        $smarty->assign(trim($params['assign']), $tmp);
        return;
    }
    echo $tmp;
}
 /**
  * Process the specififed template through smarty.
  * This method will attempt to find the current action module, and given that and the name of the template find the template contents.
  * if the template name ends with .tpl a module file template is assumed.  Otherwise, a module database template will be assumed.
  * If a module cannot be determined, then a file template is assumed, using the 'file' smarty resource.
  *
  * @param string $tpl The name of the template to process.
  */
 protected function process_template($tpl)
 {
     $smarty = cmsms()->GetSmarty();
     $actionmodule = $smarty->get_template_vars('actionmodule');
     if ($actionmodule) {
         $mod = \cms_utils::get_module($actionmodule);
         if (is_object($mod)) {
             if (endswith($tpl, '.tpl')) {
                 $out = $mod->ProcessTemplate($tpl);
             } else {
                 $out = $mod->ProcessTemplateFromDatabase($tpl);
             }
         }
     } else {
         $out = $smarty->fetch('file:' . $tpl);
     }
     return $out;
 }
Beispiel #19
0
/**
 * A function to send lost password recovery email to a specified admin user (by name)
 *
 * @internal
 * @access private
 * @param string the username
 * @return results from the attempt to send a message.
 */
function send_recovery_email($username)
{
    $gCms = cmsms();
    $config = $gCms->GetConfig();
    $userops = $gCms->GetUserOperations();
    $user = $userops->LoadUserByUsername($username);
    $obj = cms_utils::get_module('CMSMailer');
    if ($obj == null) {
        return false;
    }
    $obj->AddAddress($user->email, html_entity_decode($user->firstname . ' ' . $user->lastname));
    $obj->SetSubject(lang('lostpwemailsubject', html_entity_decode(get_site_preference('sitename', 'CMSMS Site'))));
    $url = $config['admin_url'] . '/login.php?recoverme=' . md5(md5($config['root_path'] . '--' . $user->username . md5($user->password)));
    $body = lang('lostpwemail', html_entity_decode(get_site_preference('sitename', 'CMSMS Site')), $user->username, $url);
    $obj->SetBody($body);
    audit('', 'Core', 'Sent Lost Password Email for ' . $username);
    return $obj->Send();
}
 public function execute($target = '', $data = array(), $age = '')
 {
     $mod = cms_utils::get_module('ModuleManager');
     if (!$age) {
         $age = get_site_preference('browser_cache_expiry', 60);
     }
     if ($age) {
         $age = max(1, (int) $age);
     }
     // build a signature
     $this->_signature = md5(serialize(array($target, $data)));
     $fn = $this->_getCacheFile();
     if (!$fn) {
         return;
     }
     // check for the cached file
     $atime = time() - $age * 60;
     $status = '';
     $resutl = '';
     if ($mod->GetPreference('disable_caching', 0) || !file_exists($fn) || filemtime($fn) <= $atime) {
         // execute the request
         $req = new cms_http_request();
         if ($this->_timeout) {
             $req->setTimeout($this->_timeout);
         }
         $req->execute($target, '', 'POST', $data);
         $this->_status = $req->getStatus();
         $this->_result = $req->getResult();
         @unlink($fn);
         if ($this->_status == 200) {
             // create a cache file
             $fh = fopen($fn, 'w');
             fwrite($fh, serialize(array($this->_status, $this->_result)));
             fclose($fh);
         }
     } else {
         // get data from the cache.
         $data = unserialize(file_get_contents($fn));
         $this->_status = $data[0];
         $this->_result = $data[1];
     }
 }
 public function __construct($input)
 {
     $mod = cms_utils::get_module('CGSmartImage');
     $this->_loc = $mod->GetPreference('croptofit_default_loc', 'c');
     if (cge_array::is_hash($input)) {
         if (isset($input['width'])) {
             $this->_dest_w = (int) $input['width'];
             $this->_dest_h = (int) $input['height'];
         } else {
             if (isset($input['w'])) {
                 $this->_dest_w = (int) $input['w'];
                 $this->_dest_h = (int) $input['h'];
             }
         }
         if (isset($input['loc']) && in_array($input['loc'], self::$_valid_locs)) {
             $this->_loc = $input['loc'];
         }
         if (isset($input['upscale'])) {
             $this->_upscale = (int) $input['upscale'];
         }
     } else {
         if (is_array($input)) {
             if (count($input) >= 2) {
                 $this->_dest_w = (int) trim($input[0]);
                 $this->_dest_h = (int) trim($input[1]);
                 if (count($input) >= 3 && in_array($input[2], self::$_valid_locs)) {
                     $this->_loc = $input[2];
                 }
                 if (count($input) >= 4) {
                     $this->_upscale = (int) $input[3];
                 }
             }
         }
     }
     if (!$this->_upscale) {
         $this->_dest_w = cgsi_utils::trim_to_device('width', $this->_dest_w);
         $this->_dest_h = cgsi_utils::trim_to_device('height', $this->_dest_h);
     }
     if ($this->_dest_h <= 0 || $this->_dest_w <= 0) {
         throw new Exception('Invalid values specified for Croptofit filter constructor');
     }
 }
 public function __construct($module_name)
 {
     $this->_module_name = trim($module_name);
     $this->_mod = \cms_utils::get_module($module_name);
     if (!$this->_mod) {
         throw new \RuntimeException(cgex_lang('err_modulenotfound', $module_name));
     }
     $dir = $this->_mod->GetModulePath();
     $this->_c1dat = $dir . '/_c1.dat';
     $this->_d1dat = $dir . '/_d1.dat';
     if (!is_writable($dir)) {
         throw new \RuntimeException(cgex_lang('err_vrfy_dirwritable', $module_name));
     }
     if (is_file($this->_c1dat) && !is_writable($this->_c1dat)) {
         throw new \RuntimeException(cgex_lang('err_vrfy_filewritable', $this->_c1dat));
     }
     if (is_file($this->_d1dat) && !is_writable($this->_d1dat)) {
         throw new \RuntimeException(cgex_lang('err_vrfy_filewritable', $this->_d1dat));
     }
 }
function smarty_core_get_module_plugin($_name, &$smarty)
{
    static $data;
    $fn = TMP_CACHE_LOCATION . '/modulefunctions.cache.dat';
    if (!count($data)) {
        if (!file_exists($fn)) {
            // build the cache list
            $loaded = array();
            $orig = array_keys($smarty->_plugins['function']);
            $installed = ModuleOperations::get_instance()->GetInstalledModules();
            $preloaded = ModuleOperations::get_instance()->GetLoadedModules();
            foreach ($installed as $module) {
                if (is_array($preloaded) || !count($preloaded) || !in_array($module, $preloaded)) {
                    $loaded[] = $module;
                }
                $obj = cms_utils::get_module($module);
                $tmp = array_keys($smarty->_plugins['function']);
                $tmp2 = array_diff($tmp, $orig);
                foreach ($tmp2 as $one) {
                    $data[$one] = $module;
                }
                $orig = $tmp;
            }
            foreach ($loaded as $module) {
                ModuleOperations::get_instance()->unload_module($module);
            }
            if (count($data)) {
                file_put_contents($fn, serialize($data));
            }
        } else {
            $data = unserialize(file_get_contents($fn));
        }
    }
    if (isset($data[$_name])) {
        // we know which module this plugin is associated with.
        // so make sure it's loaded.
        cms_utils::get_module($data[$_name]);
        return TRUE;
    }
    return FALSE;
}
Beispiel #24
0
 protected function after_uploaded_file($fileobject)
 {
     // here we may do image handling, and other cruft.
     if (is_object($fileobject) && $fileobject->name != '') {
         $mod = cms_utils::get_module('FileManager');
         $parms = array();
         $parms['file'] = filemanager_utils::join_path(filemanager_utils::get_full_cwd(), $fileobject->name);
         if ($mod->GetPreference('create_thumbnails')) {
             $thumb = cms_utils::generate_thumbnail($parms['file']);
             if ($thumb) {
                 $params['thumb'] = $thumb;
             }
         }
         $str = $fileobject->name . ' uploaded to ' . filemanager_utils::get_full_cwd();
         if (isset($params['thumb'])) {
             $str .= ' and a thumbnail was generated';
         }
         audit('', $mod->GetName(), $str);
         $mod->SendEvent('OnFileUploaded', $parms);
     }
 }
function smarty_function_cms_init_editor($params, &$template)
{
    $smarty = $template->smarty;
    // if the editor is not specified.
    $wysiwyg = '';
    if (isset($params['wysiwyg'])) {
        $wysiwyg = trim($params['wysiwyg']);
    }
    // get the frontend editor preference
    if (!$wysiwyg) {
        $wysiwyg = get_site_preference('frontendwysiwyg');
    }
    if (!$wysiwyg || (int) $wysiwyg < 0) {
        return;
    }
    $mod = cms_utils::get_module($wysiwyg);
    if (!is_object($mod)) {
        return;
    }
    if (!$mod->IsWYSIWYG()) {
        return;
    }
    // check to see if it is active
    if (!isset($params['force']) || $params['force'] != 0) {
        if (!$mod->WYSIWYGActive()) {
            return;
        }
    }
    // get the output
    $output = $mod->WYSIWYGGenerateHeader();
    if (!$output) {
        return;
    }
    // assign it or echo it.
    if (isset($params['assign'])) {
        $smarty->assign(trim($params['assign']) . $output);
        return;
    }
    return $output;
}
Beispiel #26
0
function cge_CreateInputSubmit(&$mod, $id, $name, $value = '', $addtext = '', $image = '', $confirmtext = '', $class = '', $alt = '', $elid = '')
{
    $real_image = '';
    if (!empty($image)) {
        $config = cms_config::get_instance();
        // check image_directories first
        if (isset($mod->_image_directories) && !empty($mod->_image_directories)) {
            foreach ($mod->_image_directories as $dir) {
                $url = cms_join_path($dir, $image);
                $path = cms_join_path($config['root_path'], $url);
                if (is_readable($path)) {
                    $real_image = $url;
                }
            }
        }
        $theme = cms_utils::get_theme_object();
        if (empty($real_image)) {
            $path = $config['root_path'] . '/' . $config['admin_dir'] . '/themes/' . $theme->themeName . '/images/';
            if (file_exists($path . $image)) {
                // its a theme image
                $real_image = $config['admin_dir'] . "/themes/" . $theme->themeName . '/images/' . $image;
            }
        }
        if (empty($real_image)) {
            if (is_object($theme)) {
                // we're in the admin
                if (!$alt) {
                    $alt = $value;
                }
                $txt = $theme->DisplayImage($image, $alt, '', '', $class);
                $real_image = $theme->imageLink[$image];
            }
        }
        $addtext .= ' title="' . $value . '"';
    }
    if (!empty($class)) {
        $addtext .= ' class="' . $class . '"';
    }
    return $mod->CreateInputSubmit($id, $name, $value, $addtext, $real_image, $confirmtext);
}
function smarty_cms_function_page_image($params, &$smarty)
{
    $result = '';
    $propname = 'image';
    if (isset($params['thumbnail'])) {
        $propname = 'thumbnail';
    }
    $gCms = cmsms();
    $contentobj =& cms_utils::get_current_content();
    if (is_object($contentobj)) {
        $result = $contentobj->GetPropertyValue($propname);
        if ($result == -1) {
            $result = '';
        }
    }
    if (isset($params['assign'])) {
        $smarty =& $gCms->GetSmarty();
        $smarty->assign($params['assign'], $result);
        return;
    }
    return $result;
}
function smarty_cms_function_module_available($params, &$template)
{
    $smarty = $template->smarty;
    $name = '';
    if (isset($params['name'])) {
        $name = trim($params['name']);
    }
    if (isset($params['m'])) {
        $name = trim($params['m']);
    }
    if (isset($params['module'])) {
        $name = trim($params['module']);
    }
    $out = FALSE;
    if ($name) {
        $out = cms_utils::module_available($name);
    }
    if (isset($params['assign'])) {
        $smarty->assign(trim($params['assign']), $out);
        return;
    }
    return $out;
}
 public function GetBlockInput()
 {
     $AdvancedContent =& cms_utils::get_module('AdvancedContent');
     $items = array();
     if ($this->GetBlockProperty('items') != '') {
         foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('items')) as $key => $val) {
             $items[$key]['label'] = trim($val);
             if ($this->GetBlockProperty('translate_labels')) {
                 $items[$key]['label'] = $AdvancedContent->lang($items[$key]['label']);
             }
             $items[$key]['value'] = $items[$key]['label'];
             $items[$key]['selected'] = trim($this->content_obj->GetPropertyValue($this->GetBlockProperty('id'))) === $items[$key]['value'];
         }
     }
     if ($this->GetBlockProperty('values') != '') {
         foreach (explode($this->GetBlockProperty('delimiter'), $this->GetBlockProperty('values')) as $key => $val) {
             $items[$key]['value'] = trim($val);
             if ($this->GetBlockProperty('translate_values')) {
                 $items[$key]['value'] = $AdvancedContent->lang($items[$key]['value']);
             }
             $items[$key]['selected'] = trim($this->content_obj->GetPropertyValue($this->GetBlockProperty('id'))) === $items[$key]['value'];
             if (!isset($items[$key]['label'])) {
                 $items[$key]['label'] = $items[$key]['value'];
             }
         }
     }
     $input = '<select name="' . $this->GetBlockProperty('id') . '" ' . ($this->GetBlockProperty('style') != '' ? 'style="' . $this->GetBlockProperty('style') . ' "' : '') . ' >';
     foreach ($items as $item) {
         $input .= '<option value="' . $item['value'] . '"';
         if ($item['selected']) {
             $input .= ' selected="selected"';
         }
         $input .= '>' . $item['label'] . '</option>';
     }
     $input .= '</select>';
     return $input;
 }
 /**
  * Get the output of the report.
  *
  * @return mixed the actual output format depends upon the template that is provided.
  */
 public function get_output()
 {
     $out = null;
     $data = parent::get_output();
     if (!is_array($data)) {
         return $out;
     }
     $smarty = cmsms()->GetSmarty();
     $smarty->assign('report_data', $data);
     $actionmodule = $smarty->get_template_vars('actionmodule');
     if ($actionmodule) {
         $mod = cms_utils::get_module($actionmodule);
         if (is_object($mod)) {
             if (endswith($this->get_template(), '.tpl')) {
                 $out = $mod->ProcessTemplate($this->get_template());
             } else {
                 $out = $mod->ProcessTemplateFromDatabase($this->get_template());
             }
         }
     } else {
         $out = $smarty->fetch('file:' . $template);
     }
     return $out;
 }