/** * Read n characters. * * @param int $length Length. * @return string * @throws \Hoa\Xml\Exception */ public function read($length) { if (0 > $length) { throw new Xml\Exception('Length must be greater than 0, given %d.', 0, $length); } if (null === parent::$_buffer) { parent::$_buffer = new Stringbuffer\ReadWrite(); parent::$_buffer->initializeWith($this->__toString()); } return parent::$_buffer->read($length); }
/** * Write n characters. * * @param string $string String. * @param int $length Length. * @return mixed * @throws \Hoa\Xml\Exception */ public function write($string, $length) { if (0 > $length) { throw new Xml\Exception('Length must be greater than 0, given %d.', 0, $length); } if (null === parent::$_buffer) { parent::$_buffer = new Stringbuffer\ReadWrite(); parent::$_buffer->initializeWith($this->__toString()); } $l = parent::$_buffer->write($string, $length); if ($l !== $length) { return false; } $this[0] = parent::$_buffer->readAll(); return $l; }
/** * Init the object data * * @param array $params - the configuration parameters * * @return boolean * @since 1.0 */ public function init($params) { $this->_caching = false; $this->_template = null; $this->_letter = null; $this->_parsed = null; $this->directory = null; $this->parsedTags = null; $this->renderMode = null; $this->tracking = null; $this->trackingGa = null; // reset all previous rendererd data for modules or placeholders parent::$_buffer = array(); $this->tracking = isset($params['tracking']) ? (bool) $params['tracking'] : true; $this->trackingGa = isset($params['trackingGa']) ? (bool) $params['trackingGa'] : true; $this->directory = !empty($params['directory']) ? $params['directory'] : JPATH_COMPONENT_ADMINISTRATOR . DS . 'extensions' . DS . 'templates'; $this->renderMode = !empty($params['renderMode']) ? $params['renderMode'] : 'full'; $this->showNames = !empty($params['showNames']); // if we already get the template then work with it. if (!empty($params['template'])) { $this->_template = $params['template']; return true; } // if request contains the letter ID... if (!empty($params['newsletter_id'])) { $this->_letter = $this->loadLetter($params['newsletter_id']); $this->_template = $this->_loadTemplate($this->_letter->t_style_id); return; } // And finaly try to find the template. if (!empty($params['t_style_id'])) { $this->_template = $this->_loadTemplate($params['t_style_id']); return true; } $this->setError('The PLAIN is not allowed because the NEWSLETTER is not loaded'); return false; }
/** * Truncate to a given length. * * @param int $size Size. * @return bool */ public function truncate($size) { if (null === parent::$_buffer) { parent::$_buffer = new Stringbuffer\ReadWrite(); parent::$_buffer->initializeWith($this->__toString()); } return parent::$_buffer->truncate($size); }