public function configAction() { $request = $this->getRequest(); $languagesFile = ROOT_DIR . DS . 'configs' . DS . 'languages.xml'; if (!file_exists($languagesFile)) { return; } $languagesXml = @simplexml_load_file($languagesFile); if (null == $languagesXml) { return; } $locales = array(); foreach ($languagesXml->language as $language) { $arr = explode('|', $language); $locales[$arr[0]] = array('code' => $arr[0], 'localName' => $arr[1], 'englishName' => $arr[2]); } $this->view->locales = $locales; $this->view->availableLanguages = array(); $configs = Gio_Core_Config_Xml::getConfig(); $this->view->configs = $configs; $default = isset($configs->localization->languages->default) ? $configs->localization->languages->default : $configs->web->language; $available = isset($configs->localization->languages->list) ? explode(',', $configs->localization->languages->list) : array($default); $this->view->availableLanguages = $available; if ($request->isPost()) { $localizationEenable = $request->getPost('localization_enable') != null ? 'true' : 'false'; $default = $request->getPost('default_language'); $available = $request->getPost('supported_languages'); $listLangs = array($default); if ($available != null) { foreach ($available as $index => $locale) { if ($locale != $default) { $listLangs[] = $locale; } } } $configs->web->language = $default; $configs->localization->enable = $localizationEenable; $configs->localization->languages->default = $default; $configs->localization->languages->list = implode(',', $listLangs); /** * Reset language details */ $configs->localization->languages->details = null; foreach ($listLangs as $lang) { $configs->localization->languages->details->{$lang} = implode('|', array($locales[$lang]['code'], $locales[$lang]['localName'], $locales[$lang]['englishName'])); } $configFile = Gio_Core_Config_Xml::getConfigFile(); $content = $configs->asXML(); $fileName = Gio_Core_Config_Xml::getConfigFile(); Gio_Core_File::writeToFile($fileName, $content); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('locale_actions_config_success')); $this->redirect($this->view->url('core_locale_config')); } }
public function setAction() { $request = $this->getRequest(); $this->disableLayout(); $this->setNoRender(); $templateName = $request->getPost('template_id'); if (!$request->isPost() || !$templateName) { $this->getResponse()->setBody('RESULT_NOT_OK'); } $configs = Gio_Core_Config_Xml::getConfig(); $configs->web->template = $templateName; $content = $configs->asXML(); $fileName = Gio_Core_Config_Xml::getConfigFile(); Gio_Core_File::writeToFile($fileName, $content); $this->getResponse()->setBody('RESULT_OK'); }
public static function add($page) { $conn = Gio_Db_Connection::getConnection(); $pageDao = new Modules_Core_Models_Mysql_Page(); $pageDao->setConnection($conn); /** * Create route layout */ $configs = Gio_Core_Config_Xml::getConfig('web'); $filename = $page['route'] . '.phtml'; $file = TEMPLATE_DIR . DS . $configs->template . DS . 'layouts' . DS . $filename; $content = null; if (file_exists($file)) { $content = file_get_contents($file); } Gio_Core_File::writeToFile($file, $content); return $pageDao->add($page); }
/** * Save mail server configurations * * @param array $data */ public static function saveConfig($data) { $config = self::getConfig(); $protocol = $data['protocol']['protocol']; $config['protocol']['protocol'] = $protocol; switch ($protocol) { case 'mail': if (isset($config['smtp'])) { unset($config['smtp']); } break; case 'smtp': $host = $data['smtp']['host']; if ($host == null || $host == '') { unset($config['smtp']['host']); } else { $config['smtp']['host'] = $host; } $port = $data['smtp']['port']; if ($port == null || $port == '') { unset($config['smtp']['port']); } else { $config['smtp']['port'] = $port; } if ($data['authentication'] == 'true') { $config['smtp']['username'] = $data['smtp']['username']; $config['smtp']['password'] = $data['smtp']['password']; } else { unset($config['smtp']['username']); unset($config['smtp']['password']); } $security = $data['smtp']['security']; if ($security != 'none') { $config['smtp']['security'] = $security; } break; } $content = Gio_Core_Array::toIni($config, true); /** * Write file */ $fileName = MOD_DIR . DS . 'mail' . DS . 'configs' . DS . 'config.ini'; return Gio_Core_File::writeToFile($fileName, $content); }
public function configAction() { $request = $this->getRequest(); $configs = Gio_Core_Config_Xml::getConfig(); $this->view->configs = $configs; $languagesFile = ROOT_DIR . DS . 'configs' . DS . 'languages.xml'; if (!file_exists($languagesFile)) { return; } $languagesXml = @simplexml_load_file($languagesFile); if (null == $languagesXml) { return; } $locales = array(); foreach ($languagesXml->language as $language) { $arr = explode('|', $language); $locales[$arr[0]] = array('code' => $arr[0], 'localName' => $arr[1], 'englishName' => $arr[2]); } $this->view->locales = $locales; if ($request->isPost()) { $act = $request->getPost('act'); switch ($act) { case 'testdbconn': $this->setNoRender(); $this->disableLayout(); $this->_testdbconn(); break; default: $version = isset($configs->install->version) ? $configs->install->version : Gio_Core_Cms::getVersion(); $date = isset($configs->install->date) ? $configs->install->date : date('Y-m-d H:i:s'); $author = isset($configs->install->author) ? (array) $configs->install->author : Gio_Core_Cms::getAuthor(); $localization = array('localization' => array('enable' => (string) $configs->localization->enable, 'languages' => array('default' => (string) $configs->localization->languages->default, 'list' => (string) $configs->localization->languages->list, 'details' => array()))); $timezone = array('timezone' => array('date' => (string) $configs->timezone->date, 'datetime' => (string) $configs->timezone->datetime)); if ($configs->localization->languages->list != null) { $list = explode(',', $configs->localization->languages->list); foreach ($list as $value) { $localization['localization']['languages']['details'][$value] = (string) $configs->localization->languages->details->{$value}; } } $configs = $request->getPost('configs'); $localization['localization']['languages']['default'] = $configs['web']['language']; $data = Modules_Core_Services_Installer::validate($configs); if (isset($data['messages_error']) && $data['messages_error']) { $this->view->errorMessages = $data['messages']; $configs = Gio_Core_Array::toObject($configs); $this->view->configs = $configs; return; } $install = array('install' => array('version' => $version, 'date' => $date, 'author' => $author)); $configs = array_merge($configs, $install); $configs = array_merge($configs, $localization); $configs = array_merge($configs, $timezone); $content = utf8_decode(Gio_Core_Array::toXml($configs, 'config')); $fileName = Gio_Core_Config_Xml::getConfigFile(); Gio_Core_File::writeToFile($fileName, $content); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('website_actions_config_success')); $this->redirect($this->view->url('core_website_config')); break; } } }
public function contentAction() { $request = $this->getRequest(); $template = $request->getParam('template_id'); $this->view->template = $template; $pageId = $request->getParam('page_id'); $page = Modules_Core_Services_Page::getById($pageId); if (null == $page) { return; } $page['template_id'] = $template; $this->view->page = $page; $templateFile = TEMPLATE_DIR . DS . $template . DS . 'layouts' . DS . $page['route'] . '.phtml'; if (!file_exists($templateFile)) { throw new Exception(''); } if ($request->isPost()) { $this->setNoRender(); $this->disableLayout(); $content = $request->getPost('content'); Gio_Core_File::writeToFile($templateFile, $content); $this->getResponse()->setBody('RESULT_OK'); return; } $content = file_get_contents($templateFile); $this->view->content = $content; }
public function step1Action() { /** * Remove all plugins */ Gio_Core_Application::getInstance()->removePlugins(); if (Gio_Core_Application::_initInstallChecker()) { $this->redirect($this->view->url('core_index_index')); } $this->setTemplate('admin'); $this->setLayout('install'); $request = $this->getRequest(); $configs = Gio_Core_Config_Xml::getConfig(); $request = Gio_Core_Request::getInstance(); if ((string) $configs->web->url != $request->getBaseUrl()) { $configs->server->static = $request->getBaseUrl(); $configs->server->resource = $request->getBaseUrl(); $configs->web->url = $request->getBaseUrl(); } $this->view->configs = $configs; $timezone = array('timezone' => array('date' => (string) $configs->timezone->date, 'datetime' => (string) $configs->timezone->datetime)); $localization = array('localization' => array('enable' => (string) $configs->localization->enable, 'languages' => array('default' => (string) $configs->localization->languages->default, 'list' => (string) $configs->localization->languages->list, 'details' => array()))); if ($configs->localization->languages->list != null) { $list = explode(',', $configs->localization->languages->list); foreach ($list as $value) { $localization['localization']['languages']['details'][$value] = (string) $configs->localization->languages->details->{$value}; } } $languagesFile = ROOT_DIR . DS . 'configs' . DS . 'languages.xml'; if (!file_exists($languagesFile)) { return; } $languagesXml = @simplexml_load_file($languagesFile); if (null == $languagesXml) { return; } $locales = array(); foreach ($languagesXml->language as $language) { $arr = explode('|', $language); $locales[$arr[0]] = array('code' => $arr[0], 'localName' => $arr[1], 'englishName' => $arr[2]); } $this->view->locales = $locales; if ($request->isPost()) { $act = $request->getPost('act'); switch ($act) { case 'testdbconn': $this->setNoRender(); $this->disableLayout(); $this->_testdbconn(); break; case '': default: $configs = $request->getPost('configs'); $data = Modules_Core_Services_Installer::validate($configs); if (isset($data['messages_error']) && $data['messages_error']) { $this->view->errorMessages = $data['messages']; $configs = Gio_Core_Array::toObject($configs); $this->view->configs = $configs; return; } $install = array('install' => array('version' => Gio_Core_Cms::getVersion(), 'date' => date('Y-m-d H:i:s'), 'author' => Gio_Core_Cms::getAuthor())); $configs = array_merge($configs, $install); $configs = array_merge($configs, $localization); $configs = array_merge($configs, $timezone); $content = utf8_decode(Gio_Core_Array::toXml($configs, 'config')); $fileName = Gio_Core_Config_Xml::getConfigFile(); Gio_Core_File::writeToFile($fileName, $content); $adminInfo = array('username' => 'admin', 'password' => '123456', 'email' => '*****@*****.**', 'fullname' => 'Ninhgio'); Modules_Core_Services_Installer::install(false, $adminInfo); $this->redirect($this->view->url('core_index_index')); break; } } }