/** MODULE : Aperçu des données saisies */ public function data() { // Liste données saisies if ($this->getData([$this->getUrl(0), 'data'])) { // Crée une pagination (retourne la première news et dernière news de la page et la liste des pages $pagination = helper::pagination($this->getData([$this->getUrl(0), 'data']), $this->getUrl()); // Inverse l'ordre du tableau pour afficher les données en ordre décroissant $inputs = array_reverse($this->getData([$this->getUrl(0), 'data'])); // Check si l'id du premier résultat est paire $firstPair = $pagination['first'] % 2 === 0; // Crée l'affichage des données en fonction de la pagination for ($i = $pagination['first']; $i < $pagination['last']; $i++) { // Ouvre la row ouverte à chaque id paire/impaire (dépend du premier résultat) if ($firstPair and $i % 2 === 0 or !$firstPair and $i % 2 === 1) { self::$content .= template::openRow(); } // Formatage des données $content = ''; foreach ($inputs[$i] as $input => $value) { $content .= $input . ' : ' . $value . '<br>'; } self::$content .= template::background($content, ['col' => 6]); // Ferme la row ouverte à chaque id paire/impaire (dépend du premier résultat) ou pour le dernier champ if ($firstPair and $i % 2 === 1 or !$firstPair and $i % 2 === 0 or !isset($inputs[$i + 1])) { self::$content .= template::closeRow(); } } // Ajoute la liste des pages en dessous des news self::$content .= $pagination['pages']; } // Contenu de la page self::$content = template::title('Données saisies') . self::$content . template::openRow() . template::button('back', ['value' => 'Retour', 'href' => helper::baseUrl() . 'module/' . $this->getUrl(0), 'col' => 2]) . template::closeRow(); }
public function action_index() { $this->template->page_title = 'Dashboard'; $this->template->content = View::factory('dashboard/index'); if (Request::POST === $this->request->method()) { $thought = ORM::factory('Thought'); $thought->created = date('Y-m-d H:i:s'); $thought->thought = substr($this->request->post('thoughts'), 0, 255); $thought->user_id = $this->user->id; $thought->save(); } // news $news = ORM::factory('News')->where('visible', '=', '1')->order_by('id', 'DESC')->find_all(); $this->template->content->news = $news; // pagination $active = max((int) $this->request->param('id'), 1); $itemsPerPage = 10; $thoughts_count = ORM::factory('Thought')->countThoughts(); $thoughts_pagination = $thoughts_count ? helper::pagination($itemsPerPage, $thoughts_count, $active) : null; $this->template->content->thoughts_pagination = $thoughts_pagination; if ($thoughts_pagination) { $thoughts = ORM::factory('Thought')->getThoughts($itemsPerPage, $thoughts_pagination->offset); $this->template->content->thoughts = $thoughts; } $last_thought = ORM::factory('Thought')->getMyLastThought(); $this->template->content->last_thought = $last_thought; // tageszeit if (in_array(date('G'), range(12, 16))) { $begruessung = 'Guten Tag'; } elseif (in_array(date('G'), range(17, 21))) { $begruessung = 'Guten Abend'; } elseif (in_array(date('G'), range(3, 11))) { $begruessung = 'Guten Morgen'; } else { $begruessung = 'Gute Nacht'; } $this->template->content->begruessung = $begruessung; }
public function action_index() { $user = $this->request->param('user'); $this->template->page_title = $user . '\'s öffentliches Tagebuch'; $place = ORM::factory('User')->where('username', '=', $user)->find(); if (!$place->loaded()) { $this->redirect(404); } $this->template->content = View::factory('places/index'); $this->template->breadcrumbs[] = $place->username; $this->template->content->place = $place; $pagination_url = $this->request->param('diary_id') ? '/places/diary/' . $place->username . '/' . $this->request->param('diary_id') . '/' . $this->request->param('seo') : '/places/' . $place->username; $this->template->content->pagination_url = $pagination_url; $diaries = $place->Diaries->where('type', '=', 'public')->find_all(); $entries = DB::select('diary_entries.*')->from('diary_entries')->join('diaries', 'INNER')->on('diaries.id', '=', 'diary_entries.diary')->where('diary_entries.user_id', '=', $place->id)->where('diaries.type', '=', 'public')->where('diary_entries.encrypted', '=', '0'); if ($this->request->param('diary_id')) { $entries->where('diaries.id', '=', $this->request->param('diary_id')); } $entries = $entries->order_by('diary_entries.id', 'DESC')->as_object()->execute(); // pagination $active = max((int) $this->request->param('page'), 1); $itemsPerPage = 5; $entries_count = count($entries); $entries_pagination = $entries_count ? helper::pagination($itemsPerPage, $entries_count, $active) : null; $this->template->content->entries_pagination = $entries_pagination; if ($entries_pagination) { $entries = DB::select('diary_entries.*', 'diaries.name')->from('diary_entries')->join('diaries', 'INNER')->on('diaries.id', '=', 'diary_entries.diary')->where('diary_entries.user_id', '=', $place->id)->where('diaries.type', '=', 'public')->where('diary_entries.encrypted', '=', '0'); if ($this->request->param('diary_id')) { $entries->where('diaries.id', '=', $this->request->param('diary_id')); } $entries = $entries->order_by('diary_entries.id', 'DESC')->offset($entries_pagination->offset)->limit($itemsPerPage)->as_object()->execute(); $this->template->content->entries = $entries; } $this->template->content->entries = $entries; $this->template->content->diaries = $diaries; }
/** MODULE : Liste des news */ public function index() { // Erreur 404 if (!$this->getData($this->getUrl(0))) { return false; } else { // Crée une pagination (retourne la première news et dernière news de la page et la liste des pages $pagination = helper::pagination($this->getData($this->getUrl(0)), $this->getUrl()); // Liste les news en classant les classant par date en ordre décroissant $news = helper::arrayCollumn($this->getData($this->getUrl(0)), 'date', 'SORT_DESC'); // Crée l'affichage des news en fonction de la pagination for ($i = $pagination['first']; $i < $pagination['last']; $i++) { self::$content .= template::title($this->getData([$this->getUrl(0), $news[$i], 'title'])) . template::subTitle(date('d/m/Y - H:i', $this->getData([$this->getUrl(0), $news[$i], 'date']))) . $this->getData([$this->getUrl(0), $news[$i], 'content']); } // Ajoute la liste des pages en dessous des news self::$content .= $pagination['pages']; } }