public function indexAction() { $this->_template = 'CatalogItemsWithoutFilter'; $page = !(int) Route::param('page') ? 1 : (int) Route::param('page'); // Seo $this->_seo['h1'] = 'Поиск'; $this->_seo['title'] = 'Поиск'; $this->_seo['keywords'] = 'Поиск'; $this->_seo['description'] = 'Поиск'; $this->setBreadcrumbs('Поиск'); // Check query $query = Arr::get($_GET, 'query'); if (!$query) { return $this->_content = $this->noResults(); } // Get count items per page $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : conf::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 items list $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'))->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit, ($page - 1) * $limit)->as_object()->execute(); // Check for empty list if (!count($result)) { return $this->_content = $this->noResults(); } // Count of parent groups $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->as_object()->execute()->current()->count; // Generate pagination $pager = Pager::factory($page, $count, $limit)->create(); // Render page $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList'); }
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'); }
function config($name, $value = null) { if (!$value) { return Config::get($name); } Config::set($name, $value); }
public function __construct($data) { if (isset($data)) { $this->_data = $data; } $this->_db = Database::getInstance(Config::get('mysql/host'), Config::get('mysql/db'), Config::get('mysql/user'), Config::get('mysql/pass')); }
public static function sendMail($data) { $transport = Swift_SmtpTransport::newInstance(Config::get('smtp.server'), Config::get('smtp.port'))->setUsername(Config::get('smtp.username'))->setPassword(Config::get('smtp.password')); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance($data['subject'])->setFrom([Config::get('smtp.username') => Config::get('framework.title')])->setTo([$data['to']])->setContentType('text/html')->setBody($data['text']); return $mailer->send($message); }
/** * Make a URL that links to a controller/action/variables. * * By default we do not use the URL variables, but you can chose to do so. * * <code> * array( * 'controller' => 'Index', * 'action' => 'Index', * 'variables' => array( * 'foo' => 'bar', * 'bar' => 'foobar' * ) * 'variable_retain' => false * ) * </code> * * @access public * @param array $param Parameters used to build the URL. * @return string */ public function render($param = array()) { // Set some defaults $defaults = array('controller' => $this->controller, 'action' => '', 'variables' => isset($param['variable_retain']) && $param['variable_retain'] ? $_GET : array(), 'variable_retain' => false); // However, we do not want the controller/action in the variable list unset($defaults['variables']['controller'], $defaults['variables']['action']); // Merge these in with the parameters // Parameters will take precedence $param = array_merge($defaults, $param); // Start to build URL // The controller $url = Core\Config::get('path', 'root') . $param['controller'] . '/' . $param['action']; // Any variables if ($param['variables']) { // Yes, there are variables to append, loop over them foreach ($param['variables'] as $variable => $value) { // If there is an odd amount of variables in the URL string // .. then we just set the last variable to true. This needs // .. to be the same in this case also. $url .= '/' . urlencode($variable) . '/' . ($value === true ? '' : $value); } } // URL has finished constructing, pass back return $url; }
public function run() { $config = Config::get('socket'); $config = array('worker_num' => 4, 'task_worker_num' => 8, 'max_request' => 10000, 'dispatch_mode' => 2, 'debug_mode' => 0, 'daemonize' => false); if (isset($argv[1]) and $argv[1] == 'daemon') { $config['daemonize'] = true; } else { $config['daemonize'] = false; } $serv = new \swoole_server("0.0.0.0", 8808); $serv->set($config); $serv->config = $config; $handler = new Handler(); $serv->on('Start', array($handler, "start")); $serv->on('Connect', array($handler, "connect")); $serv->on('Receive', array($handler, "receive")); $serv->on('Close', array($handler, "close")); $serv->on('Shutdown', array($handler, "shutdown")); $serv->on('Timer', array($handler, "timer")); $serv->on('WorkerStart', array($handler, "workStart")); $serv->on('WorkerStop', array($handler, "workStop")); $serv->on('Task', array($handler, "task")); $serv->on('Finish', array($handler, "finish")); $serv->on('WorkerError', array($handler, "workError")); $serv->start(); }
public function __construct() { //Setup extra autoloader. new Autoloader(Config::get("autoloader")); $this->setVars(); $this->run(); }
public function handle() { $aConfig = c\Config::get('dsn'); u\DB::connect($aConfig['data']); $aData = parent::handle(); $aData['data']['host'] = "http://{$_SERVER['HTTP_HOST']}/?static="; return $aData; }
function before() { parent::before(); $this->_seo['h1'] = 'Банерная система'; $this->_seo['title'] = 'Банерная система'; $this->setBreadcrumbs('Банерная система', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
/** * 登陆 */ public function login() { $api = Config::get('global', 'qqconnect'); $weibo = Config::get('global', 'weibo'); $callback = url('qqlogin', '', '', 1); $loginurl = $this->getQqLoginUrl($api['appid'], $callback); include template(); }
function before() { parent::before(); $this->_seo['h1'] = 'Сообщения из формы заказа звонка'; $this->_seo['title'] = 'Сообщения из формы заказа звонка'; $this->setBreadcrumbs('Сообщения из формы заказа звонка', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
function before() { parent::before(); $this->_seo['h1'] = 'Бронирование мест'; $this->_seo['title'] = 'Бронирование мест'; $this->setBreadcrumbs('Бронирование мест', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
function before() { parent::before(); $this->_seo['h1'] = 'Вопросы по товарам'; $this->_seo['title'] = 'Вопросы по товарам'; $this->setBreadcrumbs('Вопросы по товарам', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
function before() { parent::before(); $this->_seo['h1'] = 'Заказы в один клик'; $this->_seo['title'] = 'Заказы в один клик'; $this->setBreadcrumbs('Заказы в один клик', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
function before() { parent::before(); $this->_seo['h1'] = 'Управление городами'; $this->_seo['title'] = 'Управление городами'; $this->setBreadcrumbs('Управление городами', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
function before() { parent::before(); $this->_seo['h1'] = 'Письма директору'; $this->_seo['title'] = 'Письма директору'; $this->setBreadcrumbs('Письма директору', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
function before() { parent::before(); $this->_seo['h1'] = 'Характеристики'; $this->_seo['title'] = 'Характеристики'; $this->setBreadcrumbs('Характеристики', 'backend/' . Route::controller() . '/index'); $this->limit = Config::get('limit_backend'); }
public static function init() { $classes = Config::get('class_aliases'); if (is_array($classes)) { foreach ($classes as $classAlias => $className) { class_alias($className, $classAlias); } } }
public function get($token) { $tokenName = Config::get('session/token'); if ($this->_session->exists($tokenName) && $this->_session->get($tokenName) === $token) { $this->_session->delete($tokenName); return true; } return false; }
/** * Loads an image and prepares it for manipulation. * * $image = Image::factory('upload/test.jpg'); * * @param string $file image file path * @param string $driver driver type: GD, ImageMagick, etc * @return Image * @uses Image::$default_driver */ public static function factory($file, $driver = NULL) { if ($driver === NULL) { // $driver = Image::$default_driver; $driver = Config::get('main.image'); } // Set the class name $class = 'Core\\Image\\' . $driver; return new $class($file); }
function before() { parent::before(); $this->_seo['h1'] = 'Пользователи'; $this->_seo['title'] = 'Пользователи'; $this->setBreadcrumbs('Пользователи', 'backend/' . Route::controller() . '/index'); $this->page = (int) Route::param('page') ? (int) Route::param('page') : 1; $this->limit = (int) Arr::get($_GET, 'limit', Config::get('limit_backend')) < 1 ?: Arr::get($_GET, 'limit', Config::get('limit_backend')); $this->offset = ($this->page - 1) * $this->limit; }
function before() { parent::before(); $this->_seo['h1'] = 'Статистика по организаторам'; $this->_seo['title'] = 'Статистика по организаторам'; $this->setBreadcrumbs('Статистика по организаторам', 'backend/organizer/index'); $this->limit = Config::get('limit_backend'); $this->pay_statuses = Config::get('order.pay_statuses'); $this->seat_statuses = Config::get('order.seat_statuses'); $this->page = (int) Route::param('page') ? (int) Route::param('page') : 1; }
/** * Delete image * @param string $mainFolder - name of th block in Config/images.php * @param string $filename - name of the file we delete * @return bool */ public static function deleteImage($mainFolder, $filename) { $need = Config::get('images.' . $mainFolder); if (!$need) { return false; } foreach ($need as $one) { $file = HOST . HTML::media('/images/' . $mainFolder . '/' . Arr::get($one, 'path') . '/' . $filename); @unlink($file); } return true; }
public function indexAction() { Config::set('content_class', 'news_block'); $page = !(int) Route::param('page') ? 1 : (int) Route::param('page'); $result = DB::select()->from('articles')->where('status', '=', 1)->order_by('id', 'DESC')->limit((int) Config::get('limit_articles'))->offset(($page - 1) * (int) Config::get('limit_articles'))->find_all(); // Count of articles $count = DB::select(array(DB::expr('COUNT(articles.id)'), 'count'))->from('articles')->where('status', '=', 1)->count_all(); // Generate pagination $pager = Pager::factory($page, $count, Config::get('limit_articles'))->create(); // Render template $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Articles/List'); }
public static function addItemTag($obj) { if ($obj->sale) { return '<div class="splash2"><span>акция</span></div>'; } if ($obj->top) { return '<div class="splash3"><span>популярное</span></div>'; } if ($obj->new and time() - (int) $obj->new_from < Config::get('new_days') * 24 * 60 * 60) { return '<div class="splash"><span>новинка</span></div>'; } }
public function indexAction() { // Seo $this->_seo['h1'] = 'Корзина'; $this->_seo['title'] = 'Корзина'; $this->_seo['keywords'] = 'Корзина'; $this->_seo['description'] = 'Корзина'; // Get cart items $cart = C::factory()->get_list_for_basket(); // Render template $this->_content = View::tpl(array('cart' => $cart, 'payment' => Config::get('order.payment'), 'delivery' => Config::get('order.delivery')), 'Cart/Index'); }
public function before() { parent::before(); $this->_template = 'Afisha'; $this->setBreadcrumbs('Афиша', 'afisha'); // Set parameters for list items by $_GET // Get count items per page $this->limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit'); // Get sort type $this->sort = 'afisha.' . (in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'id'); $this->type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'DESC'; }
/** Set les paramètre de config du Login */ protected function setParams() { $config = \Core\Config::get("userManagment"); if (empty($config)) { throw new \Core\CException("Module Login error : config not set"); } $this->dbParams = new \stdClass(); $this->dbParams->database = empty($config["database"]) ? null : $config["database"]; $this->dbParams->userTable = $config["userTable"]; $this->dbParams->roleTable = $config["roleTable"]; $this->dbParams->linkTable = $config["linkTable"]; }
private function render() { if (Config::get('error')) { $this->_template = '404'; } $this->_breadcrumbs = HTML::breadcrumbs($this->_breadcrumbs); $data = array(); foreach ($this as $key => $value) { $data[$key] = $value; } echo View::tpl($data, $this->_template); echo System::global_massage(); }