function threadsummary($lang, $thread) { global $system_languages, $with_toolbar; if (!user_has_role('writer')) { return run('error/unauthorized', $lang); } $slang = false; if (isset($_GET['slang'])) { $slang = $_GET['slang']; } else { $slang = $lang; } if (!in_array($slang, $system_languages)) { return run('error/notfound', $lang); } $thread_id = thread_id($thread); if (!$thread_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $thread_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_name thread_title thread_type thread_abstract thread_cloud thread_image thread_visits thread_nosearch thread_nocloud thread_nocomment thread_nomorecomment thread_novote thread_nomorevote thread_created thread_modified */ $thread_search = !$thread_nosearch; $thread_tag = !$thread_nocloud; $thread_comment = !$thread_nocomment; $thread_morecomment = !$thread_nomorecomment; $thread_vote = !$thread_novote; $thread_morevote = !$thread_nomorevote; $thread_contents = array(); $r = thread_get_contents($lang, $thread_id, false); if ($r) { $thread_url = url('thread', $lang) . '/' . $thread_id; foreach ($r as $c) { extract($c); /* node_id node_name node_title node_number node_ignored */ $node_url = $thread_url . '/' . $node_id . '?' . 'slang=' . $slang; $thread_contents[] = compact('node_id', 'node_title', 'node_url', 'node_ignored'); } } $headline_text = translate('threadall:title', $slang); $headline_url = url('thread', $lang) . '?' . 'slang=' . $slang; $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('title')); head('title', $thread_title ? $thread_title : $thread_id); head('description', $thread_abstract); head('keywords', $thread_cloud); head('robots', 'noindex, nofollow'); $edit = user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/' . $thread_id . '?' . 'clang=' . $lang : false; $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'edit')); $scroll = true; $toolbar = $with_toolbar ? build('toolbar', $lang, compact('edit', 'scroll')) : false; $content = view('threadsummary', $slang, compact('thread_id', 'thread_title', 'thread_abstract', 'thread_cloud', 'thread_image', 'thread_visits', 'thread_search', 'thread_tag', 'thread_comment', 'thread_morecomment', 'thread_vote', 'thread_morevote', 'thread_ilike', 'thread_tweet', 'thread_plusone', 'thread_linkedin', 'thread_pinit', 'thread_created', 'thread_modified', 'thread_contents')); $output = layout('viewing', compact('toolbar', 'banner', 'content', 'sidebar')); return $output; }
function foldersummary($lang, $folder) { global $with_toolbar; $folder_id = thread_id($folder); if (!$folder_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 */ if ($thread_type != 'folder') { return run('error/notfound', $lang); } $folder_name = $thread_name; $folder_title = $thread_title; $folder_abstract = $thread_abstract; $folder_cloud = $thread_cloud; if ($folder_title) { head('title', $folder_title); } if ($folder_abstract) { head('description', $folder_abstract); } if ($folder_cloud) { head('keywords', $folder_cloud); } $folder_contents = array(); $r = thread_get_contents($lang, $folder_id); if ($r) { $folder_url = url('folder', $lang) . '/' . $folder_name; foreach ($r as $c) { extract($c); /* node_name node_title */ if (!$node_title) { continue; } $page_title = $node_title; $page_url = $folder_url . '/' . $node_name; $folder_contents[] = compact('page_title', 'page_url'); } } $content = view('foldersummary', false, compact('folder_id', 'folder_title', 'folder_contents')); $edit = user_has_role('writer') ? url('folderedit', $_SESSION['user']['locale']) . '/' . $folder_id . '?' . 'clang=' . $lang : false; $validate = url('folder', $lang) . '/' . $folder_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('toolbar', 'banner', 'content')); return $output; }
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; }
function threadeditsummary($lang, $clang, $thread) { global $supported_threads, $with_toolbar; if (!user_has_role('writer')) { return run('error/unauthorized', $lang); } $confirmed = false; $thread_id = thread_id($thread); if (!$thread_id) { return run('error/notfound', $lang); } $action = 'init'; if (isset($_POST['thread_edit'])) { $action = 'edit'; } else { if (isset($_POST['thread_reorder'])) { $action = 'reorder'; } else { if (isset($_POST['node_create'])) { $action = 'create'; } else { if (isset($_POST['node_copy'])) { $action = 'copy'; } else { if (isset($_POST['node_delete'])) { $action = 'delete'; } else { if (isset($_POST['node_confirmdelete'])) { $action = 'delete'; $confirmed = true; } else { if (isset($_POST['node_hide'])) { $action = 'hide'; } else { if (isset($_POST['node_show'])) { $action = 'show'; } } } } } } } } $thread_type = $thread_name = $thread_title = $thread_abstract = $thread_cloud = $thread_image = false; $thread_search = $thread_tag = false; $thread_comment = $thread_morecomment = $thread_vote = $thread_morevote = false; $thread_ilike = $thread_tweet = $thread_plusone = $thread_linkedin = $thread_pinit = false; $thread_visits = false; $thread_nosearch = $thread_nocloud = $thread_nocomment = $thread_nomorecomment = $thread_novote = $thread_nomorevote = true; $new_node_name = $new_node_title = $new_node_number = false; $old_node_number = false; $p = false; switch ($action) { case 'init': case 'reset': $r = thread_get($clang, $thread_id, false); if ($r) { extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud thread_image thread_visits thread_nosearch thread_nocloud thread_nocomment thread_nomorecomment thread_novote thread_nomorevote */ } $thread_search = !$thread_nosearch; $thread_tag = !$thread_nocloud; $thread_comment = !$thread_nocomment; $thread_morecomment = !$thread_nomorecomment; $thread_vote = !$thread_novote; $thread_morevote = !$thread_nomorevote; break; case 'edit': case 'create': case 'copy': case 'delete': case 'hide': case 'show': case 'reorder': if (isset($_POST['thread_type'])) { $thread_type = readarg($_POST['thread_type']); } if (isset($_POST['thread_title'])) { $thread_title = readarg($_POST['thread_title']); } if (isset($_POST['thread_name'])) { $thread_name = strtofname(readarg($_POST['thread_name'])); } if (!$thread_name and $thread_title) { $thread_name = strtofname($thread_title); } if (isset($_POST['thread_abstract'])) { $thread_abstract = readarg($_POST['thread_abstract']); } if (isset($_POST['thread_image'])) { $thread_image = readarg($_POST['thread_image']); } if (isset($_POST['thread_cloud'])) { $thread_cloud = readarg($_POST['thread_cloud'], true, false); // trim but DON'T strip! preg_match_all('/(\\S+)/', $thread_cloud, $r); $thread_cloud = implode(' ', array_unique($r[0])); } if (isset($_POST['thread_search'])) { $thread_search = readarg($_POST['thread_search']) == 'on' ? true : false; $thread_nosearch = !$thread_search; } if (isset($_POST['thread_tag'])) { $thread_tag = readarg($_POST['thread_tag']) == 'on' ? true : false; $thread_nocloud = !$thread_tag; } if (isset($_POST['thread_visits'])) { $thread_visits = readarg($_POST['thread_visits']) == 'on' ? true : false; } if (isset($_POST['thread_comment'])) { $thread_comment = readarg($_POST['thread_comment']) == 'on' ? true : false; $thread_nocomment = !$thread_comment; } if (isset($_POST['thread_morecomment'])) { $thread_morecomment = readarg($_POST['thread_morecomment']) == 'on' ? true : false; $thread_nomorecomment = !$thread_morecomment; } if (isset($_POST['thread_vote'])) { $thread_vote = readarg($_POST['thread_vote']) == 'on' ? true : false; $thread_novote = !$thread_vote; } if (isset($_POST['thread_morevote'])) { $thread_morevote = readarg($_POST['thread_morevote']) == 'on' ? true : false; $thread_nomorevote = !$thread_morevote; } if (isset($_POST['thread_ilike'])) { $thread_ilike = readarg($_POST['thread_ilike'] == 'on' ? true : false); } if (isset($_POST['thread_tweet'])) { $thread_tweet = readarg($_POST['thread_tweet'] == 'on' ? true : false); } if (isset($_POST['thread_plusone'])) { $thread_plusone = readarg($_POST['thread_plusone'] == 'on' ? true : false); } if (isset($_POST['thread_linkedin'])) { $thread_linkedin = readarg($_POST['thread_linkedin'] == 'on' ? true : false); } if (isset($_POST['thread_pinit'])) { $thread_pinit = readarg($_POST['thread_pinit'] == 'on' ? true : false); } if (isset($_POST['new_node_title'])) { $new_node_title = readarg($_POST['new_node_title']); $new_node_name = strtofname($new_node_title); } if (isset($_POST['new_node_number'])) { $new_node_number = readarg($_POST['new_node_number']); } if (isset($_POST['old_node_number'])) { $old_node_number = readarg($_POST['old_node_number']); } if (isset($_POST['p'])) { $p = $_POST['p']; // DON'T readarg! } break; default: break; } $thread_contents = array(); $r = thread_get_contents($clang, $thread_id, false); /* node_id node_number node_ignored node_name node_title node_cloud thread_image */ if (!$r or count($r) != count($p)) { $p = false; } if ($r) { $pos = 1; $thread_url = url('threadedit', $lang) . '/' . $thread_id; foreach ($r as $c) { $c['node_url'] = $thread_url . '/' . $c['node_id']; $c['pos'] = $p ? $p[$pos] : $pos; $thread_contents[$pos] = $c; $pos++; } } $missing_thread_name = false; $bad_thread_name = false; $missing_thread_type = false; $bad_thread_type = false; $missing_new_node_title = false; $bad_new_node_title = false; $bad_new_node_number = false; $missing_old_node_number = false; $bad_old_node_number = false; switch ($action) { case 'edit': if (!$thread_name) { $missing_thread_name = true; } else { if (!preg_match('#^\\w+(-\\w+)*$#', $thread_name)) { $bad_thread_name = true; } } if (!$thread_type) { $missing_thread_type = true; } else { if (!in_array($thread_type, $supported_threads)) { $bad_thread_type = true; } } break; case 'create': case 'copy': if (!$new_node_title) { $missing_new_node_title = true; } else { if (!$new_node_name) { $bad_new_node_title = true; } else { if (!preg_match('#^\\w+(-\\w+)*$#', $new_node_name)) { $bad_new_node_title = true; } } } if (!$new_node_number) { $new_node_number = false; } else { if (!is_numeric($new_node_number)) { $bad_new_node_number = true; } else { if ($new_node_number < 1 or $new_node_number > count($thread_contents) + 1) { $bad_new_node_number = true; } } } if ($action == 'create') { break; } /* fall thru */ /* fall thru */ case 'delete': case 'hide': case 'show': if (!$old_node_number) { $missing_old_node_number = true; } else { if (!is_numeric($old_node_number)) { $bad_old_node_number = true; } else { if ($old_node_number < 1 or $old_node_number > count($thread_contents)) { $bad_old_node_number = true; } } } break; case 'reorder': break; default: break; } $confirm_delete_node = false; switch ($action) { case 'edit': if ($missing_thread_name or $bad_thread_name or $missing_thread_type or $bad_thread_type) { break; } $r = thread_set($clang, $thread_id, $thread_name, $thread_title, $thread_type, $thread_abstract, $thread_cloud, $thread_image, $thread_visits, $thread_nosearch, $thread_nocloud, $thread_nocomment, $thread_nomorecomment, $thread_novote, $thread_nomorevote, $thread_ilike, $thread_tweet, $thread_plusone, $thread_linkedin, $thread_pinit); if (!$r) { break; } break; case 'create': case 'copy': if ($missing_new_node_title or $bad_new_node_title or $bad_new_node_number or $action == 'copy' and ($missing_old_node_number or $bad_old_node_number)) { break; } $user_id = user_profile('id'); if ($action == 'copy') { $node_id = $thread_contents[$old_node_number]['node_id']; $np = thread_copy_node($clang, $user_id, $thread_id, $node_id, $new_node_name, $new_node_title, $new_node_number); } else { $np = thread_create_node($clang, $user_id, $thread_id, $new_node_name, $new_node_title, $new_node_number); } if (!$np) { break; } extract($np); /* node_id node_number node_ignored */ $node_ignored = false; $node_title = $new_node_title; $node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $node_id; $pos = $node_number; if ($thread_contents) { foreach ($thread_contents as &$c) { if ($c['node_number'] >= $pos) { $c['node_number']++; } if ($c['pos'] >= $pos) { $c['pos']++; } } array_splice($thread_contents, $pos - 1, 0, array(compact('node_id', 'node_title', 'node_number', 'node_ignored', 'node_url', 'pos'))); } else { $pos = 1; $thread_contents = array($pos => compact('node_id', 'node_title', 'node_number', 'node_ignored', 'node_url', 'pos')); } $new_node_name = $new_node_title = false; $new_node_number = $node_number + 1; $old_node_number = false; break; case 'delete': if ($missing_old_node_number or $bad_old_node_number) { break; } if (!$confirmed) { $confirm_delete_node = true; break; } $node_id = $thread_contents[$old_node_number]['node_id']; $r = thread_delete_node($thread_id, $node_id); if (!$r) { break; } unset($thread_contents[$old_node_number]); $thread_contents = array_values($thread_contents); foreach ($thread_contents as &$c) { if ($c['node_number'] >= $old_node_number) { $c['node_number']--; } if ($c['pos'] >= $old_node_number) { $c['pos']--; } } $new_node_number = $old_node_number = false; break; case 'hide': if ($missing_old_node_number or $bad_old_node_number) { break; } $node_id = $thread_contents[$old_node_number]['node_id']; $r = thread_set_node_ignored($thread_id, $node_id, true); if (!$r) { break; } $thread_contents[$old_node_number]['node_ignored'] = true; break; case 'show': if ($missing_old_node_number or $bad_old_node_number) { break; } $node_id = $thread_contents[$old_node_number]['node_id']; $r = thread_set_node_ignored($thread_id, $node_id, false); if (!$r) { break; } $thread_contents[$old_node_number]['node_ignored'] = false; break; case 'reorder': if (!$p) { break; } $neworder = range(1, count($p)); array_multisort($p, SORT_NUMERIC, $neworder); $number = 1; $nc = array(); foreach ($neworder as $i) { $c =& $thread_contents[$i]; if ($c['node_number'] != $number) { thread_set_node_number($thread_id, $c['node_id'], $number); $c['node_number'] = $number; } $c['pos'] = $number; $nc[$number++] = $c; } $thread_contents = $nc; break; default: break; } head('title', $thread_title ? $thread_title : $thread_id); head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $headline_text = translate('threadall:title', $lang); $headline_url = url('threadedit', $lang) . '?' . 'clang=' . $clang; $headline = compact('headline_text', 'headline_url'); $view = $thread_name ? url('thread', $clang) . '/' . $thread_id . '?' . 'slang=' . $lang : false; $scroll = true; $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'view')); $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false; $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('title')); $inlanguages = view('inlanguages', false, compact('clang')); $errors = compact('missing_thread_name', 'bad_thread_name', 'missing_thread_type', 'bad_thread_type', 'missing_new_node_title', 'bad_new_node_title', 'bad_new_node_number', 'missing_old_node_number', 'bad_old_node_number'); $content = view('editing/threadeditsummary', $lang, compact('clang', 'inlanguages', 'supported_threads', 'thread_id', 'thread_type', 'thread_title', 'thread_name', 'thread_abstract', 'thread_cloud', 'thread_image', 'thread_visits', 'thread_search', 'thread_tag', 'thread_comment', 'thread_morecomment', 'thread_vote', 'thread_morevote', 'thread_ilike', 'thread_tweet', 'thread_plusone', 'thread_linkedin', 'thread_pinit', 'thread_contents', 'new_node_name', 'new_node_title', 'new_node_number', 'old_node_number', 'confirm_delete_node', 'errors')); $output = layout('editing', compact('toolbar', 'banner', 'content', 'sidebar')); return $output; }
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; }
function newslettersummary($lang, $newsletter) { global $with_toolbar; $newsletter_id = thread_id($newsletter); if (!$newsletter_id) { return run('error/notfound', $lang); } $r = thread_get($lang, $newsletter_id); if (!$r) { return run('error/notfound', $lang); } extract($r); /* thread_name thread_title thread_abstract thread_cloud thread_nocloud thread_nosearch */ $newsletter_name = $thread_name; $newsletter_title = $thread_title; $newsletter_abstract = $thread_abstract; $newsletter_cloud = $thread_cloud; $newsletter_modified = $thread_modified; $newsletter_nocloud = $thread_nocloud; $newsletter_nosearch = $thread_nosearch; if ($newsletter_title) { head('title', $newsletter_title); } head('description', false); head('keywords', false); head('robots', 'noindex, nofollow'); $newsletter_contents = array(); $r = thread_get_contents($lang, $newsletter_id); if ($r) { $newsletter_url = url('newsletter', $lang); foreach ($r as $c) { extract($c); /* node_id node_name node_title node_number */ $page_id = $node_id; $page_title = $node_title; $page_url = $newsletter_url . '/' . $node_name; $newsletter_contents[] = compact('page_id', 'page_title', 'page_url'); } } $content = view('newslettersummary', false, compact('newsletter_id', 'newsletter_title', 'newsletter_abstract', 'newsletter_contents')); $search = false; if (!$newsletter_nosearch) { $search_text = ''; $search_url = url('search', $lang, $newsletter_name); $suggest_url = url('suggest', $lang, $newsletter_name); $search = view('searchinput', $lang, compact('search_url', 'search_text', 'suggest_url')); } $cloud = false; if (!$newsletter_nocloud) { $cloud_url = url('search', $lang, $newsletter_name); $byname = $bycount = $index = true; $cloud = build('cloud', $lang, $cloud_url, $newsletter_id, false, 30, compact('byname', 'bycount', 'index')); } $headline_text = translate('newsletter:title', $lang); $headline_url = false; $headline = compact('headline_text', 'headline_url'); $title = view('headline', false, $headline); $sidebar = view('sidebar', false, compact('search', 'cloud', 'title')); $search = !$newsletter_nosearch ? compact('search_url', 'search_text', 'suggest_url') : false; $edit = user_has_role('writer') ? url('newsletteredit', $_SESSION['user']['locale']) . '/' . $newsletter_id : false; $validate = url('newsletter', $lang) . '/' . $newsletter_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; }