/** * CONFIG PACKAGE for Associated Content */ public function package_associated_content() { $this->table_conf = array('form_id' => 'assoc_content_form', 'form_method' => 'get', 'list_id' => 'pagetable', 'record_slug' => 'assoc_cont_rec', 'bulk' => 'false', 'no_records' => __('No content is attached to this group.', 'contexture-page-security')); $this->bulk_conf = array(); // Indexed array. Each entry is an assoc array. All values required. $this->column_conf = array(array('title' => __('Title', 'contexture-page-security'), 'slug' => 'title', 'class' => 'col-first', 'width' => ''), array('title' => '', 'slug' => 'protected', 'class' => '', 'width' => '50px'), array('title' => __('Type', 'contexture-page-security'), 'slug' => 'type', 'class' => 'col-last', 'width' => '100px')); // Indexed array. Each entry is an associative array. All values required. $this->actions_conf = array(array('title' => __('Edit', 'contexture-page-security'), 'tip' => __('Edit this content.', 'contexture-page-security'), 'slug' => 'edit', 'color' => ''), array('title' => __('Remove', 'contexture-page-security'), 'tip' => __('Detach this group from the content.', 'contexture-page-security'), 'slug' => 'trash', 'color' => 'red'), array('title' => __('View', 'contexture-page-security'), 'tip' => __('View this content on the website.', 'contexture-page-security'), 'slug' => 'view', 'color' => '')); //****** GET & SHOW TERMS ************************************************** $termlist = CTXPS_Queries::get_content_by_group($_GET['groupid'], 'term'); //wp_die('<pre>'.print_r($termlist,true).'</pre>'); foreach ($termlist as $term) { $archiveurl = get_term_link(get_term($term->term_id, $term->taxonomy)); $term_edit_url = admin_url('edit-tags.php?action=edit&taxonomy=' . $term->taxonomy . '&tag_ID=' . $term->term_id); $this->list_data[] = array('id' => $term->sec_protect_id, 'columns' => array('title' => sprintf('<strong><a href="%s">%s</a></strong>', $term_edit_url, $term->name), 'protected' => '', 'type' => 'term'), 'actions' => array('edit' => $term_edit_url, 'trash' => array('onclick' => sprintf('CTXPS_Ajax.removeTermFromGroup(%1$s,jQuery(this));return false;', $term->sec_protect_id)), 'view' => !is_wp_error($archiveurl) ? $archiveurl : '')); } unset($termlist, $term); //****** GET & SHOW POSTS ************************************************* $pagelist = CTXPS_Queries::get_content_by_group($_GET['groupid'], 'post'); foreach ($pagelist as $page) { $page_title = $page->post_title; $this->list_data[] = array('id' => $page->sec_protect_id, 'columns' => array('title' => sprintf('<strong><a href="%s">%s</a></strong>', admin_url('post.php?post=' . $page->sec_protect_id . '&action=edit'), $page_title), 'protected' => '', 'type' => $page->post_type), 'actions' => array('edit' => admin_url('post.php?post=' . $page->sec_protect_id . '&action=edit'), 'trash' => array('onclick' => sprintf('CTXPS_Ajax.removePageFromGroup(%1$s,jQuery(this));return false;', $page->sec_protect_id)), 'view' => get_permalink($page->ID))); } unset($pagelist, $page); }
/** * Renders a list of pages protected by the specified group. This returns only the * inner HTML of the <tbody> element, as tbody should be already entered on the page. * * TODO: Rebuild this using CTX_Tables. * * @global wpdb $wpdb * * @param int $group_id The id of the group we need a member list for. * @return string Html to go inside tbody. */ public static function render_content_by_group_list($group_id) { global $wpdb; $pagelist = CTXPS_Queries::get_content_by_group($group_id); if (count($pagelist) === 0) { return sprintf('<td colspan="3">%s</td>', __('No content is attached to this group.', 'contexture-page-security')); } $html = ''; $countpages = ''; $alternatecss = ' class="alternate" '; /**TODO: Must detect if this page is directly protected, or inherrited.*/ foreach ($pagelist as $page) { $page_title = $page->post_title; $html .= sprintf(' <tr id="page-%1$s" %2$s> <td class="post-title page-title column-title"> <strong><a href="%3$s">%4$s</a></strong> <div class="row-actions"> <span class="edit"><a href="%8$spost.php?post=%1$s&action=edit" title="Edit this page">' . __('Edit', 'contexture-page-security') . '</a> | </span> <span class="trash"><a id="remcontent-%1$s" onclick="CTXPS_Ajax.removePageFromGroup(%1$s,jQuery(this))" title="Remove this group from the content">' . __('Remove', 'contexture-page-security') . '</a> | </span> <span class="view"><a href="%7$s" title="View the page">' . __('View', 'contexture-page-security') . '</a></span> </div> </td> <td class="protected column-protected">%5$s</td> <td class="type column-type">%6$s</td> </tr>', $page->sec_protect_id, $alternatecss, admin_url('post.php?post=' . $page->sec_protect_id . '&action=edit'), $page_title, '', $page->post_type, get_permalink($page->sec_protect_id), admin_url()); //Alternate css style for odd-numbered rows $alternatecss = $alternatecss != '' ? '' : ' class="alternate" '; } return $html; //'<td colspan="2">There are pages attached, but this feature is not yet working.</td>'; }