/** * Sets up the test fixture. * * @return void * * @global string The script name. * @global string The URL of the current page. * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global Realblog_Controller The plugin controller. */ public function setUp() { global $sn, $su, $plugin_cf, $plugin_tx, $_Realblog_controller; $sn = '/xh/'; $su = 'Blog'; $plugin_cf['realblog'] = array('comments_plugin' => ''); $plugin_tx['realblog'] = array('blog_back' => 'Overview', 'comment_edit' => 'Edit comments', 'entry_edit' => 'Edit entry'); $this->_defineConstant('XH_ADM', false); $article = Realblog_Article::makeFromRecord(['1', '1405548000', '1405548000', '1405548000', '1', '', 'Heading', '<p>Teaser</p>', '<p>Article</p>', '', '']); $_Realblog_controller = new Realblog_Controller(); $this->_subject = new Realblog_ArticleView('1', $article, '1'); }
/** * Renders a row. * * @param Realblog_Article $article An article. * * @return string (X)HTML. * * @global string The script name. * @global array The localization of the plugins. * @global Realblog_Controller The plugin controller. */ protected function renderRow(Realblog_Article $article) { global $sn, $plugin_tx, $_Realblog_controller; $page = $_Realblog_controller->getPage(); return '<tr>' . '<td class="realblog_table_line">' . tag('input type="checkbox" name="realblogtopics[]"' . ' value="' . $article->getId() . '"') . '</td>' . '<td class="realblog_table_line">' . '<a href="' . $sn . '?&realblog&admin=plugin_main' . '&action=delete_realblog&realblogID=' . $article->getId() . '&page=' . $page . '">' . tag('img src="' . $this->imageFolder . 'delete.png"' . ' title="' . $plugin_tx['realblog']['tooltip_delete'] . '" alt="' . $plugin_tx['realblog']['tooltip_delete'] . '"') . '</a></td>' . '<td class="realblog_table_line">' . '<a href="' . $sn . '?&realblog&admin=plugin_main' . '&action=modify_realblog&realblogID=' . $article->getId() . '&page=' . $page . '">' . tag('img src="' . $this->imageFolder . 'edit.png"' . ' title="' . $plugin_tx['realblog']['tooltip_modify'] . '" alt="' . $plugin_tx['realblog']['tooltip_modify'] . '"') . '</a></td>' . '<td class="realblog_table_line">' . $article->getId() . '</td>' . '<td class="realblog_table_line">' . date($plugin_tx['realblog']['date_format'], $article->getDate()) . '</td>' . '<td class="realblog_table_line">' . $article->getStatus() . '</td>' . '<td class="realblog_table_line">' . $article->isFeedable() . '</td>' . '<td class="realblog_table_line">' . $article->isCommentable() . '</td>' . '</tr>' . '<tr><td colspan="8" class="realblog_table_title">' . $article->getTitle() . '</td></tr>'; }
/** * Returns the meta description for an article. * * @param Realblog_Article $article An article. * * @return string */ protected function getDescription(Realblog_Article $article) { return utf8_substr(html_entity_decode(strip_tags($article->getTeaser()), ENT_COMPAT, 'UTF-8'), 0, 150); }
/** * Renders the article story. * * @return string (X)HTML. */ protected function renderStory() { $story = $this->article->getBody() != '' ? $this->article->getBody() : $this->article->getTeaser(); return '<div class="realblog_show_story_entry">' . evaluate_scripting($story) . '</div>'; }
/** * Renders the article form. * * @param string $id An article ID. * @param string $action An action. * * @return string (X)HTML. * * @global string The page title. * @global array The configuration of the plugins. * @global array The localization of the plugins. * @global Realblog_Controller The plugin controller. */ protected function form($id, $action) { global $title, $plugin_cf, $plugin_tx, $_Realblog_controller; if ($action == 'add_realblog') { $article = Realblog_Article::makeFromRecord(array(REALBLOG_ID => 0, REALBLOG_DATE => time(), REALBLOG_STARTDATE => time(), REALBLOG_ENDDATE => 2147483647, REALBLOG_STATUS => 0, REALBLOG_FRONTPAGE => '', REALBLOG_TITLE => '', REALBLOG_HEADLINE => '', REALBLOG_STORY => '', REALBLOG_RSSFEED => '', REALBLOG_COMMENTS => '')); $title = $plugin_tx['realblog']['tooltip_add']; } else { $article = Realblog_Article::findById($id); if ($action == 'modify_realblog') { $title = $plugin_tx['realblog']['tooltip_modify'] . ' [ID: ' . $id . ']'; } elseif ($action == 'delete_realblog') { $title = $plugin_tx['realblog']['tooltip_delete'] . ' [ID: ' . $id . ']'; } } $view = new Realblog_ArticleAdminView($article, $action); return $view->render(); }
/** * Finds an article by ID. * * @param int $id An ID. * * @return Realblog_Article */ public static function findById($id) { $db = Realblog_DB::getConnection(); $record = $db->selectUnique('realblog.txt', REALBLOG_ID, $id); if (!empty($record)) { return Realblog_Article::makeFromRecord($record); } else { return null; } }
/** * Renders the monthly article lists. * * @param int $currentMonth The current month. * * @return string (X)HTML. */ protected function renderMonthlyArticleLists($currentMonth) { $t = ''; for ($month = $currentMonth; $month >= 1; $month--) { $realbloglist = Realblog_Article::findArchivedArticlesInPeriod(mktime(0, 0, 0, $month, 1, $this->year), mktime(0, 0, 0, $month + 1, 1, $this->year)); $monthName = $this->getMonthName($month); if (count($realbloglist) > 0) { $t .= '<h4>' . $monthName . ' ' . $this->year . '</h4>' . $this->renderArticleList($realbloglist); } } return $t; }
/** * Renders the story (body). * * @return string (X)HTML. * * @global array The localization of the plugins. */ protected function renderStory() { global $plugin_tx; return '<h4>' . $plugin_tx['realblog']['story_label'] . '</h4>' . '<textarea class="realblog_story_field"' . ' name="realblog_story" id="realblog_story" rows="30" cols="80">' . XH_hsc($this->article->getBody()) . '</textarea>'; }
/** * Renders a comment count. * * @param Realblog_Article $article An article. * * @return string (X)HTML. * * @global array The configuration of the plugins. * @global array The localization of the plugins. */ protected function renderCommentCount(Realblog_Article $article) { global $plugin_cf, $plugin_tx; $bridge = $plugin_cf['realblog']['comments_plugin'] . '_RealblogBridge'; $commentsId = 'comments' . $article->getId(); $count = call_user_func(array($bridge, count), $commentsId); $key = 'message_comments' . XH_numberSuffix($count); return '<p class="realblog_number_of_comments">' . sprintf($plugin_tx['realblog'][$key], $count) . '</p>'; }