public static function loadClass($id, $class_path, $class_name) { if (self::isModuleLoaded($id)) { return false; } if (!file_exists($class_path)) { Helpers::debugError('FrontendModules: Class file not found (' . $class_name . ' doesn\'t exist)!'); return false; } require_once $class_path; if (!class_exists($class_name)) { Helpers::debugError('FrontendModules: Class not found (class "' . $class_name . '" doesn\'t exist in ' . $class_path . ')!'); } $module = new $class_name(); self::$modules[$id] = $module; return $module; }
function smarty_function_module($params, Smarty_Internal_Template $template) { $output = ''; if (isset($params['id'])) { $module_id = $params['id']; if (FrontendModules::isModuleLoaded($module_id)) { $module = FrontendModules::getInstanceOf($module_id); $output = $module->output($params, $template); if ($output === null) { $output = ''; } } else { Helpers::debugError('Smarty plugin function.module.php: frontend module with ID "' . $module_id . '" was not loaded.'); } } else { Helpers::debugError('Smarty plugin function.module.php: parameter "id" is missing.'); } return $output; }
protected static function error($function) { $message = $function . ' could not succeed.'; if (function_exists("error_get_last")) { $info = error_get_last(); $message .= ' Error-Message: ' . $info['message']; } switch (self::$error_mode) { case self::ERROR_MODE_DEBUG: Helpers::debugError($message); break; case self::ERROR_MODE_FATAL: Helpers::fatalError($message); break; case self::ERROR_MODE_SILENT: break; default: break; } }
public static function loadClass($class_path, $class_name) { if (self::isPluginRegistered($class_name)) { return false; } if (!file_exists($class_path)) { Helpers::debugError('RegisterPlugin: Class file not found (' . $class_name . ' doesn\'t exist)!'); return false; } require_once $class_path; if (!class_exists($class_name)) { Helpers::debugError('RegisterPlugin: Class not found (class "' . $class_name . '" doesn\'t exist in ' . $class_path . ')!'); } $plugin = new $class_name(); $hooks = $plugin->register(); if (is_array($hooks)) { if (count($hooks) > 0) { foreach ($hooks as $hook) { if (isset($hook['hookId']) && isset($hook['methodName'])) { if (!method_exists($plugin, $hook['methodName'])) { Helpers::debugError('RegisterPlugin: class method not found (class-method "' . $hook['methodName'] . '" doesn\'t exist in class "' . $class_name . '")!'); return false; } self::registerHook($hook['hookId'], $class_name, $hook['methodName']); } } self::$registeredPlugins[$class_name] = array('className' => $class_name, 'classInstance' => new $class_name(), 'hooks' => $hooks); } else { return false; } } else { return false; } return true; }
public static function apply($modifier_id, &$data, $structure, $parameters) { if (self::isModifierLoaded($modifier_id)) { $modifier = self::getInstanceOf($modifier_id); $modifier->apply($data, $structure, $parameters); } else { Helpers::debugError('DataModifiers: A modifier with the ID "' . $modifier_id . '" was not loaded.'); } }
public function getArray($language_id = null, $smarty = null, $parameters = null) { // Wenn keine Sprache angegeben, Standard-Sprache annehmen if ($language_id === null) { $language_id = Config::get()->languages->standard; } // Die "rohen" Daten laden $input = $this->getArrayRaw(); $output = null; if ($input !== null) { // Seiten-Eigenschaften laden $page_id = $this->loaded_page_id; $page_properties = $this->pages->getProperties($page_id); if ($page_properties === false) { return null; } // Daten-Struktur für diese Seite laden $pages_structure = DataStructure::pagesArray(); if (!isset($pages_structure[$page_properties['template-id']]['structure'])) { Helpers::debugError('A page template with the ID "' . $page_properties['template-id'] . '" does not exist!'); return null; } $page_structure = $pages_structure[$page_properties['template-id']]['structure']; // Der Pfad zu den zugehörigen Dateien (Bilder) einer Seite unterscheiden sich // je nachdem, ob die veröffentlichte oder die editierte Version der Seite angefragt wurde if ($this->isPublished()) { $page_files = $this->pages->getPageFilesPublishedFolder($page_id, $page_properties); $page_files_url = $this->pages->getPageFilesPublishedUrl($page_id, $page_properties); } else { $page_files = $this->pages->getPageFilesEditFolder($page_id, $page_properties); $page_files_url = $this->pages->getPageFilesEditUrl($page_id, $page_properties); } $page_url = $this->pages->getPageUrl($page_id, $language_id, $page_properties); // Die Parameter für die Plugins und Modifikatoren zusammenstellen // ggf. werden einige oder alle dieser Parameter über die Variable $parameters // wieder überschrieben if (!is_array($parameters)) { $parameters = array(); } $standard_parameters = array('preview' => !$this->isPublished(), 'pageId' => $page_id, 'languageId' => $language_id, 'templateId' => $page_properties['template-id'], 'uniqueId' => $page_properties['unique-id'], 'pageUrl' => $page_url, 'pageFiles' => $page_files, 'pageFilesUrl' => $page_files_url); if ($smarty !== null) { $standard_parameters['smarty'] = $smarty; } $parameters = array_merge($standard_parameters, $parameters); // Das Ausgabe-Array wird ggf. durch Plugins und // höchstwahrscheinlich durch die Modifikatoren geändert $output = $input; if ($smarty !== null) { $this->pages->applyPluginsToDataFields(Plugins::ASSIGN_PAGE_DATA_FIELD, $parameters, $output, $page_properties); } DataModifiers::applyAll($output, $page_structure, $parameters); } return $output; }