Author: Nick Sagona, III (dev@nolainteractive.com)
 /**
  * Index action method
  *
  * @return void
  */
 public function index($rid = null)
 {
     if (null === $rid || $this->services['acl']->isAllowed($this->sess->user->role, 'users-of-role-' . $rid, 'index')) {
         $deniedRoles = [];
         $resources = $this->services['acl']->getResources();
         foreach ($resources as $name => $resource) {
             if (!$this->services['acl']->isAllowed($this->sess->user->role, $name, 'index')) {
                 $deniedRoles[] = (int) substr($name, strrpos($name, '-') + 1);
             }
         }
         $user = new Model\User();
         $searchUsername = $this->request->getQuery('search_username');
         if ($user->hasPages($this->application->config()['pagination'], $rid, $searchUsername, $deniedRoles)) {
             $limit = $this->application->config()['pagination'];
             $pages = new Paginator($user->getCount($rid, $searchUsername, $deniedRoles), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('users/index.phtml');
         $this->view->title = 'Users';
         $this->view->pages = $pages;
         $this->view->roleId = $rid;
         $this->view->queryString = $this->getQueryString('sort');
         $this->view->searchUsername = $searchUsername;
         $this->view->users = $user->getAll($rid, $searchUsername, $deniedRoles, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->view->roles = $user->getRoles();
         $this->send();
     } else {
         $this->redirect('/users');
     }
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $slug = substr($this->request->getRequestUri(), 5);
     if ($slug != '') {
         $tag = new Model\Tag();
         $tag->getBySlug($slug, $this->application->modules());
         if (isset($tag->id)) {
             if (count($tag->items) > $this->config->pagination) {
                 $page = $this->request->getQuery('page');
                 $limit = $this->config->pagination;
                 $pages = new Paginator(count($tag->items), $limit);
                 $pages->useInput(true);
                 $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
                 $tag->items = array_slice($tag->items, $offset, $limit, true);
             } else {
                 $pages = null;
             }
             $this->prepareView('tags-public/tag.phtml');
             $this->template = 'tag.phtml';
             $this->view->title = 'Tag : ' . $tag->title;
             $this->view->tag_id = $tag->id;
             $this->view->tag_title = $tag->title;
             $this->view->tag_slug = $tag->slug;
             $this->view->pages = $pages;
             $this->view->merge($tag->toArray());
             $this->send();
         } else {
             $this->error();
         }
     } else {
         $this->redirect(BASE_PATH == '' ? '/' : BASE_PATH);
     }
 }
 /**
  * Search action method
  *
  * @return void
  */
 public function search()
 {
     $search = new Model\Search();
     $fields = $this->request->isPost() ? $this->request->getPost() : $this->request->getQuery();
     $search->user_role_id = isset($this->sess->user) ? $this->sess->user->role_id : -1;
     $search->filters = $this->application->module('phire-content')->config()['filters'];
     if (isset($fields['title'])) {
         $items = $search->search($fields, $this->application->modules());
         if (count($items) > $this->config->pagination) {
             $page = $this->request->getQuery('page');
             $limit = $this->config->pagination;
             $pages = new Paginator(count($items), $limit);
             $pages->useInput(true);
             $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
             $items = array_slice($items, $offset, $limit, true);
         } else {
             $pages = null;
         }
         $this->prepareView('search-public/search.phtml');
         $this->view->title = 'Search';
         $this->view->pages = $pages;
         $this->view->items = $items;
         $this->send();
     } else {
         $this->redirect(BASE_PATH . (BASE_PATH == '' ? '/' : ''));
     }
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $library = new Model\MediaLibrary();
     if ($library->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($library->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('media/libraries/index.phtml');
     $this->view->title = 'Media Libraries';
     $this->view->pages = $pages;
     $this->view->libraries = $library->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->send();
 }
 /**
  * Index action method
  *
  * @param  int $tid
  * @return void
  */
 public function index($tid = null)
 {
     if (null === $tid) {
         $this->prepareView('entities/types.phtml');
         $type = new Model\EntityType();
         if ($type->hasPages($this->config->pagination)) {
             $limit = $this->config->pagination;
             $pages = new Paginator($type->getCount(), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->view->title = 'Entities';
         $this->view->pages = $pages;
         $this->view->types = $type->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     } else {
         $this->prepareView('entities/index.phtml');
         $entities = new Model\Entity();
         $type = new Model\EntityType();
         $type->getById($tid);
         if (!isset($type->id)) {
             $this->redirect(BASE_PATH . APP_URI . '/entities');
         }
         if ($this->services['acl']->isAllowed($this->sess->user->role, 'entity-type-' . $type->id, 'index')) {
             if ($entities->hasPages($this->config->pagination, $tid)) {
                 $limit = $this->config->pagination;
                 $pages = new Paginator($entities->getCount($tid), $limit);
                 $pages->useInput(true);
             } else {
                 $limit = null;
                 $pages = null;
             }
             $ents = $entities->getAll($tid, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
             $this->view->title = 'Entities : ' . $type->name;
             $this->view->pages = $pages;
             $this->view->tid = $tid;
             $this->view->fieldNum = $type->field_num;
             $this->view->entities = $ents;
             $this->view->fields = $entities->getAllFields($ents);
         } else {
             $this->redirect(BASE_PATH . APP_URI . '/entities');
         }
     }
     $this->send();
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $type = new Model\ContentType();
     if ($type->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($type->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('content/types/index.phtml');
     $this->view->title = 'Content : Types';
     $this->view->pages = $pages;
     $this->view->types = $type->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->send();
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $group = new Model\FieldGroup();
     if ($group->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($group->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('fields/groups/index.phtml');
     $this->view->title = 'Fields : Groups';
     $this->view->pages = $pages;
     $this->view->groups = $group->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->send();
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $session = new Model\SessionConfig();
     if ($session->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($session->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('config/index.phtml');
     $this->view->title = 'Sessions Config';
     $this->view->pages = $pages;
     $this->view->sessions = $session->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->view->rolesAvailable = $session->rolesAvailable();
     $this->send();
 }
Beispiel #9
0
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $role = new Model\Role();
     if ($role->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($role->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('phire/roles/index.phtml');
     $this->view->title = 'Roles';
     $this->view->pages = $pages;
     $this->view->queryString = $this->getQueryString('sort');
     $this->view->roles = $role->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->send();
 }
Beispiel #10
0
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $module = new Model\Module();
     if ($module->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($module->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('phire/modules/index.phtml');
     $this->view->title = 'Modules';
     $this->view->pages = $pages;
     $this->view->newModules = $module->detectNew();
     $this->view->modules = $module->getAll($this->application->modules(), $this->services['acl'], $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->view->moduleUpdates = $this->sess->updates->modules;
     $this->send();
 }
 /**
  * Index action method
  *
  * @param  int $mid
  * @return void
  */
 public function index($mid)
 {
     $map = new Model\Map();
     $map->getById($mid);
     $location = new Model\MapLocation();
     if ($location->hasPages($this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($location->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->prepareView('maps/locations/index.phtml');
     $this->view->title = 'Maps : ' . $map->name . ' : Locations';
     $this->view->pages = $pages;
     $this->view->mid = $mid;
     $this->view->locations = $location->getAll($mid, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->send();
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $uri = substr($this->request->getRequestUri(), 9);
     if ($uri != '/') {
         if (substr($uri, -1) == '/') {
             $uri = substr($uri, 0, -1);
         }
         $category = new Model\Category();
         $category->getByUri($uri);
         if (isset($category->id)) {
             $category->filters = $category->filter ? $this->application->module('phire-categories')['filters'] : [];
             $category->show_total = $this->application->module('phire-categories')['show_total'];
             $category->datetime_formats = $this->application->module('phire-categories')['datetime_formats'];
             if ($category->pagination > 0 && $category->hasPages($category->pagination)) {
                 $limit = $category->pagination;
                 $pages = new Paginator($category->getCount(), $limit);
                 $pages->useInput(true);
             } else {
                 $limit = null;
                 $pages = null;
             }
             $this->prepareView('categories-public/category.phtml');
             $this->template = 'category.phtml';
             $this->view->title = 'Category : ' . $category->title;
             $this->view->category_id = $category->id;
             $this->view->category_title = $category->title;
             $this->view->category_slug = $category->slug;
             $this->view->category_nav = $category->getNav($this->application->module('phire-categories')['nav_config']);
             $this->view->pages = $pages;
             $this->view->category_breadcrumb = $category->getBreadcrumb($category->id, $this->application->module('phire-categories')['separator']);
             $this->view->items = $category->getItems($limit, $this->request->getQuery('page'));
             $this->send();
         } else {
             $this->error();
         }
     } else {
         $this->redirect(BASE_PATH == '' ? '/' : BASE_PATH);
     }
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $search = new Model\Search();
     if ($this->request->isPost()) {
         $search->remove($this->request->getPost());
         $this->sess->setRequestValue('removed', true);
         $this->redirect(BASE_PATH . APP_URI . '/searches');
     } else {
         if ($search->hasPages($this->config->pagination)) {
             $limit = $this->config->pagination;
             $pages = new Paginator($search->getCount(), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('search/index.phtml');
         $this->view->title = 'Searches';
         $this->view->pages = $pages;
         $this->view->searches = $search->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->send();
     }
 }
Beispiel #14
0
 /**
  * Index action method
  *
  * @param  int $id
  * @return void
  */
 public function index($id = null)
 {
     if (null === $id || $this->services['acl']->isAllowed($this->sess->user->role, 'users-of-role-' . $id, 'index')) {
         $deniedRoles = [];
         $resources = $this->services['acl']->getResources();
         foreach ($resources as $name => $resource) {
             if (!$this->services['acl']->isAllowed($this->sess->user->role, $name, 'index')) {
                 $deniedRoles[] = (int) substr($name, strrpos($name, '-') + 1);
             }
         }
         $user = new Model\User();
         $searchAry = null;
         if (null !== $this->request->getQuery('search_for') && null !== $this->request->getQuery('search_by') && $this->request->getQuery('search_for') != '' && $this->request->getQuery('search_by') != '----') {
             $searchAry = ['for' => $this->request->getQuery('search_for'), 'by' => $this->request->getQuery('search_by')];
         }
         if ($user->hasPages($this->config->pagination, $id, $searchAry, $deniedRoles)) {
             $limit = $this->config->pagination;
             $pages = new Paginator($user->getCount($id, $searchAry, $deniedRoles), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('phire/users/index.phtml');
         $this->view->title = 'Users';
         $this->view->pages = $pages;
         $this->view->roleId = $id;
         $this->view->queryString = $this->getQueryString('sort');
         $this->view->searchFor = $this->request->getQuery('search_for');
         $this->view->searchBy = $this->request->getQuery('search_by');
         $this->view->users = $user->getAll($id, $searchAry, $deniedRoles, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->view->roles = $user->getRoles();
         $this->send();
     } else {
         $this->redirect(BASE_PATH . APP_URI . '/users');
     }
 }
 /**
  * Index action method
  *
  * @return void
  */
 public function index()
 {
     $click = new Model\Click();
     if ($this->request->isPost()) {
         $click->remove($this->request->getPost());
         $this->sess->setRequestValue('removed', true);
         $this->redirect(BASE_PATH . APP_URI . '/clicks');
     } else {
         if ($click->hasPages($this->config->pagination, $this->request->getQuery('filter'))) {
             $limit = $this->config->pagination;
             $pages = new Paginator($click->getCount($this->request->getQuery('filter')), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('index.phtml');
         $this->view->title = 'ClickTrack';
         $this->view->pages = $pages;
         $this->view->filter = $this->request->getQuery('filter');
         $this->view->clicks = $click->getAll($this->request->getQuery('filter'), $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->send();
     }
 }
 /**
  * Browser action method
  *
  * @param  int $lid
  * @return void
  */
 public function browser($lid = null)
 {
     if (null !== $this->request->getQuery('editor') && null !== $this->request->getQuery('type')) {
         $this->prepareView('media/browser.phtml');
         $this->view->title = 'Media Browser';
         if ($this->request->isPost()) {
             $library = new Model\MediaLibrary();
             $library->getById($lid);
             $settings = $library->getSettings();
             if (count($settings) == 4) {
                 $upload = new \Pop\File\Upload($settings['folder'], $settings['max_filesize'], $settings['disallowed_types'], $settings['allowed_types']);
                 if ($upload->test($_FILES['file'])) {
                     $media = new Model\Media();
                     $media->save($_FILES['file'], $this->request->getPost());
                     $this->sess->setRequestValue('saved', true);
                     $this->redirect(str_replace('&error=1', '', $_SERVER['REQUEST_URI']));
                 } else {
                     $this->redirect(str_replace('&error=1', '', $_SERVER['REQUEST_URI']) . '&error=1');
                 }
             }
         }
         if (null !== $lid && null !== $this->request->getQuery('asset') && null !== $this->request->getQuery('asset_type')) {
             $assets = [];
             $limit = $this->config->pagination;
             $page = $this->request->getQuery('page');
             $pages = null;
             $library = new Model\MediaLibrary();
             if ($this->request->getQuery('asset_type') == 'content' && $this->application->isRegistered('phire-content')) {
                 $type = \Phire\Content\Table\ContentTypes::findById($lid);
                 $content = \Phire\Content\Table\Content::findBy(['type_id' => $lid], ['order' => 'order, id ASC']);
                 foreach ($content->rows() as $c) {
                     $assets[] = ['id' => $c->id, 'title' => $c->title, 'uri' => BASE_PATH . $c->uri];
                 }
                 if (isset($type->id)) {
                     $this->view->assetType = $type->name;
                 }
             } else {
                 if ($this->request->getQuery('asset_type') == 'media') {
                     $library->getById($lid);
                     $media = new Model\Media(['lid' => $lid]);
                     if ($this->request->getQuery('asset') == 'file') {
                         $assets = $media->getAll();
                     } else {
                         if ($this->request->getQuery('asset') == 'image') {
                             $assets = $media->getAllImages();
                         }
                     }
                     $this->view->assetType = $library->name;
                 }
             }
             if (count($assets) > $limit) {
                 $pages = new Paginator(count($assets), $limit);
                 $pages->useInput(true);
                 $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
                 $assets = array_slice($assets, $offset, $limit, true);
             }
             $this->view->title = 'Media' . (null !== $this->view->assetType ? ' : ' . $this->view->assetType : null);
             $this->view->lid = $lid;
             $this->view->folder = $library->folder;
             $this->view->sizes = null !== $library->actions ? array_keys($library->actions) : [];
             $this->view->pages = $pages;
             $this->view->browserAssets = $assets;
         } else {
             $libraries = [];
             $limit = null;
             $pages = null;
             if ($this->request->getQuery('type') == 'file' && $this->application->isRegistered('phire-content')) {
                 $types = \Phire\Content\Table\ContentTypes::findAll(['order' => 'order ASC']);
                 if ($types->hasRows()) {
                     $libraries['Content'] = [];
                     foreach ($types->rows() as $type) {
                         $libraries['Content'][$type->id] = $type->name;
                     }
                 }
             }
             $libraries['Media'] = [];
             $library = new Model\MediaLibrary();
             $libs = $library->getAll();
             foreach ($libs as $lib) {
                 $libraries['Media'][$lib->id] = $lib->name;
             }
             $this->view->title = 'Media';
             $this->view->pages = $pages;
             $this->view->lid = $lid;
             $this->view->libraries = $libraries;
         }
         $this->send();
     } else {
         $this->redirect(BASE_PATH . APP_URI . '/media');
     }
 }
 /**
  * Logins action method
  *
  * @param  int $id
  * @return void
  */
 public function logins($id = null)
 {
     $session = new Model\UserSession();
     $user = new \Phire\Model\User();
     if ($this->request->isPost()) {
         $session->clear($this->request->getPost());
         $this->sess->setRequestValue('removed', true);
         $this->redirect(BASE_PATH . APP_URI . '/sessions/logins/' . $id);
     } else {
         if (null !== $id) {
             $session = new Model\UserSession();
             $session->getUserData($id);
             if (count($session->logins) > $this->config->pagination) {
                 $page = $this->request->getQuery('page');
                 $limit = $this->config->pagination;
                 $pages = new Paginator(count($session->logins), $limit);
                 $pages->useInput(true);
                 $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
                 $logins = array_slice($session->logins, $offset, $limit, true);
             } else {
                 $pages = null;
                 $logins = $session->logins;
             }
             $this->prepareView('user-logins.phtml');
             $this->view->title = 'Sessions : Logins';
             $this->view->pages = $pages;
             $this->view->logins = $logins;
             $this->view->total_logins = (int) $session->total_logins;
             $this->view->failed_attempts = $session->failed_attempts;
             $this->view->username = $session->username;
             $this->view->user_id = $session->user_id;
             $this->send();
         } else {
             $this->prepareView('logins.phtml');
             $this->view->title = 'Sessions : Logins';
             $searchAry = null;
             if (null !== $this->request->getQuery('search_for') && null !== $this->request->getQuery('search_by') && $this->request->getQuery('search_for') != '' && $this->request->getQuery('search_by') != '----') {
                 $searchAry = ['for' => $this->request->getQuery('search_for'), 'by' => $this->request->getQuery('search_by')];
             }
             $roleId = null !== $this->request->getQuery('role_id') && $this->request->getQuery('role_id') != '----' ? (int) $this->request->getQuery('role_id') : null;
             if ($user->hasPages($this->config->pagination, null, null, [])) {
                 $limit = $this->config->pagination;
                 $pages = new Paginator($user->getCount(null, null, []), $limit);
                 $pages->useInput(true);
             } else {
                 $limit = null;
                 $pages = null;
             }
             $users = $user->getAll($roleId, $searchAry, [], $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
             foreach ($users as $k => $u) {
                 $session = new Model\UserSession();
                 $session->getUserData($u->id);
                 $users[$k]->logins = null !== $session->logins ? $session->logins : [];
                 $users[$k]->total_logins = null !== $session->total_logins ? (int) $session->total_logins : 0;
                 $users[$k]->failed_attempts = null !== $session->failed_attempts ? $session->failed_attempts : 0;
             }
             $this->view->users = $users;
             $this->view->pages = $pages;
             $this->view->queryString = $this->getQueryString('sort');
             $this->view->searchFor = $this->request->getQuery('search_for');
             $this->view->searchBy = $this->request->getQuery('search_by');
             $this->view->roles = $user->getRoles();
             $this->send();
         }
     }
 }
 /**
  * Trash action method
  *
  * @param  int $tid
  * @return void
  */
 public function trash($tid)
 {
     $this->prepareView('content/trash.phtml');
     $content = new Model\Content();
     $type = new Model\ContentType();
     $type->getById($tid);
     if (!isset($type->id)) {
         $this->redirect(BASE_PATH . APP_URI . '/content');
     }
     if ($content->hasPages($this->config->pagination, $tid, -2)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($content->getCount($tid, -2), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->view->title = 'Content : ' . $type->name . ' : Trash';
     $this->view->pages = $pages;
     $this->view->tid = $tid;
     $this->view->queryString = $this->getQueryString('sort');
     $this->view->content = $content->getAll($tid, $this->request->getQuery('sort'), $this->request->getQuery('title'), true);
     $this->send();
 }
 /**
  * Logins action method
  *
  * @return void
  */
 public function logins()
 {
     $session = new Model\Session();
     if ($this->request->isPost()) {
         $post = $this->request->getPost();
         if (isset($post['clear_all_logins']) && (int) $post['clear_all_logins'] == 1) {
             $session->clearLogins();
             $this->sess->setRequestValue('removed', true);
         } else {
             if (isset($post['clear_logins_by']) && $post['clear_logins_by'] != '----') {
                 $session->clearLogins($post['clear_logins_by']);
                 $this->sess->setRequestValue('removed', true);
             } else {
                 if (isset($post['rm_logins'])) {
                     $session->removeLogins($post['rm_logins']);
                     $this->sess->setRequestValue('removed', true);
                 }
             }
         }
         $this->redirect('/sessions/logins');
     } else {
         $searchUsername = $this->request->getQuery('search_username');
         if ($session->hasLoginPages($this->application->config()['pagination'], $searchUsername)) {
             $limit = $this->application->config()['pagination'];
             $pages = new Paginator($session->getLoginCount($searchUsername), $limit);
             $pages->useInput(true);
         } else {
             $limit = null;
             $pages = null;
         }
         $this->prepareView('sessions/logins.phtml');
         $this->view->title = 'Sessions : Logins';
         $this->view->pages = $pages;
         $this->view->queryString = $this->getQueryString('sort');
         $this->view->searchUsername = $searchUsername;
         $this->view->users = $session->getAllUsers();
         $this->view->logins = $session->getLogins($searchUsername, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
         $this->send();
     }
 }
Beispiel #20
0
 /**
  * Get pages of content by date
  *
  * @param  string $date
  * @param  string $limit
  * @return mixed
  */
 public function getDatePages($date, $limit = null)
 {
     $sql = Table\Content::sql();
     $sql->select(['count' => 'COUNT(*)', 'in_date' => DB_PREFIX . 'content_types.in_date']);
     $sql->select()->join(DB_PREFIX . 'content_types', [DB_PREFIX . 'content_types.id' => DB_PREFIX . 'content.type_id']);
     $dateAry = explode('/', $date);
     if (count($dateAry) == 3) {
         $start = $dateAry[0] . '-' . $dateAry[1] . '-' . $dateAry[2] . ' 00:00:00';
         $end = $dateAry[0] . '-' . $dateAry[1] . '-' . $dateAry[2] . ' 23:59:59';
     } else {
         if (count($dateAry) == 2) {
             $start = $dateAry[0] . '-' . $dateAry[1] . '-01 00:00:00';
             $end = $dateAry[0] . '-' . $dateAry[1] . '-' . date('t', strtotime($dateAry[0] . '-' . $dateAry[1] . '-01')) . ' 23:59:59';
         } else {
             $start = $dateAry[0] . '-01-01 00:00:00';
             $end = $dateAry[0] . '-12-31 23:59:59';
         }
     }
     $sql->select()->where('status = :status')->where('publish >= :publish1')->where('publish <= :publish2')->where('in_date = :in_date');
     $params = ['status' => 1, 'publish' => [$start, $end], 'in_date' => 1];
     $count = Table\Content::execute((string) $sql, $params)->count;
     if ($count > $limit) {
         $pages = new Paginator($count, $limit);
         $pages->useInput(true);
     } else {
         $pages = null;
     }
     return $pages;
 }
 public function index()
 {
     if (!isset($this->sess->user)) {
         $this->redirect('/login');
     }
     $this->prepareView('index.phtml');
     if (null !== $this->request->getQuery('modules')) {
         $model = new Model\Module();
         $this->view->title = 'Modules';
     } else {
         if (null !== $this->request->getQuery('themes')) {
             $model = new Model\Theme();
             $this->view->title = 'Themes';
         } else {
             $model = new Model\System();
             $this->view->title = 'System';
         }
     }
     if ($model->hasPages($this->pagination)) {
         $limit = $this->pagination;
         $pages = new Paginator($model->getCount(), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $this->view->pages = $pages;
     $this->view->stats = $model->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort'));
     $this->view->php = $model->php;
     $this->view->db = $model->db;
     $this->view->server = $model->server;
     $this->view->os = $model->os;
     $this->send();
 }
Beispiel #22
0
<?php

require_once '../../bootstrap.php';
use Pop\Paginator\Paginator;
try {
    $rows = array(array('id' => 1, 'name' => 'Test1', 'email' => '*****@*****.**'), array('id' => 2, 'name' => 'Test2', 'email' => '*****@*****.**'), array('id' => 3, 'name' => 'Test3', 'email' => '*****@*****.**'), array('id' => 4, 'name' => 'Test4', 'email' => '*****@*****.**'), array('id' => 5, 'name' => 'Test5', 'email' => '*****@*****.**'), array('id' => 6, 'name' => 'Test6', 'email' => '*****@*****.**'), array('id' => 7, 'name' => 'Test7', 'email' => '*****@*****.**'), array('id' => 8, 'name' => 'Test8', 'email' => '*****@*****.**'), array('id' => 9, 'name' => 'Test9', 'email' => '*****@*****.**'), array('id' => 10, 'name' => 'Test10', 'email' => '*****@*****.**'), array('id' => 11, 'name' => 'Test11', 'email' => '*****@*****.**'), array('id' => 12, 'name' => 'Test12', 'email' => '*****@*****.**'), array('id' => 13, 'name' => 'Test13', 'email' => '*****@*****.**'), array('id' => 14, 'name' => 'Test14', 'email' => '*****@*****.**'), array('id' => 15, 'name' => 'Test15', 'email' => '*****@*****.**'), array('id' => 16, 'name' => 'Test16', 'email' => '*****@*****.**'));
    $header = <<<HEADER
<table class="paged-table" cellpadding="0" cellspacing="0">
    <tr><td colspan="2">[{page_links}]</td></tr>
    <tr><td><strong>Name</strong></td><td><strong>Email</strong></td></tr>

HEADER;
    $rowTemplate = <<<TMPL
    <tr><td><a href="./edit-user.php?id=[{id}]">[{name}]</a></td><td>[{email}]</td></tr>

TMPL;
    $footer = <<<FOOTER
    <tr><td colspan="2">[{page_links}]</td></tr>
</table>

FOOTER;
    $pages = new Paginator($rows, 3, 3);
    $pages->setHeader($header)->setRowTemplate($rowTemplate)->setFooter($footer);
    echo $pages;
} catch (\Exception $e) {
    echo $e->getMessage();
}
 /**
  * Browser action
  *
  * @return void
  */
 public function browser()
 {
     if (null !== $this->request->getQuery('editor') && null !== $this->request->getQuery('type')) {
         $this->prepareView('fields/browser.phtml');
         $this->view->title = 'File Browser';
         if (null === $this->request->getQuery('asset')) {
             if ($this->request->getQuery('type') == 'image') {
                 $this->view->pages = null;
                 $this->view->libraries = ['Assets' => ['images' => 'Images']];
             } else {
                 $libraries = [];
                 if ($this->application->isRegistered('phire-content')) {
                     $types = \Phire\Content\Table\ContentTypes::findAll(['order' => 'order ASC']);
                     if ($types->hasRows()) {
                         $libraries['Assets'] = [];
                         foreach ($types->rows() as $type) {
                             $libraries['Assets'][$type->id] = $type->name;
                         }
                     }
                 }
                 $libraries['Assets']['files'] = 'Files';
                 $libraries['Assets']['images'] = 'Images';
                 $this->view->pages = null;
                 $this->view->libraries = $libraries;
             }
         } else {
             $asset = $this->request->getQuery('asset');
             $assets = [];
             $limit = $this->config->pagination;
             $page = $this->request->getQuery('page');
             $pages = null;
             $field = new Model\Field();
             $uploadFolder = BASE_PATH . CONTENT_PATH . '/files';
             switch ($asset) {
                 case 'files':
                     $assets = $field->getAllFiles($uploadFolder);
                     $this->view->assetType = 'Files';
                     break;
                 case 'images':
                     $assets = $field->getAllImages($uploadFolder);
                     $this->view->assetType = 'Images';
                     break;
                 default:
                     if (is_numeric($asset) && $this->application->isRegistered('phire-content')) {
                         $type = \Phire\Content\Table\ContentTypes::findById($asset);
                         $content = \Phire\Content\Table\Content::findBy(['type_id' => $asset], ['order' => 'order, id ASC']);
                         foreach ($content->rows() as $c) {
                             $assets[BASE_PATH . $c->uri] = $c->title;
                         }
                         if (isset($type->id)) {
                             $this->view->assetType = $type->name;
                         }
                     }
                     break;
             }
             if (count($assets) > $limit) {
                 $pages = new Paginator(count($assets), $limit);
                 $pages->useInput(true);
                 $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0;
                 $assets = array_slice($assets, $offset, $limit, true);
             }
             $this->view->pages = $pages;
             $this->view->browserAssets = $assets;
         }
         $this->send();
     }
 }
Beispiel #24
0
    public function testRenderWithTemplate()
    {
        $rows = array(array('id' => 1, 'name' => 'Test1', 'email' => '*****@*****.**'), array('id' => 2, 'name' => 'Test2', 'email' => '*****@*****.**'), array('id' => 3, 'name' => 'Test3', 'email' => '*****@*****.**'), array('id' => 4, 'name' => 'Test4', 'email' => '*****@*****.**'), array('id' => 5, 'name' => 'Test5', 'email' => '*****@*****.**'), array('id' => 6, 'name' => 'Test6', 'email' => '*****@*****.**'), array('id' => 7, 'name' => 'Test7', 'email' => '*****@*****.**'), array('id' => 8, 'name' => 'Test8', 'email' => '*****@*****.**'), array('id' => 9, 'name' => 'Test9', 'email' => '*****@*****.**'), array('id' => 10, 'name' => 'Test10', 'email' => '*****@*****.**'), array('id' => 11, 'name' => 'Test11', 'email' => '*****@*****.**'), array('id' => 12, 'name' => 'Test12', 'email' => '*****@*****.**'), array('id' => 13, 'name' => 'Test13', 'email' => '*****@*****.**'), array('id' => 14, 'name' => 'Test14', 'email' => '*****@*****.**'), array('id' => 15, 'name' => 'Test15', 'email' => '*****@*****.**'), array('id' => 16, 'name' => 'Test16', 'email' => '*****@*****.**'));
        $header = <<<HEADER
<table class="paged-table" cellpadding="0" cellspacing="0">
    <tr><td colspan="2">[{page_links}]</td></tr>
    <tr><td><strong>Name</strong></td><td><strong>Email</strong></td></tr>

HEADER;
        $rowTemplate = <<<TMPL
    <tr><td><a href="./edit-user.php?id=[{id}]">[{name}]</a></td><td>[{email}]</td></tr>

TMPL;
        $footer = <<<FOOTER
    <tr><td colspan="2">[{page_links}]</td></tr>
</table>

FOOTER;
        $p = new Paginator($rows, 3, 3);
        $p->setHeader($header)->setRowTemplate($rowTemplate)->setFooter($footer);
        $render = $p->render(1, true);
        ob_start();
        $p->render(1);
        $output = ob_get_clean();
        $this->assertContains('<tr><td><a href="./edit-user.php?id=1">Test1</a></td><td>test1@email.com</td></tr>', $render);
        $this->assertContains('<tr><td><a href="./edit-user.php?id=1">Test1</a></td><td>test1@email.com</td></tr>', $output);
        $this->assertContains('<tr><td><a href="./edit-user.php?id=1">Test1</a></td><td>test1@email.com</td></tr>', (string) $p);
    }
Beispiel #25
0
 /**
  * Encode the data into its native format.
  *
  * @param  mixed  $data
  * @param  array  $options
  * @param  int    $perPage
  * @param  int    $range
  * @param  int    $total
  * @return string
  */
 public static function encode($data, array $options = null, $perPage = 0, $range = 10, $total = null)
 {
     $output = '';
     $header = '';
     $row = '';
     $footer = '';
     $sep = isset($options['separator']) ? $options['separator'] : ' | ';
     $indent = isset($options['indent']) ? $options['indent'] : '    ';
     $date = isset($options['date']) ? $options['date'] : 'M j, Y';
     $exclude = isset($options['exclude']) ? $options['exclude'] : array();
     $process = null;
     $submit = null;
     if (!is_array($exclude)) {
         $exclude = array($exclude);
     }
     if (isset($options['form']) && is_array($options['form'])) {
         $process = isset($options['form']['process']) ? $options['form']['process'] : null;
         $submit = isset($options['form']['submit']) ? $options['form']['submit'] : null;
         $output .= $indent . '<form';
         foreach ($options['form'] as $attrib => $value) {
             if ($attrib != 'process' && $attrib != 'submit') {
                 $output .= ' ' . $attrib . '="' . $value . '"';
             }
         }
         $output .= '>' . PHP_EOL;
     }
     $output .= $indent . '    <table';
     if (isset($options['table']) && is_array($options['table'])) {
         foreach ($options['table'] as $attrib => $value) {
             if ($attrib != 'headers') {
                 $output .= ' ' . $attrib . '="' . $value . '"';
             }
         }
     }
     $output .= '>' . PHP_EOL;
     // Initialize and clean the header fields.
     foreach ($data as $ary) {
         $tempAry = array_keys((array) $ary);
     }
     $headerAry = array();
     $headerKeysAry = array();
     foreach ($tempAry as $value) {
         if (!in_array($value, $exclude)) {
             $headerKeysAry[] = $value;
             if (isset($options['table']) && isset($options['table']['headers']) && is_array($options['table']['headers']) && array_key_exists($value, $options['table']['headers'])) {
                 $headerAry[] = $options['table']['headers'][$value];
             } else {
                 $headerAry[] = ucwords(str_replace('_', ' ', (string) $value));
             }
         }
     }
     if (isset($options['form'])) {
         if (isset($options['table']) && isset($options['table']['headers']) && is_array($options['table']['headers']) && isset($options['table']['headers']['process'])) {
             $headerAry[] = $options['table']['headers']['process'];
             $headerKeysAry[] = 'process';
         } else {
             $headerAry[] = null !== $submit && is_array($submit) && isset($submit['value']) ? $submit['value'] : '&nbsp;';
             $headerKeysAry[] = 'process';
         }
     }
     // Set header output.
     $output .= $indent . '        <tr><th class="first-th">' . implode('</th><th>', $headerAry) . '</th></tr>' . PHP_EOL;
     $pos = strrpos($output, '<th') + 3;
     $output = substr($output, 0, $pos) . ' class="last-th"' . substr($output, $pos);
     // Set header and row templates
     $header = $indent . '<div class="page-links">[{page_links}]</div>' . PHP_EOL . $output;
     $row = $indent . '        <tr><td class="first-td">[{' . implode('}]</td><td>[{', $headerKeysAry) . '}]</td></tr>' . PHP_EOL;
     $pos = strrpos($row, '<td') + 3;
     $row = substr($row, 0, $pos) . ' class="last-td"' . substr($row, $pos);
     $rowValuesAry = array();
     // Initialize and clean the field values.
     $i = 1;
     foreach ($data as $value) {
         $rowAry = array();
         foreach ($value as $key => $val) {
             if (!in_array($key, $exclude)) {
                 if (strtotime((string) $val) !== false && (stripos($key, 'date') !== false || stripos($key, 'time') !== false)) {
                     $v = date($date, strtotime($val)) != '12/31/1969' ? date($date, strtotime((string) $val)) : '';
                 } else {
                     $v = (string) $val;
                 }
                 if (isset($options[$key])) {
                     $tmpl = $options[$key];
                     foreach ($value as $ky => $vl) {
                         if (strtotime((string) $vl) !== false && (stripos($key, 'date') !== false || stripos($key, 'time') !== false)) {
                             $vl = date($date, strtotime($vl)) != '12/31/1969' ? date($date, strtotime((string) $vl)) : '';
                         } else {
                             $vl = (string) $vl;
                         }
                         $tmpl = str_replace('[{' . $ky . '}]', $vl, $tmpl);
                     }
                     $v = $tmpl;
                 }
                 $rowAry[] = $v;
             }
         }
         if (isset($options['form'])) {
             if (null !== $process) {
                 $tmpl = str_replace('[{i}]', $i, $process);
                 foreach ($value as $ky => $vl) {
                     $tmpl = str_replace('[{' . $ky . '}]', $vl, $tmpl);
                 }
                 if (isset($exclude['process'])) {
                     $keys = array_keys($exclude['process']);
                     if (isset($keys[0]) && $exclude['process'][$keys[0]] == $value[$keys[0]]) {
                         $tmpl = '&nbsp;';
                     }
                 }
             } else {
                 $tmpl = '&nbsp;';
             }
             $rowAry[] = $tmpl;
         }
         $i++;
         foreach ($rowAry as $k => $r) {
             $rowAry[$headerKeysAry[$k]] = $r;
             unset($rowAry[$k]);
         }
         $rowValuesAry[] = $rowAry;
         // Set field output.
         $output .= $indent . '        <tr><td class="first-td">' . implode('</td><td>', $rowAry) . '</td></tr>' . PHP_EOL;
         $pos = strrpos($output, '<td') + 3;
         $output = substr($output, 0, $pos) . ' class="last-td"' . substr($output, $pos);
     }
     if (isset($options['form'])) {
         if (null !== $submit && is_array($submit)) {
             $submitBtn = '<input type="submit" name="submit"';
             if (!isset($submit['id'])) {
                 $submitBtn .= ' id="submit"';
             }
             foreach ($submit as $attrib => $value) {
                 $submitBtn .= ' ' . $attrib . '="' . $value . '"';
             }
             $submitBtn .= ' />';
         } else {
             $submitBtn = '<input type="submit" name="submit" id="submit" value="Submit" />';
         }
         $output .= $indent . '        <tr class="table-bottom-row"><td colspan="' . count($headerAry) . '" class="table-bottom-row">' . $submitBtn . '</td></tr>' . PHP_EOL;
         $output .= $indent . '    </table>' . PHP_EOL;
         $output .= $indent . '</form>' . PHP_EOL;
         $footer = $indent . '        <tr class="table-bottom-row"><td colspan="' . count($headerAry) . '" class="table-bottom-row">' . $submitBtn . '<div class="page-links">[{page_links}]</div></td></tr>' . PHP_EOL;
         $footer .= $indent . '    </table>' . PHP_EOL;
         $footer .= $indent . '</form>' . PHP_EOL;
     } else {
         $output .= $indent . '    </table>' . PHP_EOL;
         $footer = $indent . '    </table>' . PHP_EOL;
         $footer .= $indent . '<div class="page-links">[{page_links}]</div>' . PHP_EOL;
     }
     if ($perPage > 0) {
         $pages = new Paginator($rowValuesAry, $perPage, $range, $total);
         $pages->setHeader($header)->setRowTemplate($row)->setFooter($footer)->setSeparator($sep);
         $output = (string) $pages;
     }
     return $output;
 }
 /**
  * Submissions action method
  *
  * @param  int $id
  * @return void
  */
 public function submissions($id)
 {
     $form = new Model\Form();
     $form->getById($id);
     if (!isset($form->id)) {
         $this->redirect(BASE_PATH . APP_URI . '/forms');
     }
     $submission = new Model\FormSubmission();
     if ($submission->hasPages($id, $this->config->pagination)) {
         $limit = $this->config->pagination;
         $pages = new Paginator($submission->getCount($id), $limit);
         $pages->useInput(true);
     } else {
         $limit = null;
         $pages = null;
     }
     $submissions = $submission->getAll($id, $limit, $this->request->getQuery('page'), $this->request->getQuery('sort'), $this->application->modules());
     $this->prepareView('forms/submissions.phtml');
     $this->view->title = 'Forms : ' . $form->name . ' : Submissions';
     $this->view->id = $id;
     $this->view->pages = $pages;
     $this->view->fieldListLimit = $this->application->module('phire-forms')['field_list_limit'];
     $this->view->fields = $submissions['fields'];
     $this->view->submissions = $submissions['rows'];
     $this->send();
 }