Esempio n. 1
0
function shInitializePlugin($lang, &$shLangName, &$shLangIso, $option)
{
    global $shMosConfig_lang, $shMosConfig_locale;
    $conf =& JFactory::getConfig();
    $configDefaultLanguage = $conf->getValue('config.language');
    $shLangName = empty($lang) ? $shMosConfig_locale : shGetNameFromIsoCode($lang);
    $shLangIso = shTranslateUrl($option, $shLangName) ? isset($lang) ? $lang : shGetIsoCodeFromName($shMosConfig_locale) : (isset($configDefaultLanguage) ? shGetIsoCodeFromName($configDefaultLanguage) : shGetIsoCodeFromName($shMosConfig_locale));
    if (strpos($shLangIso, '_') !== false) {
        //11/08/2007 14:30:16 mambo compat
        $shTemp = explode('_', $shLangIso);
        $shLangIso = $shTemp[0];
    }
    // reset pageid creation : the plugin must turn it on by itself
    shMustCreatePageId('set', false);
    // added protection : do not SEF if component is not installed. Do not attempt to build SEF URL
    // if component is not installed, or else plugin may try to read from comp DB tables. This will cause DB table names
    // to be displayed
    return !sh404SEF_CHECK_COMP_IS_INSTALLED || sh404SEF_CHECK_COMP_IS_INSTALLED && shFileExists(sh404SEF_ABS_PATH . 'components/' . $option . '/' . str_replace('com_', '', $option) . '.php');
}
Esempio n. 2
0
        // according to language
        // only if you have defined the
        if (!empty($sampleId)) {
            // fetch some data about the content
            try {
                // using shLib database helper is J2.x/J3.x safe
                $sampleTitle = ShlDbHelper::selectObject('#__sample_names', array('id', 'title'), array('id' => $sampleId));
            } catch (Exception $e) {
                ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
            }
            if ($sampleTitle) {
                // if we found a title for this element
                $title[] = $sampleTitle->title;
                // insert it in URL array
                shRemoveFromGETVarsList('sampleId');
                // remove sampleId var from GET vars list
                // as we have found a text equivalent
                shMustCreatePageId('set', true);
                // NEW: ask sh404sef to create a short URL for this SEF URL (pageId)
            }
        }
        shRemoveFromGETVarsList('task');
        // also remove task, as it is not needed
        // because we can revert the SEF URL without
        // it
}
// ------------------  standard plugin finalize function - don't change ---------------------------
if ($dosef) {
    $string = shFinalizePlugin($string, $title, $shAppendString, $shItemidString, isset($limit) ? @$limit : null, isset($limitstart) ? @$limitstart : null, isset($shLangName) ? @$shLangName : null);
}
// ------------------  standard plugin finalize function - don't change ---------------------------
Esempio n. 3
0
 protected static function _createShurl($nonSefUrl)
 {
     if (empty($nonSefUrl)) {
         return '';
     }
     // only create a shURL if current page returns a 200
     $headers = JResponse::getHeaders();
     // check if we have a status
     foreach ($headers as $header) {
         if (strtolower($header['name']) == 'status' && $header['value'] != 200) {
             // error or redirection, don't shurl that
             return '';
         }
     }
     // check various conditions, to avoid overloading ourselves with shURL
     // not on homepage
     if (shIsHomepage($nonSefUrl)) {
         return '';
     }
     // not for format = raw, format = pdf or printing
     $format = shGetURLVar($nonSefUrl, 'format');
     if (in_array(strtolower($format), array('raw', 'pdf'))) {
         return '';
     }
     $print = shGetURLVar($nonSefUrl, 'print');
     if ($print == 1) {
         return '';
     }
     // not if tmpl not empty or not index
     $tmpl = shGetURLVar($nonSefUrl, 'tmpl');
     if (!empty($tmpl) && $tmpl != 'index') {
         return '';
     }
     // force global setting
     shMustCreatePageId('set', true);
     // get a model and create shURL
     $model =& JModel::getInstance('Pageids', 'Sh404sefModel');
     $shURL = $model->createPageId('', $nonSefUrl);
     return $shURL;
 }