public function GetHeaderHTML() { if ($this->_header_html_called) { return; } $this->_header_html_called = true; $config = cmsms()->GetConfig(); $ret = ' <link rel=stylesheet href="' . $config['root_url'] . '/modules/AdvancedContent/css/jpicker.css" type="text/css" /> <script language="javascript" type="text/javascript" src="' . $config['root_url'] . '/modules/AdvancedContent/js/jquery.jpicker.min.js" defer="true"></script> <script language="javascript" type="text/javascript"> /* <![CDATA[ */ ac_onload.push(function(){ (function($){ $.fn.jPicker.defaults.images.clientPath="' . $config['root_url'] . '/modules/AdvancedContent/images/jpicker/";'; foreach (acContentBlockManager::GetBlocksByType('colorpicker') as $block_id) { $ret .= '$("#' . $block_id . '").jPicker();'; } return $ret . ' })(jQuery); }); /* ]]> */ </script>'; }
public static function notify_users(cgfb_comment &$comment) { self::prepare_smarty_vars($comment); $mod = cms_utils::get_module('CGFeedback'); $db = cmsms()->GetDb(); $query = 'SELECT DISTINCT author_email,author_name FROM ' . CGFEEDBACK_TABLE_COMMENTS . ' WHERE key1 = ? AND key2 = ? AND key3 = ? AND status = ? and author_notify = 1'; $users = $db->GetArray($query, array($comment->key1, $comment->key2, $comment->key3, CGFEEDBACK_STATUS_PUBLISHED)); if (!is_array($users)) { return TRUE; } $mailer = cms_utils::get_module('CMSMailer'); if (!$mailer) { return FALSE; } $mailer->reset(); $mailer->IsHTML($mod->GetPreference('usernotification_ishtml', 1)); $subj = $mod->GetPreference(CGFEEDBACK_PREF_USERNOTIFICATION_SUBJECT); $mailer->SetSubject($subj); $body = $mod->ProcessTemplateFromDatabase(CGFEEDBACK_PREF_USERNOTIFICATION_TEMPLATE); $mailer->SetBody($body); for ($i = 0; $i < count($users); $i++) { if (!is_email($users[$i]['author_email'])) { continue; } $mailer->ClearAddresses(); $mailer->AddAddress($users[$i]['author_email'], $users[$i]['author_name']); $mailer->Send(); } $comment->notified = 1; }
public function GetHeaderHTML() { $config = cmsms()->GetConfig(); $ret = ' <script language="javascript" type="text/javascript" src="' . $config['root_url'] . '/modules/AdvancedContent/js/jquery.jslider.min.js"></script> <script language="javascript" type="text/javascript"> /* <![CDATA[ */ jQuery(document).ready(function() {'; foreach ($this->content_obj->GetBlocksByType('slider') as $block_id) { $ret .= 'jQuery("#' . $block_id . '").j_slider('; if (count($this->GetBlockProperty('slider_params'))) { $ret .= '{'; $slider_params = array(); foreach ($this->GetBlockProperty('slider_params') as $paramName => $paramValue) { $slider_params[] = $paramName . ': ' . $paramValue; } $ret .= implode(',', $slider_params) . '}'; } $ret .= ');'; } return $ret . ' }); /* ]]> */ </script>'; }
/** * A function to return an expanded list of user id's given an input list * if one of the id's specified is negative, it is assumed to be a group id * and is expanded to its members. * * @param mixed A comma separated string, or an array of userid's or negative group id's. * @return array */ public static function expand_userlist($useridlist) { $users = array(); if (!is_array($useridlist)) { $useridlist = explode(',', $useridlist); } if (!count($useridlist)) { return $users; } $userops = cmsms()->GetUserOperations(); foreach ($useridlist as $oneuid) { if ($oneuid < 0) { // assume its a group id // and get all the uids for that group $groupusers = $userops->LoadUsersInGroup($oneuid * -1); foreach ($groupusers as $oneuser) { $users[] = $oneuser->id; } } else { $users[] = $oneuid; } } $users = array_unique($users); return $users; }
public function GetHelp() { $smarty = cmsms()->GetSmarty(); $smarty->assign('help_title', $this->Lang('help_title')); $smarty->assign('help_p1', $this->Lang('help_p1')); $smarty->assign('help_h1', $this->Lang('help_h1')); $smarty->assign('help_p2', $this->Lang('help_p2')); $smarty->assign('help_h2', $this->Lang('help_h2')); $smarty->assign('help_p3', $this->Lang('help_p3')); $smarty->assign('help_feat_listitem1', $this->Lang('help_feat_listitem1')); $smarty->assign('help_feat_listitem2', $this->Lang('help_feat_listitem2')); $smarty->assign('help_feat_listitem3', $this->Lang('help_feat_listitem3')); $smarty->assign('help_feat_listitem4', $this->Lang('help_feat_listitem4')); $smarty->assign('help_feat_listitem5', $this->Lang('help_feat_listitem5')); $smarty->assign('help_feat_listitem6', $this->Lang('help_feat_listitem6')); $smarty->assign('help_h3', $this->Lang('help_h3')); $smarty->assign('help_p4', $this->Lang('help_p4')); $smarty->assign('help_prefs_listitem1', $this->Lang('help_prefs_listitem1')); $smarty->assign('help_prefs_listitem2', $this->Lang('help_prefs_listitem2')); $smarty->assign('help_prefs_listitem3', $this->Lang('help_prefs_listitem3')); $smarty->assign('help_prefs_listitem4', $this->Lang('help_prefs_listitem4')); $smarty->assign('help_prefs_listitem5', $this->Lang('help_prefs_listitem5')); $smarty->assign('help_h4', $this->Lang('help_h4')); $smarty->assign('help_p5', $this->Lang('help_p5')); $smarty->assign('help_h5', $this->Lang('help_h5')); $smarty->assign('help_p6', $this->Lang('help_p6')); return $this->ProcessTemplate('help.tpl'); }
public function __construct() { global $CMS_INSTALL_PAGE, $CMS_PHAR_INSTALL; if (isset($CMS_INSTALL_PAGE) || isset($CMS_PHAR_INSTALL)) { return; } parent::__construct(); $fn = __DIR__ . '/class.cgsimple.php'; require_once $fn; $smarty = cmsms()->GetSmarty(); if (!$smarty) { return; } $cgsimple = new cgsimple(); $smarty->assign('cgsimple', $cgsimple); $smarty->registerClass('cgsimple', 'cgsimple'); $smarty->register_function('module_action_link', 'module_action_link'); $smarty->register_function('module_action_url', 'module_action_url'); $smarty->register_function('cgrepeat', 'smarty_function_cgrepeat'); $smarty->register_function('session_put', 'smarty_function_session_put'); $smarty->register_function('session_erase', 'smarty_function_session_erase'); $smarty->register_function('cgsi_array_set', array($this, 'plugin_array_set')); $smarty->register_function('cgsi_array_unset', array($this, 'plugin_array_unset')); $smarty->register_function('anchor_link', array($this, 'plugin_anchorlink')); }
/** * A method to re-initialize connections to the CMSMS configured database. * This method should be used by any UDT's or other plugins that use any other method * than the standard CMSMS supplied database object to connect to a database. * */ function &adodb_connect() { $gCms = cmsms(); $config = $gCms->GetConfig(); $str = 'pear:date:extend'; if (isset($config['db_transactions'])) { $str .= ':transaction'; } $dbinstance = ADONewConnection($config['dbms'], $str); $dbinstance->raiseErrorFn = "adodb_error"; $conn_func = isset($config['persistent_db_conn']) && $config['persistent_db_conn'] == true ? 'PConnect' : 'Connect'; if (!empty($config['db_port'])) { $dbinstance->port = $config['db_port']; } $connect_result = $dbinstance->{$conn_func}($config['db_hostname'], $config['db_username'], $config['db_password'], $config['db_name']); if (FALSE == $connect_result) { $str = "Attempt to connect to database {$config['db_name']} on {$config['db_username']}@{$config['db_hostname']} failed"; trigger_error($str, E_USER_ERROR); die($str); } $dbinstance->raiseErrorFn = null; $dbinstance->SetFetchMode(ADODB_FETCH_ASSOC); if ($config['debug'] == true) { $dbinstance->debug = true; } if (!empty($config['default_encoding']) && $config['default_encoding'] == 'utf-8' && $config['set_names'] == true) { $dbinstance->Execute("SET NAMES 'utf8'"); } return $dbinstance; }
public static function unix_time($string) { // snarfed from smarty. $string = trim($string); $time = ''; if (empty($string)) { // use "now": $time = time(); } elseif (preg_match('/^\\d{14}$/', $string)) { // it is mysql timestamp format of YYYYMMDDHHMMSS? $time = mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4)); } elseif (preg_match("/(\\d{4})-(\\d{2})-(\\d{2})\\s(\\d{2}):(\\d{2}):(\\d{2})/", $string, $dt)) { $time = mktime($dt[4], $dt[5], $dt[6], $dt[2], $dt[3], $dt[1]); } elseif (is_numeric($string)) { // it is a numeric string, we handle it as timestamp $time = (int) $string; } else { // strtotime should handle it $time = strtotime($string); if ($time == -1 || $time === false) { // strtotime() was not able to parse $string, use "now": // but try one more thing list($p1, $p2) = explode(' ', $string, 2); $db = cmsms()->GetDb(); $time = $db->UnixTimeStamp($string); if (!$time) { $time = time(); } } } return $time; }
/** * 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 __construct($smarty) { parent::__construct($smarty); $config = cmsms()->GetConfig(); $this->allow_php_tag = $config['use_smarty_php_tags']; $this->php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time', 'lang', 'nl2br', 'file_exists', 'is_string', 'is_object', 'is_file', 'print_r', 'var_dump', 'htmlspecialchars', 'htmlspecialchars_decode'); }
function cge_CGCreateInputSubmit(&$mod, $id, $name, $value = '', $addtext = '', $image = '', $confirmtext = '', $class = '') { $real_image = ''; if (!empty($image)) { $config = cmsms()->GetConfig(); // 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; } } } if (empty($real_image)) { $theme = cmsms()->variables['admintheme']; if (is_object($theme)) { // we're in the admin $txt = $theme->DisplayImage($image, $alt, $width, $height, $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 PrePopulateAdminForm($formDescriptor) { $gCms = cmsms(); $mod = $this->form_ptr->module_ptr; $fpt = $this->form_ptr; $main = array(); $adv = array(); $methods = array('POST' => 'POST', 'GET' => 'GET'); if (!function_exists('curl_init')) { array_push($main, array('', $mod->Lang('title_install_curl'))); } else { array_push($main, array($mod->Lang('title_method'), $mod->CreateInputDropdown($formDescriptor, 'fbrp_opt_method', $methods, -1, $this->GetOption('method')))); array_push($main, array($mod->Lang('title_url'), $mod->CreateInputText($formDescriptor, 'fbrp_opt_url', $this->GetOption('url', ''), 40, 255) . '<br />' . $mod->Lang('title_url_help'))); $fields = $fpt->GetFields(); foreach ($fields as $tf) { $al = $tf->GetAlias(); if (empty($al)) { $al = $tf->GetVariableName(); } array_push($adv, array($mod->Lang('title_maps_to', $tf->GetName()), $mod->CreateInputText($formDescriptor, 'fbrp_opt_fld_' . $tf->GetId(), $this->GetOption('fld_' . $tf->GetId(), $al), 40, 255) . $mod->CreateInputHidden($formDescriptor, 'fbrp_opt_sub_' . $tf->GetId(), '0') . $mod->CreateInputCheckbox($formDescriptor, 'fbrp_opt_sub_' . $tf->GetId(), '1', $this->GetOption('sub_' . $tf->GetId(), $tf->DisplayInSubmission() ? '1' : '0')) . $mod->Lang('title_include_in_submission'))); } array_push($adv, array($mod->Lang('title_additional'), $mod->CreateInputText($formDescriptor, 'fbrp_opt_additional', $this->GetOption('additional'), 40, 255) . '<br />' . $mod->Lang('title_additional_help'))); } return array('main' => $main, 'adv' => $adv); }
public static function &get_watermarker() { $mod = cge_utils::get_cge(); $txt = $mod->GetPreference('watermark_text'); $img = $mod->GetPreference('watermark_file'); $obj = new cg_watermark(); if (!empty($img)) { $config = cmsms()->GetConfig(); $obj->set_watermark_image($config['uploads_path'] . '/' . $img); } else { if (!empty($txt)) { $obj->set_watermark_text($txt); $font = $mod->GetPreference('watermark_font'); $obj->set_font($font); $obj->set_text_size($mod->GetPreference('watermark_textsize')); $obj->set_text_angle($mod->GetPreference('watermark_textangle')); $tmp = $mod->GetPreference('watermark_textcolor'); $r = hexdec(substr($tmp, 1, 2)); $g = hexdec(substr($tmp, 3, 2)); $b = hexdec(substr($tmp, 5, 2)); $obj->set_text_color($r, $g, $b); $tmp = $mod->GetPreference('watermark_bgcolor'); $r = hexdec(substr($tmp, 1, 2)); $g = hexdec(substr($tmp, 3, 2)); $b = hexdec(substr($tmp, 5, 2)); $obj->set_background_color($r, $g, $b, $mod->GetPreference('watermark_transparent', 1)); } } $obj->set_alignment($mod->GetPreference('watermark_alignment')); $obj->set_translucency($mod->GetPreference('watermark_translucency', 100)); return $obj; }
function cms_autoloader($classname) { //if( $classname != 'Smarty_CMS' && $classname != 'Smarty_Parser' && startswith($classname,'Smarty') ) return; $config = cmsms()->GetConfig(); // standard classes $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php"); if (file_exists($fn)) { __cms_load($fn); return; } $lowercase = strtolower($classname); $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php"); if (file_exists($fn) && $classname != 'Content') { __cms_load($fn); return; } // standard interfaces $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php"); if (file_exists($fn)) { __cms_load($fn); return; } global $CMS_LAZYLOAD_MODULES; global $CMS_INSTALL_PAGE; if (!isset($CMS_LAZYLOAD_MODULES) || isset($CMS_INSTALL_PAGE)) { return; } // standard content types $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php"); if (file_exists($fn)) { __cms_load($fn); return; } // module loaded content types $contentops = ContentOperations::get_instance(); if ($contentops) { // why would this ever NOT be true.. dunno, but hey. $types = $contentops->ListContentTypes(); if (in_array(strtolower($classname), array_keys($types))) { $contentops->LoadContentType(strtolower($classname)); return; } } $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php"; if (file_exists($fn)) { __cms_load($fn); return; } $list = ModuleOperations::get_instance()->GetLoadedModules(); if (is_array($list) && count($list)) { foreach (array_keys($list) as $modname) { $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php"; if (file_exists($fn)) { __cms_load($fn); return; } } } // module classes }
private static function _parse_template(&$content_obj) { $templateops =& cmsms()->GetTemplateOperations(); if ($content_obj->TemplateId() > 0) { $template = $templateops->LoadTemplateByID($content_obj->TemplateId()); } else { # should not be needed since CMSms 1.11 $template = $templateops->LoadDefaultTemplate(); $content_obj->SetTemplateId($template->id); } $matches = array(); $result = preg_match_all(AC_BLOCK_PATTERN, $template->content, $matches); if (!$result || !count($matches[1])) { return; } $AC =& ac_utils::get_module('AdvancedContent'); foreach ($matches[1] as $wholetag) { if (!($contentBlock = self::CreateContentBlock($content_obj, self::GetTagParams($wholetag)))) { continue; } # do not process blocks with same id twice if (isset(self::$_content_blocks[$content_obj->Id()][$contentBlock->GetProperty('id')])) { self::$_content_blocks[$content_obj->Id()][$contentBlock->GetProperty('id')]->SetProperty('multiple', true); continue; } self::_register_content_block($content_obj, $contentBlock); } }
public function get_attribute_input($attr, $content_obj, $adding) { $gCms = cmsms(); $feu = self::get_feu(); switch ($attr->get_name()) { case 'feu_groups': $tmp = array($feu->Lang('any_logged_in_user') => '-1'); $t2 = $feu->GetGroupList(); foreach ($t2 as $k => $v) { $tmp[$k] = $v; } if (is_array($tmp)) { $sel = array(); $sel_str = $content_obj->get_property_value('feu_groups'); if ($sel_str) { $sel = explode(',', $sel_str); } $prompt = $feu->Lang('feu_groups_prompt'); $field = $feu->CreateInputSelectList('', 'feu_groups[]', $tmp, $sel, min(count($tmp), 5)); return array($prompt . ':', $field); } break; case 'feu_redirect': // get a list of pages $val = $content_obj->get_property_value('feu_redirect', -1); $prompt = $feu->Lang('feu_redirect_prompt'); $field = CmsContentOperations::CreateHierarchyDropdown($val, '', 'feu_redirect'); return array($prompt . ':', $field); break; } }
public static function get_modules_with_method($methodname) { $gCms = cmsms(); $res = array(); if (version_compare(CMS_VERSION, '1.10-beta0') < 0) { foreach ($gCms->modules as $modulename => $onemodule) { if (!isset($onemodule['object'])) { continue; } $mod =& $onemodule['object']; if (!method_exists($mod, $methodname)) { continue; } $res[$mod->GetName()] = $mod->GetFriendlyName(); } } else { $modules = ModuleOperations::get_instance()->GetInstalledModules(); foreach ($modules as $onemodule) { $mod = ModuleOperations::get_instance()->get_module_instance($onemodule); if (!$mod) { continue; } if (!method_exists($mod, $methodname)) { continue; } $res[$mod->GetName()] = $mod->GetFriendlyName(); } } if (empty($res)) { return FALSE; } return $res; }
protected function fetch($name, &$source, &$mtime) { debug_buffer('start global_content_get_template'); $gCms = cmsms(); $config = $gCms->GetConfig(); $gcbops = $gCms->GetGlobalContentOperations(); $oneblob = $gcbops->LoadHtmlBlobByName($name); if ($oneblob) { $text = $oneblob->content; $source = $text; $mtime = $oneblob->modified_date; // So no one can do anything nasty, take out the php smarty tags. Use a user // defined plugin instead. if (!(isset($config["use_smarty_php_tags"]) && $config["use_smarty_php_tags"] == true)) { $source = preg_replace("/\\{\\/?php\\}/", "", $source); } } else { $source = "<!-- Html blob '" . $name . "' does not exist -->"; // put mention into the admin log audit('', 'Global Content Block: ' . $name, 'Can not open or does not exist!'); $mtime = time(); } debug_buffer('end global_content_get_template'); return true; }
function smarty_cms_function_content_module($params, &$smarty) { $result = ''; $key = ''; if (isset($params['block'])) { $block = $params['block']; } $gCms = cmsms(); $content_obj =& $gCms->variables['content_obj']; $manager =& $gCms->GetHierarchyManager(); $node = $manager->sureGetNodeById($content_obj->Id()); if (is_object($node)) { $contentobj =& $node->GetContent(); if (is_object($contentobj)) { $result = $contentobj->GetPropertyValue($block); if ($result == -1) { $result = ''; } } } if (isset($params['assign'])) { $smarty =& $gCms->GetSmarty(); $smarty->assign($params['assign'], $result); return; } return $result; }
function smarty_modifier_cms_date_format($string, $format = '', $default_date = '') { $gCms = cmsms(); if ($format == '') { $format = get_site_preference('defaultdateformat'); if ($format == '') { $format = '%b %e, %Y'; } if (!isset($gCms->variables['page_id'])) { $uid = get_userid(false); if ($uid) { $tmp = get_preference($uid, 'date_format_string'); if ($tmp != '') { $format = $tmp; } } } } $config = $gCms->GetConfig(); $fn = cms_join_path($config['root_path'], 'lib', 'smarty', 'plugins', 'modifier.date_format.php'); if (!file_exists($fn)) { die; } require_once $fn; return smarty_modifier_date_format($string, $format, $default_date); }
function smarty_function_anchor($params, &$template) { $smarty = $template->smarty; $gCms = cmsms(); #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 $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $str = $_SERVER['REQUEST_URI']; $pos = strpos($str, '?'); if ($pos !== FALSE) { $str = substr($str, 0, $pos); } $pageURL .= $_SERVER["SERVER_NAME"] . $str; } if (isset($pageURL)) { $url = cms_htmlentities($_SERVER['REQUEST_URI']) . '#' . $params['anchor']; $url = str_replace('&', '***', $url); $url = str_replace('&', '&', $url); $url = str_replace('***', '&', $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; }
function smarty_function_recently_updated($params, &$template) { $smarty = $template->smarty; if (empty($params['number'])) { $number = 10; } else { $number = $params['number']; } if (empty($params['leadin'])) { $leadin = "Modified: "; } else { $leadin = $params['leadin']; } if (empty($params['showtitle'])) { $showtitle = 'true'; } else { $showtitle = $params['showtitle']; } $dateformat = isset($params['dateformat']) ? $params['dateformat'] : "d.m.y h:m"; $css_class = isset($params['css_class']) ? $params['css_class'] : ""; if (isset($params['css_class'])) { $output = '<div class="' . $css_class . '"><ul>'; } else { $output = '<ul>'; } $gCms = cmsms(); $hm = $gCms->GetHierarchyManager(); $db = $gCms->GetDb(); // Get list of most recently updated pages excluding the home page $q = "SELECT * FROM " . cms_db_prefix() . "content WHERE (type='content' OR type='link')\nAND default_content != 1 AND active = 1 AND show_in_menu = 1 \nORDER BY modified_date DESC LIMIT " . (int) $number; $dbresult = $db->Execute($q); if (!$dbresult) { echo 'DB error: ' . $db->ErrorMsg() . "<br/>"; } while ($dbresult && ($updated_page = $dbresult->FetchRow())) { $curnode = $hm->getNodeById($updated_page['content_id']); $curcontent =& $curnode->GetContent(); $output .= '<li>'; $output .= '<a href="' . $curcontent->GetURL() . '">' . $updated_page['content_name'] . '</a>'; if (FALSE == empty($updated_page['titleattribute']) && $showtitle == 'true') { $output .= '<br />'; $output .= $updated_page['titleattribute']; } $output .= '<br />'; $output .= $leadin; $output .= date($dateformat, strtotime($updated_page['modified_date'])); $output .= '</li>'; } $output .= '</ul>'; if (isset($params['css_class'])) { $output .= '</div>'; } if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $output); return; } return $output; }
function calendar_HandleUpload(&$mod, $fldname, &$error) { $config = cmsms()->GetConfig(); $destDir = $mod->GetPreference('uploaddirectory', $config['uploads_path']); if (!isset($_FILES) || !isset($_FILES[$fldname]) || !$_FILES[$fldname]['name']) { $error = $mod->Lang('error_noupload'); return false; } $file =& $_FILES[$fldname]; if (!isset($file['type'])) { $file['type'] = ''; } if (!isset($file['name'])) { $file['name'] = ''; } if (!isset($file['size'])) { $file['size'] = ''; } $file['name'] = preg_replace('/[^a-zA-Z0-9\\.\\$\\%\'\\`\\-\\@\\{\\}\\~\\!\\#\\(\\)\\&\\_\\^]/', '', str_replace(array(' ', '%20'), array('_', '_'), $file['name'])); if (!$mod->isValidFilename($file['name'])) { $error = $mod->Lang('error_invalidfilename'); return false; } if ($file['error'] != 0 || $file['size'] == '' || $file['size'] == 0) { $error = $mod->Lang('error_problemwithupload'); return false; } $destname = $file['name']; $destfilespec = cms_join_path($destDir, $destname); if (file_exists($destfilespec)) { if ($mod->GetPreference('uploadunique', 1) == 1) { $i = 0; for ($i = 0; $i < 100; $i++) { $destname = $file['name']; if ($i > 0) { $destname = $i . '_' . $file['name']; } $destfilespec = cms_join_path($destDir, $destname); if (!file_exists($destfilespec)) { break; } } if ($i == 100) { $error = $mod->Lang('error_fileexists'); return false; } } else { $error = $mod->Lang('error_fileexists'); return false; } } if (!@copy($file['tmp_name'], $destfilespec)) { $error = $mod->Lang('error_filecopyfailed'); return false; } return $destname; }
function PrePopulateAdminForm($formDescriptor) { $mod = $this->form_ptr->module_ptr; $gCms = cmsms(); $contentops = $gCms->GetContentOperations(); $main = array(array($mod->Lang('title_link_autopopulate'), $mod->CreateInputCheckbox($formDescriptor, 'fbrp_opt_auto_link', '1', $this->GetOption('auto_link', '0')) . $mod->Lang('title_link_autopopulate_help')), array($mod->Lang('title_link_to_sitepage'), $contentops->CreateHierarchyDropdown('', $this->GetOption('target_page', ''), $formDescriptor . 'fbrp_opt_target_page'))); $adv = array(); return array('main' => $main, 'adv' => $adv); }
function __construct(&$content_obj, &$params = array()) { $params['type'] = 'image'; parent::__construct($content_obj, $params); $config = cmsms()->GetConfig(); $this->SetBlockProperty('prefix', isset($params['prefix']) ? $params['prefix'] : 'thumb_'); $this->SetBlockProperty('exclude', isset($params['exclude']) && $this->content_obj->IsFalse($params['exclude'])); $this->SetBlockProperty('dir', cms_join_path($config['uploads_path'], isset($params['dir']) ? $params['dir'] : get_site_preference('contentimage_path'))); $this->SetBlockProperty('inputname', isset($params['inputname']) ? $params['inputname'] : $this->GetBlockProperty('id')); }
function smarty_function_uploads_url($params, &$smarty) { $gCms = cmsms(); $config = $gCms->GetConfig(); if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $config['uploads_url']); return; } return $config['uploads_url']; }
function GetFieldInput($id, &$params, $returnid) { $mod =& $this->form_ptr->module_ptr; $v = $this->GetOption('value', ''); cmsms()->GetSmarty()->assign('FBid', $id . 'fbrp__' . $this->Id); // for selected... what to do here // for things like checked="checked" on the back page cmsms()->GetSmarty()->assign('FBvalue', $this->Value); return $mod->ProcessTemplateFromData($v); }
private static function __make() { if (is_null(self::$_store)) { self::$_store = new cge_datastore(self::$_timeout); self::$_key = md5('encrypted_store'); $config = cmsms()->GetConfig(); $key = md5($config['root_url'] + $config['root_path'] + getenv('REMOTE_ADDR')); self::$_enckey = $key; } }
public function execute($time = '') { if (!$time) { $time = time(); } // do the task. $age_days = (int) get_site_preference(self::CACHEDFILEAGE_SITEPREF, 0); $gCms = cmsms(); $gCms->clear_cached_files($age_days); return TRUE; }
function smarty_function_sitename($params, &$template) { $smarty = $template->smarty; $result = get_site_preference('sitename', 'CMSMS Site'); if (isset($params['assign'])) { $gCms = cmsms(); $smarty->assign(trim($params['assign']), $result); return; } return $result; }