コード例 #1
0
 public function test_should_bind_sql_bind_in_using_active_records()
 {
     $Tag = new Tag();
     $Tag->create(array('name' => 'Tag 1'));
     $Tag->create(array('name' => 'Tag 2'));
     $this->assertTrue($Tags = $Tag->find(array('conditions' => array('name IN (?)', $Tag->find()))));
     $this->assertEqual($Tags[0]->name, 'Tag 1');
     $this->assertEqual($Tags[1]->name, 'Tag 2');
 }
コード例 #2
0
ファイル: post.php プロジェクト: xfra35/fabulog
 /**
  * set and add new tags to the post entity
  * @param string $val
  * @return array
  */
 public function set_tags($val)
 {
     if (!empty($val)) {
         $tagsArr = \Base::instance()->split($val);
         $tag_res = new Tag();
         $tags = array();
         // find IDs of known Tags
         $known_tags = $tag_res->find(array('title IN ?', $tagsArr));
         if ($known_tags) {
             foreach ($known_tags as $tag) {
                 $tags[$tag->_id] = $tag->title;
             }
             $newTags = array_diff($tagsArr, array_values($tags));
         } else {
             $newTags = $tagsArr;
         }
         // create remaining new Tags
         foreach ($newTags as $tag) {
             $tag_res->reset();
             $tag_res->title = $tag;
             $out = $tag_res->save();
             $tags[$out->_id] = $out->title;
         }
         // set array of IDs to current Post
         $val = array_keys($tags);
     }
     return $val;
 }
コード例 #3
0
ファイル: Description.php プロジェクト: puttyplayer/CSGOShop
 public static function add($id, $meta)
 {
     $desc = Description::create(['id' => $id, 'name' => $meta->name, 'market_name' => $meta->market_name ?: $meta->name, 'icon_url' => $meta->icon_url, 'icon_url_large' => isset($meta->icon_url_large) ? $meta->icon_url_large : '', 'name_color' => $meta->name_color ?: '000000']);
     if (!empty($meta->actions)) {
         foreach ($meta->actions as $idx => $action) {
             if ($action->name == 'Inspect in Game...') {
                 $desc->inspect_url_template = $action->link;
                 $desc->save();
                 break;
             }
         }
     }
     foreach ($meta->tags as $idx => $tag_data) {
         $tag = Tag::find('all', array('conditions' => array('category = ? AND category_name = ? AND internal_name = ? AND name = ?', $tag_data->category, $tag_data->category_name, $tag_data->internal_name, $tag_data->name)));
         if (empty($tag)) {
             $tag = new Tag(['category' => $tag_data->category, 'category_name' => $tag_data->category_name, 'internal_name' => $tag_data->internal_name, 'name' => $tag_data->name]);
             if (!$tag->is_valid()) {
                 $desc->delete();
                 return null;
             } else {
                 $tag->save();
             }
         } else {
             $tag = $tag[0];
         }
         if ($tag_data->category == 'Rarity') {
             $desc->name_color = $tag_data->color;
             $desc->save();
         }
         Descriptiontag::create(['description_id' => $desc->id, 'tag_id' => $tag->id]);
     }
     return $desc;
 }
コード例 #4
0
 public function tags($id)
 {
     $tag = Tag::find($id);
     $posts = $tag->posts()->get();
     $tags = Tag::with('posts')->paginate(8);
     return View::make('search', compact('posts', 'tags'));
 }
コード例 #5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // get POST data
     $input = Input::all();
     // set validation rules
     $rules = array('title' => 'required', 'text' => 'required', 'image' => 'required');
     // validate input
     $validation = Validator::make($input, $rules);
     // if validation fails, return the user to the form w/ validation errors
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         // create new Post instance
         $post = Post::create(array('title' => $input['title']));
         // create Text instance w/ text body
         $text = Text::create(array('text' => $input['text']));
         // save new Text and associate w/ new post
         $post->text()->save($text);
         // create the new Image
         $image = Image::create(array('url' => $input['image']));
         // save new Text and associate w/ new post
         $post->image()->save($image);
         if (isset($input['tags'])) {
             foreach ($input['tags'] as $tagId) {
                 $tag = Tag::find($tagId);
                 $post->tags()->save($tag);
             }
         }
         // associate the post with the current user
         $post->author()->associate(Auth::user())->save();
         // redirect to newly created post page
         return Redirect::route('post.show', array($post->id));
     }
 }
コード例 #6
0
ファイル: TagAlias.php プロジェクト: JCQS04/myimouto
 public function alias_name()
 {
     if ($this->alias_name === null) {
         $this->alias_name = Tag::find($this->alias_id)->name;
     }
     return $this->alias_name;
 }
コード例 #7
0
ファイル: Template.php プロジェクト: minnb/vitduct
 public static function getPostByTag($tag_id)
 {
     $tagData = Tag::find($tag_id);
     if ($tagData) {
         $data = DB::select(" SELECT * FROM posts WHERE id IN (SELECT post_id FROM post_tags WHERE tag_id = {$tag_id}) ");
     }
     return $data;
 }
コード例 #8
0
ファイル: TagController.php プロジェクト: urashima82/intranet
 /**
  * Verify if exist
  */
 private function dataExist($id)
 {
     $data = Tag::find($id);
     if (!$data) {
         return Redirect::route('tag_list')->with('mError', 'Ce tag est introuvable !');
     } else {
         return $data;
     }
 }
コード例 #9
0
 public function createPostAction()
 {
     if ($this->request->isPost()) {
         $post = new Post();
         $post->topic = $this->request->getPost('title');
         $post->content = str_replace('</div>', '\\n', str_replace('<div>', '', $this->request->getPost('post')));
         $post->is_service = $this->request->getPost('is_service');
         $post->created_at = date('d.m.Y, h:i');
         if ($post->save()) {
             $tt = explode(',', $this->request->getPost('tags'));
             foreach ($tt as $t) {
                 $tag = Tag::findFirst(array('conditions' => 'name = ?1', 'bind' => array(1 => $t)));
                 if ($tag) {
                     $tag_post = new PostTag();
                     $tag_post->post_id = $post->id;
                     $tag_post->tag_id = $tag->id;
                     if (!$tag_post->save()) {
                         message($this, 'd', 'Ошибка привязки категории к посту');
                         return $this->response->redirect();
                     }
                 } else {
                     $tag = new Tag();
                     $tag->name = $t;
                     if ($tag->save()) {
                         $tag_post = new PostTag();
                         $tag_post->post_id = $post->id;
                         $tag_post->tag_id = $tag->id;
                         if (!$tag_post->save()) {
                             message($this, 'd', 'Ошибка привязки категории к посту');
                             return $this->response->redirect();
                         }
                     } else {
                         message($this, 'd', 'Ошибка сохранения новой категории');
                         return $this->response->redirect();
                     }
                 }
             }
             message($this, 's', 'Новость успешно добавлена');
             return $this->response->redirect();
         } else {
             foreach ($post->getMessages() as $message) {
                 message($this, "d", "Ошибка: " . $message->getMessage() . " в поле " . $message->getField() . ". Тип: " . $message->getType());
             }
             return $this->response->redirect();
         }
     } else {
         $this->assets->collection('headerJs')->addJs("js/jquery-ui.min.js");
         $this->assets->collection('headerCss')->addCss("css/jquery-ui.min.css")->addCss("css/jquery-ui.structure.min.css");
         $tt = Tag::find();
         $tags = "";
         foreach ($tt as $tag) {
             $tags .= '"' . $tag->name . '", ';
         }
         $tags = substr($tags, 0, -2);
         $this->view->setParamToView('tags', $tags);
     }
 }
コード例 #10
0
ファイル: TagsController.php プロジェクト: vanderlin/halp
 public function destroy($id)
 {
     $tag = Tag::find($id);
     $tag->delete();
     if ($tag == null) {
         return $this->statusResponse(['error' => 'No Tag found']);
     }
     return $this->statusResponse(['notice' => 'Tag deleted', 'tag' => $tag]);
 }
コード例 #11
0
 function approve($user_id, $ip_addr)
 {
     DB::update("tag_implications SET is_pending = FALSE WHERE id = {$this->id}");
     $t = Tag::find($this->predicate_id);
     $implied_tags = implode(' ', self::with_implied(array($t->name)));
     foreach (Post::find('all', array('conditions' => array("id IN (SELECT pt.post_id FROM posts_tags pt WHERE pt.tag_id = ?)", $t->id))) as $post) {
         $post->update_attributes(array('tags' => $post->tags . " " . $implied_tags, 'updater_user_id' => $user_id, 'updater_ip_addr' => $ip_addr));
     }
 }
コード例 #12
0
ファイル: TagImplication.php プロジェクト: JCQS04/myimouto
 public function approve($user_id, $ip_addr)
 {
     self::connection()->executeSql("UPDATE tag_implications SET is_pending = FALSE WHERE id = " . $this->id);
     $t = Tag::find($this->predicate_id);
     $implied_tags = implode(' ', self::with_implied(array($t->name)));
     foreach (Post::where("id IN (SELECT pt.post_id FROM posts_tags pt WHERE pt.tag_id = ?)", $t->id)->take() as $post) {
         $post->updateAttributes(array('tags' => $post->cached_tags . " " . $implied_tags, 'updater_user_id' => $user_id, 'updater_ip_addr' => $ip_addr));
     }
 }
コード例 #13
0
 function test_should_store_zero_strings_as_intergers()
 {
     $Tag = new Tag(array('name' => 'Ticket #21'));
     $this->assertTrue($Tag->save());
     $this->assertEqual($Tag->get('score'), 100);
     $Tag->setAttributes(array('score' => '0'));
     $this->assertTrue($Tag->save());
     $Tag =& $Tag->find($Tag->id);
     $this->assertIdentical($Tag->get('score'), 0);
 }
コード例 #14
0
function tag_links($tags, $options = array())
{
    if (!$tags) {
        return null;
    }
    $prefix = !empty($options['prefix']) ? $options['prefix'] : '';
    if (is_string($tags)) {
        $tags = explode(' ', $tags);
        $tags = Tag::find(array('conditions' => array('name in (??)', $tags), 'select' => 'name, tag_type, post_count'));
    } elseif (is_array($tags)) {
        if (is_indexed_arr($tags) && count(current($tags)) == 2) {
            # We're getting a tag's cached_related tags. We need to find the tag type.
            $i = 0;
            $t = array();
            foreach ($tags as $tag) {
                $t[] = array('name' => current($tag), 'type' => Tag::type_name_helper(current($tag)), 'post_count' => end($tag));
            }
        } else {
            # We're getting a post's cached_tags. We need to find the count for each tag.
            $names = array_keys($tags);
            # We may have a misstyped metatag. Better return.
            if (!isset($names[0]) || !is_string($names[0])) {
                return;
            }
            $count = Tag::find_post_count_and_name('all', array('conditions' => array('name in (??)', $names), 'order' => 'name', 'return_array' => true));
            // vde($count);
            $i = 0;
            # There's a possibility a tag was deleted and cached_tags wasn't updated.
            # This will cause errors, so we'll just skip tags that weren't found.
            $t = array();
            foreach ($count as $tag) {
                $t[] = array('name' => $tag['name'], 'type' => $tags[$tag['name']], 'post_count' => $tag['post_count']);
            }
        }
        $tags = $t;
        unset($t);
    } elseif (is_a($tags, 'Tag')) {
        //
    }
    $tag_query = !empty(Request::$params->tags) ? Request::$params->tags : null;
    $html = '';
    foreach ($tags as $tag) {
        list($name, $type, $count) = array_values($tag);
        if (ctype_digit($type)) {
            $type = Tag::type_name($type);
        }
        $html .= '<li class="tag-type-' . $type . '"><a href="/tag?name=' . $name . '">?</a>';
        if (User::is('>=30')) {
            $html .= ' <a href="/post?tags=' . $name . '+' . $tag_query . '">+</a> <a href="/post?tags=-' . $name . $tag_query . '">&ndash;</a>';
        }
        $hover = !empty($options['with_hover_highlight']) ? " onmouseover='Post.highlight_posts_with_tag(\"{$name}\")' onmouseout='Post.highlight_posts_with_tag(null)'" : '';
        $html .= ' <a href="/post?tags=' . $name . '"' . $hover . '>' . str_replace('_', ' ', $name) . '</a> <span class="post-count">' . $count . '</span></li>';
    }
    return $html;
}
コード例 #15
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $this->tag = Tag::find($id);
     $this->tag->fill(Input::all());
     if (!$this->tag->valid()) {
         return Redirect::back()->withInput()->with('errors', $this->tag->errors);
     } else {
         $this->tag->update();
         return Redirect::route('projects.index');
     }
 }
コード例 #16
0
ファイル: Tag.php プロジェクト: vanderlin/halp
 public static function getTop($max = 5)
 {
     $tags = DB::table('taggables')->groupBy('tag_id')->orderBy('count', 'DESC')->get(array('tag_id', DB::raw('count(*) as count')));
     $tags = array_slice($tags, 0, $max);
     $objs = [];
     foreach ($tags as $tag) {
         $t = Tag::find($tag->tag_id);
         $t->count = $tag->count;
         array_push($objs, $t);
     }
     return $collection = new Illuminate\Support\Collection($objs);
 }
コード例 #17
0
 /**
  * Process the "Add a book form"
  * @return Redirect
  */
 public function postCreate()
 {
     # Instantiate the book model
     $book = new Book();
     $book->fill(Input::except('tags'));
     # Note this save happens before we enter any tags (next step)
     $book->save();
     foreach (Input::get('tags') as $tag) {
         # This enters a new row in the book_tag table
         $book->tags()->save(Tag::find($tag));
     }
     return Redirect::action('BookController@getIndex')->with('flash_message', 'Your book has been added.');
 }
コード例 #18
0
ファイル: tags.php プロジェクト: eliasyanni/bugs
 public function post_edit($tag_id)
 {
     $tag = Tag::find($tag_id);
     $rules = array('tag' => 'unique:tags,tag,' . $tag_id . '|required|max:255', 'bgcolor' => array('max:50', 'match:/^#(?:[0-9a-f]+)$/i'));
     $input = Input::all();
     $validator = \Validator::make($input, $rules);
     if ($validator->passes()) {
         $tag->tag = $input['tag'];
         $tag->bgcolor = $input['bgcolor'];
         $tag->save();
         return Redirect::to('tags')->with('notice', __('tinyissue.tag_has_been_updated'));
     }
     return Redirect::to('tag/' . $tag_id . '/edit')->with_input()->with_errors($validator)->with('notice-error', __('tinyissue.we_have_some_errors'));
 }
コード例 #19
0
ファイル: Book.php プロジェクト: rebekahheacock/dwa15-archive
 /**
  * This array will compare an array of given tags with existing tags
  * and figure out which ones need to be added and which ones need to be deleted
  * In most cases $new is post input from a bunch of checkboxes, ex: $_POST['tags']
  */
 public function updateTags($new = array())
 {
     // Go through new tags to see what ones need to be added
     foreach ($new as $tag) {
         if (!$this->tags->contains($tag)) {
             $this->tags()->save(Tag::find($tag));
         }
     }
     // Go through existing tags and see what ones need to be deleted
     foreach ($this->tags as $tag) {
         if (!in_array($tag->pivot->tag_id, $new)) {
             $this->tags()->detach($tag->id);
         }
     }
 }
コード例 #20
0
ファイル: default_controller.php プロジェクト: fchaose/qeephp
 /**
  * 默认页面
  */
 function actionIndex()
 {
     if ($this->context->tag) {
         $tag = Tag::find('label = ?', rawurldecode($this->context->tag))->query();
         if ($tag->id()) {
             $this->view['current_tag'] = $tag;
             $this->view['posts'] = $tag->posts;
             $this->context->setParam('current_tag', $tag);
         }
     }
     if (!isset($this->view['posts'])) {
         $this->view['posts'] = Post::find()->order('created DESC')->all()->query();
     }
     $this->context->setParam('current_location', 'index');
 }
コード例 #21
0
 public function browseItems($app)
 {
     $request = $app->router->flight->request();
     $categories = array();
     $categories = Tag::find('all', array('select' => 'DISTINCT category, category_name', 'conditions' => array('category NOT IN (?)', array('ItemSet', 'Weapon', 'Tournament', 'TournamentTeam'))));
     $tags = Tag::find('all');
     $query_string = '';
     foreach ($request->query as $idx => $val) {
         $query_string .= '&' . $idx . '=' . urlencode($val);
     }
     $app->output->addBreadcrumb('', 'CSGOShop');
     $app->output->addBreadcrumb('browse', 'Browse Items');
     $app->output->setTitle('Browse Items');
     $app->output->setActiveTab('browse');
     $app->output->render('shop.browse', ['categories' => $categories, 'tags' => $tags, 'query_string' => $query_string, 'query' => $request->query]);
 }
コード例 #22
0
ファイル: Tag.php プロジェクト: minnb/vitduct
 public static function makeListTagByPage($page_id)
 {
     $tags = Post_Tag::where('post_id', $page_id)->get();
     $arr_tag = "";
     foreach ($tags as $k => $item) {
         $arr_tag[$k] = $item->tag_id;
     }
     $arr_alias = "";
     $arr_tags = "";
     if ($arr_tag != "") {
         foreach ($arr_tag as $k => $value) {
             $tag_id = $value;
             $arr_tags[$k] = Tag::find($tag_id)->tag;
         }
     }
     return $arr_tags;
 }
コード例 #23
0
 public function filter($route, $request)
 {
     if (!isset($this->user) || !$this->user || $this->user == parent::ANONYMOUS_USER) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
     if (!$this->user->hasRole('admin')) {
         return Response::json(['error' => true, 'error_description' => 'Only admin can run this service'], 401);
     }
     if (!$this->user->can('tag_delete')) {
         return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
     }
     $id = Request::segment(3);
     $tag = Tag::find($id);
     if (!$tag) {
         return Response::json(['error' => true, 'error_description' => 'Tag not found'], 400);
     }
 }
コード例 #24
0
ファイル: tags.php プロジェクト: gischen/PHP-CMS
 function post_add()
 {
     if (!cmsHelper::isCurrentUserAllowedToPerform('tags')) {
         return;
     }
     //Flash current values to session
     Input::flash();
     //Same action is used for editing and adding a new category
     $tag_title = Input::get("tagName");
     $tag_url = Input::get("tagNameUrl");
     $saving_id = Input::get('editingMode');
     //Add rules here
     $rules = array('tagName' => 'required|max:100', 'tagNameUrl' => 'required');
     //Get all inputs fields
     $input = Input::all();
     //Apply validaiton rules
     $validation = Validator::make($input, $rules);
     $checkIfTagExists = Tag::where('id', '!=', $saving_id)->where('turl', '=', $tag_url)->count();
     //Check if same tag exists
     if ($checkIfTagExists > 0) {
         return Redirect::to('/admin/tags/add')->with("errormessage", "Tag with the same url already exists");
     }
     //Validate rules
     if ($validation->fails()) {
         return Redirect::to('/admin/tags/add')->with_errors($validation);
     }
     $temp = !empty($saving_id) ? Tag::find($saving_id) : new Tag();
     $temp->turl = $tag_url;
     $temp->tname = $tag_title;
     $temp->save();
     Input::flush();
     if (!empty($saving_id)) {
         return Redirect::to('/admin/tags/edit?id=' . $saving_id)->with('successmessage', "Tag Edited successfully");
     } else {
         return Redirect::to('/admin/tags/add')->with("successmessage", "New Tag Added successfully");
     }
 }
コード例 #25
0
 /**
  * Show the form for editing the specified tag.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $tag = Tag::find($id);
     return View::make('tags.edit', compact('tag'));
 }
コード例 #26
0
ファイル: AdminProjectController.php プロジェクト: bktz/cup
 /**
  * Update the specified resource in storage.
  *
  * @param  Project  $project
  * @return Response
  */
 public function update($project)
 {
     $input = Input::all();
     $project->title = $input['title'];
     $project->contact_firstname = $input['contact_firstname'];
     $project->contact_lastname = $input['contact_lastname'];
     $project->contact_email = $input['contact_email'];
     $project->contact_phone_number = $input['contact_phone_number'];
     $project->contact_phone_number_ext = $input['contact_phone_number_ext'];
     $project->description = $input['description'];
     $project->location = $input['location'];
     $project->expected_time = $input['expected_time'];
     $project->motivation = $input['motivation'];
     $project->resources = $input['resources'];
     $project->constraints = $input['constraints'];
     $project->state = $input['state'];
     $input['tags'] = isset($input['tags']) ? $input['tags'] : array();
     //verify that there are some goals and tags in the $input
     $input['goals'] = isset($input['goals']) ? $input['goals'] : array();
     if ($project->update()) {
         // Delete project goals and then re-create them
         $project->goals()->delete();
         $loop_index = 0;
         foreach ($input['goals'] as $goal) {
             //Ignore empty goals
             if ($goal == '') {
                 $loop_index++;
                 continue;
             } else {
                 $goalObj = new Goal();
                 $goalObj->goal = $goal;
                 // The completed variable posted is an array containing the indexes for the goals that are marked as complete
                 // This will swap the array's index  with the value (ie. [0] => a, [1] => b will become [a] => 0, [b] => 1)
                 // This then allows us to see if the current loop index has a goal that is complete without needing to use a for loop
                 $completed = isset($input['completed']) ? array_flip($input['completed']) : array();
                 if (isset($completed[$loop_index])) {
                     $goalObj->complete = 1;
                 } else {
                     $goalObj->complete = 0;
                 }
                 $project->goals()->save($goalObj);
             }
             $loop_index++;
         }
         // Delete project tags and then re-create them
         $project->tags()->detach();
         foreach ($input['tags'] as $tag) {
             if ($tag == '') {
                 continue;
             } else {
                 $tagObj = Tag::find($tag);
                 $project->tags()->attach($tagObj);
             }
         }
         return Redirect::to('/admin/project/' . $project->id . '/edit')->with('info', 'The project has been updated.');
     } else {
         return Redirect::to('/admin/project/' . $project->id . '/edit')->withErrors($project->errors());
     }
 }
コード例 #27
0
ファイル: TagController.php プロジェクト: rhalff/vdragon-api
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $tag = Tag::find($id);
     $tag->delete();
     return Response::json(array('success_code' => 'OK', 'success_message' => 'Tag has been successfully deleted'), 200);
 }
コード例 #28
0
ファイル: tags.php プロジェクト: ferdinal/GulingCMS
            $tags = Post_to_tag::all(array('post_id' => $post->id));
            ?>

                        <?php 
            if ($tags) {
                ?>
                            <span class="small with-tags label label-info">
                                <span class="category-titles">Tags :</span>
                                <?php 
                foreach ($tags as $tag) {
                    ?>
                                    <a href="<?php 
                    echo base_url('web/tags/' . Tag::find($tag->tag_id)->slug);
                    ?>
"><?php 
                    echo Tag::find($tag->tag_id)->title;
                    ?>
</a> 
                                <?php 
                }
                ?>
   
                            </span>
                        <?php 
            }
            ?>



                    </div>
                    <div class="panel-footer">
コード例 #29
0
 public function nest($tagId, $parentTagId)
 {
     $tag = Tag::find($tagId);
     //cannot nest a tag in itself.
     if (is_null($tag) || $tag->user_id != Auth::user()->id || $tagId == $parentTagId) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
     }
     $parentTag = Tag::find($parentTagId);
     //if trying to nest in an unexisting tag, then tag is unnested.
     if (is_null($parentTag)) {
         $tag->parent_id = NULL;
         $tag->save();
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $tagId);
     }
     if ($parentTag->user_id != Auth::user()->id) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
     }
     //cannot nest a tag with children, cannot nest into a tag with parents
     if (count($tag->children()->get()) > 0 || count($parentTag->parents()->get()) > 0) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array());
     }
     $tag->parents()->associate($parentTag);
     $tag->save();
     return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $tagId);
 }
コード例 #30
0
ファイル: q2a.php プロジェクト: Osin/Intranet
<?php

include '../../inc/init.inc';
if (isset($tag)) {
    $conditions = array('id in (?)', Questions_Tag::find('all', array('conditions' => array('tag_id' => Tag::find_by_name($tag)->id)))->asQuestion_ID());
}
isset($conditions) ? $args['conditions'] = $conditions : ($args['conditions'] = 'title NOT LIKE ""');
$res->total = isset($args) ? Question::count($args) : Question::count();
$res->currentPage = isset($currentPage) ? $currentPage : 1;
$res->limit = $args['limit'] = isset($limit) ? $limit : 7;
$args['offset'] = ($res->currentPage - 1) * $args['limit'];
$args['order'] = isset($order) ? $order : 'created_at desc';
$res->questions = Question::all($args);
$res->tags = Tag::find('all', array('order' => 'Rand()', 'limit' => 20));
if (!isset($infos)) {
    $infos = array();
}
$res->search_opts = array(0 => array('label' => 'Quelle question vous posez vous ?', 'field' => 'title', 'type' => 'text', 'class' => 'xxlarge'));
$res->useTemplate("Questions - Reponses", $infos);