コード例 #1
0
ファイル: Batch.php プロジェクト: vigm/advancedMD
 /**
  * @param Builder $builder  Query to batch
  */
 public function __construct(Builder $builder)
 {
     $this->builder = $builder;
     $this->starting_offset = (int) $builder->getOffset();
     // TODO technically have a bit of a 32 vs 64 bit snafu here
     $this->maximum_size = (int) $builder->getLimit();
 }
コード例 #2
0
ファイル: Username.php プロジェクト: vigm/advancedMD
 /**
  * Sets the Query Builder property and builds a username list assuming
  * there are no more than 25 users available and assuming no usernames
  * were provided in the constructor.
  *
  * @param Query $builder A Query Builder object
  * @return void
  */
 public function setQuery(Builder $builder)
 {
     $this->builder = $builder;
     // Do not overwrite any provided/set usernames and only fetch and
     // display members if there are 25 or less
     if (!empty($this->options) || $builder->count() > 25) {
         return;
     }
     $members = $builder->all();
     if ($members) {
         $options = array();
         foreach ($members as $member) {
             $options[$member->member_id] = $member->username;
         }
         $this->options = $options;
     }
 }
コード例 #3
0
ファイル: Comments.php プロジェクト: vigm/advancedMD
 /**
  * Builds a Table object from a Query of Comment model entitites
  *
  * @param Builder $comments A Query\Builder object for Comment model entities
  * @return Table A Table instance
  */
 private function buildTableFromCommentQuery(Builder $comments)
 {
     ee()->load->helper('text');
     $table = ee('CP/Table');
     $table->setColumns(array('column_comment' => array('encode' => FALSE), 'column_comment_date', 'column_ip_address', 'column_status' => array('type' => Table::COL_STATUS), 'manage' => array('type' => Table::COL_TOOLBAR), array('type' => Table::COL_CHECKBOX)));
     $table->setNoResultsText(lang('no_comments'));
     $comments->order(str_replace('column_', '', $table->sort_col), $table->sort_dir);
     $data = array();
     $comment_id = ee()->session->flashdata('comment_id');
     foreach ($comments->all() as $comment) {
         switch ($comment->status) {
             case 'o':
                 $status = lang('open');
                 break;
             case 'c':
                 $status = lang('closed');
                 break;
             case 's':
                 $status = lang('spam');
                 break;
             default:
                 $status = lang("pending");
         }
         $toolbar = array();
         // You get an edit button if you can edit all comments or you can
         // edit your own comments and this comment is one of yours
         if (ee()->cp->allowed_group('can_edit_all_comments') || ee()->cp->allowed_group('can_edit_own_comments') && ($comment->author_id = ee()->session->userdata('member_id'))) {
             $toolbar = array('edit' => array('href' => ee('CP/URL')->make('publish/comments/edit/' . $comment->comment_id), 'title' => lang('edit')));
         }
         $column = array(ee('View')->make('publish/comments/partials/title')->render(array('comment' => $comment)), ee()->localize->human_time($comment->comment_date), $comment->ip_address, $status, array('toolbar_items' => $toolbar), array('name' => 'selection[]', 'value' => $comment->comment_id, 'data' => array('confirm' => lang('comment') . ': <b>' . htmlentities(ellipsize($comment->comment, 50), ENT_QUOTES, 'UTF-8') . '</b>')));
         $attrs = array();
         if ($comment_id && $comment->comment_id == $comment_id) {
             $attrs = array('class' => 'selected');
         }
         $data[] = array('attrs' => $attrs, 'columns' => $column);
     }
     $table->setData($data);
     return $table;
 }
コード例 #4
0
ファイル: AbstractChannels.php プロジェクト: vigm/advancedMD
 /**
  * Builds and returns a Table object for use of displaying a list of channel field groups
  *
  * @param	Builder 	$groups		Query builder object for channel field groups
  * @param	array 		$config		Optional Table class config overrides
  * @param	boolean 	$mutable	Whether or not the data in the table is mutable, currently
  *	determines whether or not checkboxes will be shown
  */
 protected function buildTableFromChannelGroupsQuery(Builder $groups, $config = array(), $mutable = TRUE)
 {
     $table = ee('CP/Table', array_merge(array('autosort' => TRUE), $config));
     $columns = array('group_name', 'manage' => array('type' => Table::COL_TOOLBAR));
     if ($mutable) {
         $columns[] = array('type' => Table::COL_CHECKBOX);
     }
     $table->setColumns($columns);
     $table->setNoResultsText('no_field_groups', 'create_new', ee('CP/URL')->make('channels/fields/groups/create'));
     $data = array();
     $group_id = ee()->session->flashdata('group_id');
     foreach ($groups->all() as $group) {
         $edit_url = ee('CP/URL')->make('channels/fields/groups/edit/' . $group->group_id);
         $column = array(array('content' => $group->group_name, 'href' => $edit_url), array('toolbar_items' => array('edit' => array('href' => $edit_url, 'title' => lang('edit')), 'txt-only' => array('href' => ee('CP/URL')->make('channels/fields/' . $group->group_id), 'title' => lang('custom_fields'), 'content' => strtolower(lang('fields'))))));
         if (!ee()->cp->allowed_group('can_edit_channel_fields')) {
             unset($column[0]['href']);
             unset($column[1]['toolbar_items']['edit']);
         }
         if ($mutable) {
             $column[] = array('name' => 'selection[]', 'value' => $group->group_id, 'data' => array('confirm' => lang('group') . ': <b>' . htmlentities($group->group_name, ENT_QUOTES, 'UTF-8') . '</b>'));
         }
         $attrs = array();
         if ($group_id && $group->group_id == $group_id) {
             $attrs = array('class' => 'selected');
         }
         $data[] = array('attrs' => $attrs, 'columns' => $column);
     }
     $table->setData($data);
     return $table;
 }
コード例 #5
0
ファイル: DataStore.php プロジェクト: vigm/advancedMD
 /**
  * Create a query
  *
  * @param String $name  Name of the model to query on
  */
 public function get($name)
 {
     $object = NULL;
     if ($name instanceof Model) {
         $object = $name;
         $name = $object->getName();
     }
     $builder = new Builder($name);
     $builder->setExisting($object);
     $builder->setDataStore($this);
     return $builder;
 }