저자: Nick Sagona, III (nick@popphp.org)
예제 #1
0
 /**
  * Get all sites method
  *
  * @param  string $sort
  * @param  string $page
  * @return void
  */
 public function getAll($sort = null, $page = null)
 {
     $order = $this->getSortOrder($sort, $page);
     $sites = Table\Sites::findAll($order['field'] . ' ' . $order['order']);
     if ($this->data['acl']->isAuth('Phire\\Controller\\Config\\SitesController', 'remove')) {
         $removeCheckbox = '<input type="checkbox" name="remove_sites[]" id="remove_sites[{i}]" value="[{id}]" />';
         $removeCheckAll = '<input type="checkbox" id="checkall" name="checkall" value="remove_sites" />';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'));
     } else {
         $removeCheckbox = '&nbsp;';
         $removeCheckAll = '&nbsp;';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'), 'style' => 'display: none;');
     }
     $options = array('form' => array('id' => 'sites-remove-form', 'action' => BASE_PATH . APP_URI . '/config/sites/remove', 'method' => 'post', 'process' => $removeCheckbox, 'submit' => $submit), 'table' => array('headers' => array('id' => '<a href="' . BASE_PATH . APP_URI . '/sites?sort=id">#</a>', 'edit' => '<span style="display: block; margin: 0 auto; width: 100%; text-align: center;">' . $this->i18n->__('Edit') . '</span>', 'domain' => '<a href="' . BASE_PATH . APP_URI . '/sites?sort=domain">' . $this->i18n->__('Domain') . '</a>', 'document_root' => '<a href="' . BASE_PATH . APP_URI . '/sites?sort=document_root">' . $this->i18n->__('Document Root') . '</a>', 'title' => '<a href="' . BASE_PATH . APP_URI . '/sites?sort=title">' . $this->i18n->__('Title') . '</a>', 'live' => '<a href="' . BASE_PATH . APP_URI . '/sites?sort=live">' . $this->i18n->__('Live') . '</a>', 'process' => $removeCheckAll), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'exclude' => array('force_ssl'), 'indent' => '        ');
     $siteAry = array();
     foreach ($sites->rows as $site) {
         if ($this->data['acl']->isAuth('Phire\\Controller\\Config\\SitesController', 'edit')) {
             $edit = '<a class="edit-link" title="' . $this->i18n->__('Edit') . '" href="' . BASE_PATH . APP_URI . '/config/sites/edit/' . $site->id . '">Edit</a>';
         } else {
             $edit = null;
         }
         $sAry = array('id' => $site->id, 'title' => $site->title, 'domain' => $site->domain, 'document_root' => $site->document_root, 'base_path' => $site->base_path == '' ? '&nbsp;' : $site->base_path, 'live' => $site->live == 1 ? $this->i18n->__('Yes') : $this->i18n->__('No'));
         if (null !== $edit) {
             $sAry['edit'] = $edit;
         }
         $siteAry[] = $sAry;
     }
     if (isset($siteAry[0])) {
         $this->data['table'] = Html::encode($siteAry, $options, $this->config->pagination_limit, $this->config->pagination_range);
     }
 }
예제 #2
0
 /**
  * Get all groups method
  *
  * @param  string $sort
  * @param  string $page
  * @return void
  */
 public function getAll($sort = null, $page = null)
 {
     $order = $this->getSortOrder($sort, $page);
     $groups = Table\FieldGroups::findAll($order['field'] . ' ' . $order['order'], null, $order['limit'], $order['offset']);
     if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\Structure\\GroupsController', 'remove')) {
         $removeCheckbox = '<input type="checkbox" name="remove_groups[]" id="remove_groups[{i}]" value="[{id}]" />';
         $removeCheckAll = '<input type="checkbox" id="checkall" name="checkall" value="remove_groups" />';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'));
     } else {
         $removeCheckbox = '&nbsp;';
         $removeCheckAll = '&nbsp;';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'), 'style' => 'display: none;');
     }
     $options = array('form' => array('id' => 'field-group-remove-form', 'action' => BASE_PATH . APP_URI . '/structure/groups/remove', 'method' => 'post', 'process' => $removeCheckbox, 'submit' => $submit), 'table' => array('headers' => array('id' => '<a href="' . BASE_PATH . APP_URI . '/structure/groups?sort=id">#</a>', 'edit' => '<span style="display: block; margin: 0 auto; width: 100%; text-align: center;">' . $this->i18n->__('Edit') . '</span>', 'name' => '<a href="' . BASE_PATH . APP_URI . '/structure/groups?sort=name">' . $this->i18n->__('Name') . '</a>', 'order' => '<a href="' . BASE_PATH . APP_URI . '/structure/groups?sort=order">' . $this->i18n->__('Order') . '</a>', 'process' => $removeCheckAll), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'indent' => '        ', 'exclude' => 'dynamic');
     if (isset($groups->rows[0])) {
         $groupsAry = array();
         foreach ($groups->rows as $group) {
             if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\Structure\\GroupsController', 'edit')) {
                 $edit = '<a class="edit-link" title="' . $this->i18n->__('Edit') . '" href="' . BASE_PATH . APP_URI . '/structure/groups/edit/' . $group->id . '">Edit</a>';
             } else {
                 $edit = null;
             }
             $gAry = array('id' => $group->id, 'name' => $group->name, 'order' => $group->order);
             if (null !== $edit) {
                 $gAry['edit'] = $edit;
             }
             $groupsAry[] = $gAry;
         }
         $this->data['table'] = Html::encode($groupsAry, $options, $this->config->pagination_limit, $this->config->pagination_range, Table\FieldGroups::getCount());
     }
 }
예제 #3
0
 public function testEncode()
 {
     $data = array(array('id' => 1001, 'first_name' => 'Bob', 'last_name' => 'Smith', 'birth_date' => '1977-08-19'), array('id' => 1002, 'first_name' => 'Bubba', 'last_name' => 'Smith', 'birth_date' => '1975-01-12'), array('id' => 1003, 'first_name' => 'Ted', 'last_name' => 'Smith', 'birth_date' => '1971-11-21'));
     $options = array('form' => array('id' => 'data-form', 'action' => '/some-action', 'method' => 'post', 'process' => '<input type="checkbox" name="rm_users[]" id="rm_users[{i}]" value="[{id}]" />', 'submit' => array('class' => 'submit-btn', 'value' => 'Remove?')), 'table' => array('cellpadding' => 0, 'cellspacing' => 0, 'border' => 0, 'class' => 'data-table'), 'last_name' => '<a href="/edit/[{id}]">[{last_name}]</a>');
     $html = Html::encode($data, $options);
     $this->assertContains('<form id="data-form"', $html);
     $this->assertContains('<tr><th class="first-th">Id</th><th>First Name</th><th>Last Name</th><th>Birth Date</th><th class="last-th">Remove?</th></tr>', $html);
     $this->assertContains('<tr><td class="first-td">1001</td><td>Bob</td><td><a href="/edit/1001">Smith</a></td><td>Aug 19, 1977</td><td class="last-td"><input type="checkbox" name="rm_users[]" id="rm_users1" value="1001" /></td></tr>', $html);
     $this->assertContains('<tr class="table-bottom-row"><td colspan="5" class="table-bottom-row"><input type="submit" name="submit" id="submit" class="submit-btn" value="Remove?" /></td></tr>', $html);
 }
예제 #4
0
 /**
  * Get all roles method
  *
  * @param  string $sort
  * @param  string $page
  * @return void
  */
 public function getAll($sort = null, $page = null)
 {
     $order = $this->getSortOrder($sort, $page);
     $order['field'] = $order['field'] == 'id' ? DB_PREFIX . 'user_sessions.id' : $order['field'];
     // Create SQL object to get session data
     $sql = Table\UserSessions::getSql();
     $sql->select(array(0 => DB_PREFIX . 'user_sessions.id', 1 => DB_PREFIX . 'user_types.type', 2 => DB_PREFIX . 'users.username', 3 => DB_PREFIX . 'user_sessions.ip', 4 => DB_PREFIX . 'user_sessions.user_id', 5 => DB_PREFIX . 'user_sessions.ua', 6 => DB_PREFIX . 'user_sessions.start', 7 => DB_PREFIX . 'users.type_id'))->join(DB_PREFIX . 'users', array('user_id', 'id'), 'LEFT JOIN')->join(DB_PREFIX . 'user_types', array(DB_PREFIX . 'users.type_id', 'id'), 'LEFT JOIN')->orderBy($order['field'], $order['order']);
     if (null !== $order['limit']) {
         $sql->select()->limit($order['limit'])->offset($order['offset']);
     }
     $searchByMarked = null;
     $searchByAry = array();
     $types = Table\UserTypes::findAll();
     foreach ($types->rows as $type) {
         $searchByAry[$type->id] = $type->type;
     }
     if (isset($_GET['search_by'])) {
         $count = Table\UserSessions::getCountOfType((int) $_GET['search_by']);
         $searchByMarked = (int) $_GET['search_by'];
         $sql->select()->where()->equalTo('type_id', (int) $_GET['search_by']);
     } else {
         $count = Table\UserSessions::getCount();
     }
     // Execute SQL query
     $sessions = Table\UserSessions::execute($sql->render(true));
     if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\User\\SessionsController', 'remove')) {
         $removeCheckbox = '<input type="checkbox" name="remove_sessions[]" id="remove_sessions[{i}]" value="[{id}]" />';
         $removeCheckAll = '<input type="checkbox" id="checkall" name="checkall" value="remove_sessions" />';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'));
     } else {
         $removeCheckbox = '&nbsp;';
         $removeCheckAll = '&nbsp;';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'), 'style' => 'display: none;');
     }
     if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\User\\IndexController', 'edit')) {
         $username = '******' . BASE_PATH . APP_URI . '/users/edit/[{user_id}]">[{username}]</a>';
     } else {
         $username = '******';
     }
     $options = array('form' => array('id' => 'session-remove-form', 'action' => BASE_PATH . APP_URI . '/users/sessions/remove', 'method' => 'post', 'process' => $removeCheckbox, 'submit' => $submit), 'table' => array('headers' => array('id' => '<a href="' . BASE_PATH . APP_URI . '/users/sessions?sort=id">#</a>', 'type' => '<a href="' . BASE_PATH . APP_URI . '/users/sessions?sort=type">' . $this->i18n->__('Type') . '</a>', 'username' => '<a href="' . BASE_PATH . APP_URI . '/users/sessions?sort=type">' . $this->i18n->__('Username') . '</a>', 'ip' => $this->i18n->__('IP'), 'ua' => $this->i18n->__('User Agent'), 'started' => '<a href="' . BASE_PATH . APP_URI . '/users/sessions?sort=start">' . $this->i18n->__('Started') . '</a>', 'process' => $removeCheckAll), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'date' => $this->config->datetime_format, 'exclude' => array('type_id', 'user_id', 'start', 'process' => array('id' => $this->data['user']->sess_id)), 'username' => $username, 'indent' => '        ');
     $sessAry = array();
     foreach ($sessions->rows as $session) {
         $session->started = date($this->config->datetime_format, strtotime($session->start)) . ' (' . \Pop\Feed\Format\AbstractFormat::calculateTime($session->start) . ')';
         $sessAry[] = $session;
     }
     if (isset($sessAry[0])) {
         $this->data['table'] = Html::encode($sessAry, $options, $this->config->pagination_limit, $this->config->pagination_range, $count);
         $this->data['searchBy'] = new \Pop\Form\Element\Select('search_by', $searchByAry, $searchByMarked);
     }
 }
예제 #5
0
 /**
  * Get user by ID method
  *
  * @param  int     $id
  * @return void
  */
 public function getLoginsById($id)
 {
     // Get user logins
     $this->getById($id);
     $logins = unserialize($this->logins);
     $loginsAry = array();
     $i = 1;
     foreach ($logins as $time => $login) {
         $loginsAry[] = array('id' => $i, 'timestamp' => date('D  M j, Y H:i:s', $time), 'user_agent' => $login['ua'], 'ip_address' => $login['ip']);
         $i++;
     }
     $options = array('form' => array('id' => 'user-login-remove-form', 'action' => BASE_PATH . APP_URI . '/users/logins/' . $this->id . '?type_id=' . $this->type_id, 'method' => 'post', 'process' => '&nbsp;', 'submit' => array('class' => 'remove-btn', 'value' => $this->i18n->__('Clear'))), 'table' => array('headers' => array('id' => '#', 'ip_address' => $this->i18n->__('IP Address'), 'process' => '&nbsp;'), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'date' => 'D  M j, Y H:i:s');
     $this->data['table'] = Html::encode($loginsAry, $options, $this->config()->pagination_limit, $this->config()->pagination_range);
 }
예제 #6
0
 /**
  * Get all roles method
  *
  * @param  string $sort
  * @param  string $page
  * @return void
  */
 public function getAll($sort = null, $page = null)
 {
     $order = $this->getSortOrder($sort, $page);
     $order['field'] = $order['field'] == 'id' ? DB_PREFIX . 'user_roles.id' : $order['field'];
     // Create SQL object to get role data
     $sql = Table\UserRoles::getSql();
     $sql->select(array(DB_PREFIX . 'user_roles.id', DB_PREFIX . 'user_roles.type_id', DB_PREFIX . 'user_types.type', DB_PREFIX . 'user_roles.name'))->join(DB_PREFIX . 'user_types', array('type_id', 'id'), 'LEFT JOIN')->orderBy($order['field'], $order['order']);
     if (null !== $order['limit']) {
         $sql->select()->limit($order['limit'])->offset($order['offset']);
     }
     // Execute SQL query
     $roles = Table\UserRoles::execute($sql->render(true));
     if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\User\\RolesController', 'remove')) {
         $removeCheckbox = '<input type="checkbox" name="remove_roles[]" id="remove_roles[{i}]" value="[{id}]" />';
         $removeCheckAll = '<input type="checkbox" id="checkall" name="checkall" value="remove_roles" />';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'));
     } else {
         $removeCheckbox = '&nbsp;';
         $removeCheckAll = '&nbsp;';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'), 'style' => 'display: none;');
     }
     $options = array('form' => array('id' => 'role-remove-form', 'action' => BASE_PATH . APP_URI . '/users/roles/remove', 'method' => 'post', 'process' => $removeCheckbox, 'submit' => $submit), 'table' => array('headers' => array('id' => '<a href="' . BASE_PATH . APP_URI . '/users/roles?sort=id">#</a>', 'edit' => '<span style="display: block; margin: 0 auto; width: 100%; text-align: center;">' . $this->i18n->__('Edit') . '</span>', 'type' => '<a href="' . BASE_PATH . APP_URI . '/users/roles?sort=type">' . $this->i18n->__('Type') . '</a>', 'name' => '<a href="' . BASE_PATH . APP_URI . '/users/roles?sort=name">' . $this->i18n->__('Role') . '</a>', 'process' => $removeCheckAll), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'exclude' => array('type_id', 'process' => array('id' => $this->data['user']->role_id)), 'indent' => '        ');
     if (isset($roles->rows[0])) {
         $rolesAry = array();
         foreach ($roles->rows as $role) {
             if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\User\\RolesController', 'edit')) {
                 $edit = '<a class="edit-link" title="' . $this->i18n->__('Edit') . '" href="' . BASE_PATH . APP_URI . '/users/roles/edit/' . $role->id . '">Edit</a>';
             } else {
                 $edit = null;
             }
             $rAry = array('id' => $role->id, 'name' => $role->name, 'type' => $role->type);
             if (null !== $edit) {
                 $rAry['edit'] = $edit;
             }
             $rolesAry[] = $rAry;
         }
         $this->data['table'] = Html::encode($rolesAry, $options, $this->config->pagination_limit, $this->config->pagination_range, Table\UserRoles::getCount());
     }
 }
예제 #7
0
파일: data3.php 프로젝트: nicksagona/PopPHP
<?php

require_once '../../bootstrap.php';
use Pop\Data;
try {
    $data = array(array('id' => 1001, 'first_name' => 'Bob', 'last_name' => 'Smith', 'birth_date' => '1977-08-19'), array('id' => 1002, 'first_name' => 'Bubba', 'last_name' => 'Smith', 'birth_date' => '1975-01-12'), array('id' => 1003, 'first_name' => 'Ted', 'last_name' => 'Smith', 'birth_date' => '1971-11-21'));
    $options = array('form' => array('id' => 'data-form', 'action' => '/some-action', 'method' => 'post', 'process' => '<input type="checkbox" name="rm_users[]" id="rm_users[{i}]" value="[{id}]" />', 'submit' => array('class' => 'submit-btn', 'value' => 'Remove?')), 'table' => array('cellpadding' => 0, 'cellspacing' => 0, 'border' => 0, 'class' => 'data-table'), 'last_name' => '<a href="/edit/[{id}]">[{last_name}]</a>');
    $html = Data\Type\Html::encode($data, $options);
    echo $html;
} catch (\Exception $e) {
    echo $e->getMessage();
}
예제 #8
0
 /**
  * Get all fields method
  *
  * @param  string $sort
  * @param  string $page
  * @return void
  */
 public function getAll($sort = null, $page = null)
 {
     $order = $this->getSortOrder($sort, $page);
     $fields = Table\Fields::findAll($order['field'] . ' ' . $order['order'], null, $order['limit'], $order['offset']);
     if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\Structure\\FieldsController', 'remove')) {
         $removeCheckbox = '<input type="checkbox" name="remove_fields[]" id="remove_fields[{i}]" value="[{id}]" />';
         $removeCheckAll = '<input type="checkbox" id="checkall" name="checkall" value="remove_fields" />';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'));
     } else {
         $removeCheckbox = '&nbsp;';
         $removeCheckAll = '&nbsp;';
         $submit = array('class' => 'remove-btn', 'value' => $this->i18n->__('Remove'), 'style' => 'display: none;');
     }
     if ($this->data['acl']->isAuth('Phire\\Controller\\Phire\\Structure\\FieldsController', 'edit')) {
         $edit = '<a class="edit-link" title="' . $this->i18n->__('Edit') . '" href="' . BASE_PATH . APP_URI . '/structure/fields/edit/[{id}]">Edit</a>';
     } else {
         $edit = null;
     }
     $options = array('form' => array('id' => 'field-remove-form', 'action' => BASE_PATH . APP_URI . '/structure/fields/remove', 'method' => 'post', 'process' => $removeCheckbox, 'submit' => $submit), 'table' => array('headers' => array('id' => '<a href="' . BASE_PATH . APP_URI . '/structure/fields?sort=id">#</a>', 'edit' => '<span style="display: block; margin: 0 auto; width: 100%; text-align: center;">' . $this->i18n->__('Edit') . '</span>', 'type' => '<a href="' . BASE_PATH . APP_URI . '/structure/fields?sort=type">' . $this->i18n->__('Type') . '</a>', 'name' => '<a href="' . BASE_PATH . APP_URI . '/structure/fields?sort=name">' . $this->i18n->__('Name') . '</a>', 'order' => '<a href="' . BASE_PATH . APP_URI . '/structure/fields?sort=order">' . $this->i18n->__('Order') . '</a>', 'process' => $removeCheckAll), 'class' => 'data-table', 'cellpadding' => 0, 'cellspacing' => 0, 'border' => 0), 'separator' => '', 'exclude' => array('group_id', 'values', 'default_values', 'attributes', 'validators', 'encryption', 'editor', 'models'), 'indent' => '        ');
     $fieldsAry = array();
     foreach ($fields->rows as $field) {
         $fAry = array('id' => $field->id);
         $fAry['type'] = $field->type;
         $fAry['name'] = $field->name;
         $fAry['label'] = $field->label;
         $fAry['required'] = $field->required ? $this->i18n->__('Yes') : $this->i18n->__('No');
         $fAry['order'] = $field->order;
         if (null !== $edit) {
             $fAry['edit'] = str_replace('[{id}]', $field->id, $edit);
         }
         $fieldsAry[] = $fAry;
     }
     if (isset($fieldsAry[0])) {
         $this->data['table'] = Html::encode($fieldsAry, $options, $this->config->pagination_limit, $this->config->pagination_range, Table\Fields::getCount());
     }
 }