Exemplo n.º 1
0
 /**
  * Render the entries for parent view.
  *
  * @param CollectionInterface $collection          The collection to render.
  *
  * @param array               $groupingInformation The grouping information as retrieved via
  *                                                 BaseView::getGroupingMode().
  *
  * @return void
  */
 protected function renderEntries($collection, $groupingInformation)
 {
     $environment = $this->getEnvironment();
     $clipboard = $environment->getClipboard();
     $view = $this->getViewSection();
     $listing = $view->getListingConfig();
     $remoteCur = null;
     $groupClass = 'tl_folder_tlist';
     $eoCount = -1;
     $objConfig = $environment->getDataProvider()->getEmptyConfig();
     $this->getPanel()->initialize($objConfig);
     // Generate buttons - only if not in select mode!
     if (!$this->isSelectModeActive()) {
         $buttonRenderer = new ButtonRenderer($this->environment);
         $buttonRenderer->renderButtonsForCollection($collection);
     }
     // Run each model.
     $index = 0;
     foreach ($collection as $model) {
         /** @var ModelInterface $model */
         $index++;
         // Add the group header.
         if ($groupingInformation) {
             $remoteNew = $this->formatCurrentValue($groupingInformation['property'], $model, $groupingInformation['mode'], $groupingInformation['length']);
             // Add the group header if it differs from the last header.
             if (!$listing->getShowColumns() && $groupingInformation['mode'] !== GroupAndSortingInformationInterface::GROUP_NONE && ($remoteNew != $remoteCur || $remoteCur === null)) {
                 $eoCount = -1;
                 $model->setMeta($model::GROUP_VALUE, array('class' => $groupClass, 'value' => $remoteNew));
                 $groupClass = 'tl_folder_list';
                 $remoteCur = $remoteNew;
             }
         }
         if ($listing->getItemCssClass()) {
             $model->setMeta($model::CSS_CLASS, $listing->getItemCssClass());
         }
         $event = new ParentViewChildRecordEvent($this->getEnvironment(), $model);
         $environment->getEventDispatcher()->dispatch($event::NAME, $event);
         $cssClasses = array(++$eoCount % 2 == 0 ? 'even' : 'odd');
         $modelId = IdSerializer::fromModel($model);
         if ($clipboard->hasId($modelId)) {
             $cssClasses[] = 'tl_folder_clipped';
         }
         $model->setMeta($model::CSS_ROW_CLASS, implode(' ', $cssClasses));
         if ($event->getHtml() !== null) {
             $information = array(array('colspan' => 1, 'class' => 'tl_file_list col_1', 'content' => $event->getHtml()));
             $model->setMeta($model::LABEL_VALUE, $information);
         } else {
             $event = new FormatModelLabelEvent($this->environment, $model);
             $this->environment->getEventDispatcher()->dispatch(DcGeneralEvents::FORMAT_MODEL_LABEL, $event);
             $model->setMeta($model::LABEL_VALUE, $event->getLabel());
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Generate list view from current collection.
  *
  * @param CollectionInterface $collection The collection containing the models.
  *
  * @return string
  */
 protected function viewList($collection)
 {
     $environment = $this->getEnvironment();
     $definition = $environment->getDataDefinition();
     $groupingInformation = ViewHelpers::getGroupingMode($this->environment);
     // Set label.
     $this->setListViewLabel($collection, $groupingInformation);
     // Generate buttons - only if not in select mode!
     if (!$this->isSelectModeActive()) {
         $buttonRenderer = new ButtonRenderer($this->environment);
         $buttonRenderer->renderButtonsForCollection($collection);
     }
     // Add template.
     if (isset($groupingInformation['mode']) && $groupingInformation['mode'] != GroupAndSortingInformationInterface::GROUP_NONE) {
         $objTemplate = $this->getTemplate('dcbe_general_grouping');
     } elseif (isset($groupingInformation['property']) && $groupingInformation['property'] != '') {
         $objTemplate = $this->getTemplate('dcbe_general_listView_sorting');
     } else {
         $objTemplate = $this->getTemplate('dcbe_general_listView');
     }
     $this->addToTemplate('tableName', strlen($definition->getName()) ? $definition->getName() : 'none', $objTemplate)->addToTemplate('collection', $collection, $objTemplate)->addToTemplate('select', $this->getEnvironment()->getInputProvider()->getParameter('act'), $objTemplate)->addToTemplate('action', ampersand(\Environment::get('request'), true), $objTemplate)->addToTemplate('mode', $groupingInformation ? $groupingInformation['mode'] : null, $objTemplate)->addToTemplate('tableHead', $this->getTableHead(), $objTemplate)->addToTemplate('pdp', '', $objTemplate)->addToTemplate('cdp', $definition->getName(), $objTemplate)->addToTemplate('selectButtons', $this->getSelectButtons(), $objTemplate)->addToTemplate('sortable', (bool) ViewHelpers::getManualSortingProperty($this->environment), $objTemplate)->addToTemplate('showColumns', $this->getViewSection()->getListingConfig()->getShowColumns(), $objTemplate);
     // Add breadcrumb, if we have one.
     $strBreadcrumb = $this->breadcrumb();
     if ($strBreadcrumb != null) {
         $this->addToTemplate('breadcrumb', $strBreadcrumb, $objTemplate);
     }
     return $objTemplate->parse();
 }
Exemplo n.º 3
0
 /**
  * Render the tree view and return it as string.
  *
  * @param CollectionInterface $objCollection The collection to iterate over.
  *
  * @param string              $treeClass     The class to use for the tree.
  *
  * @return string
  */
 protected function generateTreeView($objCollection, $treeClass)
 {
     $arrHtml = array();
     // Generate buttons - only if not in select mode!
     if (!$this->isSelectModeActive()) {
         $buttonRenderer = new ButtonRenderer($this->environment);
         $buttonRenderer->renderButtonsForCollection($objCollection);
     }
     foreach ($objCollection as $objModel) {
         /** @var ModelInterface $objModel */
         $strToggleID = $objModel->getProviderName() . '_' . $treeClass . '_' . $objModel->getId();
         $arrHtml[] = $this->parseModel($objModel, $strToggleID);
         if ($objModel->getMeta($objModel::HAS_CHILDREN) && $objModel->getMeta($objModel::SHOW_CHILDREN)) {
             $objTemplate = $this->getTemplate('dcbe_general_treeview_child');
             $strSubHtml = '';
             foreach ($objModel->getMeta($objModel::CHILD_COLLECTIONS) as $objCollection) {
                 $strSubHtml .= $this->generateTreeView($objCollection, $treeClass);
             }
             $this->addToTemplate('select', $this->isSelectModeActive(), $objTemplate)->addToTemplate('objParentModel', $objModel, $objTemplate)->addToTemplate('strToggleID', $strToggleID, $objTemplate)->addToTemplate('strHTML', $strSubHtml, $objTemplate)->addToTemplate('strTable', $objModel->getProviderName(), $objTemplate);
             $arrHtml[] = $objTemplate->parse();
         }
     }
     return implode("\n", $arrHtml);
 }