function write_cache()
{
    date_default_timezone_set(TIMEZONE);
    // Create cache for each year
    $flat_year = create_data_info("year");
    foreach ($flat_year as $year => $data) {
        create_pages($data, $year);
    }
    unset($flat_year);
    // Create cache for each year/month (the key of the array is yearmonth so we can split it.)
    $flat_month = create_data_info("month");
    foreach ($flat_month as $yearmonth => $data) {
        $month = substr($yearmonth, -2);
        $year = substr($yearmonth, 0, 4);
        create_pages($data, $year . '/' . $month);
    }
    unset($flat_month);
    // Create the cache for each day.
    $flat_day = create_data_info("day");
    foreach ($flat_day as $yearmonthday => $data) {
        $day = substr($yearmonthday, -2);
        $month = substr($yearmonthday, 4, 2);
        $year = substr($yearmonthday, 0, 4);
        create_pages($data, $year . '/' . $month . '/' . $day);
    }
    unset($flat_day);
    // Create cache per post
    $flat_post = create_data_info("post");
    // Create the index page that will create the "main" pages of the blog
    create_pages($flat_post, "");
    foreach ($flat_post as $post) {
        $title = urlencode($post[0]);
        $title = strtolower(str_replace('+', '_', $title));
        $filepath = ROOT_DIR . '/' . CACHE_DIR . '/' . $title . "_0.html";
        create_page_content($filepath, $post, $GLOBALS["footer"], true);
    }
    unset($flat_post);
}
示例#2
0
function create_notebook()
{
    global $windows, $sample_notebook, $book_open, $book_open_mask, $book_closed, $book_closed_mask, $book_open_xpm, $book_closed_xpm;
    $items = array('Standard' => array('standard_notebook', &$sample_notebook), 'No tabs' => array('notabs_notebook', &$sample_notebook), 'Scrollable' => array('scrollable_notebook', &$sample_notebook));
    if (!isset($windows['notebook'])) {
        $window = new GtkWindow();
        $windows['notebook'] = $window;
        $window->connect('delete_event', 'delete_event');
        $window->set_title('Notebook');
        $window->set_border_width(0);
        $box1 =& new GtkVBox(false, 0);
        $box1->show();
        $window->add($box1);
        $sample_notebook = new GtkNotebook();
        $sample_notebook->show();
        $sample_notebook->connect('switch_page', 'page_switch');
        $sample_notebook->set_tab_pos(GTK_POS_TOP);
        $box1->pack_start($sample_notebook, true, true, 0);
        $sample_notebook->set_border_width(10);
        $sample_notebook->realize();
        list($book_open, $book_open_mask) = Gdk::pixmap_create_from_xpm_d($sample_notebook->window, null, $book_open_xpm);
        list($book_closed, $book_closed_mask) = Gdk::pixmap_create_from_xpm_d($sample_notebook->window, null, $book_closed_xpm);
        create_pages(&$sample_notebook, 1, 5);
        $separator =& new GtkHSeparator();
        $separator->show();
        $box1->pack_start($separator, false, true, 10);
        $box2 =& new GtkHBox(false, 5);
        $box2->show();
        $box2->set_border_width(10);
        $box1->pack_start($box2, false, true, 0);
        $button =& new GtkCheckButton('popup menu');
        $button->show();
        $box2->pack_start($button, true, false, 0);
        $button->connect('clicked', 'notebook_popup', &$sample_notebook);
        $button =& new GtkCheckButton('homogeneous tabs');
        $button->show();
        $box2->pack_start($button, true, false, 0);
        $button->connect('clicked', 'notebook_homogeneous', &$sample_notebook);
        $box2 =& new GtkHBox(false, 5);
        $box2->show();
        $box2->set_border_width(10);
        $box1->pack_start($box2, false, true, 0);
        $label =& new GtkLabel('Notebook Style:');
        $label->show();
        $box2->pack_start($label, false, true, 0);
        $omenu = build_option_menu($items, 3, 0, &$sample_notebook);
        $omenu->show();
        $box2->pack_start($omenu, false, true, 0);
        $button =& new GtkButton('Show all Pages');
        $button->show();
        $box2->pack_start($button, false, true, 0);
        $button->connect_object('clicked', 'show_all_pages', &$sample_notebook);
        $box2 =& new GtkHBox(true, 10);
        $box2->show();
        $box2->set_border_width(10);
        $box1->pack_start($box2, false, true, 0);
        $button =& new GtkButton('prev');
        $button->show();
        $button->connect_object('clicked', array(&$sample_notebook, 'prev_page'));
        $box2->pack_start($button, true, true, 0);
        $button =& new GtkButton('next');
        $button->show();
        $button->connect_object('clicked', array(&$sample_notebook, 'next_page'));
        $box2->pack_start($button, true, true, 0);
        $button =& new GtkButton('rotate');
        $button->show();
        $button->connect_object('clicked', 'notebook_rotate', &$sample_notebook);
        $box2->pack_start($button, true, true, 0);
        $separator =& new GtkHSeparator();
        $separator->show();
        $box1->pack_start($separator, false, true, 5);
        $button =& new GtkButton('close');
        $button->show();
        $button->set_border_width(5);
        $button->connect('clicked', 'close_window');
        $box1->pack_start($button, false, false, 0);
        $button->set_flags(GTK_CAN_DEFAULT);
        $button->grab_default();
    }
    if ($windows['notebook']->flags() & GTK_VISIBLE) {
        $windows['notebook']->hide();
    } else {
        $windows['notebook']->show();
    }
}