diff --git a/includes/classes/class_faq.inc b/includes/classes/class_faq.inc index 5ee78aa..cb77183 100644 --- a/includes/classes/class_faq.inc +++ b/includes/classes/class_faq.inc @@ -1,127 +1,127 @@ * Based on code by Christoph Cullmann * Based on the cool menu code from usability.kde.org written by Simon Edwards */ class FAQ { var $items = array(); var $question; var $section; function FAQ() { } function addQuestion($question_text, $answer_text, $anchor = "") { $question = new Question($question_text, $answer_text, $anchor); array_push($this->items, $question); } function addSection($section_name) { $section = new Section($section_name); array_push($this->items, $section); } function show() { global $site_locale; startTranslation($site_locale); if ( count($this->items) ) { $numitems = count( $this->items ); print "\n

". i18n_var("Questions") . "

\n"; $isListOpened = false; for ($i=0; $i < $numitems; $i++) { $needOpenList = $this->items[$i]->needsList(); if ( ! $isListOpened && $needOpenList ) { print "\n"; $isListOpened = false; } $this->items[$i]->showQuestion(); } if ( $isListOpened ) print "\n"; print "\n\n

" . i18n_var("Answers") . "

\n"; for ($i=0; $i < $numitems; $i++) { $this->items[$i]->showAnswer(); } } } } class Question { var $question; var $answer; var $anchor; function Question($question, $answer, $anchor = "") { $this->question = $question; $this->answer = $answer; if ($anchor == "") - $this->anchor = ereg_replace("[^a-zA-Z]", "", $this->question); + $this->anchor = preg_replace("/[^a-zA-Z]/", "", $this->question); else $this->anchor = $anchor; } function showQuestion() { print "
  • anchor\">$this->question
  • \n"; } function showAnswer() { global $site_locale; print "

    anchor\">$this->question

    \n"; print "

    $this->answer

    \n"; print "

    ". i18n_var("[Up to Questions]") . "

    \n"; } function needsList() { return true; } } class Section { var $section; function Section($section) { $this->section = $section; } function showQuestion() { print "\n

    $this->section

    \n"; } function showAnswer() { print "\n

    $this->section

    \n"; } function needsList() { return false; } } diff --git a/includes/dotandapps.inc b/includes/dotandapps.inc index f6ee792..b910131 100644 --- a/includes/dotandapps.inc +++ b/includes/dotandapps.inc @@ -1,199 +1,199 @@

    Latest News

    dot.kde.org are currently not available.

    \n"; global $site_locale; startTranslation($site_locale); print "

    " . i18n_var("Latest News") . "

    \n"; $news= new RDF(); $rdf_pieces = $news->openRDF($file); if(!$items) $items = 5; // default $rdf_items = count($rdf_pieces); if ($rdf_items > $items) $rdf_items = $items; //only open the file if it has something in it if ($rdf_items > 0) { $entry = "\n\n\n"; print $entry; for($x=1;$x<=$rdf_items;$x++) { - ereg("(.*)",$rdf_pieces[$x],$title ); - ereg("(.*)",$rdf_pieces[$x],$links ); - ereg("(.*)",$rdf_pieces[$x],$date ); + preg_match("#(.*)#",$rdf_pieces[$x],$title ); + preg_match("#(.*)#",$rdf_pieces[$x],$links ); + preg_match("#(.*)#",$rdf_pieces[$x],$date ); $title[1] = utf8_encode($title[1]); // Cut down the month to three letters format day and month to DD MMM - $printDate2 = ereg_replace("[a-zA-Z]+,[[:blank:]]*([0-9]+)[[:blank:]]+([a-zA-Z][a-zA-Z][a-zA-Z]).*$", "\\1 \\2", $date[1]); + $printDate2 = preg_replace("#[a-zA-Z]+,[[:blank:]]*([0-9]+)[[:blank:]]+([a-zA-Z][a-zA-Z][a-zA-Z]).*$#", "\\1 \\2", $date[1]); $entry = "\n" . "\n" . "\n" . "\n"; print $entry; } $entry = "
    " . i18n_var("Date") . "" . i18n_var("Headline") . "
    $printDate2" . $title[1]. "
    \n" . "

    View " . i18n_var("more news...") . "

    \n"; print $entry; } print "\n"; } function kde_news_apps ($file, $items) { global $site_locale; startTranslation($site_locale); $time = split(" ", microtime()); echo "
    \n"; echo "

    " . i18n_var("Latest Applications") . "

    \n"; $apps = new RDF(); $rdf_pieces = $apps->openRDF($file); if(!$items) $items = 5; // default $rdf_items = count($rdf_pieces); //if ($rdf_items > $items) $rdf_items = $items; if ($rdf_items > 0) { $entry = "\n\n\n\n"; print $entry; $cutoff = gmdate("U", time() - 90000); $prevDate = ""; for($x=1;$x<$rdf_items;$x++) { ereg("(.*)",$rdf_pieces[$x],$title ); ereg("(.*)",$rdf_pieces[$x],$app ); ereg("(.*)",$rdf_pieces[$x],$version ); ereg("(.*)",$rdf_pieces[$x],$date ); ereg("(.*)",$rdf_pieces[$x],$links ); ereg("(.*)",$rdf_pieces[$x],$KDEversion ); ereg("(.*)",$rdf_pieces[$x],$desc ); ereg("(.*)",$rdf_pieces[$x],$category ); // no valid date string around ! if (strlen ($date[1]) < 31) $printDate = date ("d", gmdate("U"))." ".date ("F", gmdate("U")); else { // get the "10 Jan" part of the date string $printDate = substr ($date[1], 5, strlen($date[1])-20); // get month number ! $monthName = strtolower(substr ($printDate, 3, 3)); switch ($monthName) { case "jan": $month = 1; break; case "feb": $month = 2; break; case "mar": $month = 3; break; case "apr": $month = 4; break; case "may": $month = 5; break; case "jun": $month = 6; break; case "jul": $month = 7; break; case "aug": $month = 8; break; case "sep": $month = 9; break; case "oct": $month = 10; break; case "nov": $month = 11; break; case "dec": $month = 12; break; } $monthName = date ("M", mktime(0,0,0,$month,1,0)); // create the date string if ($printDate[0] == " ") $printDate = substr ($printDate, 1, 1)." ".$monthName; else $printDate = substr ($printDate, 0, 2)." ".$monthName; } $entry = "" . "\n" . "\n" ; print $entry; $prevDate = $printDate; // algorithm: show max(last 6, last 24 hours) // actually use a bit more than 24 hours (90000 secs) if (($x > $items) && (kde_parse_date ($date[1]) < $cutoff)) break; } $entry = "
    " . i18n_var("Date") . "" . i18n_var("Application / Release") . "
    ". (($printDate == $prevDate) ? " " : "$printDate") . "". $title[1] . " \n" . "
    \n

    " . i18n_var("View more applications...") . "

    \n

    " . i18n_var("Disclaimer: ") . "" . i18n_var("Application feed provided by kde-apps.org, an independent KDE website.") . "

    \n"; print $entry; } echo "
    "; } ?> diff --git a/includes/rss2.inc b/includes/rss2.inc index 084dc4e..c8319af 100644 --- a/includes/rss2.inc +++ b/includes/rss2.inc @@ -1,111 +1,111 @@ can have escaped HTML code */ function kde_general_news_rss2 ($file, $items, $summaryonly, $useexternallinks = false, $summaryonlytitle = "") { global $site_locale; startTranslation($site_locale); if ($summaryonly) { if ($summaryonlytitle) print "

    " . $summaryonlytitle . "

    \n"; else print "

    " . i18n_var("Latest News") . "

    \n"; } $news = new RDF(); $rdf_pieces = $news->openRDF($file); if(!$items) { $items = 5; // default } $rdf_items = count($rdf_pieces); if ($rdf_items > $items) { $rdf_items = $items; } //only open the file if it has something in it if ($rdf_items > 0) { /* Don't display the last story twice * if there is less than the requested number of stories * in the RDF file */ if ($rdf_items < $items) { $rdf_items = $rdf_items - 1; } print "\n"; if ($summaryonly) print "\n\n"; for($x=1;$x<=$rdf_items;$x++) { preg_match("@(.*)@s", $rdf_pieces[$x], $title); preg_match("@(.*)@s",$rdf_pieces[$x], $links); preg_match("@(.*)@s", $rdf_pieces[$x], $date); preg_match("@(.*)@s", $rdf_pieces[$x], $description); print "\n"; $parsedDate = strtotime( $date[1] ); if ( $parsedDate === -1 ) { // Date could not be parsed, so give back the raw date $cookedDate = $date[1]; } else { $cookedDate = gmdate( i18n_var("Y-m-d"), $parsedDate ); } if ($summaryonly) { print "\n"; if ($useexternallinks) print "\n"; - else print "\n"; + else print "\n"; $prevDate=$cookedDate; } else { // We need to unescape the XML/HTML character references in the $desc = $description[1]; - $desc = ereg_replace("<","<", $desc); - $desc = ereg_replace(">",">", $desc); - $desc = ereg_replace("&","&", $desc); - print "\n"; + $desc = preg_replace("/</","<", $desc); + $desc = preg_replace("/>/",">", $desc); + $desc = preg_replace("/&/","&", $desc); + print "\n"; print "\n"; } print "\n"; } print "
    " . i18n_var("Date") . "" . i18n_var("Headline") . "
    ".(($cookedDate == $prevDate) ? " " : "$cookedDate")."$title[1]$title[1]$title[1]

    $cookedDate: $title[1]

    $cookedDate: $title[1]

    $desc
    \n"; } } ?>