Пример #1
0
 /**
  *
  * Get details of the "Uncategorized" category for a given extension,
  * storing the result in a cache variable
  *
  * @param string $extension full name of extension, ie "com_content"
  */
 public static function getSh404sefContentCat()
 {
     // if not already in cache
     if (is_null(self::$_sh404sefContentCat)) {
         try {
             // read details from database
             self::$_sh404sefContentCat = ShlDbHelper::selectObject('#__categories', '*', array('parent_id' => 1, 'extension' => 'com_content', 'path' => 'sh404sef-custom-content', 'level' => 1));
         } catch (Exception $e) {
             self::$_sh404sefContentCat = null;
         }
     }
     return self::$_sh404sefContentCat;
 }
Пример #2
0
 /**
  * Fetch a non-sef url directly from database
  *
  * @param string $sefUrl the sefurl we are searching a non sef for
  * @param string $nonSefUrl will be set to non sef url found
  * @return integer code, either none found, or the url pair type: custom or automatic
  */
 public function getNonSefUrlFromDatabase(&$sefUrl, &$nonSefUrl)
 {
     try {
         $result = ShlDbHelper::selectObject($this->_getTableName(), array('oldurl', 'newurl', 'dateadd'), array('oldurl' => $sefUrl), array(), $orderBy = array('rank'));
     } catch (Exception $e) {
         return sh404SEF_URLTYPE_NONE;
     }
     if (empty($result->newurl)) {
         // no match, that's a 404 for us
         return sh404SEF_URLTYPE_404;
     }
     // found it
     $nonSefUrl = $result->newurl;
     // also adjust sefurl, as the one we have found in db might have a different case from original
     $sefUrl = $result->oldurl;
     // return code: either custom or automatic url
     return $result->dateadd == '0000-00-00' ? sh404SEF_URLTYPE_AUTO : sh404SEF_URLTYPE_CUSTOM;
 }
Пример #3
0
 public function getArticle($id)
 {
     // sanitize input
     $id = intval($id);
     if (empty($id)) {
         throw new Sh404sefExceptionDefault('Invalid article id passed to ' . __METHOD__ . ' in ' . __CLASS__, 500);
     }
     // already cached ?
     if (empty(self::$_articles[$id])) {
         // read details about the article
         $article = ShlDbHelper::selectObject('#__content', array('id', 'title', 'alias', 'catid', 'language'), array('id' => $id));
         // if not found, that's bad
         if (empty($article)) {
             throw new Sh404sefExceptionDefault('Non existing article id (' . $id . ') passed to ' . __METHOD__ . ' in ' . __CLASS__, 500);
         }
         // store our cached record
         self::$_articles[$id][$article->language] = $article;
     }
     return self::$_articles[$id];
 }
Пример #4
0
switch ($task) {
    case 'task1':
    case 'task2':
        $dosef = false;
        // these tasks do not require SEF URL
        break;
    default:
        $title[] = $sh_LANG[$shLangIso]['COM_SH404SEF_VIEW_SAMPLE'];
        // insert a 'View sample' string,
        // 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');
Пример #5
0
 function shGetCustomMetaData($nonSef)
 {
     static $_tags;
     if (is_null($_tags)) {
         $db = ShlDbHelper::getDb();
         $_tags = new Sh404sefTableMetas($db);
         // now read manually setup tags
         try {
             $data = ShlDbHelper::selectObject('#__sh404sef_metas', '*', array('newurl' => $nonSef));
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
         if (!empty($data)) {
             $_tags->bind($data);
         }
     }
     return $_tags;
 }
Пример #6
0
             $title[] = $sh_LANG[$shLangIso]['_SH404SEF_IJOOMLA_MAG_VIEW_MAGAZINE'];
         } catch (Exception $e) {
             $dosef = false;
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
     } else {
         $dosef = false;
     }
     break;
 case 'show_edition':
     if ($sefConfig->shInsertIJoomlaMagName) {
         $title[] = $shIJoomlaMagName;
     }
     if (!empty($id)) {
         try {
             $result = ShlDbHelper::selectObject('#__magazine_categories', array('id', 'title'), array('id' => $id));
             $shRef = empty($result) ? $sh_LANG[$shLangIso]['_SH404SEF_IJOOMLA_MAG_EDITION'] . $sefConfig->replacement . $id : ($sefConfig->shInsertIJoomlaMagIssueId ? $id . $sefConfig->replacement : '');
             // if name, put ID only if requested
             $title[] = $shRef . (empty($result) ? '' : $result->title);
             shRemoveFromGETVarsList('id');
             $title[] = $sh_LANG[$shLangIso]['_SH404SEF_IJOOMLA_MAG_SHOW_EDITION'];
         } catch (Exception $e) {
             $dosef = false;
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
     } else {
         $dosef = false;
     }
     break;
 case 'show_article':
     if ($sefConfig->shInsertIJoomlaMagName) {
Пример #7
0
             }
             if (!empty($pagenum)) {
                 $pattern = str_replace($sefConfig->pagerep, ' ', $sefConfig->pageTexts[$shPageInfo->currentLanguageTag]);
                 $pageNumber = str_replace('%s', $pagenum, $pattern);
             }
         } else {
             if (!empty($showall)) {
                 $pageNumber = titleToLocation(JText::_('All Pages'));
             }
         }
     }
 }
 // V 1.2.4.j 2007/04/11 : numerical ID, on some categories only
 if ($sefConfig->shInsertNumericalId && isset($sefConfig->shInsertNumericalIdCatList) && !empty($id) && $view == 'view') {
     try {
         $contentElement = ShlDbHelper::selectObject('#__content', array('id', 'catid', 'created'), array('id' => $id));
         if (!empty($contentElement)) {
             // V 1.2.4.t
             $foundCat = array_search(@$contentElement->catid, $sefConfig->shInsertNumericalIdCatList);
             if ($foundCat !== null && $foundCat !== false || $sefConfig->shInsertNumericalIdCatList[0] == '') {
                 // test both in case PHP < 4.2.0
                 $shTemp = explode(' ', $contentElement->created);
                 $title[] = str_replace('-', '', $shTemp[0]) . $contentElement->id;
             }
         }
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
     }
 }
 // end of edition id insertion
 $title = array_reverse($title);
Пример #8
0
         }
         $title[] = empty($result) ? $sh_LANG[$shLangIso]['_SH404SEF_CB_USER'] . $sefConfig->replacement . $user : ($sefConfig->shCBInsertUserId ? $user . $sefConfig->replacement . $result : $result);
         // if name, put ID only if requested
         shRemoveFromGETVarsList('user');
     }
     shRemoveFromGETVarsList('task');
     break;
 case 'userslist':
     if ($sefConfig->shInsertCBName) {
         $title[] = $shCBName;
     }
     $title[] = $sh_LANG[$shLangIso]['_SH404SEF_CB_VIEW_USERS_LIST'];
     // manage listid
     if (!empty($listid)) {
         try {
             $result = ShlDbHelper::selectObject('#__comprofiler_lists', array('listid', 'title'), array('listid' => $listid));
         } catch (Exception $e) {
             ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
         }
         $title[] = empty($result) ? $sh_LANG[$shLangIso]['_SH404SEF_CB_LIST'] . $sefConfig->replacement . $listid : $result->title;
         // if name, put ID only if requested
         shRemoveFromGETVarsList('listid');
     }
     shRemoveFromGETVarsList('task');
     break;
 case 'reportuser':
     if ($sefConfig->shInsertCBName) {
         $title[] = $shCBName;
     }
     $title[] = $sh_LANG[$shLangIso]['_SH404SEF_CB_REPORT_USER'];
     // add user name if set to do so / user id is in $uid
Пример #9
0
 function shGetJSVideoTitle($id, $option, $shLangName)
 {
     $sefConfig =& Sh404sefFactory::getConfig();
     try {
         $result = ShlDbHelper::selectObject('#__community_videos', array('id', 'title', 'category_id'), array('id' => $id));
     } catch (Exception $e) {
         ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
     }
     $videoName = ($sefConfig->shJSInsertVideoId ? $id . $sefConfig->replacement : '') . $result->title;
     // optionnally insert video category
     if ($sefConfig->shJSInsertVideoCat) {
         $title = array(shGetJSVideoCategoryTitle($result->category_id, $option, $shLangName), $videoName);
     } else {
         $title = array($videoName);
     }
     return $title;
 }
Пример #10
0
function shAddPaginationInfo($limit, $limitstart, $showall, $iteration, $url, $location, $shSeparator = null, $defaultListLimitValue = null)
{
    $mainframe = JFactory::getApplication();
    //echo 'Incoming pagination : ' . $url . ' | limit : ' . $limit . ' | start : ' . $limitstart . "\n";
    $pageInfo =& Sh404sefFactory::getPageInfo();
    // get page details gathered by system plugin
    $sefConfig =& Sh404sefFactory::getConfig();
    $database = ShlDbHelper::getDb();
    // get a default limit value, for urls where it's missing
    $listLimit = shGetDefaultDisplayNumFromURL($url, $includeBlogLinks = true);
    $defaultListLimit = is_null($defaultListLimitValue) ? shGetDefaultDisplayNumFromConfig($url, $includeBlogLinks = false) : $defaultListLimitValue;
    //echo 'Incoming pagination : $listLimit : ' . $listLimit . ' | $defaultListLimit : ' . $defaultListLimit . "\n";
    // clean suffix and index file before starting to add things to the url
    // clean suffix
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'format=pdf') !== false) {
        $shSuffix = '.pdf';
    } else {
        $shSuffix = $sefConfig->suffix;
    }
    $suffixLength = JString::strLen($shSuffix);
    if (!empty($shSuffix) && $shSuffix != '/' && JString::substr($location, -$suffixLength) == $shSuffix) {
        $location = JString::substr($location, 0, JString::strlen($location) - $suffixLength);
    }
    // clean index file
    if ($sefConfig->addFile && (empty($shSuffix) || JString::subStr($location, -$suffixLength) != $shSuffix)) {
        $indexFileLength = JString::strlen($sefConfig->addFile);
        if ($sefConfig->addFile != '/' && JString::substr($location, -$indexFileLength) == $sefConfig->addFile) {
            $location = JString::substr($location, 0, JString::strlen($location) - $indexFileLength);
        }
    }
    // do we have a trailing slash ?
    if (empty($shSeparator)) {
        $shSeparator = JString::substr($location, -1) == '/' ? '' : '/';
    }
    if (!empty($limit) && is_numeric($limit)) {
        $pagenum = intval($limitstart / $limit);
        $pagenum++;
    } else {
        if (!isset($limit) && !empty($limitstart)) {
            // only limitstart
            if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false) {
                $pagenum = intval($limitstart + 1);
                // multipage article
            } else {
                $pagenum = intval($limitstart / $listLimit) + 1;
                // blogs, tables, ...
            }
        } else {
            $pagenum = $iteration;
        }
    }
    // Make sure we do not end in infite loop here.
    if ($pagenum < $iteration) {
        $pagenum = $iteration;
    }
    // shumisha added to handle table-category and table-section which may have variable number of items per page
    // There still will be a problem with filter, which may reduce the total number of items. Thus the item we are looking for
    if ($sefConfig->alwaysAppendItemsPerPage || strpos($url, 'option=com_virtuemart') && $sefConfig->shVmUsingItemsPerPage) {
        $shMultPageLength = $sefConfig->pagerep . (empty($limit) ? $listLimit : $limit);
    } else {
        $shMultPageLength = '';
    }
    // shumisha : modified to add # of items per page to URL, for table-category or section-category
    if (!empty($sefConfig->pageTexts[$pageInfo->currentLanguageTag]) && false !== strpos($sefConfig->pageTexts[$pageInfo->currentLanguageTag], '%s')) {
        $page = str_replace('%s', $pagenum, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]) . $shMultPageLength;
    } else {
        $page = $sefConfig->pagerep . $pagenum . $shMultPageLength;
    }
    // V 1.2.4.t special processing to replace page number by headings
    $shPageNumberWasReplaced = false;
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && !empty($limitstart)) {
        // this is multipage article - limitstart instead of limit in J1.5
        if ($sefConfig->shMultipagesTitle) {
            parse_str($url, $shParams);
            if (!empty($shParams['id'])) {
                $shPageTitle = '';
                try {
                    $contentElement = ShlDbHelper::selectObject('#__content', array('id', 'fulltext', 'introtext'), array('id' => $shParams['id']));
                } catch (Exception $e) {
                    JError::raise(E_ERROR, 500, $e->getMessage());
                }
                $contentText = $contentElement->introtext . $contentElement->fulltext;
                if (!empty($contentElement) && strpos($contentText, 'class="system-pagebreak') !== false) {
                    // search for mospagebreak tags
                    // copied over from pagebreak plugin
                    // expression to search for
                    $regex = '#<hr([^>]*)class=(\\"|\')system-pagebreak(\\"|\')([^>]*)\\/>#iU';
                    // find all instances of mambot and put in $matches
                    $shMatches = array();
                    preg_match_all($regex, $contentText, $shMatches, PREG_SET_ORDER);
                    // adds heading or title to <site> Title
                    if (empty($limitstart)) {
                        // if first page use heading of first mospagebreak
                        /* if ( $shMatches[0][2] ) {
                            parse_str( html_entity_decode( $shMatches[0][2] ), $args );
                           if ( @$args['heading'] ) {
                           $shPageTitle = stripslashes( $args['heading'] );
                           }
                           }*/
                    } else {
                        // for other pages use title of mospagebreak
                        if ($limitstart > 0 && $shMatches[$limitstart - 1][1]) {
                            $args = JUtility::parseAttributes($shMatches[$limitstart - 1][0]);
                            if (@$args['title']) {
                                $shPageTitle = $args['title'];
                            } else {
                                if (@$args['alt']) {
                                    $shPageTitle = $args['alt'];
                                } else {
                                    // there is a page break, but no title. Use a page number
                                    $shPageTitle = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]);
                                }
                            }
                        }
                    }
                }
                if (!empty($shPageTitle)) {
                    // found a heading, we should use that as a Title
                    $location .= $shSeparator . titleToLocation($shPageTitle);
                }
                $shPageNumberWasReplaced = true;
                // always set the flag, otherwise we'll a Page-1 added
            }
        } else {
            // mutiple pages article, but we don't want to use smart title.
            // directly use limitstart
            $page = str_replace('%s', $limitstart + 1, $sefConfig->pageTexts[$pageInfo->currentLanguageTag]);
        }
    }
    // maybe this is a multipage with "showall=1"
    if (strpos($url, 'option=com_content') !== false && strpos($url, 'view=article') !== false && strpos($url, 'showall=1') !== false) {
        // this is multipage article with showall
        $tempTitle = JText::_('All Pages');
        $location .= $shSeparator . titleToLocation($tempTitle);
        $shPageNumberWasReplaced = true;
        // always set the flag, otherwise we'll a Page-1 added
    }
    // make sure we remove bad characters
    $takethese = str_replace('|', '', $sefConfig->friendlytrim);
    $location = JString::trim($location, $takethese);
    // add page number
    if (!$shPageNumberWasReplaced && (!isset($limitstart) && (isset($limit) && $limit != 1 && $limit != $listLimit && $limit != $defaultListLimit) || !empty($limitstart))) {
        $location .= $shSeparator . $page;
    }
    // add suffix
    if (!empty($shSuffix) && !empty($location) && $location != '/' && JString::substr($location, -1) != '/') {
        $location = $shSuffix == '/' ? $location . $shSuffix : str_replace($shSuffix, '', $location) . $shSuffix;
    }
    // add default index file
    if ($sefConfig->addFile) {
        // V 1.2.4.t
        if (empty($shSuffix) || !empty($shSuffix) && JString::subStr($location, -$suffixLength) != $shSuffix) {
            $location .= (JString::substr($location, -1) == '/' ? '' : '/') . $sefConfig->addFile;
        }
    }
    return JString::ltrim($location, '/');
}
Пример #11
0
$catid = isset($catid) ? $catid : null;
// optional prefix
$shWeblinksName = shGetComponentPrefix($option);
if (!empty($shWeblinksName) && $shWeblinksName != '/') {
    $title[] = $shWeblinksName;
}
// joomla content models
$slugsModel = Sh404sefModelSlugs::getInstance();
$menuItemTitle = getMenuTitle(null, $view, isset($Itemid) ? $Itemid : null, '', $shLangName);
$uncategorizedPath = $sefConfig->slugForUncategorizedWeblinks == shSEFConfig::COM_SH404SEF_UNCATEGORIZED_EMPTY ? '' : $menuItemTitle;
$slugsArray = array();
if ($task == 'weblink.go') {
    // jumping to link target
    if (!empty($id)) {
        try {
            $weblinkDetails = ShlDbHelper::selectObject('#__weblinks', array('id', 'title', 'catid'), array('id' => $id));
            $slugsArray[] = $weblinkDetails->title;
        } catch (Exception $e) {
            ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
            $weblinksDetails = null;
        }
        if (!empty($weblinkDetails->catid)) {
            try {
                $title = $slugsModel->getCategorySlugArray('com_weblinks', $weblinkDetails->catid, $sefConfig->includeWeblinksCat, $sefConfig->useWeblinksCatAlias, $insertId = false, $uncategorizedPath, $shLangName);
            } catch (Exception $e) {
                ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
            }
            $title[] = '/';
        }
    } else {
        $dosef = false;
Пример #12
0
 function shKUTopicName($topicid, $option, $shLangIso, $shLangName)
 {
     static $topics = array();
     $sefConfig =& Sh404sefFactory::getConfig();
     if (empty($topicid) || !$sefConfig->shFbInsertMessageSubject) {
         return '';
     }
     if (class_exists('KunenaForum')) {
         // Kunena 2.0 support
         $topic = KunenaForumTopic::getInstance($topicid);
         $topicsubject = $topic->subject;
     } elseif (class_exists('KunenaRouter')) {
         // Kunena 1.6 support
         if (empty(KunenaRouter::$msgidcache[$topicid])) {
             try {
                 KunenaRouter::$msgidcache[$topicid] = ShlDbHelper::selectResult('#__kunena_messages', array('subject', 'id'), array('id' => $topicid));
             } catch (Exception $e) {
                 ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
             }
         }
         $topicsubject = KunenaRouter::$msgidcache[$topicid];
     } else {
         // Kunena 1.0 / 1.5 support
         if (empty($topics[$topicid])) {
             try {
                 $topicDetails = ShlDbHelper::selectObject('#__fb_messages', array('id', 'subject'), array('id' => $topicid));
             } catch (Exception $e) {
                 ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
             }
             $topics[$topicid] = empty($topicDetails) ? '' : $topicDetails->subject;
         }
         $topicsubject = $topics[$topicid];
     }
     // we have a user name
     $topicstring = empty($topicsubject) ? 't' . $sefConfig->replacement . $topicid : ($sefConfig->shFbInsertMessageId ? $topicid . $sefConfig->replacement : '');
     // if name, put ID only if requested
     $topicstring = $topicstring . (empty($topicsubject) ? '' : $topicsubject);
     return $topicstring;
 }
Пример #13
0
        if (!empty($catid)) {
            try {
                $slugsArray = $slugsModel->getCategorySlugArray('com_contact', $catid, $sefConfig->includeContactCat, $sefConfig->useContactCatAlias, $insertId = false, $menuItemTitle, $shLangName);
            } catch (Exception $e) {
                ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
            }
            if (!empty($slugsArray)) {
                $title = array_merge($title, $slugsArray);
            }
            shRemoveFromGETVarsList('catid');
        }
        // fetch contact name
        if (!empty($id)) {
            shRemoveFromGETVarsList('id');
            try {
                $result = ShlDbHelper::selectObject('#__contact_details', array('name', 'id'), array('id' => $id));
            } catch (Exception $e) {
                ShlSystem_Log::error('sh404sef', '%s::%s::%d: %s', __CLASS__, __METHOD__, __LINE__, $e->getMessage());
            }
            if (!empty($result)) {
                $title[] = $result->name;
                shMustCreatePageId('set', true);
            } else {
                $title[] = $id;
            }
        }
        break;
    default:
        $dosef = false;
        break;
}
Пример #14
0
         shRemoveFromGETVarsList('task');
     } else {
         $dosef = false;
     }
     break;
     // View Company / View Company Email / Send Company Email
 // View Company / View Company Email / Send Company Email
 case 'viewco':
 case 'viewcoemail':
 case 'sendenquiry':
     $company_id = $id;
     shRemoveFromGETVarsList('task');
     // This condition allows listagent module to work so that $agent_id can be a javascript expression.
     try {
         if (is_numeric($company_id)) {
             $row = ShlDbHelper::selectObject('#__hp_companies', array('id', 'name'), array('id' => $company_id));
             // View Company
             switch ($task) {
                 case 'viewco':
                     if (!empty($row)) {
                         $title[] = $sh_LANG[$shLangIso]['_HP_SEF_COMPANY'];
                         $title[] = $row->name;
                         $title[] = '/';
                         shRemoveFromGETVarsList('id');
                     } else {
                         $title[] = $sh_LANG[$shLangIso]['_HP_SEF_COMPANY'];
                     }
                     break;
                     // View Company Email
                 // View Company Email
                 case 'viewcoemail':