示例#1
0
 /**
  * get attributes for checkbox wizard
  * @param object
  * @return array
  */
 public function getFilterParameterNames($objRow)
 {
     $return = array();
     if (!$objRow->activeRecord->metamodel_filtering) {
         return $return;
     }
     $objFilterSetting = MetaModelFilterSettingsFactory::byId($objRow->activeRecord->metamodel_filtering);
     $arrParameterDca = $objFilterSetting->getParameterFilterNames();
     return $arrParameterDca;
 }
示例#2
0
 /**
  * Return all attributes that shall be fetched from the MetaModel.
  * In this base implementation, this only includes the attributes mentioned in the render setting.
  *
  * @return string[] the names of the attributes to be fetched.
  */
 protected function getAttributeNames()
 {
     $arrAttributes = $this->objView->getSettingNames();
     // Get the right jumpto.
     $strDesiredLanguage = $this->getMetaModel()->getActiveLanguage();
     $strFallbackLanguage = $this->getMetaModel()->getFallbackLanguage();
     $intFilterSettings = 0;
     foreach ((array) $this->getView()->get('jumpTo') as $arrJumpTo) {
         // If either desired language or fallback, keep the result.
         if (!$this->getMetaModel()->isTranslated() || $arrJumpTo['langcode'] == $strDesiredLanguage || $arrJumpTo['langcode'] == $strFallbackLanguage) {
             $intFilterSettings = $arrJumpTo['filter'];
             // If the desired language, break. Otherwise try to get the desired one until all have been evaluated.
             if ($strDesiredLanguage == $arrJumpTo['langcode']) {
                 break;
             }
         }
     }
     if ($intFilterSettings) {
         $objFilterSettings = MetaModelFilterSettingsFactory::byId($intFilterSettings);
         $arrAttributes = array_merge($objFilterSettings->getReferencedAttributes(), $arrAttributes);
     }
     return $arrAttributes;
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function prepareFilter($intFilterSettings, $arrFilterUrl)
 {
     $objFilter = $this->getEmptyFilter();
     if ($intFilterSettings) {
         $objFilterSettings = MetaModelFilterSettingsFactory::byId($intFilterSettings);
         $objFilterSettings->addRules($objFilter, $arrFilterUrl);
     }
     return $objFilter;
 }
示例#4
0
 /**
  * Build the jumpTo link for use in templates.
  *
  * The returning array will hold the following keys:
  * * params - the url parameter (only if a valid filter setting could be determined).
  * * deep   - boolean true, if parameters are non empty, false otherwise.
  * * page   - id of the jumpTo page.
  * * url    - the complete generated url
  *
  * @param IMetaModelRenderSettings $objSettings The render settings to use.
  *
  * @return array
  */
 public function buildJumpToLink($objSettings)
 {
     if (!$objSettings) {
         return null;
     }
     // Get the right jumpto.
     $strDesiredLanguage = $this->getMetaModel()->getActiveLanguage();
     $strFallbackLanguage = $this->getMetaModel()->getFallbackLanguage();
     $intJumpTo = 0;
     $intFilterSettings = 0;
     foreach ((array) $objSettings->get('jumpTo') as $arrJumpTo) {
         // If either desired language or fallback, keep the result.
         if (!$this->getMetaModel()->isTranslated() || $arrJumpTo['langcode'] == $strDesiredLanguage || $arrJumpTo['langcode'] == $strFallbackLanguage) {
             $intJumpTo = $arrJumpTo['value'];
             $intFilterSettings = $arrJumpTo['filter'];
             // If the desired language, break. Otherwise try to get the desired one until all have been evaluated.
             if ($strDesiredLanguage == $arrJumpTo['langcode']) {
                 break;
             }
         }
     }
     // Apply jumpTo urls based upon the filter defined in the render settings.
     $objPage = MetaModelController::getPageDetails($intJumpTo);
     if (!$objPage) {
         return null;
     }
     $arrJumpTo = array();
     $strParams = '';
     if ($intFilterSettings) {
         $objFilterSettings = MetaModelFilterSettingsFactory::byId($intFilterSettings);
         $arrParams = $objFilterSettings->generateFilterUrlFrom($this, $objSettings);
         foreach ($arrParams as $strKey => $strValue) {
             if ($strKey == 'auto_item') {
                 $strParams = '/' . $strValue . $strParams;
             } else {
                 $strParams .= sprintf('/%s/%s', $strKey, $strValue);
             }
         }
         $arrJumpTo['params'] = $arrParams;
         $arrJumpTo['deep'] = strlen($strParams) > 0;
         if (isset($GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()][$objSettings->get('id')]['details'])) {
             $arrJumpTo['label'] = $GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()][$objSettings->get('id')]['details'];
         } elseif (isset($GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()]['details'])) {
             $arrJumpTo['label'] = $GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()]['details'];
         } else {
             $arrJumpTo['label'] = $GLOBALS['TL_LANG']['MSC']['details'];
         }
     }
     $arrJumpTo['page'] = $intJumpTo;
     $arrJumpTo['url'] = MetaModelController::generateFrontendUrl($objPage->row(), $strParams);
     return $arrJumpTo;
 }
 /**
  * Get the filters
  */
 protected function getFilters()
 {
     $strAction = '';
     /**
      * @var IMetaModelFilterSettings
      */
     $objFilterSetting = MetaModelFilterSettingsFactory::byId($this->objFilterConfig->metamodel_filtering);
     $objFrontendFilterOptions = new MetaModelFrontendFilterOptions();
     $objFrontendFilterOptions->setAutoSubmit($this->objFilterConfig->metamodel_fef_autosubmit ? true : false);
     $objFrontendFilterOptions->setHideClearFilter($this->objFilterConfig->metamodel_fef_hideclearfilter ? true : false);
     $objFrontendFilterOptions->setShowCountValues($this->objFilterConfig->metamodel_available_values ? true : false);
     $arrJumpTo = $this->objFilterConfig->arrJumpTo;
     $arrParams = $this->getParams();
     $arrWidgets = $objFilterSetting->getParameterFilterWidgets($arrParams['all'], $arrJumpTo, $objFrontendFilterOptions);
     // filter the widgets we do not want to show.
     $arrWanted = $this->getWantedNames();
     // if we have POST data, we need to redirect now.
     if ($_POST && $this->Input->post('FORM_SUBMIT') == $this->formId) {
         $arrRedirectParams = $arrParams['other'];
         foreach ($arrWanted as $strWidget) {
             $arrFilter = $arrWidgets[$strWidget];
             if (!empty($arrFilter['urlvalue'])) {
                 $arrRedirectParams[$strWidget] = $arrFilter['urlvalue'];
             }
         }
         $this->redirectPost($arrRedirectParams);
     }
     $arrRendered = array();
     // render the widgets through the filter templates.
     foreach ($this->getWantedNames() as $strWidget) {
         $arrFilter = $arrWidgets[$strWidget];
         $strTemplate = $arrFilter['raw']['eval']['template'];
         // parse sub template
         $objSubTemplate = new FrontendTemplate($strTemplate ? $strTemplate : 'mm_filteritem_default');
         $objSubTemplate->setData($arrFilter);
         $objSubTemplate->submit = $objFrontendFilterOptions->isAutoSubmit();
         $arrFilter['value'] = $objSubTemplate->parse();
         $arrRendered[$strWidget] = $arrFilter;
     }
     // return filter data
     return array('action' => $this->generateFrontendUrl($arrJumpTo, $this->getJumpToUrl($arrParams['other'])), 'formid' => $this->formId, 'filters' => $arrRendered, 'submit' => $objFrontendFilterOptions->isAutoSubmit() ? '' : $GLOBALS['TL_LANG']['metamodels_frontendfilter']['submit']);
 }