function display($args, $instance = false) { if (is_array($instance)) { $instance = $instance['number']; } if (!$instance || !is_numeric($instance) || 1 > $instance) { return; } extract($args); $parent_type = $this->options[$instance]['parent'] ? $this->options[$instance]['parent'] : 'all'; $parent_id = pp_is_project() && $parent_type == 'sub' ? pp_get_project_data(0, 'id') : 0; if ($parent_id === false) { return; } $categories = pp_get_projects($parent_id); if (!$categories) { return; } $walker = new Walker_Category(); echo $before_widget; if ($parent_type == 'sub' && $parent_id !== 0) { $title = __('Sub-projects', 'prologue-projects'); } else { $title = __('Projects', 'prologue-projects'); } $title = $this->options[$instance]['title'] ? $this->options[$instance]['title'] : $title; echo $before_title; echo $title; echo $after_title; echo '<ul>'; echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, array('style' => 'list'))); echo '</ul>'; echo $after_widget; }
function pp_admin_projects() { global $user_identity; $title = __('Edit Projects', 'prologue-projects'); if (!($project_category_id = pp_get_category_id('projects'))) { ?> <div class="wrap nosubsub"> <?php screen_icon(); ?> <h2> <?php echo wp_specialchars($title); ?> </h2> <div id="message" class="updated"><p><?php _e('You must <a href="admin.php?page=prologue-projects-settings">assign an existing category</a> as the container for all projects.', 'prologue-projects'); ?> </p></div> </div> <?php return; } global $action; wp_reset_vars(array('action')); if (isset($_GET['action']) && isset($_GET['delete']) && ('delete' == $_GET['action'] || 'delete' == $_GET['action2'])) { $action = 'bulk-delete'; } switch ($action) { case 'addproject': check_admin_referer('add-project'); if (!current_user_can('manage_categories')) { wp_die(__('Cheatin’ uh?', 'prologue-projects')); } if (pp_insert_project($_POST)) { wp_redirect('admin.php?page=prologue-projects&message=1#addproject'); } else { wp_redirect('admin.php?page=prologue-projects&message=4#addproject'); } exit; break; case 'delete': $project_ID = (int) $_GET['project_ID']; check_admin_referer('delete-project_' . $project_ID); if (!current_user_can('manage_categories')) { wp_die(__('Cheatin’ uh?', 'prologue-projects')); } $project_name = get_catname($project_ID); // Don't delete the default cats. if ($project_ID == get_option('default_category')) { wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one", 'prologue-projects'), $cat_name)); } pp_delete_project($project_ID); wp_redirect('admin.php?page=prologue-projects&message=2'); exit; break; case 'bulk-delete': check_admin_referer('bulk-projects'); echo 1; if (!current_user_can('manage_categories')) { wp_die(__('You are not allowed to delete projects.', 'prologue-projects')); } foreach ((array) $_GET['delete'] as $project_ID) { $project_name = get_catname($project_ID); // Don't delete the default cats. if ($project_ID == get_option('default_category')) { wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one", 'prologue-projects'), $cat_name)); } pp_delete_project($project_ID); } $sendback = wp_get_referer(); wp_redirect($sendback); exit; break; case 'edit': if (!current_user_can('manage_categories')) { wp_die(__('You are not allowed to edit projects.', 'prologue-projects')); } $title = __('Edit Project', 'prologue-projects'); require_once 'admin-header.php'; $project_ID = (int) $_GET['project_ID']; $project = pp_get_project_data($project_ID, 'all', 'editing'); ?> <div class="wrap nosubsub"> <?php screen_icon(); ?> <h2><?php echo wp_specialchars($title); ?> </h2> <?php if (isset($_GET['message']) && ($msg = (int) $_GET['message'])) { ?> <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?> </p></div> <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); } ?> <div class="wrap"> <div id="ajax-response"></div> <form name="addproject" id="editproject" method="post" action="admin.php?page=prologue-projects" class="validate"> <input type="hidden" name="action" value="editedproject" /> <input type="hidden" name="project_ID" value="<?php echo $project['id']; ?> " /> <?php wp_original_referer_field(true, 'previous'); ?> <?php wp_nonce_field('update-project_' . $project['id']); ?> <table class="form-table"> <tr class="form-field form-required"> <th scope="row" valign="top"><label for="project_name"><?php _e('Project Name', 'prologue-projects'); ?> </label></th> <td><input name="project_name" id="project_name" type="text" value="<?php echo attribute_escape($project['name']); ?> " size="40" aria-required="true" /><br /> <span class="setting-description"><?php _e('The name is used to identify the project almost everywhere, for example under the post or in the project widgets.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_nicename"><?php _e('Project Slug', 'prologue-projects'); ?> </label></th> <td><input name="project_nicename" id="project_nicename" type="text" value="<?php echo attribute_escape($project['slug']); ?> " size="40" /><br /> <span class="setting-description"><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_parent"><?php _e('Project Parent', 'prologue-projects'); ?> </label></th> <td><?php wp_dropdown_categories(array('child_of' => $project_category_id, 'hide_empty' => 0, 'name' => 'project_parent', 'orderby' => 'name', 'selected' => $project['parent_id'], 'hierarchical' => true, 'show_option_none' => __('None', 'prologue-projects'))); ?> <br /> <span class="setting-description"><?php _e('Projects, can have a hierarchy. You might have an event project, and under that have sub-projects for catering and merchandise. Totally optional.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_description"><?php _e('Description', 'prologue-projects'); ?> </label></th> <td><textarea name="project_description" id="project_description" rows="5" cols="40"><?php echo wp_specialchars($project['description']); ?> </textarea><br /> <span class="setting-description"><?php _e('The description is displayed on each project page.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_logo"><?php _e('Project Logo', 'prologue-projects'); ?> </label></th> <td><input name="project_logo" id="project_logo" type="text" value="<?php echo attribute_escape($project['logo']); ?> " size="255" /><br /> <span class="setting-description"><?php _e('The project\'s logo. Must be a full URL of an image. Maximum size of 64px x 64px is recommended.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_website"><?php _e('Project Website', 'prologue-projects'); ?> </label></th> <td><input name="project_website" id="project_website" type="text" value="<?php echo attribute_escape($project['website']); ?> " size="255" /><br /> <span class="setting-description"><?php _e('The project\'s external website. Must be a full URL.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_blog"><?php _e('Project Blog', 'prologue-projects'); ?> </label></th> <td><input name="project_blog" id="project_blog" type="text" value="<?php echo attribute_escape($project['blog']); ?> " size="255" /><br /> <span class="setting-description"><?php _e('The project\'s external blog. Must be a full URL.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_svn"><?php _e('Project Subversion Repository', 'prologue-projects'); ?> </label></th> <td><input name="project_svn" id="project_svn" type="text" value="<?php echo attribute_escape($project['svn']); ?> " size="255" /><br /> <span class="setting-description"><?php _e('The location of the project\'s Subversion repository. This is only common in software projects.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_trac"><?php _e('Project Trac Installation', 'prologue-projects'); ?> </label></th> <td><input name="project_trac" id="project_trac" type="text" value="<?php echo attribute_escape($project['trac']); ?> " size="255" /><br /> <span class="setting-description"><?php _e('The location of the project\'s Trac ticketing website. This is only common in software projects.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_intertrac"><?php _e('Project InterTrac Code', 'prologue-projects'); ?> </label></th> <td><input name="project_intertrac" id="project_intertrac" type="text" value="<?php echo attribute_escape($project['intertrac']); ?> " size="255" /><br /> <span class="setting-description"><?php _e('This code allows users to distinguish between different Trac installations in the same update. This is only common in software projects.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_activity"><?php _e('Project Activity Feeds', 'prologue-projects'); ?> </label></th> <td><textarea name="project_activity" id="project_activity" rows="5" cols="40"><?php echo wp_specialchars(join("\n", stripslashes_deep($project['activity']))); ?> </textarea><br /> <span class="setting-description"><?php _e('Specify a list of feeds you wish to aggregate into the projects "activity" sidebar. One feed per line. Activity reported by Trac is automatically included here.', 'prologue-projects'); ?> </span></td> </tr> <tr class="form-field"> <th scope="row" valign="top"><label for="project_overheard"><?php _e('Project Overheard Feeds', 'prologue-projects'); ?> </label></th> <td><textarea name="project_overheard" id="project_overheard" rows="5" cols="40"><?php echo wp_specialchars(join("\n", stripslashes_deep($project['overheard']))); ?> </textarea><br /> <span class="setting-description"><?php _e('Specify a list of feeds you wish to aggregate into the projects "overheard" sidebar. One feed per line.', 'prologue-projects'); ?> </span></td> </tr> </table> <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Update Project', 'prologue-projects'); ?> " /></p> </form> </div><!-- /wrap --> <?php break; case 'editedproject': $project_ID = (int) $_POST['project_ID']; check_admin_referer('update-project_' . $project_ID); if (!current_user_can('manage_categories')) { wp_die(__('Cheatin’ uh?', 'prologue-projects')); } $location = 'admin.php?page=prologue-projects'; if ($referer = wp_get_original_referer()) { if (false !== strpos($referer, 'admin.php')) { $location = $referer; } } if (pp_update_project($_POST)) { $location = add_query_arg('message', 3, $location); } else { $location = add_query_arg('message', 5, $location); } wp_redirect($location); exit; break; default: if (isset($_GET['_wp_http_referer']) && !empty($_GET['_wp_http_referer'])) { wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']))); exit; } require_once 'admin-header.php'; $messages[1] = __('Project added.', 'prologue-projects'); $messages[2] = __('Project deleted.', 'prologue-projects'); $messages[3] = __('Project updated.', 'prologue-projects'); $messages[4] = __('Project not added.', 'prologue-projects'); $messages[5] = __('Project not updated.', 'prologue-projects'); ?> <div class="wrap nosubsub"> <?php screen_icon(); ?> <h2> <?php echo wp_specialchars($title); if (isset($_GET['s']) && $_GET['s']) { printf('<span class="subtitle">' . __('Search results for “%s”', 'prologue-projects') . '</span>', wp_specialchars(stripslashes($_GET['s']))); } ?> </h2> <?php if (isset($_GET['message']) && ($msg = (int) $_GET['message'])) { ?> <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?> </p></div> <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); } ?> <form class="search-form topmargin" action="" method="get"> <p class="search-box"> <label class="hidden" for="project-search-input"><?php _e('Search Projects', 'prologue-projects'); ?> :</label> <input type="text" class="search-input" id="project-search-input" name="s" value="<?php _admin_search_query(); ?> " /> <input type="hidden" name="page" value="prologue-projects" /> <input type="submit" value="<?php _e('Search Projects', 'prologue-projects'); ?> " class="button" /> </p> </form><br class="clear" /> <div id="col-container"> <div id="col-right"> <div class="col-wrap"> <form id="posts-filter" action="" method="get"> <input type="hidden" name="page" value="prologue-projects" /> <div class="tablenav"> <?php $pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 0; if (empty($pagenum)) { $pagenum = 1; } if (!isset($projectsperpage) || $projectsperpage < 0) { $projectsperpage = 20; } $projectstotal = count(pp_get_projects()); $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'prev_text' => __('«', 'prologue-projects'), 'next_text' => __('»', 'prologue-projects'), 'total' => ceil($projectstotal / $projectsperpage), 'current' => $pagenum)); if ($page_links) { ?> <div class="tablenav-pages"><?php echo $page_links; ?> </div> <?php } ?> <div class="alignleft actions"> <select name="action"> <option value="" selected="selected"><?php _e('Bulk Actions', 'prologue-projects'); ?> </option> <option value="delete"><?php _e('Delete', 'prologue-projects'); ?> </option> </select> <input type="submit" value="<?php _e('Apply', 'prologue-projects'); ?> " name="doaction" id="doaction" class="button-secondary action" /> <?php wp_nonce_field('bulk-projects'); ?> </div> <br class="clear" /> </div> <div class="clear"></div> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <?php print_column_headers('projects'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('projects', false); ?> </tr> </tfoot> <tbody id="the-list" class="list:projects"> <?php pp_project_rows($project_category_id, 0, 0, $pagenum, $projectsperpage); ?> </tbody> </table> <div class="tablenav"> <?php if ($page_links) { ?> <div class="tablenav-pages"><?php echo $page_links; ?> </div> <?php } ?> <div class="alignleft actions"> <select name="action2"> <option value="" selected="selected"><?php _e('Bulk Actions', 'prologue-projects'); ?> </option> <option value="delete"><?php _e('Delete', 'prologue-projects'); ?> </option> </select> <input type="submit" value="<?php _e('Apply', 'prologue-projects'); ?> " name="doaction2" id="doaction2" class="button-secondary action" /> <?php wp_nonce_field('bulk-projects'); ?> </div> <br class="clear" /> </div> </form> <div class="form-wrap"> <p><?php _e('<strong>Note:</strong><br />Deleting a project does not delete the posts in that project.', 'prologue-projects'); ?> </p> </div> </div> </div><!-- /col-right --> <div id="col-left"> <div class="col-wrap"> <?php if (current_user_can('manage_categories')) { ?> <div class="form-wrap"> <h3><?php _e('Add Project', 'prologue-projects'); ?> </h3> <div id="ajax-response"></div> <form name="addproject" id="addproject" method="post" action="admin.php?page=prologue-projects" class="add:the-list: validate"> <input type="hidden" name="action" value="addproject" /> <?php wp_original_referer_field(true, 'previous'); ?> <?php wp_nonce_field('add-project'); ?> <div class="form-field form-required"> <label for="project_name"><?php _e('Project Name', 'prologue-projects'); ?> </label> <input name="project_name" id="project_name" type="text" value="" size="40" aria-required="true" /> <p><?php _e('The name is used to identify the project almost everywhere, for example under the post or in the project widgets.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_nicename"><?php _e('Project Slug', 'prologue-projects'); ?> </label> <input name="project_nicename" id="project_nicename" type="text" value="" size="40" /> <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_parent"><?php _e('Project Parent', 'prologue-projects'); ?> </label> <?php wp_dropdown_categories(array('child_of' => $project_category_id, 'hide_empty' => 0, 'name' => 'project_parent', 'orderby' => 'name', 'selected' => 0, 'hierarchical' => true, 'show_option_none' => __('None', 'prologue-projects'))); ?> <p><?php _e('Projects, can have a hierarchy. You might have an event project, and under that have sub-projects for catering and merchandise. Totally optional.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_description"><?php _e('Description', 'prologue-projects'); ?> </label> <textarea name="project_description" id="project_description" rows="5" cols="40"></textarea> <p><?php _e('The description is displayed on each project page.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_logo"><?php _e('Project Logo', 'prologue-projects'); ?> </label> <input name="project_logo" id="project_logo" type="text" value="" size="255" /> <p><?php _e('The project\'s logo. Must be a full URL of an image. Maximum size of 64px x 64px is recommended.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_website"><?php _e('Project Website', 'prologue-projects'); ?> </label> <input name="project_website" id="project_website" type="text" value="" size="255" /> <p><?php _e('The project\'s external website. Must be a full URL.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_blog"><?php _e('Project Blog', 'prologue-projects'); ?> </label> <input name="project_blog" id="project_blog" type="text" value="" size="255" /> <p><?php _e('The project\'s external blog. Must be a full URL.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_svn"><?php _e('Project Subversion Repository', 'prologue-projects'); ?> </label> <input name="project_svn" id="project_svn" type="text" value="" size="255" /> <p><?php _e('The location of the project\'s Subversion repository. This is only common in software projects.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_trac"><?php _e('Project Trac Installation', 'prologue-projects'); ?> </label> <input name="project_trac" id="project_trac" type="text" value="" size="255" /> <p><?php _e('The location of the project\'s Trac ticketing website. This is only common in software projects.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_intertrac"><?php _e('Project InterTrac Code', 'prologue-projects'); ?> </label> <input name="project_intertrac" id="project_intertrac" type="text" value="" size="255" /> <p><?php _e('This code allows users to distinguish between different Trac installations in the same update. This is only common in software projects.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_activity"><?php _e('Project Activity Feeds', 'prologue-projects'); ?> </label> <textarea name="project_activity" id="project_activity" rows="5" cols="40"></textarea> <p><?php _e('Specify a list of feeds you wish to aggregate into the projects "activity" sidebar. One feed per line. Activity reported by Trac is automatically included here.', 'prologue-projects'); ?> </p> </div> <div class="form-field"> <label for="project_overheard"><?php _e('Project Overheard Feeds', 'prologue-projects'); ?> </label> <textarea name="project_overheard" id="project_overheard" rows="5" cols="40"></textarea> <p><?php _e('Specify a list of feeds you wish to aggregate into the projects "overheard" sidebar. One feed per line.', 'prologue-projects'); ?> </p> </div> <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Project', 'prologue-projects'); ?> " /></p> </form> </div> <?php } ?> </div> </div><!-- /col-left --> </div><!-- /col-container --> </div><!-- /wrap --> <script type="text/javascript"> /* <![CDATA[ */ (function($){ $(document).ready(function(){ $('#doaction, #doaction2').click(function(){ if ( $('select[name^="action"]').val() == 'delete' ) { var m = '<?php echo js_escape(__("You are about to delete the selected projects.\n 'Cancel' to stop, 'OK' to delete.", 'prologue-projects')); ?> '; return showNotice.warn(m); } }); }); })(jQuery); /* ]]> */ </script> <?php break; } }
function pp_project_and_role_checklist($user_id = 0, $checked = false, $input_name = 'post_category') { $categories = pp_get_projects(); $walker = new PP_Walker_Category_Checklist(); $args = array(); if ($checked) { $checked = (array) $checked; $args['selected_cats'] = $checked; } else { $args['selected_cats'] = array(absint(get_query_var('cat'))); } if (!$input_name) { $input_name = 'post_category'; } $args['input_name'] = $input_name; global $blog_id; $args['user_project_role'] = get_usermeta($user_id, 'prologue_projects_' . $blog_id); $args['user_project_role'] = $args['user_project_role'] ? $args['user_project_role'] : array(); echo '<ul class="pp-update-categories">'; echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); echo '</ul>'; }