/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $dom = One_Repository::createDom(); $dom->add('<div id="content-sliders-" class="pane-sliders"> <div style="display:none;"> <div></div> </div>'); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div>'); One_Vendor::getInstance()->loadScript(preg_replace('!administrator(/?)$!', '', JURI::base()) . '/media/system/js/mootools-core.js', 'head', 30); One_Vendor::getInstance()->loadScript(preg_replace('!administrator(/?)$!', '', JURI::base()) . '/media/system/js/core.js', 'head', 31); One_Vendor::getInstance()->loadScript(preg_replace('!administrator(/?)$!', '', JURI::base()) . '/media/system/js/mootools-more.js', 'head', 32); One_Vendor::getInstance()->loadScriptDeclaration('new Fx.Accordion($$("div#content-sliders-.pane-sliders > .panel > h3.pane-toggler"), $$("div#content-sliders-.pane-sliders > .panel > div.pane-slider"), { onActive: function(toggler, i) { toggler.addClass("pane-toggler-down");toggler.removeClass("pane-toggler");i.addClass("pane-down");i.removeClass("pane-hide");Cookie.write("jpanesliders_content-sliders-",$$("div#content-sliders-.pane-sliders > .panel > h3").indexOf(toggler)); },onBackground: function(toggler, i) { toggler.addClass("pane-toggler");toggler.removeClass("pane-toggler-down");i.addClass("pane-hide");i.removeClass("pane-down");if($$("div#content-sliders-.pane-sliders > .panel > h3").length==$$("div#content-sliders-.pane-sliders > .panel > h3.pane-toggler").length) Cookie.write("jpanesliders_content-sliders-",-1); },duration: 300,opacity: false,alwaysHide: true});', 'onload', 10); One_Vendor::getInstance()->loadScriptDeclaration('new Fx.Accordion($$("div#content-sliders.pane-sliders .panel h3.pane-toggler"),$$("div#content-sliders.pane-sliders .panel div.pane-slider"), { onActive: function(toggler, i) { toggler.addClass("pane-toggler-down");toggler.removeClass("pane-toggler");i.addClass("pane-down");i.removeClass("pane-hide");Cookie.write("jpanesliders_content-sliderscom_content",$$("div#content-sliders.pane-sliders .panel h3").indexOf(toggler)); },onBackground: function(toggler, i) { toggler.addClass("pane-toggler");toggler.removeClass("pane-toggler-down");i.addClass("pane-hide");i.removeClass("pane-down"); }, duration: 300, display: 0, show: 0, alwaysHide:true, opacity: false});', 'onload', 11); $d->addDom($dom); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $params = $this->getParametersAsString(); $events = $this->getEventsAsString(); $title = $this->getCfg('title'); $dom = One_Repository::createDom(); $dom->add('<div id="' . $id . '"' . $params . $events . '>' . "\n"); $dom->add('<h3 id="' . $id . '-title" class="jpane-toggler title"' . $params . $events . '><span>' . $title . '</span></h3>' . "\n"); $dom->add("<div class='jpane-slider content'>"); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div></div>'); // add js declaration for the panel $options = '{'; $opt['onActive'] = 'function(toggler, i) { toggler.addClass(\'jpane-toggler-down\'); toggler.removeClass(\'jpane-toggler\'); }'; $opt['onBackground'] = 'function(toggler, i) { toggler.addClass(\'jpane-toggler\'); toggler.removeClass(\'jpane-toggler-down\'); }'; $opt['duration'] = 200; foreach ($opt as $k => $v) { if ($v) { $options .= $k . ': ' . $v . ','; } } if (substr($options, -1) == ',') { $options = substr($options, 0, -1); } $options .= '}'; // $dom->add('window.addEvent(\'domready\', function(){ new Accordion($$(\'.panel h3.jpane-toggler\'), $$(\'.panel div.jpane-slider\'), '.$options.'); });', '_onload'); One_Vendor::getInstance()->loadScriptDeclaration('window.addEvent(\'domready\', function(){ new Accordion($$(\'.panel h3.jpane-toggler\'), $$(\'.panel div.jpane-slider\'), ' . $options . '); });', 'onload', 10); $d->addDom($dom); }
protected function _render($model, One_Dom $d) { $output = ''; $captcha = $this->generateCaptcha(); $allowed = $this->allowedOptions(); $info = $this->getCfg('info'); $error = $this->getCfg('error'); $dom = One_Repository::createDom(); $config = array(); foreach ($this->getParameters() as $param => $value) { if ($allowed[$param] & 1) { $config[$param] = $value; } } $input = new One_Form_Widget_Scalar_Textfield('captcha', 'captcha', NULL, NULL, $config); $dom->add('<div class="OneCaptcha">'); $dom->add('<img src="' . $captcha . '" alt="captcha" />'); $input->render($model, $dom); if (is_null($info)) { //$output .= '<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>'; $dom->add('<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>'); } if (is_null($error)) { //$output .= '<span id="' . $id . 'Error" class="OneError">' . $error . '</span>'; $dom->add('<span id="' . $id . 'Error" class="OneError">' . $error . '</span>'); } $dom->add('</div>'); //return $output; $d->addDom($dom); }
/** * This method composes the form and returns the output * * @return string Output of the form */ public function execute() { // Fetch the model needed for this form. We will need it because authorization can depend on the model itself if ($this->id) { $factory = One_Repository::getFactory($this->scheme->getName()); $model = $factory->selectOne($this->id); } else { $model = One::make($this->scheme->getName()); } if (is_null($model)) { throw new One_Exception('Could not generate a form for scheme "' . $this->scheme->getName() . '" with id ' . $this->id); } $this->authorize($this->scheme->getName(), $model->id); $session = One_Repository::getSession(); $formFile = $this->getVariable('formFile', 'form'); $form = One_Form_Factory::createForm($this->scheme, $formFile, $this->getVariable('lang'), 'oneForm', ''); // Create a DOM and render the form in it $dom = One_Repository::createDom(); $form->render($model, $dom); // print_r($dom); $this->view->setModel($model); $this->view->set('scheme', $this->scheme); $this->view->set('form', $form); $this->view->set('dom', $dom); $this->view->set('errors', $session->get('errors', 'OneFormErrors')); $vForm = $this->view->show(); $session->remove('errors', 'OneFormErrors'); $session->remove('posted', 'OneFormErrors'); return $vForm; }
protected function _render($model, One_Dom $d) { $id = $this->getID(); $name = $this->getFormName(); $label = $this->getLabel(); $info = $this->getCfg('info'); $error = $this->getCfg('error'); $dom = One_Repository::createDom(); $this->setCfg('class', 'OneFieldInput' . $this->getCfg('class')); $events = $this->getEventsAsString(); $params = $this->getParametersAsString(); //$output = ''; if (!is_null($label)) { //$output .= '<label class="OneFieldLabel" for="' . $id . '">' . $label . '</label>'."\n"; $dom->add('<label class="OneFieldLabel" for="' . $id . '">' . $label . '</label>' . "\n"); } //$output .= '<input type="'.$this->_totf.'" id="' . $id . '" name="' . $name . '"' . $events . $params . ' />'."\n"; $dom->add('<input type="' . $this->_totf . '" id="' . $id . '" name="' . $name . '"' . $events . $params . ' />' . "\n"); if (is_null($info)) { //$output .= '<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>'; $dom->add('<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>'); } if (is_null($error)) { //$output .= '<span id="' . $id . 'Error" class="OneError">' . $error . '</span>'; $dom->add('<span id="' . $id . 'Error" class="OneError">' . $error . '</span>'); } //return $output; $d->addDom($dom); }
public function renderPart(One_Form_Container_Form $form, $part, $model = NULL) { $toRender = self::getPart($form, $part); if (is_null($toRender)) { return ''; } else { $dom = One_Repository::createDom(); $toRender->render($model, $dom); return $dom->render(); } }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $title = $this->getCfg('title'); $dom = One_Repository::createDom(); $dom->add('<div id="' . $id . '" class="tabbertab' . (trim($this->getCfg('default')) == 'default' ? ' tabbertabdefault' : '') . '"' . (trim($title) != '' ? ' title="' . $title . '"' : '') . '>' . "\n"); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div>'); $d->addDom($dom); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $title = $this->getCfg('title'); $dom = One_Repository::createDom(); $dom->add('<div id="' . $id . '" class="mootabs_panel">' . "\n"); $d->mootitles[] = array('id' => $id, 'title' => $title); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div>'); $d->mootabs[] = $dom; }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $params = $this->getParametersAsString(); $events = $this->getEventsAsString(); $dom = One_Repository::createDom(); $dom->add('<div id="' . $id . '"' . $params . $events . '>' . "\n"); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div>'); $d->addDom($dom); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = md5($this->getID() . microtime(true)); $title = '' != trim($this->getCfg('title')) ? trim($this->getCfg('title')) : $this->getID(); $dom = One_Repository::createDom(); $dom->add('<div id="' . $id . '"">' . "\n"); $d->jqtitles[] = array('id' => $id, 'title' => $title); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div>'); $d->jqtabs[] = $dom; }
/** * Render the output of the widget and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $this->setCfg('class', 'OneFieldInput ' . $this->getCfg('class')); $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'required' => $this->isRequired() ? ' *' : '', 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'One::getInstance()->getUrl()' => One_Config::getInstance()->getUrl()); $dom = One_Repository::createDom(); $dom->add('<script type="text/javascript" src="' . One_Vendor::getInstance()->getSitePath() . '/js/ColorPicker2.js"></script>', '_head'); $dom->add('<script type="text/javascript"> var cp = new ColorPicker( "window" ); </script>', '_head'); $content = $this->parse($model, $data); $d->addDom($dom); $d->addDom($content); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $params = $this->getParametersAsString(); $events = $this->getEventsAsString(); $title = $this->getCfg('title'); $dom = One_Repository::createDom(); $dom->add('<div class="panel">' . "\n"); $dom->add('<h3 id="' . $id . '-title" class="pane-toggler title"' . $params . $events . '><a href="javascript:void(0);"><span>' . $title . '</span></a></h3>' . "\n"); $dom->add('<div class="pane-slider content">'); foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('</div></div>'); $d->addDom($dom); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $params = $this->getParametersAsString(); $events = $this->getEventsAsString(); $dom = One_Repository::createDom(); $dom->add('<fieldset id="' . $id . '"' . $params . $events . '>' . "\n"); if (trim($this->getCfg('legend')) != '') { $dom->add('<legend>' . $this->getCfg('legend') . '</legend>'); } foreach ($this->getContent() as $widget) { $dom->add($widget->render($model, $dom)); } $dom->add('</fieldset>' . "\n"); $d->addDom($dom); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $params = $this->getParametersAsString(); $events = $this->getEventsAsString(); $dom = One_Repository::createDom(); $dom->add('<blockquote id="' . $id . '"' . $params . $events . '>' . "\n"); foreach ($this->getContent() as $widget) { if ($widget instanceof One_Form_Widget_Abstract) { $dom->add($widget->render($model, $dom)); } else { $dom->add($widget); } } $dom->add('</blockquote>' . "\n"); $d->addDom($dom); }
/** * This method renders the search form and if needed fetches and show the search results * @see plugins/system/one/lib/action/One_Controller_Action#execute() */ public function execute() { $this->authorize($this->scheme, $model->id); $results = NULL; $model = One::make($this->scheme->getName()); $cx = new One_Context(); $session = One_Repository::getSession(); if (!is_null($cx->get('doSearch'))) { $session->remove('usedSearchOptions', 'one_search'); $results = $this->performSearch(); $session->set('usedSearchOptions', $this->options, 'one_search'); } else { if (!is_null($cx->get('doWeightSearch'))) { $session->remove('usedSearchOptions', 'one_search'); $results = $this->performWeightSearch(); $session->set('usedSearchOptions', $this->options, 'one_search'); } else { if (isset($this->options['savedSearch'])) { if ($session->varExists('usedSearchOptions', 'one_search')) { $this->options = $session->get('usedSearchOptions', 'one_search'); if (isset($this->options['doSearch'])) { $results = $this->performSearch(); } else { if (isset($this->options['doWeightSearch'])) { $results = $this->performWeightSearch(); } } } } else { $session->remove('usedSearchOptions', 'one_search'); $session->remove('results', 'one_search'); } } } $dom = One_Repository::createDom(); $this->view->setModel($model); $this->view->set('scheme', $this->scheme); $this->view->set('formfile', $this->searchform); $this->view->set('results', $results); $vForm = $this->view->show(); return $vForm; }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $width = is_null($this->getCfg('width')) ? 400 : intval($this->getCfg('width')); $height = is_null($this->getCfg('height')) ? 300 : intval($this->getCfg('height')); $css = is_null($this->getCfg('css')) ? One_Vendor::getInstance()->getSitePath() . '/mootabs/mootabs1.2.css' : $this->getCfg('css'); $dom = One_Repository::createDom(); $dom->add('<script type="text/javascript" src="' . One_Vendor::getInstance()->getSitePath() . '/mootabs/mootabs1.2.js"></script>', '_head'); $dom->add('<script type="text/javascript"> function initMooTabs' . $id . '() { myTabs' . $id . ' = new mootabs( "' . $id . '", { changeTransition: "none", mouseOverClass: "over", width: ' . $width . ', height: ' . $height . ' } ); } window.addEvent("domready", initMooTabs' . $id . ' ); </script>', '_head'); $dom->add('<link href="' . $css . '" rel="stylesheet" type="text/css" />', '_head'); $dom->mootabs = array(); $dom->mootitles = array(); // add tabs foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('<div id="' . $id . '">' . "\n"); $dom->add('<ul class="mootabs_title">' . "\n"); $active = ' class="active"'; foreach ($dom->mootitles as $mootab) { $dom->add('<li title="' . $mootab['id'] . '"' . $active . '>' . $mootab['title'] . '</li>'); $active = ''; } $dom->add('</ul>' . "\n"); foreach ($dom->mootabs as $mootab) { $dom->addDom($mootab); } $dom->add("</div>"); $dom->mootabs = NULL; $dom->mootitles = NULL; $d->addDom($dom); }
/** * Render the output of the container and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = md5($this->getID() . microtime(true)); $dom = One_Repository::createDom(); $dom->jqtabs = array(); $dom->jqtitles = array(); // add tabs foreach ($this->getContent() as $content) { $content->render($model, $dom); } $dom->add('<div id="' . $id . '">' . "\n"); $dom->add('<ul>' . "\n"); foreach ($dom->jqtitles as $jqtab) { $dom->add('<li><a href="#' . $jqtab['id'] . '">' . $jqtab['title'] . '</a></li>'); } $dom->add('</ul>' . "\n"); foreach ($dom->jqtabs as $jqtab) { $dom->addDom($jqtab); } $dom->add("</div>"); $js .= ' <script type="text/javascript"> jQuery(function() { jQuery("#' . $id . '").tabs({ ajaxOptions: { error: function( xhr, status, index, anchor ) { $( anchor.hash ).html( "Error loading data" ); } } }); }); </script> '; $dom->add($js); $dom->jqtabs = NULL; $dom->jqtitles = NULL; $d->addDom($dom); }
/** * Renders the HTML widget. * This widget is too specific to render with One_Script and should not be rendered otherwise, * hence this does not use the One_Form_Container_Abstract::parse() function * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $id = $this->getID(); $name = $this->getFormName(); $value = $this->getValue($model); if (is_null($value)) { $value = $this->getDefault(); } $info = $this->getCfg('info'); $error = $this->getCfg('error'); $width = intval($this->getCfg('width')) ? 600 : intval($this->getCfg('width')); $height = intval($this->getCfg('height')) ? 300 : intval($this->getCfg('height')); $dom = One_Repository::createDom(); $this->setCfg('class', 'OneFieldHtml ' . $this->getCfg('class')); $events = $this->getEventsAsString(); $params = $this->getParametersAsString(); $theme = $this->getCfg('theme') ? $this->getCfg('theme') : "simple"; if (!is_null($this->getLabel())) { $label = '<label class="OneFieldLabel" for="' . $id . '" style="float: none;">' . $this->getLabel() . ($this->isRequired() ? ' *' : '') . '</label>' . "\n"; } if (strtolower($this->_editor) == 'joomla') { ob_start(); echo "<span class='OneWidget'>"; if ($label && !$this->getCfg('lblLast')) { echo $label; } $editor = JFactory::getEditor(); echo $editor->display($name, $value, $width, $height, '20', '60', array('image', 'pagebreak', 'readmore')); if ($label && $this->getCfg('lblLast')) { echo $label; } echo "</span>"; $result = ob_get_contents(); ob_end_clean(); $dom->add($result); $d->addDom($dom); } else { $head .= '<script type="text/javascript" src="' . JURI::root() . 'plugins/editors/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>'; $dom->add($head, '_head'); // @todo: tinyMCE.init in onload (��n keer) $main = '<script type="text/javascript"> tinyMCE.init({ theme : "' . $theme . '", language : "en", mode : "textareas", gecko_spellcheck : "true", editor_selector : "mce' . ucfirst($theme) . '", document_base_url : "' . JURI::root() . '", entities : "60,lt,62,gt", relative_urls : 1, remove_script_host : false, save_callback : "TinyMCE_Save", invalid_elements : "applet", extended_valid_elements : "a[class|name|href|target|title|onclick|rel],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],,hr[id|title|alt|class|width|size|noshade]", theme_advanced_toolbar_location : "top", theme_advanced_source_editor_height : "550", theme_advanced_source_editor_width : "750", directionality: "ltr", force_br_newlines : "false", force_p_newlines : "true", content_css : "' . JURI::root() . 'templates/ja_xenia/css/editor.css", debug : false, cleanup : true, cleanup_on_startup : false, safari_warning : false, plugins : "advlink, advimage, searchreplace,insertdatetime,emotions,media,advhr,table,fullscreen,directionality,layer,style", theme_advanced_buttons1_add : "fontselect", theme_advanced_buttons2_add : "search,replace,insertdate,inserttime,emotions,media,ltr,rtl,insertlayer,moveforward,movebackward,absolute,forecolor", theme_advanced_buttons3_add : "advhr,tablecontrols,fullscreen,styleprops", theme_advanced_disable : "help", plugin_insertdate_dateFormat : "%Y-%m-%d", plugin_insertdate_timeFormat : "%H:%M:%S", fullscreen_settings : { theme_advanced_path_location : "top" } }); function TinyMCE_Save(editor_id, content, node) { base_url = tinyMCE.settings[\'document_base_url\']; var vHTML = content; if (true == true){ vHTML = tinyMCE.regexpReplace(vHTML, \'href\\s*=\\s*"?\'+base_url+\'\', \'href="\', \'gi\'); vHTML = tinyMCE.regexpReplace(vHTML, \'src\\s*=\\s*"?\'+base_url+\'\', \'src="\', \'gi\'); vHTML = tinyMCE.regexpReplace(vHTML, \'mce_real_src\\s*=\\s*"?\', \'\', \'gi\'); vHTML = tinyMCE.regexpReplace(vHTML, \'mce_real_href\\s*=\\s*"?\', \'\', \'gi\'); } return vHTML; } </script>'; $dom->add($main, '_head'); $this->setCfg('class', 'mce' . ucfirst($theme) . ' ' . $this->getCfg('class')); $conf = $this->getParameters(); // @todo: why this line? // unset($conf['theme']); $dom->add("<span class='OneWidget'>"); // start with label? if ($label && !$this->getCfg('lblLast')) { $dom->add($label); } // render the required textarea $ta = new OneFormWidgetTextarea($id, $this->getOriginalName(), NULL, array_merge($conf, array('style' => "width:' . {$width} . 'px; height:' . {$height} . 'px;"))); $ta->render($model, $dom); // end with label? if ($label && $this->getCfg('lblLast')) { $dom->add($label); } $dom->add("</span>"); $script = 'tinyMCE.execCommand("mceAddControl", false, "' . $id . '");'; $dom->add($script, '_onload'); if (is_null($info)) { $dom->add('<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>'); } if (is_null($error)) { $dom->add('<span id="' . $id . 'Error" class="OneError">' . $error . '</span>'); } $onload = '<script type="text/javascript">tinyMCE.init();</script>'; $dom->add($onload); $d->addDom($dom); } }
/** * Renders the Joomla-Media widget. * This widget is too specific to render with One_Script and should not be rendered otherwise, * hence this does not use the One_Form_Container_Abstract::parse() function * * @param One_Model $model * @param One_Dom $d * @access protected */ protected function _render($model, One_Dom $d) { $formName = $this->getFormName(); $name = $this->getName(); $id = $this->getID(); $dom = One_Repository::createDom(); JHtml::_('behavior.modal'); // Build the script. $script = array(); $script[] = ' function jInsertFieldValue(value, id) {'; $script[] = ' var old_id = document.id(id).value;'; $script[] = ' if (old_id != id) {'; $script[] = ' var elem = document.id(id);'; $script[] = ' elem.value = value;'; $script[] = ' elem.fireEvent("change");'; $script[] = ' }'; $script[] = ' }'; // Add the script to the document head. One_Vendor::getInstance()->loadScriptDeclaration(implode("\n", $script), "head", 10); // should we show a label? if (!is_null($this->getLabel())) { $label = '<label class="OneFieldLabel" for="' . $id . '">' . $this->getLabel() . ($this->isRequired() ? ' *' : '') . '</label>' . "\n"; } $dom->add("<span class='OneWidget'>"); // start with label? if ($label && !$this->getCfg('lblLast')) { $dom->add($label); } // Initialize variables. $html = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->getCfg('class') ? ' class="' . (string) $this->getCfg('class') . '"' : ''; // The text field. $html[] = '<div class="fltlft">'; $html[] = ' <input type="text" name="' . $this->getFormName() . '" id="' . $this->getID() . '"' . ' value="' . htmlspecialchars($this->getValue($model), ENT_COMPAT, 'UTF-8') . '"' . ' readonly="readonly"' . $attr . ' />'; $html[] = '</div>'; $directory = (string) $this->getCfg('directory'); if ($this->getValue($model) && file_exists(JPATH_ROOT . '/' . $this->getValue($model))) { $folder = explode('/', $this->getValue($model)); array_shift($folder); array_pop($folder); $folder = implode('/', $folder); } elseif (file_exists(JPATH_ROOT . '/' . JComponentHelper::getParams('com_media')->get('image_path', 'images') . '/' . $directory)) { $folder = $directory; } else { $folder = ''; } $authorfield = $this->getCfg('authorfield'); $author = 0; if (!is_null($authorfield) && $authorfield != '') { $author = intval($model->{$authorfield}); } // The button. $html[] = '<div class="button2-left">'; $html[] = ' <div class="blank">'; $html[] = ' <a class="modal" title="' . JText::_('JLIB_FORM_BUTTON_SELECT') . '"' . ' href="' . 'index.php?option=com_media&view=images&tmpl=component&asset=15&author=' . $author . '&fieldid=' . $this->getID() . '&folder=' . $folder . '"' . ' rel="{handler: \'iframe\', size: {x: 800, y: 500}}">'; $html[] = JText::_('JLIB_FORM_BUTTON_SELECT') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; $html[] = '<div class="button2-left">'; $html[] = ' <div class="blank">'; $html[] = ' <a title="' . JText::_('JLIB_FORM_BUTTON_CLEAR') . '"' . ' href="#" onclick="'; $html[] = 'document.id(\'' . $this->getID() . '\').value=\'\';'; $html[] = 'document.id(\'' . $this->getID() . '\').fireEvent(\'change\');'; $html[] = 'return false;'; $html[] = '">'; $html[] = JText::_('JLIB_FORM_BUTTON_CLEAR') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; $dom->add(implode("\n", $html)); // end with label? if ($label && $this->getCfg('lblLast')) { $dom->add($label); } $dom->add("</span>"); $d->addDom($dom); }
/** * Parse the output of the widget with nanoscript * * @param One_Model $model * @param array $data */ protected function parse($model, $data = array()) { // general Dataset $data['excludeError'] = in_array($this->getCfg('excludeError'), array('true', 'yes', '1', 'exclude', 'excludeError')) ? 1 : 0; // determine if we need to look for the template-file in a subfolder of widget $widgetClass = preg_match('/One_Form_Widget_Default_/', get_class($this)) ? get_parent_class($this) : get_class($this); $current = str_replace('One_Form_Widget_', '', $widgetClass); $parts = preg_split('/_/', strtolower($current)); // array_pop($parts); $wtype = implode(DIRECTORY_SEPARATOR, $parts); $formChrome = One_Config::get('form.chrome', ''); $pattern = "%ROOT%/views/" . "{%APP%,default}/" . "oneform/" . ($formChrome ? "{" . $formChrome . '/,}' : '') . "widget/" . ($wtype ? "{" . $wtype . "/,}" : '') . "{%LANG%/,}"; One_Script_Factory::pushSearchPath($pattern); $script = new One_Script(); // $script->load($this->_type . '.html'); $script->load($wtype . '.html'); if ($script->error) { One_Script_Factory::popSearchPath(); throw new One_Exception('Error loading template for widget ' . $this->_type . ' : ' . $script->error); } $dom = One_Repository::createDom(); $dom->add($script->execute($data)); return $dom; }
/** * Renders the Joomla-HTML widget. * This widget is too specific to render with One_Script and should not be rendered otherwise, * hence this does not use the One_Form_Container_Abstract::parse() function * * @param One_Model $model * @param One_Dom $d * @access protected */ protected function _render($model, One_Dom $d) { $editor = JFactory::getEditor(); JHTML::_('behavior.tooltip'); $width = $this->getParameter('width') ? $this->getParameter('width') : '100%'; $height = $this->getParameter('height') ? $this->getParameter('height') : '550'; //TODO: clean this up, should add a 'save editor' part for each control, multiple controls do not work now ob_start(); ?> <script language="javascript" type="text/javascript"> <!-- function submitbutton(pressbutton) { var form = document.adminForm; if (pressbutton == 'cancel') { submitform( pressbutton ); return; } //save <?php echo $editor->save($this->getFormName()); ?> submitform( pressbutton ); } //--> </script> <?php echo preg_replace('/<div class="button2-left"><div class="translate">(.*?)(<\\/div><\\/div>)/is', '', $editor->display($this->getFormName(), $this->getValue($model), $width, $height, '75', '20')); $edit = ob_get_clean(); if (!is_null($this->getCfg('buttons')) && in_array($this->getCfg('buttons'), array('no', '0', 'false'))) { $edit = preg_replace('/<div class="button2-left">(.*?)(<\\/div><\\/div>)/is', '', $edit); } JHTML::_('behavior.modal'); JHTML::_('behavior.modal', 'a.modal-button'); $dom = One_Repository::createDom(); $dom->add('<span class="OneWidget clearfix">'); // should we show a label? if (!is_null($this->getLabel()) && !$this->getCfg('noLabel')) { $label = '<label class="OneFieldLabel" for="' . $this->getID() . '">' . $this->getLabel() . ($this->isRequired() ? ' *' : '') . '</label>' . "\n"; } // start with label? if ($label && !$this->getCfg('lblLast')) { $dom->add($label); } $app = JFactory::getApplication(); $jDoc = JFactory::getDocument(); $dom->add('<div class="OneWidgetEditor">'); $dom->add($edit); $dom->add('</div>'); // end with label? if ($label && $this->getCfg('lblLast')) { $dom->add($label); } $dom->add('</span>'); $d->addDom($dom); }
protected function renderJQueryDatepicker($model, One_Dom $d) { // include most common jquery files from vendor One_Vendor::requireVendor('jquery/one_loader'); $id = $this->getID(); $name = $this->getName(); $value = $this->getValue($model); $dom = One_Repository::createDom(); $extraParams = array('default' => $this->getDefault()); if (in_array($this->getCfg('one'), array('one', 'yes', 'true', '1'))) { $extraParams['one'] = 'one'; } if ('readonly' == $this->getCfg('readonly')) { $extraParams['readonly'] = 'readonly'; } $tf = new One_Form_Widget_Scalar_Textfield($id, $name, NULL, $extraParams); $tf->render($model, $dom); $pickerType = 'date'; $timeFormat = ''; if (trim($this->getCfg('time')) != '') { One_Vendor::getInstance()->loadScript('jquery/js/jquery-ui-timepicker-addon.js', 'head', 10); One_Vendor::getInstance()->loadStyle('jquery/css/ui.timepicker.addon.css', 'head', 10); $pickerType = 'datetime'; $timeFormat = ' timeFormat: "hh:mm:ss",'; } $script = ' jQuery("#' . $id . '").' . $pickerType . 'picker({ dateFormat: "yy-mm-dd",' . $timeFormat . ' showButtonPanel: true' . ('' != trim($value) ? ', defaultDate: "' . $value . '"' : '') . ' });'; One_Vendor::getInstance()->loadScriptDeclaration($script, 'onload'); $d->addDom($dom); }
/** * Render the form ending and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ public function renderEnd($model, One_Dom $d) { $dom = One_Repository::createDom(); $dom->add('</form>' . "\n"); $d->addDom($dom); }
/** * Renders the Joomla-Media widget. * This widget is too specific to render with One_Script and should not be rendered otherwise, * hence this does not use the One_Form_Container_Abstract::parse() function * * @param One_Model $model * @param One_Dom $d * @access protected */ protected function _render($model, One_Dom $d) { JHTML::_('behavior.modal'); JHTML::_('behavior.modal', 'a.modal-button'); $formName = $this->getFormName(); $name = $this->getName(); $id = $this->getID(); $link = 'index.php?option=com_media&view=images&tmpl=component&oneWidget=true&e_name=' . $name; $button = new JObject(); $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('Image')); $button->set('name', 'image'); $button->set('options', "{handler: 'iframe', size: {x: 570, y: 400}}"); $modal = $button->get('modal') ? 'class="modal-button"' : null; $href = $button->get('link') ? 'href="' . JURI::base() . $button->get('link') . '"' : null; $onclick = $button->get('onclick') ? 'onclick="' . $button->get('onclick') . '"' : null; $dom = One_Repository::createDom(); // should we show a label? if (!is_null($this->getLabel())) { $label = '<label class="OneFieldLabel" for="' . $id . '">' . $this->getLabel() . ($this->isRequired() ? ' *' : '') . '</label>' . "\n"; } $dom->add("<span class='OneWidget'>"); // start with label? if ($label && !$this->getCfg('lblLast')) { $dom->add($label); } $app = JFactory::getApplication(); $jDoc = JFactory::getDocument(); $path = ''; if ($app->getName() != 'site') { $path = '../'; } $mediaParams = JComponentHelper::getParams('com_media'); $imageExtensions = $mediaParams->get('image_extensions'); $imageExtensions = explode(',', $imageExtensions); preg_match('/\\.([a-z0-3]{1,4})$/i', $model->{$name}, $match); $currExt = $match[1]; $isImage = in_array($currExt, $imageExtensions); $currImgSrc = $path . ($isImage ? $model->{$name} : 'images/spacer.gif'); $thWidth = !is_null($this->getCfg('thWidth')) ? $this->getCfg('thWidth') : 50; $setMedia = 'function changeMedia( item, path ) { document.getElementById( item ).value = path; var setImg = "' . $path . 'images/spacer.gif"; if( path.match( /\\.(' . implode('|', $imageExtensions) . ')$/ ) ) setImg = "' . $path . '" + ' . 'path; document.getElementById( "thImg" + item ).src = setImg; document.getElementById( "thImg" + item ).style.width = "' . $thWidth . 'px"; document.getElementById( "thImgLink" + item ).href = setImg; document.getElementById("OneThumb"+item).style.display = "block"; } function clearOneJMediaImg( item ) { document.getElementById( item ).value = ""; var setImg = "' . $path . 'images/spacer.gif"; document.getElementById( "thImg" + item ).src = setImg; document.getElementById( "thImgLink" + item ).href = setImg; document.getElementById("OneThumb"+item).style.display = "none"; }'; // slimbox must be loaded AFTER mootools (current slimbox is meant for mootools 1.11) $jDoc->addScript(One_Config::getInstance()->getUrl() . '/vendor/slimbox/js/slimbox.js', 'text/javascript'); $jDoc->addStyleSheet(One_Config::getInstance()->getUrl() . '/vendor/slimbox/css/slimbox.css', 'text/css', 'screen'); $jDoc->addScriptDeclaration($setMedia); // show the input $dom->add('<div style="float: left;">'); $dom->add('<input class="OneFieldInput" type="text" name="' . $formName . '" id="' . $id . '" size="50" readonly="readonly" value="' . $model->{$name} . '" />' . "\n"); $dom->add('</div>'); $dom->add('<div class="button2-left">'); $dom->add('<div class="' . $button->get('name') . '">'); $dom->add('<a ' . $modal . ' title="' . $button->get('text') . '" ' . $href . ' ' . $onclick . ' rel="' . $button->get('options') . '">' . $button->get('text') . '</a>'); $dom->add('</div></div>'); $dom->add('<div class="button2-left">'); $dom->add('<div class="' . $button->get('name') . '">'); $dom->add('<a href="#" onclick="clearOneJMediaImg( \'' . $id . '\' ); return false;">Clear image</a>'); //TODO: clear thumb image $dom->add('</div>'); $dom->add('</div>'); $dom->add('<div class="OneThumb" id="OneThumb' . $id . '"' . ('' == trim($currImgSrc) || $path . 'images/spacer.gif' == trim($currImgSrc) ? ' style="display: none;"' : '') . '>'); $dom->add('<a href="' . $currImgSrc . '" id="thImgLink' . $id . '" rel="lightbox"><img id="thImg' . $id . '" src="' . $currImgSrc . '" width="' . $thWidth . '" /></a>'); $dom->add('</div>'); // end with label? if ($label && $this->getCfg('lblLast')) { $dom->add($label); } $dom->add("</span>"); $d->addDom($dom); }