123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <?php
- /**
- *
- * Cube Framework $Id$ hdJu3rr7BgJDAVkYjTvYG/ZRNRdup1qDbnUhOCimuXM=
- *
- * @link http://codecu.be/framework
- * @copyright Copyright (c) 2015 CodeCube SRL
- * @license http://codecu.be/framework/license Commercial License
- *
- * @version 1.4
- */
- /**
- * view helpers abstract class
- */
- namespace Cube\View\Helper;
- use Cube\View,
- Cube\Controller\Front,
- Cube\Translate,
- Cube\Translate\Adapter\AbstractAdapter as TranslateAdapter;
- abstract class AbstractHelper implements HelperInterface
- {
- /**
- * view object
- *
- * @var \Cube\View
- */
- protected $_view = null;
- /**
- *
- * the view partial to be used
- *
- * @var string
- */
- protected $_partial;
- /**
- *
- * translate adapter
- *
- * @var \Cube\Translate\Adapter\AbstractAdapter
- */
- protected $_translate;
- /**
- *
- * the end tag of the html element
- *
- * @var string
- */
- protected $_endTag = '>';
- /**
- *
- * get the view object
- *
- * @return \Cube\View
- */
- public function getView()
- {
- if ($this->_view === null) {
- $this->setView();
- }
- return $this->_view;
- }
- /**
- * set the view object
- *
- * @param \Cube\View $view
- *
- * @return $this
- */
- public function setView(View $view = null)
- {
- if (!$view instanceof View) {
- $bootstrap = Front::getInstance()->getBootstrap();
- if ($bootstrap->hasResource('view')) {
- $view = $bootstrap->getResource('view');
- } else {
- $view = new View();
- }
- }
- $this->_view = $view;
- return $this;
- }
- /**
- *
- * get the view file
- *
- * @return string
- */
- public function getPartial()
- {
- return $this->_partial;
- }
- /**
- *
- * set the view file
- *
- * @param string $partial
- *
- * @return $this
- */
- public function setPartial($partial)
- {
- $this->_partial = $partial;
- return $this;
- }
- /**
- *
- * get translate adapter
- *
- * @return \Cube\Translate\Adapter\AbstractAdapter
- */
- public function getTranslate()
- {
- if (!$this->_translate instanceof TranslateAdapter) {
- $translate = Front::getInstance()->getBootstrap()->getResource('translate');
- if ($translate instanceof Translate) {
- $this->setTranslate(
- $translate->getAdapter());
- }
- }
- return $this->_translate;
- }
- /**
- *
- * set translate adapter
- *
- * @param \Cube\Translate\Adapter\AbstractAdapter $translate
- *
- * @return $this
- */
- public function setTranslate(TranslateAdapter $translate)
- {
- $this->_translate = $translate;
- return $this;
- }
- }
|