コード例 #1
1
/**
 * Campsite url function plugin
 *
 * Type:     function
 * Name:     url
 * Purpose:
 *
 * @param array $p_params
 * @param object $p_smarty
 *      The Smarty object
 *
 * @return string $urlString
 *      The full URL string
 */
function smarty_function_url($p_params, &$p_smarty)
{
    $context = $p_smarty->getTemplateVars('gimme');
    $validValues = array('true', 'false', 'http', 'https');
    if (isset($p_params['useprotocol']) && in_array($p_params['useprotocol'], $validValues)) {
        $useprotocol = $p_params['useprotocol'];
    } else {
        $useprotocol = $p_smarty->useprotocol;
    }
    switch ($useprotocol) {
        case 'true':
            $urlString = $context->url->base;
            break;
        case 'false':
            $urlString = $context->url->base_relative;
            break;
        case 'http':
            $urlString = 'http:' . $context->url->base_relative;
            break;
        case 'https':
            $urlString = 'https:' . $context->url->base_relative;
            break;
    }
    // appends the URI path and query values to the base
    $urlString .= smarty_function_uri($p_params, $p_smarty);
    return $urlString;
}
コード例 #2
0
ファイル: function.url.php プロジェクト: nidzix/Newscoop
/**
 * Campsite url function plugin
 *
 * Type:     function
 * Name:     url
 * Purpose:
 *
 * @param array $p_params
 * @param object $p_smarty
 *      The Smarty object
 *
 * @return string $urlString
 *      The full URL string
 */
function smarty_function_url($p_params, &$p_smarty)
{
    $context = $p_smarty->getTemplateVars('gimme');
    // gets the URL base
    $urlString = $context->url->base;
    // appends the URI path and query values to the base
    $urlString .= smarty_function_uri($p_params, $p_smarty);
    return $urlString;
}
コード例 #3
0
ファイル: function.url.php プロジェクト: nistormihai/Newscoop
/**
 * Campsite url function plugin
 *
 * Type:     function
 * Name:     url
 * Purpose:
 *
 * @param array $p_params
 * @param object $p_smarty
 *      The Smarty object
 *
 * @return string $urlString
 *      The full URL string
 */
function smarty_function_url($p_params, &$p_smarty)
{
    $context = $p_smarty->get_template_vars('gimme');
    // gets the URL base
    $urlString = $context->url->base;

    // includes the smarty camp uri plugin
    require_once($p_smarty->_get_plugin_filepath('function', 'uri'));

    // appends the URI path and query values to the base
    $urlString .= smarty_function_uri($p_params, $p_smarty);

    return $urlString;
} // fn smarty_function_url
コード例 #4
0
/**
 * Campsite get_resource_id function plugin
 *
 * Type:     function
 * Name:     get_resource_id
 * Purpose:
 *
 * @param empty
 *     $p_params
 * @param object
 *     $p_smarty The Smarty object
 */
function smarty_function_get_resource_id($p_params, &$p_smarty)
{
    $context = $p_smarty->getTemplateVars('gimme');
    // gets the URL base
    $urlString = $context->url->base;
    // includes the smarty camp uri plugin
    $p_smarty->smarty->loadPlugin('smarty_function_uri');
    // appends the URI path and query values to the base
    $urlString = smarty_function_uri(array("options" => "id " . $p_params['template']), $p_smarty);
    $resourceId = NULL;
    $urlStringParams = explode('=', $urlString);
    for ($i = 0; $i < count($urlStringParams) - 1; $i++) {
        if (substr($urlStringParams[$i], -3) == 'tpl') {
            $resourceIdArray = explode('&', $urlStringParams[$i + 1]);
            $resourceId = $resourceIdArray[0];
            break;
        }
    }
    return $resourceId;
}
コード例 #5
0
/**
 * Newscoop facebook_meta block plugin
 *
 * Type:     block
 * Name:     facebook_meta
 * Purpose:  Generates the Facebook Meta information for a page
 *
 * @param string
 *     $params
 * @param string
 *     $p_smarty
 * @param string
 *     $content
 *
 * @return
 *
 */
function smarty_block_facebook_meta_block($params, $content, &$smarty, &$repeat)
{
    if (!isset($content)) {
        return '';
    }
    $smarty->smarty->loadPlugin('smarty_shared_escape_special_chars');
    $context = $smarty->getTemplateVars('gimme');
    $systemPreferences = \Zend_Registry::get('container')->get('preferences');
    $html = '';
    if ($context->article->defined) {
        $html .= '<meta property="og:title" content="' . $context->article->name . '" />' . "\n";
        $html .= '<meta property="og:type" content="article" />' . "\n";
        $html .= '<meta property="og:url" content="http://' . $context->publication->site . smarty_function_uri($params, $smarty) . '" />' . "\n";
        $html .= '<meta property="og:site_name" content="' . $context->publication->name . '" />' . "\n";
        $html .= '<meta property="og:description" content="' . strip_tags($context->article->deck) . '" />' . "\n";
        $html .= '<meta property="article:section" content="' . $context->section->name . '" />' . "\n";
        $html .= '<meta property="article:published_time" content="' . $context->article->publish_date . '" />' . "\n";
        if ($systemPreferences->get('facebook_appid')) {
            $html .= '<meta property="fb:app_id" content="' . $systemPreferences->get('facebook_appid') . '" />' . "\n";
        }
        if (array_key_exists('admins', $params)) {
            foreach ($params as $key => $value) {
                $html .= '<meta property="fb:admins" content="' . $value . '" />' . "\n";
            }
        }
        if ($context->article->keywords) {
            $html .= '<meta property="article:tag" content="' . $context->article->keywords . '" />' . "\n";
        }
        if ($context->article->image->imageurl) {
            $html .= '<meta property="og:image" content="' . $context->article->image->imageurl . '" />' . "\n";
        }
    } else {
        if ($context->section->defined) {
            $html .= '<meta property="og:title" content="' . $context->section->name . '" />' . "\n";
            $html .= '<meta property="og:type" content="article" />' . "\n";
            $html .= '<meta property="og:url" content="http://' . $context->publication->site . smarty_function_uri($params, $smarty) . '" />' . "\n";
            $html .= '<meta property="og:site_name" content="' . $context->publication->name . '" />' . "\n";
            if ($context->section->description) {
                $html .= '<meta property="og:description" content="' . strip_tags($context->section->description) . '" />' . "\n";
            }
            $html .= '<meta property="article:section" content="' . $context->section->name . '" />' . "\n";
            if ($systemPreferences->get('facebook_appid')) {
                $html .= '<meta property="fb:app_id" content="' . $systemPreferences->get('facebook_appid') . '" />' . "\n";
            }
            if (array_key_exists('admins', $params)) {
                foreach ($params as $key => $value) {
                    $html .= '<meta property="fb:admins" content="' . $value . '" />' . "\n";
                }
            }
        } else {
            if ($context->issue->defined) {
                $html .= '<meta property="og:title" content="' . $context->issue->name . '" />' . "\n";
                $html .= '<meta property="og:type" content="article" />' . "\n";
                $html .= '<meta property="og:url" content="http:/' . $context->publication->site . smarty_function_uri($params, $smarty) . '" />' . "\n";
                $html .= '<meta property="og:site_name" content="' . $context->publication->name . '" />' . "\n";
                $html .= '<meta property="article:section" content="' . $context->issue->name . '" />' . "\n";
                $html .= '<meta property="article:published_time" content="' . $context->issue->publish_date . '" />' . "\n";
                if ($systemPreferences->get('facebook_appid')) {
                    $html .= '<meta property="fb:app_id" content="' . $systemPreferences->get('facebook_appid') . '" />' . "\n";
                }
                if (array_key_exists('admins', $params)) {
                    foreach ($params as $key => $value) {
                        $html .= '<meta property="fb:admins" content="' . $value . '" />' . "\n";
                    }
                }
            } else {
                $html .= '<meta property="og:site_name" content="' . $context->publication->name . '" />' . "\n";
                if ($systemPreferences->get('facebook_appid')) {
                    $html .= '<meta property="fb:app_id" content="' . $systemPreferences->get('facebook_appid') . '" />' . "\n";
                }
                if (array_key_exists('admins', $params)) {
                    foreach ($params as $key => $value) {
                        $html .= '<meta property="fb:admins" content="' . $value . '" />' . "\n";
                    }
                }
            }
        }
    }
    return $html;
}