コード例 #1
0
ファイル: jpaneslider_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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);
    }
コード例 #2
0
ファイル: panel_tbd.php プロジェクト: pdelbar/onethree
 /**
  * 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
ファイル: color_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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);
    }
コード例 #4
0
ファイル: calendar_tbd.php プロジェクト: pdelbar/onethree
 /**
  * Class constructor
  *
  * @param One_Controller $controller
  * @param array $options
  */
 public function __construct(One_Controller $controller, $options = array())
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . One_Vendor::getInstance()->getFilePath() . '/zend');
     if (!class_exists('Zend_Locale', false)) {
         require_once 'Zend/Locale.php';
     }
     parent::__construct($controller, $options);
     $this->scheme = $options['scheme'];
     $scheme = One_Repository::getScheme($this->scheme);
     $calendarOptions = $scheme->get('behaviorOptions.calendar');
     $date = $calendarOptions['date'];
     $enddate = $calendarOptions['enddate'];
     $time = $calendarOptions['time'];
     $title = $calendarOptions['title'];
     $this->dateAttribute = $this->getVariable('dateAttribute', $date ? $date : 'date');
     $this->enddateAttribute = $this->getVariable('enddateAttribute', $enddate ? $enddate : NULL);
     $this->timeAttribute = !is_null($time) ? $this->getVariable('timeAttribute', $time ? $time : 'time') : NULL;
     $this->titleAttribute = $this->getVariable('titleAttribute', $title ? $title : 'title');
     // determine currently requested date
     $day = trim($this->getVariable('day', ''));
     $month = trim($this->getVariable('month', ''));
     $year = trim($this->getVariable('year', ''));
     if (isset($calendarOptions['startdate']) && $day == '' && $month == '' && $year == '') {
         if (preg_match('/([0-9]{4}).([0-9]{1,2}).([0-9]{1,2})/', $calendarOptions['startdate'], $matches) > 0 && checkdate($matches[2], $matches[3], $matches[1]) && mktime(0, 0, 0, $matches[2], $matches[3], $matches[1]) > time()) {
             $day = $matches[3];
             $month = $matches[2];
             $year = $matches[1];
         } else {
             $day = date('d');
             $month = date('m');
             $year = date('Y');
         }
     } else {
         if ($day != '' || $month != '' || $year != '') {
             $day = $this->getVariable('day', date('d'));
             $month = $this->getVariable('month', date('m'));
             $year = $this->getVariable('year', date('Y'));
         } else {
             $day = date('d');
             $month = date('m');
             $year = date('Y');
         }
     }
     $this->day = $day;
     $this->month = $month;
     $this->year = $year;
 }
コード例 #5
0
ファイル: mootabs_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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);
    }
コード例 #6
0
ファイル: upload_tbd.php プロジェクト: pdelbar/onethree
 /**
  * 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);
 }
コード例 #7
0
ファイル: one_tbd.php プロジェクト: pdelbar/onethree
 public function getVendorInstance()
 {
     return One_Vendor::getInstance();
 }
コード例 #8
0
ファイル: media2_tbd.php プロジェクト: pdelbar/onethree
 /**
  * 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);
 }
コード例 #9
0
ファイル: vendor.php プロジェクト: pdelbar/onethree
 /**
  * Remove the instance
  * @return void
  */
 public static function unsetInstance()
 {
     self::$_instance = NULL;
 }
コード例 #10
0
ファイル: tags_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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);
    }
コード例 #11
0
ファイル: relational_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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);
    }
コード例 #12
0
ファイル: code_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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);
    }
コード例 #13
0
ファイル: date_tbd.php プロジェクト: pdelbar/onethree
    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);
    }
コード例 #14
0
ファイル: code2_tbd.php プロジェクト: pdelbar/onethree
    /**
     * 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() . '/codemirror2/';
        //		$d->add('<script type="text/javascript" src="'.$codemirrorPath.'lib/codemirror.js"></script>', '_head' );
        //		$d->add('<link rel="stylesheet" type="text/css" href="'.$codemirrorPath.'lib/codemirror.css"/>', '_head' );
        //		$d->add('<link rel="stylesheet" type="text/css" href="'.$codemirrorPath.'theme/default.css"/>', '_head' );
        One_Vendor::getInstance()->loadScript('codemirror2/lib/codemirror.js', 'head', 1);
        One_Vendor::getInstance()->loadStyle('codemirror2/lib/codemirror.css', 'head', 1);
        One_Vendor::getInstance()->loadStyle('codemirror2/theme/default.css', 'head', 2);
        $type = strtolower($this->getCfg('type'));
        if (file_exists(One_Vendor::getInstance()->getFilePath() . '/codemirror2/mode/' . $type . '/' . $type . '.js')) {
            $mode = strtolower($this->getCfg('type'));
            //			$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/'.$type.'/'.$type.'.js"></script>', '_head' );
            One_Vendor::getInstance()->loadScript('codemirror2/mode/' . $type . '/' . $type . '.js', 'head', 2);
            if (file_exists(One_Vendor::getInstance()->getFilePath() . '/codemirror2/mode/' . $type . '/' . $type . '.css')) {
                //				$d->add('<link rel="stylesheet" type="text/css" href="'.$codemirrorPath.'mode/'.$type.'/'.$type.'.css"/>', '_head' );
                One_Vendor::getInstance()->loadStyle('codemirror2/mode/' . $type . '/' . $type . '.css', 'head', 3);
            }
        } else {
            $mode = 'scheme';
            //			$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/scheme/scheme.js"></script>', '_head' );
            One_Vendor::getInstance()->loadScript('codemirror2/mode/scheme/scheme.js', 'head', 2);
        }
        switch ($mode) {
            case 'htmlmixed':
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/css/css.js"></script>', '_head' );
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/javascript/javascript.js"></script>', '_head' );
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/xml/xml.js"></script>', '_head' );
                One_Vendor::getInstance()->loadScript('codemirror2/mode/css/css.js', 'head', 3);
                One_Vendor::getInstance()->loadScript('codemirror2/mode/javascript/javascript.js', 'head', 4);
                One_Vendor::getInstance()->loadScript('codemirror2/mode/xml/xml.js', 'head', 5);
                break;
            case 'php':
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/clike/clike.js"></script>', '_head' );
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/htmlmixed/htmlmixed.js"></script>', '_head' );
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/css/css.js"></script>', '_head' );
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/javascript/javascript.js"></script>', '_head' );
                //				$d->add('<script type="text/javascript" src="'.$codemirrorPath.'mode/xml/xml.js"></script>', '_head' );
                One_Vendor::getInstance()->loadScript('codemirror2/mode/clike/clike.js', 'head', 3);
                One_Vendor::getInstance()->loadScript('codemirror2/mode/htmlmixed/htmlmixed.js', 'head', 4);
                One_Vendor::getInstance()->loadScript('codemirror2/mode/css/css.js', 'head', 5);
                One_Vendor::getInstance()->loadScript('codemirror2/mode/javascript/javascript.js', 'head', 6);
                One_Vendor::getInstance()->loadScript('codemirror2/mode/xml/xml.js', 'head', 7);
                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'));
        $dom = $this->parse($model, $data);
        $d->addDom($dom);
        $script = 'var editor' . ucfirst($this->getID()) . ' = CodeMirror.fromTextArea(document.getElementById("' . $this->getID() . '"), {
	      	mode: "' . $mode . '",
	        lineNumbers: true,
	        tabMode: "indent",
	        matchBrackets: true,
	        theme: "default"
	      });';
        if (null !== $this->getCfg('width')) {
            $script .= '
	      jQuery(editor' . ucfirst($this->getID()) . '.getScrollerElement()).width("' . intval($this->getCfg('width')) . '");';
        }
        if (null !== $this->getCfg('height')) {
            $script .= '
	      jQuery(editor' . ucfirst($this->getID()) . '.getScrollerElement()).height("' . intval($this->getCfg('height')) . '");';
        }
        $script .= '
	      editor' . ucfirst($this->getID()) . '.refresh();';
        One_Vendor::getInstance()->loadScriptDeclaration($script, 'body', 1);
        //		$d->add( $script );
    }