Als ich das erste mal das Konzept der Module von Oxid gezeigt bekommen habe war ich begeistert. Als ich dann jedoch die Bilderresize Funktion bearbeiten wollte folgte schnell Ernüchterung, nicht alles lässt sich überschreiben. Also ging das Modifizieren der core files wieder los. Als einem dann, mit dem Update auf 4.4.2, die Möglichkeit genommen wurde, die oxlang zu überschreiben, musste eine Lösung her, da ich diese in unseren Modulen dazu verwenden das spezifische language file zu laden. Das Problem das sich mache Klassen trotz oxNew nicht überschreiben lassen liegt daran das die Config aModules noch nicht von der DB geladen hat. Das ganze geschieht hier:
public function init()
{
include getShopBasePath().'config.inc.php';
include getShopBasePath().'core/oxconfk.php';
//adding trailing slashes
$oFileUtils = oxUtilsFile::getInstance();
$this->sShopDir = $oFileUtils->normalizeDir($this->sShopDir);
$this->sCompileDir = $oFileUtils->normalizeDir($this->sCompileDir);
$this->sShopURL = $oFileUtils->normalizeDir($this->sShopURL);
$this->sSSLShopURL = $oFileUtils->normalizeDir($this->sSSLShopURL);
$this->sAdminSSLURL = $oFileUtils->normalizeDir($this->sAdminSSLURL);
...
$sCoreDir = $this->getConfigParam( 'sShopDir' );
$this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
try {
//starting up the session
$this->getSession()->start();
$sShopID = $this->getShopId();
// load now
$this->_loadVarsFromDb( $sShopID );
}
...
Wenn man nun die normalizeDir Funktion aus oxUtilsFile kopiert braucht man oxUtilsFile nicht laden. Das Einzige was man nun noch zu tun hat ist ‘aModules’ auf jeden Fall zu laden, was durch $this->_loadVarsFromDb( $sShopID, array(‘aModules’) ); bewerkstelligt wird. Hier mal der Code:
public function normalizeDir( $sDir )
{
if ( isset($sDir) && $sDir != "" && substr($sDir, -1) !== '/' ) {
$sDir .= "/";
}
return $sDir;
}
public function init()
{
include getShopBasePath().'config.inc.php';
include getShopBasePath().'core/oxconfk.php';
//adding trailing slashes
$this->sShopDir = $this->normalizeDir($this->sShopDir);
$this->sCompileDir = $this->normalizeDir($this->sCompileDir);
$this->sShopURL = $this->normalizeDir($this->sShopURL);
$this->sSSLShopURL = $this->normalizeDir($this->sSSLShopURL);
$this->sAdminSSLURL = $this->normalizeDir($this->sAdminSSLURL);
...
$sCoreDir = $this->getConfigParam( 'sShopDir' );
$this->setConfigParam( 'sCoreDir', $sCoreDir.'/core/' );
$sShopID = $this->getShopId();
// load now
$this->_loadVarsFromDb( $sShopID, array('aModules') );
try {
//starting up the session
$this->getSession()->start();
// load now
$this->_loadVarsFromDb( $sShopID );
}
...
Das Ganze mag noch nicht 100% optimal sein, jedoch hält der Oxid Shop so nun das was ich mir davon versprochen habe, nämlich als Entwickler alles überschreiben zu können. Es wäre schön wenn das Ganze in der Form Einzug in den Core halten würde und eine Diskussion entsteht die es zum Ziel hat das ganze “sauber” zu lösen.