Ejemplo n.º 1
0
function hide_show_menu_item($id, $key, $default = '')
{
    if ($extend = Extend::field('page', $key, $id)) {
        return Extend::value($extend, $default);
    }
    return $default;
}
Ejemplo n.º 2
0
function page_custom_field($key, $default = '')
{
    $id = Registry::prop('page', 'id');
    if ($extend = Extend::field('page', $key, $id)) {
        return Extend::value($extend, $default);
    }
    return $default;
}
Ejemplo n.º 3
0
 public static function listing($category = null, $page = 1, $per_page = 10, $language = false)
 {
     // get total
     $query = static::left_join(Base::table('users'), Base::table('users.id'), '=', Base::table('posts.author'))->where(Base::table('posts.status'), '=', 'published');
     if ($category) {
         $query->where(Base::table('posts.category'), '=', $category->id);
     }
     $total = $query->count();
     // get posts
     $posts = $query->sort(Base::table('posts.created'), 'desc')->take($per_page)->skip(--$page * $per_page)->get(array(Base::table('posts.*'), Base::table('users.id as author_id'), Base::table('users.bio as author_bio'), Base::table('users.real_name as author_name')));
     $outputPosts = array();
     if ($language !== false) {
         for ($i = 0; $i < count($posts); $i++) {
             $post_lang = Extend::value(Extend::field('post', 'targetlanguage', $posts[$i]->data["id"]));
             if ($post_lang === $language) {
                 $outputPosts[] = $posts[$i];
             }
         }
     } else {
         $outputPosts = $posts;
     }
     return array($total, $outputPosts);
 }
Ejemplo n.º 4
0
     List all posts and paginate through them
 */
 Route::get(array('admin/publications', 'admin/publications/(:num)'), function ($page = 1) {
     $currentPageCategoryId = getCurrentPageCategoryId('publication');
     $perpage = Config::meta('posts_per_page');
     $total = Post::where('category', '=', $currentPageCategoryId)->count();
     $posts = Post::where('category', '=', $currentPageCategoryId)->sort('created', 'desc')->take($perpage)->skip(($page - 1) * $perpage)->get();
     $url = Uri::to('admin/publications');
     //Doing something
     //Adding extend fields for each posts
     for ($i = 0; $i < count($posts); $i++) {
         $posts[$i]->typeofpublication = Extend::value(Extend::field('post', 'typeofpublication', $posts[$i]->id));
         $posts[$i]->bookimage = Extend::value(Extend::field('post', 'bookimage', $posts[$i]->id));
         $posts[$i]->externallink = Extend::value(Extend::field('post', 'externallink', $posts[$i]->id));
         $posts[$i]->customdate = Extend::value(Extend::field('post', 'customdate', $posts[$i]->id));
         $posts[$i]->publicofpublication = Extend::value(Extend::field('post', 'publicofpublication', $posts[$i]->id));
     }
     $pagination = new Paginator($posts, $total, $page, $perpage, $url);
     $vars['messages'] = Notify::read();
     $vars['posts'] = $pagination;
     $vars['categories'] = Category::sort('title')->get();
     return View::create('publications/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 /*
     Add new book
 */
 Route::get('admin/publications/addBook', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['page'] = Registry::get('posts_page');
     // extended fields
Ejemplo n.º 5
0
             if (!is_null($catchimage_extend) && !is_null($catchphrase_extend) && !is_null($catchphrase_en_extend)) {
                 $postsAccueil[$i]->data['catchphrase'] = $catchphrase_extend;
                 $postsAccueil[$i]->data['catchphrase_en'] = $catchphrase_en_extend;
                 $postsAccueil[$i]->data['catchimage'] = $catchimage_extend;
                 $vars['accroche'] = $postsAccueil[$i];
             }
         }
     }
     $vars['bioimage'] = Extend::value(Extend::field('page', 'bioimage', $biopage->id));
     $vars['biofirstpart'] = Extend::value(Extend::field('page', 'biofirstpart', $biopage->id));
     $vars['biosecondpart'] = Extend::value(Extend::field('page', 'biosecondpart', $biopage->id));
     $vars['biothirdpart'] = Extend::value(Extend::field('page', 'biothirdpart', $biopage->id));
     $vars['bioimage_en'] = Extend::value(Extend::field('page', 'bioimage_en', $biopage->id));
     $vars['biofirstpart_en'] = Extend::value(Extend::field('page', 'biofirstpart_en', $biopage->id));
     $vars['biosecondpart_en'] = Extend::value(Extend::field('page', 'biosecondpart_en', $biopage->id));
     $vars['biothirdpart_en'] = Extend::value(Extend::field('page', 'biothirdpart_en', $biopage->id));
     return View::create('accueil/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 /**
  * Team Member
  */
 Route::get('admin/accueil/addTeamMember', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['page'] = Registry::get('posts_page');
     // extended fields
     $vars['fields'] = Extend::fields('post');
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     $vars['categories'] = Category::dropdown();
     return View::create('accueil/addTeamMember', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
Ejemplo n.º 6
0
 /*
     List all posts and paginate through them
 */
 Route::get(array('admin/dossiers', 'admin/dossiers/(:num)', 'admin/dossiers/(:num)/(:any)'), function ($page = 1, $lang = 'all') {
     $lang = $lang == 'fr' || $lang == 'en' || ($lang = 'all') ? $lang : 'all';
     $currentPageCategoryId = getCurrentPageCategoryId('dossier');
     $url = Uri::to('admin/dossiers');
     $perpage = Config::meta('posts_per_page');
     $allPosts = Post::where('category', '=', $currentPageCategoryId)->sort('created', 'asc')->get();
     $allPostsSelectedLanguage = [];
     $curPagePosts = [];
     $indexFirstOk = ($page - 1) * $perpage;
     $indexLastOk = $indexFirstOk + $perpage;
     for ($i = 0; $i < count($allPosts); $i++) {
         //Getting all posts for selected language
         $allPosts[$i]->targetlanguage = Extend::value(Extend::field('post', 'targetlanguage', $allPosts[$i]->id));
         if ($lang == 'all' || $allPosts[$i]->targetlanguage == $lang) {
             $allPostsSelectedLanguage[] = $allPosts[$i];
         }
     }
     $i = $indexFirstOk;
     while ($i < count($allPostsSelectedLanguage) && $i < $indexLastOk) {
         //Getting all posts for current page
         $curPagePosts[] = $allPostsSelectedLanguage[$i];
         $i++;
     }
     $pagination = new Paginator($curPagePosts, count($allPostsSelectedLanguage), $page, $perpage, $url, $lang);
     $vars['messages'] = Notify::read();
     $vars['posts'] = $pagination;
     $vars['categories'] = Category::sort('title')->get();
     $vars['choosenlanguage'] = $lang;
Ejemplo n.º 7
0
    Registry::set('currentPageNumber', $pageNumber);
    return new Template('page');
});
/**
 * Blog Page
 */
Route::get(array('blog', 'blog/(:any)'), function ($pageNumber = 1) {
    $page = Page::slug('blog');
    $category = Category::slug('blog');
    $per_page = Config::meta('posts_per_page');
    list($total, $posts) = Post::listing($category, $pageNumber, $per_page);
    //     get the last page
    $max_page = $total > $per_page ? ceil($total / $per_page) : 1;
    for ($i = 0; $i < count($posts); $i++) {
        $postId = $posts[$i]->data["id"];
        $posts[$i]->data['lang'] = Extend::value(Extend::field('post', 'targetlanguage', $postId));
    }
    // stop users browsing to non existing ranges
    if ($pageNumber > $max_page or $pageNumber < 1) {
        return Response::create(new Template('404'), 404);
    }
    Registry::set('posts', $posts);
    Registry::set('page', $page);
    Registry::set('category', $category);
    Registry::set('total_posts', $total);
    Registry::set('maxPageNumber', $max_page);
    Registry::set('currentPageNumber', $pageNumber);
    return new Template('page');
});
Route::get('upload/numpy', function () {
    return new Template('upload/send');
Ejemplo n.º 8
0
/**
 * Get a custom field value
 *
 * @param  string
 * @param  string
 * @return string
 */
function article_custom_field($key, $default = '', $id = null)
{
    if ($id == null) {
        $id = Registry::prop('article', 'id');
    }
    if ($extend = Extend::field('post', $key, $id)) {
        return Extend::value($extend, $default);
    }
    return $default;
}