예제 #1
0
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('&', '***', $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_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;
}
예제 #3
0
 /**
  * @ignore
  */
 public function generate_ga()
 {
     // generate analytics stuff
     $property_id = \cge_param::get_string($this->_config, 'cghm_ga_propertyid');
     if (!$property_id) {
         return;
     }
     $linkdomains = \cge_param::get_string($this->_config, 'cghm_ga_linkdomains');
     if ($linkdomains) {
         $linkdomains = $this->str_to_array($linkdomains);
     }
     $subdomains = \cge_param::get_bool($this->_config, 'cghm_ga_subdomains');
     $domain = \cge_param::get_string($this->_config, 'cghm_ga_domain');
     if ($subdomains && !$domain) {
         $sysconfig = \cms_config::get_instance();
         $url = new \cms_url($sysconfig['root_url']);
         $domain = $url->get_host();
     }
     $tpl = $this->CreateSmartyTemplate('google_analytics.tpl');
     $tpl->assign('content_obj', \cms_utils::get_current_content());
     $tpl->assign('config', $this->_config);
     $tpl->assign('domain', $domain);
     if (count($linkdomains)) {
         $tpl->assign('linkdomains', $linkdomains);
     }
     return $tpl->fetch();
 }
예제 #4
0
 /**
  * Get the URL of the currently requested page.
  * Only works for frontend requests
  *
  * @deprecated
  * @return string
  */
 public static function page_url()
 {
     $content_obj = \cms_utils::get_current_content();
     if (is_object($content_obj)) {
         return $content_obj->GetURL();
     }
 }
예제 #5
0
#          The projects homepage is: cmsmadesimple.org
# Version: 0.9.4
# File   : action.default.php
#          This file is a modification of the default plugin {content}
# Purpose: performs the default frontend action if {AdvancedContent} is used.
# License: GPL
# deprecated
#-------------------------------------------------------------------------------
if (!is_object(cmsms())) {
    exit;
}
if (isset($params['active']) && ac_utils::IsFalse($params['active'])) {
    return;
}
# don't process inactive blocks
if (!($content_obj = cms_utils::get_current_content())) {
    return;
}
$config = cmsms()->GetConfig();
$type = isset($params['block_type']) ? $params['block_type'] : '';
if ($content_obj->Type() != 'advanced_content' && $content_obj->Type() != 'content2') {
    if ($type == 'image') {
        if (!function_exists('smarty_cms_function_content_image') && !function_exists('smarty_function_content_image')) {
            require_once $config['root_path'] . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'function.content_image.php';
        }
        $method = function_exists('smarty_cms_function_content_image') ? 'smarty_cms_function_content_image' : 'smarty_function_content_image';
        $output = trim($method($params, cmsms()->GetSmarty()));
    } else {
        if ($type == 'module') {
            if (!function_exists('smarty_cms_function_content_module') && !function_exists('smarty_function_content_module')) {
                require_once $config['root_path'] . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'function.content_module.php';
function smarty_cms_function_cms_stylesheet($params, &$template)
{
    #---------------------------------------------
    # Initials
    #---------------------------------------------
    $smarty = $template->smarty;
    $config = cmsms()->GetConfig();
    $db = cmsms()->GetDb();
    global $CMS_ADMIN_PAGE;
    global $CMS_LOGIN_PAGE;
    global $CMS_STYLESHEET;
    $CMS_STYLESHEET = 1;
    $template_id = -1;
    $use_https = 0;
    $cache_dir = $config['css_path'];
    $stylesheet = '';
    $combine_stylesheets = true;
    $fnsuffix = '';
    $trimbackground = FALSE;
    $forceblackandwhite = FALSE;
    $root_url = $config['css_url'];
    $auto_https = 1;
    #---------------------------------------------
    # Trivial Exclusion
    #---------------------------------------------
    if (isset($CMS_LOGIN_PAGE)) {
        return;
    }
    #---------------------------------------------
    # Read parameters
    #---------------------------------------------
    if (isset($params["templateid"]) && $params["templateid"] != "") {
        $template_id = $params["templateid"];
    } else {
        $content_obj = cms_utils::get_current_content();
        if (!is_object($content_obj)) {
            return;
        }
        $template_id = $content_obj->TemplateId();
        $use_https = (int) $content_obj->Secure();
    }
    if (isset($params['auto_https']) && $params['auto_https'] == 0) {
        $auto_https = 0;
    }
    if (isset($params['https'])) {
        $use_https = (int) $params['https'];
    }
    if ($auto_https && cmsms()->is_https_request()) {
        $use_https = 1;
    }
    if ($use_https && isset($config['ssl_url'])) {
        $root_url = $config['ssl_css_url'];
    }
    if (isset($params['nocombine']) && $params['nocombine'] == 1) {
        $combine_stylesheets = FALSE;
    }
    if (isset($params['stripbackground'])) {
        $trimbackground = (int) $params['stripbackground'];
    }
    if (isset($params['forceblackonwhite'])) {
        $forceblackandwhite = (int) $params['forceblackonwhite'];
    }
    if ($trimbackground || $forceblackandwhite) {
        $fnsuffix = '_e_';
    }
    #---------------------------------------------
    # Build query
    #---------------------------------------------
    $qparms = array();
    $where = array();
    $query = '';
    $order = '';
    if (isset($params['name']) && $params['name'] != '') {
        $query = 'SELECT DISTINCT A.css_id,A.css_name,A.css_text,A.modified_date,A.media_type,A.media_query
					FROM ' . cms_db_prefix() . 'css A';
        $where[] = 'A.css_name = ?';
        $qparms[] = trim($params['name']);
    } else {
        $query = 'SELECT DISTINCT A.css_id,A.css_name,A.css_text,A.modified_date,A.media_type,A.media_query,B.assoc_order
   	                FROM ' . cms_db_prefix() . 'css A
                    LEFT JOIN ' . cms_db_prefix() . 'css_assoc B ON A.css_id = B.assoc_css_id';
        $where[] = 'B.assoc_type = ? AND B.assoc_to_id = ?';
        $qparms = array('template', $template_id);
        if (isset($params['media']) && strtolower($params['media']) != 'all') {
            $types = explode(',', $params['media']);
            $expr = array();
            foreach ($types as $type) {
                $expr[] = 'media_type LIKE ?';
                $qparms[] = '%' . trim($type) . '%';
            }
            $expr[] = 'media_type LIKE ?';
            $qparms[] = '%all%';
            $where[] = '(' . implode(' OR ', $expr) . ')';
        }
        $order = 'ORDER BY B.assoc_order';
    }
    $query .= " WHERE " . implode(' AND ', $where) . ' ' . $order;
    #---------------------------------------------
    # Execute
    #---------------------------------------------
    $res = $db->GetArray($query, $qparms);
    if ($res) {
        // Combine stylesheets
        if ($combine_stylesheets) {
            // Group queries & types
            $all_media = array();
            $all_timestamps = array();
            $all_timestamps_string = '';
            foreach ($res as $one) {
                if (!empty($one['media_query'])) {
                    $key = md5($one['media_query']);
                    $all_media[$key][] = $one;
                    $all_timestamps[$key][] = strtotime($one['modified_date']);
                } elseif (!empty($one['media_type'])) {
                    $key = md5($one['media_type']);
                    $all_media[$key][] = $one;
                    $all_timestamps[$key][] = strtotime($one['modified_date']);
                } else {
                    $all_media['all'][] = $one;
                    $all_timestamps['all'][] = strtotime($one['modified_date']);
                }
                $all_timestamps_string .= strtotime($one['modified_date']);
                // <- This is for media param
            }
            // Stupid media parameter...
            if (isset($params['media'])) {
                // combine all matches into one stylesheet.
                $filename = 'stylesheet_combined_' . md5($template_id . $use_https . serialize($params) . $all_timestamps_string . $fnsuffix) . '.css';
                $fn = cms_join_path($cache_dir, $filename);
                if (!file_exists($fn)) {
                    $text = '';
                    foreach ($res as $one) {
                        $text .= $one['css_text'];
                        // moved this to bottom, comments on top of stylesheets cause invalid css when using @charset
                        $text .= "\n/* End of Stylesheet: " . $one['css_name'] . " Modified On " . $one['modified_date'] . " */\n";
                        if (!endswith($text, "\n")) {
                            $text .= "\n";
                        }
                    }
                    cms_stylesheet_writeCache($fn, $text, $trimbackground, $smarty, $forceblackandwhite, $template_id);
                }
                cms_stylesheet_toString($filename, $params['media'], '', $root_url, $stylesheet, $params);
            } else {
                // Group timestamps
                foreach ($all_timestamps as $k => $v) {
                    $all_timestamps[$k] = implode($v);
                }
                foreach ($all_media as $hash => $onemedia) {
                    // combine all matches into one stylesheet.
                    $filename = 'stylesheet_combined_' . md5($template_id . $use_https . serialize($params) . $all_timestamps[$hash] . $fnsuffix) . '.css';
                    $fn = cms_join_path($cache_dir, $filename);
                    // Get media_type and media_query
                    $media_query = $onemedia[0]['media_query'];
                    $media_type = $onemedia[0]['media_type'];
                    if (!file_exists($fn)) {
                        $text = '';
                        foreach ($onemedia as $one) {
                            $text .= $one['css_text'];
                            // moved this to bottom, comments on top of stylesheets cause invalid css when using @charset
                            $text .= "\n/* Stylesheet: " . $one['css_name'] . " Modified On " . $one['modified_date'] . " */\n";
                            if (!endswith($text, "\n")) {
                                $text .= "\n";
                            }
                        }
                        cms_stylesheet_writeCache($fn, $text, $trimbackground, $smarty, $forceblackandwhite, $template_id);
                    }
                    cms_stylesheet_toString($filename, $media_query, $media_type, $root_url, $stylesheet, $params);
                }
            }
            // Do not combine stylesheets
        } else {
            foreach ($res as $one) {
                if (isset($params['media'])) {
                    $media_query = $params['media'];
                    $media_type = '';
                } else {
                    $media_query = $one['media_query'];
                    $media_type = $one['media_type'];
                }
                $filename = 'stylesheet_' . md5('single' . $one['css_id'] . $use_https . strtotime($one['modified_date']) . $fnsuffix) . '.css';
                $fn = cms_join_path($cache_dir, $filename);
                if (!file_exists($fn)) {
                    cms_stylesheet_writeCache($fn, $one['css_text'], $trimbackground, $smarty, $forceblackandwhite, $template_id);
                }
                cms_stylesheet_toString($filename, $media_query, $media_type, $root_url, $stylesheet, $params);
            }
        }
    }
    #---------------------------------------------
    # Cleanup & output
    #---------------------------------------------
    // Deprecate this
    if (!(isset($config["use_smarty_php_tags"]) && $config["use_smarty_php_tags"] == true)) {
        $stylesheet = preg_replace("/\\{\\/?php\\}/", "", $stylesheet);
    }
    // Remove last comma at the end when $params['nolinks'] is set
    if (isset($params['nolinks']) && endswith($stylesheet, ',')) {
        $stylesheet = substr($stylesheet, 0, strlen($stylesheet) - 1);
    }
    // Notify core that we are no longer at stylesheet, pretty ugly way to do this. -Stikki-
    $CMS_STYLESHEET = 0;
    unset($CMS_STYLESHEET);
    unset($GLOBALS['CMS_STYLESHEET']);
    if (isset($params['assign'])) {
        $smarty->assign(trim($params['assign']), $stylesheet);
        return;
    }
    return $stylesheet;
}
예제 #7
0
 /**
  * Generate a URL to an anchor on the same page
  *
  * @param string $name The name of the anchor
  * @return string
  */
 public static function anchor_url($name)
 {
     if (!$name) {
         return;
     }
     $name = trim($name);
     if (!$name) {
         return;
     }
     $content_obj = \cms_utils::get_current_content();
     if (!is_object($content_obj)) {
         return;
     }
     return $content_obj->GetURL() . '#' . $name;
 }