当前位置: 首页>>代码示例>>PHP>>正文


PHP input::isCP方法代码示例

本文整理汇总了PHP中input::isCP方法的典型用法代码示例。如果您正苦于以下问题:PHP input::isCP方法的具体用法?PHP input::isCP怎么用?PHP input::isCP使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在input的用法示例。


在下文中一共展示了input::isCP方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     parent::__construct();
     $authID = session::item('auth_id');
     $userID = session::item('user_id');
     $ipaddress = substr(input::ipaddress(), 0, 15);
     $useragent = substr(input::useragent(), 0, 255);
     $user = array();
     if ($authID && ($user = $this->getSession($authID, $userID, $ipaddress, $useragent))) {
         if ($user['active_date'] < date_helper::now() - 60 * $this->timeout) {
             $this->saveSession($authID, $userID, $ipaddress, $useragent);
             if (isset($user['user_id']) && $user['user_id']) {
                 $this->saveLastvisit($user['user_id']);
             }
         }
     } else {
         $cookie = cookie::item('sessdata');
         $cookie = $cookie ? @json_decode($cookie, true) : array();
         if ($cookie && is_array($cookie)) {
             $userID = isset($cookie['user_id']) ? $cookie['user_id'] : '';
             $email = isset($cookie['email']) ? $cookie['email'] : '';
             $passhash = isset($cookie['passhash']) ? $cookie['passhash'] : '';
             if ($userID && is_numeric($userID) && $userID > 0) {
                 if ($user = $this->getUser($userID, false, false)) {
                     $newPasshash = $this->generatePasshash($email, $user['password']);
                     if ($user['active'] && $user['verified'] && strcmp($email, $user['email']) == 0 && strcmp($passhash, $newPasshash) == 0) {
                         $authID = $this->saveSession(0, $user['user_id'], $ipaddress, $useragent);
                         $this->saveLastvisit($user['user_id']);
                     } else {
                         $user = array();
                     }
                 }
             }
         }
     }
     if (!$user || !isset($user['user_id']) || !$user['user_id'] || !$this->createUserSession($user)) {
         $userID = 0;
         if (!$user) {
             $authID = $this->saveSession(0, $userID, $ipaddress, $useragent);
         }
         $this->createGuestSession();
     }
     session::set('auth_id', $authID);
     session::set('user_id', $userID);
     // Is the site offline?
     if (!input::isCP() && !config::item('site_online', 'system') && !session::permission('site_access_offline', 'system') && uri::getURI() != 'site/offline' && uri::segment(1) != 'load') {
         router::redirect('site/offline');
     } elseif (input::isCP() && !session::permission('site_access_cp', 'system') && (uri::getURI() != 'cp' && uri::getURI() != 'cp/users/login' && uri::getURI() != 'cp/users/login/license')) {
         router::redirect('cp/users/login');
     }
     if (!input::isCP() && $this->isLoggedin() && session::permission('site_access_cp', 'system') && uri::segment(1) != 'load' && input::demo(0, '', session::item('user_id'))) {
         $this->logout();
         view::setInfo('For the purposes of this demo you may not use front end of the site under the administrator account. As such we have now logged you out.<br/>Feel free ' . html_helper::anchor('users/signup', 'register on the site') . ' to test user end functionality or ' . html_helper::anchor('users/login', 'login') . ' using your existing account details if you have one already.');
         router::redirect();
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:56,代码来源:session.php

示例2: anchor

 public static function anchor($user, $attr = array())
 {
     if (input::isCP()) {
         $user['slug'] = 'cp/users/edit/' . $user['user_id'];
     }
     if (!input::isCP() && ($user['group_id'] == config::item('group_cancelled_id', 'users') || !$user['verified'] || !$user['active'])) {
         $anchor = $user['name'] . ' (' . __('account_inactive', 'users') . ')';
     } else {
         $attr = $attr ? array_merge($attr, array('class' => 'username')) : array('class' => 'username');
         $anchor = html_helper::anchor($user['slug'], $user['name'], $attr);
     }
     return $anchor;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:13,代码来源:users.php

示例3: usersSettingsAccountOptions

 public function usersSettingsAccountOptions($settings, $user = array())
 {
     if (input::isCP()) {
         if (uri::segment(3) == 'edit') {
             loader::helper('array');
             $expiration = array('name' => __('expire_date', 'users_account'), 'keyword' => 'expire_date', 'type' => 'date', 'value' => $user ? $user['expire_date'] : 0, 'rules' => array('valid_date'), 'select' => true);
             $credits = array('name' => __('credits_current', 'users_account'), 'keyword' => 'total_credits', 'type' => 'number', 'value' => $user ? $user['total_credits'] : 0, 'rules' => array('required' => 1, 'min_value' => 0));
             $settings = array_helper::spliceArray($settings, 'group_id', $credits, 'total_credits');
             $settings = array_helper::spliceArray($settings, 'group_id', $expiration, 'expire_date');
         }
     } else {
         if (config::item('subscriptions_active', 'billing')) {
             $settings['subscription'] = array('name' => __('plan_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => config::item('usergroups', 'core', session::item('group_id')) . (session::item('expire_date') ? ' (' . __('expire_date', 'users_account') . ': ' . date_helper::formatDate(session::item('expire_date'), 'date') . ')' : '') . (session::permission('plans_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/plans', __('plan_change', 'users_account')) : ''));
         }
         if (config::item('credits_active', 'billing')) {
             $settings['credits'] = array('name' => __('credits_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => session::item('total_credits') . (session::permission('credits_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/credits', __('credits_purchase', 'users_account')) : ''));
         }
     }
     return $settings;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:20,代码来源:billing.php

示例4: getFields

 public function getFields($plugin, $categoryID = 0, $type = 'view', $config = '', $search = false)
 {
     if (!($fields = $this->cache->item('db_fields_' . $plugin . '_' . session::item('language') . '_' . $categoryID . '_' . $type . '_' . $config . '_' . ($search ? 1 : 0))) && !is_array($fields)) {
         $fields = $fieldIDs = array();
         // Get fields
         $qfields = $this->db->query("SELECT * FROM `:prefix:core_fields` WHERE `plugin`=? AND `category_id`=? ORDER BY `order_id` ASC", array($plugin, $categoryID))->result();
         foreach ($qfields as $field) {
             // Set index
             $index = $field['field_id'];
             // Decode configuration array
             $field['config'] = $field['config'] ? @json_decode($field['config'], true) : array();
             if (!is_array($field['config'])) {
                 $field['config'] = array();
             }
             // Is configuration item present?
             if ($config == '' || $config == 'all' || isset($field['config'][$config]) && $field['config'][$config]) {
                 $fields[$index] = array();
                 $fields[$index]['keyword'] = $field['keyword'];
                 $fields[$index]['multilang'] = $field['multilang'];
                 $fields[$index]['class'] = $field['class'];
                 $fields[$index]['style'] = $field['style'];
                 if (isset($field['config']['html']) && $field['config']['html']) {
                     $fields[$index]['html'] = 1;
                 }
                 // Basic field data
                 if ($type == 'query') {
                     if ($this->isMultiValue($field['type'])) {
                         $fields[$index]['items'] = array();
                     }
                 } else {
                     if ($search && $field['sname_' . session::item('language')] != '') {
                         $fields[$index]['name'] = $field['sname_' . session::item('language')];
                     } else {
                         $fields[$index]['name'] = $type == 'view' && $field['vname_' . session::item('language')] ? $field['vname_' . session::item('language')] : $field['name_' . session::item('language')];
                     }
                     $fields[$index]['type'] = $field['type'];
                 }
                 // Data for edit and grid/browse type of pages
                 if ($type == 'full' || $type == 'edit' || $type == 'grid') {
                     $fields[$index]['field_id'] = $field['field_id'];
                     $fields[$index]['plugin'] = $field['plugin'];
                     $fields[$index]['category_id'] = $field['category_id'];
                     $fields[$index]['required'] = $field['required'];
                     $fields[$index]['system'] = $field['system'];
                     $fields[$index]['order_id'] = $field['order_id'];
                 }
                 // Data for edit type of pages
                 if ($type == 'full' || $type == 'edit') {
                     $fields[$index]['validate'] = $field['validate'];
                     $fields[$index]['validate_error'] = $field['validate_error_' . session::item('language')];
                     $fields[$index]['config'] = $field['config'];
                     // Check field's type
                     if ($this->isMultiValue($field['type'])) {
                         $fields[$index]['items'] = array();
                     }
                 }
                 // Check field's type
                 if ($this->isMultiValue($field['type'])) {
                     // Store field ID
                     $fieldIDs[$field['field_id']] = $this->getValueFormat($field['type']);
                 }
             }
         }
         // Do we have any field IDs
         if ($fieldIDs) {
             // Get items
             $items = $this->db->query("SELECT * FROM `:prefix:core_fields_items` WHERE `field_id` IN (" . implode(',', array_keys($fieldIDs)) . ") ORDER BY `order_id` ASC")->result();
             // Assign items to the field
             foreach ($items as $item) {
                 $id = $fieldIDs[$item['field_id']] == 'multiple' ? $item['item_id'] : $item['order_id'];
                 if ($search && $item['sname_' . session::item('language')] != '') {
                     $fields[$item['field_id']]['items'][$id] = $item['sname_' . session::item('language')];
                 } else {
                     $fields[$item['field_id']]['items'][$id] = $item['name_' . session::item('language')];
                 }
             }
         }
         $this->cache->set('db_fields_' . $plugin . '_' . session::item('language') . '_' . $categoryID . '_' . $type . '_' . $config . '_' . ($search ? 1 : 0), $fields, 60 * 60 * 24 * 30);
     }
     if ($type == 'edit' && !$search && input::isCP()) {
         foreach ($fields as $field) {
             if ($field['type'] == 'textarea' && isset($field['config']['html']) && $field['config']['html']) {
                 view::includeJavascript('externals/ckeditor/ckeditor.js');
             }
         }
     } elseif ($config == 'in_view') {
         $names = array();
         foreach ($fields as $field) {
             $names[$field['keyword']] = $field['name'];
         }
         config::set('fields_' . $plugin, $names, 'core');
     }
     return $fields;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:94,代码来源:fields.php

示例5: updateConfig

 public function updateConfig()
 {
     if (!input::isCP()) {
         if (!($settings = $this->cache->item('core_template_config_' . session::item('template'), true))) {
             loader::model('system/templates');
             $template = $this->templates_model->getTemplate(session::item('template'));
             $settings = isset($template['settings']) ? $template['settings'] : array();
             $this->cache->set('core_template_config_' . session::item('template'), $settings, 60 * 60 * 24 * 30, true);
         }
         config::set($settings, '', 'template');
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:12,代码来源:bootstrap.php


注:本文中的input::isCP方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。