コード例 #1
0
ファイル: BaseView.php プロジェクト: zonky2/dc-general
 /**
  * Generate all buttons for the header of a view.
  *
  * @param string $strButtonId The id for the surrounding html div element.
  *
  * @return string
  */
 protected function generateHeaderButtons($strButtonId)
 {
     /** @var CommandInterface[] $globalOperations */
     $globalOperations = $this->getViewSection()->getGlobalCommands()->getCommands();
     $buttons = array();
     if (!is_array($globalOperations)) {
         $globalOperations = array();
     }
     if ($this->isSelectModeActive()) {
         // Special case - if select mode active, we must not display the "edit all" button.
         unset($globalOperations['all']);
     } else {
         // We do not have the select mode.
         $command = $this->getCreateModelCommand();
         if ($command !== null) {
             // New button always first.
             array_unshift($globalOperations, $command);
         }
     }
     $command = $this->getBackCommand();
     if ($command !== null) {
         // Back button always to the front.
         array_unshift($globalOperations, $command);
     }
     foreach ($globalOperations as $command) {
         $buttons[$command->getName()] = $this->generateHeaderButton($command);
     }
     $buttonsEvent = new GetGlobalButtonsEvent($this->getEnvironment());
     $buttonsEvent->setButtons($buttons);
     $this->getEnvironment()->getEventDispatcher()->dispatch(GetGlobalButtonsEvent::NAME, $buttonsEvent);
     return '<div id="' . $strButtonId . '">' . implode('', $buttonsEvent->getButtons()) . '</div>';
 }
コード例 #2
0
ファイル: BaseView.php プロジェクト: amenk/dc-general
 /**
  * Generate all buttons for the header of a view.
  *
  * @param string $strButtonId The id for the surrounding html div element.
  *
  * @return string
  */
 protected function generateHeaderButtons($strButtonId)
 {
     /** @var CommandInterface[] $globalOperations */
     $globalOperations = $this->getViewSection()->getGlobalCommands()->getCommands();
     $buttons = array();
     if (!is_array($globalOperations)) {
         $globalOperations = array();
     }
     // Special case - if select mode active, we must not display the "edit all" button.
     if ($this->isSelectModeActive()) {
         unset($globalOperations['all']);
     } else {
         $command = $this->getCreateModelCommand();
         if ($command !== null) {
             // New button always first.
             array_unshift($globalOperations, $command);
         }
         $command = $this->getClearClipboardCommand();
         if ($command !== null) {
             // Clear clipboard to the end.
             $globalOperations[] = $command;
         }
     }
     $command = $this->getBackCommand();
     if ($command !== null) {
         // Back button always to the end.
         $globalOperations[] = $command;
     }
     foreach ($globalOperations as $command) {
         $buttons[$command->getName()] = $this->generateHeaderButton($command);
     }
     $buttonsEvent = new GetGlobalButtonsEvent($this->getEnvironment());
     $buttonsEvent->setButtons($buttons);
     $this->getEnvironment()->getEventPropagator()->propagate($buttonsEvent::NAME, $buttonsEvent, array($this->getEnvironment()->getDataDefinition()->getName()));
     return '<div id="' . $strButtonId . '">' . implode('', $buttonsEvent->getButtons()) . '</div>';
 }