public function action_archivos() { $tipo = $_GET['tipo']; $proceso = $_GET['proceso']; $archivos = ORM::factory('aarchivos')->where('central_id', '=', $tipo)->and_where('proceso_id', '=', $proceso)->find_all(); $this->template->content = View::factory('archivero/reportes/result_archivo')->bind('archivos', $archivos); }
public static function error_messages($errors = array()) { if (empty($errors)) { return PHP_EOL; } return View::factory('common/errors')->set('errors', $errors) . PHP_EOL; }
public function before() { if ($this->auto_render) { $hostArr = explode('.', $_SERVER['HTTP_HOST']); $preDomain = $hostArr[0]; $site = ORM::factory('Site')->where('domain', '=', $preDomain)->find(); if ($site->loaded()) { $this->siteId = $site->id; $this->category = ORM::factory('Category')->getAll($site->id, Model_Category::STATUS_SHOW); $site = $site->as_array(); $site['logo'] = '/media/image/data/' . $site['logo']; $site['category'] = $this->category; $site['author'] = '简站(Simple-Site.cn) - 免费建站、微信网站、免费微信网站!'; $site['copyright'] = 'Copyright © 2015 SimpleSite. All Rights Reserved'; $site['friendLinks'] = ORM::factory('FriendLink')->getAll($site['id']); $this->theme = "themes/{$site['theme']}/"; $this->template = View::factory($this->theme . 'base'); foreach ($site as $key => $value) { View::bind_global($key, $site[$key]); } } else { echo '404'; exit; } } }
public function __toString() { $s = ''; if (Sourcemap_Form::$use_templates) { try { $s = (string) View::factory($this->_template, array('field' => $this)); } catch (Exception $e) { $s = $e->getMessage(); } } else { if ($this->_label) { $s = $this->_makeLabel(); } if ($this->errors()) { $this->add_class('error'); } $s .= $this->_makeInput(); if ($err = $this->errors()) { $s .= "\n" . '<div class="error preserve">' . $err . '</div>'; } if ($this->errors()) { $this->remove_class('error'); } $s .= "\n<div class=\"clear\"></div>\n"; } return $s; }
/** * generates HTML for apy buton * @param Model_Order $order * @return string */ public static function button(Model_Order $order) { if (Core::config('payment.paymill_private') != '' and Core::config('payment.paymill_public') != '' and Theme::get('premium') == 1 and $order->loaded()) { return View::factory('pages/paymill/button', array('order' => $order)); } return ''; }
public function action_login() { // Проверям, вдруг пользователь уже зашел if (Auth::instance()->logged_in()) { // И если это так, то отправляем его сразу на страницу администратора return $this->request->redirect('member'); } // Если же пользователь не зашел, но данные на страницу пришли, то: if ($_POST) { // Создаем переменную, отвечающую за связь с моделью данных User $user = ORM::factory('user'); // в $status помещаем результат функции login $status = Auth::instance()->login($_POST['username'], $_POST['password']); // Если логин успешен, то if ($status) { // Отправляем пользователя на его страницу $this->request->redirect('member'); } else { // Иначе ничего не получилось, пишем failed $this->template->messages['err_msg'] = 'Ошибка входа!'; } } // Грузим view логина $this->template->content = View::factory(URL::site('login')); }
/** * Update new forum */ public function action_update() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit Topic'))); $topic = new Model_Topic($this->request->param('id')); $get_all = Model_Forum::get_all(); //get all forums to build forum parents in select $forum_parents = array(); foreach ($get_all[0] as $parent) { $forum_parents[$parent['id']] = $parent['name']; } $this->template->content = View::factory('oc-panel/pages/forum/topic', array('topic' => $topic, 'forum_parents' => $forum_parents)); if ($_POST) { $topic->title = core::post('title'); $topic->id_forum = core::post('id_forum'); $topic->description = core::post('description'); if (core::post('seotitle') != $topic->seotitle) { $topic->seotitle = $topic->gen_seotitle(core::post('seotitle')); } if (core::post('status') == 'on') { $topic->status = 1; } else { $topic->status = 0; } try { $topic->save(); Alert::set(Alert::SUCCESS, __('Topic is updated.')); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); } HTTP::redirect(Route::url('oc-panel', array('controller' => 'topic', 'action' => 'index'))); } }
/** * 显示日志详细 * * @param $blog_id 日志编号 */ public function action_show($blog_id) { $model = Model::factory('blog'); $view = View::factory('pages/blog/show.php'); $view->blog_info = $model->get_blog_info($blog_id); $this->template->content = $view; }
public function action_index() { $jobs = ORM::factory('job'); $this->request->response = View::factory('rss') ->set('jobs', $jobs->order_by('created', 'DESC')->find_all()); }
public function action_seo() { if ($this->request->method() == 'POST') { $groups = $this->request->post('groups'); foreach ($groups as $group => $items) { foreach ($items as $id => $fields) { $o = ORM::factory('Seo')->where('model', '=', ucfirst($group))->where('pk', '=', $id)->find(); if (!$o->loaded()) { $o = ORM::factory('Seo'); $o->model = ucfirst($group); $o->pk = $id; } foreach ($fields as $k => $v) { $o->{$k} = $v; } $o->save(); } } } $groups = array(); foreach (Kohana::$config->load('seo') as $group => $title) { $groups[$group] = array('title' => $title, 'items' => ORM::factory(ucfirst($group))->find_all()); } $this->template->content = View::factory('control/seo', array('groups' => $groups)); }
public function action_index() { //template header $this->template->title = ''; // $this->template->meta_keywords = 'keywords'; $this->template->meta_description = Core::config('general.site_description'); //setting main view/template and render pages // swith to decide on ads_in_home $ads = new Model_Ad(); $ads->where('status', '=', Model_Ad::STATUS_PUBLISHED); switch (core::config('advertisement.ads_in_home')) { case 2: $id_ads = array_keys(Model_Visit::popular_ads()); if (count($id_ads) > 0) { $ads->where('id_ad', 'IN', $id_ads); } break; case 1: $ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc'); break; case 0: default: $ads->order_by('published', 'desc'); break; } //if ad have passed expiration time dont show if (core::config('advertisement.expire_date') > 0) { $ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()')); } $ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all(); $this->ads = $ads; $categs = Model_Category::get_category_count(); $this->template->bind('content', $content); $this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs)); }
public function render() { $view = View::factory('feed/' . $this->type . '_' . $this->action)->bind('lecture', $lecture)->bind('user', $user)->bind('span', $span)->bind('role', $role)->bind('feed_id', $feed_id)->bind('comments', $comments)->bind('url', $url); if ($this->action == 'add') { $lecture = ORM::factory('lecture', $this->respective_id); if ($this->check_deleted($lecture)) { return View::factory('feed/unavaliable')->render(); } } else { if ($this->action == 'canceled') { $lecture = Model_Lecture::get_lecture_from_event($this->respective_id); $event = ORM::factory('event', $this->respective_id); if ($this->check_deleted($lecture)) { return View::factory('feed/unavaliable')->render(); } $view->bind('event', $event); } } $user = ORM::factory('user', $this->actor_id); $span = Date::fuzzy_span($this->time); $feed_id = $this->id; $curr_user = Auth::instance()->get_user(); $role = $curr_user->role()->name; $comment = ORM::factory('feedcomment'); $comment->where('feed_id', '=', $feed_id)->order_by('date', 'DESC'); $comments = $comment->find_all(); $url = Url::site('profile/view/id/'); return $view->render(); }
public function before() { parent::before(); $this->session = Session::instance(); # Check user authentication $auth_result = true; $action_name = Request::instance()->action; if (array_key_exists($action_name, $this->auth)) { $auth_result = $this->_check_auth($action_name); } else { if (array_key_exists('*', $this->auth)) { $auth_result = $this->_check_auth('*'); } } if (!$auth_result) { if (Auth::instance()->logged_in()) { //! \todo Flash message. Request::instance()->redirect('user'); } else { Request::instance()->redirect('login'); } } // Try to pre-fetch the template. Doesn't have to succeed. try { $this->template->content = View::factory(Request::instance()->controller . '/' . Request::instance()->action); } catch (Kohana_View_Exception $e) { } $this->template->title = ucwords(Request::instance()->action); $this->template->left = null; $this->template->right = null; $this->template->footer = null; $this->template->no_back_button = true; $this->template->menu = array(); }
/** * Edit company */ public function action_edit() { $id = $this->request->param('id'); $company = Model::factory('Company'); $view = View::factory('company/edit'); switch ($this->request->method()) { default: case 'GET': // Load values if (($post = $company->load($id)) === FALSE) { throw HTTP_Exception::factory(404, 'File not found!'); } $view->set('post', $post); $view->set('referrer', $this->request->referrer()); $this->response->body($view); break; case 'POST': $post = $this->request->post(); if ($company->validate($post)) { $company->save($post, $id); Lasku::flash("Company data is updated."); $this->redirect('company/profile'); } else { $view->set('post', $post); $view->set('referrer', $post['referrer']); $view->set('errors', $company->errors()); $this->response->body($view); } break; } }
/** * 账号列表 */ public function action_list() { $total = Model::factory('Account')->countAccounts()->getArray(); $pagination = Pagination::factory($total); $accounts = Model::factory('Account')->getAccountsByLimit($pagination->offset(), $pagination->number())->getObject(); $this->_default->content = View::factory('account/list')->set('accounts', $accounts)->set('pagination', $pagination); }
public function action_index() { // display $this->template->show_logout = TRUE; $this->template->title = 'Dashboard'; $this->template->content = View::factory('dashboard/dashboard'); }
public function action_view() { $view = View::factory("contract-view"); $id = $this->request->param("id"); $view->contract = $this->contractService->getContract(array("id" => $id))->return; $this->response->body($view); }
public function action_create() { // Check if the user has a character already. if ($this->character->loaded()) { $this->request->redirect('character/create'); } $character = Jelly::factory('character'); $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('name', 'not_empty')->rule('name', 'min_length', array(3))->rule('name', 'max_length', array(20))->rule('gender', 'not_empty')->rule('race', 'not_empty')->callback('race', array($this, 'valid_race')); if ($post->check()) { try { $values = array('name' => $post['name'], 'gender' => $post['gender'], 'race' => $post['race'], 'user' => $this->user->id, 'money' => 1000, 'hp' => 100, 'max_hp' => 100, 'level' => 1, 'xp' => 0, 'energy' => 100, 'alignment' => 5000, 'zone' => 1); $character->set($values); $character->save(); $this->MG->add_history('Created the character: ' . $post['name']); $this->request->redirect('character'); } catch (Validate_Exception $e) { // Get the errors using the Validate::errors() method $this->errors = $e->array->errors('register'); } } else { $this->errors = $post->errors('character/create'); } // Get the races the user can choose from. $races = $this->getRaces(); $this->template->content = View::factory('character/create')->set('post', $post)->set('races', $races); }
public function action_index() { Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default'))); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('User Profile'))); $seoname = $this->request->param('seoname', NULL); if ($seoname !== NULL) { $user = new Model_User(); $user->where('seoname', '=', $seoname)->limit(1)->cached()->find(); if ($user->loaded()) { $this->template->title = __('User Profile') . ' - ' . $user->name; //$this->template->meta_description = $user->name;//@todo phpseo $this->template->bind('content', $content); $ads = new Model_Ad(); $ads = $ads->where('id_user', '=', $user->id_user)->where('status', '=', Model_Ad::STATUS_PUBLISHED)->order_by('created', 'desc')->cached()->find_all(); // case when user dont have any ads if ($ads->count() == 0) { $profile_ads = NULL; } $this->template->content = View::factory('pages/userprofile', array('user' => $user, 'profile_ads' => $ads)); } else { //throw 404 throw HTTP_Exception::factory(404, __('Page not found')); } } else { //throw 404 throw HTTP_Exception::factory(404, __('Page not found')); } }
public function get_response() { $view = View::factory('error/500'); $view->message = $this->getMessage(); $response = Response::factory()->status(500)->body($view->render()); return $response; }
public function after() { if ($this->template->body && is_string($this->template->body)) { $this->template->body = View::factory($this->template->body, $this->data, false); } parent::after(); }
public function action_genre() { $task = $this->request->param('task', 'edit'); $id = $this->request->param('id', NULL); $genre = $this->submit($task, $id, 'genre'); $this->request->response = View::factory('genres/edit')->set('genre', $genre)->render(); }
public function view_prepare() { $controller = $this->request->controller(); $action = $this->request->action(); View::bind_global('controller', $controller); View::bind_global('action', $action); // Load the template if (!$this->template instanceof View) { $this->template = View::factory($this->template); } $this->template->title = $GLOBALS['WEB_TITLE']; $this->template->scripts = array(); //放在头部的Javascript $this->template->scriptscoda = array(); //放在尾部的Javascript $this->template->scriptsglobe = array(); //放在尾部的全局Javascript $this->template->styles = array(); $this->add_style('reset.css'); $this->add_style('base.css'); $this->add_style('globe.css'); //$this->add_script('jquery-1.7.2.min.js','head'); $this->add_script('jquery-1.11.2.min.js', 'head'); $this->add_script('jquery-migrate-1.2.1.min.js', 'head'); $this->add_script('base.js', 'head'); $this->add_script('globe.js', 'foot'); $this->set_keywords($GLOBALS['WEB_KEYWORDS']); $this->set_description($GLOBALS['WEB_DESC']); }
public function action_dataView() { $model = ORM::factory('Prime')->find_all(); $view = View::factory('ArchiveView'); $view->arr = $model; $this->response->body($view); }
public function action_index() { $data_pages = ORM::factory('Page')->where('title_en', '=', 'contacts')->find()->as_array(); $id = $data_pages['id']; $data_contacts = ORM::factory('Setting', 1)->as_array(); if (isset($_POST['submit'])) { $data_pages = Arr::extract($_POST, array('seo_snippet', 'keywords', 'title_head')); $data_contacts = Arr::extract($_POST, array('main_adress', 'branch_adress')); try { $page = ORM::factory('Page', $id); $page->values($data_pages); $page->save(); $contacts = ORM::factory('Setting', 1); $contacts->values($data_contacts); $contacts->save(); Controller::redirect('admin/contacts'); } catch (ORM_Validation_Exception $e) { $errors = $e->errors('validation'); } } $content = View::factory('admin/contacts/v_contacts_edit'); $content->bind('errors', $errors); $content->bind('data_pages', $data_pages); $content->bind('data_contacts', $data_contacts); $this->template->page_title = 'Контакты'; $this->template->block_center = array($content); }
/** * Creates an html list of all classes sorted by category (or package if no category) * * @return string the html for the menu */ public static function menu() { $classes = Kodoc::classes(); ksort($classes); $menu = array(); $route = Route::get('docs/api'); foreach ($classes as $class) { if (Kodoc::is_transparent($class, $classes)) { continue; } $class = Kodoc_Class::factory($class); // Test if we should show this class if (!Kodoc::show_class($class)) { continue; } $link = HTML::anchor($route->uri(array('class' => $class->class->name)), $class->class->name); if (isset($class->tags['package'])) { foreach ($class->tags['package'] as $package) { if (isset($class->tags['category'])) { foreach ($class->tags['category'] as $category) { $menu[$package][$category][] = $link; } } else { $menu[$package]['Base'][] = $link; } } } else { $menu['[Unknown]']['Base'][] = $link; } } // Sort the packages ksort($menu); return View::factory('userguide/api/menu')->bind('menu', $menu); }
public static function show_error($value, $array = array()) { if (isset($array[$value])) { $view = View::factory('error'); return $view->set('text', $array[$value])->render(); } }
public function action_index() { if (!Auth::instance()->logged_in() && isset($_POST['login'])) { $user = ORM::factory('User'); $status = Auth::instance()->login($_POST['username'], $_POST['password'], true); if ($status) { HTTP::redirect('/'); } } if (Auth::instance()->logged_in() && isset($_POST['logout'])) { Auth::instance()->logout(); } if (!Auth::instance()->logged_in()) { Guestid::factory()->get_id(); } $templateData['title'] = 'Главная.'; $templateData['description'] = ''; $template = View::factory('template')->set('templateData', $templateData); $content = View::factory("catalog"); $content->get = $_GET; $content->shopArr = Model::factory('Shop')->getShop(); $root_page = "index"; $template->root_page = $root_page; $template->content = $content; $this->response->body($template); }
public function action_process() { $this->auto_render = FALSE; $this->template = View::factory('js'); //finished? if ($this->amount_ads_import() === 0) { /*Alert::set(Alert::SUCCESS,__('All ads are processed! Congrats!')); $this->redirect(Route::url('oc-panel',array('controller'=>'import','action'=>'index')));*/ $this->template->content = json_encode('OK'); } else { //how many ads we process in each request? pass get/post $limit_process = Core::request('limit', 5); $ads_import = DB::select()->from('adsimport')->where('processed', '=', '0')->limit($limit_process)->as_object()->execute(); $i = 0; foreach ($ads_import as $adi) { if ($this->create_ad($adi) === TRUE) { $i++; } } $todo = $this->amount_ads_import(); $done = $this->amount_ads_import(1); $total = $todo + $done; $this->template->content = json_encode(round(100 - $todo * 100 / $total)); //$this->redirect(Route::url('oc-panel',array('controller'=>'import','action'=>'process'))); } }
/** * Initialize properties before running the controller methods (actions), * so they are available to our action. */ public function before() { // Run anything that need ot run before this. parent::before(); if (!Auth::instance()->logged_in()) { if ($this->request->controller != 'auth') { // If we want to force people to log in, // we can uncomment this line // TODO -- send some message saying (you must login!) //$this->request->redirect('index.php/auth/login'); } } if ($this->auto_render) { // Initialize empty values $this->template->title = 'Ptododactyl Rulez!'; $this->template->meta_keywords = ''; $this->template->meta_description = ''; $this->template->meta_copywrite = ''; $this->template->header = View::factory('includes/header'); $this->template->content = ''; $this->template->footer = View::factory('includes/footer'); $this->template->styles = array(); $this->template->scripts = array(); } }