public function getControllerClass(Zend_Controller_Request_Abstract $request) { $module = $request->getModuleName(); if ($module == 'component' && $request->getControllerName() == 'component' || $module == 'component_test' && $request->getControllerName() == 'component_test') { if ($module == 'component_test') { //FnF models setzen damit tests nicht in echte tabellen schreiben Kwf_Component_Cache::setInstance(Kwf_Component_Cache::CACHE_BACKEND_FNF); Kwf_Test_SeparateDb::setDbFromCookie(); // setzt es nur wenn es das cookie wirklich gibt if (!Kwf_Loader::isValidClass($request->getParam('root'))) { throw new Kwf_Exception_NotFound("Invalid root component"); } Kwf_Component_Data_Root::setComponentClass($request->getParam('root')); $root = Kwf_Component_Data_Root::getInstance(); $root->setFilename('kwf/kwctest/' . $request->getParam('root')); Kwf_Registry::get('acl')->getComponentAcl()->allowComponent('guest', null); //hick hack, für Kwf_Component_Abstract_Admin::getControllerUrl Zend_Registry::set('testRootComponentClass', $request->getParam('root')); } $class = $request->getParam('class'); $controller = $request->getParam('componentController'); $controller .= 'Controller'; if ($controller == 'IndexController') { $controller = 'Controller'; } if (($pos = strpos($class, '!')) !== false) { $controller = substr($class, $pos + 1) . 'Controller'; $class = substr($class, 0, $pos); } if (!in_array($class, Kwc_Abstract::getComponentClasses())) { //unknown component class return false; } $className = Kwc_Admin::getComponentClass($class, $controller); if (!$className) { return false; } class_exists($className); //trigger autoloader } else { $className = parent::getControllerClass($request); } return $className; }
protected function _afterInsert() { parent::_afterInsert(); $c = Kwc_Shop_Cart_Checkout_Payment_Wirecard_LogModel::decodeCallback($this->custom); if ($c && $c['cb']) { $ret = false; if (Kwf_Loader::isValidClass($c['cb'])) { $ret = call_user_func(array($c['cb'], 'processIpn'), $this, $c['data']); } else { if (Kwf_Component_Data_Root::getComponentClass()) { $component = Kwf_Component_Data_Root::getInstance()->getComponentById($c['cb']); if ($component) { $ret = $component->getComponent()->processIpn($this, $c['data']); } } } $this->callback_success = $ret; $this->save(); } }
private static function _getOutputWithoutCheckingIsValid($class, $id, $type) { $cacheId = self::createCacheId($class, $id, $type); $output = Kwf_Media_MemoryCache::getInstance()->load($cacheId); if ($output && !isset($output['file']) && !isset($output['contents'])) { //scaled image is not cached in apc as it might be larger - load from disk $output['file'] = 'cache/media/' . $cacheId; } if (isset($output['file']) && !file_exists($output['file'])) { $output = false; } if ($output && isset($output['mtimeFiles'])) { foreach ($output['mtimeFiles'] as $f) { if (filemtime($f) > $output['mtime']) { Kwf_Media_MemoryCache::getInstance()->remove($cacheId); $output = false; break; } } } if (!$output) { $classWithoutDot = strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class; if (!Kwf_Loader::isValidClass($classWithoutDot) || !is_instance_of($classWithoutDot, 'Kwf_Media_Output_Interface')) { throw new Kwf_Exception_NotFound(); } $output = call_user_func(array($classWithoutDot, 'getMediaOutput'), $id, $type, $class); $specificLifetime = false; $useCache = true; if (isset($output['lifetime'])) { $specificLifetime = $output['lifetime']; if (!$output['lifetime']) { $useCache = false; } } if (!isset($output['mtime'])) { if (isset($output['file'])) { $output['mtime'] = filemtime($output['file']); } else { if (isset($output['mtimeFiles'])) { $output['mtime'] = 0; foreach ($output['mtimeFiles'] as $f) { $output['mtime'] = max($output['mtime'], filemtime($f)); } } else { $output['mtime'] = time(); } } } if ($useCache) { $cacheData = $output; if (isset($cacheData['contents']) && strlen($cacheData['contents']) > 20 * 1024) { //don't cache contents larger than 20k in apc, use separate file cache file_put_contents('cache/media/' . $cacheId, $cacheData['contents']); unset($cacheData['contents']); } Kwf_Media_MemoryCache::getInstance()->save($cacheData, $cacheId, $specificLifetime); } } return $output; }
private static function _getOutputWithoutCheckingIsValid($class, $id, $type) { $cacheId = self::createCacheId($class, $id, $type); $output = Kwf_Media_MemoryCache::getInstance()->load($cacheId); if ($output && !isset($output['file']) && !isset($output['contents'])) { //cache entry from older kwf version where file was not set $output = false; } if (isset($output['file']) && !file_exists($output['file'])) { $output = false; } if ($output && isset($output['mtimeFiles'])) { foreach ($output['mtimeFiles'] as $f) { if (filemtime($f) > $output['mtime']) { Kwf_Media_MemoryCache::getInstance()->remove($cacheId); $output = false; break; } } } if (!$output) { $classWithoutDot = strpos($class, '.') ? substr($class, 0, strpos($class, '.')) : $class; if (!Kwf_Loader::isValidClass($classWithoutDot) || !is_instance_of($classWithoutDot, 'Kwf_Media_Output_Interface')) { throw new Kwf_Exception_NotFound(); } $output = call_user_func(array($classWithoutDot, 'getMediaOutput'), $id, $type, $class); $specificLifetime = false; $useCache = true; if (isset($output['lifetime'])) { $specificLifetime = $output['lifetime']; if (!$output['lifetime']) { $useCache = false; } } if (!isset($output['mtime'])) { if (isset($output['file'])) { $output['mtime'] = filemtime($output['file']); } else { if (isset($output['mtimeFiles'])) { $output['mtime'] = 0; foreach ($output['mtimeFiles'] as $f) { $output['mtime'] = max($output['mtime'], filemtime($f)); } } else { $output['mtime'] = time(); } } } if ($useCache) { $cacheData = $output; if (isset($cacheData['contents']) && strlen($cacheData['contents']) > 20 * 1024) { //don't cache contents larger than 20k in apc, use separate file cache $cacheFileName = Kwf_Config::getValue('mediaCacheDir') . '/' . $class . '/' . $id . '/' . $type; if (!is_dir(dirname($cacheFileName))) { @mkdir(dirname($cacheFileName), 0777, true); } file_put_contents($cacheFileName, $cacheData['contents']); $cacheData['file'] = $cacheFileName; unset($cacheData['contents']); } Kwf_Media_MemoryCache::getInstance()->save($cacheData, $cacheId, $specificLifetime); } } return $output; }