public function render($layout, $args = array()) { // prevent render to recurse indefinitely static $count = 0; $count++; if ($count < self::MAX_RENDER_RECURSIONS) { // init vars $parts = explode($this->_separator, $layout); $this->_layout = preg_replace('/[^A-Z0-9_\\.-]/i', '', array_pop($parts)); // render layout if ($__layout = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_layout . $this->_extension)) { // import vars and layout output extract($args); ob_start(); include $__layout; $output = ob_get_contents(); ob_end_clean(); $count--; return $output; } $count--; // raise warning, if layout was not found JError::raiseWarning(0, 'Renderer Layout "' . $layout . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')'); return null; } // raise warning, if render recurses indefinitly JError::raiseWarning(0, 'Warning! Render recursed indefinitly. (' . YUtility::debugInfo(debug_backtrace()) . ')'); return null; }
public function partial($name, $args = array()) { // clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', '_' . $name); // set template path and add global partials $path = $this->_path['template']; $path[] = $this->_basePath . DS . 'partials'; // load the partial $__file = $this->_createFileName('template', array('name' => $file)); $__partial = JPath::find($path, $__file); // render the partial if ($__partial != false) { // import vars and get content extract($args); ob_start(); include $__partial; $output = ob_get_contents(); ob_end_clean(); return $output; } return JError::raiseError(500, 'Partial Layout "' . $__file . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')'); }
public static function saveElements($post, Type $type) { // init vars $elements = array(); // update old elements foreach ($type->getElements() as $identifier => $element) { if (isset($post['elements'][$identifier])) { $data = $post['elements'][$identifier]; // bind data $element->bindConfig($data); // add to element array $elements[$data['ordering']] = $element; } } // add new elements if (isset($post['new_elements'])) { foreach ($post['new_elements'] as $data) { $element = ElementHelper::loadElement($data['type'], $type->getApplication()->getPath() . '/elements'); $element->setType($type); // set identifier (UUID) $data['identifier'] = YUtility::generateUUID(); // bind data $element->bindConfig($data); // add to element array $elements[$data['ordering']] = $element; } } // sort elements ksort($elements); $type->setXML(self::toXML($elements)); $type->clearElements(); return true; }
public function render($params = array()) { // init vars $width = $this->_data->get('width'); $height = $this->_data->get('height'); $autoplay = $this->_data->get('autoplay', false); $autoplay_bool = $autoplay ? 'true' : 'false'; $autoplay_google = $autoplay ? 'autoplay:"true"' : ''; $directory = $this->_config->get('directory'); $formats = $this->_getVideoFormats(); $file = $this->_data->get('file'); $source = $file ? JURI::root() . $directory . '/' . $file : $this->_data->get('url'); $format = $this->getVideoFormat($source); if (isset($formats[$format])) { if (in_array($format, array('flv', 'swf', 'youtube.com', 'video.google.com', 'vimeo.com', 'liveleak.com', 'vids.myspace.com'))) { JHTML::script('swfobject.js', 'administrator/components/com_zoo/elements/video/assets/js/'); $width = $width ? $width : 200; $height = $height ? $height : 200; } if (in_array($format, array('mov', 'mpg', 'mp4'))) { JHTML::script('quicktime.js', 'administrator/components/com_zoo/elements/video/assets/js/'); } // parse source link if (isset($formats[$format]['regex'])) { if (preg_match($formats[$format]['regex'], $source, $matches)) { if (isset($matches[1])) { $source = $matches[1]; } } } // video params $params = array("{SOURCE}", "{ID}", "{WIDTH}", "{HEIGHT}", "{AUTOPLAY}", "{AUTOPLAY-AS-INT}", "{AUTOPLAY-GOOGLE}"); // replacements $replace = array($source, "video-" . YUtility::generateUUID(), $width, $height, $autoplay_bool, $autoplay, $autoplay_google); return JFilterOutput::ampReplace(str_replace($params, $replace, $formats[$format]['html'])); } return JText::_('No video selected.'); }