} if (!$amount && isset($_GET[amount])) { $amount = $_GET[amount]; #FIXME } if (!$cat && isset($_GET[cat])) { $cat = "{$_GET['cat']}"; } if (!$from && isset($_GET[from])) { $from = "{$_GET['from']}"; } # Get all the articles... # ??? FIXME-remove? if ($static) { $from = null; } $allarticles = $AADB->listarticles($amount, $from); if ($static === true) { if ($select_article) { #$Parser->Article(); include KNIFE_PATH . "/display_article.php"; } else { $Parser->Articlelist($from, $amount, $static); } } else { if (!$_GET[k] and !$pathinfo_array[1]) { $Parser->Articlelist($from, $amount, $static); } else { #$Parser->Article(); include KNIFE_PATH . "/display_article.php"; } }
function search($terms, $where = false, $regexp = false) { # VERY crude search tool. Single arg # # FIXME: # Accept multiple needles # Allow limiting searches to title or content if (!$where) { $where = "content"; } $haystack = KArticles::listarticles(); $terms = explode(" ", $terms); $numberofterms = count($terms); foreach ($haystack as $date => $article) { $rel = 0; foreach ($terms as $null => $term) { if ($regexp != "yes") { $term = "/{$term}\\s/i"; } # default search regexp if ($hits = preg_match_all($term, $article[$where], $hits) and !$nonmatches[$date]) { $rel += $hits; $matches[$date] = array("title" => $article[title], "category" => $article[category], "relevance" => $rel); } else { $nonmatches[$date] = true; unset($matches[$date]); } } } $matching = array_search($term, $haystack); return $matches; }
if ($template) { $template = $alltemplates[$template]; } else { $template = $alltemplates[1]; } if (!$amount && isset($_GET[amount])) { $amount = $_GET[amount]; } #FIXME if (!$cat && isset($_GET[cat])) { $cat = "{$_GET['cat']}"; } if (!$from && isset($_GET[from])) { $from = "{$_GET['from']}"; } $allarticles = $KAclass->listarticles($amount, $from); if (!$_GET[k] and !$pathinfo_array[1] and !$_GET[display] or $static) { $i = 0; # set the number of articles to display foreach ($allarticles as $date => $article) { # Destroy variables from last loop unset($catarray); unset($newcatarray); $output = $template[listing]; # category stuff /* what should be done here is the following: grab categories (with index and name) from the settings database compare the !NUMBERS! in $article[category] with the database to find the relevant category names for use in {category}. display only items that match an array_key_exists($_GET[cat], $categories_arr)
<div id="article_preview_wrapper"> <div class="div_normal"> <fieldset> <legend>Article content preview:</legend> ' . Markdown($_POST[article][content]) . ' </fieldset> </div> </div>'; } # # Show list of articles # if (!$_GET[id] && !$_POST[editlist]) { $KAclass = new KArticles(); $allarticles = $KAclass->listarticles("", ""); $dataclass = new SettingsStorage('settings'); $allcats = $dataclass->settings['categories']; $moduletitle = i18n("edit_module_list"); $main_content .= "\n\t<form id=\"edit_article_list\" method=\"post\" class=\"cpform\">\n\t<table>\n\t\t<tr>\n\t\t\t<th>" . i18n("generic_title") . "</th>\n\t\t\t<th>" . i18n("generic_date") . "</th>\n\t\t\t<th>" . i18n("generic_comments") . "</th>\n\t\t\t<th>" . i18n("generic_category") . "</th>\n\t\t\t<th>" . i18n("generic_author") . "</th>\n\t\t\t<th style=\"text-align: right;\">" . i18n("generic_actions") . "</th>\n\t\t</tr>"; foreach ($allarticles as $date => $article) { $catarray = explode(", ", $article[category]); $catamount = count($catarray); if ($catamount == 1) { $catrowcontent = $allcats[$article[category]][name]; } else { # Replace the category numbers with their names foreach ($catarray as $null => $thiscatid) { $thiscatinfo = $allcats[$thiscatid]; $catarray[$null] = $thiscatinfo[name]; }
function getarticle($timestamp) { $allarticles = KArticles::listarticles(); $article = $allarticles[$timestamp]; return $article; }