/** * This method renders the "save" button * * @return string */ public function render() { $output = '<td><a href="#" onclick="document.getElementById( \'task\' ).value = \'save\'; document.getElementById( \'' . One_Button::getFormId() . '\' ).submit(); "><img src="' . One_Config::getInstance()->getUrl() . '/vendor/images/toolset/' . self::getToolset() . '/save.png" title="Save">'; if (self::showText()) { $output .= '<br />Save'; } $output .= '</a></td>'; return $output; }
/** * Render the output of the widget and add it to the DOM * * @param One_Model $model * @param One_Dom $d */ protected function _render($model, One_Dom $d) { $this->setCfg('class', 'OneFieldInput ' . $this->getCfg('class')); $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'required' => $this->isRequired() ? ' *' : '', 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'One::getInstance()->getUrl()' => One_Config::getInstance()->getUrl()); $dom = One_Repository::createDom(); $dom->add('<script type="text/javascript" src="' . One_Vendor::getInstance()->getSitePath() . '/js/ColorPicker2.js"></script>', '_head'); $dom->add('<script type="text/javascript"> var cp = new ColorPicker( "window" ); </script>', '_head'); $content = $this->parse($model, $data); $d->addDom($dom); $d->addDom($content); }
/** * Render the output of the 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); }
public static function initiate($siteRoot, $path, $customPath) { throw new One_Exception_Deprecated('do your own bootstrapping, dude'); // Register the autoloader One_Loader::register(); One_Config::getInstance()->setUrl($siteRoot)->setCustomPath($customPath)->setUserStore('mysql')->setTemplater(new One_Template_Adapter_NanoPretend()); // define( 'ONETEMPLATER', 'nano'); // $tmp = $path . DIRECTORY_SEPARATOR . 'nano' . DIRECTORY_SEPARATOR; // define( 'ONE_SCRIPT_PATH', $tmp ); // define( 'ONE_SCRIPT_CUSTOM_PATH', $customPath . DIRECTORY_SEPARATOR . 'nano' ); // // require_once( $tmp . 'tools' . DIRECTORY_SEPARATOR . 'autoload.php' ); require_once ONE_LIB_PATH . '/tools.php'; }
/** * 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) { // 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 $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); }
/** * Parse an include file that contains conditions * * @param string $include filename of the include */ protected static function parseInclude($include) { $filename = One_Config::getInstance()->getCustomPath() . '/conditions/' . strtolower($include) . '.xml'; $incDom = new DOMDocument('1.0', 'utf-8'); if (file_exists($filename) && $incDom->load($filename)) { $xpath = new DOMXPath($incDom); $conditions = $xpath->query('/conditions'); if ($conditions->length > 0) { $conditions = $conditions->item(0); } else { return; } foreach ($conditions->childNodes as $condition) { if ($condition instanceof DOMElement) { switch (strtolower($condition->localName)) { case 'cinclude': self::parseInclude($condition->getAttribute('file')); break; case 'condition': self::parseCondition($condition, $condition->getAttribute('name')); break; } } } } }
public function getOneInstance() { return One_Config::getInstance(); }
/** * 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); }
/** * Renders the Joomla-Media widget. * This widget is too specific to render with One_Script and should not be rendered otherwise, * hence this does not use the One_Form_Container_Abstract::parse() function * * @param One_Model $model * @param One_Dom $d * @access protected */ protected function _render($model, One_Dom $d) { JHTML::_('behavior.modal'); JHTML::_('behavior.modal', 'a.modal-button'); $formName = $this->getFormName(); $name = $this->getName(); $id = $this->getID(); $link = 'index.php?option=com_media&view=images&tmpl=component&oneWidget=true&e_name=' . $name; $button = new JObject(); $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('Image')); $button->set('name', 'image'); $button->set('options', "{handler: 'iframe', size: {x: 570, y: 400}}"); $modal = $button->get('modal') ? 'class="modal-button"' : null; $href = $button->get('link') ? 'href="' . JURI::base() . $button->get('link') . '"' : null; $onclick = $button->get('onclick') ? 'onclick="' . $button->get('onclick') . '"' : null; $dom = One_Repository::createDom(); // should we show a label? if (!is_null($this->getLabel())) { $label = '<label class="OneFieldLabel" for="' . $id . '">' . $this->getLabel() . ($this->isRequired() ? ' *' : '') . '</label>' . "\n"; } $dom->add("<span class='OneWidget'>"); // start with label? if ($label && !$this->getCfg('lblLast')) { $dom->add($label); } $app = JFactory::getApplication(); $jDoc = JFactory::getDocument(); $path = ''; if ($app->getName() != 'site') { $path = '../'; } $mediaParams = JComponentHelper::getParams('com_media'); $imageExtensions = $mediaParams->get('image_extensions'); $imageExtensions = explode(',', $imageExtensions); preg_match('/\\.([a-z0-3]{1,4})$/i', $model->{$name}, $match); $currExt = $match[1]; $isImage = in_array($currExt, $imageExtensions); $currImgSrc = $path . ($isImage ? $model->{$name} : 'images/spacer.gif'); $thWidth = !is_null($this->getCfg('thWidth')) ? $this->getCfg('thWidth') : 50; $setMedia = 'function changeMedia( item, path ) { document.getElementById( item ).value = path; var setImg = "' . $path . 'images/spacer.gif"; if( path.match( /\\.(' . implode('|', $imageExtensions) . ')$/ ) ) setImg = "' . $path . '" + ' . 'path; document.getElementById( "thImg" + item ).src = setImg; document.getElementById( "thImg" + item ).style.width = "' . $thWidth . 'px"; document.getElementById( "thImgLink" + item ).href = setImg; document.getElementById("OneThumb"+item).style.display = "block"; } function clearOneJMediaImg( item ) { document.getElementById( item ).value = ""; var setImg = "' . $path . 'images/spacer.gif"; document.getElementById( "thImg" + item ).src = setImg; document.getElementById( "thImgLink" + item ).href = setImg; document.getElementById("OneThumb"+item).style.display = "none"; }'; // slimbox must be loaded AFTER mootools (current slimbox is meant for mootools 1.11) $jDoc->addScript(One_Config::getInstance()->getUrl() . '/vendor/slimbox/js/slimbox.js', 'text/javascript'); $jDoc->addStyleSheet(One_Config::getInstance()->getUrl() . '/vendor/slimbox/css/slimbox.css', 'text/css', 'screen'); $jDoc->addScriptDeclaration($setMedia); // show the input $dom->add('<div style="float: left;">'); $dom->add('<input class="OneFieldInput" type="text" name="' . $formName . '" id="' . $id . '" size="50" readonly="readonly" value="' . $model->{$name} . '" />' . "\n"); $dom->add('</div>'); $dom->add('<div class="button2-left">'); $dom->add('<div class="' . $button->get('name') . '">'); $dom->add('<a ' . $modal . ' title="' . $button->get('text') . '" ' . $href . ' ' . $onclick . ' rel="' . $button->get('options') . '">' . $button->get('text') . '</a>'); $dom->add('</div></div>'); $dom->add('<div class="button2-left">'); $dom->add('<div class="' . $button->get('name') . '">'); $dom->add('<a href="#" onclick="clearOneJMediaImg( \'' . $id . '\' ); return false;">Clear image</a>'); //TODO: clear thumb image $dom->add('</div>'); $dom->add('</div>'); $dom->add('<div class="OneThumb" id="OneThumb' . $id . '"' . ('' == trim($currImgSrc) || $path . 'images/spacer.gif' == trim($currImgSrc) ? ' style="display: none;"' : '') . '>'); $dom->add('<a href="' . $currImgSrc . '" id="thImgLink' . $id . '" rel="lightbox"><img id="thImg' . $id . '" src="' . $currImgSrc . '" width="' . $thWidth . '" /></a>'); $dom->add('</div>'); // end with label? if ($label && $this->getCfg('lblLast')) { $dom->add($label); } $dom->add("</span>"); $d->addDom($dom); }
/** * 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); }
/** * Render the widget as a JS datepicker * * @param One_Model $model * @param One_Dom $d */ private function renderJSCalendar($model, One_Dom $d) { if (!is_null($this->getCfg('jquery'))) { return $this->renderJQueryDatepicker($model, $d); } $id = $this->getID(); $name = $this->getName(); $value = $this->getValue($model); $dom = One_Repository::createDom(); preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})( (\\d{2}):(\\d{2}):(\\d{2}))?$/', $value, $matches); One_Vendor::getInstance()->loadStyle('js/jscalendar/calendar-win2k-1.css', 'head'); One_Vendor::getInstance()->loadScript('js/jscalendar/calendar.js', 'head', 10); // One_Vendor::getInstance()->loadScript('js/jscalendar/lang/calendar-'.strtolower(substr(One::getInstance()->getLanguage(), 0, 2)).'.js', 'head', 11); // problems with language packs so stick to EN One_Vendor::getInstance()->loadScript('js/jscalendar/lang/calendar-en.js', 'head', 11); One_Vendor::getInstance()->loadScript('js/jscalendar/calendar-setup.js', 'head', 12); if ($this->getCfg('jsFlat')) { $container = new One_Form_Container_Div($id . 'container'); $extraParams = array('default' => $this->getDefault()); if (in_array($this->getCfg('one'), array('one', 'yes', 'true', '1'))) { $extraParams['one'] = 'one'; } $hidden = new One_Form_Widget_Scalar_Hidden($id, $name, null, $extraParams); $container->render($model, $dom); $hidden->render($model, $dom); $defaultDate = date('Y-m-d'); if ('' != $value && '0000-00-00' != $value && '0000-00-00 00:00:00' != $value) { $defaultDate = $value; } $onloadscript = ' Calendar.setup( { flat : "' . $id . 'container", flatCallback : dateChanged, ifFormat : "%Y-%m-%d' . (trim($this->getCfg('time')) != '' ? ' %H:%M' : '') . '"' . (trim($this->getCfg('time')) != '' ? ', showsTime : true' : '') . ', date : "' . $value . '" } ); '; $headscript = 'function dateChanged(calendar) { if(calendar.dateClicked) { var hidden = document.getElementById("' . $id . '"); var year = calendar.date.getFullYear(); var month = ((calendar.date.getMonth() + 1) < 10) ? "0" + (calendar.date.getMonth() + 1) : (calendar.date.getMonth() + 1); var day = (calendar.date.getDate() < 10) ? "0" + calendar.date.getDate() : calendar.date.getDate(); hidden.value = year + "-" + month + "-" + day; } }'; One_Vendor::getInstance()->loadScriptDeclaration($headscript, 'head', 10); One_Vendor::getInstance()->loadScriptDeclaration($onloadscript, 'onload'); } else { $extraParams = array('readonly' => 'readonly', 'default' => $this->getDefault()); if (in_array($this->getCfg('one'), array('one', 'yes', 'true', '1'))) { $extraParams['one'] = 'one'; } $tf = new One_Form_Widget_Scalar_Textfield($id, $name, NULL, $extraParams); $trigger = new One_Form_Widget_Image($id . 'trigger', $name . 'trigger', NULL, array('src' => One_Config::getInstance()->getUrl() . '/vendor/images/calendar.png', 'alt' => 'Show calendar', 'title' => 'Show calendar')); $tf->render($model, $dom); $trigger->render($model, $dom); $script = 'Calendar.setup( { inputField : "' . $name . '", ifFormat : "%Y-%m-%d' . (trim($this->getCfg('time')) != '' ? ' %H:%M' : '') . '", button : "' . $name . 'trigger"' . (trim($this->getCfg('time')) != '' ? ', showsTime : true' : '') . ' } );'; One_Vendor::getInstance()->loadScriptDeclaration($script, 'onload'); } //return $output; $d->addDom($dom); }
} $path = implode(DIRECTORY_SEPARATOR, $parts); define('JPATH_BASE', $path); // $ONE_SCRIPT_PATH = $libpath . DIRECTORY_SEPARATOR . 'nano' . DIRECTORY_SEPARATOR; // define( 'ONE_SCRIPT_PATH', $ONE_SCRIPT_PATH ); // define( 'ONE_SCRIPT_CUSTOM_PATH', JPATH_BASE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'nano' ); /* Required Files */ require_once JPATH_BASE . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'defines.php'; require_once JPATH_BASE . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'framework.php'; if ($withDB) { /* To use Joomla's Database Class */ require_once JPATH_BASE . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'factory.php'; } $mainframe = JFactory::getApplication('site'); require_once JPATH_BASE . '/plugins/system/one/lib/one.php'; One_Config::getInstance()->setCustomPath(JPATH_BASE . '/media/one'); // require_once( ONE_SCRIPT_PATH . 'tools' . DIRECTORY_SEPARATOR . 'autoload.php' ); require_once ONE_LIB_PATH . '/tools.php'; $scheme = $_POST['searchscheme']; $tparts = explode(':', $_POST['target']); $phrase = strip_tags($_POST['phrase']); $selfId = isset($_POST['selfId']) ? $_POST['selfId'] : NULL; $query = One_Repository::selectQuery($scheme); $scheme = $query->getScheme(); $idAttr = $scheme->getIdentityAttribute()->getName(); if (!is_null($selfId)) { $query->where($idAttr, 'neq', $selfId); } // possibility to implement if the 2 schemes are the same in the manytomany relationship to exclude the current ID $or = $query->addOr(); foreach ($tparts as $tpart) {
/** * 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); }