OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxseoencodercontent.php
Go to the documentation of this file.
1 <?php
2 
8 {
12  protected static $_instance = null;
13 
21  public static function getInstance()
22  {
23  return oxRegistry::get("oxSeoEncoderContent");
24  }
25 
31  protected function _getUrlExtension()
32  {
33  return '/';
34  }
35 
46  public function getContentUri( $oCont, $iLang = null, $blRegenerate = false )
47  {
48  if (!isset($iLang)) {
49  $iLang = $oCont->getLanguage();
50  }
51  //load details link from DB
52  if ( $blRegenerate || !( $sSeoUrl = $this->_loadFromDb( 'oxcontent', $oCont->getId(), $iLang ) ) ) {
53 
54  if ( $iLang != $oCont->getLanguage() ) {
55  $sId = $oCont->getId();
56  $oCont = oxNew('oxcontent');
57  $oCont->loadInLang( $iLang, $sId );
58  }
59 
60  $sSeoUrl = '';
61  if ( $oCont->oxcontents__oxcatid->value ) {
62  $oCat = oxNew( 'oxcategory' );
63  if ( $oCat->loadInLang( $iLang, $oCont->oxcontents__oxcatid->value ) ) {
64  if ( $oCat->oxcategories__oxparentid->value && $oCat->oxcategories__oxparentid->value != 'oxrootid' ) {
65  $oParentCat = oxNew( 'oxcategory' );
66  if ( $oParentCat->loadInLang( $iLang, $oCat->oxcategories__oxparentid->value ) ) {
67  $sSeoUrl .= oxRegistry::get("oxSeoEncoderCategory")->getCategoryUri( $oParentCat );
68  }
69  }
70  }
71  }
72 
73  $sSeoUrl .= $this->_prepareTitle( $oCont->oxcontents__oxtitle->value, false, $oCont->getLanguage() ) . '/';
74  $sSeoUrl = $this->_processSeoUrl( $sSeoUrl, $oCont->getId(), $iLang );
75 
76  $this->_saveToDb( 'oxcontent', $oCont->getId(), $oCont->getBaseStdLink($iLang), $sSeoUrl, $iLang );
77  }
78  return $sSeoUrl;
79  }
80 
91  public function getContentUrl( $oCont, $iLang = null)
92  {
93  if (!isset($iLang)) {
94  $iLang = $oCont->getLanguage();
95  }
96  return $this->_getFullUrl( $this->getContentUri( $oCont, $iLang ), $iLang );
97  }
98 
106  public function onDeleteContent( $sId )
107  {
108  $oDb = oxDb::getDb();
109  $sIdQuoted = $oDb->quote($sId);
110  $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcontent'");
111  $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
112  }
113 
122  protected function _getAltUri( $sObjectId, $iLang )
123  {
124  $sSeoUrl = null;
125  $oCont = oxNew( "oxcontent" );
126  if ( $oCont->loadInLang( $iLang, $sObjectId ) ) {
127  $sSeoUrl = $this->getContentUri( $oCont, $iLang, true );
128  }
129  return $sSeoUrl;
130  }
131 }