Пример #1
0
function categorySelectInput($type, $name, $val, $id, $onchange = 0, $parent_id = NULL)
{
    $rs = tree_get('txp_category', $parent_id, "parent > 0 and type='" . doSlash($type) . "'");
    if ($rs) {
        return treeSelectInput($name, $rs, $val, $id, $onchange, 1, 'name');
    }
    return false;
}
Пример #2
0
 function edit_view($id = '')
 {
     global $txpcfg, $img_dir, $file_max_upload_size;
     $out = array();
     if (!$id) {
         $id = assert_int(gps('id'));
     }
     extract($this->context);
     $categories = tree_get('txp_category', NULL, "type='image'");
     $rs = safe_row("*", "txp_image", "id = {$id}");
     if ($rs) {
         extract($rs);
         if ($ext != '.swf') {
             $img = '<img src="' . hu . $img_dir . '/' . $id . $ext . '" height="' . $h . '" width="' . $w . '" alt="" "title="' . $id . $ext . ' (' . $w . ' &#215; ' . $h . ')" />';
         } else {
             $img = '';
         }
         if ($thumbnail and $ext != '.swf') {
             $thumb = '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . '" alt="" />';
         } else {
             $thumb = '';
         }
         $out[] = startTable('edit') . tr(td($img . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'replace', $this->event, $id, $file_max_upload_size, 'image-replace', ''))) . tr(td(join('', array($thumbnail ? $thumb . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', $this->event, $id, $file_max_upload_size, 'upload-thumbnail', '')))));
         $out[] = check_gd($ext) ? $this->thumb_ui($id, $thumbnail) : '';
         $out[] = tr(td(form(graf('<label for="image-name">' . gTxt('image_name') . '</label>' . br . fInput('text', 'name', $name, 'edit', '', '', '', '', 'image-name')) . graf('<label for="image-category">' . gTxt('image_category') . '</label>' . br . categorySelectInput('image', 'category', $category, 'image-category')) . graf('<label for="alt-text">' . gTxt('alt_text') . '</label>' . br . fInput('text', 'alt', $alt, 'edit', '', '', 50, '', 'alt-text')) . graf('<label for="caption">' . gTxt('caption') . '</label>' . br . text_area('caption', '100', '400', $caption, 'caption')) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . n . hInput('id', $id) . n . eInput($this->event) . n . sInput('save') . n . hInput('sort', $sort) . n . hInput('dir', $dir) . n . hInput('page', $page) . n . hInput('search_method', $search_method) . n . hInput('crit', $crit)))) . endTable();
     }
     return join('', $out);
 }
Пример #3
0
?>
');
	}

<?php 
if ($event == 'list') {
    $sarr = array("\n", '-');
    $rarr = array('', '&#45;');
    $sections = '';
    $rs = safe_column('name', 'txp_section', "name != 'default'");
    if ($rs) {
        $sections = str_replace($sarr, $rarr, addslashes(selectInput('Section', $rs, '', true)));
    }
    $category1 = '';
    $category2 = '';
    $rs = tree_get('txp_category', NULL, "type='article'");
    if ($rs) {
        $category1 = str_replace($sarr, $rarr, addslashes(treeSelectInput('Category1', $rs, '')));
        $category2 = str_replace($sarr, $rarr, addslashes(treeSelectInput('Category2', $rs, '')));
    }
    $statuses = str_replace($sarr, $rarr, addslashes(selectInput('Status', array(1 => gTxt('draft'), 2 => gTxt('hidden'), 3 => gTxt('pending'), 4 => gTxt('live'), 5 => gTxt('sticky')), '', true)));
    $comments_annotate = addslashes(onoffRadio('Annotate', safe_field('val', 'txp_prefs', "name = 'comments_on_default'")));
    $authors = '';
    $rs = safe_column('name', 'txp_users', "privs not in(0,6)");
    if ($rs) {
        $authors = str_replace($sarr, $rarr, addslashes(selectInput('AuthorID', $rs, '', true)));
    }
    ?>

	function poweredit(elm)
	{
Пример #4
0
 function category_list($type)
 {
     $out = n . n . hed(gTxt($type . '_head') . sp . popHelp($type . '_category'), 3) . form(fInput('text', 'title', '', 'edit', '', '', 20) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('category') . sInput('create') . hInput('type', $type));
     $rs = tree_get('txp_category', NULL, "parent != 0 and type='" . doSlash($type) . "'");
     if ($rs) {
         $total_count = array();
         if ($type == 'article') {
             $rs2 = safe_rows_start('Category1, count(*) as num', 'textpattern', "1 = 1 group by Category1");
             while ($a = nextRow($rs2)) {
                 $name = $a['Category1'];
                 $num = $a['num'];
                 $total_count[$name] = $num;
             }
             $rs2 = safe_rows_start('Category2, count(*) as num', 'textpattern', "1 = 1 group by Category2");
             while ($a = nextRow($rs2)) {
                 $name = $a['Category2'];
                 $num = $a['num'];
                 if (isset($total_count[$name])) {
                     $total_count[$name] += $num;
                 } else {
                     $total_count[$name] = $num;
                 }
             }
         } else {
             if ($type == 'link') {
                 $rs2 = safe_rows_start('category, count(*) as num', 'txp_link', "1 group by category");
             } elseif ($type == 'image') {
                 $rs2 = safe_rows_start('category, count(*) as num', 'txp_image', "1 group by category");
             } elseif ($type == 'file') {
                 $rs2 = safe_rows_start('category, count(*) as num', 'txp_file', "1 group by category");
             }
             if (!empty($rs2)) {
                 while ($a = nextRow($rs2)) {
                     $name = $a['category'];
                     $num = $a['num'];
                     $total_count[$name] = $num;
                 }
             }
         }
         $items = array();
         foreach ($rs as $a) {
             extract($a);
             if ($type == 'article') {
                 $url = 'index.php?event=list' . a . 'search_method=categories' . a . 'crit=' . $name;
             } elseif ($type == 'link') {
                 $url = 'index.php?event=link' . a . 'search_method=category' . a . 'crit=' . $name;
             } elseif ($type == 'image') {
                 $url = 'index.php?event=image' . a . 'search_method=category' . a . 'crit=' . $name;
             } elseif ($type == 'file') {
                 $url = 'index.php?event=file' . a . 'search_method=category' . a . 'crit=' . $name;
             } else {
                 $url = '';
             }
             $count = '';
             if ($url) {
                 $count = isset($total_count[$name]) ? '(' . href($total_count[$name], $url) . ')' : '(0)';
             }
             if (empty($title)) {
                 $edit_link = '<em>' . eLink('category', 'edit', 'id', $id, gTxt('untitled'), 'type', $type) . '</em>';
             } else {
                 $edit_link = eLink('category', 'edit', 'id', $id, $title, 'type', $type);
             }
             $items[] = graf(checkbox('selected[]', $id, 0) . sp . str_repeat(sp . sp, $level * 2) . $edit_link . sp . small($count));
         }
         if ($items) {
             $out .= $this->multiedit_form($type, $items);
         }
     } else {
         $out .= graf(gTxt('no_categories_exist'));
     }
     return $out;
 }
Пример #5
0
function file_category_pop($val)
{
    $vals = tree_get('txp_category', NULL, "type='file'");
    if ($vals) {
        return ' ' . treeSelectInput('category', $vals, $val);
    }
    return gTxt('no_categories_available');
}
Пример #6
0
function section_resolve_inheritance($root)
{
    // trickle settings down to the specified node and any children
    // that have inherit set to 1
    // there's probably a more efficient way to do this
    $children = tree_get('txp_section', $root, "inherit='1'");
    foreach ($children as $child) {
        $ancestor = section_inherit($child['parent']);
        $rec = array('page' => $ancestor['page'], 'css' => $ancestor['css'], 'in_rss' => $ancestor['in_rss'], 'on_frontpage' => $ancestor['on_frontpage'], 'searchable' => $ancestor['searchable']);
        safe_update_rec('txp_section', $rec, "id='" . doSlash($child['id']) . "'");
    }
}
Пример #7
0
 function edit_view($id = '')
 {
     global $txpcfg, $file_base_path, $levels;
     extract(gpsa(array('name', 'category', 'permissions', 'description', 'sort', 'dir', 'page', 'crit', 'method', 'publish_now')));
     if (!$id) {
         $id = gps('id');
     }
     $categories = tree_get('txp_category', NULL, "type='file'");
     $rs = safe_row('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', "id = '{$id}'");
     if ($rs) {
         extract($rs);
         if ($permissions == '') {
             $permissions = '-1';
         }
         $file_exists = file_exists(build_file_path($file_base_path, $filename));
         $existing_files = $this->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 ? $this->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 = '';
         #categorySelectInput($type, $name, $val, $id
         $form = tr(td(form(graf(gTxt('file_category') . br . categorySelectInput('file', 'category', $category, 'file_category')) . graf(gTxt('filename') . br . fInput('text', 'filename', $filename, 'edit')) . graf(gTxt('description') . br . text_area('description', '100', '400', $description)) . fieldset(radio_list('status', $this->file_statuses(), $status, 4), gTxt('status'), 'file-status') . fieldset($created, gTxt('timestamp'), 'file-created') . graf(fInput('submit', '', gTxt('save'))) . eInput($this->event) . sInput('save') . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('method', $method))));
         echo startTable('list'), tr(td(graf(gTxt('file_status') . br . $condition) . graf(gTxt('file_name') . br . $downloadlink) . graf(gTxt('file_download_count') . br . $downloads))), $form, tr(td($this->file_upload_form(gTxt('file_replace'), 'file_replace', 'new_replace', $id))), endTable();
     }
 }