Exemplo n.º 1
0
 static function object_url($object, $options = array())
 {
     $defaults = array('id' => $object->__id, 'action' => 'show', 'object' => $object);
     $options = array_merge($defaults, $options);
     $url = MvcRouter::public_url($options);
     return $url;
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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>';
 }
Exemplo n.º 6
0
function mvc_public_url($options)
{
    return MvcRouter::public_url($options);
}
Exemplo n.º 7
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);
     }
 }
 private function redirect_non_member()
 {
     if (!is_user_logged_in())
     {
         $url = MvcRouter::public_url(array('controller' => 'members', 'action' => 'login'));
         $this->redirect($url);
     }
 }