/** * Applies sorting to data provider. */ public function apply() { $input = $this->grid->getInputProcessor()->getInput(); $sort = null; if (isset($input['sort'])) { foreach ($input['sort'] as $field => $direction) { $sort = [$field, $direction]; break; } } foreach ($this->grid->getConfig()->getColumns() as $column) { if ($sort) { if ($column->getName() === $sort[0]) { $column->setSorting($sort[1]); } else { $column->setSorting(null); } } else { if ($direction = $column->getSorting()) { $sort = [$column->getName(), $direction]; } } } if ($sort) { $this->grid->getConfig()->getDataProvider()->orderBy($sort[0], $sort[1]); } }
public function writeGrid(Grid $grid) { if (!$grid->isLoaded()) { $this->Torpor()->throwException($this->Torpor()->containerKeyName($grid) . ' grid not loaded (can only cache loaded grids)'); } return $this->_memcache->set($this->makeGridKey($grid), $grid->dumpArray(true), $this->getCompression() ? MEMCACHE_COMPRESSED : null, $this->getTTL()); }
public function indexAction() { $page = $this->request->queryString("page"); if (empty($page)) { $page = "1"; } $model = $this->model->get('feedback'); $totalRecord = $model->getTotalRecord(1); $this->view->data['page'] = $page; $this->view->data['totalRecord'] = $totalRecord; $this->view->data['pageSize'] = 10; $this->view->data['users'] = $model->getAll($page, $this->view->data['pageSize'], null); $grid = new Grid($this->view->data['users']); $grid->setModule('admin'); $grid->setController('feedback'); $grid->setTotalRecord($totalRecord); $grid->setPageSize($this->view->data['pageSize']); $grid->setPage($page); $grid->addColumn(array('header' => 'ID', 'align' => 'center', 'width' => '', 'index' => 'id')); $grid->addColumn(array('header' => 'Họ tên', 'align' => 'left', 'width' => '', 'index' => 'fullname')); $grid->addColumn(array('header' => 'Thư điện tử', 'align' => 'center', 'width' => '', 'index' => 'email')); $grid->addColumn(array('header' => 'Điện thoại', 'align' => 'center', 'width' => '', 'index' => 'phone')); $this->view->data['grid'] = $grid; $this->view->show('index'); }
public function index() { if (!isAuth(209)) { return; } $this->view->clientsJS("matiere" . DS . "index"); $matieres = $this->Matiere->selectAll(); /* $this->Assign("content", (new View())->output( array('matieres' => $matieres, 'errors' => false), false)); */ $grid = new Grid($matieres, 0); $grid->addcolonne(0, 'IDMATIERE', 'IDMATIERE', false); $grid->addcolonne(1, 'Code', 'CODE', TRUE); $grid->addcolonne(2, 'Libellé', 'LIBELLE', TRUE); $grid->droitdelete = 515; $grid->droitedit = 514; $grid->editbutton = true; $grid->dataTable = "tableMatieres"; $grid->editbuttontext = "Editer"; $grid->deletebutton = true; $grid->deletebuttontext = "Supprimer"; $grid->selectbutton = false; $total = count($matieres); $this->Assign("content", (new View())->output(array("matieres" => $grid->display(), "errors" => false, "total" => $total), false)); }
public function indexAction() { $page = $this->request->queryString("page"); if (empty($page)) { $page = "1"; } $userModel = $this->model->get('user'); $totalRecord = $userModel->getTotalRecord(1); $this->view->data['page'] = $page; $this->view->data['totalRecord'] = $totalRecord; $this->view->data['pageSize'] = 10; $this->view->data['users'] = $userModel->getUser($page, $this->view->data['pageSize'], null); $grid = new Grid($this->view->data['users']); $grid->setModule('admin'); $grid->setController('user'); $grid->setTotalRecord($totalRecord); $grid->setPageSize($this->view->data['pageSize']); $grid->setPage($page); $grid->addColumn(array('header' => 'ID', 'align' => 'center', 'width' => '', 'index' => 'id')); $grid->addColumn(array('header' => 'Tên truy cập', 'align' => 'left', 'width' => '', 'index' => 'username')); $grid->addColumn(array('header' => 'Tên hiển thị', 'align' => 'center', 'width' => '', 'index' => 'display_name')); $grid->addColumn(array('header' => 'Email', 'align' => 'center', 'width' => '', 'index' => 'email')); $this->view->data['grid'] = $grid; $this->view->show('index'); }
function RenderGrid(Grid $grid) { $hiddenValues = array(OPERATION_PARAMNAME => OPERATION_COMMIT); AddPrimaryKeyParametersToArray($hiddenValues, $grid->GetDataset()->GetPrimaryKeyValues()); $template = $grid->GetPage()->GetCustomTemplate(PagePart::VerticalGrid, PageMode::Edit, 'edit/grid.tpl'); $this->DisplayTemplate($template, array('Grid' => $grid->GetEditViewData($this)), array('Authentication' => $grid->GetPage()->GetAuthenticationViewData(), 'HiddenValues' => $hiddenValues)); }
function helper_not_in_wh_pr_grid_build(Grid $grid, $wh_id) { $grid->add_column(array('index' => 'sku', 'searchtable' => 'A', 'type' => 'text', 'tdwidth' => '15%', 'filter' => true), 'Артикул'); $grid->add_column(array('index' => 'name', 'searchtable' => 'B', 'type' => 'text', 'filter' => true), 'Название'); $grid->add_column(array('index' => 'status', 'searchtable' => 'A', 'type' => 'select', 'options' => array('' => '', '0' => 'Нет', '1' => 'Да'), 'tdwidth' => '9%', 'filter' => true), 'В поиске'); $grid->add_column(array('index' => 'action', 'type' => 'action', 'tdwidth' => '10%', 'option_string' => 'align="center"', 'sortable' => false, 'filter' => false, 'actions' => array(array('type' => 'link', 'html' => '', 'href' => set_url(array('warehouse', 'warehouses_products', 'add_exist_pr', 'wh_id', $wh_id, 'pr_id', '$1')), 'href_values' => array('ID'), 'options' => array('class' => 'icon_plus', 'title' => 'Добавить выбраный продукт')))), 'Действие'); }
public function RenderGrid(Grid $grid) { $hiddenValues = array(OPERATION_PARAMNAME => OPERATION_COMMIT_INSERT); $customParams = array(); $template = $grid->GetPage()->GetCustomTemplate(PagePart::VerticalGrid, PageMode::Insert, 'insert/grid.tpl', $customParams); $this->DisplayTemplate($template, array('Grid' => $grid->GetInsertViewData($this)), array_merge($customParams, array('Authentication' => $grid->GetPage()->GetAuthenticationViewData(), 'HiddenValues' => $hiddenValues))); }
public function searchresultAction() { $page = $this->request->queryString("page"); if (empty($page)) { $page = "1"; } $key = $this->request->getParam('txtKey'); if (!isset($key)) { $key = ''; } else { $key = trim($key); } $totalRecord = $this->model->get('product')->getTotalResult($key); $this->view->data['page'] = $page; $this->view->data['totalRecord'] = $totalRecord; $this->view->data['pageSize'] = 10; $this->view->data['products'] = $this->model->get('product')->getSearchResults($key, $page, $this->view->data['pageSize']); $grid = new Grid($this->view->data['products']); $grid->setModule('admin'); $grid->setController('product'); $grid->setTotalRecord($totalRecord); $grid->setPageSize($this->view->data['pageSize']); $grid->setPage($page); $grid->addColumn(array('header' => 'Tiêu đề bài viết', 'align' => 'left', 'width' => '', 'index' => 'title')); $grid->addColumn(array('header' => 'URL key', 'align' => 'left', 'width' => '', 'index' => 'url_key')); $grid->addColumn(array('header' => 'Xuất bản', 'align' => 'center', 'width' => '140', 'index' => 'public_time')); $grid->addColumn(array('header' => 'Thứ tự', 'align' => 'center', 'width' => '60', 'index' => 'priority')); $this->view->data['grid'] = $grid; $this->view->show('search'); }
protected function SetGridSimpleErrorMessage($message, $decodeMessage = true) { if ($decodeMessage) { $this->grid->SetErrorMessage($this->GetPage()->RenderText($message)); } else { $this->grid->SetErrorMessage($message); } }
public function __invoke() { $grid = new Grid(); $santa = new Santa($grid); $elf = new Elf($santa); $input = file_get_contents(__DIR__ . '/../../input/Day3/input.txt'); $elf->readDirections($input); $visitedHouses = $grid->getVisitedHouses(); echo "Total visited houses: " . $visitedHouses . "\n\n"; }
function index() { if (!isAuth(203)) { return; } $this->view->clientsJS("personnel" . DS . "personnel"); $data = $this->Fonction->selectAll(); $fonctions = new Combobox($data, "fonction", "IDFONCTION", "LIBELLE"); $fonctions->first = "Toutes"; $fonctions->onchange = "showPersonnelByFunction();"; $data = $this->Personnel->selectAll(); $personnels = new Grid($data, 0); $personnels->addcolonne(0, "IDPERSONNEL", "IDPERSONNEL", false); $personnels->addcolonne(1, "Civ", "CIVILITE"); $personnels->addcolonne(2, "Matricule", "MATRICULE"); $personnels->addcolonne(3, "Nom", "NOM"); $personnels->addcolonne(4, "Prénom", "PRENOM"); $personnels->addcolonne(5, "Fonction", "LIBELLE"); $personnels->addcolonne(6, "Portable", "PORTABLE"); $personnels->droitdelete = 507; $personnels->droitedit = 513; $personnels->dataTable = "tablePersonnel"; $personnels->actionbutton = true; $personnels->deletebutton = true; $personnels->editbutton = true; $total = count($data); $this->Assign("content", (new View())->output(["fonctions" => $fonctions->view("50%"), "personnels" => $personnels->display(), "total" => $total], false)); }
public function index() { if (!isAuth(211)) { return; } $this->view->clientsJS("frais" . DS . "index"); $view = new View(); $frais = $this->Frais->getFrais($this->session->anneeacademique); $grid = new Grid($frais, 0); $grid->addcolonne(0, "IDFRAIS", "IDFRAIS", false); $grid->addcolonne(1, "Classe", "LIBELLE"); $grid->addcolonne(2, "Niveau", "NIVEAUHTML"); $grid->addcolonne(3, "Description du frais", "DESCRIPTION"); $grid->addcolonne(4, "Montant", "MONTANT"); $grid->addcolonne(5, "Echéances", "ECHEANCES"); $grid->dataTable = "fraisTable"; $grid->actionbutton = true; $grid->deletebutton = true; $grid->droitdelete = 510; $grid->droitedit = 511; $grid->setColDate(5); $view->Assign("frais", $grid->display()); $content = $view->Render("frais" . DS . "index", false); $this->Assign("content", $content); }
/** * * Create resource for json data answer * @param Data\IGridRepository $repository * @param Conditions $conditions * @param Grid $grid * * @return stdClass */ private static function createResource($repository, $conditions, $grid) { $resource = new \stdClass(); if ($repositoryData = $repository->getData($conditions)) { $resource->rows = self::adaptRepositoryData($repositoryData, $grid->getSortName(), $grid->getColumnCollection()); } $resource->records = (string) $repository->countDataRows($conditions); $resource->page = (string) $conditions->page; //Total pages $resource->total = $resource->records > 0 ? ceil($resource->records / $conditions->rowsLimit) : 0; return $resource; }
/** * Create a new grid from a 9*9 array of values * * @param array $rows * * @return Grid */ public static function fromArray(array $rows) { $grid = new Grid(); $grid->validateRows($rows); foreach ($rows as $y => $row) { $grid->validateRow($y, $row); foreach ($row as $x => $value) { $grid->validateCellDoesntExist($grid, $x, $y); $grid->addCell($x, $y, $value); } } return $grid; }
public function __invoke() { $light = new Light(); $grid = new Grid(1000, 1000, $light); $parser = new InstructionParser(); $input = file(__DIR__ . '/../../input/Day6/input.txt'); foreach ($input as $line) { // Parse instruction, pass to grid $commands = $parser->parseLine($line); $grid->doOperation($commands[0], $commands[1], $commands[2], $commands[3], $commands[4]); } $numberOfLights = $grid->getTotalBrightness(); echo "Total brightness: " . $numberOfLights . "\n\n"; }
public function parse($ex_file, $s_file) { global $VERSION; $css = file_get_contents($s_file); $ex = parse_ini_file($ex_file, TRUE); print "<style>"; print "\n/* Generated by exCSS v." . $VERSION . "*/\n"; if (isset($ex['ExtendedCSS'])) { while ($cur = current($ex['ExtendedCSS'])) { $var = key($ex['ExtendedCSS']); $var_value = $ex['ExtendedCSS'][$var]; $css = str_replace("\$" . $var, $var_value, $css); next($ex['ExtendedCSS']); } } if (isset($ex['Grid'])) { $parts = $ex['Grid']['grid-parts']; // how many parts like 1 or 4 $height = $ex['Grid']['grid-height']; // height like 50% or 100% $props = $ex['Grid']['grid-props']; // proportions like 1-2-1 or 2-3-2 $grid = new Grid($parts, $height, $props); } foreach (array_keys($ex) as $x) { if ($x == 'Grid' || $x == 'ExtendedCSS') { continue; } // now there can only be things like .div1 or #div2 or div if (isset($ex["Grid"])) { if (isset($ex[$x]['grid-position'])) { $element_data = $grid->generateCSS($x, $ex[$x]['grid-position']); print $element_data; } } if (isset($ex[$x]["animation"])) { $object = $x; $anim_name = $ex[$x]["animation"]; $par = explode(';', $ex[$x]['animation-parameter']); $parameter = new Parameter(); foreach ($par as $i) { $temp = explode(':', $i); $parameter->add($temp[0], $temp[1]); } $anim = new Animation($anim_name, $object, $parameter); } } print "\n" . $css . "\n\n.container{\n\n\tdisplay: table;\n\twidth:100%;\n\theight:100%;\n\n}\n\n</style>\n"; }
function helper_invoices_grid_build(Grid $grid) { $grid->add_button('Заказы', set_url('*/orders')); $grid->add_column(array('index' => 'invoices_number', 'searchtable' => 'A', 'type' => 'text', 'tdwidth' => '14%', 'sortable' => true, 'filter' => true), 'Номер инвойса'); $grid->add_column(array('index' => 'orders_number', 'searchtable' => 'B', 'type' => 'text', 'tdwidth' => '13%', 'sortable' => true, 'filter' => true), 'Номер заказа'); $grid->add_column(array('index' => 'total', 'type' => 'text'), 'Сумма'); $grid->add_column(array('index' => 'create_date', 'type' => 'date', 'tdwidth' => '11%', 'sortable' => true, 'filter' => true), 'Создан'); $grid->add_column(array('index' => 'update_date', 'type' => 'date', 'tdwidth' => '11%', 'sortable' => true, 'filter' => true), 'Обновлен'); $grid->add_column(array('index' => 'invoices_status', 'type' => 'select', 'options' => array('' => '') + Minvoices::get_invoice_state_collection(), 'tdwidth' => '12%', 'filter' => true), 'Состояние'); $grid->add_column(array('index' => 'action', 'type' => 'action', 'tdwidth' => '10%', 'option_string' => 'align="center"', 'sortable' => false, 'filter' => false, 'actions' => array(array('type' => 'link', 'html' => '', 'href' => set_url('*/*/view_invoice/inv_id/$1'), 'href_values' => array('ID'), 'options' => array('class' => 'icon_view', 'title' => 'Просмотр')))), 'Actions'); }
public function output(Grid $grid) { $this->history = $grid->getHistory(); $this->grid = $grid; $output = '<table>'; $size = $grid->getSize(); for ($y = 1; $y <= $size; $y++) { $output .= '<tr>'; for ($x = 1; $x <= $size; $x++) { $output .= $this->getPlayableColumn($x, $y); } $output .= '</tr>'; } return $output; }
function helper_wh_shippings_grid_build(Grid $grid) { $CI =& get_instance(); $CI->load->model('warehouse/mwarehouses'); $wh_array = $CI->mwarehouses->get_wh_to_select(); $grid->add_column(array('index' => 'wh_shipping_number', 'type' => 'text', 'filter' => true, 'tdwidth' => '10%'), 'Номер'); $grid->add_column(array('index' => 'wh_sale_number', 'type' => 'text', 'searchtable' => 'B', 'tdwidth' => '10%', 'filter' => true), 'Номер продажи'); $grid->add_column(array('index' => 'total_qty', 'type' => 'text', 'tdwidth' => '7%'), 'К-во'); $grid->add_column(array('index' => 'total', 'type' => 'text'), 'Сумма'); $grid->add_column(array('index' => 'wh_alias', 'type' => 'select', 'searchtable' => 'C', 'searchname' => 'alias', 'options' => array('' => '') + $wh_array, 'filter' => true, 'tdwidth' => '10%'), 'Склад'); $grid->add_column(array('index' => 'wh_shipping_state', 'type' => 'text', 'tdwidth' => '10%'), 'Статус отправки'); $grid->add_column(array('index' => 'create_date', 'searchtable' => 'A', 'type' => 'date', 'tdwidth' => '12%', 'filter' => true), 'Дата создания'); $grid->add_column(array('index' => 'update_date', 'searchtable' => 'A', 'type' => 'date', 'tdwidth' => '12%', 'filter' => true), 'Дата обновления'); $grid->add_column(array('index' => 'action', 'type' => 'action', 'tdwidth' => '10%', 'option_string' => 'align="center"', 'actions' => array()), 'Действия'); }
public function gridToHTML(Grid $grid, CartesianRegion $region) { $tile_size = $this->computeTileSize($region->getWidth(), $region->getHeight()); $output = ''; $gridWidth = $region->getWidth() * $this->tile_size; $gridHeight = $region->getHeight() * $this->tile_size; $output .= '<div id="box" style="width: ' . $gridWidth . 'px; height:' . $gridHeight . 'px;">'; foreach (new RegionIterator($region) as $coordinates) { $tile = $grid->getTile($coordinates); $screenCoords = $this->coordsToScreen($coordinates, $region); $output .= $this->tileToHTML($tile, $screenCoords, $coordinates); } $output .= '</div>'; return $output; }
function formatRow() { parent::formatRow(); $v = $this->add('View', 'v' . $this->current_row['id'], 'content')->set($this->current_row['name']); $v->js('click', array($this->map->js()->rvadym_gmap()->polygonsArray(null), $this->map->js()->rvadym_gmap()->polygonsCoords(null), $this->map->js()->rvadym_gmap()->drawPolygons($this->current_row['draw']))); $this->current_row_html['name'] = $v->getHTML(); }
public function output(Grid $grid) { $this->history = $grid->getHistory(); $this->grid = $grid; $output = ''; $size = $grid->getSize(); for ($y = 1; $y <= $size; $y++) { for ($x = 1; $x <= $size; $x++) { $output .= $this->getPlayableColumn($x, $y); } if ($size != $y) { $output .= "\n"; } } return $output; }
public function index($page = 1) { $db = new Database(); // You can assign anything variable to a view by using standard OOP // methods. In my welcome view, the $title variable will be assigned // the value I give it here. $this->template->title = 'Welcome to YAG demo!'; $grid = Grid::factory()->set('display_head', true)->set('display_foot', true)->set('display_body', true)->set('table_attributes', array('id' => 'demo_table_1', 'width' => '100%')); $grid->CheckboxField('id')->set('title', 'ID')->set('checked', array(2, 3, 4, 6, 9))->set('sortable', true)->set('foot', form::checkbox('checkall', 'yes', false, "onclick=\"check_all('id[]');\"") . form::dropdown('action', array('edit' => 'Edit', 'delete' => 'Delete'), 'edit') . form::submit('submit', 'OK'))->set('extra', array("onclick" => "checkbox_check('id[]')")); $grid->TextField('id')->set('title', 'ID')->set('sortable', true); $grid->TextField('text')->set('title', 'Text')->set('sortable', true); $grid->DateField('date')->set('title', 'Date')->set('format', 'Y-m-d')->set('sortable', true); $grid->ActionField()->set('title', 'Action')->add_action('edit', 'id', 'Edit', 'http://www.path.to/my/controller')->add_action('delete', 'id', 'Delete'); $offset = (int) ($page - 1) * 10; $offset = $offset < 0 ? 0 : $offset; $order_field = 'id'; $order_direction = 'asc'; if ($this->input->get('order_by') and $grid->field_exists($order_field, true)) { $order_field = $this->input->get('order_by'); } if ($this->input->get('order_direction') and in_array(strtoupper($this->input->get('order_direction')), array('ASC', 'DESC'))) { $order_direction = strtoupper($this->input->get('order_direction')); } $data = $db->select($grid->get_fields(true))->from('demotable')->limit(10)->offset($offset)->orderby($order_field, $order_direction)->get(); $count = $db->query('SELECT FOUND_ROWS() AS rows;')->current(); $this->pagination = new Pagination(array('total_items' => $count->rows, 'items_per_page' => 10)); $grid->set('extra_row_foot', '<td colspan="' . count($grid->fields) . '">' . $this->pagination->render() . '</td>'); $grid->set('data', $data); $html = $grid->render(); // Get Javascript for checkbox gimmicks $this->template->checkall_js = $grid->render_js('checkall'); $this->template->content = $html; }
function formatRow() { /* ------------------------------------- | | get additional data from DB | */ // Get data about sender if ($from_model = $this->config->getTypeModelClassName($this->current_row['from_type'])) { $from = $this->add($from_model)->tryLoad($this->current_row['from_id']); } else { $from['name'] = Model_Message::getFromTypes($this->current_row['from_type']); } // get data about receiver if ($to_model = $this->config->getTypeModelClassName($this->current_row['to_type'])) { $to = $this->add($to_model)->tryLoad($this->current_row['to_id']); } else { $to['name'] = Model_Message::getToTypes($this->current_row['to_type']); } /* ------------------------------------- | | compile HTML | */ $mixed_html = ''; $message_model = $this->config->getMessageModelClassName(); $mixed_html = $mixed_html . '<div class="' . $this->config->get('message-from-class') . '"><strong>From:</strong> ' . $from['name'] . ' (' . $message_model::getFromTypes($this->current_row['from_type']) . ') ' . ($this->current_row['from_is_deleted'] ? '*deleted*' : '') . '</div>'; $mixed_html = $mixed_html . '<div class="' . $this->config->get('message-to-class') . '"><strong>To:</strong> ' . $to['name'] . ' (' . $message_model::getToTypes($this->current_row['to_type']) . ') ' . ($this->current_row['to_is_deleted'] ? '*deleted*' : '') . '</div>'; $mixed_html = $mixed_html . '<div class="' . $this->config->get('message-text-class') . '">' . $this->current_row['text'] . '</div>'; $this->current_row_html['message'] = $mixed_html; parent::formatRow(); }
public function offsetSet($offset, $value) { if (in_array($offset, $this->corners)) { $value = ON; } parent::offsetSet($offset, $value); }
/** * Short description of method initOptions * * @access public * @author Somsack Sipasseuth, <*****@*****.**> * @return boolean */ public function initOptions($options = array()) { $returnValue = (bool) false; $columns = $this->grid->getColumns(); if (isset($options['columns'])) { foreach ($options['columns'] as $columnId => $columnOptions) { if (isset($columns[$columnId])) { foreach ($columnOptions as $optionsName => $optionsValue) { if ($optionsName == 'columns') { //if the options is columns, the options will be used to augment the subgrid model $columns = $this->grid->getColumns(); $subGridAdapter = null; //get the last subgrid adapter which defines the column $adapters = $columns[$columnId]->getAdapters(); $adaptersLength = count($adapters); for ($i = $adaptersLength - 1; $i >= 0; $i--) { if ($adapters[$i] instanceof tao_helpers_grid_Cell_SubgridAdapter) { $subGridAdapter = $adapters[$i]; break; } } if (is_null($subGridAdapter)) { throw new Exception(__('The column ') . $columnId . __(' requires a subgrid adapter')); } //init options of the subgrid $subGridAdapter->getGridContainer()->initOptions($columnOptions); continue; } $columns[$columnId]->setOption($optionsName, $optionsValue); } } } } return (bool) $returnValue; }
public static function getInstance() { if (self::$instance === NULL) { self::$instance = new self(); } return self::$instance; }
/** * Constructor * * @return void */ public function __construct() { //Instancia del core de CI $this->ci =& get_instance(); //Nombre del Modulo (HMVC) self::$modulo = $this->ci->router->fetch_module(); }
/** * Get the column resets for the current position, always as html. * * @param string|null $tag Custom html tag. * * @return string */ public function getColumnResets($tag = null) { if (!$this->infinite || $this->infiniteIndex === 0 || $this->grid->hasColumn($this->infiniteIndex)) { return $this->grid->getColumnResetsAsString($this->index, $tag); } $number = count($this->grid->getColumns()); return $this->grid->getColumnResetsAsString($this->infiniteIndex % $number, $tag); }