public static function dbControllers($module = null) { $conn = Gio_Db_Connection::getConnection(); $controllerDao = new Modules_Core_Models_Mysql_Controller(); $controllerDao->setConnection($conn); return $controllerDao->dbControllers($module); }
public static function getById($widgetId, $moduleId = null) { $conn = Gio_Db_Connection::getConnection(); $widgetDao = new Modules_Core_Models_Mysql_Widget(); $widgetDao->setConnection($conn); return $widgetDao->getById($widgetId, $moduleId); }
public static function getArticles($articleId) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_News_Models_Mysql_ArticleRelate(); $dao->setConnection($conn); return $dao->getArticles($articleId); }
public static function delete($id) { $conn = Gio_Db_Connection::getConnection(); $targetDao = new Modules_Core_Models_Mysql_Target(); $targetDao->setConnection($conn); return $targetDao->delete($id); }
public static function getBannerPageAssoc($bannerId) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Ad_Models_Mysql_BannerPageAssoc(); $dao->setConnection($conn); return $dao->getBannerPageAssoc($bannerId); }
public static function count($condition = array()) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Tag_Models_Mysql_TagItem(); $dao->setConnection($conn); return $dao->count($condition); }
public static function getLatestVideo($limit) { $conn = Gio_Db_Connection::getConnection(); $videoDao = new Modules_Multimedia_Models_Mysql_Video(); $videoDao->setConnection($conn); return $videoDao->getLatestVideo($limit); }
public static function getHomeCategories($subCategory = false, $parentId = 0) { $conn = Gio_Db_Connection::getConnection(); $categoryDao = new Modules_News_Models_Mysql_Category(); $categoryDao->setConnection($conn); return $categoryDao->getHomeCategories($subCategory, $parentId); }
public function addAction() { $request = $this->getRequest(); $this->view->defaultModule = $this->_defaultModule; $sourceId = $request->getParam('source_id'); $sourceCategory = null == $sourceId ? null : Modules_Category_Services_Category::getById($sourceId); $this->view->sourceCategory = $sourceCategory; $this->view->lang = $request->getParam('lang'); $conn = Gio_Db_Connection::getConnection(); $categoryDao = new Modules_Category_Models_Mysql_Category(); $categoryDao->setConnection($conn); $this->view->categoryDao = $categoryDao; if ($request->isPost()) { $user = Gio_Core_Session::getUser(); $categoryData = $request->getPost('category'); $categoryData = Modules_Category_Services_Category::validate($categoryData); if (isset($categoryData['messages_error']) && $categoryData['messages_error']) { $this->view->errorMessages = $categoryData['messages']; $this->view->categoryData = $categoryData; return; } $parentCategory = null; if ($categoryData['parent_id']) { $parentCategory = Modules_Category_Services_Category::getById($categoryData['parent_id']); } $path = $parentCategory && $parentCategory['category_path'] ? $parentCategory['category_path'] . '/' . $categoryData['slug'] : $categoryData['slug']; $category = array('name' => $this->view->STRING->escape($categoryData['name']), 'slug' => $this->view->STRING->escape($categoryData['slug']), 'category_path' => $this->view->STRING->escape($path), 'meta' => $this->view->STRING->escape($categoryData['meta']), 'status' => $this->view->STRING->escape($categoryData['status']), 'module_id' => $this->view->STRING->escape($categoryData['module_id']), 'parent_id' => $this->view->STRING->escape($categoryData['parent_id']), 'language' => $this->view->STRING->escape($categoryData['language']), 'status' => $this->view->STRING->escape($categoryData['status']), 'created_date' => date('Y-m-d H:i:s'), 'modified_date' => date('Y-m-d H:i:s'), 'user_id' => $user['user_id']); $sourceItem = isset($categoryData['source_item']) ? $categoryData['source_item'] : null; $categoryId = Modules_Category_Services_Category::add($category, $sourceItem); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('category_actions_add_success')); $this->redirect($this->view->url('category_category_add')); } }
public function deleteByRole($roleId) { $conn = Gio_Db_Connection::getConnection(); $ruleDao = new Modules_Core_Models_Mysql_Rule(); $ruleDao->setConnection($conn); return $ruleDao->deleteByRole($roleId); }
public static function add($articleId) { $request = Gio_Core_Request::getInstance(); $articleRelateIds = $request->getParam('relateArticleIds'); if ($articleId && !empty($articleRelateIds)) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_News_Models_Mysql_Article(); $dao->addToRelateArticles($articleId, $articleRelateIds); } }
protected function showAction() { $currRoute = Gio_Core_Route::getCurrentRoute(); $routeName = $currRoute['name']; $defaults = $currRoute; $request = $this->getRequest(); $this->view->lang = $request->getParam('lang'); $links = array(); if (isset($defaults['localization']['enable']) && 'true' == $defaults['localization']['enable'] && isset($defaults['localization']['identifier']['class'])) { $class = $defaults['localization']['identifier']['class']; $name = $defaults['localization']['identifier']['param']; /** * The DAO method used to get the model instance */ $method = isset($defaults['localization']['identifier']['method']) ? $defaults['localization']['identifier']['method'] : 'getById'; $id = Gio_Core_Request::getInstance()->getParam($name); $conn = Gio_Db_Connection::getConnection(); $translationDao = new Modules_Core_Models_Mysql_Translation(); $translationDao->setConnection($conn); $items = $translationDao->getItems($id, $class); $array = explode('_', $class); $array[] = $array[count($array) - 1]; $array[count($array) - 2] = 'Mysql'; $daoClass = implode('_', $array); $daoInstance = new $daoClass(); $daoInstance->setConnection($conn); if ($items != null) { $config = Gio_Core_Config_Xml::getConfig('localization'); $languages = $config->languages->details; foreach ($items as $item) { if ($item['item_id'] == $id) { continue; } $object = $daoInstance->{$method}($item['item_id']); if ($object != null) { $language = $item['language']; if (isset($languages[$item['language']])) { $info = explode('|', $languages[$item['language']]); $language = $info[1]; } $links[] = array('url' => $this->view->url($routeName, $object), 'label' => $language); } } } } $this->view->assign('links', $links); }
/** * Get all translation items of given item * * @param Gio_Core_Model $dao * @param array $item * @return array */ public static function translationItems($item, $daoInstance) { $configs = Gio_Core_Config_Xml::getConfig(); if (!isset($configs->localization->languages->list) || $configs->localization->languages->list == $configs->web->language) { return array(); } /** * Create DAO instance based on the item class */ $conn = Gio_Db_Connection::getConnection(); $daoInstance->setConnection($conn); $result = array(); foreach (explode(',', $configs->localization->languages->list) as $lang) { $result[$lang] = null; } $translations = $daoInstance->getTranslations($item); if ($translations != null) { foreach ($translations as $translation) { $result[$translation['language']] = $translation; } } return $result; }
public function import($file) { $conn = Gio_Db_Connection::getConnection(); $prefix = $conn->_tablePrefix; $queries = Gio_Core_Import_MysqlParser::parse($file, $prefix); if ($queries) { foreach ($queries as $query) { $conn->query($query); /** * FIXME: Use PDO instead of normal MySQL connection * <code> * try { * $conn->beginTransaction(); * $conn->query($query); * $conn->commit(); * } cactch (Exception $ex) { * $conn->rollBack() * } * </code> */ } } $conn->close(); }
public function dispatch() { $cacheType = 'widgets'; $request = $this->_request; /** * XML */ $xmlFilename = array($this->_module, $this->_widget, $this->_action); $xmlFilename = implode('_', $xmlFilename); /** * Check file html cache */ $globalConfig = Gio_Core_Config_Xml::getConfig(); $configs = Gio_Core_Config_Xml::getConfig('cache'); $checkCache = false; if ($configs->enable == 'true' && $this->_cacheEnable == true) { $cacheName = $xmlFilename; $postParams = $request->getPostParams(); $getParams = $request->getParams(); $widgetParams = $this->_params; $json = new Services_JSON(); $cacheParams = !empty($postParams) ? base64_encode($json->encodeUnsafe($postParams)) : null; $cacheParams = !empty($getParams) ? base64_encode($json->encodeUnsafe($getParams)) : null; $cacheParams = !empty($widgetParams) ? base64_encode($json->encodeUnsafe($widgetParams)) : null; $cacheKey = md5($cacheName . $this->_template . $cacheParams . base64_encode($json->encodeUnsafe($globalConfig))); $cacheTimeout = $this->_cacheTimeout ? $this->_cacheTimeout : 3600; /** * Create html file cache */ if ($checkCache = Gio_Core_Cache::isCached($cacheType, $cacheKey, $cacheTimeout)) { $html = $this->view->render(Gio_Core_Cache::_generateFileName($cacheType, $cacheKey)); return $html; } } /** * Localization config */ $aboutFile = ROOT_DIR . DS . 'modules' . DS . $this->_module . DS . 'widgets' . DS . $this->_widget . DS . 'about.xml'; if (file_exists($aboutFile)) { $info = @simplexml_load_file($aboutFile); $localization = $info->localization['enable']; if ($localization != null && 'true' == (string) $localization) { $idClass = (string) $info->localization->identifier['class']; $idParam = (string) $info->localization->identifier['param']; $this->_params[$idParam] = isset($this->_params[$idParam]) ? $this->_params[$idParam] : null; $conn = Gio_Db_Connection::getConnection(); $this->_translationDao->setConnection($conn); $items = $this->_translationDao->getItems($this->_params[$idParam], $idClass, $request->getParam('lang')); if ($items != null && 1 == count($items)) { $this->_params[$idParam] = $items[0]['item_id']; } } } $ucfModule = ucfirst($this->_module); $ucfWidget = ucfirst($this->_widget); $widgetClassName = array('Modules', $ucfModule, 'Widgets', $ucfWidget, 'Widget'); $widgetClassName = implode('_', $widgetClassName); $widgetClass = new $widgetClassName(); if (!method_exists($widgetClass, $this->_action . 'Action')) { return; } $widgetClass->setParams($this->_params); call_user_func(array($widgetClass, $this->_action . 'Action')); $widgetDefaultViewFile = MOD_DIR . DS . $this->_module . DS . 'widgets' . DS . $this->_widget . DS . $this->_action . '.phtml'; $widgetViewFile = TEMPLATE_DIR . DS . $this->_template . DS . 'modules' . DS . $this->_module . DS . 'widgets' . DS . $this->_widget . DS . $this->_action . '.phtml'; $widgetViewFile = file_exists($widgetViewFile) ? $widgetViewFile : $widgetDefaultViewFile; $widgetClass->view->cacheEnable = $this->_cacheEnable; $widgetClass->view->cacheTimeout = $this->_cacheTimeout; $return = $widgetClass->view->render($widgetViewFile); if (!isset($this->_params['load']) || $this->_params['load'] != 'ajax') { $jsCss = array('cssFiles' => array(), 'jsFiles' => array()); $search = array('{APP_WEB_URL}', '{APP_STATIC_SERVER}', '{WIDGET_URL}'); $replace = array($this->view->APP_WEB_URL, $this->view->APP_STATIC_SERVER, $this->view->APP_STATIC_SERVER . DS . 'modules' . DS . strtolower($this->_module) . DS . 'widgets' . DS . strtolower($this->_widget)); $configFile = ROOT_DIR . DS . 'modules' . DS . strtolower($this->_module) . DS . 'widgets' . DS . strtolower($this->_widget) . DS . 'about.xml'; if (file_exists($configFile)) { $widgetConfig = @simplexml_load_file($configFile); if ($resources = $widgetConfig->resources) { if ($resources = $resources->resource) { foreach ($resources as $resource) { $attr = $resource->attributes(); switch ((string) $attr['type']) { case 'css': $jsCss['cssFiles'][] = str_replace($search, $replace, (string) $attr['src']); break; case 'javascript': $jsCss['jsFiles'][] = str_replace($search, $replace, (string) $attr['src']); break; } } } } } if ($jsCss['cssFiles']) { foreach ($jsCss['cssFiles'] as $index => $file) { Gio_Core_View::getInstance()->headStyle($file); } } if ($jsCss['jsFiles']) { foreach ($jsCss['jsFiles'] as $index => $file) { Gio_Core_View::getInstance()->headScript($file); } } } if (!$checkCache && $configs->enable == 'true' && $this->_cacheEnable == true) { $cacheCompress = isset($configs->compress) && $configs->compress == 'true' ? true : false; $cacheContent = Gio_Core_View::getInstance()->generateScripts() . Gio_Core_View::getInstance()->generateStyles() . $return; /** * HTML Compress */ if (isset($configs->compress) && $configs->compress == 'true') { $cacheContent = Gio_Core_HtmlCompress::compress($cacheContent); } Gio_Core_Cache::cache($cacheType, $cacheKey, $cacheContent, $cacheCompress); } return $return; }
public static function getAllZones($active = false) { $conn = Gio_Db_Connection::getConnection(); $zoneDao = new Modules_Ad_Models_Mysql_Zone(); $zoneDao->setConnection($conn); return $zoneDao->getAllZones($active); }
public static function getByItem($item) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Tag_Models_Mysql_Tag(); $dao->setConnection($conn); return $dao->getByItem($item); }
public static function uninstall($module) { $conn = Gio_Db_Connection::getConnection(); $moduleDao = new Modules_Core_Models_Mysql_Module(); $moduleDao->setConnection($conn); return $moduleDao->uninstall($module); }
/** * 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 __construct() { $this->_lang = Gio_Core_Config_Xml::getConfig('web')->language; $this->_conn = Gio_Db_Connection::getConnection(); }
public static function dbPages($fieldsName = null) { $conn = Gio_Db_Connection::getConnection(); $pageDao = new Modules_Core_Models_Mysql_Page(); $pageDao->setConnection($conn); return $pageDao->dbPages($fieldsName); }
public function run() { ini_set("max_execution_time", 100); ini_set('memory_limit', '256M'); require_once LIB_DIR . DS . 'simplehtmldom' . DS . 'simple_html_dom.php'; $conn = Gio_Db_Connection::getConnection(); $articleAutoDao = new Modules_News_Models_Mysql_Articleauto(); $articleAutoDao->setConnection($conn); $numArticles = 30; $articlesAuto = $articleAutoDao->find($numArticles); $articleDao = new Modules_News_Models_Mysql_Article(); $articleDao->setConnection($conn); /** * Auto Tags */ $autoTag = false; $allTags = array(); if ($autoTag) { // $tagDao = new Admin_Modules_News_Models_Mysql_Tag(); // $tagDao->setConnection($conn); // $allTags = $tagDao->getAllTags(); } if ($articlesAuto) { foreach ($articlesAuto as $index => $articleAuto) { $categories = explode('-', $articleAuto['category_ids']); $article = array('title' => trim($articleAuto['title']), 'slug' => trim($articleAuto['slug']), 'created_date' => $articleAuto['created_date'], 'category_id' => $categories[0], 'status' => 'active', 'description' => trim($articleAuto['description']), 'article_hot' => $index % 5 == 0 ? 1 : 0, 'article_sticky' => $index % 3 != 0 ? 1 : 0, 'link_source' => $articleAuto['link_source'], 'image_url' => $articleAuto['image_url'], 'web_id' => $articleAuto['website'], 'article_photo' => $articleAuto['article_photo'], 'article_video' => $articleAuto['article_video'], 'language' => 'vi_VN'); $existsArticle = $articleDao->getByLink($article['link_source']); $articleAutoDao->delete($articleAuto['auto_id']); if (null == $existsArticle) { switch ($articleAuto['website']) { case 'vtc': $article = $this->_vtc($article); break; case 'vnexpress': $article = $this->_vnexpress($article); break; case 'dantri': $article = $this->_dantri($article); break; case 'thethaovanhoa': $article = $this->_thethaovanhoa($article); break; case 'zing': $article = $this->_zing($article); break; case 'megafun': $article = $this->_megafun($article); break; case 'kenh14': $article = $this->_kenh14($article); break; case 'ngoisao': $article = $this->_ngoisao($article); break; case 'haitugio': $article = $this->_haitugio($article); break; case 'tuoitre': $article = $this->_tuoitre($article); break; case 'thanhnien': $article = $this->_thanhnien($article); break; case 'nguoilaodong': $article = $this->_nguoilaodong($article); break; case 'haisao': $article = $this->_haisao($article); break; case 'autopro': $article = $this->_autopro($article); break; case 'bongda': $article = $this->_bongda($article); break; case 'tintuconline': $article = $this->_tintuconline($article); break; } if ($article['title'] && $article['description'] && $article['content']) { $articleId = $articleDao->add($article); if ($articleId) { /** * Add to article category assoc */ $articleDao->addToCategories($articleId, $categories); } } } } } }
public function linkAction() { $this->setNoRender(); $this->disableLayout(); $request = $this->getRequest(); $linkId = (int) $request->getParam('link_id'); $type = $request->getParam('web_id'); if (!$linkId) { return; } $cron = new Modules_News_Services_Cron(); switch ($type) { case 'vnexpress': $cron->vnexpress($linkId); break; case 'zing': $cron->zing($linkId); break; case 'dantri': $cron->dantri($linkId); break; case 'megafun': $cron->megafun($linkId); break; case 'kenh14': $cron->kenh14($linkId); break; case 'ngoisao': $cron->ngoisao($linkId); break; case 'haitugio': $cron->haitugio($linkId); break; case 'tuoitre': $cron->tuoitre($linkId); break; case 'thanhnien': $cron->thanhnien($linkId); break; case 'nguoilaodong': $cron->nguoilaodong($linkId); break; case 'haisao': $cron->haisao($linkId); break; case 'autopro': $cron->autopro($linkId); break; case 'bongda': $cron->bongda($linkId); break; case 'vtc': $cron->vtc($linkId); break; case 'tintuconline': $cron->tintuconline($linkId); break; } $arrayArticles = $cron->addArticles; $arrayCategories = $cron->addCategories; /** * */ if (!empty($arrayArticles) && !empty($arrayCategories)) { $conn = Gio_Db_Connection::getConnection(); $articleDao = new Modules_News_Models_Mysql_Article(); $articleDao->setConnection($conn); $articleAutoDao = new Modules_News_Models_Mysql_Articleauto(); $articleAutoDao->setConnection($conn); for ($i = 0; $i < count($arrayArticles); $i++) { $addArticles = $arrayArticles[$i]; $categories = $arrayCategories[$i]; foreach ($addArticles as $index => $article) { $existsArticle = $articleAutoDao->getByLink($article['link_source']); if (null == $existsArticle) { $articleAutoDao->add($article); } } } } }
public static function checkEmailExist($email) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Core_Models_Mysql_User(); $dao->setConnection($conn); return $dao->getByEmail($email); }
public static function deleteByController($module, $controller) { $conn = Gio_Db_Connection::getConnection(); $actionrDao = new Modules_Core_Models_Mysql_Action(); $actionrDao->setConnection($conn); return $actionrDao->deleteByController($module, $controller); }
public static function getModules() { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Core_Models_Mysql_Hook(); $dao->setConnection($conn); return $dao->getModules(); }
public static function add($mail) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Mail_Models_Mysql_Mail(); $dao->setDbConnection($conn); return $dao->add($mail); }
public static function count($condition = array()) { $conn = Gio_Db_Connection::getConnection(); $webDao = new Modules_News_Models_Mysql_Web(); $webDao->setConnection($conn); return $webDao->count($condition); }
public static function getSource($article) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_News_Models_Mysql_Article(); $dao->setConnection($conn); return $dao->getSource($article); }
public static function getTranslatable($lang) { $conn = Gio_Db_Connection::getConnection(); $dao = new Modules_Page_Models_Mysql_Page(); $dao->setConnection($conn); return $dao->getTranslatable($lang); }