Пример #1
0
 public function add_rewrite_rules($rules)
 {
     global $wp_rewrite;
     $new_rules = array();
     $routes = MvcRouter::get_public_routes();
     // Use default routes if none have been defined
     if (empty($routes)) {
         MvcRouter::public_connect('{:controller}', array('action' => 'index'));
         MvcRouter::public_connect('{:controller}/{:id:[\\d]+}', array('action' => 'show'));
         MvcRouter::public_connect('{:controller}/{:action}/{:id:[\\d]+}');
         $routes = MvcRouter::get_public_routes();
     }
     foreach ($routes as $route) {
         $route_path = $route[0];
         $route_defaults = $route[1];
         if (strpos($route_path, '{:controller}') !== false) {
             foreach ($this->public_controller_names as $controller) {
                 $route_rules = $this->get_rewrite_rules($route_path, $route_defaults, $controller);
                 $new_rules = array_merge($route_rules, $new_rules);
             }
         } else {
             if (!empty($route_defaults['controller'])) {
                 $route_rules = $this->get_rewrite_rules($route_path, $route_defaults, $route_defaults['controller'], 1);
                 $new_rules = array_merge($route_rules, $new_rules);
             }
         }
     }
     $rules = array_merge($new_rules, $rules);
     $rules = apply_filters('mvc_public_rewrite_rules', $rules);
     return $rules;
 }
Пример #2
0
 static function admin_object_url($object, $options = array())
 {
     $defaults = array('id' => $object->__id, 'object' => $object);
     $options = array_merge($defaults, $options);
     $url = MvcRouter::admin_url($options);
     return $url;
 }
Пример #3
0
 public function set_pagination($collection)
 {
     $params = $this->params;
     unset($params['page']);
     unset($params['conditions']);
     $url = MvcRouter::public_url(array('controller' => $this->name, 'action' => $this->action));
     $this->pagination = array('base' => $url . '%_%', 'format' => '?page=%#%', 'total' => $collection['total_pages'], 'current' => $collection['page'], 'add_args' => $params);
 }
Пример #4
0
 public function set_pagination($collection)
 {
     $url_params = MvcRouter::admin_url_params(array('controller' => $this->name));
     $params = $this->params;
     unset($params['page_num']);
     $params['page'] = $url_params['page'];
     $this->set('pagination', array('base' => get_admin_url() . 'admin.php%_%', 'format' => '?page_num=%#%', 'total' => $collection['total_pages'], 'current' => $collection['page'], 'add_args' => $params));
 }
Пример #5
0
 public function filter_post_link($permalink, $post)
 {
     if (substr($post->post_type, 0, 4) == 'mvc_') {
         $model_name = substr($post->post_type, 4);
         $controller = MvcInflector::tableize($model_name);
         $model_name = MvcInflector::camelize($model_name);
         $model = MvcModelRegistry::get_model($model_name);
         $object = $model->find_one_by_post_id($post->ID);
         if ($object) {
             $url = MvcRouter::public_url(array('object' => $object));
             if ($url) {
                 return $url;
             }
         }
     }
     return $permalink;
 }
Пример #6
0
 public function create($model_name, $options = array())
 {
     $defaults = array('action' => $this->controller->action, 'controller' => MvcInflector::tableize($model_name), 'public' => false);
     $options = array_merge($defaults, $options);
     $this->model_name = $model_name;
     $this->object = MvcObjectRegistry::get_object($model_name);
     $this->model = MvcModelRegistry::get_model($model_name);
     $this->schema = $this->model->schema;
     $object_id = !empty($this->object) && !empty($this->object->__id) ? $this->object->__id : null;
     $router_options = array('controller' => $options['controller'], 'action' => $options['action']);
     if ($object_id) {
         $router_options['id'] = $object_id;
     }
     $enctype = isset($options['enctype']) ? ' enctype="' . $options['enctype'] . '"' : '';
     $url = $options['public'] ? MvcRouter::public_url($router_options) : MvcRouter::admin_url($router_options);
     $html = '<form action="' . $url . '" method="post"' . $enctype . '>';
     if ($object_id) {
         $html .= '<input type="hidden" id="' . $this->input_id('hidden_id') . '" name="' . $this->input_name('id') . '" value="' . $object_id . '" />';
     }
     return $html;
 }
Пример #7
0
 public function admin_actions_cell($controller, $object)
 {
     $links = array();
     $object_name = empty($object->__name) ? 'Item #' . $object->__id : $object->__name;
     $encoded_object_name = $this->esc_attr($object_name);
     $links[] = '<a href="' . MvcRouter::admin_url(array('object' => $object, 'action' => 'edit')) . '" title="Edit ' . $encoded_object_name . '">Edit</a>';
     $links[] = '<a href="' . MvcRouter::public_url(array('object' => $object)) . '" title="View ' . $encoded_object_name . '">View</a>';
     $links[] = '<a href="' . MvcRouter::admin_url(array('object' => $object, 'action' => 'delete')) . '" title="Delete ' . $encoded_object_name . '" onclick="return confirm(&#039;Are you sure you want to delete ' . $encoded_object_name . '?&#039;);">Delete</a>';
     $html = implode(' | ', $links);
     return '<td>' . $html . '</td>';
 }
Пример #8
0
 public function add_admin_ajax_routes()
 {
     $routes = MvcRouter::get_admin_ajax_routes();
     if (!empty($routes)) {
         foreach ($routes as $route) {
             $route['is_admin_ajax'] = true;
             $method = 'admin_ajax_' . $route['wp_action'];
             $this->dispatcher->{$method} = create_function('', 'MvcDispatcher::dispatch(array("controller" => "' . $route['controller'] . '", "action" => "' . $route['action'] . '"));die();');
             add_action('wp_ajax_' . $route['wp_action'], array($this->dispatcher, $method));
         }
     }
 }
Пример #9
0
 public function admin_ajax_connect($route)
 {
     $_this =& MvcRouter::get_instance();
     $_this->add_admin_ajax_route($route);
 }
Пример #10
0
<h2><?php 
echo MvcInflector::pluralize_titleize($model->name);
?>
</h2>

<form id="posts-filter" action="<?php 
echo MvcRouter::admin_url();
?>
" method="get">

    <p class="search-box">
        <label class="screen-reader-text" for="post-search-input">Search:</label>
        <input type="hidden" name="page" value="<?php 
echo MvcRouter::admin_page_param($model->name);
?>
" />
        <input type="text" name="q" value="<?php 
echo empty($params['q']) ? '' : $params['q'];
?>
" />
        <input type="submit" value="Search" class="button" />
    </p>

</form>

<div class="tablenav">

    <div class="tablenav-pages">
    
        <?php 
echo paginate_links($pagination);
Пример #11
0
<?php

MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_documents', 'action' => 'show'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_documents', 'action' => 'add'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_documents', 'action' => 'delete'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_documents', 'action' => 'index'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_connections', 'action' => 'index'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_collections', 'action' => 'index'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_fields', 'action' => 'index'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_supra_mongodb_documents', 'action' => 'edit'));
Пример #12
0
function mvc_admin_url($options)
{
    return MvcRouter::admin_url($options);
}
Пример #13
0
<?php

MvcRouter::public_connect('', array('controller' => 'documentation_nodes', 'action' => 'show', 'local_id' => 1));
MvcRouter::public_connect('documentation/{:documentation_version_name:[\\d.]+}', array('controller' => 'documentation_nodes', 'action' => 'show', 'local_id' => 1));
MvcRouter::public_connect('documentation/{:documentation_version_name:[\\d.]+}/{:local_id:[\\d]+}/.*', array('controller' => 'documentation_nodes', 'action' => 'show'));
MvcRouter::public_connect('documentation/{:local_id:[\\d]+}/.*', array('controller' => 'documentation_nodes', 'action' => 'show'));
MvcRouter::public_connect('search', array('controller' => 'documentation_nodes', 'action' => 'search'));
MvcRouter::public_connect('{:controller}', array('action' => 'index'));
MvcRouter::public_connect('{:controller}/{:id:[\\d]+}', array('action' => 'show'));
MvcRouter::public_connect('{:controller}/{:action}/{:id:[\\d]+}');
MvcRouter::admin_ajax_connect(array('controller' => 'admin_documentation_nodes', 'action' => 'update_tree'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_documentation_nodes', 'action' => 'preview_content'));
Пример #14
0
<?php

MvcRouter::public_connect('{:controller}', array('action' => 'index'));
MvcRouter::public_connect('{:controller}/{:id:[\\d]+}', array('action' => 'show'));
MvcRouter::public_connect('{:controller}/{:action}/{:id:[\\d]+}');
// $ajaxControllers = array(
//   'admin_surveys',
//   'admin_sections',
//   'admin_questions',
//   'admin_question_options'
// );
// foreach( $ajaxControllers as $c ){
//   MvcRouter::admin_ajax_connect(array('controller' => $c, 'action' => 'add_json'));
//   MvcRouter::admin_ajax_connect(array('controller' => $c, 'action' => 'add_json'));
// }
MvcRouter::admin_ajax_connect(array('controller' => 'admin_surveys', 'action' => 'add_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_surveys', 'action' => 'edit_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_surveys', 'action' => 'delete_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_sections', 'action' => 'add_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_sections', 'action' => 'edit_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_sections', 'action' => 'delete_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_questions', 'action' => 'add_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_questions', 'action' => 'edit_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_questions', 'action' => 'delete_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_question_options', 'action' => 'add_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_question_options', 'action' => 'edit_json'));
MvcRouter::admin_ajax_connect(array('controller' => 'admin_question_options', 'action' => 'delete_json'));
Пример #15
0
 public function check_access()
 {
     if (!strpos($this->current_url(), 'login') && !is_user_logged_in())
     {
         $url = MvcRouter::public_url(array('controller' => 'members', 'action' => 'login'));
         $this->redirect($url);
     }
 }
Пример #16
0
<?php

MvcRouter::public_connect('{:controller}', array('action' => 'index'));
MvcRouter::public_connect('{:controller}/{:id:[\\d]+}', array('action' => 'show'));
MvcRouter::public_connect('{:controller}/{:action}/{:id:[\\d]+}');
Пример #17
0
<?php
MvcRouter::public_connect('{:controller}', array('action' => 'index'));
MvcRouter::public_connect('{:controller}/{:id:[\d]+}', array('action' => 'show'));
MvcRouter::public_connect('{:controller}/{:action}/{:id:[\d]+}');
MvcRouter::public_connect('{:controller}/{:action}');
MvcRouter::public_connect('enroll', array('controller' => 'enrollments', 'action' => 'enroll'));
MvcRouter::public_connect('apply/{:hash}', array('controller' => 'enrollments', 'action' => 'payment'));
MvcRouter::public_connect('renew', array('controller' => 'enrollments', 'action' => 'payment'));
MvcRouter::public_connect('upgrade', array('controller' => 'enrollments', 'action' => 'payment'));

MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_details'));
MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_pwd'));
MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_settings'));
MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_cc'));
MvcRouter::admin_ajax_connect(array('controller' => 'members', 'action' => 'update_auto_renew'));
 private function redirect_non_member()
 {
     if (!is_user_logged_in())
     {
         $url = MvcRouter::public_url(array('controller' => 'members', 'action' => 'login'));
         $this->redirect($url);
     }
 }