Esempio n. 1
0
 /** Get an instance of the configured ESI type handler class.
  * @return object An instance of the configured ESI type handler.
  */
 protected static function getESITypeHandler()
 {
     if (self::$esiTypeHandler !== null) {
         return self::$esiTypeHandler;
     }
     $ini = eZINI::instance('nxc_esi.ini');
     $handler = null;
     $ini->assign('ESIType', 'ESITypeHandler', $handler);
     if (!is_string($handler) || $handler == '') {
         eZDebug::writeError('No ESI type handler is configured, falling back to default.', __METHOD__);
         $handler = 'nxcESITypeNone';
     }
     if (!class_exists($handler)) {
         eZDebug::writeError('Invalid ESI type handler in configuration, no such class: ' . $handler, __METHOD__);
         $handler = 'nxcESITypeNone';
     }
     try {
         $handler = new $handler();
     } catch (Exception $exception) {
         eZDebug::writeError('Invalid ESI type handler in configuration,' . ' the class could not be instantiated: ' . $handler . "\n" . $exception->getMessage(), __METHOD__);
         $handler = new nxcESITypeNone();
     }
     self::$esiTypeHandler = $handler;
     return self::$esiTypeHandler;
 }
Esempio n. 2
0
     eZExecution::cleanExit();
     break;
 case 'method':
 case 'method-static':
     if (!isset($keys['class']) || trim($keys['class']) == '') {
         eZDebug::writeError('Tried to include a method call without specifying the class.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     if (!isset($keys['method']) || trim($keys['method']) == '') {
         eZDebug::writeError('Tried to include a method call without specifying the method.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     $class = $keys['class'];
     $method = $keys['method'];
     unset($keys['class'], $keys['method']);
     if (!nxcESI::isMethodAllowed($class, $method)) {
         eZDebug::writeError('Tried to include a method call that is not allowed.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     if (!class_exists($class)) {
         eZDebug::writeError('Tried to include a method call on a non-existing class.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
     }
     if ($includeType == 'method-static') {
         $call = array($class, $method);
     } else {
         $call = array(new $class(), $method);
     }
     if (!is_callable($call)) {
         eZDebug::writeError('Tried to include a method call on a non-callable method.', 'nxc_esi/include/' . $includeType);
         return $module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
Esempio n. 3
0
 /** Extract the cache keys, with values, from the function invocation.
  * @return array Associative array of key name to value.
  * @see process()
  */
 private function extractKeys($tpl, $functionParameters, $rootNamespace, $currentNamespace, $functionPlacement)
 {
     $keys = array();
     foreach ($functionParameters as $paramName => $paramValue) {
         if (!nxcESI::validateKeyName($paramName)) {
             $tpl->warning($this->ESIncludeName, 'Invalid key name: ' . $paramName, $functionPlacement);
         } else {
             $value = $tpl->elementValue($paramValue, $rootNamespace, $currentNamespace, $functionPlacement);
             if (is_null($value)) {
                 // Skip this key
             } elseif (is_bool($value)) {
                 $keys[$paramName] = $value ? 'true' : 'false';
             } elseif (is_string($value) || is_numeric($value)) {
                 $keys[$paramName] = strval($value);
             } else {
                 $tpl->warning($this->ESIncludeName, 'Invalid value for key ' . $paramName . ': ' . $value, $functionPlacement);
             }
         }
     }
     return $keys;
 }