public function showAction() { $request = $this->getRequest(); $this->view->lang = $request->getParam('lang'); $modules = Modules_Core_Services_Module::getModulesInstalled(); foreach ($modules as $index => $module) { $modules[$index]['resource'] = Gio_Core_Module::getAboutModule($module['module_id'], 'resource'); } $this->view->wModules = $modules; $coreResources = Gio_Core_Module::getAboutModule('core'); $this->view->coreResources = $coreResources; $widgetsToolbox = Modules_Core_Services_Widget::dbWidgetsToolbox(); $this->view->widgetsToolbox = $widgetsToolbox; }
public function loadAction() { $mod = $this->getParam('mod'); $widgets = Modules_Core_Services_Widget::dbWidgets($mod); $this->view->widgets = $widgets; }
/** * Perform install actions * * @param bool $importSampleData * @return bool */ public static function install($importSampleData = false, $adminInfo = array()) { try { $view = Gio_Core_View::getInstance(); $moduleDirs = Gio_Core_File::getSubDir(ROOT_DIR . DS . 'modules'); /** * Install modules */ $modules = array(); foreach ($moduleDirs as $module) { $modules[] = Modules_Core_Services_Module::install($module); } foreach ($modules as $module) { if ($module) { Modules_Core_Services_Module::add($module); } } /** * Install widgets */ foreach ($moduleDirs as $module) { /** * Load all widgets from module */ $widgetDirs = Gio_Core_File::getSubDir(ROOT_DIR . DS . 'modules' . DS . $module . DS . 'widgets'); foreach ($widgetDirs as $widgetName) { $widget = array('module_id' => $module, 'widget_id' => $widgetName, 'title' => $view->TRANSLATOR->widget('about_title', $module, $widgetName), 'description' => $view->TRANSLATOR->widget('about_description', $module, $widgetName), 'created_date' => date('Y-m-d H:i:s')); Modules_Core_Services_Widget::add($widget); } } /** * Create resources and previleges */ foreach ($moduleDirs as $module) { $file = ROOT_DIR . DS . 'modules' . DS . $module . DS . 'configs' . DS . 'permissions.xml'; if (!file_exists($file)) { continue; } $xml = simplexml_load_file($file); foreach ($xml->controller as $res) { $attr = $res->attributes(); $langKey = (string) $attr['langKey']; $description = $view->TRANSLATOR->translator($langKey, $module); $description = $description == $langKey ? (string) $attr['description'] : $description; $resource = array('controller_id' => $attr['name'], 'description' => $description, 'module_id' => $module, 'created_date' => date('Y-m-d H:i:s')); /** * Add resource */ Modules_Core_Services_Controller::add($resource); if ($res->action) { foreach ($res->action as $pri) { $attr2 = $pri->attributes(); $langKey = (string) $attr2['langKey']; $description = $view->TRANSLATOR->translator($langKey, $module); $description = $description == $langKey ? (string) $attr2['description'] : $description; $privilege = array('controller_id' => $attr['name'], 'description' => $description, 'module_id' => $module, 'action_id' => $attr2['name'], 'created_date' => date('Y-m-d H:i:s')); Modules_Core_Services_Action::add($privilege); } } } } /** * Finally, init data */ $dbFile = ROOT_DIR . DS . 'install' . DS . 'db.xml'; if (file_exists($dbFile)) { $xml = simplexml_load_file($dbFile); $xpath = $xml->xpath('module/query'); if (is_array($xpath) && count($xpath) > 0) { $conn = Gio_Db_Connection::getConnection(); foreach ($xpath as $query) { $q = str_replace('###table_prefix###', $conn->_tablePrefix, (string) $query); $conn->query($q); } } } /** * Allows user to import sample data */ if ($importSampleData) { $file = ROOT_DIR . DS . 'install' . DS . 'giocms_sample_db.sql'; $importer = Gio_Core_Import_Importer::getInstance(); if ($importer != null && $file != null) { $importer->import($file); } } /** * Create admin user */ $salt = md5(time()); $user = array('username' => $adminInfo['username'], 'password' => md5(md5($adminInfo['password']) . $salt), 'email' => $adminInfo['email'], 'fullname' => $adminInfo['fullname'], 'salt' => $salt, 'status' => 'active', 'created_date' => date('Y-m-d H:i:s'), 'role_id' => 1); Modules_Core_Services_User::add($user); } catch (Exception $ex) { return false; } return true; }
public function ajaxAction() { $this->disableLayout()->setNoRender(); $request = $this->getRequest(); if (!$request->isPost()) { return; } $module = ucfirst(strtolower($request->getPost('mod'))); $name = ucfirst(strtolower($request->getPost('name'))); $cacheEnable = $request->getPost('cache'); $cacheEnable = $cacheEnable == 'true' ? true : false; $cacheTimeout = $request->getPost('timeout'); $cacheTimeout = $cacheTimeout > 0 ? $cacheTimeout : 3600; $params = array('load' => 'ajax', 'module' => $module, 'widget' => $name); $paramString = $request->getPost('params'); if ($paramString) { $temp = explode('|', $paramString); foreach ($temp as $index => $param) { $data = explode('=', $param); if ($param && count($data) == 2) { $params[$data[0]] = $data[1]; } } } $configs = Gio_Core_Config_Xml::getConfig('web'); $params['lang'] = !isset($params['lang']) || null == $params['lang'] ? $configs->language : $params['lang']; $action = $request->getPost('act', 'show'); $response = Modules_Core_Services_Widget::load($module, $name, $action, $params, $cacheEnable, $cacheTimeout); $json = new Services_JSON(); $this->getResponse()->setBody($json->encodeUnsafe($response)); }