Beispiel #1
0
 public static function GetPanel()
 {
     $tpl = new Template();
     $pages = Pages_Model::GetPages();
     $tpl->SetParam('pages', $pages);
     return $tpl->Fetch('templates/pages/pages-panel.tpl');
 }
 public function AddAction()
 {
     $fields = array('page_title', 'page_text', 'page_display_in_menu');
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (empty($_POST['page_display_in_menu'])) {
             $_POST['page_display_in_menu'] = 'n';
         }
         $rows = Utils::ArrayFilter($_POST, $fields);
         $id = Pages_Model::PageAdd($rows);
         header("Location: /pages/view/{$id}");
     }
     $res = array('Title' => 'Добавление страницы', 'PageTitle' => 'Добавление страницы');
     $res['Content'] = Pages_View::GetAddPage();
     return $res;
 }
 function index_action()
 {
     $this->pageTitle = 'Lista komentarzy';
     $comments = $this->model->comments();
     // if no comments
     if (!$comments->exists) {
         echo '<p>Brak komentarzy</p>';
         return;
     }
     // table configuration
     $table = new ACPTable();
     $table->isPagination = false;
     $table->header = array('Komentarz', 'Napisany', 'Autor');
     $table->selectedActions[] = array('Usuń', 'comments/delete/');
     $table->selectedActions[] = array('Zatwierdź', 'comments/approve/');
     $table->selectedActions[] = array('Odrzuć', 'comments/reject/');
     // users, posts, pages
     $posts = array();
     // in all two arrays data about certain post/page is stored, with [id] key
     $pages = array();
     // adding comments
     foreach ($comments as $comment) {
         $id = $comment->id;
         //--
         $content = strip_tags($comment->content);
         if (mb_strlen($content) > 500) {
             $content = mb_substr($content, 0, 500) . ' (...)';
         }
         $content = nl2br($content);
         //--
         $actions = '';
         // previewing
         if ($comment->type == 'blogpost') {
             // fetching data
             if (!isset($posts[$comment->record])) {
                 $posts[$comment->record] = Blog_Model::postData_id($comment->record);
             }
             $post =& $posts[$comment->record];
             //--
             $actions .= '<a href="#/' . date('Y/m', $post->published) . '/' . $post->name . '#comment-' . $id . '" title="Obejrzyj komentarz na stronie">Zobacz</a> | ';
         } elseif ($comment->type = 'page') {
             // fetching data
             if (!isset($pages[$comment->record])) {
                 $pages[$comment->record] = Pages_Model::pageData_id($comment->record);
             }
             $page =& $pages[$comment->record];
             //--
             $actions .= '<a href="#/' . $page->name . '#comment-' . $id . '" title="Obejrzyj komentarz na stronie">Zobacz</a> | ';
         }
         $actions .= '<a href="$/comments/edit/' . $id . '" title="Edytuj komentarz">Edytuj</a> | ';
         $actions .= '<a href="$/comments/delete/' . $id . '" title="Usuń komentarz">Usuń</a>';
         // approve/reject (only if comment wasn't written by admin)
         if ($comment->authorID === null) {
             if ($comment->approved) {
                 $actions .= ' | <a href="$/comments/reject/' . $id . '" title="Oznacz komentarz jako oczekujący na moderację">Odrzuć</a>';
             } else {
                 $actions .= ' | <a href="$/comments/approve/' . $id . '" title="Oznacz komentarz jako sprawdzony">Zatwierdź</a>';
             }
         }
         //--
         $commentInfo = '';
         if (!$comment->approved) {
             $commentInfo .= '[<strong>Niesprawdzony!</strong>] ';
         }
         $commentInfo .= $content;
         $commentInfo .= '<div class="acp-actions">' . $actions . '</div>';
         //--
         $created = HumanDate($comment->created);
         //--
         if ($comment->authorID !== null) {
             $user = Users::userData(1);
             //--
             $author = htmlspecialchars($user->nick) . ' (admin)';
         } else {
             $author = htmlspecialchars($comment->authorName);
             if ($comment->authorWebsite !== null) {
                 $author = '<a href="' . htmlspecialchars($comment->authorWebsite) . '" target="_blank">' . $author . '</a>';
             }
             $author .= '<br>' . htmlspecialchars($comment->authorEmail);
         }
         //--
         $rowAttributes = array();
         if (!$comment->approved) {
             $rowAttributes = array('style' => 'background-color:#F5E8D9');
         }
         $cells = array($commentInfo, $created, $author);
         $table->addRow($id, $cells, $rowAttributes);
     }
     // displaying
     echo $table->generate();
 }