Example #1
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;
 }
Example #2
0
 /**
  * Retrieve the caption text for the "Show details" link,
  *
  * This message is looked up in the following order:
  * 1. $GLOBALS['TL_LANG']['MSC'][<mm tablename>][<render settings id>]['details']
  * 2. $GLOBALS['TL_LANG']['MSC'][<mm tablename>]['details']
  * 3. $GLOBALS['TL_LANG']['MSC']['details']
  *
  * @return string
  */
 protected function getDetailsCaption()
 {
     if (isset($this->objView) && isset($GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()][$this->objView->get('id')]['details'])) {
         return $GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()][$this->objView->get('id')]['details'];
     } elseif (isset($GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()]['details'])) {
         return $GLOBALS['TL_LANG']['MSC'][$this->getMetaModel()->getTableName()]['details'];
     } else {
         return $GLOBALS['TL_LANG']['MSC']['details'];
     }
 }
 /**
  * Retrieve the jump to information from the setting.
  *
  * @return array|null The jump to information or null if none has been set.
  */
 public function getJumpTo()
 {
     return $this->parent->getJumpTo();
 }