Example #1
0
function display_site_object()
{
    $site_object = new wp_model();
    $site_title = $site_object->get_site_title();
    $main_nav = $site_object->get_main_nav();
    $category_nav = $site_object->get_category_nav();
    $archive_nav = $site_object->get_archive_nav();
    $bookmark_nav = $site_object->get_bookmarks();
    $post_count = $site_object->get_post_count();
    $user_logged_in = is_user_logged_in() ? 'true' : 'false';
    # $random = ((rand()%9)*(rand()%8)*(rand()%7));
    if (!isset($_GET['_escaped_fragment_'])) {
        echo '<script src="' . get_bloginfo('template_url') . '/assets/js/loadscripts.js" type="text/javascript"></script>';
        echo '<script>';
        echo 'var site = site || {';
        echo 'base_url:"' . get_bloginfo('url') . '",';
        echo 'logged_in:' . $user_logged_in . ',';
        echo 'twtr_info: ' . get_user_twitter_info() . ',';
        echo 'pages:' . json_encode($main_nav) . ',';
        echo 'title:' . json_encode($site_title) . ',';
        echo 'categories:' . json_encode($category_nav) . ',';
        echo 'archives:' . json_encode($archive_nav) . ',';
        echo 'bookmarks:' . json_encode($bookmark_nav) . ',';
        echo 'post_count:' . $post_count . ',';
        echo 'scripts:[';
        echo '"https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js",';
        echo '"http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js",';
        echo '"http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.6/underscore-min.js",';
        echo '"http://ajax.cdnjs.com/ajax/libs/backbone.js/0.3.3/backbone-min.js",';
        echo '"' . get_bloginfo('template_url') . '/assets/js/wpApp.min.js"';
        echo '],';
        echo 'js:{}';
        echo '};';
        echo '$script(site.scripts,function(){';
        echo 'var appController=new site.js.wordpressController();});';
        echo '</script>';
    }
}
Example #2
0
 public function display()
 {
     $view = new wp_view();
     switch ($this->template) {
         case 'category':
             if ($this->arguments_length == 4) {
                 $view->setTemplate('category');
                 $meta = array('slug' => $this->route_fragments[1], 'id' => $this->route_fragments[2], 'page' => $this->route_fragments[3]);
                 $output = wp_model::get_category_entries($meta['slug'], $meta['id'], $meta['page']);
                 $view->assign('meta', $meta);
             } else {
                 $view->setTemplate('redirect');
                 $output = '#!/404/';
             }
             break;
         case 'archive':
             if ($this->arguments_length == 4) {
                 $view->setTemplate('archive');
                 $meta = array('month' => $this->route_fragments[1], 'year' => $this->route_fragments[2], 'page' => $this->route_fragments[3]);
                 $output = wp_model::get_archive_entries($meta['month'], $meta['year'], $meta['page']);
                 $view->assign('meta', $meta);
             } else {
                 $view->setTemplate('redirect');
                 $output = '#!/404/';
             }
             break;
         case 'post':
             if ($this->arguments_length == 3) {
                 $view->setTemplate('post');
                 $id = $this->route_fragments[2];
                 $output = wp_model::get_post_entry($id);
             } else {
                 $view->setTemplate('redirect');
                 $output = '#!/404/';
             }
             break;
         case 'commentform':
             $view->setTemplate('commentform');
             $output = '';
             break;
         case 'comment_delete':
             $view->setTemplate('comment_delete');
             $id = $this->route_fragments[1];
             $output = wp_model::delete_comment($id);
             break;
         case 'page':
             if ($this->arguments_length == 2) {
                 $view->setTemplate('page');
                 $slug = $this->route_fragments[1];
                 $output = wp_model::get_page_entry($slug);
             } else {
                 $view->setTemplate('redirect');
                 $output = '#!/404/';
             }
             break;
         case 'index':
             if ($this->arguments_length == 2) {
                 $view->setTemplate('index');
                 $page = $this->route_fragments[1];
                 $output = wp_model::get_index_entries($page);
                 $view->assign('page', $page);
             } else {
                 $view->setTemplate('redirect');
                 $output = '#!/404/';
             }
             break;
         case '404':
             $view->setTemplate('404');
             $output = '';
             break;
         default:
             $view->setTemplate('redirect');
             $output = '#!/404/';
             break;
     }
     $title = wp_model::get_site_title();
     $main_nav = wp_model::get_main_nav();
     $category_nav = wp_model::get_category_nav();
     $archive_nav = wp_model::get_archive_nav();
     $bookmarks = wp_model::get_bookmarks();
     $view->assign('title', $title);
     $view->assign('main_nav', $main_nav);
     $view->assign('category_nav', $category_nav);
     $view->assign('archive_nav', $archive_nav);
     $view->assign('bookmarks', $bookmarks);
     $view->assign('content', $output);
     $view->assign('output_type', $this->output_type);
     return $view->loadTemplate();
 }