Exemple #1
0
function homepage($lang)
{
    global $sitename, $siteshot;
    $page_contents = build('content', $lang, 'homepage');
    $besocial = $sharebar = false;
    $ilike = true;
    $tweetit = true;
    $plusone = true;
    $linkedin = true;
    $pinit = true;
    if ($tweetit or $pinit) {
        $description = translate('description', $lang);
        if ($tweetit) {
            $tweet_text = $description ? $description : $sitename;
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $description ? $description : $sitename;
            $pinit_image = $siteshot;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
    }
    list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    $content = view('anypage', false, compact('page_contents', 'besocial'));
    head('title', $sitename);
    $languages = 'homepage';
    $contact = true;
    $banner = build('banner', $lang, compact('languages', 'contact'));
    $languages = false;
    $contact = false;
    $footer = build('footer', $lang, compact('languages', 'contact'));
    $output = layout('standard', compact('sharebar', 'banner', 'footer', 'content'));
    return $output;
}
Exemple #2
0
function anypage($lang, $arglist = false)
{
    global $sitename, $siteshot;
    $page = false;
    if (is_array($arglist)) {
        $page = implode('/', $arglist);
    }
    if (!$page) {
        return run('error/notfound', $lang);
    }
    $page_contents = build('content', $lang, $page);
    if ($page_contents === false) {
        return run('error/notfound', $lang);
    }
    $besocial = $sharebar = false;
    $ilike = true;
    $tweetit = true;
    $plusone = true;
    $linkedin = true;
    $pinit = true;
    if ($tweetit or $pinit) {
        $description = translate('description', $lang);
        if ($tweetit) {
            $tweet_text = $description ? $description : $sitename;
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $description ? $description : $sitename;
            $pinit_image = $siteshot;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
    }
    list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    $content = view('anypage', false, compact('page_contents', 'besocial'));
    head('title', $sitename);
    $contact = false;
    $banner = build('banner', $lang, compact('contact'));
    $contact = false;
    $footer = build('footer', $lang, compact('contact'));
    $output = layout('standard', compact('sharebar', 'banner', 'footer', 'content'));
    return $output;
}
Exemple #3
0
function home($lang)
{
    global $root_node, $request_path, $with_toolbar, $sitename, $siteshot;
    if (!$root_node) {
        return run('error/internalerror', $lang);
    }
    $r = node_get($lang, $root_node);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_name node_title node_abstract node_cloud node_image node_created node_modified node_nocomment node_nomorecomment node_ilike node_tweet node_plusone node_linkedin node_pinit */
    head('title', translate('home:title', $lang));
    if ($node_abstract) {
        head('description', $node_abstract);
    } else {
        head('description', translate('description', $lang));
    }
    if ($node_cloud) {
        head('keywords', $node_cloud);
    } else {
        head('keywords', translate('keywords', $lang));
    }
    $request_path = $lang;
    $page_contents = build('nodecontent', $lang, $root_node);
    $besocial = $sharebar = false;
    if ($page_contents) {
        $ilike = $node_ilike;
        $tweetit = $node_tweet;
        $plusone = $node_plusone;
        $linkedin = $node_linkedin;
        $pinit = $node_pinit;
        if ($tweetit or $pinit) {
            $description = $node_abstract ? $node_abstract : translate('description', $lang);
            if ($tweetit) {
                $tweet_text = $description ? $description : $sitename;
                $tweetit = $tweet_text ? compact('tweet_text') : true;
            }
            if ($pinit) {
                $pinit_text = $description ? $description : $sitename;
                $pinit_image = $node_image ? $node_image : $siteshot;
                $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
            }
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('home', false, compact('page_contents', 'besocial'));
    $languages = 'home';
    $contact = $account = $admin = $donate = true;
    $edit = user_has_role('writer') ? url('editpage', $_SESSION['user']['locale']) . '/' . $root_node . '?' . 'clang=' . $lang : false;
    $validate = url('home', $lang);
    $banner = build('banner', $lang, $with_toolbar ? compact('languages', 'contact', 'account', 'admin', 'donate') : compact('languages', 'contact', 'account', 'admin', 'donate', 'edit', 'validate'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $search_text = '';
    $search_url = url('search', $lang);
    $suggest_url = url('suggest', $lang);
    $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url'));
    $sidebar = view('sidebar', false, compact('search'));
    $contact_page = url('contact', $lang);
    $newsletter_page = false;
    $footer = view('footer', $lang, compact('contact_page', 'newsletter_page'));
    $output = layout('standard', compact('footer', 'banner', 'content', 'sidebar', 'sharebar', 'toolbar'));
    return $output;
}
Exemple #4
0
function story($lang, $arglist = false)
{
    global $request_path, $with_toolbar;
    $story = $page = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $story = $arglist[0];
        }
        if (isset($arglist[1])) {
            $page = $arglist[1];
        }
    }
    if (!$story) {
        return run('error/notfound', $lang);
    }
    $story_id = thread_id($story);
    if (!$story_id) {
        return run('error/notfound', $lang);
    }
    $page_id = thread_node_id($story_id, $page, $lang);
    if (!$page_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $story_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_type thread_name thread_title thread_abstract thread_cloud thread_nocloud thread_nosearch thread_nocomment thread_nomorecomment */
    if ($thread_type != 'story') {
        return run('error/notfound', $lang);
    }
    $story_name = $thread_name;
    $story_title = $thread_title;
    $story_abstract = $thread_abstract;
    $story_cloud = $thread_cloud;
    $story_nocloud = $thread_nocloud;
    $story_nosearch = $thread_nosearch;
    $r = thread_get_node($lang, $story_id, $page_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_number node_ignored node_name node_title node_abstract node_cloud node_user_id node_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin */
    if ($node_ignored) {
        return run('error/notfound', $lang);
    }
    $page_user_id = $node_user_id;
    $page_name = $node_name;
    $page_title = $node_title;
    $page_abstract = $node_abstract;
    $page_cloud = $node_cloud;
    $page_number = $node_number;
    $page_modified = $node_modified;
    if (!$page) {
        $request_path .= '/' . $page_name;
    }
    if ($story_title) {
        head('title', $story_title);
    }
    if ($page_abstract) {
        head('description', $page_abstract);
    } else {
        if ($story_abstract) {
            head('description', $story_abstract);
        }
    }
    if ($page_cloud) {
        head('keywords', $page_cloud);
    } else {
        if ($story_cloud) {
            head('keywords', $story_cloud);
        }
    }
    head('date', $page_modified);
    $page_contents = build('nodecontent', $lang, $page_id);
    $page_comment = false;
    if (!($thread_nocomment or $node_nocomment)) {
        $nomore = (!$page_contents or $thread_nomorecomment or $node_nomorecomment) ? true : false;
        $page_url = url('story', $lang) . '/' . $story_name . '/' . $page_name;
        $page_comment = build('nodecomment', $lang, $page_id, $page_user_id, $page_url, $nomore);
    }
    $vote = false;
    if (!($thread_novote or $node_novote)) {
        $nomore = (!$page_contents or $thread_nomorevote or $node_nomorevote) ? true : false;
        $vote = build('vote', $lang, $page_id, 'node', $nomore);
    }
    $visits = false;
    if ($thread_visits and $node_visits) {
        $nomore = user_has_role('writer');
        $visits = build('visits', $lang, $page_id, $nomore);
    }
    $besocial = $sharebar = false;
    if ($page_contents or $page_comment) {
        $ilike = $thread_ilike && $node_ilike;
        $tweetit = $thread_tweet && $node_tweet;
        $plusone = $thread_plusone && $node_plusone;
        $linkedin = $thread_linkedin && $node_linkedin;
        $pinit = $thread_pinit && $node_pinit;
        if ($tweetit) {
            $tweet_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $pinit_image = $node_image;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('storycontent', false, compact('page_id', 'page_title', 'page_contents', 'page_comment', 'page_number', 'besocial', 'vote', 'visits'));
    $search = false;
    if (!$story_nosearch) {
        $search_text = '';
        $search_url = url('search', $lang, $story_name);
        $suggest_url = url('suggest', $lang, $story_name);
        $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url'));
    }
    $cloud = false;
    if (!$story_nocloud) {
        $cloud_url = url('search', $lang, $story_name);
        $byname = $bycount = $index = true;
        $cloud = build('cloud', $lang, $cloud_url, $story_id, false, 30, compact('byname', 'bycount', 'index'));
    }
    $summary = array();
    $r = thread_get_contents($lang, $story_id);
    if ($r) {
        $story_url = url('story', $lang) . '/' . $story_name;
        foreach ($r as $c) {
            extract($c);
            /* node_id node_name node_title node_number */
            $summary_page_id = $node_id;
            $summary_page_title = $node_title;
            $summary_page_url = $story_url . '/' . $node_name;
            $summary[] = compact('summary_page_id', 'summary_page_title', 'summary_page_url');
        }
    }
    $title = false;
    if ($story_title) {
        $headline_text = $story_title;
        $headline_url = false;
        $headline = compact('headline_text', 'headline_url');
        $title = view('headline', false, $headline);
    }
    $sidebar = view('sidebar', false, compact('search', 'cloud', 'title', 'summary'));
    $search = !$story_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false;
    $edit = user_has_role('writer') ? url('storyedit', $_SESSION['user']['locale']) . '/' . $story_id . '/' . $page_id . '?' . 'clang=' . $lang : false;
    $validate = url('story', $lang) . '/' . $story_name . '/' . $page_name;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'edit', 'validate', 'search'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'sidebar', 'content'));
    return $output;
}
Exemple #5
0
function folderpage($lang, $folder, $page)
{
    global $with_toolbar;
    $folder_id = thread_id($folder);
    if (!$folder_id) {
        return run('error/notfound', $lang);
    }
    $page_id = thread_node_id($folder_id, $page, $lang);
    if (!$page_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $folder_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_type thread_name thread_title thread_abstract thread_cloud thread_image */
    if (!($thread_type == 'folder' or $thread_type == 'book' or $thread_type == 'story')) {
        return run('error/notfound', $lang);
    }
    $folder_name = $thread_name;
    $folder_title = $thread_title;
    $folder_abstract = $thread_abstract;
    $folder_cloud = $thread_cloud;
    $r = thread_get_node($lang, $folder_id, $page_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* node_number node_ignored node_name node_title node_abstract node_cloud node_image node_user_id node_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin node_pinit */
    if ($node_ignored) {
        return run('error/notfound', $lang);
    }
    $page_user_id = $node_user_id;
    $page_name = $node_name;
    $page_title = $node_title;
    $page_abstract = $node_abstract;
    $page_cloud = $node_cloud;
    $page_modified = $node_modified;
    if ($page_title) {
        head('title', $page_title);
    } else {
        if ($folder_title) {
            head('title', $folder_title);
        }
    }
    if ($page_abstract) {
        head('description', $page_abstract);
    } else {
        if ($folder_abstract) {
            head('description', $folder_abstract);
        }
    }
    if ($page_cloud) {
        head('keywords', $page_cloud);
    } else {
        if ($folder_cloud) {
            head('keywords', $folder_cloud);
        }
    }
    head('date', $page_modified);
    $page_contents = build('nodecontent', $lang, $page_id);
    $page_comment = false;
    if (!($thread_nocomment or $node_nocomment)) {
        $nomore = (!$page_contents or $thread_nomorecomment or $node_nomorecomment) ? true : false;
        $page_url = url('folder', $lang) . '/' . $folder_name . '/' . $page_name;
        $page_comment = build('nodecomment', $lang, $page_id, $page_user_id, $page_url, $nomore);
    }
    $vote = false;
    if (!($thread_novote or $node_novote)) {
        $nomore = (!$page_contents or $thread_nomorevote or $node_nomorevote) ? true : false;
        $vote = build('vote', $lang, $page_id, 'node', $nomore);
    }
    $visits = false;
    if ($thread_visits and $node_visits) {
        $nomore = user_has_role('writer');
        $visits = build('visits', $lang, $page_id, $nomore);
    }
    $besocial = $sharebar = false;
    if ($page_contents or $page_comment) {
        $ilike = $thread_ilike && $node_ilike;
        $tweetit = $thread_tweet && $node_tweet;
        $plusone = $thread_plusone && $node_plusone;
        $linkedin = $thread_linkedin && $node_linkedin;
        $pinit = $thread_pinit && $node_pinit;
        if ($tweetit) {
            $tweet_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $node_abstract ? $node_abstract : ($node_title ? $node_title : $thread_title);
            $pinit_image = $node_image;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('folderpage', false, compact('page_title', 'page_contents', 'page_comment', 'besocial', 'vote', 'visits'));
    $edit = user_has_role('writer') ? url('folderedit', $_SESSION['user']['locale']) . '/' . $folder_id . '/' . $page_id . '?' . 'clang=' . $lang : false;
    $validate = url('folder', $lang) . '/' . $folder_name . '/' . $page_name;
    $banner = build('banner', $lang, $with_toolbar ? false : compact('edit', 'validate'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'content'));
    return $output;
}
Exemple #6
0
function booksummary($lang, $book)
{
    global $with_toolbar;
    $book_id = thread_id($book);
    if (!$book_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $book_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_name thread_title thread_abstract thread_cloud thread_image thread_nocloud thread_nosearch */
    if ($thread_type != 'book') {
        return run('error/notfound', $lang);
    }
    $book_name = $thread_name;
    $book_title = $thread_title;
    $book_abstract = $thread_abstract;
    $book_cloud = $thread_cloud;
    $book_modified = $thread_modified;
    $book_nocloud = $thread_nocloud;
    $book_nosearch = $thread_nosearch;
    $book_novote = $thread_novote;
    $book_nomorevote = $thread_nomorevote;
    if ($book_title) {
        head('title', $book_title);
    }
    if ($book_abstract) {
        head('description', $book_abstract);
    }
    if ($book_cloud) {
        head('keywords', $book_cloud);
    }
    head('date', $book_modified);
    $book_contents = array();
    $r = thread_get_contents($lang, $book_id);
    if ($r) {
        $book_url = url('book', $lang) . '/' . $book_name;
        foreach ($r as $c) {
            extract($c);
            /* node_id node_name node_title node_number */
            $page_id = $node_id;
            $page_title = $node_title;
            $page_url = $book_url . '/' . $node_name;
            $book_contents[] = compact('page_id', 'page_title', 'page_url');
        }
    }
    $vote = false;
    if (!$book_novote) {
        $nomore = (!$book_contents or $book_nomorevote) ? true : false;
        $vote = build('vote', $lang, $book_id, 'thread', $nomore);
    }
    $besocial = $sharebar = false;
    if ($book_contents) {
        $ilike = $thread_ilike;
        $tweetit = $thread_tweet;
        $plusone = $thread_plusone;
        $linkedin = $thread_linkedin;
        $pinit = $thread_pinit;
        if ($tweetit) {
            $tweet_text = $thread_abstract ? $thread_abstract : $thread_title;
            $tweetit = $tweet_text ? compact('tweet_text') : true;
        }
        if ($pinit) {
            $pinit_text = $thread_abstract ? $thread_abstract : $thread_title;
            $pinit_image = $thread_image;
            $pinit = $pinit_text && $pinit_image ? compact('pinit_text', 'pinit_image') : false;
        }
        list($besocial, $sharebar) = socialize($lang, compact('ilike', 'tweetit', 'plusone', 'linkedin', 'pinit'));
    }
    $content = view('booksummary', false, compact('book_id', 'book_title', 'book_abstract', 'book_contents', 'besocial', 'vote'));
    $search = false;
    if (!$book_nosearch) {
        $search_text = '';
        $search_url = url('search', $lang, $book_name);
        $suggest_url = url('suggest', $lang, $book_name);
        $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url'));
    }
    $cloud = false;
    if (!$book_nocloud) {
        $cloud_url = url('search', $lang, $book_name);
        $byname = $bycount = $index = true;
        $cloud = build('cloud', $lang, $cloud_url, $book_id, false, 30, compact('byname', 'bycount', 'index'));
    }
    $headline_text = translate('bookall:title', $lang);
    $headline_url = url('book', $lang);
    $headline = compact('headline_text', 'headline_url');
    $title = view('headline', false, $headline);
    $sidebar = view('sidebar', false, compact('search', 'cloud', 'title'));
    $search = !$book_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false;
    $edit = user_has_role('writer') ? url('bookedit', $_SESSION['user']['locale']) . '/' . $book_id . '?' . 'clang=' . $lang : false;
    $validate = url('book', $lang) . '/' . $book_name;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'edit', 'validate', 'search'));
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'validate')) : false;
    $output = layout('standard', compact('sharebar', 'toolbar', 'banner', 'sidebar', 'content'));
    return $output;
}