/** * 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; }
public function testOxContentSetAndGet() { $sValue = 'sėkme Литовские für'; $oContent = new oxcontent(); $oContent->setId('_testContent'); $oContent->oxcontents__oxloadid = new oxField("_testLoadId"); $oContent->oxcontents__oxtitle = new oxField($sValue); $oContent->oxcontents__oxcontent = new oxField($sValue); $oContent->oxcontents__oxfolder = new oxField($sValue); $oContent->save(); $oContent = new oxcontent(); $oContent->load('_testContent'); $this->assertEquals($sValue, $oContent->oxcontents__oxtitle->value); $this->assertEquals($sValue, $oContent->oxcontents__oxcontent->value); $this->assertEquals($sValue, $oContent->oxcontents__oxfolder->value); }