public function render() { error_reporting(E_ALL); ini_set('display_errors', 1); Application::loadLibrary('olmi/request'); Application::loadLibrary('core/router'); $url = ltrim($_SERVER['REQUEST_URI'], '/'); $user_session = Application::getUserSession(); $user_logged = $user_session->getUserAccount(); Router::setDefaultModuleName($user_logged ? 'profile' : 'login'); Router::route($url); $page = Application::getPage(); $page = Application::getPage(); $page->setTitle('OCS'); $page->addMeta(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1')); $page->addMeta(array('charset' => 'utf-8')); $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap.min.css')); $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap-theme.min.css')); $page->addStylesheet(coreResourceLibrary::getStaticPath('jquery-ui/jquery-ui-bootstrap.css')); $page->addStylesheet(coreResourceLibrary::getStaticPath('/css/admin.css')); $page->addScript(coreResourceLibrary::getStaticPath('/js/jquery-1.11.3.min.js')); $page->addScript(coreResourceLibrary::getStaticPath('/jquery-ui/jquery-ui.min.js')); $page->addScript(coreResourceLibrary::getStaticPath('/bootstrap/js/bootstrap.min.js')); $page->addScript(coreResourceLibrary::getStaticPath('/js/application.js')); $page->addLiteral(' <script type="text/javascript"> jQuery(document).ready(function(){ App.init(); }); </script> '); $smarty = Application::getSmarty(); $module_name = Router::getModuleName(); $module_params = Router::getModuleParams(); if ($module_name) { $module = Application::getResourceInstance('module', $module_name); if (coreAccessControlLibrary::accessAllowed($user_logged, $module)) { $content = call_user_func(array($module, 'run'), $module_params); } else { Application::stackError(Application::gettext('You have no permission to login')); $user_session->logout(); Redirector::redirect(Application::getSeoUrl('/login?back=' . Router::getSourceUrl())); } } else { $content = Application::runModule('page404'); } $smarty->assign('content', $content); $html_head = $page->getHtmlHead(); $smarty->assign('html_head', $html_head); /*$smarty->assign('header', Application::getBlock('header')); $smarty->assign('footer', Application::getBlock('footer'));*/ $template_path = coreResourceLibrary::getTemplatePath('index'); $smarty->display($template_path); }
public function render() { $user_session = Application::getUserSession(); if (!$user_session->userLogged()) { return $this->terminate(); } $smarty = Application::getSmarty(); $smarty->assign('top_menu', Application::getBlock('menu')); $smarty->assign('user_logged', $user_session->getUserAccount()); $smarty->assign('logout_link', Application::getSeoUrl('/login/logout')); $smarty->assign('site_logo', coreResourceLibrary::getStaticPath('/img/site_logo.jpg')); $template_path = $this->getTemplatePath(); return $smarty->fetch($template_path); }
protected function createForm($object) { $form_class = coreResourceLibrary::getEffectiveClass('form', 'ocs_order_edit'); $this->form = new $form_class(); $this->form->initWithEntityFields($object); $this->form->setHeading($this->action == 'add' ? 'Добавление заявки' : 'Редактирование заявки'); $action_field = coreFormElementsLibrary::get('hidden', 'action'); $action_field->setValue($this->action); $this->form->addField($action_field); $form_action = "/{$this->getName()}"; if ($this->page > 1) { $form_action .= "?page={$this->page}"; } $form_action = Application::getSeoUrl($form_action); $this->form->setAction($form_action); $this->form->setMethod('post'); }
public function run() { $sql_scripts = coreResourceLibrary::findAll('deploy_db_script', null, null, 'sql'); ksort($sql_scripts); $db = Application::getDb(); $show_errors_old = $db->getShowErrors(); $db->setShowErrors(false); $db->execute("START TRANSACTION"); $deploy_succeed = true; $executed_this_time = array(); foreach ($sql_scripts as $script_name => $script_list) { if (!$deploy_succeed) { continue; } foreach ($script_list as $script) { $script_succeed = true; $path = $script->path; $sql_errors = array(); echo "Executing {$path}... "; if ($this->wasExecutedBefore($path)) { echo "[SKIPPED]\n"; continue; } $path_abs = coreResourceLibrary::getAbsolutePath($path); $script = file_get_contents($path_abs); $script = str_replace("\r\n", "\n", $script); $bom = pack('H*', 'EFBBBF'); $script = preg_replace("/^{$bom}/", '', $script); $queries = explode(";\n", $script); foreach ($queries as $q) { if (!$script_succeed) { continue; } $q = trim($q); if (!$q) { continue; } $query_suceed = (bool) $db->execute($q); if (!$query_suceed) { $sql_errors[] = $db->getLastError(); } $script_succeed = $script_succeed && $query_suceed; } if ($script_succeed) { echo "[OK]\n"; $executed_this_time[] = $path; } else { echo "[FAILED]\n"; echo "Errors:\n" . implode("\n", $sql_errors); $deploy_succeed = false; } } } if ($deploy_succeed) { foreach ($executed_this_time as $ett) { $this->markScriptAsExecuted($ett); } $db->execute("COMMIT"); } else { $db->execute("ROLLBACK"); } $db->setShowErrors($show_errors_old); }