Example #1
0
/**
* Prepare a banner item for rendering
*
* @param    array   $A          banner details
* @param    ref     $template   reference of the banner template
*
*/
function prepare_banner_item($A, &$template)
{
    global $_CONF, $_USER, $LANG_ADMIN, $LANG_BANNER, $_IMAGE_TYPE, $LANG_DIRECTION;
    $url = COM_buildUrl($_CONF['site_url'] . '/banner/portal.php?what=banner&item=' . $A['bid']);
    $template->set_var('banner_url', $url);
    $template->set_var('banner_actual_url', $A['url']);
    $template->set_var('banner_actual_url_encoded', urlencode($A['url']));
    $template->set_var('banner_name', stripslashes($A['title']));
    $template->set_var('banner_name_encoded', urlencode($A['title']));
    $template->set_var('banner_hits', COM_numberFormat($A['hits']));
    $content = stripslashes($A['title']);
    $template->set_var('banner_html', $content);
    if (!COM_isAnonUser() && !SEC_hasRights('banner.edit')) {
        $reporturl = $_CONF['site_url'] . '/banner/index.php?mode=report&bid=' . $A['bid'];
        $template->set_var('banner_broken', COM_createLink($LANG_BANNER[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('banner_broken', '');
    }
    $bannerimg = nl2br(stripslashes($A['description']));
    $flg_link = empty($A['url']) ? false : true;
    $banner = banner_buildBanner($A['bid'], $content, $bannerimg, $flg_link);
    $template->set_var('banner_description', $banner);
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('banner.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/banner/index.php?mode=edit&bid=' . $A['bid'];
        $template->set_var('banner_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
        $attr = array('class' => 'editlink');
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl, $attr));
    } else {
        $template->set_var('banner_edit', '');
        $template->set_var('edit_icon', '');
    }
}
Example #2
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_CONF, $_LI_CONF, $LANG_ADMIN, $LANG_LINKS, $LANG_DIRECTION, $_IMAGE_TYPE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $actualUrl = stripslashes($A['url']);
    $title = stripslashes($A['title']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $actualUrl);
    $template->set_var('link_actual_url_encoded', rawurlencode($actualUrl));
    $template->set_var('link_name', $title);
    $template->set_var('link_name_encoded', rawurlencode($title));
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $template->set_var('link_description', PLG_replaceTags(COM_nl2br(stripslashes($A['description']))));
    $attr = array('title' => $actualUrl);
    if (substr($actualUrl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
        $class = 'ext-link';
        if (!empty($LANG_DIRECTION) && $LANG_DIRECTION == 'rtl') {
            $class .= '-rtl';
        }
        $attr['class'] = $class;
        if ($_LI_CONF['new_window']) {
            $attr['target'] = '_blank';
        }
    }
    $html = COM_createLink($title, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?mode=edit&amp;lid=' . $A['lid'];
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
}
Example #3
0
/**
* Set the {lang_id} and {lang_attribute} variables for a template
*
* @param    ref     $template   template to use
* @return   void
* @note     {lang_attribute} is only set in multi-language environments.
*
*/
function COM_setLangIdAndAttribute(&$template)
{
    global $_CONF;
    $langAttr = '';
    $langId = '';
    if (!empty($_CONF['languages']) && !empty($_CONF['language_files'])) {
        $langId = COM_getLanguageId();
    } else {
        // try to derive the language id from the locale
        $l = explode('.', $_CONF['locale']);
        // get rid of character set
        $langId = $l[0];
        $l = explode('@', $langId);
        // get rid of '@euro', etc.
        $langId = $l[0];
    }
    if (!empty($langId)) {
        $l = explode('-', str_replace('_', '-', $langId));
        if (count($l) == 1 && strlen($langId) == 2) {
            $langAttr = 'lang="' . $langId . '"';
        } else {
            if (count($l) == 2) {
                if ($l[0] == 'i' || $l[0] == 'x') {
                    $langId = implode('-', $l);
                    $langAttr = 'lang="' . $langId . '"';
                } else {
                    if (strlen($l[0]) == 2) {
                        $langId = implode('-', $l);
                        $langAttr = 'lang="' . $langId . '"';
                    } else {
                        $langId = $l[0];
                        // this isn't a valid lang attribute, so don't set $langAttr
                    }
                }
            }
        }
    }
    $template->set_var('lang_id', $langId);
    if (!empty($_CONF['languages']) && !empty($_CONF['language_files'])) {
        $template->set_var('lang_attribute', ' ' . $langAttr);
    } else {
        $template->set_var('lang_attribute', '');
    }
}
Example #4
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_LI_CONF, $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $A['url']);
    $template->set_var('link_name', $A['title']);
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $template->set_var('link_description', PLG_replaceTags(nl2br($A['description']), 'links', 'description'));
    $content = $A['title'];
    if ($_LI_CONF['target_blank'] == 1) {
        $attr = array('title' => $A['url'], 'class' => 'ext-link', 'target' => '_blank');
    } else {
        $attr = array('title' => $A['url'], 'class' => 'ext-link');
    }
    $html = COM_createLink($content, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?edit=x&amp;lid=' . $A['lid'];
        $template->set_var('edit_url', $editurl);
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"/>";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
}
Example #5
0
/**
* Prepare a link item for rendering
*
* @param    array   $A          link details
* @param    ref     $template   reference of the links template
*
*/
function prepare_link_item($A, &$template)
{
    global $_LI_CONF, $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE, $LANG_LOCALE;
    $url = COM_buildUrl($_CONF['site_url'] . '/links/portal.php?what=link&amp;item=' . $A['lid']);
    $template->set_var('link_url', $url);
    $template->set_var('link_actual_url', $A['url']);
    $template->set_var('link_name', $A['title']);
    $template->set_var('link_hits', COM_numberFormat($A['hits']));
    $linkDesc = PLG_replaceTags(nl2br($A['description']), 'links', 'description');
    $template->set_var('link_description', $linkDesc);
    //                        PLG_replaceTags(nl2br($A['description']),'links','description'));
    $content = $A['title'];
    if ($_LI_CONF['target_blank'] == 1) {
        $attr = array('title' => $A['url'], 'class' => 'ext-link', 'target' => '_blank');
    } else {
        $attr = array('title' => $A['url'], 'class' => 'ext-link');
    }
    $html = COM_createLink($content, $url, $attr);
    $template->set_var('link_html', $html);
    if (!COM_isAnonUser() && !SEC_hasRights('links.edit')) {
        $reporturl = $_CONF['site_url'] . '/links/index.php?mode=report&amp;lid=' . $A['lid'];
        $template->set_var('link_broken', COM_createLink($LANG_LINKS[117], $reporturl, array('class' => 'pluginSmallText', 'rel' => 'nofollow')));
    } else {
        $template->set_var('link_broken', '');
    }
    if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('links.edit')) {
        $editurl = $_CONF['site_admin_url'] . '/plugins/links/index.php?edit=x&amp;lid=' . $A['lid'];
        $template->set_var('edit_url', $editurl);
        $template->set_var('link_edit', COM_createLink($LANG_ADMIN['edit'], $editurl));
        $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}\" " . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"/>";
        $template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
    } else {
        $template->set_var('link_edit', '');
        $template->set_var('edit_icon', '');
    }
    if ($_LI_CONF['linksperpage'] == 1) {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addMeta('property', 'og:site_name', urlencode($_CONF['site_name']));
        $outputHandle->addMeta('property', 'og:locale', isset($LANG_LOCALE) ? $LANG_LOCALE : 'en_US');
        $outputHandle->addMeta('property', 'og:title', $A['title']);
        $outputHandle->addMeta('property', 'og:type', 'website');
        $outputHandle->addMeta('property', 'og:url', $A['url']);
        if (preg_match('/<img[^>]+src=([\'"])?((?(1).+?|[^\\s>]+))(?(1)\\1)/si', $linkDesc, $arrResult)) {
            $outputHandle->addMeta('property', 'og:image', $arrResult[2]);
        }
    }
}