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


PHP validate::getTotalErrors方法代码示例

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


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

示例1: _sendFeedback

 protected function _sendFeedback()
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('name' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 2, 'max_length' => 255)), 'email' => array('rules' => array('required', 'is_string', 'trim', 'valid_email', 'min_length' => 4, 'max_length' => 255)), 'subject' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 5, 'max_length' => 255)), 'message' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 10, 'max_length' => 10000)));
     if (config::item('feedback_captcha', 'feedback') == 1 || config::item('feedback_captcha', 'feedback') == 2 && !users_helper::isLoggedin()) {
         $rules['captcha'] = array('rules' => array('is_captcha'));
     }
     validate::setRules($rules);
     // Validate form values
     if (!validate::run($rules)) {
         return false;
     }
     // Get values
     $email = input::post('email');
     $subject = input::post('subject');
     $message = input::post('message') . "\n\n--\n" . input::post('name') . ' <' . input::post('email') . '>' . "\n" . input::ipaddress();
     // Send feedback
     if (!$this->feedback_model->sendFeedback($email, $subject, $message)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('send_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('message_sent', 'feedback'));
     router::redirect('feedback');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:31,代码来源:feedback.php

示例2: _submitReport

 protected function _submitReport($resource, $resourceID, $userID, $itemID, $subjects)
 {
     // Extra rules
     $rules = array('subject' => array('rules' => $subjects ? array('required', 'callback__is_valid_subject' => array($subjects)) : array('callback__is_valid_subject' => array($subjects))), 'message' => array('rules' => array('is_string', 'trim', 'max_length' => 255)));
     validate::setRules($rules);
     // Validate form values
     if (!validate::run($rules)) {
         return false;
     }
     // Get values
     $subject = $subjects ? (int) input::post('subject') : 0;
     $message = input::post('message');
     // Send feedback
     if (!$this->reports_model->saveReport($resourceID, $userID, $itemID, $subject, $message)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     router::redirect('report/sent' . (input::get('modal') ? '?modal=1' : ''));
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:22,代码来源:report.php

示例3: _saveAlbum

 protected function _saveAlbum($albumID, $album, $fields)
 {
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'), 'privacy' => array('rules' => 'intval'), 'public' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extra fields
     $extra = array();
     $extra['comments'] = config::item('picture_comments', 'pictures') && config::item('picture_privacy_comments', 'pictures') ? (int) input::post('comments') : 1;
     $extra['privacy'] = config::item('album_privacy_view', 'pictures') ? (int) input::post('privacy') : 1;
     $extra['public'] = config::item('album_privacy_public', 'pictures') ? (int) input::post('public') : 1;
     // Save album
     if (!($albumID = $this->pictures_albums_model->saveAlbumData($albumID, session::item('user_id'), $album, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('album_saved', 'pictures'));
     router::redirect('pictures/albums/edit/' . $albumID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:24,代码来源:albums.php

示例4: _savePage

 protected function _savePage($pageID, $parentID, $page, $fields, $options, $trail)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array();
     foreach ($options as $option) {
         if (isset($option['rules'])) {
             $rules[$option['keyword']] = array('label' => $option['name'], 'rules' => $option['rules']);
         }
     }
     $rules['keyword'] = array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'max_length' => 128, 'callback__is_valid_keyword' => array($parentID, $pageID)));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Did keyword change?
     if ($pageID && $page['system'] && strcmp($page['keyword'], input::post('keyword'))) {
         validate::setFieldError('keyword', __('page_system_rename', 'pages'));
         return false;
     }
     // Extras
     $extra = array();
     $extra['parent_id'] = $parentID;
     $extra['location'] = ($trail ? implode('/', $trail) . '/' : '') . input::post('keyword');
     $extra['keyword'] = input::post('keyword');
     $extra['file_name'] = input::post('file_name');
     $extra['comments'] = config::item('page_comments', 'pages') ? (int) input::post('comments') : 1;
     $extra['likes'] = config::item('page_rating', 'pages') == 'likes' ? (int) input::post('likes') : 1;
     $extra['votes'] = config::item('page_rating', 'pages') == 'stars' ? (int) input::post('votes') : 1;
     $extra['trail'] = (int) input::post('trail');
     $extra['active'] = (int) input::post('active');
     // Save page
     if (!($pageID = $this->pages_model->savePageData($pageID, $parentID, $page, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('page_saved', 'pages'));
     router::redirect('cp/content/pages/edit/' . $parentID . '/' . $pageID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:45,代码来源:pages.php

示例5: _saveAlbum

 protected function _saveAlbum($albumID, $album, $fields)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'), 'privacy' => array('rules' => 'intval'), 'public' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extras
     $extra = array();
     $extra['comments'] = config::item('picture_comments', 'pictures') && config::item('picture_privacy_comments', 'pictures') ? (int) input::post('comments') : 1;
     $extra['privacy'] = config::item('album_privacy_view', 'pictures') ? (int) input::post('privacy') : 1;
     $extra['public'] = config::item('album_privacy_public', 'pictures') ? (int) input::post('public') : 1;
     // Save album
     if (!($albumID = $this->pictures_albums_model->saveAlbumData($albumID, 0, $album, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('album_saved', 'pictures', array(), array('%1' => html_helper::anchor('cp/plugins/pictures/albums/edit/' . $albumID, '\\1'), '%2' => html_helper::anchor('cp/plugins/pictures/browse/' . $albumID, '\\1'))));
     router::redirect('cp/plugins/pictures/albums/edit/' . $albumID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:28,代码来源:albums.php

示例6: _saveMessage

 protected function _saveMessage($messageID, $message)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array('message' => array('label' => __('message', 'messages'), 'rules' => array('trim', 'required')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get input data
     $body = input::post('message');
     // Save message
     if (!($messageID = $this->messages_model->saveMessage($messageID, $message['conversation_id'], $body))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('message_saved', 'messages'));
     router::redirect('cp/plugins/messages/edit/' . $messageID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:27,代码来源:messages.php

示例7: _savePicture

 protected function _savePicture($pictureID, $adID, $picture, $ad, $fields)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Validate form values
     if (!$this->fields_model->validateValues($fields)) {
         return false;
     }
     // Extras
     $extra = array();
     $extra['active'] = (int) input::post('active');
     // Save picture
     if (!($pictureID = $this->classifieds_pictures_model->savePictureData($pictureID, $adID, $picture, $ad, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('picture_saved', 'classifieds'));
     router::redirect('cp/plugins/classifieds/pictures/edit/' . $adID . '/' . $pictureID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:24,代码来源:pictures.php

示例8: vote

 public function vote()
 {
     // Is user logged in?
     if (!users_helper::isLoggedin()) {
         view::ajaxError(__('no_login', 'system_info'), 403);
     }
     // Get vars
     $resource = input::post_get('resource');
     $itemID = (int) input::post_get('item_id');
     $score = (int) input::post_get('score');
     // Get resource ID
     $resourceID = config::item('resources', 'core', $resource, 'resource_id');
     if (!$resourceID || !$itemID || $score < 1 || $score > 5) {
         return false;
     }
     // Load votes model
     loader::model('comments/votes');
     // Get resource item and vote if exists
     $item = $this->votes_model->getResourceVote($resource, $itemID);
     // Do resource or vote exist?
     if (!$item || $item['post_date']) {
         return false;
     }
     // Save vote
     if (!$this->votes_model->saveVote($resource, isset($item['user_id']) ? $item['user_id'] : 0, $itemID, $score)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     $rating = number_format(($item['total_score'] + $score) / ($item['total_votes'] + 1), 2);
     $params = array('resource' => $resource, 'itemID' => $itemID, 'votes' => $item['total_votes'] + 1, 'score' => $item['total_score'], 'rating' => $rating, 'voted' => $score, 'date' => date_helper::now());
     $output = view::load('comments/rating', $params, true);
     view::ajaxResponse($output);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:35,代码来源:comments.php

示例9: _saveBanner

 protected function _saveBanner($groupID, $bannerID, $bannerOld)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array('name' => array('label' => __('name', 'system'), 'rules' => array('trim', 'required', 'max_length' => 255)), 'keyword' => array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'max_length' => 128, 'alpha_dash', 'strtolower', 'callback__is_unique_keyword' => array($groupID, $bannerID))), 'code' => array('label' => __('banner_code', 'banners'), 'rules' => array('trim', 'required')), 'count_views' => array('label' => __('banner_count_views', 'banners'), 'rules' => array('trim', 'intval')), 'total_views' => array('label' => __('banner_views', 'banners'), 'rules' => array('trim', 'intval')), 'count_clicks' => array('label' => __('banner_count_clicks', 'banners'), 'rules' => array('trim', 'intval')), 'total_clicks' => array('label' => __('banner_clicks', 'banners'), 'rules' => array('trim', 'intval')), 'secure_mode' => array('label' => __('banner_secure_mode', 'banners'), 'rules' => array('trim', 'intval')), 'active' => array('label' => __('active', 'system'), 'rules' => array('trim', 'intval')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Banner data
     $bannerData = input::post(array('name', 'keyword', 'code', 'count_views', 'total_views', 'count_clicks', 'total_clicks', 'secure_mode', 'active'));
     $bannerData['group_id'] = $groupID;
     // Save banner
     if (!($bannerID = $this->banners_model->saveBanner($groupID, $bannerID, $bannerData))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('banner_saved', 'banners'));
     router::redirect('cp/content/banners/edit/' . $groupID . '/' . $bannerID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:28,代码来源:banners.php

示例10: _saveMessage

 protected function _saveMessage($conversationID, $conversation)
 {
     // Are we allowed to reply?
     if ($conversation['user_id'] == session::item('user_id') && !session::permission('messages_reply', 'messages') || !in_array($conversation['users'][$conversation['user_id']]['group_id'], session::permission('messages_reply', 'messages'))) {
         view::setError(__('no_action', 'system'));
         return false;
     } 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'))));
         return false;
     }
     // Create rules
     $rules = array('message' => array('label' => __('message', 'messages'), 'rules' => array('trim', 'required', 'callback__is_messages_delay')));
     // Do we have character limit?
     if (session::permission('messages_characters_limit', 'messages')) {
         $rules['message']['rules']['max_length'] = session::permission('messages_characters_limit', 'messages');
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get input data
     $message = input::post('message');
     // Save message
     if (!($messageID = $this->messages_model->saveMessage(0, $conversationID, $message, $conversation['recipients']))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Create email replacement tags
     $tags = array();
     foreach (session::section('session') as $key => $value) {
         $tags['from.' . $key] = $value;
     }
     $tags['conversation_link'] = config::siteURL('messages/view/' . $conversationID);
     // Send new private message email
     loader::library('email');
     foreach ($conversation['users'] as $user) {
         if ($user['user_id'] != session::item('user_id') && (!isset($user['config']['notify_messages']) || $user['config']['notify_messages'])) {
             $this->email->sendTemplate('messages_new', $user['email'], array_merge($tags, $user), $user['language_id']);
         }
     }
     // Success
     view::setInfo(__('message_sent', 'messages'));
     router::redirect('messages/view/' . $conversationID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:48,代码来源:messages.php

示例11: _saveMessage

 protected function _saveMessage($userID)
 {
     // Is user logged in?
     if (!users_helper::isLoggedin()) {
         return false;
     }
     if ($userID) {
         // Get user
         if (!($user = $this->users_model->getUser($userID)) || !$user['active'] || !$user['verified']) {
             return false;
         }
         // 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'))) {
             return false;
         } elseif (!$this->users_model->getPrivacyAccess($user['user_id'], isset($user['config']['privacy_profile']) ? $user['config']['privacy_profile'] : 1)) {
             return false;
         } elseif (!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)) {
             return false;
         }
     } else {
         $userID = session::item('user_id');
     }
     // Load messages model
     loader::model('timeline/messages', array(), 'timeline_messages_model');
     // Create rules
     $rules = array('message' => array('label' => __('message', 'timeline'), 'rules' => array('trim', 'required', 'min_length' => config::item('message_min_length', 'timeline'), 'max_length' => config::item('message_max_length', 'timeline'), 'callback__is_messages_delay')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         $output = view::load('timeline/post', array('user' => $user), true);
         view::ajaxError($output);
     }
     // Get message
     $message = input::post('message');
     // Save message
     if (!($messageID = $this->timeline_messages_model->saveMessage(0, $message, $userID))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     $actions = $this->timeline_model->getActions($userID, 0, 0, 1);
     $output = view::load('timeline/actions', array('actions' => $actions), true);
     view::ajaxResponse($output);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:46,代码来源:timeline.php

示例12: _savePicture

 protected function _savePicture($pictureID, $adID, $picture, $ad, $fields)
 {
     // Create rules
     $rules = array();
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extras
     $extra = array();
     // Save picture
     if (!($pictureID = $this->classifieds_pictures_model->savePictureData($pictureID, $adID, $picture, $ad, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('picture_saved', 'classifieds'));
     router::redirect('classifieds/pictures/edit/' . $adID . '/' . $pictureID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:21,代码来源:pictures.php

示例13: _saveEntry

 protected function _saveEntry($newsID, $news, $fields)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'), 'likes' => array('rules' => 'intval'), 'votes' => array('rules' => 'intval'), 'active' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extras
     $extra = array();
     $extra['comments'] = config::item('news_comments', 'news') ? (int) input::post('comments') : 1;
     $extra['likes'] = config::item('news_rating', 'news') == 'likes' ? (int) input::post('likes') : 1;
     $extra['votes'] = config::item('news_rating', 'news') == 'stars' ? (int) input::post('votes') : 1;
     $extra['active'] = (int) input::post('active');
     // Save news
     if (!($newsID = $this->news_model->saveEntryData($newsID, $news, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('entry_saved', 'news'));
     router::redirect('cp/content/news/edit/' . $newsID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:29,代码来源:news.php

示例14: _saveAd

 protected function _saveAd($adID, $ad, $fields)
 {
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extra fields
     $extra = array();
     $extra['comments'] = config::item('ad_comments', 'classifieds') && config::item('ad_privacy_comments', 'classifieds') ? (int) input::post('comments') : 1;
     // Save ad
     if (!($adID = $this->classifieds_model->saveAdData($adID, session::item('user_id'), $ad, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('ad_saved', 'classifieds'));
     router::redirect('classifieds/edit/' . $adID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:22,代码来源:classifieds.php

示例15: _saveBlog

 protected function _saveBlog($blogID, $blog, $fields)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'), 'privacy' => array('rules' => 'intval'), 'public' => array('rules' => 'intval'), 'active' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extras
     $extra = array();
     $extra['comments'] = config::item('blog_comments', 'blogs') && config::item('blog_privacy_comments', 'blogs') ? (int) input::post('comments') : 1;
     $extra['privacy'] = config::item('blog_privacy_view', 'blogs') ? (int) input::post('privacy') : 1;
     $extra['public'] = config::item('blog_privacy_public', 'blogs') ? (int) input::post('public') : 1;
     $extra['active'] = (int) input::post('active');
     // Save blog
     if (!($blogID = $this->blogs_model->saveBlogData($blogID, 0, $blog, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('blog_saved', 'blogs'));
     router::redirect('cp/plugins/blogs/edit/' . $blogID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:29,代码来源:blogs.php


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