Beispiel #1
0
 /**
  * Get flexigrid for specified model.
  *
  * @param string $modelClass
  * @param array $options
  * @return \Curry_Flexigrid
  */
 public function getGrid($modelClass, $options = array())
 {
     $options = array_merge(array('title' => $modelClass . 's', 'rp' => 100, 'rpOptions' => array(25, 50, 100, 200, 500)), $options);
     $flexigrid = new \Curry_Flexigrid_Propel($modelClass, url('', $_GET)->add(array('view' => $modelClass . 'Json')), $options);
     $editUrl = url('', $_GET)->add(array('module', 'view' => $modelClass));
     $flexigrid->addEditButton($editUrl);
     $flexigrid->addAddButton($editUrl);
     $flexigrid->addDeleteButton();
     if (in_array('translatable', array_keys(\PropelQuery::from($modelClass)->getTableMap()->getBehaviors()))) {
         $langcode = \LanguageQuery::create()->findOne()->getLangcode();
         $flexigrid->addLinkButton('View Translations', 'icon-flag', url('', $_GET)->add(array('translate' => true, 'langcode' => $langcode)));
     }
     return $flexigrid;
 }
Beispiel #2
0
 /**
  * Get table grid.
  * 
  * @return Curry_Flexigrid_Propel
  */
 private function getTableGrid()
 {
     $tableMap = PropelQuery::from($_GET['table'])->getTableMap();
     $flexigrid = new Curry_Flexigrid_Propel($_GET['table'], url('', array("module", "table", "view" => "TableJson")), array("rp" => 25, "rpOptions" => array(10, 25, 40, 50, 100, 200)));
     // Unhide Pk column as you may want to see it in db backend
     if ($flexigrid->getPrimaryKey()) {
         $flexigrid->setColumnOption($flexigrid->getPrimaryKey(), array('hide' => false));
     }
     // Make columns searchable
     foreach ($tableMap->getColumns() as $column) {
         $name = strtolower($column->getName());
         $display = ucfirst(str_replace("_", " ", $name));
         $flexigrid->addSearchItem($name, $display);
     }
     $flexigrid->addColumn('pk', 'Primary Key', array('hide' => true, 'escape' => false));
     $flexigrid->setPrimaryKey('pk');
     $flexigrid->setColumnCallback('pk', array('Curry_Backend_DatabaseHelper', 'getObjectPk'));
     $editUrl = url('', array("module", "table", "view" => "Row"));
     $flexigrid->addAddButton($editUrl);
     $flexigrid->addEditButton($editUrl);
     $flexigrid->addCommandButton('Delete', 'icon_delete', 'dodelete');
     // TODO: Add confirmation.
     $flexigrid->addSeparator();
     $flexigrid->addCommandButton('Empty', 'icon_bin_empty', 'empty');
     // TODO: Add confirmation.
     $flexigrid->addLinkButton('Check relations', 'icon_wrench', (string) url('', array('module', 'view' => 'Cleanup', 'table')));
     if (array_key_exists('nested_set', $tableMap->getBehaviors())) {
         $flexigrid->addLinkButton('Repair nested set', 'icon_wrench', (string) url('', array('module', 'view' => 'RepairNestedSet', 'table')));
     }
     $flexigrid->addSeparator();
     $flexigrid->addLinkButton('Import', 'icon_page_excel', (string) url('', array('module', 'view' => 'Import', 'table')));
     $flexigrid->addLinkButton('Export', 'icon_page_excel', (string) url('', array('module', 'view' => 'Export', 'table')));
     return $flexigrid;
 }