本文整理汇总了PHP中Category_Model::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Category_Model::getAll方法的具体用法?PHP Category_Model::getAll怎么用?PHP Category_Model::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Category_Model
的用法示例。
在下文中一共展示了Category_Model::getAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* Show the profile of a group
*/
public function view($params)
{
$this->setView('view.php');
try {
$group = $this->model->getInfoByName($params['group']);
$this->set('group', $group);
} catch (Exception $e) {
throw new ActionException('Page', 'error404');
}
$this->setTitle(__('GROUP_TITLE', array('group' => htmlspecialchars($group['name']))));
$is_logged = isset(User_Model::$auth_data);
$is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
$is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
$category = isset($params['category']) ? $params['category'] : null;
$category_model = new Category_Model();
$post_model = new Post_Model();
$this->set(array('is_logged' => $is_logged, 'is_student' => $is_student, 'is_admin' => $is_admin, 'categories' => $category_model->getAll(), 'current_category' => $category, 'posts' => $post_model->getPosts(array('restricted' => true, 'group_id' => (int) $group['id'], 'category_name' => $category, 'official' => $is_logged ? null : true, 'show_private' => $is_student), Config::POST_DISPLAYED)));
// Events
$event_model = new Event_Model();
$this->set(array('events' => $event_model->getByMonth((int) date('Y'), (int) date('n'), array('group_id' => (int) $group['id'], 'official' => $is_logged ? null : true, 'show_private' => $is_student)), 'calendar_month' => (int) date('n'), 'calendar_year' => (int) date('Y')));
// If the user is logged
if ($is_logged) {
$this->set(array('username' => User_Model::$auth_data['username'], 'groups_auth' => Group_Model::getAuth()));
}
if ($is_student) {
$this->set(array('firstname' => User_Model::$auth_data['firstname'], 'lastname' => User_Model::$auth_data['lastname'], 'avatar_url' => User_Model::$auth_data['avatar_url']));
}
}
示例2: view
/**
* Show the profile of a student
*/
public function view($params)
{
$this->setView('view.php');
$is_logged = isset(User_Model::$auth_data);
$is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
$is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
// If the user isn't logged in
if (!$is_logged) {
throw new ActionException('User', 'signin', array('redirect' => $_SERVER['REQUEST_URI']));
}
try {
$student = $this->model->getInfo($params['username']);
$post_model = new Post_Model();
$this->setTitle(htmlspecialchars($student['firstname'] . ' ' . $student['lastname']));
$this->set(array('student' => $student, 'groups' => isset($student['id']) ? Group_Model::getAuth((int) $student['id']) : array(), 'is_owner' => User_Model::$auth_data['username'] == $student['username'], 'is_logged' => true, 'is_student' => $is_student, 'is_admin' => $is_admin, 'username' => User_Model::$auth_data['username']));
if ($is_student) {
$this->set(array('firstname' => User_Model::$auth_data['firstname'], 'lastname' => User_Model::$auth_data['lastname'], 'avatar_url' => User_Model::$auth_data['avatar_url']));
}
// If the student is a user, we show their posts
if (isset($student['id'])) {
$category = isset($params['category']) ? $params['category'] : null;
$category_model = new Category_Model();
$this->set(array('posts' => $post_model->getPosts(array('restricted' => true, 'user_id' => (int) $student['id'], 'category_name' => $category, 'official' => false, 'show_private' => $is_student), Config::POST_DISPLAYED), 'categories' => $category_model->getAll(), 'current_category' => $category));
}
} catch (Exception $e) {
throw new ActionException('Page', 'error404');
}
}
示例3: index
public function index($params)
{
$this->setView('index.php');
$is_logged = isset(User_Model::$auth_data);
$is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
$is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
$category = isset($params['category']) ? $params['category'] : null;
$category_model = new Category_Model();
$this->set(array('is_logged' => $is_logged, 'is_student' => $is_student, 'is_admin' => $is_admin, 'categories' => $category_model->getAll(), 'current_category' => $category));
// If the user is logged
if ($is_logged) {
$this->set(array('username' => User_Model::$auth_data['username'], 'groups_auth' => Group_Model::getAuth(), 'posts' => $this->model->getPosts(array('restricted' => true, 'official' => false, 'category_name' => $category, 'show_private' => $is_student), Config::POST_DISPLAYED)));
}
// If the user is a student
if ($is_student) {
$this->set(array('firstname' => User_Model::$auth_data['firstname'], 'lastname' => User_Model::$auth_data['lastname'], 'avatar_url' => User_Model::$auth_data['avatar_url']));
}
// Official posts
$this->set('official_posts', $this->model->getPosts(array('restricted' => true, 'official' => true, 'category_name' => $category, 'show_private' => $is_student), Config::POST_DISPLAYED));
// Events
$event_model = new Event_Model();
$this->set(array('events' => $event_model->getByMonth((int) date('Y'), (int) date('n'), array('official' => $is_logged ? null : true, 'show_private' => $is_student)), 'calendar_month' => (int) date('n'), 'calendar_year' => (int) date('Y')));
}
示例4: foreach
// Renvoi un login echec
$user = $xml->createElement('user');
$node = $xml->createElement('nom', "false");
$user->appendChild($node);
$node = $xml->createElement('prenom', "false");
$user->appendChild($node);
$node = $xml->createElement('student_number', "0");
$user->appendChild($node);
$node = $xml->createElement('avatar', "");
$user->appendChild($node);
$MainNode->appendChild($user);
}
if (isset($_GET['install']) && $_GET['install'] == "true") {
// Envoi des données de base pour l'installation sur l'appli
$Categories = new Category_Model();
$tableauDesCategories = $Categories->getAll();
foreach ($tableauDesCategories as $cat) {
$GroupXml = $xml->createElement('category');
$node = $xml->createElement('name', $cat['name']);
$GroupXml->appendChild($node);
$node = $xml->createElement('id', $cat['id']);
$GroupXml->appendChild($node);
$MainNode->appendChild($GroupXml);
}
}
// Lecture des posts demandés et
$model = new Post_Model();
// Parametres de base :
$postParam = array('restricted' => true, 'show_private' => true);
if (isset($_GET['id']) && $_GET['id'] != "-1") {
$postParam['id'] = $_GET['id'];