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


PHP ajax::success方法代码示例

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


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

示例1: action_files

 public function action_files()
 {
     $files = array();
     $limit = arr::get($_GET, 'limit', 10);
     $offset = arr::get($_GET, 'offset', 0);
     $query = ORM::factory('File');
     if (arr::get($_GET, 'tags', false)) {
         $tags = arr::get($_GET, 'tags');
         if (arr::get($_GET, 'matchAll', false) == "true") {
             $tagsquery = DB::select('files_tags.file_id')->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->group_by('files_tags.file_id')->having(DB::expr('COUNT(files_tags.file_id)'), '=', count($tags))->execute();
             //die(var_dump($tagsquery));
         } else {
             $tagsquery = DB::select('files_tags.file_id')->distinct(true)->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->execute();
             //die(var_dump($tagsquery));
         }
         if ((bool) $tagsquery->count()) {
             $ids = array();
             foreach ($tagsquery as $q) {
                 $ids[] = arr::get($q, 'file_id');
                 //$files[] = ORM::factory('File', arr::get($q, 'file_id'))->info();
             }
             $query = $query->where('id', 'IN', $ids);
         } else {
             // Empty resultset
             ajax::success('ok', array('files' => array()));
         }
     }
     $query = $query->order_by('created', 'DESC')->limit($limit)->offset($offset)->find_all();
     if ((bool) $query->count()) {
         foreach ($query as $file) {
             $files[] = $file->info();
         }
     }
     ajax::success('ok', array('files' => $files));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:35,代码来源:Filebrowser.php

示例2: action_create

 public function action_create()
 {
     try {
         user::create($_POST);
         ajax::success(__('User created'), array('redirect' => 'users'));
     } catch (ORM_Validation_Exception $e) {
         $errors = $e->errors('models');
         $errstr = array('<ul>');
         if ((bool) count($errors)) {
             foreach ($errors as $error) {
                 if (is_array($error)) {
                     foreach ($error as $err) {
                         $errstr[] = '<li>' . $err . '</li>';
                     }
                 } else {
                     $errstr[] = '<li>' . $error . '</li>';
                 }
             }
         }
         $errstr[] = '</li>';
         ajax::error(implode('', $errstr));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:25,代码来源:Users.php

示例3: action_get

 public function action_get()
 {
     $content = ORM::factory('Content')->order_by('hits', 'DESC')->limit(10)->find_all();
     $contents = array();
     if ((bool) $content->count()) {
         foreach ($content as $c) {
             $contents[] = array('id' => $c->id, 'title' => $c->title, 'type' => $c->contenttype->display, 'hits' => $c->hits);
         }
     }
     ajax::success('', array('contents' => $contents));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Popularcontent.php

示例4: action_get

 public function action_get()
 {
     $visitors = ORM::factory('Visitor')->find_all();
     $varray = array();
     if ((bool) $visitors->count()) {
         foreach ($visitors as $visitor) {
             $varray[] = $visitor->info();
         }
     }
     ajax::success('ok', array('visitors' => $varray));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Currentvisitors.php

示例5: action_get

 public function action_get()
 {
     $errors = ORM::factory('Error')->order_by('time', 'DESC')->limit(10)->find_all();
     $errs = array();
     if ((bool) $errors->count()) {
         foreach ($errors as $e) {
             $errs[] = array('id' => $e->id, 'type' => $e->type, 'ip' => $e->ip, 'when' => date('d/m/Y H:i', $e->time), 'url' => $e->url);
         }
     }
     ajax::success('', array('errors' => $errs));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Errorpages.php

示例6: action_delete

 public function action_delete()
 {
     $vacation = ORM::factory('Vacation', arr::get($_POST, 'id', ''));
     if (!$vacation->loaded()) {
         ajax::error('Ferien blev ikke fundet. Er den allerede blevet slettet?');
     }
     try {
         $vacation->delete();
         ajax::success();
     } catch (exception $e) {
         ajax::error('Der opstod en fejl: ' . $e->getMessage());
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:13,代码来源:Vacations.php

示例7: action_toggleread

 public function action_toggleread()
 {
     $message = ORM::factory('Message', arr::get($_POST, 'id'));
     if (!$message->loaded()) {
         ajax::error(__('The message wasn\'t found. Has it already been deleted?'));
     }
     $message->read = arr::get($_POST, 'read', '0');
     try {
         $message->save();
         ajax::success();
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:14,代码来源:Messages.php

示例8: action_getautosave

 public function action_getautosave()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $autosave = ORM::factory('Page')->where('user_id', '=', $user->id)->where('type', '=', 'autosave')->find();
     $content = '';
     if ($autosave->loaded() && $autosave->content != '') {
         $content = $autosave->decode($autosave->content);
         $autosave->delete();
     }
     ajax::success('', array('content' => $content, 'md5' => md5($content)));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:14,代码来源:Write.php

示例9: action_create

 public function action_create()
 {
     $role = ORM::factory('Role');
     $role->name = arr::get($_POST, 'name', false);
     if (!$role->name) {
         ajax::error(__('Enter a name to create a new role'));
     }
     $role->description = arr::get($_POST, 'description', '');
     try {
         $role->save();
         ajax::success('', array('role' => $role->info()));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:15,代码来源:Roles.php

示例10: action_get

 public function action_get()
 {
     $contenttype = ORM::factory('Contenttype', arr::get($_GET, 'id', ''));
     if (!$contenttype->loaded()) {
         ajax::error(__('Contenttype not found. Has it been deleted?'));
     }
     $items = array();
     $contents = $contenttype->contents->find_all();
     if ((bool) $contents->count()) {
         foreach ($contents as $content) {
             $items[] = array('id' => $content->id, 'title' => $content->title());
         }
     }
     ajax::success('', array('id' => $contenttype->id, 'type' => $contenttype->type, 'slug' => $contenttype->slug, 'icon' => $contenttype->icon, 'hierarchical' => $contenttype->hierarchical, 'has_categories' => $contenttype->has_categories, 'has_tags' => $contenttype->has_tags, 'has_timestamp' => $contenttype->has_timestamp, 'has_thumbnail' => $contenttype->has_thumbnail, 'has_author' => $contenttype->has_author, 'display' => $contenttype->display, 'items' => $items));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:15,代码来源:Contenttype.php

示例11: action_add

 public function action_add()
 {
     $title = arr::get($_POST, 'title', false);
     if (!$title || empty($title)) {
         ajax::error('A title is required');
     }
     $option = ORM::factory('Option');
     $option->optiongroup_id = arr::get($_POST, 'group');
     $option->title = $title;
     $option->key = arr::get($_POST, 'key', '');
     $option->type = arr::get($_POST, 'type', 'text');
     $option->description = arr::get($_POST, 'description', '');
     $option->editable = arr::get($_POST, 'editable', '1');
     try {
         $option->save();
         ajax::success('Option added', array('option' => $option->info()));
     } catch (exception $e) {
         ajax::error('Something went wrong: ' . $e->getMessage());
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:20,代码来源:Options.php

示例12: action_create

 public function action_create()
 {
     $content = ORM::factory('Content', arr::get($_POST, 'parent', ''));
     if (!$content->loaded()) {
         ajax::error('The content wasn\'t found. Has it been deleted?');
     }
     $title = arr::get($_POST, 'title', false);
     if (!$title) {
         $title = $content->title;
     }
     $clone = $content->copy();
     $clone->splittest = $content->id;
     $clone->splittest_title = $title;
     try {
         $clone->save();
         ajax::success('Splittest created', array('splittest' => array('id' => $clone->id, 'title' => $clone->splittest_title)));
     } catch (exception $e) {
         ajax::error('An error occurred and the splittest couldn\'t be created. The site said: ' . $e->getMessage());
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:20,代码来源:Splittest.php

示例13: action_info

 public function action_info()
 {
     maintenance::delete_inactive_visitors();
     $messages = 0;
     if (user::logged()) {
         $user = user::get();
         $messages += $user->messages->where('read', '=', '0')->count_all();
         $roles = $user->roles->find_all();
         $roleids = array();
         if ((bool) $roles->count()) {
             foreach ($roles as $role) {
                 $roleids[] = $role->id;
             }
         }
         if ((bool) count($roleids)) {
             $messages += ORM::factory('Message')->where('role_id', 'in', $roleids)->where('read', '=', '0')->where('user_id', '!=', $user->id)->count_all();
         }
     }
     ajax::success('', array('current_visitors' => $visitors = ORM::factory('Visitor')->count_all(), 'unread_messages' => $messages));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:20,代码来源:Site.php

示例14: action_takechallenge

 public function action_takechallenge()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in to sign up for the challenge!');
     }
     $user = user::get();
     if ($user->doing_challenge()) {
         ajax::error('You are already doing the challenge! Complete it first, then sign up again.');
     }
     $challenge = ORM::factory('User_Challenge');
     $challenge->user_id = $user->id;
     $challenge->start = $user->timestamp();
     $challenge->progress = 0;
     if ($user->wrote_today()) {
         $challenge->progress = 1;
     }
     $challenge->save();
     $user->add_event('Signed up for the 30 day challenge!');
     ajax::success('Awesome! You have signed up for the challenge! Good luck!', array('progress' => $challenge->progress));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:20,代码来源:Games.php

示例15: action_new

 public function action_new()
 {
     $contenttype = $this->check_contenttype();
     $content = ORM::factory('Content');
     $content->user_id = user::get()->id;
     $content->contenttype_id = $contenttype->id;
     $typeid = $this->request->param('typeid');
     $content->contenttypetype_id = isset($typeid) && !empty($typeid) ? $typeid : '0';
     $content->title = '';
     $content->status = 'draft';
     $content->created = time();
     try {
         $content->save();
         $blocks = $contenttype->blocktypes->where('min', '>', 0)->where('parent', '=', 0)->where('contenttypetype_id', '=', $content->contenttypetype_id)->find_all();
         if ((bool) $blocks->count()) {
             $loop = 0;
             foreach ($blocks as $block) {
                 for ($i = 0; $i < $block->min; $i++) {
                     $contentblock = ORM::factory('Block');
                     $contentblock->content_id = $content->id;
                     $contentblock->blocktype_id = $block->id;
                     $contentblock->order = $loop;
                     $contentblock->save();
                     $loop++;
                 }
             }
         }
         //cms::redirect('content/edit/'.$content->id);
         ajax::success('ok', array('id' => $content->id));
     } catch (HTTP_Exception_Redirect $e) {
         throw $e;
     } catch (exception $e) {
         notes::add('error', 'Der opstod en fejl: ' . $e->getMessage());
         echo 'error';
         //cms::redirect('content/index/'.$contenttype->id);
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:37,代码来源:Content.php


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