', $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 = "%A%%title%%a%  %date% - (%commcount%)"; if ($orderby == "") $orderby = "date"; if ($orderhow == "") $orderhow = "SORT_DESC"; if ($first_n == "") $first_n = 1000; // echo "
 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 = ""; // create the html code to be returned $max = count($valid_entries); if ($max > $first_n) $max = $first_n; for ($i=0;$i<$max;$i++) { $sub_output = array(); $current_entry = $valid_entries[$i]; $code = $valid_entries[$i]['code']; $title = $valid_entries[$i]['title']; $user = $valid_entries[$i]['user']; $date = $valid_entries[$i]['date']; $date_array = explode("-",$date); $date = $date_array[2]."/".$date_array[1]."/".$date_array[0]." ".$date_array[3].":".$date_array[4]; $commcount = $valid_entries[$i]['commcount']; $open_a = ""; $close_a = ""; $sub_output[] = "$user"; $sub_output[] = "$date"; $sub_output[] = "$title"; $sub_output[] = "$commcount"; $sub_output[] = "$open_a"; $sub_output[] = "$close_a"; $string_2 = str_replace($sub_input,$sub_output,$string); // $string_2 = html_entity_decode($string_2); $string_2 = unhtmlspecialchars($string_2); if ($table == "yes") $to_return .= "$string_2"; else $to_return .= "$string_2"; } if ($table == "yes") $to_return .= "
\n"; else $to_return .= "\n"; // return the code return $to_return; } ?>