function config($name, $value = null) { if (!$value) { return Config::get($name); } Config::set($name, $value); }
public function innerAction() { $this->_template = 'CatalogItemsWithoutFilter'; $page = !(int) Route::param('page') ? 1 : (int) Route::param('page'); // Check for existance $brand = DB::select()->from('brands')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current(); if (!$brand) { return Config::error(); } // Seo $this->_seo['h1'] = $brand->h1; $this->_seo['title'] = $brand->title; $this->_seo['keywords'] = $brand->keywords; $this->_seo['description'] = $brand->description; $this->setBreadcrumbs($brand->name); // Get count items per page $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit'); // Get sort type $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort'; $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC'; // Get popular items $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('catalog.brand_id', '=', $brand->id)->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit)->offset(($page - 1) * $limit)->as_object()->execute(); // Set description of the brand to show it above the sort part Config::set('brand_description', View::tpl(array('brand' => $brand), 'Brands/Inner')); // Count of parent groups $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('brand_id', '=', $brand->id)->where('status', '=', 1)->as_object()->execute()->current()->count; // Generate pagination $pager = Pager::factory($page, $count, $limit)->create(); // Render template $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList'); }
private function config() { $result = DB::select('key', 'zna')->from('config')->where('status', '=', 1)->find_all(); foreach ($result as $obj) { Config::set($obj->key, $obj->zna); } $this->setBreadcrumbs('Главная', 'backend'); }
private function config() { Config::set('content_class', 'wTxt'); $result = DB::select('key', 'zna')->from('config')->where('status', '=', 1)->as_object()->execute(); foreach ($result as $obj) { Config::set($obj->key, $obj->zna); } $result = DB::select('script', 'place')->from('seo_metrika')->where('status', '=', 1)->as_object()->execute(); foreach ($result as $obj) { $this->_seo['metrika'][$obj->place][] = $obj->script; } $result = DB::select('script')->from('seo_counters')->where('status', '=', 1)->as_object()->execute(); foreach ($result as $obj) { $this->_seo['counters'][] = $obj->script; } $this->setBreadcrumbs('Главная', ''); }
public function innerAction() { Config::set('content_class', 'new_block'); // Check for existance $obj = DB::select()->from('articles')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->find(); if (!$obj) { return Config::error(); } // Seo $this->_seo['h1'] = $obj->h1; $this->_seo['title'] = $obj->title; $this->_seo['keywords'] = $obj->keywords; $this->_seo['description'] = $obj->description; $this->setBreadcrumbs($obj->name); // Add plus one to views DB::update('articles')->set(array('views' => $obj->views + 1))->where('id', '=', $obj->id)->execute(); // Render template $this->_content = View::tpl(array('obj' => $obj), 'Articles/Inner'); }
public function addMeta($name, $order = false) { Config::set('h1', $name); Config::set('title', $name); Config::set('keywords', $name); Config::set('description', $name); if ($order) { $this->setBreadcrumbs('Личный кабинет', 'user/orders'); } $this->setBreadcrumbs($name); }
function before() { parent::before(); $this->_toolbar = Widgets::get('Toolbar/Edit'); Config::set('colls', 'column-2'); }
define('DEFAULT_CONTROLLER', 'General'); define('DEFAULT_METHOD', 'inicio'); /** * Set the default template. */ define('TEMPLATE', 'Default'); /** * Set a default language. */ define('LANGUAGE_CODE', 'en'); /** * PREFER to be used in database calls default is smvc_ */ define('PREFIX', ''); /** * Set prefix for sessions. */ define('SESSION_PREFIX', ''); /** * Optional create a constant for the name of the site. */ define('SITETITLE', 'Dcorrido'); /** * Optional set a site email address. */ define('SITEEMAIL', '*****@*****.**'); /** * Setup the (class) Aliases configuration. */ Config::set('class_aliases', array('Errors' => '\\Core\\Error', 'Language' => '\\Core\\Language', 'Mail' => '\\Helpers\\PhpMailer\\Mail', 'Assets' => '\\Helpers\\Assets', 'Arr' => '\\Helpers\\Arr', 'Cookie' => '\\Helpers\\Cookie', 'Csrf' => '\\Helpers\\Csrf', 'Date' => '\\Helpers\\Date', 'Document' => '\\Helpers\\Document', 'Form' => '\\Helpers\\Form', 'Ftp' => '\\Helpers\\Ftp', 'GeoCode' => '\\Helpers\\GeoCode', 'Hooks' => '\\Helpers\\Hooks', 'Inflector' => '\\Helpers\\Inflector', 'Number' => '\\Helpers\\Number', 'Paginator' => '\\Helpers\\Paginator', 'Password' => '\\Helpers\\Password', 'RainCaptcha' => '\\Helpers\\RainCaptcha', 'Request' => '\\Helpers\\Request', 'ReservedWords' => '\\Helpers\\ReservedWords', 'Response' => '\\Helpers\\Response', 'Session' => '\\Helpers\\Session', 'SimpleCurl' => '\\Helpers\\SimpleCurl', 'TableBuilder' => '\\Helpers\\TableBuilder', 'Tags' => '\\Helpers\\Tags', 'Url' => '\\Helpers\\Url'));
public static function setFilterParameters() { if (!Route::param('filter')) { return false; } $fil = Route::param('filter'); $fil = explode("&", $fil); $filter = array(); foreach ($fil as $g) { $g = urldecode($g); $g = strip_tags($g); $g = stripslashes($g); $g = trim($g); $s = explode("=", $g); $filter[$s[0]] = explode(",", $s[1]); } conf::set('filter_array', $filter); return true; }
function addAction() { if ($_POST) { $error = 0; $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); if (!trim(Arr::get($post, 'name'))) { Message::GetMessage(0, 'Наименование страницы не может быть пустым!'); $error = 1; } if (!trim(Arr::get($post, 'alias'))) { Message::GetMessage(0, 'Алиас не может быть пустым!'); $error = 1; } if (!$error) { $post['alias'] = Common::getUniqueAlias($this->tablename, Arr::get($post, 'alias')); $res = Common::insert($this->tablename, $post)->execute(); if ($res) { Message::GetMessage(1, 'Вы успешно добавили данные!'); HTTP::redirect('backend/' . Route::controller() . '/' . Route::action()); } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } $result = Arr::to_object($post); } else { $result = array(); } $this->_toolbar = Widgets::get('Toolbar/Edit'); Config::set('colls', 'column-2'); $this->_seo['h1'] = 'Добавление'; $this->_seo['title'] = 'Добавление'; $this->setBreadcrumbs('Добавление', 'backend/' . Route::controller() . '/' . Route::action()); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'tree' => Support::getSelectOptions('Content/Select', 'content', $result->parent_id)), $this->tpl_folder . '/Form'); }
<?php require_once __DIR__ . '/autoload.php'; use core\Config; use core\Bootstrap; Config::set(['app' => ['name' => 'PHPancy', 'version' => '0.0.1'], 'mysql' => ['host' => '127.0.0.1', 'db' => 'phpancy', 'user' => 'root', 'pass' => 'password'], 'session' => ['name' => 'user', 'token' => 'xsrf'], 'cookie' => ['name' => 'remember', 'expiry' => 604800]]); try { (new Bootstrap())->init(); } catch (Exception $e) { echo $e->getMessage(); }