コード例 #1
0
ファイル: Grid.php プロジェクト: nandorodpires2/gallery
 /**
  * Calculate colspan for pagination and top
  *
  * @return int
  */
 protected function _colspan()
 {
     $row = 0;
     $totalFields[$row] = 0;
     // add the extra left fields
     foreach ($this->_extraColumns as $value) {
         if ($value['position'] != 'left') {
             continue;
         }
         $rows = 1;
         $cols = 1;
         if (isset($value['newrow']) && $value['newrow']) {
             $row++;
         }
         if (isset($value['rowspan']) && $value['rowspan'] !== null) {
             $rows = $value['rowspan'];
         }
         if (isset($value['colspan']) && $value['colspan'] !== null) {
             $cols = $value['colspan'];
         }
         if ($cols < 0) {
             $cols = 1;
         }
         // add the appropriate number of columns for the relevant rows
         for ($a = 0; $a < $rows; $a++) {
             $totalFields[$row + $a] += $cols;
         }
     }
     // loop through the fields
     foreach ($this->_fields as $nf) {
         $rows = 1;
         $cols = 1;
         if (isset($this->_data['fields'][$nf])) {
             // skip certain types of fields
             $value = $this->_data['fields'][$nf];
             if (isset($value['remove']) && $value['remove'] == 1) {
                 continue;
             } elseif (isset($value['hidden']) && $value['hidden'] == 1 && $this->_removeHiddenFields === true) {
                 continue;
             }
             if (isset($value['hRow']) && $value['hRow'] == 1) {
                 continue;
             }
             if (isset($value['newrow']) && $value['newrow']) {
                 $row++;
             }
             if (isset($value['rowspan']) && $value['rowspan'] !== null) {
                 $rows = $value['rowspan'];
             }
             if (isset($value['colspan']) && $value['colspan'] !== null) {
                 $cols = $value['colspan'];
             }
             if ($cols < 0) {
                 $cols = 1;
             }
         }
         // add the appropriate number of columns for the relevant rows
         for ($a = 0; $a < $rows; $a++) {
             if (!isset($totalFields[$row + $a])) {
                 $totalFields[$row + $a] = 0;
             }
             $totalFields[$row + $a] += $cols;
         }
     }
     // add the extra right fields
     foreach ($this->_extraColumns as $value) {
         if ($value['position'] != 'right') {
             continue;
         }
         $rows = 1;
         $cols = 1;
         if (isset($value['newrow']) && $value['newrow']) {
             $row++;
         }
         if (isset($value['rowspan']) && $value['rowspan'] !== null) {
             $rows = $value['rowspan'];
         }
         if (isset($value['colspan']) && $value['colspan'] !== null) {
             $cols = $value['colspan'];
         }
         if ($cols < 0) {
             $cols = 1;
         }
         // add the appropriate number of columns for the relevant rows
         for ($a = 0; $a < $rows; $a++) {
             $totalFields[$row + $a] += $cols;
         }
     }
     if ($this->_allowDelete == 1) {
         $totalFields[$row]++;
     }
     if ($this->_allowEdit == 1) {
         $totalFields[$row]++;
     }
     if (is_array($this->_detailColumns) && $this->_isDetail == false) {
         $totalFields[$row]++;
     }
     if ($this->_massActions->hasMassActions()) {
         $totalFields[$row]++;
     }
     $this->_colspan = max($totalFields);
     return $this->_colspan;
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: Aeryris/grid
 public function massAction()
 {
     if ($this->getRequest()->isPost()) {
         echo "<pre>";
         print_r($this->_getAllParams());
         die;
     }
     $grid = $this->grid();
     $select = $this->_db->select()->from('Country');
     $grid->query($select);
     $actions = new Bvb_Grid_Mass_Actions();
     //        $actions->setMassActions(array(array('url' => $grid->getUrl(),
     //                                             'caption' => 'Remove (Nothing will happen)',
     //                                             'confirm' => 'Are you sure?'),
     //                                       array('url' => $grid->getUrl() . '/nothing/happens',
     //                                             'caption' => 'Some other action',
     //                                             'confirm' => 'Another confirmation message?')));
     $actions->addMassAction($grid->getUrl() . '/option/delete', 'Delete', 'Are you sure?');
     $actions->addMassAction($grid->getUrl(), 'Print');
     $grid->setMassActions($actions);
     $grid->setRecordsPerPage(15);
     $grid->setPaginationInterval(array(10 => 10, 20 => 20, 50 => 50, 100 => 100));
     $grid->setTableGridColumns(array('Name', 'Continent', 'Population', 'LocalName', 'GovernmentForm'));
     $grid->setSqlExp(array('Population' => array('functions' => array('SUM'))));
     $this->view->pages = $grid->deploy();
     $this->render('index');
 }
コード例 #3
0
 public function testMassActions()
 {
     $this->grid->setSource(new Bvb_Grid_Source_Zend_Table(new Bugs()));
     $actions = new Bvb_Grid_Mass_Actions();
     $actions->addMassAction($this->grid->getUrl() . '/option/delete', 'Delete', 'Are you sure?');
     $actions->addMassAction($this->grid->getUrl(), 'Print');
     $actions->setMassActionsSeparator(',');
     $actions->setMultipleFieldsSeparator('-');
     $this->grid->setMassActions($actions);
     $grid = $this->grid->deploy();
     $this->controller->getResponse()->setBody($grid);
     $this->assertQuery("[@id='massCheckBox_']");
 }