function controlToHTML($name) { // $html = '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.2/build/editor/assets/skins/sam/simpleeditor.css" />'; $html = '<link rel="stylesheet" type="text/css" href="' . YUI2_PATH . 'editor/assets/skins/sam/simpleeditor.css" />'; $html .= '<div class="yui-skin-sam"><textarea name="' . $name . '" id="' . $name . '"'; $html .= " rows=\"" . $this->rows . "\" cols=\"" . $this->cols . "\""; if ($this->accesskey != "") { $html .= " accesskey=\"" . $this->accesskey . "\""; } if (!empty($this->class)) { $html .= " class=\"" . $this->class . "\""; } if ($this->tabindex >= 0) { $html .= " tabindex=\"" . $this->tabindex . "\""; } if (@$this->required) { $html .= ' required="' . rawurlencode($this->default) . '" caption="' . rawurlencode($this->caption) . '" '; } $html .= ">"; $html .= $this->default; $html .= "</textarea></div>"; $script = "\n\t\t(function() {\n \t\t\tvar Dom = YAHOO.util.Dom,\n \t\tEvent = YAHOO.util.Event;\n \n \t\t\tvar myConfig = {\n \t\t\theight: '95%',\n \t\t\twidth: '530px',\n \t\t\tdompath: true,\n\t\t\t\thandleSubmit: true,\n\t\t\t\tautoHeight: true\n \t\t\t};\n\n \t\t\tYAHOO.log('Create the Editor..', 'info', 'example');\n \t\t\tvar myEditor = new YAHOO.widget.SimpleEditor('" . $name . "', myConfig);\n \t\t\tmyEditor.render();\n\n\t\t})();"; expJavascript::pushToFoot(array("unique" => 'editor-' . $name, "yui2mods" => 'editor', "yui3mods" => null, "content" => $script, "src" => "")); return $html; }
function toHTML($label, $name) { $assets_path = SCRIPT_RELATIVE . 'framework/core/subsystems/forms/controls/assets/'; $subTypeName = empty($this->subtype) ? "expFile[]" : "expFile[" . $this->subtype . "][]"; $files = $this->buildImages(); $html = '<div id="filemanager' . $name . '" class="filemanager control' . (empty($this->class) ? "" : " " . $this->class) . '">'; //$html .= '<div id="displayfiles" class="displayfiles" style="padding:5px; border:1px solid #444"> </div>'; $html .= '<div class="hd"><label class="label">' . $label . ''; if ($this->limit != null) { $html .= ' | <small>' . gt('Limit') . ': <em class="limit">' . $this->limit . '</em></small>'; } if ($this->count < $this->limit) { $html .= ' | <a class="add" href="#" id="addfiles-' . $name . '">' . gt('Add Files') . '</a>'; } $html .= '</label></div>'; if (empty($files)) { $this->count = 0; $files = '<li class="blank">' . gt('You need to add some files') . '</li>'; } $html .= '<ul id="filelist' . $name . '" class="filelist">'; $html .= $files; $html .= '</ul>'; $html .= '<input type="hidden" name="' . $subTypeName . '" value="' . $subTypeName . '">'; $html .= '</div>'; $js = "\n YUI(EXPONENT.YUI3_CONFIG).use('dd-constrain','dd-proxy','dd-drop','json','io', function(Y) {\n var limit = " . $this->limit . ";\n var filesAdded = " . $this->count . ";\n var fl = Y.one('#filelist" . $name . "');\n \n // file picker window opener\n function openFilePickerWindow(e){\n e.halt();\n win = window.open('" . makeLink($params = array('controller' => 'file', 'action' => 'picker', 'ajax_action' => "1", 'update' => $name)) . "', 'IMAGE_BROWSER','left=20,top=20,scrollbars=yes,width=800,height=600,toolbar=no,resizable=yes,status=0');\n if (!win) {\n //Catch the popup blocker\n alert('" . gt('Please disable your popup blocker') . "!!');\n }\n };\n \n var listenForAdder = function(){\n var af = Y.one('#addfiles-" . $name . "');\n af.on('click',openFilePickerWindow);\n };\n \n var showEmptyLI = function(){\n var blank = Y.Node.create('<li class=\"blank\">" . gt('You need to add some files') . "</li>');\n fl.appendChild(blank);\n };\n \n if (limit > filesAdded) {\n listenForAdder();\n }\n \n // remove the file from the list\n fl.delegate('click',function(e){\n e.target.ancestor('li').remove();\n \n showFileAdder();\n },'.delete');\n \n var showFileAdder = function() {\n var sf = Y.one('#addfiles-" . $name . "');\n if (Y.Lang.isNull(sf)) {\n var afl = Y.Node.create('<a class=\"add\" href=\"#\" id=\"addfiles-" . $name . "\">" . gt('Add Files') . "</a>');\n Y.one('#filemanager" . $name . " .hd').append(afl);\n listenForAdder();\n }\n filesAdded--;\n if (filesAdded == 0) showEmptyLI();\n }\n\n //Drag Drop stuff\n \n //Listen for all drop:over events\n Y.DD.DDM.on('drop:over', function(e) {\n //Get a reference to out drag and drop nodes\n var drag = e.drag.get('node'),\n drop = e.drop.get('node');\n\n //Are we dropping on a li node?\n if (drop.get('tagName').toLowerCase() === 'li') {\n //Are we not going up?\n if (!goingUp) {\n drop = drop.get('nextSibling');\n }\n //Add the node to this list\n e.drop.get('node').get('parentNode').insertBefore(drag, drop);\n //Resize this nodes shim, so we can drop on it later.\n e.drop.sizeShim();\n }\n });\n //Listen for all drag:drag events\n Y.DD.DDM.on('drag:drag', function(e) {\n //Get the last y point\n var y = e.target.lastXY[1];\n //is it greater than the lastY var?\n if (y < lastY) {\n //We are going up\n goingUp = true;\n } else {\n //We are going down..\n goingUp = false;\n }\n //Cache for next check\n lastY = y;\n });\n //Listen for all drag:start events\n Y.DD.DDM.on('drag:start', function(e) {\n //Get our drag object\n var drag = e.target;\n //Set some styles here\n drag.get('node').setStyle('opacity', '.25');\n drag.get('dragNode').set('innerHTML', drag.get('node').get('innerHTML'));\n drag.get('dragNode').setStyles({\n opacity: '.85',\n borderColor: drag.get('node').getStyle('borderColor'),\n backgroundImage: drag.get('node').getStyle('backgroundImage')\n });\n });\n //Listen for a drag:end events\n Y.DD.DDM.on('drag:end', function(e) {\n var drag = e.target;\n //Put out styles back\n drag.get('node').setStyles({\n visibility: '',\n opacity: '1'\n });\n });\n //Listen for all drag:drophit events\n Y.DD.DDM.on('drag:drophit', function(e) {\n var drop = e.drop.get('node'),\n drag = e.drag.get('node');\n\n //if we are not on an li, we must have been dropped on a ul\n if (drop.get('tagName').toLowerCase() !== 'li') {\n if (!drop.contains(drag)) {\n drop.appendChild(drag);\n }\n }\n });\n\n //Static Vars\n var goingUp = false, lastY = 0;\n\n var initDragables = function(){\n\n //Get the list of li's in the lists and make them draggable\n var lis = Y.Node.all('#filelist" . $name . " li');\n if (lis){\n lis.each(function(v, k) {\n var dd = new Y.DD.Drag({\n node: v,\n proxy: true,\n moveOnEnd: false,\n target: {\n padding: '0 0 0 20'\n }\n }).plug(Y.Plugin.DDConstrained, {\n //Keep it inside the #list1 node\n constrain2node: '#filelist" . $name . "',\n stickY:true\n }).plug(Y.Plugin.DDProxy, {\n //Don't move the node at the end of the drag\n moveOnEnd: false,\n borderStyle:'0'\n });//.addHandle('.fpdrag');\n });\n }\n\n //var tar = new Y.DD.Drop({ node:Y.one('#filelist" . $name . "')});\n }\n \n initDragables();\n\n // calback function from open window\n EXPONENT.passBackFile" . $name . " = function(id) {\n\n var complete = function (ioId, o) {\n var df = Y.one('#filelist" . $name . "');\n var objson = Y.JSON.parse(o.responseText);\n var obj = objson.data;\n if (obj.mimetype!='image/png' && obj.mimetype!='image/gif' && obj.mimetype!='image/jpeg'){\n var filepic = '<img class=\"filepic\" src=\"'+EXPONENT.ICON_RELATIVE+'\"attachableitems/generic_22x22.png\">';\n } else {\n var filepic = '<img class=\"filepic\" src=\"'+EXPONENT.URL_FULL+'thumb.php?id='+obj.id+'&w=24&h=24&zc=1\">';\n }\n \n var html = '<li>';\n html += '<input type=\"hidden\" name=\"" . $subTypeName . "\" value=\"'+obj.id+'\">';\n html += '<a class=\"delete\" rel=\"imgdiv'+obj.id+'\" href=\"javascript:{}\">" . gt('delete') . "<\\/a>';\n html += filepic;\n html += '<span class=\"filename\">'+obj.filename+'<\\/span>';\n html += '<\\/li>';\n \n htmln = Y.Node.create(html); \n \n df.append(htmln);\n\n var dd = new Y.DD.Drag({\n node: htmln,\n proxy: true,\n moveOnEnd: false,\n target: {\n padding: '0 0 0 20'\n }\n }).plug(Y.Plugin.DDConstrained, {\n constrain2node: '#filelist" . $name . "',\n stickY:true\n }).plug(Y.Plugin.DDProxy, {\n moveOnEnd: false,\n borderStyle:'0'\n });\n\n \n var af = Y.one('#addfiles-" . $name . "');\n\n if (filesAdded==0) {\n fl.one('.blank').remove();\n }\n\n filesAdded++\n\n if (!Y.Lang.isNull(af) && limit==filesAdded) {\n af.remove();\n }\n\n //initDragables();\n };\n \n var cfg = {\n on:{\n success:complete\n }\n };\n Y.io(EXPONENT.URL_FULL+'index.php.php?controller=file&action=getFile&ajax_action=1&json=1&id='+id, cfg);\n //ej.fetch({action:'getFile',controller:'fileController',json:1,params:'&id='+id});\n }\n\n });\n "; // END PHP STRING LITERAL expCSS::pushToHead(array("unique" => "cal2", "link" => $assets_path . "files/attachable-files.css")); // exponent_javascript_toFoot("filepicker".$name,"json,connection","dd-constrain,dd-proxy,dd-drop",$js,""); expJavascript::pushToFoot(array("unique" => "filepicker" . $name, "yui3mods" => "1", "content" => $js, "src" => "")); return $html; }
/** * Smarty {yuimenu} function plugin * * Type: function<br> * Name: yuimenu<br> * Purpose: display a yui menu * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_yuimenu($params, &$smarty) { $menu = ' function buildmenu () { var oMenuSidenavJs = new YAHOO.widget.Menu("' . $params['buildon'] . '", { position: "static", hidedelay: 100, lazyload: true }); var aSubmenuData = ' . navigationmodule::navtojson() . '; oMenuSidenavJs.subscribe("beforeRender", function () { if (this.getRoot() == this) { for (i=0; i<=this.getItems().length; i++){ var j=i; // console.debug(aSubmenuData[j].itemdata.length); if (aSubmenuData[j].itemdata.length>0){ this.getItem(i).cfg.setProperty("submenu", aSubmenuData[j]); } } } }); oMenuSidenavJs.render(); } YAHOO.util.Event.onDOMReady(buildmenu); '; expJavascript::pushToFoot(array("unique" => "yuimenubar-" . $params['buildon'], "yui2mods" => "menu", "yui3mods" => $smarty->getTemplateVars('__name'), "content" => $menu, "src" => "")); }
/** * Smarty {pop} block plugin * * Type: block<br> * Name: pop<br> * Purpose: Set up a pop block * * @param $params * @param $content * @param \Smarty $smarty * @param $repeat */ function smarty_block_pop($params, $content, &$smarty, &$repeat) { if ($content) { $params['content'] = $content; expJavascript::panel($params); } }
function controlToHTML($name) { $html = "\n <div class=\"yui-skin-sam\">\n <div id=\"cal" . $name . "Container\"></div>\n <div id=\"calinput\">\n <input class=\"text\" type=\"text\" name=\"" . $name . "\" id=\"" . $name . "\" />\n <button class=\"button\" type=\"button\" id=\"update-" . $name . "\">Update Calendar</button>\n </div>\n </div>\n <div style=\"clear:both\"></div>\n "; $script = "\n YUI(EXPONENT.YUI3_CONFIG).use('node','yui2-calendar', function(Y) {\n var YAHOO=Y.YUI2;\n \n YAHOO.namespace(\"example.calendar\");\n\n YAHOO.example.calendar.init = function() {\n\n function handleSelect(type,args,obj) {\n var dates = args[0]; \n var date = dates[0];\n var year = date[0], month = date[1], day = date[2];\n\n var txtDate1 = document.getElementById(\"" . $name . "\");\n txtDate1.value = month + \"/\" + day + \"/\" + year;\n }\n\n function updateCal() {\n var txtDate1 = document.getElementById(\"" . $name . "\");\n\n if (txtDate1.value != \"\") {\n YAHOO.example.calendar.cal" . $name . ".select(txtDate1.value);\n var selectedDates = YAHOO.example.calendar.cal" . $name . ".getSelectedDates();\n var firstDate = selectedDates[0];\n YAHOO.example.calendar.cal" . $name . ".cfg.setProperty(\"pagedate\", (firstDate.getMonth()+1) + \"/\" + firstDate.getFullYear());\n YAHOO.example.calendar.cal" . $name . ".render();\n\n }\n }\n\n // For this example page, stop the Form from being submitted, and update the cal instead\n function handleSubmit(e) {\n updateCal();\n YAHOO.util.Event.preventDefault(e);\n }\n YAHOO.example.calendar.cal" . $name . " = new YAHOO.widget.Calendar(\"cal" . $name . "\",\"cal" . $name . "Container\",{selected:'" . date('m/d/Y', $this->default) . "'});\n YAHOO.example.calendar.cal" . $name . ".selectEvent.subscribe(handleSelect, YAHOO.example.calendar.cal" . $name . ", true);\n YAHOO.example.calendar.cal" . $name . ".select('" . date('m/d/Y', $this->default) . "');\n YAHOO.example.calendar.cal" . $name . ".render();\n YAHOO.util.Event.addListener(\"update-" . $name . "\", \"click\", updateCal);\n YAHOO.util.Event.addListener(\"dates-" . $name . "\", \"submit\", handleSubmit);\n }\n\n YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);\n });\n \n "; expJavascript::pushToFoot(array("unique" => 'calpop-' . $name, "yui3mods" => 1, "content" => $script, "src" => "")); return $html; }
/** * Smarty {script} block plugin * * Type: block<br> * Name: script<br> * Purpose: Set up a script block * * @param $params * @param $content * @param \Smarty $smarty * @param $repeat */ function smarty_block_script($params, $content, &$smarty, &$repeat) { if ($content) { global $userjsfiles; if (empty($params['unique'])) { die("<strong style='color:red'>" . gt("The 'unique' parameter is required for the {script} plugin.") . "</strong>"); } if ((isset($params['yui2mods']) || isset($params['yuimodules'])) && !strstr($content, "YUI(")) { $params['yui3mods'] = 1; $yui2mods = $params['yui2mods'] ? $params['yui2mods'] : $params['yuimodules']; $toreplace = array('"', "'", " "); $stripmodquotes = str_replace($toreplace, "", $yui2mods); $splitmods = explode(",", $stripmodquotes); $y3wrap = "YUI(EXPONENT.YUI3_CONFIG).use("; $y3wrap .= "'yui2-yahoo-dom-event', "; foreach ($splitmods as $key => $mod) { if ($mod == "menu") { $y3wrap .= "'yui2-container', "; } $y3wrap .= "'yui2-" . $mod . "', "; } $y3wrap .= "function(Y) {\r\n"; $y3wrap .= "var YAHOO=Y.YUI2;"; $y3wrap .= $content; $y3wrap .= "});"; $content = $y3wrap; } expJavascript::pushToFoot(array("unique" => $params['unique'], "yui3mods" => $params['yui3mods'], "content" => $content, "src" => $params['src'])); } }
/** * Smarty {object_to_js} function plugin * * Type: function<br> * Name: object_to_js<br> * Purpose: convert a php object into javascript * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_object_to_js($params, &$smarty) { echo "var " . $params['name'] . " = new Array();\n"; if (isset($params['objects']) && count($params['objects']) > 0) { //Write Out DataClass. This is generated from the data object. echo expJavascript::jClass($params['objects'][0], "class_" . $params['name']); //This will load up the data... foreach ($params['objects'] as $object) { echo $params['name'] . ".push(" . expJavascript::jObject($object, "class_" . $params['name']) . ");\n"; //Stuff in a unique id for reference. echo $params['name'] . "[" . $params['name'] . ".length-1].__ID = " . $params['name'] . ".length-1;\n"; } } return ""; }
public function send() { if (!expJavascript::inAjaxAction()) { if (isset($this->redirecturl)) { redirect_to($this->redirecturl); } } else { if (expJavascript::requiresJSON()) { echo json_encode($this->packet); } else { global $template; echo $template->render(); } exit; } }
function controlToHTML($name, $label) { $assets_path = SCRIPT_RELATIVE . 'framework/core/subsystems/forms/controls/assets/'; $html = '<div class="text-control control exp-skin" id="search_stringControl">'; $html .= empty($this->label) ? '' : '<label for="' . $name . '">' . $label . '</label>'; $html .= '<input type="text" class="text " size="20" value="' . $this->value . '" name="' . $name . '" id="' . $name . '"/> <div id="results' . $name . '"></div> </div> '; $script = "\n YUI(EXPONENT.YUI3_CONFIG).use('node','yui2-yahoo-dom-event','yui2-animation','yui2-autocomplete','yui2-connection','yui2-datasource', function(Y) {\n YAHOO = Y.YUI2;\n Y.one('#" . $name . "').on('click',function(e){e.target.set('value','');});\n\n // autocomplete\n var autocomplete = function() {\n // Use an XHRDataSource\n var oDS = new YAHOO.util.XHRDataSource(EXPONENT.URL_FULL+\"index.php\");\n // Set the responseType\n oDS.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;\n\n //oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;\n // Define the schema of the delimited results\n oDS.responseSchema = {\n resultsList : \"data\",\n fields : [" . $this->schema . "]\n };\n\n // Enable caching\n oDS.maxCacheEntries = 5;\n\n // Instantiate the AutoComplete\n var oAC = new YAHOO.widget.AutoComplete(\"" . $name . "\", \"results" . $name . "\", oDS);\n oAC.generateRequest = function(sQuery) {\n return \"?ajax_action=1&json=1&controller=" . $this->controller . "&model=" . $this->searchmodel . "&searchoncol=" . $this->searchoncol . "&action=" . $this->action . "&query=\"+sQuery ;\n };\n \n " . $this->jsinject . "\n\n }();\n });\n "; // end JS // css expCSS::pushToHead(array("unique" => "ac0", "link" => $assets_path . "autocomplete/autocomplete.css")); expJavascript::pushToFoot(array("unique" => 'ac' . $name, "yui3mods" => 1, "content" => $script, "src" => "")); //exponent_javascript_toFoot('ac'.$name, "animation,autocomplete,connection,datasource", null, $script); return $html; }
function controlToHTML($name, $label) { $opts_template = get_template_for_action('common', 'configopts', null); $opts_template->assign('opts', $this->opts); $html = ' <div class="yui-skin-sam"> <div id="demo"> <div id="leftopts">'; $html .= $opts_template->render(); $html .= '</div> </div> </div> '; $script = "\n\t\t\tvar cp = new configPanel(" . $this->title . ", 'leftopts', '" . $this->welcome . "', 750, 450);\n\t\t cp.fire();\n\t\t"; expJavascript::pushToFoot(array("unique" => 'cfgmgr', "yui2mods" => 'dragdrop,element,animation,resize,layout', "yui3mods" => null, "content" => '//comment', "src" => PATH_RELATIVE . 'framework/core/assets/js/exp-layout.js')); return $html; }
public static function pushToHead($params) { global $css_primer, $css_core, $css_links, $css_theme, $css_inline; // primer css if (isset($params['css_primer'])) { $primer_array = $params['css_primer']; foreach ($primer_array as $path) { //indexing the array by the filename $css_primer[$path] = $path; } } // files in framework/core/assets/css that is general to many views and the system overall if (isset($params['corecss'])) { $core_array = explode(",", $params['corecss']); foreach ($core_array as $filename) { $existspath = BASE . "framework/core/assets/css/" . $filename . ".css"; $filepath = PATH_RELATIVE . "framework/core/assets/css/" . $filename . ".css"; if (is_file($existspath)) { $css_core[$filepath] = $filepath; } } } // css linked in through the css plugin if (isset($params['link'])) { $css_links[$params['link']] = $params['link']; } // CSS hard coded in a view if (!empty($params['css'])) { $tcss = trim($params['css']); if (!empty($tcss)) { $css_inline[$params['unique']] = $params['css']; } } if (expJavascript::inAjaxAction()) { echo "<div class=\"io-execute-response\">"; if (isset($params['corecss']) && !empty($css_core)) { foreach ($css_core as $path) { echo '<link rel="stylesheet" type="text/css" href="' . $path . '">'; } } echo '<link rel="stylesheet" type="text/css" href="' . $params['link'] . '">'; echo "</div>"; } }
function toHTML($label, $name) { $html = '<div id="list' . $name . '" class="list control">'; $html .= '<label>' . gt('Add') . ' ' . $label . '</label>'; $html .= '<input id="list-input-' . $name . '" name="list-input-' . $name . '">'; $html .= '<a class="addtolist" href="#">' . gt('Add to list') . '</a>'; $html .= '<h2>' . $label . '</h2>'; $html .= '<ul id="list-values-' . $name . '">'; if (count($this->value) > 0) { foreach ($this->value as $value) { $html .= '<li><input type="hidden" name="' . $name . '[]" value="' . $value . '">'; $html .= $value . '<a class="remove-from-list" href="#">remove?</a></li>'; } } else { '<h2 id="empty-list-' . $name . '">' . gt('There are no items yet.') . '</h2>'; } $html .= '</ul>'; $html .= '</div>'; $js = "\n var add = YAHOO.util.Dom.getElementsByClassName('addtolist', 'a');\n YAHOO.util.Event.on(add, 'click', function(e,o){\n YAHOO.util.Dom.setStyle('empty-list-" . $name . "', 'display', 'none');\n YAHOO.util.Event.stopEvent(e);\n var listitem = YAHOO.util.Dom.get('list-input-" . $name . "');\n var newli = document.createElement('li');\n var newLabel = document.createElement('span');\n newLabel.innerHTML = listitem.value + '<input type=\"hidden\" name=\"" . $name . "[]\" value=\"'+listitem.value+'\" />';\n var newRemove = document.createElement('a');\n newRemove.setAttribute('href','#');\n newRemove.innerHTML = ' " . gt('Remove') . "?';\n newli.appendChild(newLabel);\n newli.appendChild(newRemove);\n var list = YAHOO.util.Dom.get('list-values-" . $name . "');\n list.appendChild(newli);\n YAHOO.util.Event.on(newRemove, 'click', function(e,o){\n var list = YAHOO.util.Dom.get('list-values-" . $name . "');\n list.removeChild(this)\n },newli,true);\n listitem.value = '';\n //alert(listitem);\n });\n \n var existingRems = YAHOO.util.Dom.getElementsByClassName('remove-from-list', 'a');\n YAHOO.util.Event.on(existingRems, 'click', function(e,o){\n YAHOO.util.Event.stopEvent(e);\n var targ = YAHOO.util.Event.getTarget(e);\n var lItem = YAHOO.util.Dom. getAncestorByTagName(targ,'li');\n var list = YAHOO.util.Dom.get('list-values-" . $name . "');\n list.removeChild(lItem);\n });\n "; // END PHP STRING LITERAL expJavascript::pushToFoot(array("unique" => "listcontrol" . $name, "yui2mods" => "json,connection", "yui3mods" => "listcontrol-" . $name, "content" => $js, "src" => "")); return $html; }
/** * Smarty {yuimenubar} function plugin * * Type: function<br> * Name: yuimenubar<br> * Purpose: display a yui menu bar * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_yuimenubar($params, &$smarty) { $menu = ' function buildmenu () { var oMenuBar = new YAHOO.widget.MenuBar("' . $params['buildon'] . '", { constraintoviewport:false, postion:"dynamic", visible:true, zIndex:250, autosubmenudisplay: true, hidedelay: 750, lazyload: true }); var aSubmenuData = ' . navigationmodule::navtojson() . '; oMenuBar.subscribe("beforeRender", function () { if (this.getRoot() == this) { for (i=0; i<=this.getItems().length; i++){ var j=i; if (aSubmenuData[j].itemdata.length>0){ this.getItem(i).cfg.setProperty("submenu", aSubmenuData[j]); } } } }); oMenuBar.render(); } YAHOO.util.Event.onDOMReady(buildmenu); '; expJavascript::pushToFoot(array("unique" => "yuimenubar-" . $params['buildon'], "yui2mods" => "menu", "yui3mods" => $smarty->getTemplateVars('__name'), "content" => $menu, "src" => "")); }
# Exponent is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License as published by the Free # Software Foundation; either version 2 of the # License, or (at your option) any later version. # # GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } //$nav = navigationmodule::levelTemplate(intval($_REQUEST['id'], 0)); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $nav = $db->selectObjects('section', 'parent=' . $id, 'rank'); $manage_all = false; if (expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $id))) { $manage_all = true; } $navcount = count($nav); for ($i = 0; $i < $navcount; $i++) { if ($manage_all || expPermissions::check('manage', expCore::makeLocation('navigationmodule', '', $nav[$i]->id))) { $nav[$i]->manage = 1; } else { $nav[$i]->manage = 0; } $nav[$i]->link = expCore::makeLink(array('section' => $nav[$i]->id), '', $nav[$i]->sef_name); } $nav[$navcount - 1]->last = true; echo expJavascript::ajaxReply(201, '', $nav);
/** * Smarty {ddrerank} function plugin * * Type: function<br> * Name: ddrerank<br> * Purpose: display item re-ranking popup * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_ddrerank($params, &$smarty) { global $db; $loc = $smarty->getTemplateVars('__loc'); $badvals = array("[", "]", ",", " ", "'", "\"", "&", "#", "%", "@", "!", "\$", "(", ")", "{", "}"); $uniqueid = str_replace($badvals, "", $loc->src) . $params['id']; $controller = !empty($params['controller']) ? $params['controller'] : $loc->mod; if ($params['sql']) { $sql = explode("LIMIT", $params['sql']); $params['items'] = $db->selectObjectsBySQL($sql[0]); } else { if ($params['items'][0]->id) { $model = empty($params['model']) ? $params['items'][0]->classname : $params['model']; $only = !empty($params['only']) ? ' AND ' . $params['only'] : ''; $obj = new $model(); $params['items'] = $obj->find('all', "location_data='" . serialize($loc) . "'" . $only, "rank"); } else { $params['items'] = array(); } } if (count($params['items']) >= 2) { expCSS::pushToHead(array("corecss" => "rerank,panel")); $sortfield = empty($params['sortfield']) ? 'title' : $params['sortfield']; //what was this even for? // attempt to translate the label if (!empty($params['label'])) { $params['label'] = gt($params['label']); } echo '<a id="rerank' . $uniqueid . '" class="reranklink" href="#">' . gt("Order") . ' ' . $params['label'] . '</a>'; $html = ' <div id="panel' . $uniqueid . '" class="exp-skin-panel exp-skin-rerank hide"> <div class="yui3-widget-hd">Order ' . $params['label'] . '</div> <div class="yui3-widget-bd"> <form method="post" action="' . URL_FULL . '"> <input type="hidden" name="model" value="' . $model . '" /> <input type="hidden" name="controller" value="' . $controller . '" /> <input type="hidden" name="lastpage" value="' . curPageURL() . '" /> <input type="hidden" name="src" value="' . $loc->src . '" />'; if (!empty($params['items'])) { // we may need to pass through an ID for some reason, like a category ID for products $html .= $params['id'] ? '<input type="hidden" name="id" value="' . $params['id'] . '" />' : ''; $html .= '<input type="hidden" name="action" value="manage_ranks" /> <ul id="listToOrder' . $uniqueid . '" style="' . (count($params['items'] < 12) ? "" : "height:350px") . ';overflow-y:auto;"> '; $odd = "even"; foreach ($params['items'] as $item) { $html .= ' <li class="' . $odd . '"> <input type="hidden" name="rerank[]" value="' . $item->id . '" /> <div class="fpdrag"></div>'; //Do we include the picture? It depends on if there is one set. $html .= $item->expFile[0]->id && $item->expFile[0]->is_image ? '<img class="filepic" src="' . URL_FULL . 'thumb.php?id=' . $item->expFile[0]->id . '&w=16&h=16&zc=1">' : ''; $html .= '<span class="label">' . (!empty($item->{$sortfield}) ? substr($item->{$sortfield}, 0, 40) : gt('Untitled')) . '</span> </li>'; $odd = $odd == "even" ? "odd" : "even"; } $html .= '</ul> <div class="yui3-widget-ft"> <button type="submit" class="awesome small ' . BTN_COLOR . '">' . gt('Save') . '</button> </div> </form> </div> </div> '; } else { $html .= '<strong>' . gt('Nothing to re-rank') . '</strong> </div> </div> '; } echo $html; $script = "\n YUI(EXPONENT.YUI3_CONFIG).use('node','dd','dd-plugin','panel', function(Y) {\n var panel = new Y.Panel({\n srcNode:'#panel" . $uniqueid . "',\n width : 500,\n visible : false,\n zIndex : 50,\n centered : false,\n render : 'body',\n // plugins : [Y.Plugin.Drag]\n }).plug(Y.Plugin.Drag);\n \n panel.dd.addHandle('.yui3-widget-hd');\n \n var panelContainer = Y.one('#panel" . $uniqueid . "').get('parentNode');\n panelContainer.addClass('exp-panel-container');\n Y.one('#panel" . $uniqueid . "').removeClass('hide');\n \n Y.one('#rerank" . $uniqueid . "').on('click',function(e){\n e.halt();\n panel.show();\n panel.set('centered',true);\n });\n\n //Static Vars\n var goingUp = false, lastY = 0;\n\n // the list\n var ul = '#listToOrder" . $uniqueid . "';\n\n //Get the list of li's in the lists and make them draggable\n var lis = Y.Node.all('#listToOrder" . $uniqueid . " li');\n// lis.each(function(v, k) {\n // var dragItem = new Y.DD.Drag({\n // node: v,\n // target: {\n // padding: '0 0 0 0'\n // }\n // }).plug(Y.Plugin.DDProxy, {\n // moveOnEnd: false\n // }).plug(Y.Plugin.DDConstrained, {\n // constrain2node: ul,\n // stickY:true\n // }).plug(Y.Plugin.DDNodeScroll, {\n // node: ul\n // }).addHandle('.fpdrag');\n\n var dragItems = new Y.DD.Delegate({\n container: ul,\n nodes: 'li',\n target: {\n padding: '0 0 0 0'\n }\n })\n \n dragItems.dd.plug(Y.Plugin.DDConstrained, {\n constrain2node: ul,\n stickY:true\n }).plug(Y.Plugin.DDProxy, {\n moveOnEnd: false\n }).plug(Y.Plugin.DDConstrained, {\n constrain2node: ul,\n stickY:true\n }).plug(Y.Plugin.DDNodeScroll, {\n node: ul\n }).addHandle('.fpdrag');\n\n dragItems.on('drop:over', function(e) {\n //Get a reference to out drag and drop nodes\n var drag = e.drag.get('node'),\n drop = e.drop.get('node');\n\n //Are we dropping on a li node?\n if (drop.get('tagName').toLowerCase() === 'li') {\n //Are we not going up?\n if (!goingUp) {\n drop = drop.get('nextSibling');\n }\n //Add the node to this list\n e.drop.get('node').get('parentNode').insertBefore(drag, drop);\n //Resize this nodes shim, so we can drop on it later.\n e.drop.sizeShim();\n }\n });\n //Listen for all drag:drag events\n dragItems.on('drag:drag', function(e) {\n //Get the last y point\n var y = e.target.lastXY[1];\n //is it greater than the lastY var?\n if (y < lastY) {\n //We are going up\n goingUp = true;\n } else {\n //We are going down..\n goingUp = false;\n }\n //Cache for next check\n lastY = y;\n Y.DD.DDM.syncActiveShims(true);\n });\n //Listen for all drag:start events\n dragItems.on('drag:start', function(e) {\n //Get our drag object\n var drag = e.target;\n //Set some styles here\n drag.get('node').setStyle('opacity', '.25');\n drag.get('dragNode').addClass('rerank-proxy').set('innerHTML', drag.get('node').get('innerHTML'));\n drag.get('dragNode').setStyles({\n opacity: '.5'\n // borderColor: drag.get('node').getStyle('borderColor'),\n // backgroundColor: drag.get('node').getStyle('backgroundColor')\n });\n });\n //Listen for a drag:end events\n dragItems.on('drag:end', function(e) {\n var drag = e.target;\n //Put out styles back\n drag.get('node').setStyles({\n visibility: '',\n opacity: '1'\n });\n });\n //Listen for all drag:drophit events\n dragItems.on('drag:drophit', function(e) {\n var drop = e.drop.get('node'),\n drag = e.drag.get('node');\n\n //if we are not on an li, we must have been dropped on a ul\n if (drop.get('tagName').toLowerCase() !== 'li') {\n if (!drop.contains(drag)) {\n drop.appendChild(drag);\n }\n }\n });\n// });\n\n //Create simple targets for the 2 lists..\n var tar = new Y.DD.Drop({\n node: ul\n }); \n });\n \n "; if (!expTheme::inPreview()) { expJavascript::pushToFoot(array("unique" => $uniqueid, "yui3mods" => 1, "content" => $script)); } } }
public function makeHeaderCols($params) { global $router; if (!empty($this->columns) && is_array($this->columns)) { $this->header_columns = ''; // get the parameters used to make this page. if (!expTheme::inAction()) { unset($params['section']); if (empty($params['controller'])) { $params['controller'] = $this->controller; } if (empty($params['action'])) { $params['action'] = $this->action; } } $current = ''; if (isset($params['order'])) { $current = $params['order']; unset($params['order']); } else { $current = $this->order; } //loop over the columns and build out a list of <th>'s to be used in the page table foreach ($this->columns as $colname => $col) { // if this is the column we are sorting on right now we need to setup some class info $class = isset($this->class) ? $this->class : 'page'; $params['dir'] = 'ASC'; if ($col == $current) { $class = 'current'; $class .= ' ' . strtolower($this->order_direction); if (isset($_REQUEST['dir'])) { $params['dir'] = $_REQUEST['dir'] == 'ASC' ? 'DESC' : 'ASC'; } else { $params['dir'] = $this->order_direction == 'ASC' ? 'DESC' : 'ASC'; } } $params['order'] = $col; $this->header_columns .= '<th class="' . $class . '">'; // if this column is empty then it's not supposed to be a sortable column if (empty($col)) { $this->header_columns .= '<span>' . $colname . '</span>'; $this->columns[$colname] = ' '; } else { if ($colname == "actupon") { $this->header_columns .= '<input type=checkbox name=selall value=1 class="select-all"/>'; $js = "\r\n YUI(EXPONENT.YUI3_CONFIG).use('node', function(Y) {\r\n Y.all('input[type=checkbox]').on('click',function(e){\r\n if (e.target.test('.select-all')) {\r\n if (!e.target.get('checked')) {\r\n this.each(function(n){\r\n n.set('checked',false);\r\n });\r\n } else {\r\n this.each(function(n){\r\n n.set('checked',true);\r\n });\r\n };\r\n };\r\n });\r\n });\r\n "; expJavascript::pushToFoot(array("unique" => 'select-all', "yui3mods" => null, "content" => $js, "src" => "")); } else { unset($params['page']); $this->header_columns .= '<a href="' . $router->makeLink($params, null, null, true) . '" alt="sort by ' . $colname . '" rel="nofollow">' . $colname . '</a>'; } } $this->header_columns .= '</th>'; } } }
function toHTML($label, $name) { $link = expCore::makeLink(array("module" => $this->controller->baseclassname, "action" => "edit", "parent" => 0)); $html = ""; if ($this->menu == "true") { if ($this->addable) { $html = '<a class="add" href="' . $link . '">Add a Category</a> | '; } $html .= '<a href="#" id="expandall">Expand All</a> | '; $html .= '<a href="#" id="collapseall">Collapse All</a>'; } $html .= ' <div id="' . $this->id . '" class="nodetree"></div> <div class="loadingdiv">Loading Categories</div>'; foreach ($this->tags as $i => $val) { if (!empty($this->values) && in_array($val->id, $this->values)) { $this->tags[$i]->value = true; } else { $this->tags[$i]->value = false; } $this->tags[$i]->draggable = $this->draggable; $this->tags[$i]->checkable = $this->checkable; } $obj = json_encode($this->tags); $script = "\n\t\tEXPONENT.YUI3_CONFIG.modules = {\n 'exp-tree' : {\n fullpath: EXPONENT.PATH_RELATIVE+'framework/core/assets/js/exp-tree.js',\n requires : ['node','yui2-container','yui2-menu','yui2-treeview','yui2-animation','yui2-dragdrop','yui2-json','yui2-connection']\n }\n }\n\n \t\t//EXPONENT.YUI3_CONFIG.filter = \".js\";\n\n YUI(EXPONENT.YUI3_CONFIG).use('node','exp-tree', function(Y) {\n \t\t\tvar obj2json = " . $obj . ";\n\t\t\t\tEXPONENT.DragDropTree.init('" . $this->id . "',obj2json,'" . $this->modelname . "','" . $this->menu . "','" . $this->expandonstart . "');\n\t\t\t\tY.one('.nodetree').next().remove();\n\t\t\t});\n\t\t"; // exponent_javascript_toFoot('expddtree', 'treeview,menu,animation,dragdrop,json,container,connection', null, $script, PATH_RELATIVE.'framework/core/assets/js/exp-tree.js'); expJavascript::pushToFoot(array("unique" => 'expddtree', "yui3mods" => 1, "content" => $script)); return $html; }
/** * Smarty {rating} function plugin * * Type: function<br> * Name: rating<br> * Purpose: display a rating * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_rating($params, &$smarty) { global $user, $db; expCSS::pushToHead(array("unique" => 'ratings', "link" => PATH_RELATIVE . "framework/modules/core/assets/css/ratings.css")); $params['subtype'] = isset($params['subtype']) ? $params['subtype'] : $params['content_type']; $total_rating = 0; if (!empty($params['record']->expRating[$params['subtype']])) { foreach ($params['record']->expRating[$params['subtype']] as $rating) { $total_rating = $total_rating + $rating->rating; if ($rating->poster == $user->id) { $myrate = $rating->rating; } } $rating_count = count($params['record']->expRating[$params['subtype']]); $total_average = number_format($total_rating / $rating_count, 1); } else { $rating_count = 0; $total_average = 0; } $avg_percent = round($total_average * 100 / 5) + 1; $html = ' <div class="star-rating"> <div id="rating-total-' . $params['subtype'] . '" class="star-stats"> <strong>' . $params['label'] . '</strong> <div id="user-rating-' . $params['subtype'] . '" class="star-bar"> <div id="star-average-' . $params['subtype'] . '" class="star-average" style="width:' . $avg_percent . '%"></div>'; if ($user->isLoggedIn()) { $html .= '<div id="my-ratings-' . $params['subtype'] . '" class="my-ratings"> <span rel="1" class="u-star st1' . ($myrate >= 1 ? " selected" : "") . '"> <span rel="2" class="u-star st2' . ($myrate >= 2 ? " selected" : "") . '"> <span rel="3" class="u-star st3' . ($myrate >= 3 ? " selected" : "") . '"> <span rel="4" class="u-star st4' . ($myrate >= 4 ? " selected" : "") . '"> <span rel="5" class="u-star st5' . ($myrate >= 5 ? " selected" : "") . '"> </span> </span> </span> </span> </span> </div>'; } if ($rating_count) { $html .= '</div><em><span class="avg">' . $total_average . '</span> ' . gt('avg. by') . ' <span class="raters">' . $rating_count . '</span> ' . gt('people') . '</em></div>'; } else { $html .= '</div><em><span class="raters">' . gt('Be the first to rate this item.') . '</em></div>'; } $rated = $db->selectValue('content_expRatings', 'expratings_id', "content_type='" . $params['content_type'] . "' AND subtype='" . $params['subtype'] . "' AND poster='" . $user->id . "'"); $rated_val = $db->selectValue('expRatings', 'rating', "id='" . $rated . "' AND poster='" . $user->id . "'"); $html .= ' <div class="rating-form"> <form id="ratingform-' . $params['subtype'] . '" action="index.php" method="post"> <input type="hidden" name="action" value="update" /> <input type="hidden" name="controller" value="expRating" /> <input type="hidden" name="content_type" value="' . $params['content_type'] . '" /> <input type="hidden" name="subtype" value="' . $params['subtype'] . '" /> <input type="hidden" name="content_id" value="' . $params['record']->id . '" />'; $control = new radiogroupcontrol(); // differentiate it from the old school forms $control->newschool = true; $control->cols = 0; $control->default = $rated_val; $control->items = array_combine(explode(',', "1,2,3,4,5"), explode(',', "1,2,3,4,5")); $html .= $control->toHTML('', 'rating'); $html .= '<button>Save Rating</button> </form> </div> </div> '; $content = "\n YUI(EXPONENT.YUI3_CONFIG).use('node','event','io', function(Y) {\n var myrating = '" . $myrate . "';\n var ratingcount = '" . $rating_count . "';\n var total_rating = '" . $total_rating . "';\n var total_average = '" . $total_average . "';\n var avg_percent = '" . $avg_percent . "';\n \n function update_totals(mynewrating) {\n if (myrating=='') {\n myrating = mynewrating;\n ratingcount = parseInt(ratingcount)+1\n Y.one('#rating-total-" . $params['subtype'] . " .raters').setContent(ratingcount);\n }\n total_rating = (total_rating==0) ? parseInt(mynewrating) : total_rating-myrating+parseInt(mynewrating);\n total_average = total_rating/ratingcount;\n avg_percent = total_average*100/5;\n Y.one('#rating-total-" . $params['subtype'] . " .avg').setContent(total_average.toFixed(1));\n Y.one('#star-average-" . $params['subtype'] . "').setStyle('width',Math.round(avg_percent)+1+'%');\n myrating = mynewrating;\n }\n \n var iocfg = {\n method: 'POST',\n data: 'json=1&ajax_action=1',\n form: {\n id: 'ratingform-" . $params['subtype'] . "',\n useDisabled: false\n }\n };\n function save_rating() {\n var url = EXPONENT.URL_FULL+'index.php';\n Y.io(url, iocfg);\n Y.on('io:success', onSuccess, this);\n Y.on('io:failure', onFailure, this);\n };\n function onSuccess(id,response,args) {\n\n };\n function onFailure(id,response,args) {\n alert('woops, something is broke...');\n };\n\n var myratings = Y.one('#my-ratings-" . $params['subtype'] . "');\n\n // handles what happens when you click on the stars\n myratings.delegate(\n {\n 'click' : function(e) {\n e.stopPropagation();\n e.container.all('.u-star').removeClass('selected');\n update_totals(e.target.getAttribute('rel'))\n e.target.addClass('selected').ancestors('.u-star').addClass('selected');\n var form = Y.one('#ratingform-" . $params['subtype'] . "');\n form.one('[value='+myrating+']').set('checked','checked');\n save_rating();\n //form.submit();\n }\n },'.u-star');\n\n // handles what happens when you hover over the stars if you've not rated this item before\n myratings.on(\n {\n 'mouseenter' : function(e) {\n myratings.all('.u-star').removeClass('selected');\n },\n 'mouseleave' : function(e) {\n if (myrating!='') {\n myratings.one('.u-star[rel='+myrating+']').addClass('selected').ancestors('.u-star').addClass('selected');\n }\n }\n });\n\n });\n "; if ($user->isLoggedIn()) { expJavascript::pushToFoot(array("unique" => 'ratings' . $params['subtype'], "yui3mods" => "yui", "content" => $content)); } echo $html; }
public static function processCSSandJS() { global $jsForHead, $cssForHead; // returns string, either minified combo url or multiple link and script tags $jsForHead = expJavascript::parseJSFiles(); $cssForHead = expCSS::parseCSSFiles(); }
/** * Smarty {paginate} block plugin * * Type: block<br> * Name: paginate<br> * Purpose: Set up a pagination block * * @param $params * @param $content * @param \Smarty $smarty */ function smarty_block_paginate($params, $content, &$smarty) { if ($content) { ?> <script language="JavaScript"> //Cookie Stuff function getCookieVal(offset) { var endstr = document.cookie.indexOf(";", offset); if (endstr == -1) endstr = document.cookie.length; return decodeURIComponent (document.cookie.substring(offset, endstr)); } function getCookie(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i,j) == arg) return getCookieVal(j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function setCookie(name, value) { document.cookie = name + "=" + encodeURIComponent(value); } //End Cookie Stuff. //Class to define new filters function cFilter(name, filterFunc) { //This is the display name this.name = name; //Call back function. Should expect a data object and return a boolean. //True = included; //False = not included this.filterFunc = filterFunc; } //Class to define columns function cColumn(headerText, attribute, overrideFunc, sortFunc, sLink) { //Column Header Text this.headerText = headerText; //Attribut of the data object to display if overrideFunc is null; this.attribute = "var_"+attribute; //Callback Function. Should expect a dataobject and return a string //This will be called for each row and the return data will be displayed. //Use this to put any special data into the the cell. //If this is defined, attribute will be ignored. this.overrideFunc = overrideFunc; this.sortFunc = sortFunc; //This will add an href with a src of link for each item in the column. //The id from the record is appended to the link. this.sLink = sLink || ""; this.ascending = 0; } //This is the main Sorting/Filtering/Paging class var paginate = new function() { this.rowsPerPage = <?php echo isset($params['rowsPerPage']) ? $params['rowsPerPage'] : 20; ?> ; this.tableName = <?php echo isset($params['tableName']) ? '"' . $params['tableName'] . '"' : '"dataTable"'; ?> ; this.currentPage = <?php echo isset($params['currentPage']) ? $params['currentPage'] : '1'; ?> ; this.filterCellName = <?php echo isset($params['filterCellName']) ? '"' . $params['filterCellName'] . '"' : '"filterCell"'; ?> ; this.searchCellName = <?php echo isset($params['searchCellName']) ? '"' . $params['searchCellName'] . '"' : '"searchCell"'; ?> ; this.modulePrefix = <?php echo isset($params['modulePrefix']) ? '"' . $params['modulePrefix'] . '"' : '"default"'; ?> ; this.name = <?php echo "'" . $params['paginateName'] . "';\n"; ?> this.noRecords = '<?php echo isset($params['noRecordsText']) ? $params['noRecordsText'] : gt("No records found"); ?> '; this.noMatches = '<?php echo isset($params['noMatchesText']) ? $params['noMatchesText'] : gt("Nothing matched your criteria."); ?> '; this.filteredData = new Array(); this.allData = new Array(); //This will hold the location of each of the controls this.controls = new Array(); //This is an array of cColumn Objects this.columns = new Array(); //This is an array of cFilter Objects. this.filters = new Array(); this.applyFilter = function(sID) { this.filteredData = null; this.filteredData = new Array(); var bInclude = false; var bHit = false; var aFilterArray = new Array(); var any = 1; if (sID == "fromcookie") { var cookieStr = getCookie(this.name + "_filters"); if (cookieStr != null) { any = cookieStr.substr(0,1)=="1"; aFilterArray = cookieStr.substr(2).split(":"); for (var i in aFilterArray) { aFilterArray[i] = aFilterArray[i] == "true"; } } } else { for (var filterKey in this.filters) { aFilterArray[filterKey] = document.getElementById(sID + "_filter" + filterKey).checked; } any = document.getElementById(sID + "_any").checked; } var bHaveFilter; for (var dataKey in this.allData) { bInclude = false; bHaveFilter = false; bHit = true; for (var filterKey in aFilterArray) { if (aFilterArray[filterKey]) { bHaveFilter = true; bHit = this.filters[filterKey].filterFunc(this.allData[dataKey]); if (any) { if (bHit) { bInclude = true; break; } } else { //All if (!bHit) { bInclude = false; break; } else { bInclude = true; } } } } if (bInclude || !bHaveFilter) { this.filteredData.push(this.allData[dataKey]); } } var sortcolumn = getCookie(this.name + "_sortcolumn"); var sortdirection = getCookie(this.name + "_sortdirection"); this.defaultSort(sortcolumn,sortdirection); var sCookie = ""; if (any) { sCookie = "1"; } else { sCookie = "0"; } sCookie += ":" + aFilterArray.join(":"); setCookie(this.name + "_filters",sCookie); this.drawTable(); } this.defaultSort = function(sortcolumn,sortdirection) { if (sortcolumn != null) { this.columns[sortcolumn].ascending = sortdirection; this.sort(sortcolumn,true); } else { for (var key in this.columns) { if (!(this.columns[key].sortFunc != null && this.columns[key].attribute != "")) { this.columns this.sort(key,true); break; } } } } this.sort = function(index,doNotDraw) { for (var data in this.columns) { if (data == index) { if (this.columns[index].ascending == 1) { this.columns[index].ascending = 0; } else { this.columns[index].ascending = 1; } } else { this.columns[data].ascending = -1; } } var asc = this.columns[index].ascending==1?-1:1; setCookie(this.name + "_sortcolumn",index); setCookie(this.name + "_sortdirection",asc); if (this.columns[index].sortFunc != null) { if (this.columns[index].ascending) { this.filteredData.sort(this.columns[index].sortFunc); } else { var sortFunc = this.columns[index].sortFunc; this.filteredData.sort(function(a,b) { return -1*(sortFunc(a,b)); }); } } else { var attr = this.columns[index].attribute; if (attr != "") { this.filteredData.sort(function(a,b) { return (asc)*(a[attr].toLowerCase() > b[attr].toLowerCase() ? -1 : 1); }); } } if (!doNotDraw) this.drawTable(); } this.gotoPage = function(iPage) { setCookie(this.name + "_page",iPage); this.currentPage = parseInt(iPage); this.drawTable(); } this.selectedPage = function(select) { this.gotoPage(parseInt(select.options[select.selectedIndex].value) + 1); } this.drawTable = function() { var ptTable = document.getElementById(this.tableName); if (ptTable == null) return; while (ptTable.rows.length > 0) { ptTable.deleteRow(0); } if (this.currentPage > (Math.floor(this.filteredData.length / this.rowsPerPage) + 1)) { this.currentPage = Math.floor(this.filteredData.length / this.rowsPerPage) + 1; } var startCount = (this.currentPage - 1) * this.rowsPerPage; var endCount = startCount + this.rowsPerPage; if (endCount > this.filteredData.length) endCount = this.filteredData.length; var row = document.createElement("tr"); var cell = document.createElement("td"); var cell_content; row = document.createElement("tr"); for (var data in this.columns) { cell = document.createElement("th"); if (document.all) { // IE is different cell.setAttribute("className","header " + this.modulePrefix + "_header"); } else { cell.setAttribute("class","header " + this.modulePrefix + "_header"); } cell_content = this.columns[data].headerText; if (this.columns[data].attribute != "" || this.columns[data].sortFunc != null) { cell_content = "<a href='#' onclick='paginate.sort(\""+data+"\"); return false;'>"+this.columns[data].headerText+"</a>"; if (this.columns[data].ascending != -1) { cell_content += " <img id='sortCol_"+data+"' src='<?php echo ICON_RELATIVE; ?> sort"+(this.columns[data].ascending ? "de" : "a")+"scending.png' border='0' />"; } else { cell_content += " <img id='sortCol_"+data+"' src='<?php echo ICON_RELATIVE; ?> blank.gif' border='0' />"; } } cell.innerHTML = cell_content; row.appendChild(cell); } ptTable.appendChild(row); if (this.filteredData.length) { var rowCycle = 0; var rowCounter = 0; for (var dataObject in this.filteredData) { rowCounter++; if ((rowCounter > startCount) && (rowCounter <= (startCount + this.rowsPerPage))) { row = document.createElement("tr"); if (document.all) { // IE is different row.setAttribute("className","row " + ((rowCycle == 0)?"odd":"even")); } else { row.setAttribute("class","row " + ((rowCycle == 0)?"odd":"even")); } rowCycle = !rowCycle; for (var data in this.columns) { cell = document.createElement("td"); cell.setAttribute("valign","top"); var sText = ""; if (this.columns[data].overrideFunc == undefined) { sText = (this.filteredData[dataObject][this.columns[data].attribute] == undefined)?" ":this.filteredData[dataObject][this.columns[data].attribute]; } else { sText = this.columns[data].overrideFunc(this.filteredData[dataObject]); } if (this.columns[data].sLink != "") { cell.innerHTML = "<a href='#' onclick='" + this.columns[data].sLink + this.filteredData[dataObject]['id'] + "' class='mngmntlink " + this.modulePrefix + "_mngmntlink'>" + sText + "</a>"; } else { cell.innerHTML = sText; } row.appendChild(cell); } ptTable.appendChild(row); } } } else { row = document.createElement("tr"); if (document.all) { // IE is different row.setAttribute("className","row"); } else { row.setAttribute("class","row"); } cell = document.createElement("td"); cell.setAttribute("style","text-align: center; font-style: italic"); cell.setAttribute("colspan",this.columns.length); if (this.allData.length) { cell.innerHTML = this.noMatches; } else { cell.innerHTML = this.noRecords; } row.appendChild(cell); ptTable.appendChild(row); } for (var key in this.controls) { if (this.filteredData.length) { switch (key.substr(0,3)) { case "pp_": //Page Picker Drop Down var select = document.createElement("select"); select.setAttribute("onchange","paginate.selectedPage(this); return false"); var opt = null; for (var i = 0; i < Math.floor(this.filteredData.length/this.rowsPerPage) + 1; i++) { opt = document.createElement("option"); opt.innerHTML = (i+1); opt.setAttribute("value",i); if (i == this.currentPage-1) opt.setAttribute("selected","true"); select.appendChild(opt); } document.getElementById(key).innerHTML = ""; document.getElementById(key).appendChild(document.createTextNode(this.controls[key])); document.getElementById(key).appendChild(select); break; case "tp_": //Text based page picker var iPad = this.controls[key]; var totalPages = Math.ceil(this.filteredData.length/this.rowsPerPage); var iLeftOverflow = iPad - (this.currentPage-1); var iLeftStart = 1; if (iLeftOverflow < 0) iLeftStart = Math.abs(iLeftOverflow) + 1; var iRightEnd = this.currentPage + iPad; var iRightOverflow = totalPages - iRightEnd; if (iRightOverflow < 0) iRightEnd = totalPages; if (iLeftOverflow > 0) iRightEnd += iLeftOverflow; if (iRightEnd > totalPages) iRightEnd = totalPages; if (iRightOverflow < 0) iLeftStart -= Math.abs(iRightOverflow); if (iLeftStart < 1) iLeftStart = 1; var sOut = ""; if (iLeftStart > 1) { sOut = "<a href='JavaScript:paginate.gotoPage(1);' class='mngmntlink " + this.modulePrefix + "_mngmntlink'><<</a> <a href='JavaScript:paginate.gotoPage(" + ((this.currentPage - (iPad * 2) < 1)?"1":(this.currentPage - (iPad * 2))) + ");' class='mngmntlink " + this.modulePrefix + "_mngmntlink'>...</a> "; } for (var x = iLeftStart; x <= iRightEnd; x++) { if (x != this.currentPage) { sOut += "<a href='JavaScript:paginate.gotoPage(" + x + ");' class='mngmntlink " + this.modulePrefix + "_mngmntlink'>" + x + "</a> "; } else { sOut += "<b>" + x + "</b> "; } } if (iRightEnd < totalPages) { sOut += "<a href='JavaScript:paginate.gotoPage(" + ((this.currentPage + (iPad * 2) > totalPages)?totalPages:(this.currentPage + (iPad * 2))) + ");' class='mngmntlink " + this.modulePrefix + "_mngmntlink'>...</a> <a href='JavaScript:paginate.gotoPage(" + totalPages + ");' class='mngmntlink " + this.modulePrefix + "_mngmntlink'>>></a>"; } document.getElementById(key).innerHTML = sOut; break; case "ps_": var sText = this.controls[key]; var regex = /%cp/ sText = sText.replace(regex,this.currentPage); regex = /%tp/ sText = sText.replace(regex,Math.floor(this.filteredData.length / this.rowsPerPage) + 1); regex = /%sr/ sText = sText.replace(regex,(startCount + 1)); regex = /%er/ sText = sText.replace(regex,endCount); regex = /%tr/ sText = sText.replace(regex,this.filteredData.length); document.getElementById(key).innerHTML = sText; break; default: break; } } } } this.drawPagePicker = function(sText) { var sID = "pp_" + (Math.floor(Math.random() * 10000)); this.controls[sID] = sText; return "<span id='" + sID + "'></span>"; } this.drawPageTextPicker = function(padding) { if (padding == undefined) padding = 3; var sID = "tp_" + (Math.floor(Math.random() * 10000)); this.controls[sID] = padding; return "<span id='" + sID + "'></span>"; } this.drawPageStats = function (sText) { //This will return write page location information based on sText; //Keys that will be replaces... // %cp - current page // %tp - total pages // %sr - starting record // %er - ending record // %tr - total records if (sText == "") sText = "<?php echo gt("On page") . " %cp " . gt("of") . " %tp " . gt("viewing records") . " %sr " . gt("to") . " %er " . gt("of"); ?> %tr."; var sID = "ps_" + (Math.floor(Math.random() * 10000)); this.controls[sID] = sText; return "<span id='" + sID + "'></span>"; } this.drawFilterForm = function() { var sID = "ff_" + (Math.floor(Math.random() * 10000)); this.controls[sID] = ""; if (this.filters.length) { var aFilterArray = new Array(); var cookieStr = getCookie(this.name + "_filters"); var any = true; if (cookieStr != null) { any = cookieStr.substr(0,1)=="1"; aFilterArray = cookieStr.substr(2).split(":"); for (var i in aFilterArray) { aFilterArray[i] = aFilterArray[i] == "true"; } } var cell = document.createElement("span"); for (var key1 in this.filters) { var filter = this.filters[key1]; var cb = document.createElement("input"); cb.setAttribute("type","checkbox"); cb.setAttribute("id", sID + "_filter"+key1); if (aFilterArray[key1]) { cb.setAttribute("checked","true"); } cell.appendChild(cb); cell.appendChild(document.createTextNode(filter.name)); cell.appendChild(document.createElement("br")); } var radio_any = document.createElement("input"); radio_any.setAttribute("type","radio"); if (any) { radio_any.setAttribute("checked","true"); } radio_any.setAttribute("id",sID + "_any"); radio_any.setAttribute("name", sID + "_match"); var radio_all = document.createElement("input"); radio_all.setAttribute("type","radio"); if (!any) { radio_all.setAttribute("checked","true"); } radio_all.setAttribute("id",sID + "_all"); radio_all.setAttribute("name", sID + "_match"); cell.appendChild(radio_any); cell.appendChild(document.createTextNode(<?php echo gt("Match Any Criteria"); ?> )); cell.appendChild(document.createElement("br")); cell.appendChild(radio_all); cell.appendChild(document.createTextNode(<?php echo gt("Match All Criteria"); ?> )); cell.appendChild(document.createElement("br")); var btn = document.createElement("input"); btn.setAttribute("type","button"); btn.setAttribute("value",<?php echo gt("Filter"); ?> ); btn.setAttribute("onclick","paginate.applyFilter('" + sID + "'); return false;"); cell.appendChild(btn); return cell.innerHTML; } } this.drawSearchForm = function() { var sID = "sf_" + (Math.floor(Math.random() * 10000)); this.controls[sID] = ""; return "<span id='" + sID + "'></span>"; } this.drawForms = function() { this.drawFilterForm(); this.drawSearchForm(); } } <?php if (isset($params['objects']) && count($params['objects']) > 0) { //Write Out DataClass. This is generated from the data object. echo expJavascript::jClass($params['objects'][0], 'paginateDataClass'); ?> var tempObj = new paginateDataClass(); for (var attribute in tempObj) { paginate.columns.push(new cColumn(attribute,attribute,null)); } <?php //This will load up the data... foreach ($params['objects'] as $object) { echo "paginate.allData.push(" . expJavascript::jObject($object, 'paginateDataClass') . ");\r\n"; echo "paginate.allData[paginate.allData.length-1].__ID = paginate.allData.length-1;\r\n"; } echo "paginate.filteredData = paginate.allData;\n"; } echo $content; ?> var page = getCookie(paginate.name + "_page"); if (page != null) { paginate.currentPage = parseInt(page); } var sortcolumn = getCookie(paginate.name + "_sortcolumn"); var sortdirection = getCookie(paginate.name + "_sortdirection"); paginate.applyFilter("fromcookie"); </script> <?php } }
/** * Smarty {prod_images} function plugin * * Type: function<br> * Name: prod_images<br> * Purpose: display product images * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_prod_images($params, &$smarty) { //load up the img plugin require_once $smarty->_get_plugin_filepath('function', 'img'); $rec = $params['record']; if ($rec->main_image_functionality == 'iws') { $images = $rec->expFile['imagesforswatches']; } else { $images = $rec->expFile['mainimage']; } //ref for additional images so we can play with the array $additionalImages = !empty($rec->expFile['images']) ? $rec->expFile['images'] : array(); $mainImages = !empty($additionalImages) ? array_merge($images, $additionalImages) : $images; $mainthmb = !empty($rec->expFile['mainthumbnail'][0]) ? $rec->expFile['mainthumbnail'][0] : $mainImages[0]; $addImgs = array_merge(array($mainthmb), $additionalImages); //pulling in store configs. This is a placeholder for now, so we'll manually set them til we get that worked in. $config = $smarty->getTemplateVars('config'); // $config = array( // "listing-width"=>148, // "listing-height"=>148, // "disp-width"=>200, // "disp-height"=>250, // "thmb-box"=>40, // "swatch-box"=>30, // "swatch-pop"=>100 // ); switch ($params['display']) { case 'single': $html = '<a class="prod-img" href="' . makelink(array("controller" => "store", "action" => "showByTitle", "title" => $rec->title)) . '">'; $width = !empty($params['width']) ? $params['width'] : 100; $imgparams = array("constraint" => 1, "file_id" => $images[0]->id, "w" => $config["listingwidth"], "h" => $config["listingheight"], "return" => 1, "class" => "ecom-image"); if (!$images[0]->id) { unset($imgparams['file_id']); $imgparams['src'] = 'framework/modules/ecommerce/assets/images/no-image.jpg'; $imgparams['alt'] = gt('No image found for') . ' ' . $rec->title; } $img = smarty_function_img($imgparams, &$smarty); $html .= $img; $html .= '</a>'; break; case 'main': // if we have only 1 image to display, left do a little math to figure out how tall to make our display box if (count($addImgs) <= 1) { $config['displayheight'] = ceil($mainImages[0]->image_height * $config['displaywidth'] / $mainImages[0]->image_width); } if (count($addImgs) > 1) { $adi .= '<ul class="thumbnails">'; for ($i = 0; $i < count($addImgs); $i++) { $thumbparams = array("h" => $config['addthmbw'], "w" => $config['addthmbh'], "zc" => 1, "file_id" => $addImgs[$i]->id, "return" => 1, "class" => "thumnail"); $thmb .= '<li>' . smarty_function_img($thumbparams, &$smarty) . '</li>'; } $adi .= $thmb; $adi .= '</ul>'; } // shrink shrink the display window to fit the selected image if no height is set if ($config['displayheight'] == 0) { $config['displayheight'] = $config['displaywidth'] * $mainImages[0]->image_height / $mainImages[0]->image_width; } $html = '<div class="ecom-images loading-images" style="width:' . $config['displaywidth'] . 'px;">'; // if configured, the additional thumb images will display at the bottom $html .= $config['thumbsattop'] == 1 ? $adi : ''; $html .= '<ul class="enlarged" style="height:' . $config['displayheight'] . 'px;width:' . $config['displaywidth'] . 'px;">'; for ($i = 0; $i < count($mainImages); $i++) { $imgparams = array("w" => $config['displaywidth'], "file_id" => $mainImages[$i]->id, "return" => 1, "class" => "large-img"); $img .= '<li>' . smarty_function_img($imgparams, &$smarty) . '</li>'; } $html .= $img; $html .= '</ul>'; // if configured, the additional thumb images will display at the bottom $html .= $config['thumbsattop'] != 1 ? $adi : ''; $html .= '</div>'; // javascripting $js = "\n YUI(EXPONENT.YUI3_CONFIG).use('node','anim', function(Y) {\n // set up the images with correct z-indexes to put the first image on top\n var imgs = Y.all('.ecom-images img.large-img');\n var thumbs = Y.all('.thumbnails img');\n var swatches = Y.all('.swatches .swatch');\n\n //remove loading\n Y.one('.loading-images').removeClass('loading-images');\n\n var resetZ = function(n,y){\n n.setStyles({'zIndex':0,'display':'none'});\n n.set('id','exp-ecom-msi-'+y);\n }\n\n imgs.each(resetZ);\n imgs.item(0).setStyles({'zIndex':'1','display':'block'});\n \n swatches.each(function(n,y){\n n.set('id','exp-ecom-ms-'+y)\n });\n \n swatches.on('click',function(e){\n imgs.each(resetZ);\n var curImg = imgs.item(swatches.indexOf(e.target));\n var imgWin = curImg.ancestor('ul.enlarged');\n imgWin.setStyle('height',curImg.get('height')+'px');\n //animImgWin(imgWin,curImg.get('height'));\n curImg.setStyles({'zIndex':'1','display':'block'});\n });\n \n thumbs.on('click',function(e){\n imgs.each(resetZ);\n \n if (swatches.size()!=0) {\n var processedIndex = thumbs.indexOf(e.target)==0 ? 0 : swatches.size()+thumbs.indexOf(e.target)-1;\n } else {\n var processedIndex = thumbs.indexOf(e.target);\n }\n var curImg = imgs.item(processedIndex); \n curImg.ancestor('ul.enlarged').setStyle('height',curImg.get('height')+'px'); \n curImg.setStyles({'zIndex':'1','display':'block'});\n });\n \n // animation... too much for now, but we'll leave the code\n var animImgWin = function (node,h) {\n var hAnim = new Y.Anim({\n node: node,\n to: {height: h},\n easing:Y.Easing.easeOut,\n duration:0.5\n });\n hAnim.run();\n }\n \n });\n "; expJavascript::pushToFoot(array("unique" => 'imgswatches', "yui2mods" => null, "yui3mods" => null, "content" => $js, "src" => "")); break; case 'swatches': $html = '<ul class="swatches">'; $swatches = $rec->expFile['swatchimages']; for ($i = 0; $i < count($swatches); $i++) { $small = array("h" => $config['swatchsmh'], "w" => $config['swatchsmw'], "zc" => 1, "file_id" => $swatches[$i]->id, "return" => 1, "class" => 'swatch'); $med = array("h" => $config['swatchpoph'], "w" => $config['swatchpopw'], "zc" => 1, "file_id" => $swatches[$i]->id, "return" => 1); $swtch .= '<li>' . smarty_function_img($small, &$smarty); $swtch .= '<div>' . smarty_function_img($med, &$smarty) . '<strong>' . $swatches[$i]->title . '</strong></div>'; $swtch .= '</li>'; } $html .= $swtch; $html .= '</ul>'; break; } echo $html; }
# GPL: http://www.gnu.org/licenses/gpl.txt # ################################################## if (!defined('EXPONENT')) { exit(''); } global $user, $db; $my_version = gt("Exponent Version") . " : " . EXPONENT_VERSION_MAJOR . "." . EXPONENT_VERSION_MINOR . "." . EXPONENT_VERSION_REVISION . "<br />"; if (EXPONENT_VERSION_TYPE != '') { $my_type = gt("Release level") . " : " . EXPONENT_VERSION_TYPE . EXPONENT_VERSION_ITERATION . "<br />"; } else { $my_type = ''; } $my_releasedate = gt("Release date") . " : " . date("F-d-Y", EXPONENT_VERSION_BUILDDATE); $script = "\n// YUI(EXPONENT.YUI3_CONFIG).use('node', function(Y) {\n// \n// });\n\n"; expJavascript::pushToFoot(array("unique" => 'admin1', "yui3mods" => null, "content" => $script)); if ($user->isAdmin()) { $expAdminMenu = array('text' => '<img src="' . $this->asset_path . 'images/admintoolbar/expbar.png">', 'classname' => 'site', 'submenu' => array('id' => 'admin', 'itemdata' => array(array('classname' => 'info', 'text' => gt('About ExponentCMS'), "submenu" => array('id' => 'ver', 'itemdata' => array(array('classname' => 'moreinfo', 'text' => $my_version . $my_type . $my_releasedate . "<br />" . gt("PHP Version") . " : " . phpversion(), "disabled" => true), array('text' => gt("Exponent Documentation"), 'url' => '#', 'id' => 'docs-toolbar', 'classname' => 'docs'), array('text' => gt("Discuss Exponent"), 'url' => '#', 'id' => 'forums-toolbar', 'classname' => 'forums'), array('text' => gt("Report a bug"), 'url' => '#', 'id' => 'reportabug-toolbar', 'classname' => 'reportbug'))))))); } else { $expAdminMenu = array('text' => '<img src="' . $this->asset_path . 'images/admintoolbar/expbar.png">', 'classname' => 'site', 'submenu' => array('id' => 'admin', 'itemdata' => array(array('classname' => 'info', 'text' => gt('About ExponentCMS'), "submenu" => array('id' => 'ver', 'itemdata' => array(array('classname' => 'moreinfo', 'text' => $my_version . $my_type . $my_releasedate, "disabled" => true), array('text' => gt("Exponent Documentation"), 'url' => '#', 'id' => 'docs-toolbar', 'classname' => 'docs'), array('text' => gt("Discuss Exponent"), 'url' => '#', 'id' => 'forums-toolbar', 'classname' => 'forums'))))))); } if ($user->isAdmin()) { if (SMTP_USE_PHP_MAIL) { $expAdminMenu['submenu']['itemdata'][] = array('text' => gt("Configuration"), 'classname' => 'config', 'submenu' => array('id' => 'configure', 'itemdata' => array(array('text' => gt("Configure Website"), 'url' => makeLink(array('module' => 'administration', 'action' => 'configure_site'))), array('text' => gt('Regenerate Search Index'), 'classname' => 'search', 'url' => makeLink(array('module' => 'search', 'action' => 'spider')))))); } else { $expAdminMenu['submenu']['itemdata'][] = array('text' => gt('Configuration'), 'classname' => 'config', 'submenu' => array('id' => 'configure', 'itemdata' => array(array('text' => gt("Configure Website"), 'url' => makeLink(array('module' => 'administration', 'action' => 'configure_site'))), array('text' => gt('Test SMTP Mail Server Settings'), 'url' => makeLink(array('module' => 'administration', 'action' => 'test_smtp'))), array('text' => gt('Regenerate Search Index'), 'classname' => 'search', 'url' => makeLink(array('module' => 'search', 'action' => 'spider')))))); } } $groups = $db->selectObjects('groupmembership', 'member_id=' . $user->id . ' AND is_admin=1'); if ($user->isAdmin() || !empty($groups)) { $expAdminMenu['submenu']['itemdata'][] = array('text' => gt('User Management'), 'classname' => 'users', 'submenu' => array('id' => 'usermanagement', 'itemdata' => array(array('text' => gt('User Accounts'), 'url' => makeLink(array('controller' => 'users', 'action' => 'manage')), 'classname' => 'euser'), array('text' => gt('Group Accounts'), 'url' => makeLink(array('module' => 'users', 'action' => 'manage_groups')), 'classname' => 'egroup'), array('text' => gt('Profile Definitions'), 'url' => makeLink(array('module' => 'users', 'action' => 'manage_extensions'))), array('text' => gt('User Sessions'), 'url' => makeLink(array('module' => 'users', 'action' => 'manage_sessions'))))));
function controlToHTML($name, $label) { $this->name = empty($this->name) ? $name : $this->name; $this->id = empty($this->id) ? $name : $this->id; $html = '<table height=100% class="quantity-tbl" cellspacing="0" cellpadding="0"><tr><td style="padding:3px;">'; $html .= '<input type="text" id="' . $this->id . '" name="' . $this->name . '" value="' . $this->default . '"'; if ($this->size) { $html .= ' size="' . $this->size . '"'; } $html .= ' class="' . $this->type . " " . $this->class . '"'; if ($this->tabindex >= 0) { $html .= ' tabindex="' . $this->tabindex . '"'; } if ($this->accesskey != "") { $html .= ' accesskey="' . $this->accesskey . '"'; } if ($this->filter != "") { $html .= " onkeypress=\"return " . $this->filter . "_filter.on_key_press(this, event);\" "; $html .= "onblur=\"" . $this->filter . "_filter.onblur(this);\" "; $html .= "onfocus=\"" . $this->filter . "_filter.onfocus(this);\" "; $html .= "onpaste=\"return " . $this->filter . "_filter.onpaste(this, event);\" "; } if ($this->disabled) { $html .= ' disabled'; } if (!empty($this->readonly)) { $html .= ' readonly="readonly"'; } $caption = isset($this->caption) ? $this->caption : str_replace(array(":", "*"), "", ucwords($label)); if (!empty($this->required)) { $html .= ' required="' . rawurlencode($this->default) . '" caption="' . $caption . '" '; } if (!empty($this->onclick)) { $html .= ' onclick="' . $this->onclick . '" '; } if (!empty($this->onchange)) { $html .= ' onchange="' . $this->onchange . '" '; } $html .= ' /></td>'; $html .= '<td width="14" style="padding:0;"> <table style="float:left;margin:0;"><tr><td style="padding:0;"> <a id="up-' . $this->id . ' " class="uptick" href="javascript:void(0);" style="float:left;"> <img style="margin:0;padding:0;font-size:0;line-height:0;float:left;" src="' . ICON_RELATIVE . 'quantity-up.png"' . XHTML_CLOSING . '> </a></td></tr><tr><td style="padding:0;"> <a id="down-' . $this->id . ' " class="downtick" href="javascript:void(0);" style="float:left;"> <img style="margin:0;padding:0;font-size:0;line-height:0;float:left;" src="' . ICON_RELATIVE . 'quantity-down.png"' . XHTML_CLOSING . '> </a></td></tr></table> </td></tr></table>'; // if this control is using an ajax action then lets set up a variable for the function call $ajaxaction = isset($this->ajaxaction) ? $this->ajaxaction . "(id, value);" : ''; // setup the JS to be used by this control. $script = "\n (function() {\n EXPONENT.onQuantityAdjusted = new YAHOO.util.CustomEvent('Quantity Adjusted');\n var upItems = YAHOO.util.Dom.getElementsByClassName('uptick');\n var downItems = YAHOO.util.Dom.getElementsByClassName('downtick');\n var values = YAHOO.util.Dom.getElementsByClassName('" . $this->type . "');\n YAHOO.util.Event.on(upItems, 'click', incrementQuantity);\n YAHOO.util.Event.on(downItems, 'click', decrementQuantity);\n YAHOO.util.Event.on(values, 'change', checkAjaxAction);\n \n function incrementQuantity(e) { \n YAHOO.util.Event.stopEvent(e);\n var el = YAHOO.util.Dom.getAncestorByTagName(YAHOO.util.Event.getTarget(e), 'a'); \n var qtyID = el.id.replace('up-', '').replace(' ', '');\n changeQuantity(qtyID, 1);\n };\n \n function decrementQuantity(e) { \n YAHOO.util.Event.stopEvent(e);\n var el = YAHOO.util.Dom.getAncestorByTagName(YAHOO.util.Event.getTarget(e), 'a'); \n var qtyID = el.id.replace('down-', '').replace(' ', '');\n changeQuantity(qtyID, -1);\n }\n \n function changeQuantity(qtyID, value) {\n var qtyBox = YAHOO.util.Dom.get(qtyID);\n var newval = parseInt(qtyBox.value) + parseInt(value);\n\t\t if (newval < 1) return 1;\n if (newval >= " . $this->min . " && newval <= " . $this->max . ") {\n qtyBox.value = newval;\n callAjaxAction(qtyBox.id, newval);\n }\n }\n\n function checkAjaxAction(e) {\n var qtyBox = YAHOO.util.Event.getTarget(e);\n if (qtyBox.value < " . $this->min . ") {\n qtyBox.value = " . $this->min . ";\n } else if (qtyBox.value > " . $this->max . ") {\n qtyBox.value = " . $this->max . ";\n }\n \n callAjaxAction(qtyBox.id, qtyBox.value);\n }\n\n function callAjaxAction(id, value) {\n " . $ajaxaction . "\n }\n })();\n "; $extfile = isset($this->loadjsfile) ? $this->loadjsfile : null; expJavascript::pushToFoot(array("unique" => 'qty', "yui2mods" => 'json,connection', "yui3mods" => null, "content" => $script, "src" => $extfile)); return $html; }
expLang::loadLang(); // Initialize the Database subsystem $db = expDatabase::connect(DB_USER, DB_PASS, DB_HOST . ':' . DB_PORT, DB_NAME); // Initialize the Modules subsystem & Create the list of available/active controllers $available_controllers = expModules::initializeControllers(); //original position //$available_controllers = array(); //$available_controllers = initializeControllers(); //foreach ($db->selectObjects('modstate',1) as $mod) { // if (!empty($mod->path)) $available_controllers[$mod->module] = $mod->path; //FIXME test location //} // Initialize the History (Flow) subsystem. $history = new expHistory(); //<--This is the new flow subsystem // Initialize the javascript subsystem if (expJavascript::inAjaxAction()) { set_error_handler('handleErrors'); } // Validate the session and populate the $user variable if ($db->havedb) { $user = new user(); expSession::validate(); } /* exdoc * The flag to use a mobile theme variation. */ if (!defined('MOBILE')) { if (defined('FORCE_MOBILE') && FORCE_MOBILE && $user->isAdmin()) { define('MOBILE', true); } else { define('MOBILE', expTheme::is_mobile());
function controlToHTML($name) { $datectl = new yuicalendarcontrol($this->default, '', false); $timectl = new datetimecontrol($this->default, false); $datetime = date('l, F d, o g:i a', $this->default); $html = '<span id="dtdisplay-' . $name . '">' . $datetime . '</span>'; if (!$this->display_only) { $html .= '<input id="pub-' . $name . '" type="checkbox" name="' . $name . '"'; $html .= $this->checked ? ' checked>' . $this->edit_text : '>' . $this->edit_text; $html .= '<div '; $html .= $this->checked ? 'style="display:none"' : ''; $html .= ' id="datetime-' . $name . '">'; $html .= $this->showdate ? $datectl->controlToHTML($name . "date") : ""; $html .= '<div class="yuitime">'; $html .= $this->showtime ? $timectl->controlToHTML($name . "time") : ""; $html .= '</div>'; $html .= '</div>'; } $script = "\n YUI(EXPONENT.YUI3_CONFIG).use('node', function(Y) {\n Y.on('click',function(e){\n var cal = Y.one('#datetime-" . $name . "');\n if (cal.getStyle('display')=='none') {\n cal.setStyle('display','block');\n } else {\n cal.setStyle('display','none');\n }\n },'#pub-" . $name . "');\n });\n "; expJavascript::pushToFoot(array("unique" => "newsmod-" . $name, "yui3mods" => "1", "content" => $script)); return $html; }
function controlToHTML($name, $label) { $assets_path = SCRIPT_RELATIVE . 'framework/core/subsystems/forms/controls/assets/'; $html = "\n <div id=\"cal-container-" . $name . "\" class=\"yui-skin-sam control calendar-control\">\n <label for=\"" . $name . "\" class=\"label\">" . $label . "</label><input size=26 type=\"text\" id=\"date-" . $name . "\" name=\"date-" . $name . "\" value=\"" . $this->default_date . "\" class=\"text datebox\" /> \n @ <input size=3 type=\"text\" id=\"time-h-" . $name . "\" name=\"time-h-" . $name . "\" value=\"" . $this->default_hour . "\" class=\"timebox\" maxlength=2/>\n : <input size=3 type=\"text\" id=\"time-m-" . $name . "\" name=\"time-m-" . $name . "\" value=\"" . $this->default_min . "\" class=\"timebox\" maxlength=2/>\n <select id=\"ampm-" . $name . "\" name=\"ampm-" . $name . "\">"; if ($this->default_ampm == "AM") { $html .= "<option selected>am</option><option>pm</option>"; } else { $html .= "<option>am</option><option selected>pm</option>"; } $html .= " \n </select>\n </div>\n <div style=\"clear:both\"></div>\n "; $script = "\n YUI(EXPONENT.YUI3_CONFIG).use('node','yui2-yahoo-dom-event','yui2-button','yui2-calendar','yui2-container','yui2-dragdrop','yui2-slider', function(Y) {\n var YAHOO=Y.YUI2;\n var Event = YAHOO.util.Event,\n Dom = YAHOO.util.Dom,\n dialog,\n calendar;\n\n // time input restriction to 12 hour\n Y.one('#time-h-" . $name . "').on('keyup',function(e){\n if (e.target.get('value')>12) {\n e.target.set('value',12);\n }\n \n if (e.target.get('value')<0) {\n e.target.set('value',0);\n }\n });\n \n // time input restriction to 12 hour\n Y.one('#time-m-" . $name . "').on('keyup',function(e){\n if (e.target.get('value')>59) {\n e.target.set('value',59);\n }\n \n if (e.target.get('value')<0) {\n e.target.set('value',0);\n }\n });\n \n\n Event.on(\"date-" . $name . "\", \"click\", function() {\n \n // Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.\n if (!dialog) {\n\n // Hide Calendar if we click anywhere in the document other than the calendar\n Event.on(document, \"click\", function(e) {\n var el = Event.getTarget(e);\n var dialogEl = dialog.element;\n // if (el != dialogEl && !Dom.isAncestor(dialogEl, el) && el != showBtn && !Dom.isAncestor(showBtn, el)) {\n // dialog.hide();\n // }\n });\n\n function resetHandler() {\n // Reset the current calendar page to the select date, or \n // to today if nothing is selected.\n var selDates = calendar.getSelectedDates();\n var resetDate;\n\n if (selDates.length > 0) {\n resetDate = selDates[0];\n } else {\n resetDate = calendar.today;\n }\n\n calendar.cfg.setProperty(\"pagedate\", resetDate);\n calendar.render();\n }\n\n function closeHandler() {\n dialog.hide();\n }\n\n var dialog = new YAHOO.widget.Dialog(\"container-" . $name . "\", {\n visible:false,\n context:[\"date-" . $name . "\", \"tl\", \"bl\"],\n buttons:[ {text:\"Reset\", handler: resetHandler, isDefault:true}, {text:\"Done\", handler: closeHandler}],\n draggable:false,\n width:310,\n close:true\n });\n dialog.setHeader('Pick A Date');\n dialog.setBody('<div id=\"cal-" . $name . "\" class=\"cal\"></div>');\n dialog.render(\"cal-container-" . $name . "\");\n YAHOO.util.Dom.addClass(\"container-" . $name . "\", 'calpop');\n \n dialog.showEvent.subscribe(function() {\n if (YAHOO.env.ua.ie) {\n // Since we're hiding the table using yui-overlay-hidden, we \n // want to let the dialog know that the content size has changed, when\n // shown\n dialog.fireEvent(\"changeContent\");\n }\n });\n }\n\n // Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.\n if (!calendar) {\n\n var calendar = new YAHOO.widget.Calendar(\"cal-" . $name . "\", {\n iframe:false, // Turn iframe off, since container has iframe support.\n hide_blank_weeks:true // Enable, to demonstrate how we handle changing height, using changeContent\n });\n calendar.render();\n \n calendar.selectEvent.subscribe(function() {\n if (calendar.getSelectedDates().length > 0) {\n\n var selDate = calendar.getSelectedDates()[0];\n\n // Pretty Date Output, using Calendar's Locale values: Friday, 8 February 2008\n var wStr = calendar.cfg.getProperty(\"WEEKDAYS_LONG\")[selDate.getDay()];\n var dStr = selDate.getDate();\n var mStr = calendar.cfg.getProperty(\"MONTHS_LONG\")[selDate.getMonth()];\n var yStr = selDate.getFullYear();\n\n Dom.get(\"date-" . $name . "\").value = wStr + \", \" + dStr + \" \" + mStr + \" \" + yStr;\n } else {\n Dom.get(\"date-" . $name . "\").value = \"\";\n }\n //dialog.hide();\n });\n\n calendar.renderEvent.subscribe(function() {\n // Tell Dialog it's contents have changed, which allows \n // container to redraw the underlay (for IE6/Safari2)\n dialog.fireEvent(\"changeContent\");\n });\n }\n\n var seldate = calendar.getSelectedDates();\n\n if (seldate.length > 0) {\n // Set the pagedate to show the selected date if it exists\n calendar.cfg.setProperty(\"pagedate\", seldate[0]);\n calendar.render();\n }\n\n dialog.show();\n });\n });\n "; // end JS // css expCSS::pushToHead(array("unique" => "cal0", "link" => YUI2_PATH . "button/assets/skins/sam/button.css")); expCSS::pushToHead(array("unique" => "cal1", "link" => YUI2_PATH . "calendar/assets/skins/sam/calendar.css")); expCSS::pushToHead(array("unique" => "cal2", "link" => $assets_path . "calendar/calendarcontrol.css")); expJavascript::pushToFoot(array("unique" => 'calpop' . $name, "yui3mods" => 1, "content" => $script)); return $html; }
function controlToHTML($name) { global $db; $contentCSS = ''; $cssabs = BASE . 'themes/' . DISPLAY_THEME . '/editors/ckeditor/ckeditor.css'; $css = PATH_RELATIVE . 'themes/' . DISPLAY_THEME . '/editors/ckeditor/ckeditor.css'; if (THEME_STYLE != "" && is_file(BASE . 'themes/' . DISPLAY_THEME . '/editors/ckeditor/ckeditor_' . THEME_STYLE . '.css')) { $cssabs = BASE . 'themes/' . DISPLAY_THEME . '/editors/ckeditor/ckeditor_' . THEME_STYLE . '.css'; $css = PATH_RELATIVE . 'themes/' . DISPLAY_THEME . '/editors/ckeditor/ckeditor_' . THEME_STYLE . '.css'; } if (is_file($cssabs)) { $contentCSS = "contentsCss : '" . $css . "',"; } if (empty($this->toolbar)) { $settings = $db->selectObject('htmleditor_ckeditor', 'active=1'); } elseif ($this->toolbar != 0) { $settings = $db->selectObject('htmleditor_ckeditor', 'id=' . $this->toolbar); } if (!empty($settings)) { $tb = stripSlashes($settings->data); $skin = $settings->skin; $scayt_on = $settings->scayt_on ? 'true' : 'false'; $paste_word = $settings->paste_word ? 'pasteFromWordPromptCleanup : true,' : 'forcePasteAsPlainText : true,'; $plugins = stripSlashes($settings->plugins); $stylesset = stripSlashes($settings->stylesset); $formattags = stripSlashes($settings->formattags); $fontnames = stripSlashes($settings->fontnames); } // set defaults if (empty($tb)) { $tb = "\n \t ['Source','-','Preview','-','Templates'],\n ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print','SpellChecker','Scayt'],\n ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],\n '/',\n ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],\n ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],\n ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],\n ['Link','Unlink','Anchor'],\n ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'],\n '/',\n ['Styles','Format','Font','FontSize'],\n ['TextColor','BGColor'],\n ['Maximize', 'ShowBlocks','-','About']"; } if (empty($skin)) { $skin = 'kama'; } if (empty($scayt_on)) { $scayt_on = 'true'; } if (empty($paste_word)) { $paste_word = 'forcePasteAsPlainText : true,'; } if (empty($plugins)) { $plugins = ''; } if (empty($stylesset)) { $stylesset = "'default'"; } if (empty($formattags)) { $formattags = "'p;h1;h2;h3;h4;h5;h6;pre;address;div'"; } if (empty($fontnames)) { $fontnames = "'Arial/Arial, Helvetica, sans-serif;' +\n 'Comic Sans MS/Comic Sans MS, cursive;' +\n 'Courier New/Courier New, Courier, monospace;' +\n 'Georgia/Georgia, serif;' +\n 'Lucida Sans Unicode/Lucida Sans Unicode, Lucida Grande, sans-serif;' +\n 'Tahoma/Tahoma, Geneva, sans-serif;' +\n 'Times New Roman/Times New Roman, Times, serif;' +\n 'Trebuchet MS/Trebuchet MS, Helvetica, sans-serif;' +\n 'Verdana/Verdana, Geneva, sans-serif'"; } $content = "\n\t YUI(EXPONENT.YUI3_CONFIG).use('yui', function(Y) {\n\t // Y.on('readyforcke', function () {\n \t \tEXPONENT.editor" . createValidId($name) . " = CKEDITOR.replace('" . createValidId($name) . "',\n \t\t\t\t{\n \t\t\t\t\tskin : '" . $skin . "',\n \t\t\t\t\ttoolbar : [" . $tb . "],\n \t\t\t\t\t" . $paste_word . "\n scayt_autoStartup : " . $scayt_on . ",\n filebrowserBrowseUrl : '" . makelink(array("controller" => "file", "action" => "picker", "ajax_action" => 1, "ck" => 1, "update" => "fck")) . "',\n filebrowserWindowWidth : '800',\n filebrowserWindowHeight : '600',\n \t\t\t\t\tfilebrowserLinkBrowseUrl : '" . PATH_RELATIVE . "external/editors/connector/CKeditor_link.php',\n filebrowserLinkWindowWidth : '320',\n filebrowserLinkWindowHeight : '600',\n \t\t\t\t\tfilebrowserImageBrowseLinkUrl : '" . PATH_RELATIVE . "external/editors/connector/CKeditor_link.php',\n \t\t\t\t\textraPlugins : 'stylesheetparser,autogrow,tableresize," . $plugins . "',\n \t\t\t\t\tautoGrow_maxHeight : 400,\n \t\t\t\t\tentities_additional : '',\n \t\t\t\t\t" . $contentCSS . "\n stylesSet : " . $stylesset . ",\n \t\t\t\t\tformat_tags : " . $formattags . ",\n font_names :\n " . $fontnames . ",\n \t\t\t\t\tuiColor : '#aaaaaa',\n \t\t\t\t\tbaseHref : '" . URL_FULL . "'\n });\n\n \t\t\t\tCKEDITOR.on( 'instanceReady', function( ev ) {\n \t\t\t\t\tvar blockTags = ['div','h1','h2','h3','h4','h5','h6','p','pre','ol','ul','li'];\n \t\t\t\t\tvar rules = {\n \t\t\t\t\t\tindent : false,\n \t\t\t\t\t\tbreakBeforeOpen : false,\n \t\t\t\t\t\tbreakAfterOpen : false,\n \t\t\t\t\t\tbreakBeforeClose : false,\n \t\t\t\t\t\tbreakAfterClose : true\n \t\t\t\t\t};\n \t\t\t\t\tfor (var i=0; i<blockTags.length; i++) {\n \t\t\t\t\t\tev.editor.dataProcessor.writer.setRules( blockTags[i], rules );\n \t\t\t\t\t}\n \t\t\t\t});\n\n // });\n\t });\n \n\t "; expJavascript::pushToFoot(array("unique" => "zzz-cke" . $name, "yui3mods" => "1", "content" => $content)); $html = "<script src=\"" . PATH_RELATIVE . "external/editors/ckeditor/ckeditor.js\"></script>"; $html .= "<textarea class=\"textarea\" id=\"" . createValidId($name) . "\" name=\"{$name}\""; $html .= " rows=\"" . $this->rows . "\" cols=\"" . $this->cols . "\""; if ($this->accesskey != "") { $html .= " accesskey=\"" . $this->accesskey . "\""; } if (!empty($this->class)) { $html .= " class=\"" . $this->class . "\""; } if ($this->tabindex >= 0) { $html .= " tabindex=\"" . $this->tabindex . "\""; } $html .= ">"; $html .= htmlentities($this->default, ENT_COMPAT, LANG_CHARSET); $html .= "</textarea>"; return $html; }
/** * Smarty {getchromemenu} function plugin * * Type: function<br> * Name: getchromemenu<br> * Purpose: display the chrome menu * * @param $params * @param \Smarty $smarty * @return bool */ function smarty_function_getchromemenu($params, &$smarty) { global $router, $user; $cloc = $smarty->getTemplateVars('__loc'); $module = $params['module']; $list = '<ul class="container-menu">'; $list .= '<li class="container-info">' . $module->action . ' / ' . str_replace($module->action . '_', '', $module->view) . '</li>'; if (!empty($params['rank']) && expPermissions::check('order_modules', $cloc)) { $uplink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 2, 'b' => $params['rank'] - 1)); $downlink = $router->makeLink(array('module' => 'containermodule', 'src' => $cloc->src, 'action' => 'order', 'a' => $params['rank'] - 1, 'b' => $params['rank'])); if ($params['rank'] != 1) { //dont show this up arrow if it's the first module in a container $list .= '<li><a href="' . $uplink . '" class="mod-up">' . gt("Move Module Up") . '</a></li>'; } if (!$params['last']) { //if this is the last module in a container don't show down arrow. $list .= '<li><a href="' . $downlink . '" class="mod-down">' . gt("Move Module Down") . '</a></li>'; } } $rerank = $params['rerank']; if ($rerank == 'false') { $rerank = 0; } else { $rerank = 1; } if ($user->isAdmin()) { $userlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'userperms', '_common' => 1)); $grouplink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'groupperms', '_common' => 1)); $list .= '<li><a href="' . $userlink . '" class="user">' . gt("User Permissions") . '</a></li>'; $list .= '<li><a href="' . $grouplink . '" class="group">' . gt("Group Permissions") . '</a></li>'; } if (!empty($module->id) && expPermissions::check('edit_module', $cloc) && $module->permissions['administrate'] == 1) { $editlink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'edit', 'src' => $module->info['source'])); $list .= '<li><a href="' . $editlink . '" class="config-view">' . gt("Configure Action") . " & " . gt("View") . '</a></li>'; } if ($module->permissions['configure'] == 1) { if (expModules::controllerExists($module->info['class'])) { $configlink = $router->makeLink(array('module' => expModules::getControllerName($module->info['class']), 'src' => $module->info['source'], 'action' => 'configure', 'hcview' => $module->view)); $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>'; } elseif ($module->info['hasConfig']) { $configlink = $router->makeLink(array('module' => $module->info['class'], 'src' => $module->info['source'], 'action' => 'configure', '_common' => 1)); $list .= '<li><a href="' . $configlink . '" class="config-mod">' . gt("Configure Settings") . '</a></li>'; } } if (!empty($module->id) && expPermissions::check('delete_module', $cloc)) { $deletelink = $router->makeLink(array('module' => 'containermodule', 'id' => $module->id, 'action' => 'delete', 'rerank' => $rerank)); $list .= '<li><a href="' . $deletelink . '" class="delete" onclick="alert(\'' . gt("This content is being sent to the Recycle Bin to be recovered later if you wish.") . '\')">' . gt("Remove Module") . '</a></li>'; } if (HELP_ACTIVE) { $helplink = help::makeHelpLink(expModules::getControllerName($module->info['class'])); $list .= '<li><a href="' . $helplink . '" class="helplink" target="_blank">' . gt("Get Help") . '</a></li>'; } $list .= '</ul>'; expCSS::pushToHead(array("unique" => "container-chrome", "link" => PATH_RELATIVE . "framework/modules/container/assets/css/admin-container.css")); expJavascript::pushToFoot(array("unique" => 'container-chrome', "yui3mods" => 'node', "src" => PATH_RELATIVE . "framework/core/assets/js/exp-container.js")); echo $list; }
function updateQuantity() { global $order; if (expJavascript::inAjaxAction()) { $id = str_replace('quantity-', '', $this->params['id']); $item = new orderitem($id); if (!empty($item->id)) { //$newqty = $item->product->updateQuantity($this->params['value']); $newqty = $item->product->updateQuantity($this->params['value']); if ($newqty > $item->product->quantity) { if ($item->product->availability_type == 1) { $diff = $item->product->quantity <= 0 ? $newqty : $newqty - $item->product->quantity; $updates->message = 'Only ' . $item->product->quantity . ' ' . $item->products_name . ' are currently in stock. Shipping may be delayed on the other ' . $diff; } elseif ($item->product->availability_type == 2) { $updates->message = $item->products_name . ' only has ' . $item->product->quantity . ' on hand. You can not add any more than that to your cart.'; $updates->cart_total = '$' . number_format($order->getCartTotal(), 2); $updates->item_total = '$' . number_format($item->getTotal(), 2); $updates->item_id = $id; $updates->quantity = $item->product->quantity; echo json_encode($updates); return true; } } $item->quantity = $newqty; $item->save(); $order->refresh(); $updates->cart_total = '$' . number_format($order->getCartTotal(), 2); $updates->item_total = '$' . number_format($item->getTotal(), 2); $updates->item_id = $id; $updates->quantity = $item->quantity; echo json_encode($updates); } } else { if (!is_numeric($this->params['quantity'])) { flash('error', gt('Please enter a valid quantity.')); expHistory::back(); } $item = new orderitem($this->params['id']); if (!empty($item->id)) { //$newqty = $item->product->updateQuantity($this->params['quantity']); $newqty = $this->params['quantity']; //$oiObj = new orderitem(); //$oi = $oiObj->find('all','product_id='.$item->product->id); $qCheck = 0; //$item->product->quantity; //if (!empty($oi)) //{ foreach ($order->orderitem as $orderItem) { if ($orderItem->product_id == $item->product_id) { $qCheck += $orderItem->quantity; } } //eDebug("Done",true); //} /*eDebug($item->quantity); eDebug($item->product->quantity); eDebug($qCheck); eDebug($newqty,true); */ //check minimum quantity $qtyMessage = ''; if ($newqty < $item->product->minimum_order_quantity) { $qtyMessage = $item->product->title . ' has a minimum order quantity of ' . $item->product->minimum_order_quantity . '. The quantity has been adjusted and added to your cart.<br/><br/>'; $newqty = $item->product->minimum_order_quantity; } $itemMessage = ''; if ($qCheck + ($newqty - $item->quantity) > $item->product->quantity) { if ($item->product->availability_type == 1) { $diff = $item->product->quantity <= 0 ? $newqty : $newqty - $item->product->quantity; $itemMessage = gt('Only') . ' ' . $item->product->quantity . ' ' . $item->products_name . ' ' . gt('are currently in stock. Shipping may be delayed on the other') . ' ' . $diff . "<br/><br/>"; //$updates->message = 'Only '.$item->product->quantity.' '.$item->products_name.' are currently in stock. Shipping may be delayed on the other '.$diff; } elseif ($item->product->availability_type == 2) { flash('error', $item->products_name . ' ' . gt('only has') . ' ' . $item->product->quantity . ' ' . gt('on hand. You can not add any more than that to your cart.')); /*$updates->message = $item->products_name.' only has '.$item->product->quantity.' on hand. You can not add any more to your cart.'; $updates->cart_total = '$'.number_format($order->getCartTotal(), 2); $updates->item_total = '$'.number_format($item->quantity*$item->products_price, 2); $updates->item_id = $id; $updates->quantity = $item->product->quantity; echo json_encode($updates); */ expHistory::back(); } } else { if ($newqty <= 0) { $item->delete(); flash('message', $item->products_name . ' ' . gt('has been removed from your cart.')); expHistory::back(); } } $item->quantity = $newqty; $item->save(); $order->refresh(); /*$updates->cart_total = '$'.number_format($order->getCartTotal(), 2); $updates->item_total = '$'.number_format($item->quantity*$item->products_price, 2); $updates->item_id = $id; $updates->quantity = $item->quantity; */ //echo json_encode($updates); } //redirect_to(array('controller'=>'cart','action'=>'show')); flash('message', $qtyMessage . $itemMessage . $item->products_name . ' ' . gt('quantity has been updated.')); expHistory::back(); } }
public static function panel($params) { $content = "<div class=\"pnlmsg\">" . htmlentities($params['content']) . "</div>"; $id = "exppanel" . $params['id']; $width = !empty($params['width']) ? $params['width'] : "300px"; $type = !empty($params['type']) ? $params['type'] : "info"; $dialog = !empty($params['dialog']) ? explode(":", $params['dialog']) : ""; $header = !empty($params['header']) ? $params['header'] : " "; $renderto = !empty($params['renderto']) ? $params['renderto'] : 'document.body'; $on = !empty($params['on']) ? $params['on'] : 'load'; $onnogo = !empty($params['onnogo']) ? $params['onnogo'] : ''; $onyesgo = !empty($params['onyesgo']) ? $params['onyesgo'] : ''; $trigger = !empty($params['trigger']) ? '"' . $params['trigger'] . '"' : 'selfpop'; $zindex = !empty($params['zindex']) ? $params['zindex'] : "50"; //$hide = !empty($params['hide']) ? $params['hide'] : "hide"; $fixedcenter = !empty($params['fixedcenter']) ? $params['fixedcenter'] : "true"; $fade = !empty($params['fade']) ? $params['fade'] : null; $modal = !empty($params['modal']) ? $params['modal'] : "true"; $draggable = empty($params['draggable']) ? "false" : $params['draggable']; $constraintoviewport = !empty($params['constraintoviewport']) ? $params['constraintoviewport'] : "true"; $fade = !empty($params['fade']) ? "effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:" . $params['fade'] . "}," : ""; $close = !empty($params['close']) ? $params['close'] : "true"; $script = ""; if (is_array($dialog)) { $script .= "\n var handleYes = function(e,o) {\n this.hide();"; if ($onyesgo != "") { $script .= "document.location = '" . trim($onyesgo) . "'"; } $script .= "};\n var handleNo = function(e,o) {\n this.hide();"; if ($onyesgo != "") { $script .= "var textlink = '" . trim($onnogo) . "';"; $script .= 'document.location = textlink.replace(/&/g,"&");'; } $script .= "};"; $script .= "var " . $id . " = new YAHOO.widget.SimpleDialog('" . $id . "', { "; $script .= "buttons: [ { text:'" . $dialog[0] . "', handler:handleYes, isDefault:true },{ text:'" . $dialog[1] . "', handler:handleNo } ],"; //$script .= "text: 'Do you want to continue?',"; } else { $script .= "var " . $id . " = new YAHOO.widget.Panel('" . $id . "', { "; } $script .= "fixedcenter:" . $fixedcenter . ",\n draggable:" . $draggable . ",\n modal:" . $modal . ",\n class:'exp-" . $type . " " . $hide . "',\n zIndex:" . $zindex . "," . $fade . "width:'" . $width . "',\n visible:false,\n constraintoviewport:" . $constraintoviewport . ",\n close:" . $close . " } );"; $script .= $id . ".setHeader('" . $header . "');"; $script .= "var pnlcontent = " . $content . ";"; $script .= $id . ".setBody('<span class=\"type-icon\"></span>'+pnlcontent);"; $script .= $id . ".setFooter('" . $footer . "</div>');"; $script .= $id . ".render(" . $renderto . ");"; $script .= "YAHOO.util.Dom.addClass('" . $id . "','exp-" . $type . "');"; if ($hide == false) { $script .= "YAHOO.util.Dom.addClass('" . $id . "','" . $hide . "');"; } switch ($trigger) { case 'selfpop': $script .= "YAHOO.util.Event.onDOMReady(" . $id . ".show, " . $id . ", true);"; break; default: $script .= "YAHOO.util.Event.on(" . $trigger . ", '" . $on . "', function(e,o){\n YAHOO.util.Event.stopEvent(e);\n o.show();\n }, " . $id . ", true);"; break; } expJavascript::pushToFoot(array("unique" => 'pop-' . $params['name'], "yui2mods" => 'animation,container', "yui3mods" => null, "content" => $script, "src" => "")); }