Exemplo n.º 1
0
function article_edit($message = "")
{
    global $txpcfg, $txp_user, $vars;
    extract(get_prefs());
    extract(gpsa(array('view', 'from_view', 'step')));
    if (!empty($GLOBALS['ID'])) {
        // newly-saved article
        $ID = intval($GLOBALS['ID']);
        $step = 'edit';
    } else {
        $ID = gps('ID');
    }
    include_once $txpcfg['txpath'] . '/lib/classTextile.php';
    $textile = new Textile();
    if (!$view) {
        $view = "text";
    }
    if (!$step) {
        $step = "create";
    }
    if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != "preview" && $from_view != 'html') {
        $pull = true;
        //-- it's an existing article - off we go to the db
        $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}");
        extract($rs);
        if ($AnnotateInvite != $comments_default_invite) {
            $AnnotateInvite = $AnnotateInvite;
        } else {
            $AnnotateInvite = $comments_default_invite;
        }
    } else {
        $pull = false;
        //-- assume they came from post
        if (!$from_view or $from_view == 'text') {
            extract(gpsa($vars));
        } elseif ($from_view == 'preview' or $from_view == 'html') {
            // coming from either html or preview
            if (isset($_POST['store'])) {
                $store = unserialize(base64_decode($_POST['store']));
                extract($store);
            }
        }
        foreach ($vars as $var) {
            if (isset(${$var})) {
                $store_out[$var] = ${$var};
            }
        }
    }
    $GLOBALS['step'] = $step;
    if ($step == 'create') {
        $textile_body = 1;
        $textile_excerpt = 1;
    }
    if ($step != 'create') {
        // Previous record?
        $prev_id = checkIfNeighbour('prev', $sPosted);
        // Next record?
        $next_id = checkIfNeighbour('next', $sPosted);
    }
    pagetop($Title, $message);
    echo '<form action="index.php" method="post" name="article">';
    if (!empty($store_out)) {
        echo hInput('store', base64_encode(serialize($store_out)));
    }
    echo hInput('ID', $ID), eInput('article'), sInput($step);
    echo '<input type="hidden" name="view" />', startTable('edit');
    echo '<tr><td>&nbsp;</td><td colspan="3">', $view == 'preview' ? hed(ucfirst(gTxt('preview')), 2) . graf($Title) : '', $view == 'html' ? hed('XHTML', 2) . graf($Title) : '', $view == 'text' ? br . '<input type="text" name="Title" value="' . cleanfInput($Title) . '" class="edit" size="40" tabindex="1" />' : '', '</td></tr>';
    //-- article input --------------
    echo '<tr>
  		<td valign="top">', $view == 'text' && $use_textile == 2 ? '<p><a href="#" onclick="toggleDisplay(\'textile_help\');">' . gTxt('textile_help') . '</a></p>
		<div id="textile_help" style="display:none;">' . sidehelp() . '</div>' : sp;
    if ($view == 'text') {
        echo '<p><a href="#" onclick="toggleDisplay(\'advanced\');">' . gTxt('advanced_options') . '</a></p>', '<div id="advanced" style="display:none;">', graf(gTxt('use_textile') . br . tag(checkbox2('textile_body', $textile_body) . gTxt('article'), 'label') . br . tag(checkbox2('textile_excerpt', $textile_excerpt) . gTxt('excerpt'), 'label')), $allow_form_override ? graf(gTxt('override_default_form') . br . form_pop($override_form) . popHelp('override_form')) : '', $custom_1_set ? custField(1, $custom_1_set, $custom_1) : '', $custom_2_set ? custField(2, $custom_2_set, $custom_2) : '', $custom_3_set ? custField(3, $custom_3_set, $custom_3) : '', $custom_4_set ? custField(4, $custom_4_set, $custom_4) : '', $custom_5_set ? custField(5, $custom_5_set, $custom_5) : '', $custom_6_set ? custField(6, $custom_6_set, $custom_6) : '', $custom_7_set ? custField(7, $custom_7_set, $custom_7) : '', $custom_8_set ? custField(8, $custom_8_set, $custom_8) : '', $custom_9_set ? custField(9, $custom_9_set, $custom_9) : '', $custom_10_set ? custField(10, $custom_10_set, $custom_10) : '', graf(gTxt('keywords') . popHelp('keywords') . br . '<textarea name="Keywords" style="width:100px;height:80px" rows="1" cols="1">' . $Keywords . '</textarea>'), graf(gTxt('article_image') . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit')), graf(gTxt('url_title') . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit')) . '</div>
			
			<p><a href="#" onclick="toggleDisplay(\'recent\');">' . gTxt('recent_articles') . '</a>' . '</p>' . '<div id="recent" style="display:none;">';
        $recents = safe_rows_start("Title, ID", 'textpattern', "1 order by LastMod desc limit 10");
        if ($recents) {
            echo '<p>';
            while ($recent = nextRow($recents)) {
                extract($recent);
                if (!$Title) {
                    $Title = gTxt('untitled') . sp . $ID;
                }
                echo '<a href="?event=article' . a . 'step=edit' . a . 'ID=' . $ID . '">' . $Title . '</a>' . br . n;
            }
            echo '</p>';
        }
        echo '</div>';
    } else {
        echo sp;
    }
    echo '</td>
    	<td valign="top" style="width:400px">';
    if ($view == "preview") {
        if ($use_textile == 2) {
            echo $textile->TextileThis($Body);
        } else {
            if ($use_textile == 1) {
                echo nl2br($Body);
            } else {
                if ($use_textile == 0) {
                    echo $Body;
                }
            }
        }
    } elseif ($view == "html") {
        if ($use_textile == 2) {
            $bod = $textile->TextileThis($Body);
        } else {
            if ($use_textile == 1) {
                $bod = nl2br($Body);
            } else {
                if ($use_textile == 0) {
                    $bod = $Body;
                }
            }
        }
        echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code');
    } else {
        echo '<textarea style="width:400px;height:420px" rows="1" cols="1" name="Body" tabindex="2">', htmlspecialchars($Body), '</textarea>';
    }
    //-- excerpt --------------------
    if ($articles_use_excerpts) {
        if ($view == 'text') {
            $Excerpt = str_replace("&amp;", "&", htmlspecialchars($Excerpt));
            echo graf(gTxt('excerpt') . popHelp('excerpt') . br . '<textarea style="width:400px;height:50px" rows="1" cols="1" name="Excerpt" tabindex="3">' . $Excerpt . '</textarea>');
        } else {
            echo '<hr width="50%" />';
            echo $textile_excerpt ? $view == 'preview' ? graf($textile->textileThis($Excerpt), 1) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt), 1)), 'code') : graf($Excerpt);
        }
    }
    //-- author --------------
    if ($view == "text" && $step != "create") {
        echo "<p><small>" . gTxt('posted_by') . " {$AuthorID}: ", date("H:i, d M y", $sPosted + tz_offset());
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . " {$LastModID}: ", date("H:i, d M y", $sLastMod + tz_offset());
        }
        echo '</small></p>';
    }
    echo hInput('from_view', $view), '</td>';
    echo '<td valign="top" align="left" width="20">';
    //-- layer tabs -------------------
    echo $use_textile == 2 ? tab('text', $view) . tab('html', $view) . tab('preview', $view) : '&#160;';
    echo '</td>';
    ?>
	
<td width="200" valign="top" style="padding-left:10px" align="left" id="articleside">
<?php 
    //-- prev/next article links --
    if ($view == 'text') {
        if ($step != 'create' and ($prev_id or $next_id)) {
            echo '<p>', $prev_id ? prevnext_link('&#8249;' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '&#8250;', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>';
        }
    }
    //-- status radios --------------
    echo $view == 'text' ? n . graf(status_radio($Status)) . n : '';
    //-- category selects -----------
    echo $view == 'text' ? graf(gTxt('categorize') . ' [' . eLink('category', '', '', '', gTxt('edit')) . ']' . br . category_popup('Category1', $Category1) . category_popup('Category2', $Category2)) : '';
    //-- section select --------------
    if (!$from_view && !$pull) {
        $Section = getDefaultSection();
    }
    echo $view == 'text' ? graf(gTxt('section') . ' [' . eLink('section', '', '', '', gTxt('edit')) . ']' . br . section_popup($Section)) : '';
    //-- comments stuff --------------
    if ($step == "create") {
        //Avoiding invite disappear when previewing
        $AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite;
        if ($comments_on_default == 1) {
            $Annotate = 1;
        }
    }
    echo $use_comments == 1 && $view == 'text' ? graf(gTxt('comments') . onoffRadio("Annotate", $Annotate) . '<br />' . gTxt('comment_invitation') . '<br />' . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit')) : '';
    //-- timestamp -------------------
    if ($step == "create" and empty($GLOBALS['ID'])) {
        if ($view == 'text') {
            //Avoiding modified date to disappear
            $persist_timestamp = !empty($store_out['year']) ? mktime($store_out['hour'], $store_out['minute'], '00', $store_out['month'], $store_out['day'], $store_out['year']) : time();
            echo graf(tag(checkbox('publish_now', '1') . gTxt('set_to_now'), 'label')), '<p>', gTxt('or_publish_at'), popHelp("timestamp"), br, tsi('year', 'Y', $persist_timestamp), tsi('month', 'm', $persist_timestamp), tsi('day', 'd', $persist_timestamp), sp, tsi('hour', 'H', $persist_timestamp), ':', tsi('minute', 'i', $persist_timestamp), '</p>';
        }
        //-- publish button --------------
        if ($view == 'text') {
            echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish") : fInput('submit', 'publish', gTxt('save'), "publish");
        }
    } else {
        if ($view == 'text') {
            echo '<p>', gTxt('published_at'), popHelp("timestamp"), br, tsi('year', 'Y', $sPosted, 5), tsi('month', 'm', $sPosted, 6), tsi('day', 'd', $sPosted, 7), sp, tsi('hour', 'H', $sPosted, 8), ':', tsi('minute', 'i', $sPosted, 9), '</p>', hInput('sPosted', $sPosted), hInput('sLastMod', $sLastMod), hInput('AuthorID', $AuthorID), hInput('LastModID', $LastModID), graf(checkbox('reset_time', '1', 0) . gTxt('reset_time'));
        }
        //-- save button --------------
        if ($view == 'text') {
            if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) {
                echo fInput('submit', 'save', gTxt('save'), "publish");
            }
        }
    }
    echo '</td></tr></table></form>';
}
Exemplo n.º 2
0
 function wizard_steps($step)
 {
     $step_details = '';
     foreach ($this->installation_steps as $key => $detail) {
         if (@$detail[$step]) {
             $options = '';
             if (@$detail['has_options']) {
                 $function = array(&$this, 'option_' . $key);
                 if (is_callable($function)) {
                     $options = n . tag(call_user_func($function, $step), 'span', ' id="wizard_' . $key . '" style="display: block; margin-right: 1em; padding: 0.5em; background-color: #eee;"');
                 }
             }
             $checkbox = '';
             if (@$detail['optional']) {
                 $checked = isset($detail['checked']) ? $detail['checked'] : 0;
                 $checkbox = checkbox2('optional_' . $key, $checked, $options ? '" onclick="toggleDisplay(\'wizard_' . $key . '\');' : '');
             }
             $step_details .= n . tag(graf(tag($detail[$step] . $checkbox, 'label') . $options), 'li');
         }
     }
     return $step_details . n;
 }
Exemplo n.º 3
0
function thumb_ui($id)
{
    global $prefs;
    extract($prefs);
    return tr(td(form(graf(gTxt('create_thumbnail')) . startTable('', 'left', '', 1) . tr(fLabelCell(gTxt('thumb_width') . ':') . fInputCell('width', '', 1, 4) . fLabelCell(gTxt('thumb_height') . ':') . fInputCell('height', '', 1, 4) . fLabelCell(gTxt('keep_square_pixels') . ':') . tda(checkbox2('crop', ''), ' class="noline"') . tda(fInput('submit', '', gTxt('Create'), 'smallerbox'), ' class="noline"')) . hInput('id', $id) . eInput('image') . sInput('thumbnail_create') . endTable())));
}
function bot_admin_tooltips_tab($event, $step)
{
    global $bot_admin_tooltips_main_array, $plugins;
    if (isset($_POST['bot_item'])) {
        // if there are preferences
        $prefs = bot_get_tips();
        // array of values from the db table
    }
    $r = safe_rows_start('name, val', 'txp_prefs', 'event = "custom" AND val != ""');
    // creates an array of all cfs for selectInput in bot_admin_tooltips_tab
    if ($r) {
        global $arr_custom_fields;
        while ($a = nextRow($r)) {
            $name = 'tab_write|' . str_replace('_set', '', $a['name']);
            $val = $a['val'];
            $arr_custom_fields[$name] = $val;
        }
    }
    pagetop('bot_admin_tooltips ' . gTxt('preferences'), $step == 'update' ? gTxt('preferences_saved') : '');
    echo hed('bot | admin tooltips', '2', ' style="text-align: center; margin:20px auto;   padding-bottom:10px;"');
    if ($step == 'install') {
        // Install the preferences table.
        bot_admin_tooltips_install();
    }
    if ($step == 'uninstall') {
        //remove table
        safe_query("DROP TABLE " . PFX . "bot_admin_tooltips");
        safe_delete('txp_prefs', 'event = "bot_tips_"');
    }
    if ($step == 'update') {
        // set function variables
        $new_item = doslash(ps('bot_new_item'));
        $new_tip = doslash(ps('bot_new_tip'));
        $item = doslash(ps('bot_item'));
        $tip = doslash(ps('bot_saved_tip'));
        $tip_id = ps('bot_id');
        $delete_id = ps('bot_delete_id');
        $hide_pophelp = ps('bot_admin_tooltips_hide_pophelp');
        $js_event = ps('bot_admin_tooltips_js_event');
        $tips_bg = doslash(ps('bot_admin_tooltips_bg'));
        $tips_color = doslash(ps('bot_admin_tooltips_color'));
        $tips_border_color = doslash(ps('bot_admin_tooltips_border_color'));
        $js_path = doslash(ps('bot_admin_tooltips_path'));
        if ($delete_id) {
            // checks if there is something to delete
            foreach ($delete_id as $id) {
                safe_delete('bot_admin_tooltips', 'id ="' . $id . '"');
            }
        }
        safe_update('txp_prefs', 'val= "' . $hide_pophelp . '"', 'name = "bot_admin_tooltips_hide_pophelp"');
        // updates pophelp prefs
        safe_update('txp_prefs', 'val= "' . $js_event . '"', 'name = "bot_admin_tooltips_js_event"');
        // updates click/hover prefs
        safe_update('txp_prefs', 'val= "' . $tips_bg . '"', 'name = "bot_admin_tooltips_bg"');
        // updates bg prefs
        safe_update('txp_prefs', 'val= "' . $tips_color . '"', 'name = "bot_admin_tooltips_color"');
        // updates color prefs
        safe_update('txp_prefs', 'val= "' . $tips_border_color . '"', 'name = "bot_admin_tooltips_border_color"');
        // updates border color prefs
        safe_update('txp_prefs', 'val= "' . $js_path . '"', 'name = "bot_admin_tooltips_path"');
        // updates path prefs
        if ($item != '' && $tip != '') {
            // when tips are set
            for ($i = 0; $i < count($item); $i++) {
                // creates the "posted_variables" array containing item, tip, tip_id
                $posted_variables[$item[$i]]['item'] = $item[$i];
                $posted_variables[$item[$i]]['tip'] = $tip[$i];
                $posted_variables[$item[$i]]['id'] = $tip_id[$i];
            }
            foreach ($posted_variables as $item => $values) {
                // for each posted variable (item, tip, tip_id) updates the db
                $tip = $values['tip'];
                $id = $values['id'];
                if ($item != '' && $tip != '') {
                    // if there is item AND tip
                    safe_update('bot_admin_tooltips', 'item = "' . $item . '", tip = "' . $tip . '"', 'id = "' . $id . '"');
                } elseif ($tip == '') {
                    // if there is no tip, tip is deleted from db
                    safe_delete('bot_admin_tooltips', 'item ="' . $item . '"');
                }
            }
            if ($new_item != '' && $new_tip != '') {
                // if there is a new tip is inserted in db
                safe_insert('bot_admin_tooltips', 'item = "' . $new_item . '", tip = "' . $new_tip . '"');
            }
        } elseif ($new_item != '' && $new_tip != '') {
            // if no tips are set yet deals only with new tip
            safe_insert('bot_admin_tooltips', 'item = "' . $new_item . '", tip = "' . $new_tip . '"');
        }
    }
    if (bot_admin_tooltips_check_install()) {
        extract(bot_admin_tooltips_get_prefs());
        // beginning of the form
        echo form('<div style="text-align:center; background:#f2f2f2; margin:20px auto 40px; padding:10px; border-bottom:solid #ccc 1px; border-top:solid #ccc 1px; ">' . n . '<label for="bot_admin_tooltips_bg">Background color </label>' . finput('text', 'bot_admin_tooltips_bg', $bot_admin_tooltips_bg) . n . '&nbsp; &nbsp;' . n . '<label for="bot_admin_tooltips_color">Text color </label>' . finput('text', 'bot_admin_tooltips_color', $bot_admin_tooltips_color) . n . '&nbsp; &nbsp;' . n . '<label for="bot_admin_tooltips_border_color">Border color </label>' . finput('text', 'bot_admin_tooltips_border_color', $bot_admin_tooltips_border_color) . n . '&nbsp; &nbsp;' . n . '<label for="bot_admin_tooltips_js_event">Show tip on hover </label>' . checkbox2('bot_admin_tooltips_js_event', $bot_admin_tooltips_js_event) . n . '&nbsp; &nbsp;' . n . '<label for="bot_admin_tooltips_hide_pophelp">Hide txp pophelps </label>' . checkbox2('bot_admin_tooltips_hide_pophelp', $bot_admin_tooltips_hide_pophelp) . n . '&nbsp; &nbsp;' . n . '<label for="bot_admin_tooltips_path">Path to js </label>' . finput('text', 'bot_admin_tooltips_path', $bot_admin_tooltips_path) . n . '</div>' . '<div style="margin: 0 auto 20px; width:580px; padding:0 10px;">' . n . eInput('bot_admin_tooltips_tab') . n . sInput('update') . n . fInput('submit', 'update', 'Update', 'publish') . '</div>' . n . startTable('list') . n . tr(td(strong('Item')) . td(strong('Tip'))) . n . bot_admin_tooltips_output_rows() . n . endTable() . '<div style="margin: 20px auto; width:580px; padding:0 10px;">' . n . eInput('bot_admin_tooltips_tab') . n . sInput('update') . n . fInput('submit', 'update', 'Update', 'publish') . '</div>');
        // uninstall button
        echo n . t . '<div style="margin: 20px auto 0; width:580px; border-top:dashed #ccc 1px; margin-top:40px; padding:10px 10px 0;">' . n . t . t . graf(bot_admin_tooltips_gTxt('uninstall_message')) . n . hed(bot_admin_tooltips_gTxt('uninstall'), '1') . n . n . form(n . eInput('bot_admin_tooltips_tab') . n . sInput('uninstall') . n . n . fInput('submit', 'uninstall', 'Uninstall ', 'smallerbox'), "", "confirm('" . bot_admin_tooltips_gTxt('uninstall_confirm') . "')") . '</div>';
    } else {
        // install message
        echo n . t . '<div style="margin: auto; width:40%;">' . n . t . t . hed('bot_admin_tooltips ' . gTxt('Preferences'), '1') . n . graf(bot_admin_tooltips_gTxt('install_message')) . n . n . form(n . eInput('bot_admin_tooltips_tab') . n . sInput('install') . n . n . fInput('submit', 'install', 'Install ', 'publish')) . '</div>';
    }
}