Exemple #1
0
/*
  Copyright (C) <2011>  Vasyl Martyniuk <*****@*****.**>
 This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
 This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require_once '../../../../wp-admin/admin.php';
require_once 'Zend/Markup.php';
require_once 'bbcodes.php';
wp_enqueue_style('aam-treeview', WPACCESS_CSS_URL . 'treeview/jquery.treeview.css');
wp_enqueue_style('aam-reference', WPACCESS_CSS_URL . 'reference.css');
wp_enqueue_script('jquery-treeview', WPACCESS_JS_URL . 'treeview/jquery.treeview.js', array('jquery'));
wp_enqueue_script('jquery-treeedit', WPACCESS_JS_URL . 'treeview/jquery.treeview.edit.js');
wp_enqueue_script('admin-reference', WPACCESS_JS_URL . 'admin-reference.js');
iframe_header('ConfigPress Reference');
$template = mvb_Model_Template::readTemplate(WPACCESS_TEMPLATE_DIR . 'reference.html');
mvb_Model_Label::initConfigPressGuideLabels();
$bbcode = Zend_Markup::factory('Bbcode');
foreach ($bbcode_list as $code => $config) {
    $bbcode->addMarkup($code, Zend_Markup_Renderer_RendererAbstract::TYPE_REPLACE, $config);
}
$template = mvb_Model_Label::clearLabels($template, $bbcode);
echo mvb_Model_Template::clearTemplate($template);
iframe_footer();
Exemple #2
0
 function manage()
 {
     //render error list if applicable
     $tmpl = $this->renderErrorList($this->template);
     //render version indicator
     $tmpl = mvb_Model_Template::replaceSub('VERSION', $this->renderVersionIndicator(), $tmpl);
     //render Admin Menu Tab
     $tmpl = mvb_Model_Template::replaceSub('MAIN_MENU_TAB', $this->renderMenuTab(), $tmpl);
     //render Metabox & Widgets Tab
     $tmpl = mvb_Model_Template::replaceSub('METABOX_TAB', $this->renderMetaboxTab(), $tmpl);
     //render Capabilities Tab
     $tmpl = mvb_Model_Template::replaceSub('CAPABILITY_TAB', $this->renderCapabilityTab(), $tmpl);
     //render Restriction Tab
     $tmpl = mvb_Model_Template::replaceSub('RESTRICTION_TAB', $this->renderRestrictionTab(), $tmpl);
     //render ConfigPress Tab
     $tmpl = mvb_Model_Template::replaceSub('CONFIG_PRESS_TAB', $this->renderConfigPressTab(), $tmpl);
     //render Submit Metabox
     $tmpl = mvb_Model_Template::replaceSub('SUBMIT_METABOX', $this->renderSubmitMetabox(), $tmpl);
     //render Role Manager Metabox
     $tmpl = mvb_Model_Template::replaceSub('ROLE_METABOX', $this->renderRoleMetabox(), $tmpl);
     $tmpl = $this->updateMarkers($tmpl);
     $tmpl = mvb_Model_Label::clearLabels($tmpl);
     $tmpl = mvb_Model_Template::clearTemplate($tmpl);
     //add filter to future add-ons
     echo apply_filters(WPACCESS_PREFIX . 'option_page', $tmpl);
 }
 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('&nbsp;');
                 }
                 $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;
 }
 public function renderOptionList()
 {
     $this->template = mvb_Model_Template::retrieveSub('MAIN_OPTIONS_LIST', $this->template);
     //render Admin Menu Tab
     $tmpl = mvb_Model_Template::replaceSub('MAIN_MENU_TAB', $this->renderMenuTab(), $this->template);
     //render Metabox & Widgets Tab
     $tmpl = mvb_Model_Template::replaceSub('METABOX_TAB', $this->renderMetaboxTab(), $tmpl);
     //render Capabilities Tab
     $tmpl = mvb_Model_Template::replaceSub('CAPABILITY_TAB', $this->renderCapabilityTab(), $tmpl);
     //render Restriction Tab
     $tmpl = mvb_Model_Template::replaceSub('RESTRICTION_TAB', $this->renderRestrictionTab(), $tmpl);
     //render ConfigPress Tab
     $tmpl = mvb_Model_Template::replaceSub('CONFIG_PRESS_TAB', $this->renderConfigPressTab(), $tmpl);
     $tmpl = $this->updateMarkers($tmpl);
     $tmpl = mvb_Model_Label::clearLabels($tmpl);
     $tmpl = mvb_Model_Template::clearTemplate($tmpl);
     $result = array('html' => apply_filters(WPACCESS_PREFIX . 'option_page', $tmpl), 'status' => 'success');
     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;
 }