function module_articles_frontpage() { echo "<!-- start articles frontpage -->"; global $article_author; global $no_articles_text; global $jokes, $layout, $chars_showing_articles, $chars_showing_first_article; $query = "select * from articles WHERE is_deleted IS NULL AND comment_to IS NULL AND is_draft IS NULL ORDER BY date_posted DESC, time_posted DESC LIMIT 8"; $result = DB_get_table($query); ?> <!-- start articles frontpage --> <?php if ($layout == "newspaper") { echo '<table class="frontpage_table_2columns">'; } else { echo '<table class="frontpage_table">'; } if (!$result || DB_rows_affected($result) < 1) { // hvis noe er feil, vis en vits. echo '<tr>'; echo '<td colspan="2" class=\\"articles_frontpage\\">'; echo $no_articles_text . ' Vi presenterer i stedet en vits.<br/><br/>'; echo $jokes[array_rand($jokes, 1)]; echo '</td>'; echo '</tr>'; } else { $num_results = DB_rows_affected(); // øverste artikkel, spenner over begge kolonnene. echo "<tr>"; echo '<td colspan="2" class="articles_frontpage">'; $row = DB_next_row($result); echo '<div class="header2 articletitlefront"><a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '">' . stripslashes($row['title']) . '</a></div>'; echo '<div class="metatext">' . $article_author; echo '<span class="author">: '; if (isset($row['author_username'])) { echo '<a href="index.php?m_c=mvp&username='******'author_username'] . '">' . stripslashes($row['author']) . '</a>'; } else { echo stripslashes($row['author']); } echo '</span>'; echo ', postet <span class="date">' . make_date($row['date_posted']) . ' </span><span class="time">' . make_time($row['time_posted']) . '</span></div>'; echo '<div class="textbody">'; if (strlen($row['body']) < $chars_showing_first_article * 2) { echo stripslashes(nl2br($row['body'])); } else { echo closeUnclosedTags(stripslashes(substr(nl2br($row['body']), 0, $chars_showing_first_article))); echo " ..."; $chars_left = strlen($row['body']) - $chars_showing_first_article; } echo '</div>'; $number_of_comments = number_of_comments($row['articleid']); echo '<div class="showarticlelink">'; if (strlen($row['body']) < $chars_showing_first_article * 2) { echo '<a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '">Vis artikkelside</a> '; } else { echo '<a href="index.php?c=' . $chars_showing_first_article . '&m_c=m_va&articleid=' . $row['articleid'] . '#continue">Les hele artikkelen <span class="notice">(' . $chars_left . ' flere tegn)</span></a> '; } // Give link to comments if any, else link to the commenting form if ($number_of_comments > 0) { echo '<a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '#comments">Les kommentarer (' . $number_of_comments . ')</a> '; } else { global $anyone_comments; if ($anyone_comments || isset($_SESSION['valid_user'])) { echo '<a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '#commentform">Skriv kommentar</a> '; } else { echo "<span id='loginlink'><a href=\"javascript:showDiv('loginform', 'errorandlogout')\">Logg inn og kommenter</a></span>"; } } echo '</div>'; echo '</td>'; echo '</tr>'; // resten av artiklene if ($layout == "newspaper") { $chars_showing_first_article = $chars_showing_first_article / 4; } for ($i = 1; $i < $num_results; $i++) { // sjekker layout og hvilken 'side' man er på, siden man kan velge mellom 1 eller 2 kolonner. if (!($i % 2 == 0) || $layout == "weblog") { echo "<tr>"; if ($layout == "weblog") { echo '<td colspan="2" class="articles_frontpage">'; } else { echo '<td class="articles_frontpage_2column">'; } } else { if ($layout == "weblog") { echo '<td colspan="2" class="articles_frontpage">'; } else { echo '<td class="articles_frontpage_2column">'; } } $row = DB_next_row($result); echo '<div class="header2 articletitlefront"><a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '">' . stripslashes($row['title']) . '</a></div>'; echo '<div class="metatext">' . $article_author; echo '<span class="author">: '; if (isset($row['author_username'])) { echo '<a href="index.php?m_c=mvp&username='******'author_username'] . '">' . stripslashes($row['author']) . '</a>'; } else { echo stripslashes($row['author']); } echo '</span>'; echo ', postet <span class="date">' . make_date($row['date_posted']) . ' </span><span class="time">' . make_time($row['time_posted']) . '</span></div>'; echo '<div class="textbody">'; if (strlen($row['body']) < $chars_showing_first_article * 2) { echo stripslashes(nl2br($row['body'])); } else { echo stripslashes(substr(nl2br($row['body']), 0, $chars_showing_first_article)); echo " ..."; $chars_left = strlen($row['body']) - $chars_showing_first_article; } echo '</div>'; $number_of_comments = number_of_comments($row['articleid']); echo "<div class=\"showarticlelink\">"; if (strlen($row['body']) < $chars_showing_first_article * 2) { echo '<a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '">Vis artikkelside</a> '; } else { echo '<a href="index.php?c=' . $chars_showing_first_article . '&m_c=m_va&articleid=' . $row['articleid'] . '#continue">Les hele artikkelen <span class="notice">(' . $chars_left . ' flere tegn)</span></a> '; } if ($number_of_comments > 0) { echo '<a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '#comments">Les kommentarer (' . $number_of_comments . ')</a> '; } else { echo '<a href="index.php?m_c=m_va&articleid=' . $row['articleid'] . '#commentform">Skriv kommentar</a> '; } echo '</div>'; echo '</td>'; if (!($i % 2 != 0) || $layout == "weblog") { echo "</tr>"; } } // slutt for-løkke // helt til slutt, hvis antall artikler på forsiden er et partall, // og dette ikke er weblog (en artikkel pr rad) // vil vi bare ha en artikkel på slutten, og må huske å avslutte raden. if ($num_results % 2 == 0 && $layout != "weblog") { echo "</tr>"; } } echo "</table>"; }
function ag_wp_trim_excerpt($text) { global $post; $raw_excerpt = $text; if ('' == $text) { //Retrieve the post content. $text = get_the_content(''); //Delete all shortcode tags from the content. $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $allowed_tags = '<p>,<em>,<strong>,<b>,<ul>,<li>,<ol>,<blockquote>'; /*** Add the allowed HTML tags separated by a comma.***/ $text = strip_tags($text, $allowed_tags); $excerpt_word_count = 40; /*** change the excerpt word count to any integer you like.***/ $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); $excerpt_end = '... <span class="more-link"><a href="' . get_permalink($post->ID) . '" class="more-link">' . __('Read More', 'framework') . '</a></span>'; /*** change the excerpt endind to something else.***/ $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = $text . $excerpt_more; $text = closeUnclosedTags($text); //close any unclosed tags } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); }
function printArticle($article) { h1_link(stripslashes($article['title']), url_to_article($article['articleid'])); articleMetaInfo(getAuthorOfArticle($article['articleid']), getAuthorOfArticleUsername($article['articleid']), make_date($article['date_posted']), make_time($article['time_posted']), $article['language']); div_open("textbody", ""); // Skips inserting #continue anchor due to many broken links //$article['body'] = substr($article['body'], 0, getSetting("article_length_soft_limit", 1500)) . '<a name="continue"></a>' . substr($article['body'], getSetting("article_length_soft_limit", 1500)); $paragraph = makeReadyForPrint(closeUnclosedTags($article['body'])); echo nl2br($paragraph); div_close(); }