Example #1
0
function sec_section_list($message = '')
{
    global $wlink;
    pagetop(gTxt('sections'), $message);
    $default = safe_row('page, css', 'txp_section', "name = 'default'");
    $pages = safe_column('name', 'txp_page', "1 = 1");
    $styles = safe_column('name', 'txp_css', "1 = 1");
    echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(td(gTxt('default')) . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td());
    $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            echo n . n . tr(n . td($name) . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\"");
        }
    }
    echo n . n . endTable();
}
Example #2
0
 function init($name = '')
 {
     static $instance;
     if ($name === '') {
         $name = pluggable_ui('admin_side', 'theme_name', get_pref('theme_name', 'classic'));
     }
     if ($instance && is_object($instance) && $name == $instance->name) {
         return $instance;
     } else {
         $instance = null;
     }
     $instance = theme::factory($name);
     if (!$instance) {
         set_pref('theme_name', 'classic');
         die(gTxt('cannot_instantiate_theme', array('{name}' => $name, '{class}' => "{$name}_theme", '{path}' => theme::path($name))));
     }
     return $instance;
 }
Example #3
0
function sec_section_list($message = '')
{
    global $wlink, $event;
    pagetop(gTxt('sections'), $message);
    $default = safe_row('page, css', 'txp_section', "name = 'default'");
    $pages = safe_column('name', 'txp_page', "1 = 1");
    $styles = safe_column('name', 'txp_css', "1 = 1");
    echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
    echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td(), ' class="section default"');
    $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name");
    if ($rs) {
        $ctr = 1;
        while ($a = nextRow($rs)) {
            extract($a);
            echo n . n . tr(n . td($name, '', 'label') . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), ' class="name"') . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), ' class="title"') . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline'), ' class="option is-default"') . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline'), ' class="option on-frontpage"') . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline'), ' class="option in-rss"') . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline'), ' class="option is-searchable"') . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"');
            $ctr++;
        }
    }
    echo n . n . endTable() . '</div>';
}
Example #4
0
 function init($name = '')
 {
     static $instance;
     if (empty($name)) {
         $name = pluggable_ui('admin_side', 'theme_name', get_pref('theme_name', 'classic'));
     }
     if ($instance && is_object($instance) && $name == $instance->name) {
         return $instance;
     } else {
         $instance = null;
     }
     $path = txpath . DS . THEME . DS . $name . DS . $name . '.php';
     if (is_file($path)) {
         require_once $path;
     } else {
         $name = 'classic';
         set_pref('theme_name', $name);
         require_once txpath . DS . THEME . DS . $name . DS . $name . '.php';
     }
     $t = "{$name}_theme";
     $instance = new $t($name);
     return $instance;
 }
Example #5
0
/**
 * Renders and outputs the section editor panel.
 */
function section_edit()
{
    global $event, $step, $all_pages, $all_styles;
    require_privs('section.edit');
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method', 'name')));
    $is_edit = $name && $step == 'section_edit';
    $caption = gTxt('create_section');
    $is_default_section = false;
    if ($is_edit) {
        $rs = safe_row("*", 'txp_section', "name = '" . doSlash($name) . "'");
        if ($name == 'default') {
            $caption = gTxt('edit_default_section');
            $is_default_section = true;
        } else {
            $caption = gTxt('edit_section');
        }
    } else {
        // Pulls defaults for the new section from the 'default'.
        $rs = safe_row("page, css, on_frontpage, in_rss, searchable", 'txp_section', "name = 'default'");
        if ($rs) {
            $rs['name'] = $rs['title'] = $rs['description'] = '';
        }
    }
    if (!$rs) {
        sec_section_list(array(gTxt('unknown_section'), E_ERROR));
        return;
    }
    extract($rs, EXTR_PREFIX_ALL, 'sec');
    pagetop(gTxt('tab_sections'));
    $out = array();
    $out[] = hed($caption, 2);
    if ($is_default_section) {
        $out[] = hInput('name', 'default');
    } else {
        $out[] = inputLabel('section_name', fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 'section_name', '', array('class' => 'txp-form-field edit-section-name')) . inputLabel('section_title', fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 'section_longtitle', '', array('class' => 'txp-form-field edit-section-longtitle'));
    }
    $out[] = inputLabel('section_page', selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 'uses_page', 'section_uses_page', array('class' => 'txp-form-field edit-section-uses-page')) . inputLabel('section_css', selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 'uses_style', 'section_uses_css', array('class' => 'txp-form-field edit-section-uses-css'));
    if (!$is_default_section) {
        $out[] = inputLabel('on_front_page', yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), '', 'section_on_frontpage', array('class' => 'txp-form-field edit-section-on-frontpage')) . inputLabel('syndicate', yesnoradio('in_rss', $sec_in_rss, '', $sec_name), '', 'section_syndicate', array('class' => 'txp-form-field edit-section-syndicate')) . inputLabel('include_in_search', yesnoradio('searchable', $sec_searchable, '', $sec_name), '', 'section_searchable', array('class' => 'txp-form-field edit-section-searchable'));
    }
    $out[] = inputLabel('section_description', '<textarea id="section_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $sec_description . '</textarea>', 'description', 'section_description', array('class' => 'txp-form-field txp-form-field-textarea edit-section-description'));
    $out[] = pluggable_ui('section_ui', 'extend_detail_form', '', $rs) . graf(sLink('section', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . eInput('section') . sInput('section_save') . hInput('old_name', $sec_name) . hInput('search_method', $search_method) . hInput('crit', $crit) . hInput('page', $page) . hInput('sort', $sort) . hInput('dir', $dir);
    echo form(join('', $out), '', '', 'post', 'txp-edit', '', 'section_details');
}
Example #6
0
function article_edit($message = '', $concurrent = FALSE)
{
    global $vars, $txp_user, $comments_disabled_after, $txpcfg, $prefs;
    extract($prefs);
    extract(gpsa(array('view', 'from_view', 'step')));
    if (!empty($GLOBALS['ID'])) {
        // newly-saved article
        $ID = $GLOBALS['ID'];
        $step = 'edit';
    } else {
        $ID = gps('ID');
    }
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    // switch to 'text' view upon page load and after article post
    if (!$view || gps('save') || gps('publish')) {
        $view = 'text';
    }
    if (!$step) {
        $step = "create";
    }
    if ($step == "edit" && $view == "text" && !empty($ID) && $from_view != 'preview' && $from_view != 'html' && !$concurrent) {
        $pull = true;
        //-- it's an existing article - off we go to the db
        $ID = assert_int($ID);
        $rs = safe_row("*, unix_timestamp(Posted) as sPosted,\n\t\t\t\tunix_timestamp(Expires) as sExpires,\n\t\t\t\tunix_timestamp(LastMod) as sLastMod", "textpattern", "ID={$ID}");
        extract($rs);
        $reset_time = $publish_now = $Status < 4 && $sPosted <= time();
    } else {
        $pull = false;
        //-- assume they came from post
        if ($from_view == 'preview' or $from_view == 'html') {
            $store_out = array();
            $store = unserialize(base64_decode(ps('store')));
            foreach ($vars as $var) {
                if (isset($store[$var])) {
                    $store_out[$var] = $store[$var];
                }
            }
        } else {
            $store_out = gpsa($vars);
            if ($concurrent) {
                $store_out['sLastMod'] = safe_field('unix_timestamp(LastMod) as sLastMod', 'textpattern', 'ID=' . $ID);
            }
        }
        $rs = $store_out;
        extract($store_out);
    }
    $GLOBALS['step'] = $step;
    if ($step == 'create') {
        $textile_body = $use_textile;
        $textile_excerpt = $use_textile;
    }
    if ($step != 'create') {
        // Previous record?
        $prev_id = checkIfNeighbour('prev', $sPosted);
        // Next record?
        $next_id = checkIfNeighbour('next', $sPosted);
    }
    $page_title = $Title ? $Title : gTxt('write');
    pagetop($page_title, $message);
    echo n . n . '<form name="article" method="post" action="index.php">';
    if (!empty($store_out)) {
        echo hInput('store', base64_encode(serialize($store_out)));
    }
    echo hInput('ID', $ID) . eInput('article') . sInput($step) . '<input type="hidden" name="view" />' . startTable('edit') . '<tr>' . n . '<td id="article-col-1">';
    if ($view == 'text') {
        //-- markup help --------------
        echo pluggable_ui('article_ui', 'sidehelp', side_help($textile_body, $textile_excerpt));
        //-- custom menu entries --------------
        echo pluggable_ui('article_ui', 'extend_col_1', '', $rs);
        //-- advanced --------------
        echo '<h3 class="plain lever' . (get_pref('pane_article_advanced_visible') ? ' expanded' : '') . '"><a href="#advanced">' . gTxt('advanced_options') . '</a></h3>' . '<div id="advanced" class="toggle" style="display:' . (get_pref('pane_article_advanced_visible') ? 'block' : 'none') . '">';
        // markup selection
        echo pluggable_ui('article_ui', 'markup', n . graf('<label for="markup-body">' . gTxt('article_markup') . '</label>' . br . pref_text('textile_body', $textile_body, 'markup-body')) . n . graf('<label for="markup-excerpt">' . gTxt('excerpt_markup') . '</label>' . br . pref_text('textile_excerpt', $textile_excerpt, 'markup-excerpt')), $rs);
        // form override
        echo $allow_form_override ? pluggable_ui('article_ui', 'override', graf('<label for="override-form">' . gTxt('override_default_form') . '</label>' . sp . popHelp('override_form') . br . form_pop($override_form, 'override-form')), $rs) : '';
        // custom fields, believe it or not
        $max = get_pref('max_custom_fields', 10);
        $cf = '';
        for ($i = 1; $i <= $max; $i++) {
            $custom_x_set = "custom_{$i}_set";
            $custom_x = "custom_{$i}";
            $cf .= ${$custom_x_set} !== '' ? custField($i, ${$custom_x_set}, ${$custom_x}) : '';
        }
        echo pluggable_ui('article_ui', 'custom_fields', $cf, $rs);
        // keywords
        echo pluggable_ui('article_ui', 'keywords', n . graf('<label for="keywords">' . gTxt('keywords') . '</label>' . sp . popHelp('keywords') . br . n . '<textarea id="keywords" name="Keywords" cols="18" rows="5">' . htmlspecialchars(str_replace(',', ', ', $Keywords)) . '</textarea>'), $rs);
        // article image
        echo pluggable_ui('article_ui', 'article_image', n . graf('<label for="article-image">' . gTxt('article_image') . '</label>' . sp . popHelp('article_image') . br . fInput('text', 'Image', $Image, 'edit', '', '', 22, '', 'article-image')), $rs);
        // url title
        echo pluggable_ui('article_ui', 'url_title', n . graf('<label for="url-title">' . gTxt('url_title') . '</label>' . sp . popHelp('url_title') . br . fInput('text', 'url_title', $url_title, 'edit', '', '', 22, '', 'url-title')), $rs);
        echo '</div>' . n;
        //-- recent articles --------------
        echo '<h3 class="plain lever' . (get_pref('pane_article_recent_visible') ? ' expanded' : '') . '"><a href="#recent">' . gTxt('recent_articles') . '</a>' . '</h3>' . '<div id="recent" class="toggle" style="display:' . (get_pref('pane_article_recent_visible') ? 'block' : 'none') . '">';
        $recents = safe_rows_start("Title, ID", 'textpattern', "1=1 order by LastMod desc limit 10");
        if ($recents) {
            echo '<ul class="plain-list">';
            while ($recent = nextRow($recents)) {
                if (!$recent['Title']) {
                    $recent['Title'] = gTxt('untitled') . sp . $recent['ID'];
                }
                echo n . t . '<li><a href="?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID'] . '">' . escape_title($recent['Title']) . '</a></li>';
            }
            echo '</ul>';
        }
        echo '</div>';
    } else {
        echo sp;
    }
    echo '</td>' . n . '<td id="article-main">';
    //-- title input --------------
    if ($view == 'preview') {
        echo hed(gTxt('preview'), 2) . hed($Title, 1);
    } elseif ($view == 'html') {
        echo hed('XHTML', 2) . hed($Title, 1);
    } elseif ($view == 'text') {
        echo pluggable_ui('article_ui', 'title', n . '<p><label for="title">' . gTxt('title') . '</label>' . sp . popHelp('title') . br . '<input type="text" id="title" name="Title" value="' . escape_title($Title) . '" class="edit" size="40" tabindex="1" />', $rs);
        if ($step != 'create') {
            include_once txpath . '/publish/taghandlers.php';
            $url = permlinkurl_id($ID);
            if ($Status != 4 and $Status != 5) {
                $url .= (strpos($url, '?') === FALSE ? '?' : '&amp;') . 'txpreview=' . intval($ID) . '.' . time();
            }
            echo sp . sp . '<a href="' . $url . '" class="article-view">' . gTxt('view') . '</a>';
        }
        echo '</p>';
    }
    //-- body --------------------
    if ($view == 'preview') {
        if ($textile_body == USE_TEXTILE) {
            echo $textile->TextileThis($Body);
        } else {
            if ($textile_body == CONVERT_LINEBREAKS) {
                echo nl2br($Body);
            } else {
                if ($textile_body == LEAVE_TEXT_UNTOUCHED) {
                    echo $Body;
                }
            }
        }
    } elseif ($view == 'html') {
        if ($textile_body == USE_TEXTILE) {
            $bod = $textile->TextileThis($Body);
        } else {
            if ($textile_body == CONVERT_LINEBREAKS) {
                $bod = nl2br($Body);
            } else {
                if ($textile_body == LEAVE_TEXT_UNTOUCHED) {
                    $bod = $Body;
                }
            }
        }
        echo tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($bod)), 'code');
    } else {
        echo pluggable_ui('article_ui', 'body', n . graf('<label for="body">' . gTxt('body') . '</label>' . sp . popHelp('body') . br . '<textarea id="body" name="Body" cols="55" rows="31" tabindex="2">' . htmlspecialchars($Body) . '</textarea>'), $rs);
    }
    //-- excerpt --------------------
    if ($articles_use_excerpts) {
        if ($view == 'text') {
            echo pluggable_ui('article_ui', 'excerpt', n . graf('<label for="excerpt">' . gTxt('excerpt') . '</label>' . sp . popHelp('excerpt') . br . '<textarea id="excerpt" name="Excerpt" cols="55" rows="5" tabindex="3">' . htmlspecialchars($Excerpt) . '</textarea>'), $rs);
        } else {
            echo n . '<hr width="50%" />';
            echo $textile_excerpt == USE_TEXTILE ? $view == 'preview' ? graf($textile->textileThis($Excerpt)) : tag(str_replace(array(n, t), array(br, sp . sp . sp . sp), htmlspecialchars($textile->TextileThis($Excerpt))), 'code') : graf($Excerpt);
        }
    }
    //-- author --------------
    if ($view == "text" && $step != "create") {
        echo '<p class="small">' . gTxt('posted_by') . ': ' . htmlspecialchars($AuthorID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sPosted);
        if ($sPosted != $sLastMod) {
            echo br . gTxt('modified_by') . ': ' . htmlspecialchars($LastModID) . ' &#183; ' . safe_strftime('%d %b %Y &#183; %X', $sLastMod);
        }
        echo '</p>';
    }
    echo hInput('from_view', $view), '</td>';
    //-- layer tabs -------------------
    echo '<td id="article-tabs">';
    echo pluggable_ui('article_ui', 'view', $use_textile == USE_TEXTILE || $textile_body == USE_TEXTILE ? tag(tab('text', $view) . tab('html', $view) . tab('preview', $view), 'ul') : '&#160;', $rs);
    echo '</td>';
    echo '<td id="article-col-2">';
    if ($view == 'text') {
        if ($step != 'create') {
            echo n . graf(href(gtxt('create_new'), 'index.php?event=article'));
        }
        //-- prev/next article links --
        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 pluggable_ui('article_ui', 'status', n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio($Status) . n . '</fieldset>', $rs);
        //-- category selects -----------
        echo pluggable_ui('article_ui', 'categories', n . n . '<fieldset id="write-sort">' . n . '<legend>' . gTxt('sort_display') . '</legend>' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1')) . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2')), $rs);
        //-- section select --------------
        if (!$from_view && !$pull) {
            $Section = getDefaultSection();
        }
        echo pluggable_ui('article_ui', 'section', n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section')) . n . '</fieldset>', $rs);
        //-- "More" section
        echo n . n . '<h3 class="plain lever' . (get_pref('pane_article_more_visible') ? ' expanded' : '') . '"><a href="#more">' . gTxt('more') . '</a></h3>', '<div id="more" class="toggle" style="display:' . (get_pref('pane_article_more_visible') ? 'block' : 'none') . '">';
        //-- 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;
            }
        }
        if ($use_comments == 1) {
            $invite[] = n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>';
            $comments_expired = false;
            if ($step != 'create' && $comments_disabled_after) {
                $lifespan = $comments_disabled_after * 86400;
                $time_since = time() - $sPosted;
                if ($time_since > $lifespan) {
                    $comments_expired = true;
                }
            }
            if ($comments_expired) {
                $invite[] = n . n . graf(gTxt('expired'));
            } else {
                $invite[] = n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite'));
            }
            $invite[] = n . n . '</fieldset>';
            echo pluggable_ui('article_ui', 'annotate_invite', join('', $invite), $rs);
        }
        if ($step == "create" and empty($GLOBALS['ID'])) {
            //-- timestamp -------------------
            //Avoiding modified date to disappear
            $persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time();
            echo pluggable_ui('article_ui', 'timestamp', n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $persist_timestamp) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp)) . n . '</fieldset>', array('sPosted' => $persist_timestamp) + $rs);
            //-- expires -------------------
            $persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME;
            echo pluggable_ui('article_ui', 'expires', n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $persist_timestamp) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp)) . n . '</fieldset>', $rs);
            // end "More" section
            echo n . n . '</div>';
            //-- publish button --------------
            echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4);
        } else {
            //-- timestamp -------------------
            if (!empty($year)) {
                $sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second);
            }
            echo pluggable_ui('article_ui', 'timestamp', n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>') . n . graf(gTxt('published_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $sPosted) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted)) . n . hInput('sPosted', $sPosted) . n . hInput('sLastMod', $sLastMod) . n . hInput('AuthorID', $AuthorID) . n . hInput('LastModID', $LastModID) . n . '</fieldset>', $rs);
            //-- expires -------------------
            if (!empty($exp_year)) {
                if (empty($exp_month)) {
                    $exp_month = 1;
                }
                if (empty($exp_day)) {
                    $exp_day = 1;
                }
                if (empty($exp_hour)) {
                    $exp_hour = 0;
                }
                if (empty($exp_minute)) {
                    $exp_minute = 0;
                }
                if (empty($exp_second)) {
                    $exp_second = 0;
                }
                $sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second);
            }
            echo pluggable_ui('article_ui', 'expires', n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires)) . n . hInput('sExpires', $sExpires) . n . '</fieldset>', $rs);
            // end "More" section
            echo n . n . '</div>';
            //-- save button --------------
            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", '', '', '', 4);
            }
        }
    }
    echo '</td></tr></table></form>' . n;
    // Assume users would not change the timestamp if they wanted to "publish now"/"reset time"
    echo script_js(<<<EOS
\t\t\$('#write-timestamp input.edit').change(
\t\t\tfunction() {
\t\t\t\t\$('#publish_now').attr('checked', false);
\t\t\t\t\$('#reset_time').attr('checked', false);
\t\t\t});
EOS
);
}
Example #7
0
function section_detail_partial($thesection)
{
    static $pages, $styles;
    if (empty($pages)) {
        $pages = safe_column('name', 'txp_page', "1 = 1");
        $styles = safe_column('name', 'txp_css', "1 = 1");
    }
    extract($thesection);
    $default_section = $name == 'default';
    $out = '<table>' . ($default_section ? '' : n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), ' class="name"')) . ($default_section ? '' : n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), ' class="title"')) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . ($default_section ? '' : n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline'), ' class="option is-default"')) . ($default_section ? '' : n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline'), ' class="option on-frontpage"')) . ($default_section ? '' : n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline'), ' class="option in-rss"')) . ($default_section ? '' : n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline'), ' class="option is-searchable"')) . pluggable_ui('section_ui', 'extend_detail_form', '', $thesection) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . ($default_section ? hInput('name', $name) : hInput('old_name', $name)), ' colspan="2" class="noline"')) . endTable();
    // TODO: AJAX form submission
    //			return form($out,'', 'postForm(this);', 'post', 'async', 'section-'.$name, 'section-form-'.$name);
    return form($out, '', '', 'post', '', 'section-' . $name, 'section-form-' . $name);
}
Example #8
0
function section_edit()
{
    global $event, $step, $txp_user, $all_pages, $all_styles;
    $name = gps('name');
    $is_edit = $name && $step == 'section_edit';
    if ($is_edit) {
        $name = assert_string($name);
        $rs = safe_row('*', 'txp_section', "name = '" . doSlash($name) . "'");
    } else {
        $rs = array_flip(getThings('describe `' . PFX . 'txp_section`'));
    }
    if ($rs) {
        if (!has_privs('section.edit')) {
            sec_section_list(gTxt('restricted_area'));
            return;
        }
        pagetop(gTxt('tab_sections'));
        extract($rs, EXTR_PREFIX_ALL, 'sec');
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        $is_default_section = $is_edit && $sec_name == 'default';
        $caption = gTxt($is_default_section ? 'edit_default_section' : ($is_edit ? 'edit_section' : 'create_section'));
        if (!$is_edit) {
            // Pulling out the radio items from the default entry might seem pointless since they can't be directly
            // edited, but they will take on either:
            //  a) the default (SQL) values as defined at table creation time, or
            //  b) the values set when a multi-edit was performed that included the default section (because the values are silently updated then)
            $default = doSlash(safe_row('page, css, on_frontpage, in_rss, searchable', 'txp_section', "name = 'default'"));
            $sec_name = $sec_title = '';
            $sec_page = $default['page'];
            $sec_css = $default['css'];
            $sec_on_frontpage = $default['on_frontpage'];
            $sec_in_rss = $default['in_rss'];
            $sec_searchable = $default['searchable'];
        }
        echo '<div id="' . $event . '_container" class="txp-container">';
        echo form('<div class="txp-edit">' . hed($caption, 2) . ($is_default_section ? hInput('name', 'default') : inputLabel('section_name', fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 'section_name')) . ($is_default_section ? '' : inputLabel('section_title', fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 'section_longtitle')) . inputLabel('section_page', selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 'uses_page', 'section_uses_page') . inputLabel('section_css', selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 'uses_style', 'section_uses_css') . ($is_default_section ? '' : inputLabel('on_front_page', yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), '', 'section_on_frontpage')) . ($is_default_section ? '' : inputLabel('syndicate', yesnoradio('in_rss', $sec_in_rss, '', $sec_name), '', 'section_syndicate')) . ($is_default_section ? '' : inputLabel('include_in_search', yesnoradio('searchable', $sec_searchable, '', $sec_name), '', 'section_searchable')) . pluggable_ui('section_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('section') . sInput('section_save') . hInput('old_name', $sec_name) . hInput('search_method', $search_method) . hInput('crit', $crit) . hInput('page', $page) . hInput('sort', $sort) . hInput('dir', $dir) . '</div>', '', '', 'post', 'edit-form', '', 'section_details');
        echo '</div>';
    }
}
Example #9
0
function thumb_ui($id, $rs)
{
    global $prefs, $sort, $dir, $page, $search_method, $crit;
    extract($prefs);
    return tr(td(pluggable_ui('image_ui', 'thumbnail_create', form(graf(gTxt('create_thumbnail'), ' class="label"') . startTable('thumbnail_alter', 'left', '', 1) . tr(fLabelCell(gTxt('thumb_width'), '', 'width') . fInputCell('width', @$thumb_w, 1, 4, '', 'width') . fLabelCell(gTxt('thumb_height'), '', 'height') . fInputCell('height', @$thumb_h, 1, 4, '', 'height') . fLabelCell(gTxt('keep_square_pixels'), '', 'crop') . tda(checkbox('crop', 1, @$thumb_crop, '', 'crop'), ' class="noline"') . tda(fInput('submit', '', gTxt('Create'), 'smallerbox'), ' class="noline"'), ' class="thumbnail-alter-controls"') . n . hInput('id', $id) . n . eInput('image') . n . sInput('thumbnail_create') . n . hInput('sort', $sort) . n . hInput('dir', $dir) . n . hInput('page', $page) . n . hInput('search_method', $search_method) . n . hInput('crit', $crit) . endTable(), '', '', 'post', 'edit-form', '', 'thumbnail_alter_form'), $rs)), ' class="thumbnail-alter"');
}
Example #10
0
function pagetop($pagetitle, $message = "")
{
    global $siteurl, $sitename, $txp_user, $event, $step, $app_mode, $theme;
    if ($app_mode == 'async') {
        return;
    }
    $area = gps('area');
    $event = !$event ? 'article' : $event;
    $bm = gps('bm');
    $privs = safe_field("privs", "txp_users", "name = '" . doSlash($txp_user) . "'");
    $GLOBALS['privs'] = $privs;
    $areas = areas();
    $area = false;
    foreach ($areas as $k => $v) {
        if (in_array($event, $v)) {
            $area = $k;
            break;
        }
    }
    if (gps('logout')) {
        $body_id = 'page-logout';
    } elseif (!$txp_user) {
        $body_id = 'page-login';
    } else {
        $body_id = 'page-' . htmlspecialchars($event);
    }
    ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
    echo LANG;
    ?>
" lang="<?php 
    echo LANG;
    ?>
" dir="<?php 
    echo gTxt('lang_dir');
    ?>
">
	<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex, nofollow" />
	<title>Txp &#8250; <?php 
    echo htmlspecialchars($sitename);
    ?>
 &#8250; <?php 
    echo escape_title($pagetitle);
    ?>
</title>
	<script src="jquery.js" type="text/javascript"></script>
	<?php 
    echo script_js('var textpattern = {event: "' . htmlspecialchars($event) . '", step: "' . htmlspecialchars($step) . '"};');
    ?>
	<script type="text/javascript" src="textpattern.js"></script>
	<script type="text/javascript">
	<!--

		var cookieEnabled = checkCookies();

		if (!cookieEnabled)
		{
			confirm('<?php 
    echo trim(gTxt('cookies_must_be_enabled'));
    ?>
');
		}

<?php 
    $edit = array();
    if ($event == 'list') {
        $rs = safe_column('name', 'txp_section', "name != 'default'");
        $edit['section'] = $rs ? selectInput('Section', $rs, '', true) : '';
        $rs = getTree('root', 'article');
        $edit['category1'] = $rs ? treeSelectInput('Category1', $rs, '') : '';
        $edit['category2'] = $rs ? treeSelectInput('Category2', $rs, '') : '';
        $edit['comments'] = onoffRadio('Annotate', safe_field('val', 'txp_prefs', "name = 'comments_on_default'"));
        $edit['status'] = selectInput('Status', array(1 => gTxt('draft'), 2 => gTxt('hidden'), 3 => gTxt('pending'), 4 => gTxt('live'), 5 => gTxt('sticky')), '', true);
        $rs = safe_column('name', 'txp_users', "privs not in(0,6) order by name asc");
        $edit['author'] = $rs ? selectInput('AuthorID', $rs, '', true) : '';
    }
    if (in_array($event, array('image', 'file', 'link'))) {
        $rs = getTree('root', $event);
        $edit['category'] = $rs ? treeSelectInput('category', $rs, '') : '';
        $rs = safe_column('name', 'txp_users', "privs not in(0,6) order by name asc");
        $edit['author'] = $rs ? selectInput('author', $rs, '', true) : '';
    }
    if ($event == 'plugin') {
        $edit['order'] = selectInput('order', array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9), 5, false);
    }
    if ($event == 'admin') {
        $edit['privilege'] = privs();
        $rs = safe_column('name', 'txp_users', '1=1');
        $edit_assign_assets = $rs ? selectInput('assign_assets', $rs, '', true) : '';
    }
    // output JavaScript
    ?>
		function poweredit(elm)
		{
			var something = elm.options[elm.selectedIndex].value;

			// Add another chunk of HTML
			var pjs = document.getElementById('js');

			if (pjs == null)
			{
				var br = document.createElement('br');
				elm.parentNode.appendChild(br);

				pjs = document.createElement('P');
				pjs.setAttribute('id','js');
				elm.parentNode.appendChild(pjs);
			}

			if (pjs.style.display == 'none' || pjs.style.display == '')
			{
				pjs.style.display = 'block';
			}

			if (something != '')
			{
				switch (something)
				{
<?php 
    foreach ($edit as $key => $val) {
        echo "case 'change" . $key . "':" . n . t . "pjs.innerHTML = '<span>" . str_replace(array("\n", '-'), array('', '&#45;'), str_replace('</', '<\\/', addslashes($val))) . "<\\/span>';" . n . t . 'break;' . n . n;
    }
    if (isset($edit_assign_assets)) {
        echo "case 'delete':" . n . t . "pjs.innerHTML = '<label for=\"assign_assets\">" . addslashes(gTxt('assign_assets_to')) . "</label><span>" . str_replace(array("\n", '-'), array('', '&#45;'), str_replace('</', '<\\/', addslashes($edit_assign_assets))) . "<\\/span>';" . n . t . 'break;' . n . n;
    }
    ?>
					default:
						pjs.style.display = 'none';
						break;
				}
			}

			return false;
		}

		addEvent(window, 'load', cleanSelects);
	-->
	</script>
	<?php 
    echo $theme->html_head();
    callback_event('admin_side', 'head_end');
    ?>
	</head>
	<body id="<?php 
    echo $body_id;
    ?>
" class="<?php 
    echo $area;
    ?>
">
	<?php 
    callback_event('admin_side', 'pagetop');
    $theme->set_state($area, $event, $bm, $message);
    echo pluggable_ui('admin_side', 'header', $theme->header());
    callback_event('admin_side', 'pagetop_end');
}
Example #11
0
/**
 * Renders a HTML &lt;select&gt; list of installed admin-side themes.
 *
 * Can be altered by plugins via the 'prefs_ui > theme_name'
 * pluggable UI callback event.
 *
 * @param  string $name HTML name and id of the widget
 * @param  string $val  Initial (or current) selected item
 * @return string HTML
 */
function themename($name, $val)
{
    $themes = theme::names();
    foreach ($themes as $t) {
        $theme = theme::factory($t);
        if ($theme) {
            $m = $theme->manifest();
            $title = empty($m['title']) ? ucwords($theme->name) : $m['title'];
            $vals[$t] = $title;
            unset($theme);
        }
    }
    asort($vals, SORT_STRING);
    return pluggable_ui('prefs_ui', 'theme_name', selectInput($name, $vals, $val, '', '', $name));
}
Example #12
0
/**
 * Renders expiration date partial.
 *
 * The rendered widget can be customised via the 'article_ui > expires'
 * pluggable UI callback event.
 *
 * @param  array  $rs Article data
 * @return string HTML
 */
function article_partial_expires($rs)
{
    extract($rs);
    $out = wrapRegion('write-expires', graf(span(gTxt('date'), array('class' => 'txp-label-fixed')) . br . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires), ' class="date expires"') . graf(span(gTxt('time'), array('class' => 'txp-label-fixed')) . br . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires), ' class="time expires"') . hInput('sExpires', $sExpires), '', gTxt('expires'));
    return pluggable_ui('article_ui', 'expires', $out, $rs);
}
Example #13
0
function cat_event_category_edit($evname)
{
    pagetop(gTxt('categories'));
    $id = assert_int(gps('id'));
    $parent = doSlash(gps('parent'));
    $row = safe_row("*", "txp_category", "id={$id}");
    if ($row) {
        extract($row);
        $out = stackRows(fLabelCell($evname . '_category_name') . fInputCell('name', $name, 1, 20), fLabelCell('parent') . td(cat_parent_pop($parent, $evname, $id)), fLabelCell($evname . '_category_title') . fInputCell('title', $title, 1, 30), pluggable_ui('category_ui', 'extend_detail_form', '', $row), hInput('id', $id), tdcs(fInput('submit', '', gTxt('save_button'), 'smallerbox'), 2));
    }
    $out .= eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name);
    echo '<div id="category_container" class="txp-container txp-edit">' . form(startTable('edit', '', 'edit-pane') . $out . endTable(), '', '', 'post', 'edit-form') . '</div>';
}
Example #14
0
<?php

/*
	This is Textpattern
	Copyright 2005 by Dean Allen
	www.textpattern.com
	All rights reserved
	Use of this software indicates acceptance of the Textpattern license agreement
$HeadURL$
$LastChangedRevision$
*/
if (!defined('txpinterface')) {
    die('txpinterface is undefined.');
}
// -------------------------------------------------------------
header(pluggable_ui('admin_side', 'x_frame_options', 'X-Frame-Options: SAMEORIGIN'));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
echo LANG;
?>
" lang="<?php 
echo LANG;
?>
" dir="<?php 
echo txpspecialchars(gTxt('lang_dir'));
?>
">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php 
Example #15
0
function image_edit($message = '', $id = '')
{
    global $prefs, $file_max_upload_size, $txp_user, $event, $all_image_cats;
    if (!$id) {
        $id = gps('id');
    }
    $id = assert_int($id);
    $rs = safe_row("*, unix_timestamp(date) as uDate", "txp_image", "id = {$id}");
    if ($rs) {
        extract($rs);
        if (!has_privs('image.edit') && !($author === $txp_user && has_privs('image.edit.own'))) {
            image_list(gTxt('restricted_area'));
            return;
        }
        pagetop(gTxt('edit_image'), $message);
        extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
        if ($ext != '.swf') {
            $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape');
            $img_info = $id . $ext . ' (' . $w . ' &#215; ' . $h . ')';
            $img = '<div class="fullsize-image"><img class="content-image" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" alt="' . $img_info . '" title="' . $img_info . '" /></div>';
        } else {
            $img = $aspect = '';
        }
        if ($thumbnail and $ext != '.swf') {
            $thumb_info = $id . 't' . $ext . ' (' . $thumb_w . ' &#215; ' . $thumb_h . ')';
            $thumb = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="' . $thumb_info . '" ' . ($thumb_w ? 'width="' . $thumb_w . '" height="' . $thumb_h . '" title="' . $thumb_info . '"' : '') . ' />';
        } else {
            $thumb = '';
            if ($thumb_w == 0) {
                $thumb_w = get_pref('thumb_w', 0);
            }
            if ($thumb_h == 0) {
                $thumb_h = get_pref('thumb_h', 0);
            }
        }
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo pluggable_ui('image_ui', 'fullsize_image', $img, $rs), '<section class="txp-edit">', hed(gTxt('edit_image'), 2), pluggable_ui('image_ui', 'image_edit', wrapGroup('image_edit_group', upload_form('', '', 'image_replace', 'image', $id, $file_max_upload_size, 'image_replace', 'image-replace'), 'replace_image', 'replace-image', 'replace_image_form'), $rs), pluggable_ui('image_ui', 'thumbnail_image', '<div class="thumbnail-edit">' . ($thumbnail ? $thumb . n . dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)) : '') . '</div>', $rs), pluggable_ui('image_ui', 'thumbnail_edit', wrapGroup('thumbnail_edit_group', upload_form('', '', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'upload_thumbnail', 'thumbnail-upload'), 'upload_thumbnail', 'thumbnail-upload', 'upload_thumbnail'), $rs), check_gd($ext) ? pluggable_ui('image_ui', 'thumbnail_create', wrapGroup('thumbnail_create_group', form(graf(n . '<label for="width">' . gTxt('thumb_width') . '</label>' . fInput('text', 'width', @$thumb_w, 'input-xsmall', '', '', INPUT_XSMALL, '', 'width') . n . '<label for="height">' . gTxt('thumb_height') . '</label>' . fInput('text', 'height', @$thumb_h, 'input-xsmall', '', '', INPUT_XSMALL, '', 'height') . n . '<label for="crop">' . gTxt('keep_square_pixels') . '</label>' . checkbox('crop', 1, @$prefs['thumb_crop'], '', 'crop') . fInput('submit', '', gTxt('Create')), ' class="edit-alter-thumbnail"') . hInput('id', $id) . eInput('image') . sInput('thumbnail_create') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'thumbnail_alter_form'), 'create_thumbnail', 'thumbnail-alter', 'create_thumbnail'), $rs) : '', '<div class="image-detail">', form(inputLabel('image_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'image_name'), 'image_name') . inputLabel('image_category', treeSelectInput('category', $all_image_cats, $category, 'image_category'), 'image_category') . inputLabel('image_alt_text', fInput('text', 'alt', $alt, '', '', '', INPUT_REGULAR, '', 'image_alt_text'), 'alt_text') . inputLabel('image_caption', text_area('caption', 0, 0, $caption, 'image_caption', TEXTAREA_HEIGHT_SMALL, INPUT_LARGE), 'caption', '', '', '') . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . hInput('id', $id) . eInput('image') . sInput('image_save') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'image_details_form'), '</div>', '</section>' . n . '</div>';
    }
}
Example #16
0
/**
 * Renders a file upload form.
 *
 * The rendered form can be customised via the '{$event}_ui > upload_form'
 * pluggable UI callback event.
 *
 * @param  string $label         File name label. May be empty
 * @param  string $pophelp       Help item
 * @param  string $step          Step
 * @param  string $event         Event
 * @param  string $id            File id
 * @param  int    $max_file_size Maximum allowed file size
 * @param  string $label_id      HTML id attribute for the filename input element
 * @param  string $class         HTML class attribute for the form element
 * @return string HTML
 */
function upload_form($label, $pophelp = '', $step, $event, $id = '', $max_file_size = 1000000, $label_id = '', $class = 'upload-form')
{
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
    if (!$label_id) {
        $p_class = 'edit-' . $event . '-upload';
        $label_id = $event . '-upload';
    } else {
        $p_class = 'edit-' . str_replace('_', '-', $label_id);
    }
    $argv = func_get_args();
    return pluggable_ui($event . '_ui', 'upload_form', n . tag((!empty($max_file_size) ? hInput('MAX_FILE_SIZE', $max_file_size) : '') . eInput($event) . sInput($step) . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit) . graf(tag($label, 'label', array('for' => $label_id)) . popHelp($pophelp) . fInput('file', 'thefile', '', '', '', '', '', '', $label_id) . fInput('submit', '', gTxt('upload')), array('class' => $p_class)) . tInput() . n, 'form', array('class' => $class, 'method' => 'post', 'enctype' => 'multipart/form-data', 'action' => 'index.php')), $argv);
}
Example #17
0
/**
 * Return the HTML &lt;title&gt; contents for an admin-side page.
 *
 * The rendered title can be customised via a 'admin_side > html_title'
 * pluggable UI callback event.
 *
 * @param  string $pagetitle Specific page title part
 * @return string
 * @since  4.6.0
 */
function admin_title($pagetitle)
{
    global $sitename;
    if ((string) $pagetitle === '') {
        $title = gTxt('untitled');
    } else {
        $title = $pagetitle;
    }
    $title = escape_title($title) . ' - ' . txpspecialchars($sitename) . ' &#124; Textpattern CMS';
    return pluggable_ui('admin_side', 'html_title', $title, compact('pagetitle'));
}
Example #18
0
/**
 * Renders and outputs a category editor panel.
 *
 * @param string $evname Type of category
 */
function cat_event_category_edit($evname, $message = '')
{
    $id = assert_int(gps('id'));
    $parent = doSlash(gps('parent'));
    $row = safe_row("*", 'txp_category', "id = {$id}");
    if ($row) {
        pagetop(gTxt('edit_category'), $message);
        extract($row);
        list($parent_widget, $has_parent) = cat_parent_pop($parent, $evname, $id);
        $out = hed(gTxt('edit_category'), 2) . inputLabel('category_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'category_name'), $evname . '_category_name', '', array('class' => 'txp-form-field edit-category-name')) . inputLabel('category_parent', $parent_widget, 'parent', '', array('class' => 'txp-form-field edit-category-parent')) . inputLabel('category_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'category_title'), $evname . '_category_title', '', array('class' => 'txp-form-field edit-category-title')) . inputLabel('category_description', '<textarea id="category_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $description . '</textarea>', $evname . '_category_description', 'category_description', array('class' => 'txp-form-field txp-form-field-textarea edit-category-description')) . pluggable_ui('category_ui', 'extend_detail_form', '', $row) . hInput('id', $id) . graf(sLink('category', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name);
        echo form($out, '', '', 'post', 'txp-edit');
    } else {
        cat_category_list(array(gTxt('category_not_found'), E_ERROR));
    }
}
Example #19
0
/**
 * The editor for sections.
 */
function section_edit()
{
    global $event, $step, $all_pages, $all_styles;
    require_privs('section.edit');
    extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method', 'name')));
    $is_edit = $name && $step == 'section_edit';
    $caption = gTxt('create_section');
    $is_default_section = false;
    if ($is_edit) {
        $rs = safe_row('*', 'txp_section', "name = '" . doSlash($name) . "'");
        if ($name == 'default') {
            $caption = gTxt('edit_default_section');
            $is_default_section = true;
        } else {
            $caption = gTxt('edit_section');
        }
    } else {
        // Pulls defaults for the new section from the 'default'.
        $rs = safe_row('*', 'txp_section', "name = 'default'");
        if ($rs) {
            $rs['name'] = $rs['title'] = '';
        }
    }
    if (!$rs) {
        sec_section_list(array(gTxt('unknown_section'), E_ERROR));
        return;
    }
    extract($rs, EXTR_PREFIX_ALL, 'sec');
    pagetop(gTxt('tab_sections'));
    $out = array();
    $out[] = n . tag_start('section', array('class' => 'txp-edit')) . hed($caption, 2);
    if ($is_default_section) {
        $out[] = hInput('name', 'default');
    } else {
        $out[] = inputLabel('section_name', fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 'section_name') . inputLabel('section_title', fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 'section_longtitle');
    }
    $out[] = inputLabel('section_description', text_area('description', 0, 0, $sec_description, 'section_description', TEXTAREA_HEIGHT_SMALL, INPUT_LARGE), 'section_description');
    $out[] = inputLabel('section_page', selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 'uses_page', 'section_uses_page') . inputLabel('section_css', selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 'uses_style', 'section_uses_css');
    if (!$is_default_section) {
        $out[] = inputLabel('on_front_page', yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), '', 'section_on_frontpage') . inputLabel('syndicate', yesnoradio('in_rss', $sec_in_rss, '', $sec_name), '', 'section_syndicate') . inputLabel('include_in_search', yesnoradio('searchable', $sec_searchable, '', $sec_name), '', 'section_searchable');
    }
    $out[] = pluggable_ui('section_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('section') . sInput('section_save') . hInput('old_name', $sec_name) . hInput('search_method', $search_method) . hInput('crit', $crit) . hInput('page', $page) . hInput('sort', $sort) . hInput('dir', $dir) . n . tag_end('section');
    echo n . tag_start('div', array('id' => $event . '_container', 'class' => 'txp-container')) . form(join('', $out), '', '', 'post', 'edit-form', '', 'section_details') . n . tag_end('div');
}
Example #20
0
function file_edit($message = '', $id = '')
{
    global $file_base_path, $levels, $file_statuses, $txp_user, $event, $all_file_cats;
    extract(gpsa(array('name', 'title', 'category', 'permissions', 'description', 'sort', 'dir', 'page', 'crit', 'search_method', 'publish_now')));
    if (!$id) {
        $id = gps('id');
    }
    $id = assert_int($id);
    $rs = safe_row('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', "id = {$id}");
    if ($rs) {
        extract($rs);
        $filename = sanitizeForFile($filename);
        if (!has_privs('file.edit') && !($author === $txp_user && has_privs('file.edit.own'))) {
            require_privs();
        }
        pagetop(gTxt('edit_file'), $message);
        if ($permissions == '') {
            $permissions = '-1';
        }
        if (!has_privs('file.publish') && $status >= STATUS_LIVE) {
            $status = STATUS_PENDING;
        }
        $file_exists = file_exists(build_file_path($file_base_path, $filename));
        $existing_files = get_filenames();
        $replace = $file_exists ? wrapGroup('file_upload_group', file_upload_form('', '', 'file_replace', $id, 'file_replace'), 'replace_file', 'replace-file', 'file_replace') : wrapGroup('file_upload_group', file_upload_form('', '', 'file_replace', $id, 'file_reassign'), 'file_relink', 'upload-file', 'file_reassign');
        $condition = span($file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'), array('class' => $file_exists ? 'success' : 'error'));
        $downloadlink = $file_exists ? make_download_link($id, txpspecialchars($filename), $filename) : txpspecialchars($filename);
        $created = graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . n . '<label for="publish_now">' . gTxt('set_to_now') . '</label>', ' class="edit-file-publish-now"') . graf(gTxt('or_publish_at') . popHelp('timestamp'), ' class="edit-file-publish-at"') . graf(span(gTxt('date'), array('class' => 'txp-label-fixed')) . br . tsi('year', '%Y', $rs['created'], '', gTxt('yyyy')) . ' / ' . tsi('month', '%m', $rs['created'], '', gTxt('mm')) . ' / ' . tsi('day', '%d', $rs['created'], '', gTxt('dd')), ' class="edit-file-published"') . graf(span(gTxt('time'), array('class' => 'txp-label-fixed')) . br . tsi('hour', '%H', $rs['created'], '', gTxt('hh')) . ' : ' . tsi('minute', '%M', $rs['created'], '', gTxt('mm')) . ' : ' . tsi('second', '%S', $rs['created'], '', gTxt('ss')), ' class="edit-file-created"');
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo n . '<section class="txp-edit">' . hed(gTxt('edit_file'), 2) . inputLabel('condition', $condition) . inputLabel('name', $downloadlink) . inputLabel('download_count', $downloads) . $replace . n . '<div class="file-detail ' . ($file_exists ? '' : 'not-') . 'exists">' . form(($file_exists ? inputLabel('file_status', selectInput('status', $file_statuses, $status, false, '', 'file_status'), 'file_status') . inputLabel('file_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'file_title'), 'title') . inputLabel('file_category', treeSelectInput('category', $all_file_cats, $category, 'file_category'), 'file_category') . inputLabel('file_description', '<textarea id="file_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $description . '</textarea>', 'description', '', '', '') . wrapRegion('file_created', $created, '', gTxt('timestamp'), '', 'file-created') . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('Save'), 'publish')) . hInput('filename', $filename) : (empty($existing_files) ? '' : gTxt('existing_file') . selectInput('filename', $existing_files, '', 1)) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('Save'), 'publish')) . hInput('category', $category) . hInput('perms', $permissions == '-1' ? '' : $permissions) . hInput('title', $title) . hInput('description', $description) . hInput('status', $status)) . eInput('file') . sInput('file_save') . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method), '', '', 'post', 'edit-form', '', $file_exists ? 'file_details' : 'assign_file') . n . '</div>' . n . '</section>' . n . '</div>';
    }
}
Example #21
0
function file_edit($message = '', $id = '')
{
    global $file_base_path, $levels, $file_statuses, $txp_user;
    extract(gpsa(array('name', 'category', 'permissions', 'description', 'sort', 'dir', 'page', 'crit', 'search_method', 'publish_now')));
    if (!$id) {
        $id = gps('id');
    }
    $id = assert_int($id);
    $categories = getTree('root', 'file');
    $rs = safe_row('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', "id = {$id}");
    if ($rs) {
        extract($rs);
        if (!has_privs('file.edit') && !($author == $txp_user && has_privs('file.edit.own'))) {
            file_list(gTxt('restricted_area'));
            return;
        }
        pagetop(gTxt('file'), $message);
        if ($permissions == '') {
            $permissions = '-1';
        }
        if (!has_privs('file.publish') && $status >= 4) {
            $status = 3;
        }
        $file_exists = file_exists(build_file_path($file_base_path, $filename));
        $replace = $file_exists ? tr(td(file_upload_form(gTxt('replace_file'), 'upload', 'file_replace', $id))) : '';
        $existing_files = get_filenames();
        $condition = '<span class="';
        $condition .= $file_exists ? 'ok' : 'not-ok';
        $condition .= '">';
        $condition .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing');
        $condition .= '</span>';
        $downloadlink = $file_exists ? make_download_link($id, htmlspecialchars($filename), $filename) : htmlspecialchars($filename);
        $created = n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $rs['created']) . ' / ' . tsi('month', '%m', $rs['created']) . ' / ' . tsi('day', '%d', $rs['created'])) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $rs['created']) . ' : ' . tsi('minute', '%M', $rs['created']) . ' : ' . tsi('second', '%S', $rs['created']));
        $form = '';
        if ($file_exists) {
            $form = tr(td(form(graf(gTxt('file_category') . br . treeSelectInput('category', $categories, $category)) . graf(gTxt('description') . br . text_area('description', '100', '400', $description)) . fieldset(radio_list('status', $file_statuses, $status, 4), gTxt('status'), 'file-status') . fieldset($created, gTxt('timestamp'), 'file-created') . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'))) . eInput('file') . sInput('file_save') . hInput('filename', $filename) . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method))));
        } else {
            $form = tr(tda(hed(gTxt('file_relink'), 3) . file_upload_form(gTxt('upload_file'), 'upload', 'file_replace', $id) . form(graf(gTxt('existing_file') . ' ' . selectInput('filename', $existing_files, "", 1) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . fInput('submit', '', gTxt('Save'), 'smallerbox') . eInput('file') . sInput('file_save') . hInput('id', $id) . hInput('category', $category) . hInput('perms', $permissions == '-1' ? '' : $permissions) . hInput('description', $description) . hInput('status', $status) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method))), ' colspan="4" style="border:0"'));
        }
        echo startTable('list', '', 'edit-pane'), tr(td(graf(gTxt('file_status') . br . $condition) . graf(gTxt('file_name') . br . $downloadlink) . graf(gTxt('file_download_count') . br . $downloads))), $form, $replace, endTable();
    }
}
Example #22
0
/**
 * User editor panel.
 *
 * Accessing requires 'admin.edit' privileges.
 */
function author_edit()
{
    global $step, $txp_user;
    require_privs('admin.edit');
    pagetop(gTxt('tab_site_admin'), '');
    $vars = array('user_id', 'name', 'RealName', 'email', 'privs');
    $rs = array();
    $out = array();
    extract(gpsa($vars));
    $is_edit = $user_id && $step == 'author_edit';
    if ($is_edit) {
        $user_id = assert_int($user_id);
        $rs = safe_row('*', 'txp_users', "user_id = {$user_id}");
        extract($rs);
    }
    if ($is_edit) {
        $out[] = hed(gTxt('edit_author'), 2);
    } else {
        $out[] = hed(gTxt('add_new_author'), 2);
    }
    if ($is_edit) {
        $out[] = inputLabel('login_name', strong(txpspecialchars($name)));
    } else {
        $out[] = inputLabel('login_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), 'login_name', 'add_new_author');
    }
    $out[] = inputLabel('real_name', fInput('text', 'RealName', $RealName, '', '', '', INPUT_REGULAR, '', 'real_name'), 'real_name') . inputLabel('login_email', fInput('email', 'email', $email, '', '', '', INPUT_REGULAR, '', 'login_email'), 'email');
    if ($txp_user != $name) {
        $out[] = inputLabel('privileges', privs($privs), 'privileges', 'about_privileges');
    } else {
        $out[] = inputLabel('privileges', strong(get_priv_level($privs))) . hInput('privs', $privs);
    }
    $out[] = pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('admin');
    if ($user_id) {
        $out[] = hInput('user_id', $user_id) . hInput('name', $name) . sInput('author_save');
    } else {
        $out[] = sInput('author_save_new');
    }
    echo form(n . tag(join('', $out) . n, 'section', array('class' => 'txp-edit')), '', '', 'post', 'edit-form', '', 'user_edit');
}
Example #23
0
function link_edit($message = '')
{
    global $vars, $event, $step, $txp_user;
    pagetop(gTxt('tab_link'), $message);
    echo '<div id="' . $event . '_container" class="txp-container">';
    extract(array_map('assert_string', gpsa($vars)));
    $is_edit = $id && $step == 'link_edit';
    $rs = array();
    if ($is_edit) {
        $id = assert_int($id);
        $rs = safe_row('*', 'txp_link', "id = {$id}");
        if ($rs) {
            extract($rs);
            if (!has_privs('link.edit') && !($author == $txp_user && has_privs('link.edit.own'))) {
                link_list(gTxt('restricted_area'));
                return;
            }
        }
    }
    if (has_privs('link.edit') || has_privs('link.edit.own')) {
        $caption = gTxt($is_edit ? 'edit_link' : 'add_new_link');
        echo form('<div class="txp-edit">' . n . hed($caption, 2) . n . inputLabel('linkname', fInput('text', 'linkname', $linkname, '', '', '', INPUT_REGULAR, '', 'linkname'), 'title') . n . inputLabel('linksort', fInput('text', 'linksort', $linksort, '', '', '', INPUT_REGULAR, '', 'linksort'), 'sort_value', 'link_sort') . n . inputLabel('url', fInput('text', 'url', $url, '', '', '', INPUT_REGULAR, '', 'url'), 'url', 'link_url', 'edit-link-url') . n . inputLabel('link_category', linkcategory_popup($category) . ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']', 'link_category', 'link_category') . n . inputLabel('link_description', '<textarea id="link_description" name="description" cols="' . INPUT_LARGE . '" rows="' . INPUT_SMALL . '">' . txpspecialchars($description) . '</textarea>', 'description', 'link_description', '', '') . n . pluggable_ui('link_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('link') . sInput('link_save') . hInput('id', $id) . hInput('search_method', gps('search_method')) . hInput('crit', gps('crit')) . '</div>', '', '', 'post', 'edit-form', '', 'link_details');
    }
    echo '</div>';
}
Example #24
0
/**
 * Renders and outputs the file editor panel.
 *
 * @param string|array $message The activity message
 * @param int          $id      The file ID
 */
function file_edit($message = '', $id = '')
{
    global $file_base_path, $levels, $file_statuses, $txp_user, $event, $all_file_cats;
    extract(gpsa(array('name', 'title', 'category', 'permissions', 'description', 'sort', 'dir', 'page', 'crit', 'search_method', 'publish_now')));
    if (!$id) {
        $id = gps('id');
    }
    $id = assert_int($id);
    $rs = safe_row("*, UNIX_TIMESTAMP(created) AS created, UNIX_TIMESTAMP(modified) AS modified", 'txp_file', "id = {$id}");
    if ($rs) {
        extract($rs);
        $filename = sanitizeForFile($filename);
        if (!has_privs('file.edit') && !($author === $txp_user && has_privs('file.edit.own'))) {
            require_privs();
        }
        pagetop(gTxt('edit_file'), $message);
        if ($permissions == '') {
            $permissions = '-1';
        }
        if (!has_privs('file.publish') && $status >= STATUS_LIVE) {
            $status = STATUS_PENDING;
        }
        $file_exists = file_exists(build_file_path($file_base_path, $filename));
        $existing_files = get_filenames();
        $replace = $file_exists ? file_upload_form('replace_file', 'file_replace', 'file_replace', $id, 'file_replace', ' replace-file') : file_upload_form('file_relink', 'file_reassign', 'file_replace', $id, 'file_reassign', ' upload-file');
        $condition = span($file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'), array('class' => $file_exists ? 'success' : 'error'));
        $downloadlink = $file_exists ? make_download_link($id, txpspecialchars($filename), $filename) : txpspecialchars($filename);
        $created = inputLabel('year', tsi('year', '%Y', $rs['created'], '', 'year') . ' <span role="separator">/</span> ' . tsi('month', '%m', $rs['created'], '', 'month') . ' <span role="separator">/</span> ' . tsi('day', '%d', $rs['created'], '', 'day'), 'publish_date', array('timestamp_file', 'instructions_file_date'), array('class' => 'txp-form-field date posted')) . inputLabel('hour', tsi('hour', '%H', $rs['created'], '', 'hour') . ' <span role="separator">:</span> ' . tsi('minute', '%M', $rs['created'], '', 'minute') . ' <span role="separator">:</span> ' . tsi('second', '%S', $rs['created'], '', 'second'), 'publish_time', array('', 'instructions_file_time'), array('class' => 'txp-form-field time posted')) . n . tag(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . n . tag(gTxt('set_to_now'), 'label', array('for' => 'publish_now')), 'div', array('class' => 'posted-now'));
        echo n . tag_start('div', array('class' => 'txp-edit')) . hed(gTxt('edit_file'), 2) . $replace . inputLabel('condition', $condition, '', '', array('class' => 'txp-form-field edit-file-condition')) . inputLabel('name', $downloadlink, '', '', array('class' => 'txp-form-field edit-file-name')) . inputLabel('download_count', $downloads, '', '', array('class' => 'txp-form-field edit-file-download-count')) . form(($file_exists ? inputLabel('file_status', selectInput('status', $file_statuses, $status, false, '', 'file_status'), 'file_status', '', array('class' => 'txp-form-field edit-file-status')) . $created . inputLabel('file_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'file_title'), 'title', '', array('class' => 'txp-form-field edit-file-title')) . inputLabel('file_category', event_category_popup('file', $category, 'file_category') . n . eLink('category', 'list', '', '', gTxt('edit'), '', '', '', 'txp-option-link'), 'file_category', '', array('class' => 'txp-form-field edit-file-category')) . inputLabel('file_description', '<textarea id="file_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $description . '</textarea>', 'description', '', array('class' => 'txp-form-field txp-form-field-textarea edit-file-description')) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(sLink('file', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . hInput('filename', $filename) : (empty($existing_files) ? '' : gTxt('existing_file') . selectInput('filename', $existing_files, '', 1)) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(sLink('file', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . hInput('category', $category) . hInput('perms', $permissions == '-1' ? '' : $permissions) . hInput('title', $title) . hInput('description', $description) . hInput('status', $status)) . eInput('file') . sInput('file_save') . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method), '', '', 'post', 'file-detail ' . ($file_exists ? '' : 'not-') . 'exists', '', $file_exists ? 'file_details' : 'assign_file') . n . tag_end('div');
    }
}
Example #25
0
function link_edit($message = '')
{
    global $vars, $step;
    pagetop(gTxt('edit_links'), $message);
    extract(gpsa($vars));
    $rs = array();
    if ($id && $step == 'link_edit') {
        $id = assert_int($id);
        $rs = safe_row('*', 'txp_link', "id = {$id}");
        extract($rs);
    }
    if ($step == 'link_save' or $step == 'link_post') {
        foreach ($vars as $var) {
            ${$var} = '';
        }
    }
    echo form(startTable('edit') . tr(fLabelCell('title', '', 'link-title') . fInputCell('linkname', $linkname, 1, 30, '', 'link-title')) . tr(fLabelCell('sort_value', '', 'link-sort') . fInputCell('linksort', $linksort, 2, 15, '', 'link-sort')) . tr(fLabelCell('url', 'link_url', 'link-url') . fInputCell('url', $url, 3, 30, '', 'link-url')) . tr(fLabelCell('link_category', 'link_category', 'link-category') . td(linkcategory_popup($category) . ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']')) . tr(tda('<label for="link-description">' . gTxt('description') . '</label>' . sp . popHelp('link_description'), ' style="text-align: right; vertical-align: top;"') . td('<textarea id="link-description" name="description" cols="40" rows="7" tabindex="4">' . htmlspecialchars($description) . '</textarea>')) . pluggable_ui('link_ui', 'extend_detail_form', '', $rs) . tr(td() . td(fInput('submit', '', gTxt('save'), 'publish'))) . endTable() . eInput('link') . ($id ? sInput('link_save') . hInput('id', $id) : sInput('link_post')) . hInput('search_method', gps('search_method')) . hInput('crit', gps('crit')), 'margin-bottom: 25px;');
    echo link_list();
}
Example #26
0
/**
 * Renders expiration date partial.
 *
 * The rendered widget can be customised via the 'article_ui > expires'
 * pluggable UI callback event.
 *
 * @param  array $rs Article data
 * @return string HTML
 */
function article_partial_expires($rs)
{
    extract($rs);
    $out = inputLabel('exp_year', tsi('exp_year', '%Y', $sExpires, '', 'exp_year') . ' <span role="separator">/</span> ' . tsi('exp_month', '%m', $sExpires, '', 'exp_month') . ' <span role="separator">/</span> ' . tsi('exp_day', '%d', $sExpires, '', 'exp_day'), 'expire_date', array('expires', 'instructions_expire_date'), array('class' => 'txp-form-field date expires')) . inputLabel('exp_hour', tsi('exp_hour', '%H', $sExpires, '', 'exp_hour') . ' <span role="separator">:</span> ' . tsi('exp_minute', '%M', $sExpires, '', 'exp_minute') . ' <span role="separator">:</span> ' . tsi('exp_second', '%S', $sExpires, '', 'exp_second'), 'expire_time', array('', 'instructions_expire_time'), array('class' => 'txp-form-field time expires')) . hInput('sExpires', $sExpires);
    return pluggable_ui('article_ui', 'expires', $out, $rs);
}
Example #27
0
function link_edit($message = '')
{
    global $vars, $event, $step, $txp_user;
    pagetop(gTxt('edit_links'), $message);
    echo '<div id="' . $event . '_container" class="txp-container">';
    extract(gpsa($vars));
    $rs = array();
    if ($id && $step == 'link_edit') {
        $id = assert_int($id);
        $rs = safe_row('*', 'txp_link', "id = {$id}");
        if ($rs) {
            extract($rs);
            if (!has_privs('link.edit') && !($author == $txp_user && has_privs('link.edit.own'))) {
                link_list(gTxt('restricted_area'));
                return;
            }
        }
    }
    if ($step == 'link_save' or $step == 'link_post') {
        foreach ($vars as $var) {
            ${$var} = '';
        }
    }
    if (has_privs('link.edit') || has_privs('link.edit.own')) {
        echo '<div class="txp-edit">' . form(startTable('edit', '', 'edit-pane') . tr(fLabelCell('title', '', 'link-title') . fInputCell('linkname', $linkname, 1, 30, '', 'link-title'), ' class="name"') . tr(fLabelCell('sort_value', '', 'link-sort') . fInputCell('linksort', $linksort, 2, 15, '', 'link-sort'), ' class="sort"') . tr(fLabelCell('url', 'link_url', 'link-url') . fInputCell('url', $url, 3, 30, '', 'link-url'), ' class="url"') . tr(fLabelCell('link_category', 'link_category', 'link-category') . td(linkcategory_popup($category) . ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']'), ' class="category"') . tr(tda('<label for="link-description">' . gTxt('description') . '</label>' . sp . popHelp('link_description'), ' style="text-align: right; vertical-align: top;"') . td('<textarea id="link-description" name="description" cols="40" rows="7" tabindex="4">' . htmlspecialchars($description) . '</textarea>'), ' class="description text"') . pluggable_ui('link_ui', 'extend_detail_form', '', $rs) . tr(td() . td(fInput('submit', '', gTxt('save'), 'publish'))) . endTable() . eInput('link') . ($id ? sInput('link_save') . hInput('id', $id) : sInput('link_post')) . hInput('search_method', gps('search_method')) . hInput('crit', gps('crit')), 'margin-bottom: 25px;', '', 'post', 'edit-form', '', 'link_details') . '</div>';
    }
    link_list();
    echo '</div>';
}
Example #28
0
function author_form()
{
    global $step, $txp_user;
    $vars = array('user_id', 'name', 'RealName', 'email', 'privs');
    $rs = array();
    extract(gpsa($vars));
    if ($user_id && $step == 'author_edit') {
        $user_id = assert_int($user_id);
        $rs = safe_row('*', 'txp_users', "user_id = {$user_id}");
        extract($rs);
    }
    if ($step == 'author_save' or $step == 'author_save_new') {
        foreach ($vars as $var) {
            ${$var} = '';
        }
    }
    $caption = gTxt($user_id && $step == 'author_edit' ? 'edit_author' : 'add_new_author');
    return form(hed($caption, 3, ' style="text-align: center;"') . startTable('edit', '', 'edit-pane') . tr(fLabelCell('login_name', '', 'name') . ($user_id && $step == 'author_edit' ? td(strong($name)) : fInputCell('name', $name)), ' class="name login-name"') . tr(fLabelCell('real_name', '', 'RealName') . fInputCell('RealName', $RealName), ' class="name real-name"') . tr(fLabelCell('email', '', 'email') . fInputCell('email', $email), ' class="email"') . tr(fLabelCell('privileges', '', 'privs') . td(($txp_user != $name ? privs($privs) : hInput('privs', $privs) . strong(get_priv_level($privs))) . sp . popHelp('about_privileges')), ' class="privs"') . pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . tr(td() . td(fInput('submit', '', gTxt('save'), 'publish') . ($user_id ? '' : sp . popHelp('add_new_author')))) . endTable() . eInput('admin') . ($user_id ? hInput('user_id', $user_id) . sInput('author_save') : sInput('author_save_new')), '', '', 'post', 'edit-form', '', 'user_edit');
}
Example #29
0
function upload_form($label, $pophelp, $step, $event, $id = '', $max_file_size = '1000000', $label_id = '', $class = 'upload-form')
{
    global $sort, $dir, $page, $search_method, $crit;
    $class = $class ? ' class="' . $class . '"' : '';
    $label_id = $label_id ? $label_id : $event . '-upload';
    $argv = func_get_args();
    return pluggable_ui($event . '_ui', 'upload_form', n . n . '<form' . $class . ' method="post" enctype="multipart/form-data" action="index.php">' . n . '<div>' . (!empty($max_file_size) ? n . hInput('MAX_FILE_SIZE', $max_file_size) : '') . n . eInput($event) . n . sInput($step) . n . hInput('id', $id) . n . hInput('sort', $sort) . n . hInput('dir', $dir) . n . hInput('page', $page) . n . hInput('search_method', $search_method) . n . hInput('crit', $crit) . n . graf('<label for="' . $label_id . '">' . $label . '</label>' . sp . popHelp($pophelp) . sp . fInput('file', 'thefile', '', 'edit', '', '', '', '', $label_id) . sp . fInput('submit', '', gTxt('upload'), 'smallerbox')) . n . '</div>' . n . '</form>', $argv);
}
Example #30
0
function author_edit()
{
    global $step, $txp_user;
    require_privs('admin.edit');
    pagetop(gTxt('tab_site_admin'), '');
    $vars = array('user_id', 'name', 'RealName', 'email', 'privs');
    $rs = array();
    extract(gpsa($vars));
    $is_edit = $user_id && $step == 'author_edit';
    if ($is_edit) {
        $user_id = assert_int($user_id);
        $rs = safe_row('*', 'txp_users', "user_id = {$user_id}");
        extract($rs);
    }
    $caption = gTxt($is_edit ? 'edit_author' : 'add_new_author');
    echo form('<div class="txp-edit">' . n . hed($caption, 2) . n . inputLabel('login_name', $is_edit ? strong($name) : fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), $is_edit ? '' : 'login_name', $is_edit ? '' : 'add_new_author') . n . inputLabel('real_name', fInput('text', 'RealName', $RealName, '', '', '', INPUT_REGULAR, '', 'real_name'), 'real_name') . n . inputLabel('login_email', fInput('text', 'email', $email, '', '', '', INPUT_REGULAR, '', 'login_email'), 'email') . n . inputLabel('privileges', $txp_user != $name ? privs($privs) : hInput('privs', $privs) . strong(get_priv_level($privs)), $is_edit ? '' : 'privileges', 'about_privileges') . n . pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('admin') . ($user_id ? hInput('user_id', $user_id) . sInput('author_save') : sInput('author_save_new')) . '</div>', '', '', 'post', 'edit-form', '', 'user_edit');
}