Пример #1
0
 /**
  * Returns SEO uri for content object. Includes parent category path info if
  * content is assigned to it
  *
  * @param oxContent $oCont        content category object
  * @param int       $iLang        language
  * @param bool      $blRegenerate if TRUE forces seo url regeneration
  *
  * @return string
  */
 public function getContentUri($oCont, $iLang = null, $blRegenerate = false)
 {
     if (!isset($iLang)) {
         $iLang = $oCont->getLanguage();
     }
     //load details link from DB
     if ($blRegenerate || !($sSeoUrl = $this->_loadFromDb('oxContent', $oCont->getId(), $iLang))) {
         if ($iLang != $oCont->getLanguage()) {
             $sId = $oCont->getId();
             $oCont = oxNew('oxContent');
             $oCont->loadInLang($iLang, $sId);
         }
         $sSeoUrl = '';
         if ($oCont->getCategoryId() && $oCont->getType() === 2) {
             $oCat = oxNew('oxCategory');
             if ($oCat->loadInLang($iLang, $oCont->oxcontents__oxcatid->value)) {
                 $sParentId = $oCat->oxcategories__oxparentid->value;
                 if ($sParentId && $sParentId != 'oxrootid') {
                     $oParentCat = oxNew('oxCategory');
                     if ($oParentCat->loadInLang($iLang, $oCat->oxcategories__oxparentid->value)) {
                         $sSeoUrl .= oxRegistry::get("oxSeoEncoderCategory")->getCategoryUri($oParentCat);
                     }
                 }
             }
         }
         $sSeoUrl .= $this->_prepareTitle($oCont->oxcontents__oxtitle->value, false, $oCont->getLanguage()) . '/';
         $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $oCont->getId(), $iLang);
         $this->_saveToDb('oxcontent', $oCont->getId(), $oCont->getBaseStdLink($iLang), $sSeoUrl, $iLang);
     }
     return $sSeoUrl;
 }
Пример #2
0
 /**
  * getParsedContent() test case
  * test returned parsed content with smarty tags when template regeneration is disabled
  * and template is saved twice.
  *
  * @return null
  */
 public function testGetParsedContentTagsWhenTemplateAlreadyGeneratedAndRegenerationDisabled()
 {
     $this->getConfig()->setConfigParam('blCheckTemplates', false);
     $this->_oObj->oxcontents__oxcontent = new oxField("[{* *}]generated", oxField::T_RAW);
     $this->_oObj->save();
     $this->setRequestParameter('oxcid', $this->_oObj->getId());
     $oContent = oxNew('content');
     $oContent->getParsedContent();
     $this->_oObj->oxcontents__oxcontent = new oxField("[{* *}]regenerated", oxField::T_RAW);
     $this->_oObj->save();
     $oContent = oxNew('content');
     $this->assertEquals('regenerated', $oContent->getParsedContent());
 }