예제 #1
0
    /**
     * 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);
    }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
    /**
     * 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);
    }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }
예제 #6
0
 /**
  * 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(), 'totf' => $this->_totf, 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), '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'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #7
0
 /**
  * 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)
 {
     $op = $this->getOp($this->getCfg('optype'));
     $this->setCfg('class', 'OneFieldInput ' . $this->getCfg('class'));
     $data = array('id' => $this->getID(), 'name' => $this->getName(), 'totf' => $this->_totf, 'op' => null !== $op ? $op->render() : NULL, 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #8
0
 /**
  * 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)
 {
     if ($this->getCfg('showEmpty')) {
         $this->_options = array_merge(array('' => '---'), $this->_options);
     }
     $this->setCfg('class', 'OneFieldDropdown ' . $this->getCfg('class'));
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'options' => $this->_options, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #9
0
 /**
  * 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);
 }
예제 #10
0
 /**
  * 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);
 }
예제 #11
0
 /**
  * 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)
 {
     JHTML::_('behavior.modal');
     JHTML::_('behavior.modal', 'a.modal-button');
     $this->setCfg('class', 'OneFieldTextfield ' . $this->getCfg('class'));
     $path = preg_replace('{/|\\\\}', DIRECTORY_SEPARATOR, trim($this->getCfg('path')));
     if (substr($path, -1, 1) != DIRECTORY_SEPARATOR) {
         $path .= DIRECTORY_SEPARATOR;
     }
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'path' => $path, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'oneUrl' => One_Config::getInstance()->getUrl());
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #12
0
 /**
  * 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);
 }
예제 #13
0
 /**
  * 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);
 }
예제 #14
0
 /**
  * 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);
 }
예제 #15
0
 /**
  * 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)
 {
     $rKeyvals = $this->getCfg('options');
     if (null !== $rKeyvals) {
         // benedikt 17/04/09: code toegevoegd zodat de juiste labels & values gebruikt worden
         $rKeyvals = explode(';', $rKeyvals);
         $keyvals = array();
         foreach ($rKeyvals as $val) {
             $tmp = explode('=', $val);
             $keyvals[$tmp[0]] = $tmp[1];
         }
     } else {
         $keyvals = $this->getOptions();
     }
     $this->setCfg('class', 'OneFieldRadiogroup ' . $this->getCfg('class'));
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'options' => $keyvals, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #16
0
 /**
  * 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'));
     $value = is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model);
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'value' => $value, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'required' => $this->isRequired() ? ' *' : '', 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'oneUrl' => One_Config::getInstance()->getUrl(), 'vendorUrl' => One_Vendor::getInstance()->getSitePath(), 'path' => !is_null($this->getCfg('path')) ? $this->getCfg('path') : One_Config::getInstance()->getSiterootUrl(), 'isSimple' => !is_null($this->getCfg('simple')) ? 'yes' : 'no');
     if ('' != trim($value)) {
         $salt = 'DR$8efatrA4reb66fr+ch5$Ucujach3phe9U@AqutR8hajuq47a6&5tucHu58aSt';
         $encPath = base64_encode($this->getCfg('path') . '/' . $value);
         $forCheck = strlen($encPath);
         $check = md5($forCheck . $encPath . $salt);
         $encLabel = base64_encode($this->getLabel());
         preg_match('/\\.([a-z0-9]+)$/i', $value, $matches);
         $extension = $matches[1];
         $data['encPath'] = $encPath;
         $data['encLabel'] = $encLabel;
         $data['check'] = $check;
         $data['extension'] = $extension;
     }
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #17
0
    /**
     * 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);
    }
예제 #18
0
 /**
  * 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)
 {
     if ($this->getCfg('showEmpty')) {
         $keyvals = array();
         $keyvals[''] = '---';
         foreach ($this->_options as $key => $val) {
             $keyvals[$key] = $val;
         }
         $this->_options = $keyvals;
     }
     $value = count($this->getValue($model, $this->getCfg('role'))) == 0 ? $this->getDefault() : $this->getValue($model, $this->getCfg('role'));
     if (!is_array($value) && !is_null($value)) {
         $value = array($value);
     } else {
         if (is_null($value)) {
             $value = array();
         }
     }
     $this->setCfg('class', 'OneFieldDropdown ' . $this->getCfg('class'));
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => $value, 'options' => $this->_options, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #19
0
 /**
  * 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)
 {
     $rKeyvals = $this->getCfg('options');
     if (trim($rKeyvals) != '') {
         $rKeyvals = explode(';', $rKeyvals);
         $keyvals = array();
         foreach ($rKeyvals as $val) {
             $tmp = explode('=', $val);
             $keyvals[$tmp[0]] = $tmp[1];
         }
         $this->_options = $keyvals;
     }
     if ($this->getCfg('showEmpty')) {
         $tmp = array('' => '---');
         foreach ($this->_options as $key => $val) {
             $tmp[$key] = $val;
         }
         $this->_options = $tmp;
     }
     $this->setCfg('class', 'OneFieldDropdown ' . $this->getCfg('class'));
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'options' => $this->_options, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #20
0
 /**
  * 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&amp;view=images&amp;tmpl=component&amp;asset=15&amp;author=' . $author . '&amp;fieldid=' . $this->getID() . '&amp;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);
 }
예제 #21
0
    /**
     * 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);
    }
예제 #22
0
    /**
     * 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);
        }
    }
예제 #23
0
    /**
     * 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', 'OneFieldDropdown ' . $this->getCfg('class'));
        // fetch all data to do with the relationship
        $parts = explode(':', $this->getCfg('role'));
        $related = $model->getRelated($parts[1]);
        $targetAttr = $this->getCfg('targetAttribute');
        $triggerOn = intval($this->getCfg('triggerOn')) > 0 ? intval($this->getCfg('triggerOn')) : 2;
        $scheme = $model->getScheme();
        $idAttr = $scheme->getIdentityAttribute()->getName();
        $link = $scheme->getLink($parts[1]);
        $relatedIDs = '';
        $options = array();
        if (is_array($related) && count($related) > 0) {
            $relatedIDArray = array();
            $idAttr = One_Repository::getScheme($link->getTarget())->getIdentityAttribute()->getName();
            $tparts = explode(':', $targetAttr);
            foreach ($related as $relate) {
                if (is_null($idAttr)) {
                    $scheme = $model->getScheme();
                    $idAttr = $scheme->getIdentityAttribute()->getName();
                }
                $value = $relate->{$idAttr};
                $shown = '';
                foreach ($tparts as $tpart) {
                    $shown .= $relate->{$tpart} . ' ';
                }
                $options[$value] = $shown;
                $relatedIDArray[] = $relate->{$idAttr};
            }
            $relatedIDs = implode('^,^', $relatedIDArray);
        }
        $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'options' => $options, 'onEmpty' => strtolower($this->getCfg('onEmpty')), 'triggerOn' => $triggerOn, 'scheme' => $scheme, 'link' => $link, 'targetAttr' => $targetAttr, 'modelID' => $model->{$idAttr}, 'relatedIDs' => $relatedIDs, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
        //		$dom = new One_Dom(); // dom for head section
        //
        //		$head = '<script type="text/javascript" src="' . One::getInstance()->getUrl() . 'lib/libraries/js/featherajax.js"></script>';
        //		$dom->add( $head, '_head' );
        $head = '
			function setRelatedOptions( selfscheme, scheme, selfId, id, targetAttribute, phrase )
			{
				var self = "";
				if( selfscheme == scheme )
					self = "&selfId=" + selfId;
				var aj = new AjaxObject101();
				aj.sndReq( "post", "' . One_Config::getInstance()->getUrl() . '/lib/form/ajax/relational.php", "searchscheme=" + scheme + "&dd=f" + id + "&target=" + targetAttribute + "&phrase=" + phrase + self );
			}

			function addChosenOptions( id )
			{
				var dropdown = document.getElementById( "f" + id );
				var to       = document.getElementById( "t" + id );
				for( var i = 0; i < dropdown.length; i++ )
				{
					if( dropdown.options[i].selected == true )
					{
						var option = document.createElement("option");
						option.value = dropdown.options[i].value;
						option.innerHTML = dropdown.options[i].text;

						var found = false
						for( var j = 0; j < to.length; j++ )
						{
							if( option.value == to.options[j].value )
							{
								found = true;
								break;
							}
						}

						if( !found )
						{
							var hidden = document.getElementById( id );
							to.appendChild( option );

							if( hidden.value != "" )
								hidden.value = hidden.value + "^,^" + option.value;
							else
								hidden.value = option.value;
						}
					}
				}

			}

			function removeChosenOptions( id )
			{
				var to     = document.getElementById( "t" + id );
				var hidden = document.getElementById( id );

				for( var i = ( to.length - 1 ); i >= 0; i-- )
				{
					if( to.options[i].selected == true )
					{
						var pattern  = \'((\\^,\\^)?\' + to.options[i].value + \'(\\^,\\^)?)\';
						var test     = new RegExp( pattern, "gi" );
						/* @TODO There is probably an easier way to do this  */
						hidden.value = hidden.value.replace( test, "" );
						hidden.value = hidden.value.replace( /\\^,\\^\\^,\\^/gi, "^,^" );
						hidden.value = hidden.value.replace( /^\\^,\\^/gi, "" );
						hidden.value = hidden.value.replace( /\\^,\\^$/gi, "" );
						to.remove( i );
					}
				}
			}';
        //		$dom->add( $head, '_head' );
        One_Vendor::getInstance()->loadScript('js/featherajax.js', 200);
        One_Vendor::getInstance()->loadScriptDeclaration($head, 'head', 200);
        $content = $this->parse($model, $data);
        //		$d->addDom($dom);
        $d->addDom($content);
    }
예제 #24
0
    /**
     * 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&amp;view=images&amp;tmpl=component&amp;oneWidget=true&amp;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);
    }
예제 #25
0
    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);
    }
예제 #26
0
 /**
  * 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)
 {
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'totf' => $this->_totf, 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #27
0
 /**
  * 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);
 }
예제 #28
0
 /**
  * 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)
 {
     if (!is_null($this->getCfg('options'))) {
         $this->_options = array();
         $options = explode(';', $this->getCfg('options'));
         foreach ($options as $val) {
             $parts = explode('=', $val, 2);
             $this->_options[$parts[0]] = $parts[1];
         }
     }
     $value = count($this->getValue()) == 0 ? $this->getDefault() : $this->getValue();
     if (!is_array($value) && !is_null($value)) {
         $value = array($value);
     } else {
         if (is_null($value)) {
             $value = array();
         }
     }
     $this->setCfg('class', 'OneFieldCheckbox ' . $this->getCfg('class'));
     $data = array('id' => $this->getID(), 'name' => $this->getName() . '[]', 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'value' => $value, 'options' => $this->_options, 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
예제 #29
0
    /**
     * 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)
    {
        One_Vendor::requireVendor('jquery/one_loader');
        One_Vendor::getInstance()->loadScript('jquery/js/jquery.tagify.js', 'head', 10);
        if (is_null($this->getCfg('role')) || is_null($this->getCfg('targetAttribute'))) {
            throw new One_Exception('The Multi-tag widget is only allowed for Many-to-many relations');
        }
        $parts = explode(':', $this->getCfg('role'), 2);
        $targetAttr = $this->getCfg('targetAttribute');
        $link = $model->getScheme()->getLink($parts[1]);
        if (is_null($link) || !$link->getAdapterType() instanceof One_Relation_Adapter_Manytomany) {
            throw new One_Exception('The Multi-tag widget is only allowed for Many-to-many relations');
        }
        $tScheme = One_Repository::getScheme($model->getScheme()->getLink($parts[1])->getTarget());
        $tIdAttr = $tScheme->getIdentityAttribute()->getName();
        // set initial values
        $value = array();
        $values = is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model);
        foreach ($values as $tId) {
            $tModel = One_Repository::selectOne($tScheme->getName(), $tId);
            if (null !== $tModel) {
                $value[$tModel->{$tIdAttr}] = $tModel->{$targetAttr};
            }
        }
        $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'options' => $this->getOptions(), 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
        $dom = $this->parse($model, $data);
        //		$dom->add('<script type="text/javascript" href="'.One_Vendor::getInstance()->getSitePath().'/jquery/js/jquery.tagify.js" />'."\n", '_head');
        //		$dom->add('<link rel="stylesheet" type="text/css" href="'.One_Vendor::getInstance()->getSitePath().'/jquery/css/tagify-style.css" />'."\n", '_head');
        //One_Vendor::getInstance()->loadScript('jquery/js/jquery.tagify.js', 'head', 20);
        One_Vendor::getInstance()->loadStyle('jquery/css/tagify-style.css', 'head', 20);
        // Prepare autocomplete tagfield
        $script = '
		var oneTags' . $this->getID() . ' = jQuery("#' . $this->getID() . '").tagify();
		oneTags' . $this->getID() . '.tagify("inputField").autocomplete({
	        source: function(req, add) {
				req.field = "' . $targetAttr . '";
				req.query = "formtags";

				//pass request to server
                jQuery.getJSON("' . One_Config::getInstance()->getSiterootUrl() . One_Config::getInstance()->getAddressOne() . '&scheme=' . $tScheme->getName() . '&task=json", req, function(data) {

              	 	//create array for response objects
                    var suggestions = [];

              		//process response
                    jQuery.each(data, function(i, val) {
						var keyval = { "label": val.' . $targetAttr . ', "value": val.' . $tIdAttr . ' };
		                suggestions.push(keyval);
	    			});

	            	//pass array to callback
                    add(suggestions);

                });
			},
	        position: { of: oneTags' . $this->getID() . '.tagify("containerDiv") },
			select: function(e, ui) {
				oneTags' . $this->getID() . '.tagify("inputField").val(ui.item.label);
        		oneTags' . $this->getID() . '.tagify("add", ui.item.value, ui.item.label);
				oneTags' . $this->getID() . '.tagify("inputField").val("");
        		return false;
			},
			focus: function(e, ui) {
				oneTags' . $this->getID() . '.tagify("inputField").val(ui.item.label);
				return false;
			},
			change: function(e, ui) {
				oneTags' . $this->getID() . '.tagify("inputField").val("");
				return false;
			}
    	});
		';
        foreach ($value as $tId => $tVal) {
            $script .= '
		oneTags' . $this->getID() . '.tagify("add", "' . $tId . '", "' . $tVal . '");';
        }
        //		$dom->add($script, '_onload');
        One_Vendor::getInstance()->loadScriptDeclaration($script, 'onload', 20);
        $d->addDom($dom);
    }
예제 #30
0
    /**
     * 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)
    {
        $codemirrorPath = One_Vendor::getInstance()->getSitePath() . '/codemirror/';
        $script = '<script type="text/javascript" src="' . $codemirrorPath . 'js/codemirror.js"></script>';
        $d->add($script, '_head');
        switch (strtolower($this->getCfg('type'))) {
            case 'javascript':
                $parser = '["tokenizejavascript.js", "parsejavascript.js"]';
                $stylesheet = '"' . $codemirrorPath . 'css/jscolors.css"';
                break;
            case 'css':
                $parser = '"parsecss.js"';
                $stylesheet = '"' . $codemirrorPath . 'css/csscolors.css"';
                break;
            case 'htmlmix':
                $parser = '["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsehtmlmixed.js"]';
                $stylesheet = '["' . $codemirrorPath . 'css/xmlcolors.css", "' . $codemirrorPath . 'css/jscolors.css", "' . $codemirrorPath . 'css/csscolors.css"]';
                $availableParsers = array('XMLParser' => '(X)(HT)ML', 'CSSParser' => 'CSS', 'JSParser' => 'JavaScript', 'HTMLMixedParser' => 'HTML Mixed');
                break;
            case 'htmlphp':
                $parser = '["parsexml.js", "parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "../contrib/php/js/tokenizephp.js", "../contrib/php/js/parsephp.js", "../contrib/php/js/parsephphtmlmixed.js"]';
                $stylesheet = '["' . $codemirrorPath . 'css/xmlcolors.css", "' . $codemirrorPath . 'css/jscolors.css", "' . $codemirrorPath . 'css/csscolors.css", "' . $codemirrorPath . 'contrib/php/css/phpcolors.css"]';
                $availableParsers = array('XMLParser' => '(X)(HT)ML', 'CSSParser' => 'CSS', 'JSParser' => 'JavaScript', 'PHPParser' => 'PHP', 'PHPHTMLMixedParser' => 'PHP-HTML Mixed');
                break;
            case 'sql':
                $parser = '"../contrib/sql/js/parsesql.js"';
                $stylesheet = '"' . $codemirrorPath . 'contrib/sql/css/sqlcolors.css"';
                break;
            case 'nano':
                $parser = '"parsenano.js"';
                $stylesheet = '"' . $codemirrorPath . 'css/nanocolors.css"';
                break;
            case 'nanomix':
                $parser = '["parsenano.js","parsexml.js"]';
                $stylesheet = '["' . $codemirrorPath . 'css/nanocolors.css", "' . $codemirrorPath . 'css/xmlcolors.css"]';
                $availableParsers = array('XMLParser' => '(X)(HT)ML', 'NanoParser' => 'nano');
                break;
            default:
                $parser = '"parsexml.js"';
                $stylesheet = '"' . $codemirrorPath . 'css/xmlcolors.css"';
                break;
        }
        $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), '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'), 'parsers' => $availableParsers);
        $dom = $this->parse($model, $data);
        $d->addDom($dom);
        // onChange doesn't work well when changing parser
        //		$script = '<script type="text/javascript">
        //	      var editor' . ucfirst( $this->getID() ) . ' = CodeMirror.fromTextArea( "' . $this->getID() . '", {
        //	      	width: "95%",
        //	      	height: "350px",
        //	        parserfile: ' . $parser . ',
        //	        stylesheet: ' . $stylesheet . ',
        //	        path: "' . $codemirrorPath . 'js/",
        //	        continuousScanning: 50,
        //	        lineNumbers: true,
        //	        tabMode: "indent",
        //	        autoMatchParens: true,
        //	        iframeClass: "OneCodeWidget",
        //	        onChange: function() { document.getElementById( "' . $this->getID() . '" ).value = editor' . ucfirst( $this->getID() ) . '.getCode(); }
        //	      });
        //	    </script>';
        $script = '<script type="text/javascript">
	      var editor' . ucfirst($this->getID()) . ' = CodeMirror.fromTextArea( "' . $this->getID() . '", {
	      	width: "95%",
	      	height: "350px",
	        parserfile: ' . $parser . ',
	        stylesheet: ' . $stylesheet . ',
	        path: "' . $codemirrorPath . 'js/",
	        continuousScanning: 50,
	        lineNumbers: true,
	        tabMode: "indent",
	        autoMatchParens: true,
	        iframeClass: "OneCodeWidget"
	      });
	    </script>';
        $d->add($script);
    }