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


PHP utf8::trim方法代码示例

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


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

示例1: sendTemplate

 public function sendTemplate($keyword, $email, $tags = array(), $language = '')
 {
     loader::model('system/emailtemplates');
     if (!$language) {
         $language = config::item('language_id', 'system');
     }
     if (is_numeric($language)) {
         $language = config::item('languages', 'core', 'keywords', $language);
     } elseif (!in_array($language, config::item('languages', 'core', 'keywords'))) {
         return false;
     }
     if (!($template = config::item($keyword . '_' . $language, '_system_emails_cache'))) {
         if (!($template = $this->cache->item('core_email_template_' . $keyword . '_' . $language))) {
             $template = $this->emailtemplates_model->prepareTemplate($keyword, $language);
             if (count($template) == 3) {
                 if ($template[$keyword]['active']) {
                     $template = array('subject' => $template[$keyword]['subject'], 'message_html' => utf8::trim($template['header']['message_html'] . $template[$keyword]['message_html'] . $template['footer']['message_html']), 'message_text' => utf8::trim($template['header']['message_text'] . "\n\n" . $template[$keyword]['message_text'] . "\n\n" . $template['footer']['message_text']));
                 } else {
                     $template = 'none';
                 }
             } else {
                 error::show('Could not fetch email template from the database: ' . $keyword);
             }
             $this->cache->set('core_email_template_' . $keyword . '_' . $language, $template, 60 * 60 * 24 * 30);
         }
         config::set(array($keyword . '_' . $language => $template), '', '_system_emails_cache');
     }
     $retval = true;
     if (is_array($template) && $template) {
         $retval = $this->sendEmail($email, $template['subject'], $template['message_text'], $template['message_html'], $tags);
     }
     return $retval;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:33,代码来源:email.php

示例2: delete

 public function delete()
 {
     // Get URI vars
     $slugID = urldecode(utf8::trim(uri::segment(4)));
     // Do we have a slug ID?
     if ($slugID == '') {
         error::show404();
     }
     // Get user
     if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) {
         error::show404();
     } elseif ($user['user_id'] == session::item('user_id')) {
         router::redirect($user['slug']);
     }
     // Does user exist?
     if (!($blocked = $this->users_blocked_model->getUser($user['user_id'], true))) {
         view::setError(__('no_blocked_user', 'users_blocked'));
         router::redirect('users/blocked');
     }
     // Delete blocked user
     $this->users_blocked_model->deleteBlockedUser(session::item('user_id'), $user['user_id']);
     // Success
     view::setInfo(__('user_unblocked', 'users_blocked'));
     router::redirect(input::get('page') ? 'users/blocked' : $user['slug']);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:25,代码来源:blocked.php

示例3: send

 public function send()
 {
     // Get URI vars
     $slugID = utf8::trim(urldecode(uri::segment(3)));
     // Do we have a slug ID?
     if ($slugID) {
         if (!($user = $this->users_model->getUser($slugID))) {
             view::setError(__('no_user', 'users'));
             router::redirect('messages/manage');
         }
         // Does user have permission to send messages to this user group?
         if (!session::permission('messages_send', 'messages') || !in_array($user['group_id'], session::permission('messages_send', 'messages'))) {
             view::noAccess();
         } elseif ($user['user_id'] == session::item('user_id')) {
             view::setError(__('message_recipients_self', 'messages'));
             router::redirect('messages/manage');
         } elseif (config::item('credits_active', 'billing') && session::permission('messages_credits', 'messages') && session::permission('messages_credits', 'messages') > session::item('total_credits')) {
             view::setError(__('no_credits', 'system', array(), array('%' => html_helper::anchor('billing/credits', '\\1'))));
             router::redirect('messages/manage');
         }
     } else {
         router::redirect('messages/manage');
     }
     // Did user reach the max messages limit?
     if (session::permission('messages_limit', 'messages') && session::permission('messages_limit', 'messages') <= session::item('total_conversations')) {
         view::setError(__('message_limit_reached', 'messages', array('%limit%' => session::permission('messages_limit', 'messages'))));
         router::redirect('messages/manage');
     }
     // Did we block this user or did they block us?
     if (config::item('blacklist_active', 'users') && ($blocked = $this->users_blocked_model->getUser($user['user_id']))) {
         if ($blocked['user_id'] == session::item('user_id')) {
             view::setError(__('user_blocked', 'users'));
         } else {
             view::setError(__('user_blocked_self', 'users'));
         }
         router::redirect($user['slug']);
     }
     // Get templates
     $templates = array();
     if (session::permission('messages_templates', 'messages')) {
         loader::model('messages/templates', array(), 'messages_templates_model');
         $templates = $this->messages_templates_model->getTemplates(true, true);
     }
     // Assign vars
     view::assign(array('user' => $slugID ? $user : array(), 'templates' => $templates));
     // Process form values
     if (input::post('do_save_conversation')) {
         $this->_saveConversation($slugID ? $user : array());
     }
     // Set title
     view::setTitle(__('message_send', 'messages'));
     // Load view
     view::load('messages/send');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:54,代码来源:messages.php

示例4: _saveLanguage

 protected function _saveLanguage($languageID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Rules array
     $rules = array();
     // Keyword and name fields
     $rules = array('name' => array('label' => __('name', 'system'), 'rules' => array('required', 'max_length' => 128)), 'keyword' => array('label' => __('keyword', 'system'), 'rules' => array('required', 'max_length' => 128, 'alpha_dash', 'strtolower', 'callback__is_unique_keyword' => $languageID)));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get post data
     $name = utf8::trim(input::post('name'));
     $keyword = trim(input::post('keyword'));
     // Save language pack
     if (!$this->languages_model->saveLanguage($languageID, $name, $keyword)) {
         return false;
     }
     // Success
     view::setInfo(__('language_saved', 'system_languages'));
     router::redirect($languageID ? 'cp/system/languages/edit/' . $keyword : '/cp/system/languages');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:27,代码来源:languages.php

示例5: _saveRecipients

 protected function _saveRecipients($newsletterID, $filters)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     $values = $params['join_columns'] = array();
     // Check extra user field
     $user = utf8::trim(input::post_get('user'));
     if ($user) {
         $params['join_columns'][] = $this->search_model->prepareValue($user, 'u', 'user');
         $values['user'] = $user;
     }
     // Check extra verified field
     $verified = input::post_get('verified');
     if ($verified != '') {
         $params['join_columns'][] = '`u`.`verified`=' . (int) $verified;
         $values['verified'] = $verified;
     }
     // Check extra status field
     $status = input::post_get('active');
     if ($status != '') {
         $params['join_columns'][] = '`u`.`active`=' . (int) $status;
         $values['active'] = $status;
     }
     // Check extra group field
     $groups = input::post_get('groups');
     if ($groups) {
         foreach ($groups as $index => $group) {
             if (config::item('usergroups', 'core', $group)) {
                 $groups[$index] = (int) $group;
             } else {
                 unset($groups[$index]);
             }
         }
         if ($groups) {
             $params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', $groups) . ')';
             $values['groups'] = $groups;
         }
     }
     // Check extra type field
     $typeID = input::post_get('type_id');
     if ($typeID != '' && config::item('usertypes', 'core', 'keywords', $typeID)) {
         $params['join_columns'][] = '`u`.`type_id`=' . $typeID;
         $values['type_id'] = $typeID;
     }
     // Search users
     $searchID = $values ? $this->search_model->searchData('profile', $filters, $params['join_columns'], $values, array('type_id' => $typeID)) : 'no_terms';
     // Do we have any search terms?
     if ($searchID == 'no_terms') {
         view::setError(__('search_no_terms', 'system'));
     } elseif ($searchID == 'no_results') {
         view::setError(__('search_no_results', 'system'));
     } else {
         // Get search
         if (!($search = $this->search_model->getSearch($searchID))) {
             view::setError(__('save_error', 'system'));
         }
         $newsletter = array('params' => array('conditions' => $search['conditions'], 'values' => $search['values']), 'total_users' => $search['results'], 'total_sent' => 0);
         // Save recipients
         if (!$this->newsletters_model->saveNewsletter($newsletterID, $newsletter)) {
             view::setError(__('save_error', 'system'));
             return false;
         }
         router::redirect('cp/content/newsletters/review/' . $newsletterID);
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:67,代码来源:newsletters.php

示例6: parseCounters

 protected function parseCounters($params)
 {
     // Get fields
     $filters = $this->fields_model->getFields('pictures', 1, 'edit', 'in_search', true);
     // Set extra fields
     $filters[] = array('name' => __('search_keyword', 'system'), 'type' => 'text', 'keyword' => 'q');
     $filters[] = array('name' => __('user', 'system'), 'type' => 'text', 'keyword' => 'user');
     // Assign vars
     view::assign(array('filters' => $filters, 'values' => array()));
     // Did user submit the filter form?
     if (input::post_get('do_search')) {
         $values = array();
         // Check extra keyword
         $keyword = utf8::trim(input::post_get('q'));
         if ($keyword) {
             $params['join_columns'][] = $this->search_model->prepareValue($keyword, 'a', array('data_title', 'data_description'));
             $values['q'] = $keyword;
         }
         // Check extra user field
         $user = utf8::trim(input::post_get('user'));
         if ($user) {
             $params['join_columns'][] = $this->search_model->prepareValue($user, 'u', 'user');
             $values['user'] = $user;
         }
         // Search albums
         $searchID = $this->search_model->searchData('picture_album', $filters, $params['join_columns'], $values);
         // Do we have any search terms?
         if ($searchID == 'no_terms') {
             view::setError(__('search_no_terms', 'system'));
         } elseif ($searchID == 'no_results') {
             view::setError(__('search_no_results', 'system'));
             $params['total'] = 0;
             return $params;
         } else {
             router::redirect('cp/plugins/pictures/albums?search_id=' . $searchID);
         }
     }
     // Do we have a search ID?
     if (!input::post_get('do_search') && input::get('search_id')) {
         // Get search
         if (!($search = $this->search_model->getSearch(input::get('search_id')))) {
             view::setError(__('search_expired', 'system'));
             router::redirect('cp/plugins/pictures/albums');
         }
         // Combine results
         $params['join_columns'] = $search['conditions']['columns'];
         $params['join_items'] = $search['conditions']['items'];
         $params['values'] = $search['values'];
         $params['total'] = $search['results'];
         // Assign vars
         view::assign(array('values' => $search['values']));
     } else {
         // Count albums
         if (!($params['total'] = $this->counters_model->countData('picture_album', 0, 0, $params['join_columns'], $params['join_items'], $params))) {
             view::setInfo(__('no_albums', 'pictures'));
         }
     }
     return $params;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:59,代码来源:albums.php

示例7: parseCounters

 protected function parseCounters($params)
 {
     // Set filter fields
     $filters = array(array('name' => __('keyword', 'system'), 'type' => 'text', 'keyword' => 'q'), array('name' => __('reporter', 'reports'), 'type' => 'text', 'keyword' => 'user'));
     // Assign vars
     view::assign(array('filters' => $filters, 'values' => array()));
     // Did user submit the filter form?
     if (input::post_get('do_search')) {
         $values = array();
         // Check extra keyword field
         $keyword = utf8::trim(input::post_get('q'));
         if ($keyword) {
             $params['join_columns'][] = $this->search_model->prepareValue($keyword, 'r', 'message');
             $values['q'] = $keyword;
         }
         // Check extra user field
         $user = utf8::trim(input::post_get('user'));
         if ($user) {
             $params['join_columns'][] = $this->search_model->prepareValue($user, 'u', 'user');
             $values['user'] = $user;
         }
         // Search reports
         $searchID = $this->search_model->searchData('report', $filters, $params['join_columns'], $values);
         // Do we have any search terms?
         if ($searchID == 'no_terms') {
             view::setError(__('search_no_terms', 'system'));
         } elseif ($searchID == 'no_results') {
             view::setError(__('search_no_results', 'system'));
             $params['total'] = 0;
             return $params;
         } else {
             router::redirect('cp/content/reports?search_id=' . $searchID);
         }
     }
     // Do we have a search ID?
     if (!input::post_get('do_search') && input::get('search_id')) {
         // Get search
         if (!($search = $this->search_model->getSearch(input::get('search_id')))) {
             view::setError(__('search_expired', 'system'));
             router::redirect('cp/content/reports');
         }
         // Combine results
         $params['join_columns'] = $search['conditions']['columns'];
         $params['values'] = $search['values'];
         $params['total'] = $search['results'];
         // Assign vars
         view::assign(array('values' => $search['values']));
     } else {
         // Count reports
         if (!($params['total'] = $this->counters_model->countData('report', 0, 0, $params['join_columns'], array(), $params))) {
             view::setInfo(__('no_reports', 'reports'));
         }
     }
     return $params;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:55,代码来源:reports.php

示例8: parseCounters

 protected function parseCounters($params, $typeID)
 {
     // Set filters
     $filters = array(array('name' => __('user', 'system'), 'type' => 'text', 'keyword' => 'user'), array('name' => __('user_group', 'users'), 'type' => 'select', 'keyword' => 'group', 'items' => config::item('usergroups', 'core')), array('name' => __('user_type', 'users'), 'type' => 'select', 'keyword' => 'type_id', 'items' => config::item('usertypes', 'core', 'names')));
     foreach (config::item('usertypes', 'core', 'keywords') as $id => $type) {
         $filters['types'][$id] = $this->fields_model->getFields('users', $id, 'edit');
     }
     $filters[] = array('name' => __('verified', 'users'), 'type' => 'boolean', 'keyword' => 'verified');
     $filters[] = array('name' => __('active', 'system'), 'type' => 'boolean', 'keyword' => 'active');
     // Assign vars
     view::assign(array('filters' => $filters, 'values' => array()));
     // Did user submit the filter form?
     if (input::post_get('do_search')) {
         $values = array();
         // Check extra user field
         $user = utf8::trim(input::post_get('user'));
         if ($user) {
             $params['join_columns'][] = $this->search_model->prepareValue($user, 'u', 'user');
             $values['user'] = $user;
         }
         // Check extra verified field
         $verified = input::post_get('verified');
         if ($verified != '') {
             $params['join_columns'][] = '`u`.`verified`=' . (int) $verified;
             $values['verified'] = $verified;
         }
         // Check extra status field
         $status = input::post_get('active');
         if ($status != '') {
             $params['join_columns'][] = '`u`.`active`=' . (int) $status;
             $values['active'] = $status;
         }
         // Check extra group field
         $group = input::post_get('group');
         if ($group != '' && config::item('usergroups', 'core', $group)) {
             $params['join_columns'][] = '`u`.`group_id`=' . $group;
             $values['group'] = $group;
         }
         // Check extra type field
         $typeID = input::post_get('type_id');
         if ($typeID != '' && config::item('usertypes', 'core', 'keywords', $typeID)) {
             $params['join_columns'][] = '`u`.`type_id`=' . $typeID;
             $values['type_id'] = $typeID;
         }
         // Search users
         $searchID = $this->search_model->searchData('profile', $filters, $params['join_columns'], $values, array('type_id' => $typeID));
         // Do we have any search terms?
         if ($searchID == 'no_terms') {
             view::setError(__('search_no_terms', 'system'));
         } elseif ($searchID == 'no_results') {
             view::setError(__('search_no_results', 'system'));
             $params['total'] = 0;
             return $params;
         } else {
             router::redirect('cp/users?search_id=' . $searchID);
         }
     }
     // Do we have a search ID?
     if (!input::post_get('do_search') && input::get('search_id')) {
         // Get search
         if (!($search = $this->search_model->getSearch(input::get('search_id')))) {
             view::setError(__('search_expired', 'system'));
             router::redirect('cp/users');
         }
         // Combine results
         $params['join_columns'] = $search['conditions']['columns'];
         $params['join_items'] = $search['conditions']['items'];
         $params['values'] = $search['values'];
         $params['total'] = $search['results'];
         // Assign vars
         view::assign(array('values' => $search['values']));
     } else {
         // Count users
         if (!($params['total'] = $this->counters_model->countData('user', 0, 0, $params['join_columns'], $params['join_items'], $params))) {
             view::setInfo(__('no_users', 'users'));
         }
     }
     return $params;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:79,代码来源:users.php

示例9: parseCounters

 protected function parseCounters($params = array())
 {
     // Assign vars
     view::assign(array('filters' => array(), 'values' => array()));
     // Do we have permission to search?
     if (session::permission('news_search', 'news')) {
         // Get fields
         $filters = $this->fields_model->getFields('news', 0, 'edit', 'in_search', true);
         // Set extra fields
         $filters[] = array('name' => __('search_keyword', 'system'), 'type' => 'text', 'keyword' => 'q');
         // Assign vars
         view::assign(array('filters' => $filters));
         // Did user submit the filter form?
         if (input::post_get('do_search') && session::permission('news_search', 'news')) {
             $values = array();
             $params['total'] = $params['max'] = 0;
             // Check extra keyword
             $keyword = utf8::trim(input::post_get('q'));
             if ($keyword) {
                 $params['join_columns'][] = $this->search_model->prepareValue($keyword, 'n', array('data_title_' . session::item('language'), 'data_body_' . session::item('language')));
                 $values['q'] = $keyword;
             }
             // Search news
             $searchID = $this->search_model->searchData('news', $filters, $params['join_columns'], $values, array('multilang' => true));
             // Do we have any search terms?
             if ($searchID == 'no_terms') {
                 view::setError(__('search_no_terms', 'system'));
             } elseif ($searchID == 'no_results') {
                 view::setError(__('search_no_results', 'system'));
                 return $params;
             } else {
                 router::redirect('news?search_id=' . $searchID);
             }
         }
         // Do we have a search ID?
         if (!input::post_get('do_search') && input::get('search_id')) {
             // Get search
             if (!($search = $this->search_model->getSearch(input::get('search_id')))) {
                 view::setError(__('search_expired', 'system'));
                 router::redirect('news');
             }
             // Set results
             $params['join_columns'] = $search['conditions']['columns'];
             $params['join_items'] = $search['conditions']['items'];
             $params['values'] = $search['values'];
             $params['total'] = $search['results'];
             $params['max'] = config::item('max_search_results', 'system') && config::item('max_search_results', 'system') < $params['total'] ? config::item('max_search_results', 'system') : $params['total'];
             // Assign vars
             view::assign(array('values' => $search['values']));
         }
     }
     if (!input::get('search_id')) {
         // Count news
         if (!($params['total'] = $this->counters_model->countData('news', 0, 0, $params['join_columns'], $params['join_items'], $params))) {
             view::setInfo(__('no_entries', 'news'));
         }
         $params['max'] = $params['total'];
     }
     return $params;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:60,代码来源:news.php

示例10: parseCounters

 protected function parseCounters($params, $gateways)
 {
     // Set filter fields
     $filters = array(array('name' => __('receipt_id', 'billing_transactions'), 'type' => 'text', 'keyword' => 'receipt_id'), array('name' => __('product', 'billing'), 'type' => 'text', 'keyword' => 'product'), array('name' => __('payment_gateway', 'billing'), 'type' => 'select', 'items' => $gateways, 'keyword' => 'gateway_id'), array('name' => __('user', 'system'), 'type' => 'text', 'keyword' => 'user'));
     // Assign vars
     view::assign(array('filters' => $filters, 'values' => array()));
     // Did user submit the filter form?
     if (input::post_get('do_search')) {
         $values = array();
         // Check extra product field
         $product = input::post_get('product');
         if ($product != '') {
             $params['join_columns'][] = "`i`.`name` LIKE '" . trim($this->db->escape($product, true), "'") . "'";
             $values['product'] = $product;
         }
         // Check extra receipt field
         $receipt_id = input::post_get('receipt_id');
         if ($receipt_id != '') {
             $params['join_columns'][] = "`t`.`receipt_id`=" . $this->db->escape($receipt_id);
             $values['receipt_id'] = $receipt_id;
         }
         // Check extra gateway field
         $gateway_id = input::post_get('gateway_id');
         if ($gateway_id && isset($gateways[$gateway_id])) {
             $params['join_columns'][] = "`t`.`gateway_id`=" . $gateway_id;
             $values['gateway_id'] = $gateway_id;
         }
         // Check extra user field
         $user = utf8::trim(input::post_get('user'));
         if ($user) {
             $params['join_columns'][] = $this->search_model->prepareValue($user, 'u', 'user');
             $values['user'] = $user;
         }
         // Search transactions
         $searchID = $this->search_model->searchData('billing_transaction', $filters, $params['join_columns'], $values);
         // Do we have any search terms?
         if ($searchID == 'no_terms') {
             view::setError(__('search_no_terms', 'system'));
         } elseif ($searchID == 'no_results') {
             view::setError(__('search_no_results', 'system'));
             $params['total'] = 0;
             return $params;
         } else {
             router::redirect('cp/billing/transactions?search_id=' . $searchID);
         }
     }
     // Do we have a search ID?
     if (!input::post_get('do_search') && input::get('search_id')) {
         // Get search
         if (!($search = $this->search_model->getSearch(input::get('search_id')))) {
             view::setError(__('search_expired', 'system'));
             router::redirect('cp/billing/transactions');
         }
         // Combine results
         $params['join_columns'] = $search['conditions']['columns'];
         $params['values'] = $search['values'];
         $params['total'] = $search['results'];
         // Assign vars
         view::assign(array('values' => $search['values']));
     } else {
         // Count transactions
         if (!($params['total'] = $this->counters_model->countData('billing_transaction', 0, 0, $params['join_columns'], array(), $params))) {
             view::setInfo(__('no_transactions', 'billing_transactions'));
         }
     }
     return $params;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:67,代码来源:transactions.php

示例11: parseSearch


//.........这里部分代码省略.........
                                 $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . "`>=" . $from;
                             } elseif ($to && isset($field['items'][$to])) {
                                 $values[$keyword . '__to'] = $to;
                                 $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . "`<=" . $to;
                             }
                         } else {
                             // Do we have an array?
                             if (!is_array($value)) {
                                 $value = array($value);
                             }
                             // Make sure only existing item IDs are present
                             $value = array_intersect($value, array_keys($field['items']));
                             // Do we have any IDs?
                             if ($value) {
                                 // Do we have a single ID?
                                 if (count($value) == 1) {
                                     $values[$keyword] = isset($field['config']['search_options']) && $field['config']['search_options'] == 'multiple' ? $value : current($value);
                                     $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . '`=' . current($value);
                                 } else {
                                     $values[$keyword] = $value;
                                     $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . '` IN (' . implode(',', $value) . ')';
                                 }
                             }
                         }
                     } elseif ($this->getValueFormat($field['type']) == 'birthday') {
                         // Set new values
                         $from = (int) input::post_get($keyword . '__from');
                         $to = (int) input::post_get($keyword . '__to');
                         // Make sure only existing item IDs are present
                         if ($from > 0 && $to > 0) {
                             // Switch values if $from is bigger than $to
                             if ($from > $to) {
                                 $temp = $from;
                                 $from = $to;
                                 $to = $temp;
                             }
                             $values[$keyword . '__from'] = $from;
                             $values[$keyword . '__to'] = $to;
                             $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . '` BETWEEN ' . (date('Y') - $to - 1) . date('md') . ' AND ' . (date('Y') - $from) . date('md');
                         } elseif ($to > 0) {
                             $values[$keyword . '__to'] = $to;
                             $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . '`>= ' . (date('Y') - $to - 1) . date('md');
                         } elseif ($from > 0) {
                             $values[$keyword . '__from'] = $from;
                             $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . '`<=' . (date('Y') - $from) . date('md');
                         }
                     } elseif ($this->getValueFormat($field['type']) == 'location') {
                         // Set country, state and city values
                         $location = input::post_get($keyword);
                         foreach (array('country', 'state', 'city') as $key) {
                             if (isset($location[$key]) && is_numeric($location[$key]) && $location[$key] > 0) {
                                 $values[$keyword][$key] = $location[$key];
                                 $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . ($key != 'country' ? '_' . $key : '') . '`=' . (int) $location[$key];
                             }
                         }
                     } else {
                         // Do we have a ranged search option
                         if (($this->getValueFormat($field['type']) == 'number' || $this->getValueFormat($field['type']) == 'double') && isset($field['config']['search_options']) && $field['config']['search_options'] == 'range') {
                             // Set new values
                             $from = input::post_get($keyword . '__from');
                             $to = input::post_get($keyword . '__to');
                             // Make sure only existing item IDs are present
                             if ($from != '' && $to != '' && is_numeric($from) && is_numeric($to)) {
                                 // Switch values if $from is larger than $to
                                 if ($from > $to) {
                                     $temp = $from;
                                     $from = $to;
                                     $to = $temp;
                                 }
                                 $values[$keyword . '__from'] = $from;
                                 $values[$keyword . '__to'] = $to;
                                 $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . "` BETWEEN " . $from . " AND " . $to;
                             } elseif ($from != '' && is_numeric($from)) {
                                 $values[$keyword . '__from'] = $from;
                                 $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . "`>=" . $from;
                             } elseif ($to != '' && is_numeric($to)) {
                                 $values[$keyword . '__to'] = $to;
                                 $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . "`<=" . $to;
                             }
                         } else {
                             // Trim value
                             $value = utf8::trim($value);
                             // Do we have a value?
                             if ($value != '') {
                                 $values[$keyword] = $value;
                                 // Is this a numeric value?
                                 if (is_numeric($value)) {
                                     $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . (isset($params['multilang']) && $params['multilang'] && $field['multilang'] ? '_' . session::item('language') : '') . '`=' . $value;
                                 } else {
                                     $columns[] = "`" . $resource['prefix'] . "`.`data_" . $field['keyword'] . (isset($params['multilang']) && $params['multilang'] && $field['multilang'] ? '_' . session::item('language') : '') . "` LIKE '%" . trim($this->db->escapeLike($value), "'") . "%'";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return array($columns, $items, $values);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:101,代码来源:fields.php

示例12: user

 public function user()
 {
     // Get user and last action ID
     $slugID = urldecode(utf8::trim(uri::segment(3)));
     $lastID = (int) input::post_get('last_id', 0);
     // Get user
     if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) {
         error::show404();
     }
     // Does user have permission to view this user group/type?
     if (!in_array($user['group_id'], session::permission('users_groups_browse', 'users')) || !in_array($user['type_id'], session::permission('users_types_browse', 'users'))) {
         view::noAccess();
     } elseif (!$this->users_model->getPrivacyAccess($user['user_id'], isset($user['config']['privacy_profile']) ? $user['config']['privacy_profile'] : 1)) {
         view::noAccess($user['slug']);
     }
     // Get actions
     $actions = $this->timeline_model->getActions($user['user_id'], 1, $lastID, 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 = $this->likes_model->getMultiLikes($ratings);
         $votes = $this->votes_model->getMultiVotes($ratings);
         $ratings = $likes + $votes;
     }
     // Can we post messages?
     $post = session::permission('messages_post', 'timeline') && $this->users_model->getPrivacyAccess($user['user_id'], isset($user['config']['privacy_timeline_messages']) ? $user['config']['privacy_timeline_messages'] : 1, false) ? true : false;
     // Update comments pagination
     config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
     // Set meta tags
     $this->metatags_model->set('timeline', 'timeline_user', array('user' => $user));
     // Set title
     view::setTitle(__('timeline_recent', 'system_navigation'), false);
     // Set trail
     view::setTrail($user['slug'], $user['name']);
     // Load view
     if (input::isAjaxRequest()) {
         $output = view::load('timeline/actions', array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), true);
         view::ajaxResponse($output);
     } else {
         view::load('timeline/index', array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings));
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:53,代码来源:timeline.php

示例13: trim

 /**
  * Tests the utf8::trim() function.
  * @dataProvider trim_provider
  * @group core.helpers.utf8.trim
  * @test
  */
 public function trim($str, $charlist, $expected_result)
 {
     $result = utf8::trim($str, $charlist);
     $this->assertEquals($expected_result, $result);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:11,代码来源:Helper_UTF8_Test.php

示例14: parseCounters

 protected function parseCounters($params = array(), $type = 'index')
 {
     // Assign vars
     view::assign(array('filters' => array(), 'values' => array()));
     // Do we have permission to search?
     if (session::permission('albums_search', 'pictures')) {
         // Get fields
         $filters = $this->fields_model->getFields('pictures', 1, 'edit', 'in_search', true);
         // Set extra fields
         $filters[] = array('name' => __('search_keyword', 'system'), 'type' => 'text', 'keyword' => 'q');
         // Assign vars
         view::assign(array('filters' => $filters));
         // Did user submit the filter form?
         if (input::post_get('do_search') && session::permission('albums_search', 'pictures')) {
             $values = array();
             $params['total'] = $params['max'] = 0;
             // Check extra keyword
             $keyword = utf8::trim(input::post_get('q'));
             if ($keyword) {
                 $params['join_columns'][] = $this->search_model->prepareValue($keyword, 'a', array('data_title', 'data_description'));
                 $values['q'] = $keyword;
             }
             // Search albums
             $searchID = $this->search_model->searchData('picture_album', $filters, $params['join_columns'], $values);
             // Do we have any search terms?
             if ($searchID == 'no_terms') {
                 view::setError(__('search_no_terms', 'system'));
             } elseif ($searchID == 'no_results') {
                 view::setError(__('search_no_results', 'system'));
                 return $params;
             } else {
                 switch ($type) {
                     case 'user':
                         router::redirect('pictures/user/' . uri::segment(4) . '?search_id=' . $searchID);
                         break;
                     case 'manage':
                         router::redirect('pictures/manage?search_id=' . $searchID);
                         break;
                     default:
                         router::redirect('pictures?search_id=' . $searchID);
                         break;
                 }
             }
         }
         // Do we have a search ID?
         if (!input::post_get('do_search') && input::get('search_id')) {
             // Get search
             if (!($search = $this->search_model->getSearch(input::get('search_id')))) {
                 view::setError(__('search_expired', 'system'));
                 switch ($type) {
                     case 'user':
                         router::redirect('pictures/user/' . uri::segment(4));
                         break;
                     case 'manage':
                         router::redirect('pictures/manage');
                         break;
                     default:
                         router::redirect('pictures');
                         break;
                 }
             }
             // Set results
             $params['join_columns'] = $search['conditions']['columns'];
             $params['join_items'] = $search['conditions']['items'];
             $params['values'] = $search['values'];
             $params['total'] = $search['results'];
             $params['max'] = config::item('max_search_results', 'system') && config::item('max_search_results', 'system') < $params['total'] ? config::item('max_search_results', 'system') : $params['total'];
             // Assign vars
             view::assign(array('values' => $search['values']));
         }
     }
     if (!input::get('search_id')) {
         // Count albums
         if ($type == 'manage' && !$params['total'] || $type != 'manage' && !($params['total'] = $this->counters_model->countData('picture_album', 0, 0, $params['join_columns'], $params['join_items'], $params))) {
             if ($type == 'manage') {
                 view::setInfo(__('no_albums_self', 'pictures'));
             } else {
                 view::setInfo(__('no_albums', 'pictures'));
             }
         }
         $params['max'] = $params['total'];
     }
     return $params;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:84,代码来源:albums.php

示例15: _saveField

 protected function _saveField($plugin, $table, $categoryID, $fieldID, $fieldOld, $configs, $hidden)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Rules array
     $rules = array();
     // Data array
     $inputData = array('keyword', 'type', 'style', 'class', 'required', 'system', 'multilang');
     // Name
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $lang) {
         $rules['name_' . $lang] = array('label' => __('name', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $rules['vname_' . $lang] = array('label' => __('name_view', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $rules['sname_' . $lang] = array('label' => __('name_search', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $rules['validate_error_' . $lang] = array('label' => __('validate_error', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $inputData[] = 'name_' . $lang;
         $inputData[] = 'vname_' . $lang;
         $inputData[] = 'sname_' . $lang;
         $inputData[] = 'validate_error_' . $lang;
     }
     // Keyword
     $rules['keyword'] = array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'alpha_dash', 'max_length' => 128, 'callback__is_unique_keyword' => array($plugin, $categoryID, $fieldID), 'callback__is_system_field' => array($fieldID ? $fieldOld['keyword'] : '', $fieldID ? $fieldOld['system'] : '')));
     // Type
     $rules['type'] = array('label' => __('field_type', 'system_fields'), 'rules' => array('required', 'callback__is_system_field' => array($fieldID ? $fieldOld['type'] : '', $fieldID ? $fieldOld['system'] : '')));
     // Style value
     $rules['style'] = array('label' => __('style', 'system_fields'), 'rules' => array('trim'));
     // Class value
     $rules['class'] = array('label' => __('class', 'system_fields'), 'rules' => array('trim'));
     // Required
     $rules['required'] = array('label' => __('required', 'system_fields'), 'rules' => array('intval'));
     // Regular expression
     $rules['validate'] = array('label' => __('validate', 'system_fields'), 'rules' => array('trim'));
     $inputData[] = 'validate';
     // Configuration array
     $inputConfig = array();
     foreach (array('custom', input::post('type')) as $conf) {
         if (isset($configs[$conf])) {
             foreach ($configs[$conf] as $option) {
                 $rules['config_' . $conf . '_' . $option['keyword']] = array('label' => utf8::strtolower($option['label']), 'rules' => isset($option['rules']) ? $option['rules'] : array());
                 $inputConfig[$option['keyword']] = 'config_' . $conf . '_' . $option['keyword'];
             }
         }
     }
     // Add items rules
     $items = array();
     $oldItems = $fieldID ? $fieldOld['items'] : array();
     if ($this->fields_model->isMultiValue(input::post('type'))) {
         $itemsPost = input::post('items');
         $sitemsPost = input::post('sitems');
         foreach (config::item('languages', 'core', 'keywords') as $languageID => $lang) {
             $orderID = 1;
             if (isset($itemsPost[$lang]) && is_array($itemsPost[$lang])) {
                 foreach ($itemsPost[$lang] as $itemID => $itemName) {
                     // Trim name
                     $itemName = utf8::trim($itemName);
                     // Assign item data
                     $items[$itemID]['order_id'] = $orderID;
                     $items[$itemID]['name_' . $lang] = $itemName;
                     $items[$itemID]['sname_' . $lang] = $sitemsPost[$lang][$itemID];
                     $orderID++;
                     // Add rule
                     $rules['items[' . $lang . '][' . $itemID . ']'] = array();
                     if ($itemName == '') {
                         validate::setRule('items', '', '');
                         validate::setFieldError('items', __('empty_item', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''));
                     }
                 }
             }
         }
         if (!$items) {
             validate::setRule('items', '', '');
             validate::setFieldError('items', __('no_items', 'system_fields'));
         }
         view::assign(array('field' => array('items' => $items)));
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get post data
     $fieldData = input::post($inputData);
     // Default data
     $fieldData['system'] = isset($hidden['system']) ? $hidden['system'] : 0;
     $fieldData['multilang'] = isset($hidden['multilang']) ? $hidden['multilang'] : 0;
     // Get config data
     $fieldData['config'] = array();
     foreach ($inputConfig as $key => $val) {
         $fieldData['config'][$key] = input::post($val);
     }
     // Set additional config data
     $fieldData['config']['html'] = input::post('html') ? 1 : 0;
     $fieldData['config']['in_search'] = input::post('in_search') ? 1 : 0;
     $fieldData['config']['in_search_advanced'] = input::post('in_search_advanced') ? 1 : 0;
     if ($fieldData['config']['in_search'] || $fieldData['config']['in_search_advanced']) {
         $fieldData['config']['search_options'] = input::post('search_options') ? input::post('search_options') : '';
     }
     if (input::post('type') == 'checkbox' || input::post('search_options') == 'multiple') {
//.........这里部分代码省略.........
开发者ID:soremi,项目名称:tutornavi,代码行数:101,代码来源:system.php


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