public static function renderInfo($id, $type, $parent, $tmpl) { global $wp_post_statuses, $wp_post_types; switch ($type) { case 'post': //get information about page or post $post = get_post($id); if ($post->ID) { $tmpl = mvb_Model_Template::retrieveSub('POST', $tmpl); $tmpl = phpQuery::newDocument($tmpl); $data = $parent->getConfig()->getRestriction('post', $id); foreach ($data as $key => $value) { $tmpl['#' . $key]->attr('checked', 'checked'); } if ($parent->getCurrentUser()) { $tmpl['.save-postinfo-all']->attr('disabled', 'disabled'); } $tmpl['.category-title']->html(mvb_Model_Helper::editPostLink($post)); //check what type of post is it and render exclude if page if (isset($wp_post_types[$post->post_type])) { if ($wp_post_types[$post->post_type]->capability_type != 'page') { $tmpl['#exclude']->remove(); } } $tmpl = $tmpl->htmlOuter(); } break; case 'taxonomy': //get information about category $taxonomy = mvb_Model_Helper::getTaxonomyByTerm($id); $term = get_term($id, $taxonomy); if ($term->term_id) { $tmpl = mvb_Model_Template::retrieveSub('CATEGORY', $tmpl); $tmpl = phpQuery::newDocument($tmpl); $data = $parent->getConfig()->getRestriction('taxonomy', $id); foreach ($data as $key => $value) { $tmpl['#' . $key]->attr('checked', 'checked'); } if ($parent->getCurrentUser()) { $tmpl['.save-postinfo-all']->attr('disabled', 'disabled'); } $tmpl['.category-title']->html(mvb_Model_Helper::editTermLink($term)); $tmpl['.subposts']->html(sprintf(mvb_Model_Label::get('LABEL_178'), $term->name)); if (mvb_Model_Helper::isPremium()) { $tmpl['.premium']->removeClass('premium'); $tmpl['#premium-ind']->html(' '); } $tmpl = $tmpl->htmlOuter(); } break; default: $tmpl = ''; break; } $tmpl = mvb_Model_Label::clearLabels($tmpl); $result = array('status' => 'success', 'html' => mvb_Model_Template::clearTemplate($tmpl)); return $result; }
/** * Get Information about current post or page * * @global type $wp_post_statuses * @global type $wp_post_types * @return type */ protected function get_info() { global $wp_post_statuses, $wp_post_types; $id = intval($_POST['id']); $type = trim($_POST['type']); $role = $_POST['role']; $user = $_POST['user']; if ($user) { $config = mvb_Model_API::getUserAccessConfig($user); } else { $config = mvb_Model_API::getRoleAccessConfig($role); } //render html $tmpl = new mvb_Model_Template(); $templatePath = WPACCESS_TEMPLATE_DIR . 'admin_options.html'; $template = $tmpl->readTemplate($templatePath); $template = $tmpl->retrieveSub('POST_INFORMATION', $template); $result = array('status' => 'error'); switch ($type) { case 'post': //get information about page or post $post = get_post($id); if ($post->ID) { $template = $tmpl->retrieveSub('POST', $template); if ($config->hasRestriction('post', $id)) { $restiction = $config->getRestriction('post', $id); $checked = $restiction['restrict'] ? 'checked' : ''; $checked_front = $restiction['restrict_front'] ? 'checked' : ''; $exclude = $config->hasExclude($id) ? 'checked' : ''; $expire = $restiction['expire'] ? date('m/d/Y', $restiction['expire']) : ''; } $markerArray = array('###post_title###' => mvb_Model_Helper::editPostLink($post), '###disabled_apply_all###' => $user ? 'disabled="disabled"' : '', '###restrict_checked###' => isset($checked) ? $checked : '', '###restrict_front_checked###' => isset($checked_front) ? $checked_front : '', '###restrict_expire###' => isset($expire) ? $expire : '', '###exclude_page_checked###' => isset($exclude) ? $exclude : '', '###post_type###' => ucfirst($post->post_type), '###post_status###' => $wp_post_statuses[$post->post_status]->label, '###post_visibility###' => mvb_Model_Helper::checkVisibility($post), '###ID###' => $post->ID); //check what type of post is it and render exclude if page $render_exclude = FALSE; if (isset($wp_post_types[$post->post_type])) { switch ($wp_post_types[$post->post_type]->capability_type) { case 'page': $render_exclude = TRUE; break; default: break; } } if ($render_exclude) { $excld_tmlp = $tmpl->retrieveSub('EXCLUDE_PAGE', $template); } else { $excld_tmlp = ''; } $template = $tmpl->replaceSub('EXCLUDE_PAGE', $excld_tmlp, $template); $template = $tmpl->updateMarkers($markerArray, $template); $result = array('status' => 'success', 'html' => $tmpl->clearTemplate($template)); } break; case 'taxonomy': //get information about category $taxonomy = mvb_Model_Helper::getTaxonomyByTerm($id); $term = get_term($id, $taxonomy); if ($term->term_id) { $template = $tmpl->retrieveSub('CATEGORY', $template); if ($config->hasRestriction('taxonomy', $id)) { $tax = $config->getRestriction('taxonomy', $id); $checked = $tax['restrict'] ? 'checked' : ''; $checked_front = $tax['restrict_front'] ? 'checked' : ''; $expire = $tax['expire'] ? date('m/d/Y', $tax['expire']) : ''; } $markerArray = array('###name###' => mvb_Model_Helper::editTermLink($term), '###disabled_apply_all###' => $user ? 'disabled="disabled"' : '', '###restrict_checked###' => isset($checked) ? $checked : '', '###restrict_front_checked###' => isset($checked_front) ? $checked_front : '', '###restrict_expire###' => isset($expire) ? $expire : '', '###post_number###' => $term->count, '###ID###' => $term->term_id); $template = $tmpl->updateMarkers($markerArray, $template); $result = array('status' => 'success', 'html' => $tmpl->clearTemplate($template)); } break; default: break; } return $result; }