Пример #1
0
 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();
 }
Пример #2
0
                            $out = "сегодня в {$a[3]}:{$a[4]}";
                            break;
                        case date('d', time() + 86400):
                            $out = "завтра в {$a[3]}:{$a[4]}";
                            break;
                        case date('d', time() + 172800):
                            $out = "послезавтра в {$a[3]}:{$a[4]}";
                            break;
                    }
                    break;
            }
        }
        if ($out == '') {
            $out = date($format, $date);
        }
        return $out;
    }
}
switch ($format) {
    case 'HumanDate':
        $out = HumanDate($time, isset($aformat) ? $aformat : "Y.m.d H:i:s");
        break;
    case 'W3C':
        $date = new DateTime();
        $date->setTimestamp($time);
        $out = $date->format(DateTime::W3C);
        break;
    default:
        $out = date($format, $time);
}
return $out;
Пример #3
0
 function index_action()
 {
     // determining posts scope (all/trash/drafts/published)
     switch ($this->params->scope) {
         case 'trash':
             $scopeLabel = ' (kosz)';
             $scope = 'trash';
             break;
         case 'drafts':
             $scopeLabel = ' (szkice)';
             $scope = 'drafts';
             break;
         case 'published':
             $scopeLabel = ' (opublikowane)';
             $scope = 'published';
             break;
         default:
             $scope = 'all';
             break;
     }
     // fetching posts
     $posts = $this->model->allPosts($scope);
     // if no blog posts
     if ($posts->empty) {
         $view = View('admin/list');
         $view->counts = $this->model->counts();
         $view->table = null;
         $view->display();
         return;
     }
     // table configuration
     $table = new ACPTable();
     $table->isPagination = false;
     $table->header = array('Wpis', 'Data', 'Komentarzy');
     // actions for selected posts
     if ($scope == 'trash') {
         $table->selectedActions[] = array('Usuń na zawsze', 'blog/delete/', 'Nieodwracalnie usuń zaznaczone wpisy');
         $table->selectedActions[] = array('Przywróć', 'blog/untrash/', 'Przywróć zaznaczone wpisy z kosza do szkiców');
     } else {
         $table->selectedActions[] = array('Usuń', 'blog/trash/', 'Przenieś zaznaczone wpisy do kosza');
     }
     // adding posts
     foreach ($posts as $post) {
         $id = $post->id;
         //--
         $title = '<strong>' . $post->title . '</strong>';
         // title as link to edit (not in trash)
         if ($scope != 'trash') {
             $title = '<a href="$/blog/edit/' . $id . '" title="Edytuj wpis">' . $title . '</a>';
         }
         // draft marker (only for 'all' scope)
         if ($post->status == 'draft' && $scope == 'all') {
             $title = '(Szkic) ' . $title;
         }
         //--
         $content = nl2br(strip_tags($post->content));
         if (mb_strlen($content) > 130) {
             $content = mb_substr($content, 0, 130) . ' (...)';
         }
         //--
         $linkTo = '#/' . date('Y/m', $post->published) . '/' . $post->name;
         $actions = '';
         // preview and editing (not for trash)
         if ($scope != 'trash') {
             $actions .= '<a href="' . $linkTo . '" title="Obejrzyj wpis na stronie">Zobacz</a>';
             $actions .= ' | <a href="$/blog/edit/' . $id . '" title="Edytuj wpis">Edytuj</a>';
         }
         // publishing (for drafts)
         if ($post->status == 'draft') {
             $actions .= ' | <a href="$/blog/publish/' . $id . '" title="Publikuj wpis">Publikuj</a>';
         }
         // moving to drafts
         if ($post->status == 'published') {
             $actions .= ' | <a href="$/blog/unpublish/' . $id . '" title="Przenieś opublikowany wpis do szkiców">Przenieś do szkiców</a>';
         }
         // deleting and untrashing (trash scope), or moving to trash (other scopes)
         if ($scope == 'trash') {
             $actions .= '<a href="$/blog/delete/' . $id . '" title="Nieodwracalnie usuń wpis">Usuń na zawsze</a>';
             $actions .= ' | <a href="$/blog/untrash/' . $id . '" title="Przywróć wpis z kosza do szkiców">Przywróć</a>';
         } else {
             $actions .= ' | <a href="$/blog/trash/' . $id . '" title="Przenieś wpis do kosza">Usuń</a>';
         }
         //--
         $postInfo = $title . '<br>';
         $postInfo .= '<small>' . $content . '</small><br>';
         $postInfo .= '<div class="acp-actions">' . $actions . '</div>';
         //--
         $dates = '<small>';
         // creation/publication date
         if ($post->status == 'published') {
             $dates .= 'opublikowany ' . HumanDate($post->published, true, true);
         } else {
             $dates .= 'utworzony ' . HumanDate($post->published, true, true);
         }
         // update date
         if ($post->updated > $post->published) {
             $dates .= ', <br>zmieniony ' . HumanDate($post->updated, true, true);
         }
         $dates .= '</small>';
         //--
         $allComments = $post->commentsCount;
         $unapprovedComments = $allComments - $post->approvedCommentsCount;
         $comments = $allComments;
         if ($unapprovedComments > 0) {
             $comments .= ' <strong><a href="' . $linkTo . '#comments">(' . $unapprovedComments . ' do sprawdzenia!)</a></strong>';
         }
         //--
         $cells = array($postInfo, $dates, $comments);
         $table->addRow($id, $cells);
     }
     // displaying
     $this->pageTitle = 'Lista wpisów' . $scopeLabel;
     $view = View('admin/list');
     $view->counts = $this->model->counts();
     $view->posts = $posts;
     $view->table = $table->generate();
     $view->display();
 }
Пример #4
0
 public function _post_action($name)
 {
     // getting post data
     $post = $this->model->postData_name($name);
     if (!$post) {
         Watermelon::displayNoPageFoundError();
         return;
     }
     // checking if published
     if ($post->status !== 'published') {
         // displaying notice for admin, or 'not found'
         if (Users::isLogged()) {
             $this->displayNotice('Ten wpis nie jest opublikowany. Tylko Ty go możesz zobaczyć.');
         } else {
             Watermelon::displayNoPageFoundError();
             return;
         }
     }
     // post
     $post->content = Textile::textile($post->content);
     $post->url = '#/' . date('Y/m', $post->published) . '/' . $post->name;
     // displaying (if exists)
     $id = $post->id;
     $this->pageTitle = $post->title;
     $this->noHeader = true;
     $view = View('post');
     $view->post = $post;
     $view->commentsView = Comments::commentsView($id, 'blogpost', $post->url, (bool) $post->allowComments);
     $view->editHref = '%/blog/edit/' . $id . '?backTo=post';
     $view->deleteHref = '%/blog/trash/' . $id . '/' . base64_encode('#/');
     $view->published_human = HumanDate($post->published, true, true);
     $view->display();
 }
Пример #5
0
 function index_action()
 {
     // determining posts scope (published/trash)
     switch ($this->params->scope) {
         case 'trash':
             $scopeLabel = ' (kosz)';
             $scope = 'trash';
             break;
         default:
             $scope = 'published';
             break;
     }
     // fetching pages
     $pages = $this->model->pages($scope);
     // if no pages
     if ($pages->empty) {
         $view = View('admin/list');
         $view->counts = $this->model->counts();
         $view->table = null;
         $view->display();
         return;
     }
     // table configuration
     $table = new ACPTable();
     $table->isPagination = false;
     $table->header = array('Strona', 'Data', 'Komentarzy');
     // actions for selected posts
     if ($scope == 'trash') {
         $table->selectedActions[] = array('Usuń na zawsze', 'pages/delete/', 'Nieodwracalnie usuń zaznaczone strony');
         $table->selectedActions[] = array('Przywróć', 'pages/untrash/', 'Przywróć zaznaczone strony z kosza');
     } else {
         $table->selectedActions[] = array('Usuń', 'pages/trash/', 'Przenieś zaznaczone strony do kosza');
     }
     // adding pages
     foreach ($pages as $page) {
         $id = $page->id;
         //--
         $title = '<strong>' . $page->title . '</strong>';
         // title as link to edit (not in trash)
         if ($scope != 'trash') {
             $title = '<a href="$/pages/edit/' . $id . '" title="Edytuj stronę">' . $title . '</a>';
         }
         //--
         $content = nl2br(strip_tags($page->content));
         if (mb_strlen($content) > 130) {
             $content = mb_substr($content, 0, 130) . ' (...)';
         }
         //--
         $actions = '';
         if ($scope == 'published') {
             $actions .= '<a href="#/' . $page->name . '" title="Obejrzyj na stronie">Zobacz</a> | ';
             $actions .= '<a href="$/pages/edit/' . $id . '" title="Edytuj stronę">Edytuj</a> | ';
             $actions .= '<a href="$/pages/trash/' . $id . '" title="Przenieś stronę do kosza">Usuń</a>';
         } else {
             $actions .= '<a href="$/pages/delete/' . $id . '" title="Nieodwracalnie usuń stronę">Usuń na zawsze</a>';
             $actions .= ' | <a href="$/pages/untrash/' . $id . '" title="Przywróć stronę z kosza">Przywróć</a>';
         }
         //--
         $pageInfo = $title . '<br>';
         $pageInfo .= '<small>' . $content . '</small><br>';
         $pageInfo .= '<div class="acp-actions">' . $actions . '</div>';
         //--
         $dates = '<small>' . HumanDate($page->created, true, true);
         $dates .= '<br>(' . HumanDate($page->updated, true, true) . ')</small>';
         //TODO: + by [author]
         $dates = '<small>';
         $dates .= 'utworzona ' . HumanDate($page->created, true, true);
         if ($page->updated > $page->created) {
             $dates .= ', <br>zmieniona ' . HumanDate($page->updated, true, true);
         }
         $dates .= '</small>';
         //--
         $allComments = $page->commentsCount;
         $unapprovedComments = $allComments - $page->approvedCommentsCount;
         $comments = $allComments;
         if ($unapprovedComments > 0) {
             $comments .= ' <strong><a href="#/' . $name . '#comments">(' . $unapprovedComments . ' do sprawdzenia!)</a></strong>';
         }
         //--
         $cells = array($pageInfo, $dates, $comments);
         $table->addRow($id, $cells);
     }
     // displaying
     $this->pageTitle = 'Lista stron' . $scopeLabel;
     $view = View('admin/list');
     $view->counts = $this->model->counts();
     $view->pages = $pages;
     $view->table = $table->generate();
     $view->display();
 }