', $string );
return $string;
}
}
/*
* function: snippet_entrieslist_is_in_category
* args:
* $entry: the entry
* $category: the category
*
* This function checks if an entry is associated whit a category
*/
function snippet_entrieslist_is_in_category($entry, $category)
{
$categories = $entry['category'];
$max = count($categories);
for ($i=0;$i<$max;$i++)
{
$entry['category'][$i] = unentify($entry['category'][$i]);
$category = unentify($category);
if (strcasecmp($entry['category'][$i], $category) == 0) return true;
}
return false;
}
/*
* function snippet_entrieslist
* args:
* $category: this indicates the category
* $string: this sets the format of the output rows. ie: %title% - %user% (%commcount%) %date%
* $orderby: user, date, title, commcount
* $orderhow: can be SORT_DESC, SORT_ASC
* $first_n: display only the first n entries after ordered
* $table: yes,no
*
* this is the main function
*/
function snippet_entrieslist($category="", $string="", $orderby="", $orderhow = "", $first_n = "", $table = "")
{
global $Paths;
echo $orderby;
$category = trim($category);
$string = trim($string);
$orderby = trim($orderby);
$orderhow = trim($orderhow);
$first_n = trim($first_n);
$table = trim($table);
if ($category == "") $category = "default";
if ($table == "") $table = "yes";
if (($string == "") && ($table == "no")) $string = "%A%%title%%a% - %date% - comments: %commcount%
";
if (($string == "") && ($table == "yes")) $string = "
cant' get to works this \$first_n: $first_n"; $to_return = ""; $valid_entries = array(); // this array will hold entries associated whit the $category category $db = new db(); // create a new database $list_entries = $db->getlist_range("1970-01-01-00-00", "2020-12-31-23-59","","", FALSE); // Gets all entries // populate $valid_entries $max = count($list_entries); for ($i=0;$i<$max;$i++) { $current_entry = $list_entries[$i]; if (snippet_entrieslist_is_in_category($current_entry, $category)) $valid_entries[] = $current_entry; } // let's sort! foreach($valid_entries as $entry) $sortAux[] = $entry["$orderby"]; if ($orderhow = "SORT_DESC") $orderhow = SORT_DESC; if ($orderhow = "SORT_ASC") $orderhow = SORT_ASC; array_multisort($sortAux, $orderhow, $valid_entries); $link = $Paths['host'].$Paths['pivot_url']."entry.php"; // http://www.site.com/weblog/pivot/entry.php $sub_input = array(); $sub_input[] = "%user%"; $sub_input[] = "%date%"; $sub_input[] = "%title%"; $sub_input[] = "%commcount%"; $sub_input[] = "%A%"; $sub_input[] = "%a%"; if ($table == "yes") $to_return = "