Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(t3lib_extMgm::extPath('rtehtmlarea') . 'pi2/class.tx_rtehtmlarea_pi2.php');
- class Tx_FETest_ViewHelpers_Form_RTEViewHelper extends Tx_Fluid_ViewHelpers_Form_TextareaViewHelper
- {
- protected static $_RTEcounter = 0;
- protected $_storage;
- /**
- * Initialize arguments.
- * @return void
- * @api
- */
- public function initializeArguments()
- {
- $this->registerTagAttribute('formName', 'string', 'The form name that contains rte', true);
- parent::initializeArguments();
- }
- /**
- * Renders the textarea.
- *
- * @return string
- * @api
- */
- public function render()
- {
- $this->_initRTE();
- if (!$this->isAvailable())
- {
- return parent::render();
- }
- $content = $this->_storage->additionalJS_initial . '<script type="text/javascript">'. implode(chr(10), $this->_storage->additionalJS_pre) . '</script>';
- $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);
- $content .= $RTEItem . '<script type="text/javascript">' . implode(chr(10), $this->_storage->additionalJS_post) . '</script>';
- $this->registerFieldNameForFormTokenGeneration($this->getName());
- $this->setErrorClassAttribute();
- return $content;
- }
- public function getRTE()
- {
- return (!$this->isAvailable())?null:$this->_storage->RTEObj;
- }
- public function isAvailable()
- {
- return (!empty($this->_storage->RTEObj) && $this->_storage->RTEObj->isAvailable());
- }
- protected function _initRTE()
- {
- $this->_storage = new Tx_FETest_Utility_RTEStorage();
- $this->_storage->RTEObj = t3lib_div::makeInstance('tx_rtehtmlarea_pi2');
- if (!$this->isAvailable())
- {
- return;
- }
- self::$_RTEcounter++;
- $this->_storage->table = 'my-table-name';
- $this->_storage->field = $this->getName();
- $this->_storage->formName = $this->arguments['formName'];
- $this->_storage->pluginKey = 'tx_myextension_pi1';
- $this->_storage->PA['itemFormElName'] = $this->_storage->pluginKey . '[' . $this->_storage->field . ']';
- $this->_storage->PA['itemFormElValue'] = stripslashes($_POST[ $this->_storage->field ]);
- $this->_storage->thePidValue = $GLOBALS['TSFE']->id;
- }
- }
- # EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement