Beispiel #1
0
 static function show($msg, $title = '操作失败', $cacheId = 'null', $cacheTime = -1)
 {
     $error = new view();
     $error->template_dir = _FFPHP_ . 'extend';
     $error->assign('title', $title);
     $error->assign('msg', $msg);
     $error->display('template/error');
     exit;
 }
Beispiel #2
0
 public function edit()
 {
     // Get URI vars
     $subjectID = (int) uri::segment(6);
     // Get subject
     $subject = array();
     if ($subjectID && !($subject = $this->reports_subjects_model->getSubject($subjectID, false))) {
         view::setError(__('no_subject', 'reports_subjects'));
         router::redirect('cp/content/reports/subjects');
     }
     // Assign vars
     view::assign(array('subjectID' => $subjectID, 'subject' => $subject));
     // Process form values
     if (input::post('do_save_subject')) {
         $this->_saveSubject($subjectID);
     }
     // Set title
     view::setTitle($subjectID ? __('subject_edit', 'reports_subjects') : __('subject_new', 'reports_subjects'));
     // Set trail
     view::setTrail('cp/content/reports/subjects/edit/' . ($subjectID ? $subjectID : ''), $subjectID ? __('subject_edit', 'reports_subjects') . ' - ' . text_helper::entities($subject['name']) : __('subject_new', 'reports_subjects'));
     // Set actions
     if (count(config::item('languages', 'core', 'keywords')) > 1) {
         view::setAction('translate', '');
     }
     // Load view
     view::load('cp/content/reports/subjects/edit');
 }
Beispiel #3
0
 public static function getPictures($params = array())
 {
     if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) {
         return '';
     }
     loader::model('pictures/pictures');
     $template = isset($params['template']) ? $params['template'] : 'pictures/helpers/pictures';
     $user = isset($params['user']) && $params['user'] ? $params['user'] : array();
     $userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0);
     $params['albums'] = true;
     if ($userID) {
         $params['join_columns'][] = '`p`.`user_id`=' . $userID;
     }
     if (!$userID || $userID != session::item('user_id')) {
         if ($userID) {
             $params['privacy'] = $userID;
         } else {
             $params['join_columns'][] = '`a`.`public`=1';
             $params['join_columns'][] = '`u`.`verified`=1';
             $params['join_columns'][] = '`u`.`active`=1';
             $params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')';
             $params['join_columns'][] = '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')';
         }
     }
     $params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $pictures = codebreeder::instance()->pictures_model->getPictures('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
     view::assign(array('pictures' => $pictures, 'user' => $user, 'params' => $params), '', $template);
     return view::load($template, array(), 1);
 }
Beispiel #4
0
 public function edit()
 {
     // Get URI vars
     $groupID = (int) uri::segment(6);
     // Get group
     $group = array();
     if ($groupID && !($group = $this->banners_groups_model->getGroup($groupID))) {
         view::setError(__('no_group', 'banners'));
         router::redirect('cp/content/banners/groups');
     }
     // Assign vars
     view::assign(array('groupID' => $groupID, 'group' => $group));
     // Process form values
     if (input::post('do_save_group')) {
         $this->_saveGroup($groupID);
     }
     // Set title
     view::setTitle($groupID ? __('group_edit', 'banners') : __('group_new', 'banners'));
     // Set trail
     view::setTrail('cp/content/banners/groups/edit/' . ($groupID ? $groupID : ''), $groupID ? __('group_edit', 'banners') . ' - ' . text_helper::entities($group['name']) : __('group_new', 'banners'));
     // Assign actions
     if ($groupID) {
         view::setAction('cp/content/banners/browse/' . $groupID, __('banners', 'banners'), array('class' => 'icon-text icon-banners'));
     }
     // Load view
     view::load('cp/content/banners/groups/edit');
 }
Beispiel #5
0
 public function edit()
 {
     // Get URI vars
     $templateID = (int) uri::segment(6);
     // Get template
     $template = array();
     if ($templateID && !($template = $this->newsletters_templates_model->getTemplate($templateID, false))) {
         view::setError(__('no_template', 'newsletters_templates'));
         router::redirect('cp/content/newsletters/templates');
     }
     // Assign vars
     view::assign(array('templateID' => $templateID, 'template' => $template));
     // Process form values
     if (input::post('do_save_template')) {
         $this->_saveTemplate($templateID);
     }
     // Set title
     view::setTitle($templateID ? __('template_edit', 'newsletters_templates') : __('template_new', 'newsletters_templates'));
     // Set trail
     view::setTrail('cp/content/newsletters/templates/edit/' . ($templateID ? $templateID : ''), $templateID ? __('template_edit', 'newsletters_templates') . ' - ' . text_helper::entities($template['name']) : __('template_new', 'newsletters_templates'));
     // Load ckeditor
     view::includeJavascript('externals/ckeditor/ckeditor.js');
     // Load view
     view::load('cp/content/newsletters/templates/edit');
 }
Beispiel #6
0
 public function searchData($resource, $fields, $columns, $values, $params = array())
 {
     // Parse filter values
     if ($fields) {
         list($_columns, $items, $_values) = $this->fields_model->parseSearch($resource, $fields, $params);
         // Merge values
         $columns = $columns && is_array($columns) ? array_merge($_columns, $columns) : $_columns;
         $values = $values && is_array($values) ? array_merge($_values, $values) : $_values;
     } else {
         $items = $columns['items'];
         $columns = $columns['columns'];
     }
     // Assign vars
     view::assign(array('values' => $values));
     // Do we have any values?
     if ($values) {
         // Count data
         $total = $this->counters_model->countData($resource, 0, 0, $columns, $items, $params, 0);
         if ($total) {
             // Save search
             $searchID = $this->search_model->saveSearch(array('columns' => $columns, 'items' => $items), $values, $total);
             // Return search ID
             return $searchID;
         } else {
             return 'no_results';
         }
     } else {
         return 'no_terms';
     }
 }
Beispiel #7
0
 public function payment()
 {
     // Get URI vars
     $planID = (int) uri::segment(4);
     // Get plan
     if (!$planID || !($plan = $this->plans_model->getPlan($planID)) || !$plan['active']) {
         view::setError(__('no_plan', 'billing_plans'));
         router::redirect('billing/plans');
     }
     // Get gateways
     if (!($gateways = $this->gateways_model->getGateways())) {
         view::setError(__('no_gateways_user', 'billing_gateways'));
         router::redirect('billing/plans');
     }
     // Product
     $plan['product_id'] = $planID;
     $plan['type'] = 'plans';
     // Assign vars
     view::assign(array('product' => $plan, 'gateways' => $gateways, 'location' => 'billing/plans/payment/' . $planID));
     // Set title
     view::setTitle(__('payment', 'billing_transactions'));
     // Set trail
     view::setTrail('billing/plans', __('plans', 'billing_plans'));
     // Load view
     view::load('billing/payment');
 }
Beispiel #8
0
 /**
  * md文件解析
  */
 public function md()
 {
     $file = $this->get('file');
     $p = $this->get('p');
     // 目录
     $directory = MD_FILE_ROOT_PATH . $p . '/';
     // 如果不存在自动创建
     filesystem::mkdir($directory);
     // 遍历文件夹所有内容
     $path = array();
     $dir = filesystem::ls($directory);
     usort($dir, 'compare');
     foreach ($dir as $d) {
         $path[] = trim($d);
     }
     //  解析mk文件
     $file = $directory . $file;
     if (is_file($file)) {
         $md = new markdown($file);
         $html = $md->parse();
         view::assign('html', $html);
     }
     view::assign('path', $path);
     view::assign('p', $p);
     view::assign('file', str_replace($directory, '', $file));
 }
Beispiel #9
0
 public function payment()
 {
     // Get URI vars
     $packageID = (int) uri::segment(4);
     // Get package
     if (!$packageID || !($package = $this->credits_model->getPackage($packageID)) || !$package['active']) {
         view::setError(__('no_package', 'billing_credits'));
         router::redirect('billing/credits');
     }
     // Get gateways
     if (!($gateways = $this->gateways_model->getGateways())) {
         view::setError(__('no_gateways_user', 'billing_gateways'));
         router::redirect('billing/credits');
     }
     // Product
     $package['product_id'] = $packageID;
     $package['name'] = __('credits_info', 'billing_credits', array('%s' => $package['credits']));
     $package['type'] = 'credits';
     // Assign vars
     view::assign(array('product' => $package, 'gateways' => $gateways, 'location' => 'billing/credits/payment/' . $packageID));
     // Set title
     view::setTitle(__('payment', 'billing_transactions'));
     // Set trail
     view::setTrail('billing/credits', __('credits', 'billing_credits'));
     // Load view
     view::load('billing/payment');
 }
Beispiel #10
0
 public function edit()
 {
     // Get URI vars
     $templateID = (int) uri::segment(6);
     // Get template
     $template = array();
     if ($templateID && !($template = $this->messages_templates_model->getTemplate($templateID, false))) {
         view::setError(__('no_template', 'messages_templates'));
         router::redirect('cp/plugins/messages/templates');
     }
     // Assign vars
     view::assign(array('templateID' => $templateID, 'template' => $template));
     // Process form values
     if (input::post('do_save_template')) {
         $this->_saveTemplate($templateID);
     }
     // Set title
     view::setTitle($templateID ? __('template_edit', 'messages_templates') : __('template_new', 'messages_templates'));
     // Set trail
     view::setTrail('cp/plugins/messages/templates/edit/' . ($templateID ? $templateID : ''), $templateID ? __('template_edit', 'messages_templates') . ' - ' . text_helper::entities($template['name']) : __('template_new', 'messages_templates'));
     // Set actions
     if (count(config::item('languages', 'core', 'keywords')) > 1) {
         view::setAction('translate', '');
     }
     // Load view
     view::load('cp/plugins/messages/templates/edit');
 }
Beispiel #11
0
 public function settings()
 {
     // Get URI vars
     $keyword = uri::segment(5);
     // Get service
     if (!$keyword || !($service = $this->users_authentication_model->getService($keyword))) {
         view::setError(__('no_service', 'users_authentication'));
         router::redirect('cp/users/authentication');
     }
     // Get manifest
     $manifest = $this->users_authentication_model->getManifest($keyword);
     // Is demo mode enabled?
     if (input::demo(0)) {
         foreach ($service['settings'] as $k => $v) {
             if ($v) {
                 $service['settings'][$k] = 'hidden in this demo';
             }
         }
     }
     // Assign vars
     view::assign(array('manifest' => $manifest, 'service' => $service));
     // Process form values
     if (input::post('do_save_settings')) {
         $this->_saveSettings($keyword, $manifest, $service);
     }
     // Set title
     view::setTitle(__('settings', 'system'));
     // Set trail
     view::setTrail('cp/users/authentication/settings/' . $keyword, __('settings', 'system') . ' - ' . text_helper::entities($service['name']));
     // Load view
     view::load('cp/users/authentication/settings');
 }
Beispiel #12
0
 public static function getTimeline($user = array(), $privacy = 2, $template = 'timeline/helpers/timeline')
 {
     loader::model('timeline/timeline');
     // Get actions
     $actions = codebreeder::instance()->timeline_model->getActions($user ? $user['user_id'] : 0, true, 0, config::item('actions_per_page', 'timeline'));
     $ratings = array();
     // Do we have actions and are we logged in?
     if ($actions && users_helper::isLoggedin()) {
         foreach ($actions as $action) {
             if ($action['rating']) {
                 $ratings[$action['relative_resource']][] = $action['item_id'];
             } else {
                 $ratings['timeline'][] = $action['action_id'];
             }
         }
         // Load votes and like models
         loader::model('comments/votes');
         loader::model('comments/likes');
         // Get likes and votes
         $likes = codebreeder::instance()->likes_model->getMultiLikes($ratings);
         $votes = codebreeder::instance()->votes_model->getMultiVotes($ratings);
         $ratings = $likes + $votes;
     }
     // Can we post messages?
     $post = session::permission('messages_post', 'timeline') && codebreeder::instance()->users_model->getPrivacyAccess($user['user_id'], $privacy, false) ? true : false;
     view::assign(array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), '', $template);
     // Update comments pagination
     config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
     return view::load($template, array(), 1);
 }
Beispiel #13
0
 /**
  * ip地址查询
  */
 public function ip()
 {
     $ip = $this->post('ip');
     if (!$ip) {
         return;
     }
     $result = $ip_address = array();
     // tool.lu
     $toollu = curl::post('http://tool.lu/netcard/ajax.html', array('ip' => $ip));
     $toollu = json_decode($toollu, true);
     $result['tool.lu'] = trim($toollu['text'][2]);
     $result['纯真数据库'] = trim($toollu['text'][1]);
     // 站长工具
     $chinaz = curl::post('http://ip.chinaz.com', array('ip' => $ip));
     $chinaz = trim(preg_replace('/<.+?>/', '', $chinaz));
     $chinaz = explode('查询结果', $chinaz);
     if ($chinaz) {
         unset($chinaz[0]);
         $size = intval(count($chinaz));
         $chinaz[$size] = trim(substr($chinaz[$size], 0, strpos($chinaz[$size], 'document')));
         $address = '';
         foreach ($chinaz as $c) {
             $c = explode('==>>', $c);
             $ip_address_ = explode(':', trim($c[0]));
             $ip_address[] = trim($ip_address_[1]);
             $tmp_arr = explode("\r\n", trim($c[2]));
             $address .= trim($tmp_arr[0]) . '  ';
         }
         $result['站长工具'] = trim($address);
     }
     // 淘宝
     if ($ip_address) {
         $taobao = curl::get('http://ip.taobao.com/service/getIpInfo.php', array('ip' => $ip_address[0]));
         $taobao = json_decode($taobao, true);
         if (intval($taobao['code']) === 0) {
             $taobao = $taobao['data'];
             $result['淘宝'] = $taobao['country'] . '|' . $taobao['area'] . '|' . $taobao['region'] . '|' . $taobao['city'] . '|' . $taobao['isp'];
         }
     }
     // ipip.net
     if ($ip_address) {
         $ipip = curl::get('http://freeapi.ipip.net/' . $ip_address[0]);
         $ipip = json_decode($ipip, true);
         if (is_array($ipip)) {
             $ipipstr = '';
             foreach ($ipip as $str) {
                 $str = trim($str);
                 if (empty($str)) {
                     continue;
                 }
                 $ipipstr .= $str . ' ';
             }
             $result['ipip.net'] = $ipipstr;
         }
     }
     view::assign('input', $ip);
     view::assign('ip', $ip_address);
     view::assign('result', $result);
 }
 /**
  * 模板变量赋值
  * @access protected
  * @param mixed $name 要显示的模板变量
  * @param mixed $value 变量的值
  * @return Action
  */
 protected function assign($name, $value = '')
 {
     if ($this->view == null) {
         $this->view = new \Think\View();
     }
     $this->view->assign($name, $value);
     return $this;
 }
 public function indexAction($args)
 {
     $v = new view("dashboard");
     $v->assign("mesargs", $args);
     if (!isset($_SESSION['role']) || $_SESSION['role'] != "admin") {
         $this->redirect("index", "");
     }
 }
Beispiel #16
0
 public function browse($resource = '', $itemID = 0, $total = false, $page = false, $post = true, $info = true, $static = false)
 {
     // Get vars
     if (input::isAjaxRequest() && !$static) {
         $resource = input::post_get('resource');
         $itemID = (int) input::post_get('item_id');
         $post = (bool) input::post_get('post');
         $info = (bool) input::post_get('info');
     }
     $split = (int) input::post_get('split') && (int) input::post_get('split') <= config::item('comments_per_page', 'comments') ? (int) input::post_get('split') : config::item('comments_per_page', 'comments');
     // Get resource ID
     $resourceID = config::item('resources', 'core', $resource, 'resource_id');
     if (!$resourceID || !$itemID) {
         return false;
     }
     // Do we have the number of comments?
     if ($total === false) {
         // Count comments
         $total = $this->comments_model->countComments(array(), array(), array('resource' => $resource, 'item_id' => $itemID));
     }
     // Post comment
     if (input::post('do_save_comment') && session::permission('comments_post', 'comments')) {
         if ($this->_saveComment($resource, $itemID)) {
             $total++;
         }
     } elseif (input::post('delete') && session::permission('comments_delete', 'comments')) {
         if ($this->_deleteComment($resource, $itemID, (int) input::post('delete'))) {
             $total--;
         }
     }
     // Current page
     $page = $page ? $page : (int) input::post_get('page', 1);
     $page = $page > 0 ? $page : 1;
     // Limit
     $limit = ($page - 1) * $split . ', ' . $split;
     // Get comments
     $comments = $this->comments_model->getComments($resource, $itemID, array(), '`c`.`post_date` desc', $limit);
     // If no comments were found, try to fetch from from the previous page
     if (!$comments && $page > 1) {
         $page--;
         // Limit
         $from = ($page - 1) * $split;
         $limit = $from . ', ' . $split;
         $comments = $this->comments_model->getComments($resource, $itemID, array(), '`c`.`post_date` desc', $limit);
     }
     // Pagination config
     $config = array('base_url' => 'comments/browse?', 'total_items' => $total, 'items_per_page' => $split, 'current_page' => $page, 'uri_segment' => 'page', 'link_attr' => array('onclick' => "runAjax(this.href,{'resource':'" . $resource . "','item_id':" . $itemID . ",'split':" . $split . ",'post':" . ($post ? 1 : 0) . ",'info':" . ($info ? 1 : 0) . "},'replaceContent','comments-container-" . $resource . "-" . $itemID . "','pagination-" . $resource . "-" . $itemID . "');return false;"));
     $pagination = loader::library('pagination', $config, null);
     // Assign vars
     view::assign(array('resource' => $resource, 'itemID' => $itemID, 'comments' => $comments, 'pagination' => $pagination, 'split' => $split, 'post' => users_helper::isLoggedin() && $post ? true : false, 'info' => $info), '', 'comments/index');
     if (input::isAjaxRequest() && !$static) {
         $output = view::load('comments/index', array(), true);
         view::ajaxResponse($output);
     } else {
         view::load('comments/index');
     }
 }
 public function indexAction($args)
 {
     if ($this->getActiveContest() == FALSE) {
         $v = new view("nocontest");
         $v->assign("mesargs", $args);
     } else {
         $v = new view("index");
         $v->assign("mesargs", $args);
     }
 }
Beispiel #18
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     $cookie = cookie::get(COOKIE_KEY);
     if (!$cookie) {
         redirect('./');
         return;
     }
     view::assign('setting', madmin::get_setting());
     view::assign('now', time());
 }
Beispiel #19
0
 /**
  * 字节数转换
  */
 public function bytes()
 {
     $bytes = $this->post_ufloat('bytes');
     if ($bytes <= 0) {
         return;
     }
     $result = filesystem::bytes($bytes);
     view::assign('result', $result);
     view::assign('input', $bytes);
 }
Beispiel #20
0
 /**
  * 初始化视图
  * @access private
  * @return void
  */
 private function initView()
 {
     //实例化视图类
     if (!$this->view) {
         $this->view = Think::instance('View');
     }
     // 模板变量传值
     if ($this->tVar) {
         $this->view->assign($this->tVar);
     }
 }
Beispiel #21
0
 public static function getNews($params = array())
 {
     loader::model('news/news');
     $template = isset($params['template']) ? $params['template'] : 'news/helpers/news';
     $params['join_columns'][] = '`n`.`active`=1';
     $params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $entries = codebreeder::instance()->news_model->getEntries('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
     view::assign(array('entries' => $entries, 'params' => $params), '', $template);
     return view::load($template, array(), 1);
 }
 /**
  * Initialize the view
  * @access private
  * @return void
  */
 private function initView()
 {
     //View class is instantiated
     if (!$this->view) {
         $this->view = Sen::instance('View');
     }
     // Template variables by value
     if ($this->tVar) {
         $this->view->assign($this->tVar);
     }
 }
Beispiel #23
0
 public function index()
 {
     // Get license details
     if (!($license = $this->license_model->getLicense())) {
         view::setError(__('no_license', 'system_license'));
         router::redirect('cp/help/license/change');
     }
     // Assign vars
     view::assign(array('license' => $license));
     // Set title
     view::setTitle(__('help_license', 'system_navigation'));
     // Load view
     view::load('cp/help/license/view');
 }
Beispiel #24
0
 public function submit()
 {
     // Does user have permission to submit reports?
     if (!session::permission('reports_post', 'reports')) {
         view::setError(__('no_action', 'system'));
         view::load('system/elements/blank', array('autoclose' => true));
         return false;
     }
     $resource = uri::segment(3);
     $itemID = uri::segment(4);
     if (!$resource || !($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !config::item('resources', 'core', $resource, 'report')) {
         view::setError(__('resource_invalid', 'system'));
         view::load('system/elements/blank', array('autoclose' => true));
         return false;
     }
     if (!$itemID || !is_numeric($itemID) || $itemID < 0) {
         view::setError(__('item_invalid', 'reports'));
         view::load('system/elements/blank', array('autoclose' => true));
         return false;
     }
     // Does this item exist?
     if (!($userID = $this->reports_model->getUserID($resource, $itemID))) {
         view::setError(__('item_invalid', 'reports'));
         view::load('system/elements/blank', array('autoclose' => true));
         return false;
     }
     // Did we report this already?
     if ($this->reports_model->isReported($resourceID, $itemID)) {
         view::setError(__('report_exists', 'reports'));
         view::load('system/elements/blank', array('autoclose' => true));
         return false;
     }
     // Get subjects
     $subjects = array();
     $data = $this->reports_subjects_model->getSubjects(false, true);
     foreach ($data as $subject) {
         $subjects[$subject['subject_id']] = $subject['name'];
     }
     $subjects = $subjects ? array('' => __('select', 'system')) + $subjects : $subjects;
     // Assign vars
     view::assign(array('subjects' => $subjects));
     // Process form values
     if (input::post('do_submit_report')) {
         $this->_submitReport($resource, $resourceID, $userID, $itemID, $subjects);
     }
     // Set title
     view::setTitle(__('report_submit', 'reports'));
     // Load view
     view::load('report/index');
 }
Beispiel #25
0
 protected function parseQuerystring($pagination = 15, $max = 0)
 {
     $qstring = array();
     // Set max page
     $maxpage = $max ? ceil($max / $pagination) : 0;
     // Get current page
     $qstring['page'] = (int) input::get('page', 1);
     $qstring['page'] = $qstring['page'] > 0 ? !$maxpage || $qstring['page'] <= $maxpage ? $qstring['page'] : $maxpage : 1;
     // Set limit
     $from = ($qstring['page'] - 1) * $pagination;
     $qstring['limit'] = (!$max || $from <= $max ? $from : $max) . ', ' . (!$max || $max >= $pagination ? $pagination : $max);
     // Assign vars
     view::assign(array('qstring' => $qstring));
     return $qstring;
 }
Beispiel #26
0
 /**
  * 时间戳转换
  */
 public function timestamp()
 {
     $timestamp = $this->post_int('timestamp');
     $date = $this->post('date');
     if (!$timestamp && !$date) {
         return;
     }
     if ($timestamp) {
         view::assign('timestamp_input', $timestamp);
         view::assign('timestamp_result', date('Y-m-d H:i:s', $timestamp));
     }
     if ($date) {
         view::assign('date_input', $date);
         view::assign('date_result', strtotime($date));
     }
 }
Beispiel #27
0
 /**
  * 第二步
  */
 public function step2()
 {
     $host = $this->post('host');
     $port = $this->post_uint('port');
     $user = $this->post('user');
     $pass = $this->post('pass');
     $pre = $this->post('pre');
     $db = $this->post('db');
     if (!$host || !$port || !$user || !$pass || !$db) {
         redirect('./');
     }
     view::assign('host', $host);
     view::assign('port', $port);
     view::assign('user', $user);
     view::assign('pass', $pass);
     view::assign('pre', $pre);
     view::assign('db', $db);
 }
Beispiel #28
0
 public function view()
 {
     // Get URI vars
     $listID = uri::segment(6);
     // Get list
     if (!$listID || !($list = $this->lists_model->getList($listID))) {
         router::redirect('cp/system/config/system');
     }
     // Did we submit the form?
     if (input::post('action') == 'reorder' && input::post('ids')) {
         $this->_reorderItems();
     }
     // Get items
     if (!($items = $this->lists_model->getItems($listID))) {
         router::redirect('cp/system/config/system');
     }
     // Create table grid
     $grid = array('uri' => 'cp/system/templates/navigation', 'keyword' => 'templates', 'header' => array('name' => array('html' => __('name', 'system'), 'class' => 'name'), 'active' => array('html' => __('active', 'system'), 'class' => 'status')), 'content' => array());
     // Create grid content
     foreach ($items as $item) {
         $grid['content'][] = array('name' => array('html' => $item['name']), 'status' => array('html' => html_helper::anchor('cp/system/templates/navigation/togglestatus/' . $item['item_id'], $item['active'] ? __('yes', 'system') : __('no', 'system'), array('class' => $item['active'] ? 'label success small' : 'label important small'))));
     }
     // Filter hooks
     hook::filter('cp/system/templates/navigation/browse/grid', $grid);
     // Assign vars
     view::assign(array('grid' => $grid, 'items' => $items, 'listID' => $listID));
     // Set title
     view::setTitle(__('system_templates_navigation_manage', 'system_navigation'));
     // Set trail
     view::setTrail('cp/system/templates/navigation/view/' . $listID, $list['name']);
     // Set actions
     view::setAction('#', __('done', 'system'), array('class' => 'icon-text icon-system-done', 'onclick' => 'saveSortable();return false;', 'id' => 'actions_link_save'));
     view::setAction('#', __('cancel', 'system'), array('class' => 'icon-text icon-system-cancel', 'onclick' => 'cancelSortable();return false;', 'id' => 'actions_link_cancel'));
     view::setAction('#', __('reorder', 'system'), array('class' => 'icon-text icon-system-sort', 'onclick' => 'switchSortable();return false;', 'id' => 'actions_link_reorder'));
     // Include sortable vendor files
     view::includeJavascript('externals/html5sortable/html5sortable.js');
     view::includeStylesheet('externals/html5sortable/style.css');
     // Load view
     if (input::isAjaxRequest()) {
         view::load('cp/system/templates/navigation/items/browse_' . (input::post('view') == 'list' ? 'list' : 'grid'));
     } else {
         view::load('cp/system/templates/navigation/items/browse');
     }
 }
Beispiel #29
0
 public function edit()
 {
     // Get URI vars
     $typeID = (int) uri::segment(5);
     // Get type
     $type = array();
     if ($typeID && !($type = $this->users_types_model->getType($typeID, false))) {
         view::setError(__('no_type', 'users_types'));
         router::redirect('cp/users/types');
     }
     $fields = array();
     // Do we have an existing type?
     if ($typeID) {
         // Get text fields
         $fields = array('' => __('none', 'system'));
         foreach ($this->fields_model->getFields('users', $typeID) as $field) {
             if ($field['type'] == 'text') {
                 $fields[$field['keyword']] = $field['name'];
             }
         }
     }
     // Assign vars
     view::assign(array('typeID' => $typeID, 'type' => $type, 'fields' => $fields));
     // Process form values
     if (input::post('do_save_type')) {
         $this->_saveType($typeID, $type, $fields);
     }
     // Set title
     view::setTitle($typeID ? __('type_edit', 'users_types') : __('type_new', 'users_types'));
     // Set trail
     view::setTrail('cp/users/types/edit/' . ($typeID ? $typeID : ''), $typeID ? __('type_edit', 'users_types') . ' - ' . text_helper::entities($type['name']) : __('type_new', 'users_types'));
     // Set trail
     if ($typeID) {
         // Assign actions
         view::setAction('cp/system/fields/users/browse/' . $typeID, __('profile_questions', 'users_types'), array('class' => 'icon-text icon-system-fields'));
     }
     if (count(config::item('languages', 'core', 'keywords')) > 1) {
         view::setAction('translate', '');
     }
     // Load view
     view::load('cp/users/types/edit');
 }
Beispiel #30
0
 public function editComment()
 {
     $manageCommentsModel = new ManageCommentsModel();
     if (!isset($_GET['id']) && !isset($_GET['meme_id'])) {
         $id = intval($_POST['id']);
         $meme_id = intval($_POST['meme_id']);
         $model['id'] = $id;
         $model['content'] = isset($_POST['content']) ? $_POST['content'] : '';
         $manageCommentsModel->UpdateItem($model);
         header('location: ManageComments.php?action=listComments&meme_id=' . $meme_id);
     }
     $id = intval($_GET['id']);
     $meme_id = intval($_GET['meme_id']);
     $model = $manageCommentsModel->GetItemById($id);
     $view = new view('manage_comments/editComment');
     $view->assign('model', $model);
     $template = new View('common/administration');
     $include = str_replace('<!--[[content]]-->', $view->output(), $template->output());
     echo $include;
 }