Example #1
0
 /**
  *  @todo Build a resource plugin that creates the {WFLabel id="XXX"} on the fly so we can use bindings etc.
  *  @todo also eventually we will have a convention for calling certain methods to get metadata about all discoverable properties.
  */
 function browse_PageDidLoad($page, $params)
 {
     $tName = $params['objectName'];
     try {
         $tMap = $this->propelDBMap->getTable($tName);
     } catch (Exception $e) {
         header("Location: " . WFRequestController::WFURL($this->invocation()->modulePath(), 'objects'));
         exit;
     }
     $peerMethod = $tMap->getPhpName() . "Peer";
     // set up paginator; query for data
     // set up sort links
     $cols = array();
     $sortOptions = array();
     $defaultSortKeys = array();
     $dynamicWidgetIDs = array();
     $primaryKeys = array();
     foreach ($tMap->getColumns() as $col) {
         $cols[$col->getColumnName()] = $col->getPhpName();
         $sortOptions['+' . $col->getFullyQualifiedName()] = $col->getPhpName();
         $sortOptions['-' . $col->getFullyQualifiedName()] = $col->getPhpName();
         if ($col->isPrimaryKey()) {
             $defaultSortKeys[] = '+' . $col->getFullyQualifiedName();
             $primaryKeys[] = $col->getPhpName();
         }
         // create sort widget
         $sw = new WFPaginatorSortLink("sortLink_" . $col->getPhpName(), $page);
         $sw->setPaginator($this->paginator);
         $sw->setValue($col->getFullyQualifiedName());
         $dynamicWidgetIDs[$col->getPhpName()]['sortLink'] = $sw->id();
         // create label widget via WFDynamic
         $lw = new WFDynamic("label_" . $col->getPhpName(), $page);
         $lw->setWidgetClass('WFLabel');
         $lw->setArrayController($this->records);
         $lw->setSimpleBindKeyPath($col->getPhpName());
         $labelConfig = array('ellipsisAfterChars' => array('custom' => array('iterate' => false, 'value' => 50)));
         $lw->setWidgetConfig($labelConfig);
         $dynamicWidgetIDs[$col->getPhpName()]['label'] = $lw->id();
     }
     $this->paginator->setSortOptions($sortOptions);
     $this->paginator->setDefaultSortKeys($defaultSortKeys);
     $this->paginator->setDataDelegate(new WFPagedPropelQuery(new Criteria(), $peerMethod));
     $this->paginator->setPaginatorState($params['paginatorState']);
     $result = $this->paginator->currentItems();
     // set up controller
     $this->records->setClass($tMap->getPhpName());
     $this->records->setClassIdentifiers($primaryKeys);
     $this->records->setContent($result);
     $page->assign('dynamicWidgetIDs', $dynamicWidgetIDs);
     $page->assign('tableMap', $tMap);
     $page->assign('columns', $cols);
     $page->assign('objects', $result);
     $this->browseTableName = $tMap->getName();
 }
Example #2
0
 /**
  *  Just before rendering, we want to update the checked status of all managed checkboxes to reflect the selection status of the arrayController.
  *
  *  @param string Blockcontent.
  *  @return string Rendered HTML.
  */
 function render($blockContent = NULL)
 {
     if (!$this->preRenderCheckHasRun) {
         $this->preRenderCheckHasRun = true;
         $this->updateSelectionCheckboxes();
     }
     return parent::render($blockContent);
 }