Advertisement
Guest User

Tx_FETest_ViewHelpers_Form_RTEViewHelper

a guest
Dec 19th, 2011
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1. <?php
  2.  
  3. require_once(t3lib_extMgm::extPath('rtehtmlarea') . 'pi2/class.tx_rtehtmlarea_pi2.php');
  4.  
  5. class Tx_FETest_ViewHelpers_Form_RTEViewHelper extends Tx_Fluid_ViewHelpers_Form_TextareaViewHelper
  6. {
  7.     protected static $_RTEcounter = 0;
  8.     protected $_storage;
  9.  
  10.     /**
  11.      * Initialize arguments.
  12.      * @return void
  13.      * @api
  14.      */
  15.     public function initializeArguments()
  16.     {
  17.         $this->registerTagAttribute('formName', 'string', 'The form name that contains rte', true);
  18.         parent::initializeArguments();
  19.     }
  20.  
  21.     /**
  22.      * Renders the textarea.
  23.      *
  24.      * @return string
  25.      * @api
  26.      */
  27.     public function render()
  28.     {
  29.         $this->_initRTE();
  30.  
  31.         if (!$this->isAvailable())
  32.         {
  33.             return parent::render();
  34.         }
  35.        
  36.         $content = $this->_storage->additionalJS_initial . '<script type="text/javascript">'. implode(chr(10), $this->_storage->additionalJS_pre) . '</script>';
  37.        
  38.         $RTEItem = $this->getRTE()->drawRTE($this->_storage, $this->_storage->table, $this->_storage->field, $row = array(), $this->_storage->PA, $this->_storage->specConf, $this->_storage->thisConfig, $this->_storage->RTEtypeVal, '', $this->_storage->thePidValue);
  39.        
  40.         $content .= $RTEItem . '<script type="text/javascript">' . implode(chr(10), $this->_storage->additionalJS_post) . '</script>';
  41.  
  42.         $this->registerFieldNameForFormTokenGeneration($this->getName());
  43.         $this->setErrorClassAttribute();
  44.         return $content;
  45.     }
  46.  
  47.     public function getRTE()
  48.     {
  49.         return (!$this->isAvailable())?null:$this->_storage->RTEObj;
  50.     }
  51.  
  52.     public function isAvailable()
  53.     {
  54.         return (!empty($this->_storage->RTEObj) && $this->_storage->RTEObj->isAvailable());
  55.     }
  56.  
  57.     protected function _initRTE()
  58.     {
  59.         $this->_storage = new Tx_FETest_Utility_RTEStorage();
  60.         $this->_storage->RTEObj = t3lib_div::makeInstance('tx_rtehtmlarea_pi2');
  61.         if (!$this->isAvailable())
  62.         {
  63.             return;
  64.         }
  65.  
  66.         self::$_RTEcounter++;
  67.  
  68.         $this->_storage->table = 'my-table-name';
  69.         $this->_storage->field = $this->getName();
  70.         $this->_storage->formName = $this->arguments['formName'];
  71.         $this->_storage->pluginKey = 'tx_myextension_pi1';
  72.         $this->_storage->PA['itemFormElName'] = $this->_storage->pluginKey . '[' . $this->_storage->field . ']';
  73.         $this->_storage->PA['itemFormElValue'] = stripslashes($_POST[ $this->_storage->field ]);
  74.         $this->_storage->thePidValue = $GLOBALS['TSFE']->id;
  75.     }
  76. }
  77.  
  78. # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement