예제 #1
0
function threadeditall($lang, $clang)
{
    global $supported_threads, $with_toolbar;
    if (!user_has_role('writer')) {
        return run('error/unauthorized', $lang);
    }
    $confirmed = false;
    $action = 'init';
    if (isset($_POST['thread_create'])) {
        $action = 'create';
    } else {
        if (isset($_POST['thread_delete'])) {
            $action = 'delete';
        } else {
            if (isset($_POST['thread_confirmdelete'])) {
                $action = 'delete';
                $confirmed = true;
            } else {
                if (isset($_POST['threadlist_reorder'])) {
                    $action = 'reorder';
                }
            }
        }
    }
    $new_thread_name = $new_thread_title = $new_thread_type = $new_thread_number = false;
    $old_thread_number = false;
    $p = false;
    switch ($action) {
        case 'init':
        case 'reset':
            break;
        case 'create':
        case 'delete':
        case 'reorder':
            if (isset($_POST['new_thread_title'])) {
                $new_thread_title = readarg($_POST['new_thread_title']);
            }
            if ($new_thread_title) {
                $new_thread_name = strtofname($new_thread_title);
            }
            if (isset($_POST['new_thread_number'])) {
                $new_thread_number = readarg($_POST['new_thread_number']);
            }
            if (isset($_POST['new_thread_type'])) {
                $new_thread_type = readarg($_POST['new_thread_type']);
            }
            if (isset($_POST['old_thread_number'])) {
                $old_thread_number = readarg($_POST['old_thread_number']);
            }
            if (isset($_POST['p'])) {
                $p = $_POST['p'];
                // DON'T readarg!
            }
        default:
            break;
    }
    $thread_list = array();
    $r = thread_list($clang, false, false);
    if (!$r or count($r) != count($p)) {
        $p = false;
    }
    if ($r) {
        $pos = 1;
        $thread_url = url('threadedit', $lang);
        foreach ($r as $b) {
            $b['thread_url'] = $thread_url . '/' . $b['thread_id'];
            $b['pos'] = $p ? $p[$pos] : $pos;
            $thread_list[$pos] = $b;
            $pos++;
        }
    }
    $missing_new_thread_title = false;
    $missing_new_thread_name = false;
    $bad_new_thread_name = false;
    $missing_new_thread_type = false;
    $bad_new_thread_type = false;
    $bad_new_thread_number = false;
    $missing_old_thread_number = false;
    $bad_old_thread_number = false;
    switch ($action) {
        case 'create':
            if (!$new_thread_title) {
                $missing_new_thread_title = true;
            }
            if (!$new_thread_name) {
                $missing_new_thread_name = true;
            } else {
                if (!preg_match('#^[\\w-]{2,}$#', $new_thread_name)) {
                    $bad_new_thread_name = true;
                }
            }
            if (!$new_thread_number) {
                $bad_new_thread_number = false;
            } else {
                if (!is_numeric($new_thread_number)) {
                    $bad_new_thread_number = true;
                } else {
                    if ($new_thread_number < 1 or $new_thread_number > count($thread_list) + 1) {
                        $bad_new_thread_number = true;
                    }
                }
            }
            if (!$new_thread_type) {
                $missing_new_thread_type = true;
            } else {
                if (!in_array($new_thread_type, $supported_threads)) {
                    $bad_new_thread_type = true;
                }
            }
            break;
        case 'delete':
            if (!$old_thread_number) {
                $missing_old_thread_number = true;
            } else {
                if (!is_numeric($old_thread_number)) {
                    $bad_old_thread_number = true;
                } else {
                    if ($old_thread_number < 1 or $old_thread_number > count($thread_list)) {
                        $bad_old_thread_number = true;
                    }
                }
            }
            break;
        default:
            break;
    }
    $confirm_delete_thread = false;
    switch ($action) {
        case 'create':
            if ($missing_new_thread_title or $missing_new_thread_name or $bad_new_thread_name or $bad_new_thread_number or $missing_new_thread_type or $bad_new_thread_type) {
                break;
            }
            $user_id = user_profile('id');
            $np = thread_create($clang, $user_id, $new_thread_name, $new_thread_title, $new_thread_type, $new_thread_number);
            if (!$np) {
                break;
            }
            extract($np);
            /* thread_id thread_number */
            $thread_title = $new_thread_title;
            $thread_url = url('threadedit', $lang) . '/' . $thread_id;
            $pos = $thread_number;
            if ($thread_list) {
                foreach ($thread_list as &$tr) {
                    if ($tr['thread_number'] >= $pos) {
                        $tr['thread_number']++;
                    }
                    if ($tr['pos'] >= $pos) {
                        $tr['pos']++;
                    }
                }
                array_splice($thread_list, $pos - 1, 0, array(compact('thread_id', 'thread_title', 'thread_number', 'thread_url', 'pos')));
                array_multisort(range(1, count($thread_list)), $thread_list);
            } else {
                $pos = 1;
                $thread_list = array($pos => compact('thread_id', 'thread_title', 'thread_number', 'thread_url', 'pos'));
            }
            break;
        case 'delete':
            if ($missing_old_thread_number or $bad_old_thread_number) {
                break;
            }
            if (!$confirmed) {
                $confirm_delete_thread = true;
                break;
            }
            $thread_id = $thread_list[$old_thread_number]['thread_id'];
            $r = thread_delete($thread_id);
            if (!$r) {
                break;
            }
            unset($thread_list[$old_thread_number]);
            foreach ($thread_list as &$b) {
                if ($b['pos'] >= $old_thread_number) {
                    $b['pos']--;
                }
            }
            $old_thread_number = false;
            break;
        case 'reorder':
            if (!$p) {
                break;
            }
            $neworder = range(1, count($p));
            array_multisort($p, SORT_NUMERIC, $neworder);
            $number = 1;
            $nl = array();
            foreach ($neworder as $i) {
                $tr =& $thread_list[$i];
                if ($tr['thread_number'] != $number) {
                    thread_set_number($tr['thread_id'], $number);
                    $tr['thread_number'] = $number;
                }
                $tr['pos'] = $number;
                $nl[$number++] = $tr;
            }
            $thread_list = $nl;
            break;
        default:
            break;
    }
    head('title', translate('threadall:title', $lang));
    head('description', false);
    head('keywords', false);
    head('robots', 'noindex, nofollow');
    $site_title = translate('title', $lang);
    $view = url('thread', $clang) . '?' . 'slang=' . $lang;
    $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'view'));
    $scroll = true;
    $toolbar = $with_toolbar ? build('toolbar', $lang, compact('view', 'scroll')) : false;
    $inlanguages = view('inlanguages', false, compact('clang'));
    $errors = compact('missing_new_thread_title', 'bad_new_thread_title', 'missing_new_thread_name', 'missing_new_thread_type', 'bad_new_thread_name', 'bad_new_thread_type', 'bad_new_thread_number', 'missing_old_thread_number', 'bad_old_thread_number');
    $content = view('editing/threadeditall', $lang, compact('clang', 'site_title', 'inlanguages', 'supported_threads', 'thread_list', 'new_thread_title', 'new_thread_type', 'new_thread_number', 'old_thread_number', 'confirm_delete_thread', 'errors'));
    $output = layout('editing', compact('toolbar', 'banner', 'content'));
    return $output;
}
예제 #2
0
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;
}
예제 #3
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;
}