OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
oxseoencodercontent.php
Go to the documentation of this file.
1 <?php
2 
8 {
9 
15  protected function _getUrlExtension()
16  {
17  return '/';
18  }
19 
30  public function getContentUri($oCont, $iLang = null, $blRegenerate = false)
31  {
32  if (!isset($iLang)) {
33  $iLang = $oCont->getLanguage();
34  }
35  //load details link from DB
36  if ($blRegenerate || !($sSeoUrl = $this->_loadFromDb('oxContent', $oCont->getId(), $iLang))) {
37 
38  if ($iLang != $oCont->getLanguage()) {
39  $sId = $oCont->getId();
40  $oCont = oxNew('oxContent');
41  $oCont->loadInLang($iLang, $sId);
42  }
43 
44  $sSeoUrl = '';
45  if ($oCont->getCategoryId() && $oCont->getType() === 2) {
46  $oCat = oxNew('oxCategory');
47  if ($oCat->loadInLang($iLang, $oCont->oxcontents__oxcatid->value)) {
48  $sParentId = $oCat->oxcategories__oxparentid->value;
49  if ($sParentId && $sParentId != 'oxrootid') {
50  $oParentCat = oxNew('oxCategory');
51  if ($oParentCat->loadInLang($iLang, $oCat->oxcategories__oxparentid->value)) {
52  $sSeoUrl .= oxRegistry::get("oxSeoEncoderCategory")->getCategoryUri($oParentCat);
53  }
54  }
55  }
56  }
57 
58  $sSeoUrl .= $this->_prepareTitle($oCont->oxcontents__oxtitle->value, false, $oCont->getLanguage()) . '/';
59  $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $oCont->getId(), $iLang);
60 
61  $this->_saveToDb('oxcontent', $oCont->getId(), $oCont->getBaseStdLink($iLang), $sSeoUrl, $iLang);
62  }
63 
64  return $sSeoUrl;
65  }
66 
75  public function getContentUrl($oCont, $iLang = null)
76  {
77  if (!isset($iLang)) {
78  $iLang = $oCont->getLanguage();
79  }
80 
81  return $this->_getFullUrl($this->getContentUri($oCont, $iLang), $iLang);
82  }
83 
89  public function onDeleteContent($sId)
90  {
91  $oDb = oxDb::getDb();
92  $sIdQuoted = $oDb->quote($sId);
93  $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcontent'");
94  $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
95  }
96 
105  protected function _getAltUri($sObjectId, $iLang)
106  {
107  $sSeoUrl = null;
109  $oCont = oxNew("oxcontent");
110  if ($oCont->loadInLang($iLang, $sObjectId)) {
111  $sSeoUrl = $this->getContentUri($oCont, $iLang, true);
112  }
113 
114  return $sSeoUrl;
115  }
116 }