/** * List tags * * @uses Request::is_datatables * @uses ORM::dataTables * @uses Text::plain * @uses HTML::icon * @uses Route::url * @uses Route::get * @uses Assets::popup */ public function action_list() { Assets::popup(); $is_datatables = Request::is_datatables(); if ($is_datatables) { $tags = ORM::factory('tag'); $this->_datatables = $tags->dataTables(array('name', 'id', 'type')); foreach ($this->_datatables->result() as $tag) { $this->_datatables->add_row(array(Text::plain($tag->name), HTML::anchor($tag->url, $tag->url), Text::plain($tag->type), HTML::icon($tag->edit_url, 'fa-edit', array('class' => 'btn btn-sm btn-default action-edit', 'title' => __('Edit Tag'))) . ' ' . HTML::icon($tag->delete_url, 'fa-trash-o', array('class' => 'btn btn-sm btn-default action-delete', 'title' => __('Delete Tag'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-tags')))); } } $this->title = __('Tags'); $url = Route::url('admin/tag', array('action' => 'list'), TRUE); $view = View::factory('admin/tag/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('url', $url); $this->response->body($view); }
/** * List user roles * * @uses Request::is_datatables * @uses ORM::dataTables */ public function action_list() { $is_datatables = Request::is_datatables(); if ($is_datatables) { $roles = ORM::factory('role'); $this->_datatables = $roles->dataTables(array('name', 'description', 'special')); foreach ($this->_datatables->result() as $role) { $this->_datatables->add_row(array(Text::plain($role->name), Text::plain($role->description), $role->special ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-ban"></i>', $role->special ? HTML::icon($role->perm_url, 'fa-lock', array('title' => __('Edit Permissions'))) : HTML::icon($role->edit_url, 'fa-edit', array('title' => __('Edit Role'))) . ' ' . HTML::icon($role->delete_url, 'fa-trash-o', array('title' => __('Delete Role'))) . ' ' . HTML::icon($role->perm_url, 'fa-lock', array('title' => __('Edit Permissions'))))); } } $this->title = __('Roles'); $add_url = Route::get('admin/role')->uri(array('action' => 'add')); $url = Route::url('admin/role', array('action' => 'list'), TRUE); $view = View::factory('admin/role/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('add_url', $add_url)->set('url', $url); $this->response->body($view); }
/** * List Category Groups * * @uses Assets::popup * @uses Request::is_datatables * @uses Text::plain * @uses HTML::icon * @uses Route::get * @uses Route::uri * @uses Route::url */ public function action_list() { Assets::popup(); $is_datatables = Request::is_datatables(); $terms = ORM::factory('term')->where('lft', '=', 1); if ($is_datatables) { $this->_datatables = $terms->dataTables(array('name', 'description')); foreach ($this->_datatables->result() as $term) { $this->_datatables->add_row(array(Text::plain($term->name) . '<div class="description">' . Text::plain($term->description) . '</div>', HTML::icon(Route::get('admin/term')->uri(array('action' => 'list', 'id' => $term->id)), 'fa-th-list', array('class' => 'action-list', 'title' => __('List Categories'))), HTML::icon(Route::get('admin/term')->uri(array('action' => 'add', 'id' => $term->id)), 'fa-plus', array('class' => 'action-add', 'title' => __('Add Category'))), HTML::icon(Route::get('admin/taxonomy')->uri(array('action' => 'edit', 'id' => $term->id)), 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit Group'))), HTML::icon(Route::get('admin/taxonomy')->uri(array('action' => 'delete', 'id' => $term->id)), 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete Group'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-vocabs')))); } } $this->title = __('Category Groups'); $add_url = Route::get('admin/taxonomy')->uri(array('action' => 'add')); $url = Route::url('admin/taxonomy', array('action' => 'list'), TRUE); $view = View::factory('admin/taxonomy/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('add_url', $add_url)->set('url', $url); $this->response->body($view); }
/** * Displays a list of all users * * @uses Request::is_datatables * @uses ORM::dataTables * @uses Text::plain * @uses Text::auto_link * @uses User::roles * @uses HTML::anchor * @uses HTML::icon * @uses Route::get * @uses Route::url * @uses Date::formatted_time * @uses Assets::popup */ public function action_list() { $is_datatables = Request::is_datatables(); if ($is_datatables) { $users = ORM::factory('user'); // @todo fix dummy id column for roles to match the column order $this->_datatables = $users->dataTables(array('name', 'mail', 'created', 'login', 'id', 'status')); foreach ($this->_datatables->result() as $user) { $this->_datatables->add_row(array(HTML::anchor($user->url, Text::plain($user->nick)), Text::auto_link($user->mail), Date::formatted_time($user->created, 'M d, Y'), $user->login > 0 ? Date::formatted_time($user->login, 'M d, Y') : __('Never'), User::roles($user), $user->status == 1 ? '<span class="status-active"><i class="fa fa-check-circle"></i></span>' : '<span class="status-blocked"><i class="fa fa-ban"></i></span>', HTML::icon(Route::get('admin/user')->uri(array('action' => 'edit', 'id' => $user->id)), 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit User'))) . ' ' . HTML::icon(Route::get('admin/permission')->uri(array('action' => 'user', 'id' => $user->id)), 'fa-key', array('class' => '', 'title' => __('Edit Permission'))) . ' ' . HTML::icon($user->delete_url, 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete User'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-users')))); } } Assets::popup(); $this->title = __('Users'); $url = Route::url('admin/user', array('action' => 'list'), TRUE); $view = View::factory('admin/user/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('url', $url); $this->response->body($view); }
/** * List menus * * @uses ORM::reset * @uses ORM::dataTables * @uses Route::get * @uses Route::uri * @uses Route::url * @uses Assets::popup * @uses Request::is_datatables * @uses Text::plain * @uses HTML::icon */ public function action_list() { Assets::popup(); $is_datatables = Request::is_datatables(); $menus = ORM::factory('menu')->where('lft', '=', 1); if ($is_datatables) { $this->_datatables = $menus->dataTables(array('title', 'descp')); foreach ($this->_datatables->result() as $menu) { $this->_datatables->add_row(array(Text::plain($menu->title) . '<div class="description">' . Text::plain($menu->descp) . '</div>', HTML::icon($menu->list_items_url, 'fa-th-list', array('class' => 'action-list', 'title' => __('List Links'))), HTML::icon($menu->add_item_url, 'fa-plus', array('class' => 'action-add', 'title' => __('Add Link'))), HTML::icon($menu->edit_url, 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit Menu'))), HTML::icon($menu->delete_url, 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete Menu'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-menus')))); } } $this->title = __('Menus'); $add_url = Route::get('admin/menu')->uri(array('action' => 'add')); $url = Route::url('admin/menu', array('action' => 'list'), TRUE); $view = View::factory('admin/menu/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('add_url', $add_url)->set('url', $url); $this->response->body($view); }
public function action_list() { if (Request::is_datatables()) { if (!ACL::check('access oaclient2')) { throw new HTTP_Exception_404('You have no permission to access oauth2 clients.'); } $posts = ORM::factory('oaclient'); if (!User::is_admin()) { $user = Auth::instance()->get_user(); $posts->where('user_id', '=', $user->id); } $this->_datatables = $posts->dataTables(array('title', 'client_id', 'user_id', 'created')); foreach ($this->_datatables->result() as $oaclient) { $this->_datatables->add_row(array(HTML::anchor($oaclient->url, Text::plain($oaclient->title)), $oaclient->client_id, $oaclient->user->nick, System::date('M d, Y', $oaclient->created), HTML::icon($oaclient->edit_url, 'fa-edit', array('class' => 'action-edit', 'data-toggle' => 'popup1', 'title' => __('Edit'))) . ' ' . HTML::icon($oaclient->delete_url, 'fa-trash-o', array('class' => 'action-delete', 'data-toggle' => 'popup', 'title' => __('Delete'))))); } } $this->title = __('Oauth Clients'); $view = View::factory('client/list')->bind('datatables', $this->_datatables)->set('url', Route::url('oauth2/client', array('action' => 'list'), TRUE))->set('show', TRUE); $this->response->body($view); }
/** * Display a list of incoming messages * * @uses Assets::popup * @uses Route::url * @uses Route::get * @uses Route::uri * @uses Request::is_datatables * @uses Form::checkbox * @uses HTML::anchor * @uses Date::formatted_time * @uses HTML::icon * @uses Text::limit_chars */ public function action_inbox() { Assets::popup(); $url = Route::url('user/message', array('action' => 'inbox'), TRUE); $redirect = Route::get('user/message')->uri(array('action' => 'inbox')); $form_action = Route::get('user/message')->uri(array('action' => 'bulk', 'id' => PM::INBOX)); $destination = '?destination=' . $redirect; $is_datatables = Request::is_datatables(); /** @var $messages Model_Message */ $messages = ORM::factory('Message')->loadInbox(); if ($is_datatables) { $this->_datatables = $messages->dataTables(array('id', 'subject', 'sender', 'sent')); foreach ($this->_datatables->result() as $message) { $this->_datatables->add_row(array(Form::checkbox('messages[' . $message->id . ']', $message->id, isset($_POST['messages'][$message->id])), HTML::anchor($message->user->url, $message->user->nick, array('class' => 'message-' . $message->status)), HTML::anchor($message->url, Text::limit_chars($message->subject, 20), array('class' => 'message-' . $message->status)) . ' ' . HTML::anchor($message->url, Text::limit_chars(strip_tags($message->body), 80)), Date::formatted_time($message->sent, 'M d, Y'), HTML::icon($message->delete_url . $destination, 'fa-trash-o', array('title' => __('Delete Message'), 'data-toggle' => 'popup', 'data-table' => '#user-message-inbox')))); } } $this->title = __('Inbox'); $view = View::factory('message/inbox')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('action', $form_action)->set('url', $url); $this->response->body($view); }
/** * Loads the template View object, if it is direct request * * @return void * @throws Http_Exception_415 If none of the accept-types are supported */ public function before() { // Execute parent::before first parent::before(); if ($this->bare == FALSE) { // Load the config $this->_config = Config::load('site'); if (Kohana::$profiling) { // Start a new benchmark token $this->_benchmark = Profiler::start('Gleez', ucfirst($this->request->controller()) . ' Controller'); } // Test whether the current request is command line request if (Kohana::$is_cli) { $this->_ajax = FALSE; $this->auto_render = FALSE; } // Test whether the current request is the first request if (!$this->request->is_initial()) { $this->_internal = TRUE; $this->auto_render = FALSE; } // Test whether the current request is ajax request if ($this->request->is_ajax()) { $this->_ajax = TRUE; $this->auto_render = FALSE; } // Test whether the current request is jquery mobile request. ugly hack if (Request::is_mobile() and $this->_config->get('mobile_theme', FALSE)) { $this->_ajax = FALSE; $this->auto_render = TRUE; } // Test whether the current request is datatables request if (Request::is_datatables()) { $this->_ajax = TRUE; $this->auto_render = FALSE; } $this->response->headers('X-Powered-By', Gleez::getVersion(TRUE, TRUE) . ' (' . Gleez::CODENAME . ')'); $this->_auth = Auth::instance(); // Get desired response formats $accept_types = Request::accept_type(); $accept_types = Arr::extract($accept_types, array_keys($this->_accept_formats)); // Set response format to first matched element $this->_response_format = $this->request->headers()->preferred_accept(array_keys($this->_accept_formats)); $site_name = Template::getSiteName(); $url = URL::site(NULL, TRUE); View::bind_global('site_name', $site_name); View::bind_global('site_url', $url); } if ($this->auto_render && $this->bare == FALSE) { // Throw exception if none of the accept-types are supported if (!($accept_types = array_filter($accept_types))) { throw new Http_Exception_415('Unsupported accept-type', 415); } // Initiate a Format instance $this->_format = Format::instance(); // Load the template $this->template = View::factory($this->template); $this->title_separator = $this->_config->get('title_separator', ' | '); $this->_widgets = Widgets::instance(); $this->template->_admin = Theme::$is_admin; // Set the destination & redirect url $this->_desti = array('destination' => $this->request->uri()); $this->redirect = $this->request->query('destination') !== NULL ? $this->request->query('destination') : array(); // Bind the generic page variables $this->template->set('site_name', Template::getSiteName())->set('site_slogan', $this->_config->get('site_slogan', __('Innovate IT')))->set('site_url', URL::site(NULL, TRUE))->set('site_logo', $this->_config->get('site_logo', FALSE))->set('sidebar_left', array())->set('sidebar_right', array())->set('column_class', '')->set('main_column', 12)->set('head_title', $this->title)->set('title', $this->title)->set('subtitle', $this->subtitle)->set('icon', $this->icon)->set('schemaType', $this->schemaType)->set('front', FALSE)->set('mission', FALSE)->set('tabs', FALSE)->set('subtabs', FALSE)->set('actions', FALSE)->set('_user', $this->_auth->get_user())->bind('datatables', $this->_datatables); // Page Title $this->title = ucwords($this->request->controller()); // Assign the default css files $this->_set_default_css(); // Assign the default js files $this->_set_default_js(); // Set default server headers $this->_set_default_server_headers(); // Set default meta data and media $this->_set_default_meta_links(); $this->_set_default_meta_tags(); /** * Make your view template available to all your other views * so easily you could access template variables */ View::bind_global('template', $this->template); } if (Kohana::$environment === Kohana::DEVELOPMENT) { Log::debug('Executing Controller [:controller] action [:action]', array(':controller' => $this->request->controller(), ':action' => $this->request->action())); } }
/** * Blog list * * @uses Route::url * @uses Route::get * @uses Route::uri * @uses Request::is_datatables * @uses Form::checkbox * @uses HTML::anchor * @uses HTML::label * @uses HTML::icon * @uses Post::bulk_actions * @uses Assets::popup */ public function action_list() { Assets::popup(); $this->title = __('Blog List'); $url = Route::url('admin/blog', array('action' => 'list'), TRUE); $redirect = Route::get('admin/blog')->uri(array('action' => 'list')); $action = Route::get('admin/blog')->uri(array('action' => 'bulk')); $destination = '?destination=' . $redirect; $is_datatables = Request::is_datatables(); $blogs = ORM::factory('blog'); if ($is_datatables) { $this->_datatables = $blogs->dataTables(array('id', 'title', 'author', 'status', 'updated')); foreach ($this->_datatables->result() as $blog) { $this->_datatables->add_row(array(Form::checkbox('blogs[' . $blog->id . ']', $blog->id, isset($_POST['blogs'][$blog->id])), HTML::anchor($blog->url, $blog->title), HTML::anchor($blog->user->url, $blog->user->nick), HTML::label(__($blog->status), $blog->status), Date::formatted_time($blog->updated, 'M d, Y'), HTML::icon($blog->edit_url . $destination, 'fa-edit', array('class' => 'btn btn-sm btn-default action-edit', 'title' => __('Edit Blog'))) . ' ' . HTML::icon($blog->delete_url . $destination, 'fa-trash-o', array('class' => 'btn btn-sm btn-default action-delete', 'title' => __('Delete Blog'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-blogs')))); } } $view = View::factory('admin/blog/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('action', $action)->set('actions', Post::bulk_actions(TRUE, 'blog'))->set('url', $url); $this->response->body($view); }
<?php if (Request::is_datatables()) { ?> <?php echo $datatables->render(); } else { ?> <?php Assets::datatables(); ?> <div class="wellact"> <table id="datatable-oaclient" class="table table-striped table-bordered table-highlight" data-toggle="datatable" data-target="<?php echo $url; ?> " data-sorting='[["3", "desc"]]'> <thead> <tr> <th width="20%"><?php echo __("Title"); ?> </th> <th width="30%"><?php echo __("Client Id"); ?> </th> <th width="20%"><?php echo __("Created By"); ?> </th>
/** * Prepare DataTables list * * @param ORM $posts Posts * * @uses Request::is_datatables * @uses ORM::dataTables * @uses Datatables::result * @uses Datatables::add_row * @uses HTML::anchor * @uses Form::checkbox * @uses Text::limit_words * @uses Date::formatted_time * @uses HTML::icon * @uses I18n::__ * @uses Route::get * @uses Route::uri */ private function _prepare_list(ORM $posts) { if (Request::is_datatables()) { $this->_datatables = $posts->dataTables(array('id', 'title', 'author', 'guest_name', 'created')); foreach ($this->_datatables->result() as $post) { if ($post->author == 1 and !is_null($post->guest_name)) { $author = HTML::anchor($post->guest_url, $post->guest_name, array()) . __(' (not verified)'); } else { $author = HTML::anchor(Route::get('user')->uri(array('action' => 'profile', 'id' => $post->author)), $post->user->nick, array()); } $this->_datatables->add_row(array(Form::checkbox('comments[' . $post->id . ']', $post->id, isset($_POST['comments'][$post->id])), HTML::anchor($post->url, Text::limit_chars($post->title, 40), array('class' => 'action-view', 'title' => Text::limit_chars($post->rawbody, 120))), $author, HTML::anchor($post->post->url, $post->post->title, array('class' => 'action-view')), Date::formatted_time($post->created), HTML::icon($post->edit_url . $this->_destination, 'fa-edit', array('class' => 'btn btn-sm btn-default action-edit', 'title' => __('Edit'))), HTML::icon($post->delete_url . $this->_destination, 'fa-trash-o', array('class' => 'btn btn-sm btn-default action-delete', 'title' => __('Delete'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-comments')))); } } }