<?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);
<?php include '../../inc/init.inc'; if ((!isset($title) || $title == "") && !isset($question_id) || (!isset($content) || $content == "")) { $res->load('questions', array()); } else { if (isset($title)) { $args['title'] = $title; } if (isset($question_id)) { $args['question_id'] = $question_id; } $args['content'] = $content; $args['user_id'] = $res->user->id; $question = Question::create($args); if (isset($tag_list_values)) { $tags = explode(',', $tag_list_values); foreach ($tags as $tagName) { $tagName = strtoupper($tagName); if (Tag::exists(array('name' => $tagName))) { $tag = Tag::find_by_name($tagName); } else { $tag = Tag::create(array('name' => $tagName)); } Questions_Tag::create(array('question_id' => $question->id, 'tag_id' => $tag->id)); } } } $res->load('question', array('id' => $question->id));