/** * Format value. * * @access public * @param string $value * @return string * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function format($value) { $sOutput = ''; if ($value instanceof ModelCore\FileBroker) { $oAttributes = Helper\Attributes::factory(); $oField = $this->getField(); /* @var $oField View\ViewField */ $sFieldName = $oField->getName(); $oFile = $value->getFile(); /* @var $oFile \Model\File */ // get file path $sFilePath = $oFile->getFullPath(); // generate HTML $oAttributes->addToAttribute('href', Router::getBase() . '/' . $sFilePath); $sOutput = '<img src="/assets/system/file_icons/' . $oFile->getExt() . '.png" alt="" /> <a ' . $oAttributes->renderAttributes() . '>' . $sFilePath . '</a>'; // remove objects unset($oFileManager); } // return final output return $this->sPrefix . $sOutput . $this->sSuffix; }
/** * Format value. * * @access public * @param ModelCore\FileBroker $oImageBroker * @return string * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function format($oImageBroker) { $sOutput = ''; if ($oImageBroker instanceof ModelCore\FileBroker && $oImageBroker->getFile() instanceof \Model\File) { $oAttributes = Helper\Attributes::factory(); $oField = $this->getField(); /* @var $oField \Plethora\View\ViewField */ $oFile = $oImageBroker->getFile(); /* @var $oFile \Model\File */ // set proper ALT if (!empty($this->sImageAltPattern)) { $oModel = $oField->getEntity()->getModel(); $aFields = $oModel->getMetadata()->getFieldNames(); if ($oModel->hasLocales()) { $aFields = array_merge($aFields, $oModel->getLocalesMetadata()->getFieldNames()); } $sAlt = $this->sImageAltPattern; foreach ($aFields as $sField) { if (strpos($sAlt, ':' . $sField) !== FALSE) { $sAlt = str_replace(':' . $sField, $oModel->{$sField}, $sAlt); } if (strpos($sAlt, ':') === FALSE) { break; } } $oAttributes->addToAttribute('alt', $sAlt); } // get image path $sFieldName = $oField->getName(); $oFormField = $oField->getEntity()->getModel()->getConfig()->getField($sFieldName); /* @var $oFormField \Plethora\Form\Field\ImageModel */ $sImagePath = $oFile->getFullPath(); if (empty($sImagePath) && $oFormField->getDefaultImage() === NULL) { return NULL; } elseif (empty($sImagePath) && $oFormField->getDefaultImage() !== NULL) { $sImagePath = $oFormField->getDefaultImage(); } // stylize image if (!empty($this->sImageStyle)) { $sImagePath = ImageStyles::useStyle($this->sImageStyle, $sImagePath); } $oAttributes->addToAttribute('src', Router::getBase() . '/' . $sImagePath); $sOutput = '<img ' . $oAttributes->renderAttributes() . ' />'; // if this image should be linked to it's original-sized equivalent if ($this->bLinkToOriginalSize) { $sImagePathOriginal = '/' . $oFormField->getUploadPath(TRUE) . '/' . $oFile->getNameWithExt(); $oAttributes = Helper\Attributes::factory()->setAttributes($this->aLinkAttributes); $sOutput = Helper\Html::a($sImagePathOriginal, $sOutput, $oAttributes); } } // return final output return $this->sPrefix . $sOutput . $this->sSuffix; }
/** * Constructor * * @access public * @param string $name field name * @param string $value field name * @param Form $form form instance * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function __construct($name, $value, Form &$form) { $this->sName = $name; $this->sValue = $value; $this->oForm = $form; $this->attributes = Helper\Attributes::factory(); }
<?php /** * @author Krzysztof Trzos * @package base * @subpackage views\view\imitation * @since 1.0.0-alpha * @version 1.0.0-alpha */ ?> <?php /* @var $sURL string */ /* @var $sTitle string */ /* @var $sValue string */ ?> <?php $oAttributes = \Plethora\Helper\Attributes::factory(); $oAttributes->setAttribute('title', $sTitle); ?> <?php echo \Plethora\Helper\Html::a($sURL, empty($sValue) ? __('read more') : $sValue, $oAttributes);
*/ use Plethora\Helper; use Plethora\View; ?> <?php /* @var $sRouteTitle string */ /* @var $sRouteName string */ /* @var $sPath string */ /* @var $aRouteParams array */ /* @var $oSiblings View */ /* @var $aParameters array */ ?> <li <?php echo Helper\Attributes::factory()->renderAttributes($aParameters); ?> > <?php echo Helper\Html::a($sPath, $sRouteTitle); ?> <?php if ($oSiblings instanceof View) { ?> <?php echo $oSiblings->render(); ?> <?php } ?> </li>
/** * Constructor. * * @access public * @param string $name field name * @param Form $form form * @throws Exception * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function __construct($name, Form $form) { $this->name = $name; $this->oForm = $form; $this->oAttributes = Helper\Attributes::factory(); $this->resetAllNeededAttributes(); $this->bFormSubmitted = $this->getFormObject()->isSubmitted(); // add particular field to form (if not a singleton) if ($form->getName() !== 'singletons') { if (!$form->hasField($name)) { $form->addField($this); } else { throw new Exception('Form "' . $form->getName() . '" already has field with name "' . $this->getName() . '".'); } } }