OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
shop_license.php
Go to the documentation of this file.
1 <?php
2 
8 class Shop_License extends Shop_Config
9 {
14  protected $_sThisTemplate = "shop_license.tpl";
15 
16 
21  protected $_aVersionCheckLinks = array(
22  "EE" => "http://admin.oxid-esales.com/EE/onlinecheck.php",
23  "PE" => "http://admin.oxid-esales.com/PE/onlinecheck.php",
24  "CE" => "http://admin.oxid-esales.com/CE/onlinecheck.php"
25  );
26 
27 
34  public function render()
35  {
36  $myConfig = $this->getConfig();
37  if ($myConfig->isDemoShop()) {
38  throw oxNew( "oxSystemComponentException", "license" );
39  }
40 
42 
43  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
44  if ( $soxId != "-1" && isset( $soxId ) ) {
45  // load object
46  $oShop = oxNew( "oxshop" );
47  $oShop->load( $soxId );
48  $this->_aViewData["edit"] = $oShop;
49  }
50 
51  $this->_aViewData["version"] = $myConfig->getVersion();
52 
53 
54  $this->_aViewData['aCurVersionInfo'] = $this->_fetchCurVersionInfo( $this->_aVersionCheckLinks["CE"] );
55 
56  if (!$this->_canUpdate()) {
57  $this->_aViewData['readonly'] = true;
58  }
59 
60  return $this->_sThisTemplate;
61  }
62 
63 
69  protected function _canUpdate()
70  {
71  $myConfig = $this->getConfig();
72 
73  $blIsMallAdmin = oxSession::getVar( 'malladmin' );
74  if (!$blIsMallAdmin) {
75  return false;
76  }
77 
78  if ($myConfig->isDemoShop()) {
79  return false;
80  }
81 
82  return true;
83  }
84 
92  protected function _fetchCurVersionInfo( $sUrl )
93  {
94  $aParams = array("myversion" => $this->getConfig()->getVersion() );
95  $oLang = oxRegistry::getLang();
96  $iLang = $oLang->getTplLanguage();
97  $sLang = $oLang->getLanguageAbbr( $iLang );
98 
99  $oCurl = oxNew('oxCurl');
100  $oCurl->setMethod("POST");
101  $oCurl->setUrl($sUrl . "/" . $sLang);
102  $oCurl->setParameters($aParams);
103  $sOutput = $oCurl->execute();
104 
105  $sOutput = strip_tags($sOutput, "<br>, <b>");
106  $aResult = explode("<br>", $sOutput);
107  if ( strstr( $aResult[5], "update" ) ) {
108  $sUpdateLink = 'http://wiki.oxidforge.org/Category:Downloads';
109  if ( !OXID_VERSION_PE_CE ) {
110  $sUpdateLink = oxRegistry::getLang()->translateString( "VERSION_UPDATE_LINK" );
111  }
112  $aResult[5] = "<a id='linkToUpdate' href='$sUpdateLink' target='_blank'>" . $aResult[5] . "</a>";
113  }
114  $sOutput = implode("<br>", $aResult);
115 
116  return $sOutput;
117  }
118 }