/** * 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 $dom) { // collect required data $id = $this->getID(); $name = $this->getFormName(); $value = $this->getValue($model); if ($value == null) { $value = $this->getDefault(); } $info = $this->getCfg('info'); $error = $this->getCfg('error'); $this->setCfg('class', 'OneFieldInput ' . $this->getCfg('class')); $events = $this->getEventsAsString(); $params = $this->getParametersAsString(); // show the input $dom->add('<input type="' . $this->_totf . '" id="' . $id . '" name="' . $name . '" value="' . $this->getLabel() . '"' . $events . $params . ' />' . "\n"); // extra info if (!is_null($info)) { $dom->add('<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>'); } // error message if (!is_null($error)) { $dom->add('<span id="' . $id . 'Error" class="OneError">' . $error . '</span>'); } }
/** * 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 $dom) { $src = $this->getCfg('src'); if (trim($src) == '') { throw new One_Exception("A field of type 'nscript' should have a 'src'-attribute defining the nanoScript file to parse."); } One_Script_Factory::saveSearchPath(); One_Script_Factory::clearSearchPath(); $useLang = $this->getCfg('language'); if ('' == trim($useLang)) { $useLang = strtolower(One_Config::get('app.language')); } die('deprecated stuff found in ' . __FILE__ . ':' . __LINE); $cps = One_Config::getInstance()->getCustomPaths(); foreach ($cps as $cp) { One_Script_Factory::addSearchPath($cp . '/views/' . One_Config::get('app.name') . '/' . $model->getScheme()->getName() . '/language/' . $useLang . '/'); } foreach ($cps as $cp) { One_Script_Factory::addSearchPath($cp . '/views/' . One_Config::get('app.name') . '/' . $model->getScheme()->getName() . '/'); } $ns = new One_Script(); $ns->load($src); if (!$ns->isError()) { if ($this->getID()) { $ns->set('id', $this->getID()); } if ($this->getName()) { $ns->set('name', $this->getName()); } if ($this->getLabel()) { $ns->set('label', $this->getLabel()); } if ($this->getValue($model)) { $ns->set('value', $this->getValue($model)); } $ns->set('model', $model); $dom->add($ns->execute()); } else { throw new One_Exception($ns->error); } $dom->add($this->value); One_Script_Factory::restoreSearchPath(); }
/** * 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 $dom) { $src = $this->getCfg('code'); $ns = new One_Script(); if ($this->getID()) { $ns->set('id', $this->getID()); } if ($this->getName()) { $ns->set('name', $this->getName()); } if ($this->getLabel()) { $ns->set('label', $this->getLabel()); } if ($this->getValue($model)) { $ns->set('value', $this->getValue($model)); } $ns->set('model', $model); $s = $ns->executeString($src); $dom->add($s); $dom->add($this->value); One_Script_Factory::restoreSearchPath(); }
/** * 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 $dom) { // collect required data $id = $this->getID(); $name = $this->getName(); $childScheme = $this->getCfg('scheme'); $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/jquery.js" type="text/javascript"></script>', '_head'); $dom->add('<script type="text/javascript">jQuery.noConflict();</script>', 'head'); $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/jquery/jquery.color.js" type="text/javascript"></script>', '_head'); $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/jquery.simplemodal-1.3.3.js" type="text/javascript"></script>', '_head'); $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/managerToolbar.js" type="text/javascript"></script>', '_head'); $dom->add('<link rel="stylesheet" href="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/toolbar.css" type="text/css" />', '_head'); $dom->add('<link rel="stylesheet" href="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/toolbar.ie6.css" type="text/css" />', '_head'); $content = '<div class="childPopupPanel"> <a href="#" onclick="jModal( \'' . $id . 'NsBox\', \'' . $childScheme . '\' ); return false;">Lookup</a> <div id="' . $id . 'NsBox"></div> </div>'; $dom->add($content); }
/** * 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 $dom) { $dom->add($this->value); }
/** * 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); }
/** * 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) { $start = date('Y-m'); if (!is_null($this->getCfg('start'))) { $start = trim($this->getCfg('start')); } $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'start' => $start); $dom = $this->parse($model, $data); // add multidate.js $d->add('<script type="text/javascript" src="' . One_Config::getInstance()->getUrl() . 'lib/form/js/multidate.js"></script>' . "\n", '_head'); // define our multiDate JS object // onload create the calendar $script = 'multi' . ucfirst($this->getID()) . '.createCalendar();'; $d->add($script, '_onload'); $script = '<script type="text/javascript">var multi' . ucfirst($this->getID()) . ' = "";</script>'; $d->add($script); $d->addDom($dom); $script = '<script type="text/javascript">var multi' . ucfirst($this->getID()) . ' = new MultiDate( 2010, 4, "OneCalendar' . ucfirst($this->getID()) . '", "' . $this->getID() . '" );</script>'; $d->add($script); }