Exemplo n.º 1
0
    $timeline->getYear(0)->addMonth(0);

    echo "Month: ".$timeline->getYear(0)->getMonth(0)->getNumber();

    $timeline->getYear(0)->getMonth(0)->addPost(2, "Some Post");

    echo "Day: ".$timeline->getYear(0)->getMonth(0)->getPostDay(0);
    echo "Title: ".$timeline->getYear(0)->getMonth(0)->getPostTitle(0);
    */
while ($row = mysql_fetch_array($result)) {
    $date = date_parse($row['post_date']);
    $row_year = $date['year'];
    $row_month = $date['month'];
    $row_day = $date['day'];
    // $year stores the index of the current year
    $year = $timeline->findYear($row_year);
    if ($year == -1) {
        // year does not exist, create the year
        $timeline->addYear($row_year);
        // re-index
        $year = $timeline->findYear($row_year);
    }
    // $month stores the index of the current month
    $month = $timeline->getYear($year)->findMonth($row_month);
    if ($month = -1) {
        // month does not exist, create the month
        $timeline->getYear($year)->addMonth($row_month);
        // re-index
        $month = $timeline->getYear($year)->findMonth($row_month);
    }
    $timeline->getYear($year)->getMonth($month)->addPost($row_day, $row['post_title'], $row['ID']);