public static function getHooks($module = null) { // $conn = Gio_Db_Connection::getConnection(); // $dao = new Modules_Core_Models_Mysql_Hook(); // $dao->setConnection($conn); // return $dao->getHooks($module); $ret = array(); $hooksDir = ROOT_DIR . DS . 'hooks'; if ($module) { $hooksDir = MOD_DIR . DS . $module . DS . 'hooks'; } if (!file_exists($hooksDir)) { return $ret; } $hooksIterator = new DirectoryIterator($hooksDir); foreach ($hooksIterator as $hook) { if ($hook->isDot()) { continue; } $hookName = $hook->getFilename(); if ('CVS' == $hookName || '.svn' == strtolower($hookName) || 'index.html' == $hookName || '.htaccess' == $hookName) { continue; } /** * Widget information */ $xmlFile = $hooksDir . DS . $hookName . DS . 'about.xml'; if (file_exists($xmlFile)) { $xmlData = @simplexml_load_file($xmlFile); $data = array('name' => strtolower((string) $xmlData->name), 'module' => strtolower((string) $xmlData->module), 'thumbnail' => (string) $xmlData->thumbnail, 'author' => (string) $xmlData->author, 'email' => (string) $xmlData->email, 'description' => (string) $xmlData->description, 'version' => (string) $xmlData->version, 'license' => (string) $xmlData->license, 'params' => Gio_Core_Hook_Config::getParams($hookName, $module)); $ret[] = $data; } } return $ret; }
public function installAction() { $this->setNoRender(); $this->disableLayout(); $response = 'RESULT_NOT_OK'; $request = $this->getRequest(); if (!$request->isPost()) { return; } $moduleId = $request->getPost('module_id'); $moduleId = $moduleId == 'GLOBAL' ? null : $moduleId; $name = $request->getPost('name'); $title = $request->getPost('title'); $description = $request->getPost('description'); $hookInfo = Gio_Core_Hook_Config::getHookInfo($name, $moduleId); $hook = array('module' => $moduleId, 'name' => $hookInfo['name'], 'description' => $hookInfo['description'], 'author' => $hookInfo['author'], 'email' => $hookInfo['email'], 'license' => $hookInfo['license'], 'version' => $hookInfo['version'], 'thumbnail' => $hookInfo['thumbnail']); if (Modules_Core_Services_Hook::exist($hook) == true) { return; } Modules_Core_Services_Hook::add($hook); $response = 'RESULT_OK'; $this->getResponse()->setBody($response); }