示例#1
0
function nodeurl($lang, $thread_id, $node_id)
{
    global $db_debug;
    $flag = $db_debug;
    $db_debug = false;
    $action = false;
    $args = array();
    if ($thread_id) {
        $r = thread_get($lang, $thread_id);
        if (!$r) {
            return false;
        }
        $action = $r['thread_type'];
        $args[] = $r['thread_name'];
    }
    if ($node_id) {
        $r = node_get($lang, $node_id);
        if (!$r) {
            return false;
        }
        $args[] = $r['node_name'];
    }
    $db_debug = $flag;
    return url($action, $lang, $args);
}
示例#2
0
文件: node.php 项目: RazorMarx/izend
function node($lang, $arglist = false)
{
    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);
    }
    $node = false;
    if (is_array($arglist)) {
        if (isset($arglist[0])) {
            $node = $arglist[0];
        }
    }
    if (!$node) {
        return run('error/notfound', $lang);
    }
    $node_id = node_id($node);
    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_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;
    head('title', $node_id);
    head('description', $node_abstract);
    head('keywords', $node_cloud);
    head('robots', 'noindex, nofollow');
    $edit = user_has_role('writer') ? url('editnode', $_SESSION['user']['locale']) . '/' . $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;
    $node_contents = build('nodecontent', $lang, $node_id);
    $content = view('node', $slang, compact('node_id', 'node_name', 'node_title', 'node_abstract', 'node_cloud', 'node_image', 'node_created', 'node_modified', 'node_comment', 'node_morecomment', 'node_vote', 'node_morevote', 'node_ilike', 'node_tweet', 'node_plusone', 'node_linkedin', 'node_pinit', 'node_contents'));
    $output = layout('standard', compact('toolbar', 'banner', 'content'));
    return $output;
}
示例#3
0
文件: home.php 项目: RazorMarx/izend
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;
}
示例#4
0
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;
}
示例#5
0
dump($r);
extract($r);
// node_id;
$r = node_get('en', $node_id);
dump($r);
$r = node_get('fr', $node_id, false);
dump($r);
$lang = 'en';
$node_name = 'testnode';
$node_title = 'Test node';
$node_abstract = 'The test node.';
$node_cloud = 'test node';
$node_image = '/files/images/testnode.png';
$r = node_set('en', $node_id, $node_name, $node_title, $node_abstract, $node_cloud, $node_image, false, false, false, false, true, true, true, true, true);
dump($r);
$r = node_get($lang, $node_id);
dump($r);
$content_type = 'text';
$r = node_create_content($lang, $node_id, $content_type);
dump($r);
$r['content_type'] = $content_type;
$r['content_ignored'] = false;
$content_text = $r;
$content_type = 'download';
$r = node_create_content($lang, $node_id, $content_type, 1);
dump($r);
$r['content_type'] = $content_type;
$r['content_ignored'] = false;
$content_download = $r;
$r = node_get_contents($lang, $node_id);
dump($r);
示例#6
0
function nodeeditor($lang, $clang, $node_id, $content_types)
{
    $action = 'init';
    if (isset($_POST['node_edit'])) {
        $action = 'edit';
    }
    $node_name = $node_title = $node_abstract = $node_cloud = $node_image = $node_comment = $node_morecomment = $node_vote = $node_morevote = false;
    $node_ilike = $node_tweet = $node_plusone = $node_linkedin = $node_pinit = false;
    $node_visits = false;
    $node_nocomment = $node_nomorecomment = $node_novote = $node_nomorevote = true;
    switch ($action) {
        case 'init':
        case 'reset':
            $r = node_get($clang, $node_id, false);
            if ($r) {
                extract($r);
            }
            $node_comment = !$node_nocomment;
            $node_morecomment = !$node_nomorecomment;
            $node_vote = !$node_novote;
            $node_morevote = !$node_nomorevote;
            break;
        case 'edit':
            if (isset($_POST['node_title'])) {
                $node_title = readarg($_POST['node_title']);
            }
            if (isset($_POST['node_name'])) {
                $node_name = strtofname(readarg($_POST['node_name']));
            }
            if (empty($node_name) and !empty($node_title)) {
                $node_name = strtofname($node_title);
            }
            if (isset($_POST['node_abstract'])) {
                $node_abstract = readarg($_POST['node_abstract']);
            }
            if (isset($_POST['node_cloud'])) {
                $node_cloud = readarg($_POST['node_cloud'], true, false);
                // trim but DON'T strip!
                preg_match_all('/(\\S+)/', $node_cloud, $r);
                $node_cloud = implode(' ', array_unique($r[0]));
            }
            if (isset($_POST['node_image'])) {
                $node_image = readarg($_POST['node_image']);
            }
            if (isset($_POST['node_visits'])) {
                $node_visits = readarg($_POST['node_visits']) == 'on' ? true : false;
            }
            if (isset($_POST['node_comment'])) {
                $node_comment = readarg($_POST['node_comment']) == 'on' ? true : false;
                $node_nocomment = !$node_comment;
            }
            if (isset($_POST['node_morecomment'])) {
                $node_morecomment = readarg($_POST['node_morecomment']) == 'on' ? true : false;
                $node_nomorecomment = !$node_morecomment;
            }
            if (isset($_POST['node_vote'])) {
                $node_vote = readarg($_POST['node_vote']) == 'on' ? true : false;
                $node_novote = !$node_vote;
            }
            if (isset($_POST['node_morevote'])) {
                $node_morevote = readarg($_POST['node_morevote']) == 'on' ? true : false;
                $node_nomorevote = !$node_morevote;
            }
            if (isset($_POST['node_ilike'])) {
                $node_ilike = readarg($_POST['node_ilike'] == 'on' ? true : false);
            }
            if (isset($_POST['node_tweet'])) {
                $node_tweet = readarg($_POST['node_tweet'] == 'on' ? true : false);
            }
            if (isset($_POST['node_plusone'])) {
                $node_plusone = readarg($_POST['node_plusone'] == 'on' ? true : false);
            }
            if (isset($_POST['node_linkedin'])) {
                $node_linkedin = readarg($_POST['node_linkedin'] == 'on' ? true : false);
            }
            if (isset($_POST['node_pinit'])) {
                $node_pinit = readarg($_POST['node_pinit'] == 'on' ? true : false);
            }
            break;
        default:
            break;
    }
    $missing_node_name = false;
    $bad_node_name = false;
    switch ($action) {
        case 'edit':
            if (empty($node_name)) {
                $missing_node_name = true;
            } else {
                if (!preg_match('#^\\w+(-\\w+)*$#', $node_name)) {
                    $bad_node_name = true;
                }
            }
            break;
        default:
            break;
    }
    switch ($action) {
        case 'edit':
            if ($missing_node_name or $bad_node_name) {
                break;
            }
            $r = node_set($clang, $node_id, $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);
            if (!$r) {
                break;
            }
            if (!$node_comment) {
                $node_morecomment = false;
            }
            if (!$node_vote) {
                $node_morevote = false;
            }
            break;
        default:
            break;
    }
    $content_editor = build('nodecontenteditor', $lang, $clang, $node_id, $content_types);
    $inlanguages = view('inlanguages', false, compact('clang'));
    $errors = compact('missing_node_name', 'bad_node_name');
    $output = view('editing/nodeeditor', $lang, compact('clang', 'inlanguages', 'node_name', 'node_title', 'node_abstract', 'node_cloud', 'node_image', 'node_visits', 'node_comment', 'node_morecomment', 'node_vote', 'node_morevote', 'node_ilike', 'node_tweet', 'node_plusone', 'node_linkedin', 'node_pinit', 'content_editor', 'errors'));
    return $output;
}