/** * Create image tag. * * @static * @access public * @param string $sImageSource * @param string $aAltText * @param Attributes $oAttributes * @return string * @since 1.0.0-alpha * @version 1.0.0-alpha */ public static function img($sImageSource, $aAltText, Attributes $oAttributes = NULL) { if ($oAttributes === NULL) { $oAttributes = new Attributes(); } $oAttributes->setAttribute('src', $sImageSource); $oAttributes->setAttribute('alt', $aAltText); return '<img ' . $oAttributes->renderAttributes() . ' />'; }
/** * Create next level of menu. * * @access private * @param array $routes * @param integer $level * @return View * @throws Exception\Router * @since 1.0.0-dev * @version 1.3.0-dev */ private function createNextLevel(array $routes, $level) { $entries = []; $level++; foreach ($routes as $route) { /* @var $route array */ /* @var $routeTitle string */ /* @var $routeName string */ /* @var $routeParams array */ /* @var $children array */ $routeTitle = $route['title']; $routeName = Helper\Arrays::get($route, 'route_name', NULL); $routeParams = Helper\Arrays::get($route, 'route_parameters', []); $url = Helper\Arrays::get($route, 'url', NULL); $children = Helper\Arrays::get($route, 'children', []); if ($routeName !== NULL) { $path = Route::factory($routeName)->path($routeParams); } else { $path = $url; } $singleLevel = View::factory('menu/single_level'); $singleLevel->set('route', $route); $singleLevel->set('routeTitle', $routeTitle); $singleLevel->set('routeName', $routeName); $singleLevel->set('path', $path); $singleLevel->set('routeParams', $routeParams); $singleLevel->set('classes', $route['classes']); if ($children !== []) { $children = $this->createNextLevel($children, $level); /* @var $children View */ } $singleLevel->set('children', $children); $entries[] = $singleLevel; } if ($level > 1) { return View::factory('menu/submenu')->set('submenuClasses', $this->submenuClasses)->set('level', $level)->set('entries', $entries); } else { $this->attributes->addToAttribute('class', 'menu_level_1'); return View::factory('menu/menu')->set('attributes', $this->attributes)->set('entries', $entries); } }
/** * 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() . '".'); } } }