コード例 #1
0
ファイル: threadeditnode.php プロジェクト: RazorMarx/izend
function threadeditnode($lang, $clang, $thread, $node)
{
    global $with_toolbar, $supported_contents, $limited_contents;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $thread_id = thread_id($thread);
    if (!$thread_id) {
        return run('error/notfound', $lang);
    }
    $node_id = thread_node_id($thread_id, $node, $clang);
    if (!$node_id) {
        return run('error/notfound', $lang);
    }
    $thread_name = $thread_title = $thread_abstract = $thread_cloud = $thread_type = false;
    $r = thread_get($clang, $thread_id, false);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_name thread_title thread_abstract thread_cloud thread_type */
    $content_types = $supported_contents;
    if ($thread_type and $limited_contents and array_key_exists($thread_type, $limited_contents)) {
        $content_types = $limited_contents[$thread_type];
    }
    $node_editor = build('nodeeditor', $lang, $clang, $node_id, $content_types);
    $node_name = $node_title = false;
    $r = thread_get_node($clang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        /* node_name node_title */
    }
    head('title', $thread_title ? $thread_title : $thread_id);
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $banner = $toolbar = false;
    $headline_text = $thread_title ? $thread_title : $thread_id;
    $headline_url = url('threadedit', $lang) . '/' . $thread_id . '?' . 'clang=' . $clang;
    $headline = compact('headline_text', 'headline_url');
    $view = $node_name ? url('thread', $clang) . '/' . $thread_id . '/' . $node_id . '?' . 'slang=' . $lang : false;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'view'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false;
    $prev_node_label = $prev_node_url = false;
    $r = thread_node_prev($clang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_id;
        $prev_node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $prev_node_id . '?' . 'clang=' . $clang;
    }
    $next_node_label = $next_node_url = false;
    $r = thread_node_next($clang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        $next_node_label = $next_node_title ? $next_node_title : $next_node_id;
        $next_node_url = url('threadedit', $lang) . '/' . $thread_id . '/' . $next_node_id . '?' . 'clang=' . $clang;
    }
    $title = view('headline', false, $headline);
    $sidebar = view('sidebar', false, compact('title'));
    $content = view('editing/threadeditnode', $lang, compact('node_editor', 'node_id', 'node_title', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label'));
    $output = layout('editing', compact('toolbar', 'banner', 'content', 'sidebar'));
    return $output;
}
コード例 #2
0
ファイル: threadnode.php プロジェクト: RazorMarx/izend
function threadnode($lang, $thread, $node)
{
    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_nocloud thread_nosearch thread_created thread_modified */
    $node_id = thread_node_id($thread_id, $node, $lang);
    if (!$node_id) {
        return run('error/notfound', $lang);
    }
    $r = node_get($lang, $node_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_visits node_nocomment node_nomorecomment node_novote node_nomorevote node_ilike node_tweet node_plusone node_linkedin node_pinit */
    $node_comment = !$node_nocomment;
    $node_morecomment = !$node_nomorecomment;
    $node_vote = !$node_novote;
    $node_morevote = !$node_nomorevote;
    $node_contents = build('nodecontent', $lang, $node_id);
    $headline_text = $thread_title ? $thread_title : $thread_id;
    $headline_url = url('thread', $lang) . '/' . $thread_name . '?' . 'slang=' . $slang;
    $headline = compact('headline_text', 'headline_url');
    $title = view('headline', false, $headline);
    $sidebar = view('sidebar', false, compact('title'));
    $prev_node_label = $prev_node_url = false;
    $r = thread_node_prev($lang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_id;
        $prev_node_url = url('thread', $lang) . '/' . $thread_id . '/' . $prev_node_id . '?' . 'slang=' . $slang;
    }
    $next_node_label = $next_node_url = false;
    $r = thread_node_next($lang, $thread_id, $node_id, false);
    if ($r) {
        extract($r);
        $next_node_label = $next_node_title ? $next_node_title : $next_node_id;
        $next_node_url = url('thread', $lang) . '/' . $thread_id . '/' . $next_node_id . '?' . 'slang=' . $slang;
    }
    head('title', $thread_title ? $thread_title : $thread_id);
    head('description', $node_abstract);
    head('keywords', $node_cloud);
    head('robots', 'noindex, nofollow');
    $edit = user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/' . $thread_id . '/' . $node_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('threadnode', $slang, compact('node_id', 'node_name', 'node_title', 'node_abstract', 'node_cloud', 'node_image', 'node_created', 'node_modified', 'node_visits', 'node_comment', 'node_morecomment', 'node_vote', 'node_morevote', 'node_ilike', 'node_tweet', 'node_plusone', 'node_linkedin', 'node_pinit', 'node_contents', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label'));
    $output = layout('viewing', compact('toolbar', 'banner', 'content', 'sidebar'));
    return $output;
}
コード例 #3
0
ファイル: bookpage.php プロジェクト: RazorMarx/izend
function bookpage($lang, $book, $page)
{
    global $with_toolbar;
    $book_id = thread_id($book);
    if (!$book_id) {
        return run('error/notfound', $lang);
    }
    $page_id = thread_node_id($book_id, $page, $lang);
    if (!$page_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $book_id);
    if (!$r) {
        return run('error/notfound', $lang);
    }
    extract($r);
    /* thread_type thread_name thread_title thread_abstract thread_cloud thread_image thread_nocloud thread_nosearch thread_nocomment thread_nomorecomment */
    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_nocloud = $thread_nocloud;
    $book_nosearch = $thread_nosearch;
    $r = thread_get_node($lang, $book_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 */
    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 ($book_title and $page_title) {
        head('title', $book_title . ' - ' . $page_title);
    } else {
        if ($page_title) {
            head('title', $page_title);
        } else {
            if ($book_title) {
                head('title', $book_title);
            }
        }
    }
    if ($page_abstract) {
        head('description', $page_abstract);
    } else {
        if ($book_abstract) {
            head('description', $book_abstract);
        }
    }
    if ($page_cloud) {
        head('keywords', $page_cloud);
    } else {
        if ($book_cloud) {
            head('keywords', $book_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('book', $lang) . '/' . $book_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);
    }
    $prev_page_label = $prev_page_url = false;
    $r = thread_node_prev($lang, $book_id, $page_id);
    if ($r) {
        extract($r);
        /* prev_node_id prev_node_name prev_node_title prev_node_number */
        $prev_page_label = $prev_node_title ? $prev_node_title : $prev_node_number;
        $prev_page_url = url('book', $lang) . '/' . $book_name . '/' . ($prev_node_name ? $prev_node_name : $prev_node_id);
    }
    $next_page_label = $next_page_url = false;
    $r = thread_node_next($lang, $book_id, $page_id);
    if ($r) {
        extract($r);
        /* next_node_id next_node_name next_node_title next_node_number */
        $next_page_label = $next_node_title ? $next_node_title : $next_node_number;
        $next_page_url = url('book', $lang) . '/' . $book_name . '/' . ($next_node_name ? $next_node_name : $next_node_id);
    }
    $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('bookpage', false, compact('page_id', 'page_title', 'page_contents', 'page_comment', 'page_number', 'prev_page_url', 'prev_page_label', 'next_page_url', 'next_page_label', 'besocial', 'vote', 'visits'));
    $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 = $book_title ? $book_title : $book_id;
    $headline_url = url('book', $lang) . '/' . $book_name;
    $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 . '/' . $page_id . '?' . 'clang=' . $lang : false;
    $validate = url('book', $lang) . '/' . $book_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', 'content', 'sidebar'));
    return $output;
}
コード例 #4
0
ファイル: newsletterpage.php プロジェクト: RazorMarx/izend
function newsletterpage($lang, $newsletter, $page)
{
    global $with_toolbar;
    $newsletter_id = thread_id($newsletter);
    if (!$newsletter_id) {
        return run('error/notfound', $lang);
    }
    $page_id = thread_node_id($newsletter_id, $page, $lang);
    if (!$page_id) {
        return run('error/notfound', $lang);
    }
    $r = thread_get($lang, $newsletter_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 */
    $newsletter_name = $thread_name;
    $newsletter_title = $thread_title;
    $newsletter_nocloud = $thread_nocloud;
    $newsletter_nosearch = $thread_nosearch;
    $r = thread_get_node($lang, $newsletter_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_modified */
    if ($node_ignored) {
        return run('error/notfound', $lang);
    }
    $page_name = $node_name;
    $page_title = $node_title;
    $page_abstract = $node_abstract;
    $page_cloud = $node_cloud;
    $page_modified = $node_modified;
    if ($newsletter_title and $page_title) {
        head('title', $newsletter_title . ' - ' . $page_title);
    } else {
        if ($page_title) {
            head('title', $page_title);
        } else {
            if ($newsletter_title) {
                head('title', $newsletter_title);
            }
        }
    }
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $message_title = $message_html = $message_text = false;
    $r = newsletter_get_message($newsletter_id, $page_id, $lang);
    if ($r) {
        list($message_title, $message_html, $message_text) = $r;
    }
    $postnews = false;
    $with_mail = false;
    $mailto = false;
    $missing_mail = false;
    $bad_mail = false;
    $email_sent = false;
    if (user_has_role('administrator') and $message_title and ($message_html or $message_text)) {
        require_once 'userprofile.php';
        $mailto = user_profile('mail');
        $with_mail = true;
        if (isset($_POST['newsletterpage_send'])) {
            if (isset($_POST['newsletterpage_mailto'])) {
                $mailto = strtolower(strflat(readarg($_POST['newsletterpage_mailto'])));
                if (!$mailto) {
                    $missing_mail = true;
                } else {
                    if (!validate_mail($mailto)) {
                        $bad_mail = true;
                    }
                }
            }
            if (!($missing_mail or $bad_mail)) {
                require_once 'emailhtml.php';
                $cssfile = ROOT_DIR . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'newsletter.css';
                $css = @file_get_contents($cssfile);
                $r = emailhtml($message_text, $message_html, $css, $mailto, $message_title);
                if ($r) {
                    $email_sent = true;
                }
            }
        }
        $postnews = build('postnews', $lang, $newsletter_id, $page_id);
    }
    $prev_page_label = $prev_page_url = false;
    $r = thread_node_prev($lang, $newsletter_id, $page_id);
    if ($r) {
        extract($r);
        /* prev_node_id prev_node_name prev_node_title prev_node_number */
        $prev_page_label = $prev_node_title ? $prev_node_title : $prev_node_number;
        $prev_page_url = url('newsletter', $lang) . '/' . ($prev_node_name ? $prev_node_name : $prev_node_id);
    }
    $next_page_label = $next_page_url = false;
    $r = thread_node_next($lang, $newsletter_id, $page_id);
    if ($r) {
        extract($r);
        /* next_node_id next_node_name next_node_title next_node_number */
        $next_page_label = $next_node_title ? $next_node_title : $next_node_number;
        $next_page_url = url('newsletter', $lang) . '/' . ($next_node_name ? $next_node_name : $next_node_id);
    }
    $content = view('newsletterpage', $lang, compact('page_id', 'page_title', 'page_modified', 'message_title', 'message_text', 'message_html', 'prev_page_url', 'prev_page_label', 'next_page_url', 'next_page_label', 'postnews', 'with_mail', 'mailto', 'missing_mail', 'bad_mail', 'email_sent'));
    $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, 15, compact('byname', 'bycount', 'index'));
    }
    $headline_text = $newsletter_title ? $newsletter_title : $newsletter_id;
    $headline_url = url('newsletter', $lang);
    $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 . '/' . $page_id . '?' . 'clang=' . $lang : false;
    $validate = url('newsletter', $lang) . '/' . $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('toolbar', 'banner', 'content', 'sidebar'));
    return $output;
}
コード例 #5
0
ファイル: testdbthread.php プロジェクト: RazorMarx/izend
extract($r);
// node_id node_number
$another_node_name = 'anothertestnode';
$another_node_title = 'Another test node';
$r = thread_create_node($lang, $user_id, $thread_id, $another_node_name, $another_node_title, 1);
dump($r);
$another_node_id = $r['node_id'];
$node_name = 'testnode';
$node_title = 'Test node';
$node_abstract = 'The test node.';
$node_cloud = 'test node';
$node_image = '/files/images/testnode.png';
$r = thread_set_node($lang, $thread_id, $node_id, $node_name, $node_title, $node_abstract, $node_cloud, $node_image, false, false, false, false, true, true, true, true, true);
dump($r);
$r = thread_get_node($lang, $thread_id, $node_id);
dump($r);
$r = thread_node_id($thread_id, false);
dump($r);
$r = thread_node_id($thread_id, $node_id);
dump($r);
$r = thread_node_id($thread_id, $node_name, $lang);
dump($r);
$r = thread_node_next($lang, $thread_id, $another_node_id);
dump($r);
$r = thread_node_prev($lang, $thread_id, $node_id);
dump($r);
$r = thread_delete_node($thread_id, $another_node_id);
dump($r);
$r = thread_delete($thread_id);
dump($r);
echo sprintf('%.4f', microtime(true) - $msecs), PHP_EOL;