/** * Setting file name * * @access public * @param string $sValue * @return $this * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function setName($sValue) { $this->sFileName = \Plethora\Helper\String::prepareToURL($sValue); return $this; }
/** * Format value. * * @access public * @param string $value * @return string * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function format($value) { $oLink = Helper\Link::factory(); // set title attribute $sTitle = ''; $sURL = ''; $oModel = $this->getField()->getEntity()->getModel(); $oLocales = $oModel->getLocales(); if ($oModel->hasField($this->getConfigTitle())) { $sTitle = $oModel->{$this->getConfigTitle()}; } elseif ($oLocales !== NULL && $oLocales->hasField($this->getConfigTitle())) { $sTitle = $oLocales->{$this->getConfigTitle()}; } $sTitle = $this->titlePrefix . $sTitle . $this->titleSuffix; if (!empty($sTitle)) { $oLink->setTitle($sTitle); } // set URL of the link if ($this->bValueAsURL) { $sURL = $value; } elseif (!empty($this->valueFromField)) { $sURL = $this->getField()->getEntity()->getModel()->getValue($this->valueFromField); } elseif ($this->getUrl() !== NULL) { $sURL = $this->getUrl(); } elseif ($this->getRouteName() !== NULL) { $aArgs = $this->getRouteAttributes(); foreach ($aArgs as $sAttrKey => $sField) { $sAttrValue = NULL; if ($oModel->hasField($sField)) { $sAttrValue = $oModel->{$sField}; } elseif ($oLocales !== NULL && $oLocales->hasField($sField)) { $sAttrValue = $oLocales->{$sField}; } $aArgs[$sAttrKey] = Helper\String::prepareToURL($sAttrValue); } $sURL = Route::factory($this->getRouteName())->url($aArgs); } // return newly generated link code return $this->sPrefix . $oLink->code($value, $sURL) . $this->sSuffix; }