예제 #1
0
 /**
  * Create the "new" button.
  *
  * @return null|Command
  */
 protected function getCreateModelCommand()
 {
     $environment = $this->getEnvironment();
     $definition = $environment->getDataDefinition();
     $basicDefinition = $definition->getBasicDefinition();
     $providerName = $environment->getDataDefinition()->getName();
     $mode = $basicDefinition->getMode();
     $config = $this->getEnvironment()->getBaseConfigRegistry()->getBaseConfig();
     if ($serializedPid = $environment->getInputProvider()->getParameter('pid')) {
         $pid = ModelId::fromSerialized($serializedPid);
     } else {
         $pid = null;
     }
     if (!$basicDefinition->isCreatable()) {
         return null;
     }
     $command = new Command();
     $parameters = $command->getParameters();
     $extra = $command->getExtra();
     $extra['class'] = 'header_new';
     $extra['accesskey'] = 'n';
     $extra['attributes'] = 'onclick="Backend.getScrollOffset();"';
     $command->setName('button_new')->setLabel($this->translate('new.0', $providerName))->setDescription($this->translate('new.1', $providerName));
     $this->getPanel()->initialize($config);
     // Add new button.
     if ($mode == BasicDefinitionInterface::MODE_PARENTEDLIST || $mode == BasicDefinitionInterface::MODE_HIERARCHICAL) {
         $filter = new Filter();
         $filter->andModelIsFromProvider($basicDefinition->getDataProvider());
         if ($parentDataProviderName = $basicDefinition->getParentDataProvider()) {
             $filter->andParentIsFromProvider($parentDataProviderName);
         } else {
             $filter->andHasNoParent();
         }
         if ($environment->getClipboard()->isNotEmpty($filter)) {
             return null;
         }
     }
     $parameters['act'] = 'create';
     // Add new button.
     if ($pid) {
         $parameters['pid'] = $pid->getSerialized();
     }
     return $command;
 }
예제 #2
0
 /**
  * Create the "clear clipboard" button.
  *
  * @return CommandInterface|null
  */
 protected function getClearClipboardCommand()
 {
     if ($this->getEnvironment()->getClipboard()->isEmpty()) {
         return null;
     }
     $command = new Command();
     $parameters = $command->getParameters();
     $extra = $command->getExtra();
     $extra['class'] = 'header_clipboard';
     $extra['accesskey'] = 'x';
     $extra['attributes'] = 'onclick="Backend.getScrollOffset();"';
     $parameters['clipboard'] = '1';
     $command->setName('button_clipboard')->setLabel($this->translate('MSC.clearClipboard'))->setDescription($this->translate('MSC.clearClipboard'));
     return $command;
 }