/** * form_article_tab * * * * * * */ function form_article_tab($article_data) { // link outout if (isset($article_data['link'])) { $link = '<p><span class="note">' . $article_data['link'] . '</span></p>'; } else { $link = ''; } // authors if (empty($_SESSION[WW_SESS]['guest']) || $_SESSION[WW_SESS]['level'] == 'editor') { $author_list = get_authors_admin(); $author_select = ' <select name="author_id" title="select author"> '; foreach ($author_list as $author) { $a_selected = $article_data['author_id'] == $author['id'] ? ' selected="selected"' : ''; $author_select .= ' <option value="' . $author['id'] . '"' . $a_selected . '>' . $author['title'] . '</option> '; } $author_select .= ' </select>'; } else { $author_select = ' <input type="hidden" name="author_id" value="' . $_SESSION[WW_SESS]['user_id'] . '"/> <input type="text" name="author_name" value="' . $_SESSION[WW_SESS]['name'] . '" readonly="readonly"/>'; } // categories $category_list = get_categories_admin(); $category_select = ' <select name="category_id"> '; foreach ($category_list as $category) { $c_selected = $article_data['category_id'] == $category['id'] ? ' selected="selected"' : ''; $category_select .= ' <option value="' . $category['id'] . '"' . $c_selected . '>' . $category['title'] . '</option> '; // nested items if (isset($category['child'])) { foreach ($category['child'] as $child) { $c_ch_selected = $article_data['category_id'] == $child['id'] ? ' selected="selected"' : ''; $category_select .= ' <option value="' . $child['id'] . '"' . $c_ch_selected . '> ... ' . $child['title'] . '</option> '; } } // end nested items } $category_select .= ' </select>'; // tags $tag_checkboxes = ''; $tags_list = get_tags_admin(); foreach ($tags_list as $tag_id => $tag) { $tag_checked = isset($article_data['tags']) && in_array($tag_id, $article_data['tags']) ? ' checked="checked"' : ''; $tag_checkboxes .= ' <li> <label for="tags[' . $tag_id . ']"> <input type="checkbox" id="tags[' . $tag_id . ']" name="tags[' . $tag_id . ']" value="' . $tag_id . '"' . $tag_checked . '/>' . $tag['title'] . ' </label> </li>'; } // build form $html = ' <div id="tab_article"> ' . $link . ' <p> <label for="title">Title</label> <input type="text" name="title" title="type article title" value="' . $article_data['title'] . '" /> </p> <p> <label for="summary">Summary/Intro</label> <textarea name="summary" id="summary" title="type article summary" cols="40" rows="4">' . $article_data['summary'] . '</textarea> </p> <p> <label for="body">Article</label> <textarea name="body" id="body" cols="40" rows="3">' . htmlentities(stripslashes($article_data['body'])) . '</textarea> </p> <p> <label for="author_id">Author</label> ' . $author_select . ' </p> <p> <label for="category_id">Category</label> ' . $category_select . ' <span class="note">or type in a new category below</span> <input type="text" name="category_new" id="category_new" class="unlabelled"/> </p> <p> <label for="tags">Tags</label> </p> <ul id="tags" class="checkbox_list"> ' . $tag_checkboxes . ' </ul> <p> <span class="note">or type in a new tag below (separate with commas)</span> <input type="text" name="tag_new" id="tag_new" class="unlabelled"/> </p> '; // show date and time dropdowns - only for draft and postdated articles if ($article_data['status'] == 'D' || strtotime($article_data['date_uploaded']) > time()) { $html .= form_insert_date_fields($article_data); } else { // show publish date in hidden field $html .= ' <input type="hidden" name="date_uploaded" value="' . $article_data['date_uploaded'] . '"/>'; } // status options - only available non-draft articles if ($article_data['status'] != 'D') { $a_selected = $article_data['status'] == 'A' ? ' selected="selected"' : ''; $p_selected = $article_data['status'] == 'P' ? ' selected="selected"' : ''; $w_selected = $article_data['status'] == 'W' ? ' selected="selected"' : ''; $html .= ' <p> <label for="status">Status</label> <select name="status"> <option value="P"' . $p_selected . '>Published</option> <option value="A"' . $a_selected . '>Archived</option> <option value="W"' . $w_selected . '>Withdrawn</option> </select> </p> '; } // option to update url version of post title if (!empty($article_data['url'])) { $pre_checked = $article_data['status'] == 'D' ? ' checked="checked"' : ''; $html .= ' <p> <label for="url">URL title</label> <input type="text" name="url" value="' . $article_data['url'] . '" readonly="readonly"/> <span class="note"> <input type="checkbox" name="update_url" value="1"' . $pre_checked . '/> tick here if you want the url-friendly version of the post title updated<br />(note that this will change the permanent url for your article) </span> </p>'; } $html .= '</div>'; return $html; }
$status = ' postdated'; } // other statuses if (isset($_GET['status'])) { $status_list = define_article_status(); $status = ' ' . $status_list[$_GET['status']]; } // any content generation $left_header = $total_articles . ' articles found'; $right_header = '<a href="' . $_SERVER["PHP_SELF"] . '?page_name=write">/Write a new article</a>'; $page_header = show_page_header($left_header, $right_header); // get aside content // any functions $status_list = get_articles_stats(1); $author_list = get_authors_admin(1); $category_list = get_categories_admin(1); $tags_list = get_tags_admin(1); // any content generation // output main content - into $main_content variable $main_content = $page_header; $main_content .= '<h4>Showing all' . $status . ' articles' . implode(', ', $title_text) . '</h4>'; $main_content .= build_admin_article_listing($articles); if ($total_articles > $per_page) { $main_content .= show_admin_listing_nav($total_pages, $per_page); } // output aside content - into $aside_content variable $aside_content = '<h4>Filter articles</h4>'; $aside_content .= '<p><a href="' . $_SERVER["PHP_SELF"] . '?page_name=articles">show all articles</a></p>'; $aside_content .= build_snippet('Status', $status_list); $aside_content .= build_snippet('Authors', $author_list); $aside_content .= build_snippet('Categories', $category_list);
$category_id = (int) $_GET['category_id']; $delete_status = delete_category($category_id); if ($delete_status === true) { $reload = $_SERVER["PHP_SELF"] . '?page_name=categories'; header('Location: ' . $reload); } else { $error = $delete_status; } } // cancel delete tag if (isset($_POST['cancel_delete_category']) && $_POST['cancel_delete_category'] == 'No') { $category_id = (int) $_GET['category_id']; header('Location: ' . $_SERVER["PHP_SELF"] . '?page_name=categories&category_id=' . $category_id); } // category list $categories_list = get_categories_admin(); // get main content $category_id = isset($_GET['category_id']) ? (int) $_GET['category_id'] : 0; // parent category list for select box $parent_select = array(); foreach ($categories_list as $parent) { if (!empty($parent['category_id'])) { continue; } else { $parent_select[$parent['id']] = $parent['title']; } } // if no category selected if (empty($category_id)) { $left_text = 'Categories'; $right_text = '';