Beispiel #1
0
/**
 * Smarty {form} block plugin
 *
 * Type:     block<br>
 * Name:     form<br>
 * Purpose:  Set up a form block
 * 
 * @param $params
 * @param $content
 * @param \Smarty $smarty
 * @param $repeat
 */
function smarty_block_form($params, $content, &$smarty, &$repeat)
{
    if (empty($content)) {
        $name = isset($params['name']) ? $params['name'] : 'form';
        $id = empty($params['id']) ? $name : $params['id'];
        $module = isset($params['module']) ? $params['module'] : $smarty->getTemplateVars('__loc')->mod;
        $controller = isset($params['controller']) ? $params['controller'] : $smarty->getTemplateVars('__loc')->con;
        $method = isset($params['method']) ? $params['method'] : "POST";
        $enctype = isset($params['enctype']) ? $params['enctype'] : 'multipart/form-data';
        echo "<!-- Form Object 'form' -->\r\n";
        echo '<script type="text/javascript" src="' . PATH_RELATIVE . 'framework/core/subsystems/forms/js/inputfilters.js.php"></script>' . "\r\n";
        // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/subsystems/forms/controls/listbuildercontrol.js"></script>'."\r\n";
        // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/subsystems/forms/js/required.js"></script>'."\r\n";
        // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/calendar.js"></script>'."\r\n";
        // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/lang/calendar-en.js"></script>'."\r\n";
        // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'external/jscalendar/calendar-setup.js"></script>'."\r\n";
        // echo '<script type="text/javascript" src="'.PATH_RELATIVE.'js/PopupDateTimeControl.js"></script>'."\r\n";
        expCSS::pushToHead(array("corecss" => "forms"));
        echo '<form id="' . $id . '" name="' . $name . '" class="' . $params['class'] . '" method="' . $method . '" action="' . URL_FULL . 'index.php" enctype="' . $enctype . '">' . "\r\n";
        if (!empty($controller)) {
            echo '<input type="hidden" name="controller" id="controller" value="' . $controller . '" />' . "\r\n";
        } else {
            echo '<input type="hidden" name="module" id="module" value="' . $module . '" />' . "\r\n";
        }
        echo '<input type="hidden" name="src" id="src" value="' . $smarty->getTemplateVars('__loc')->src . '" />' . "\r\n";
        echo '<input type="hidden" name="int" id="int" value="' . $smarty->getTemplateVars('__loc')->int . '" />' . "\r\n";
        if (isset($params['action'])) {
            echo '<input type="hidden" name="action" id="action" value="' . $params['action'] . '" />' . "\r\n";
        }
        //echo the innards
    } else {
        echo $content;
        echo '</form>';
    }
}
 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+'&amp;w=24&amp;h=24&amp;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;
 }
Beispiel #3
0
/**
 * Smarty {css} block plugin
 *
 * Type:     block<br>
 * Name:     css<br>
 * Purpose:  Set up a css block
 *
 * @param $params
 * @param $content
 * @param \Smarty $smarty
 * @param $repeat
 */
function smarty_block_css($params, $content, &$smarty, &$repeat)
{
    if ($content) {
        if (empty($params['unique'])) {
            die("<strong style='color:red'>" . gt("The 'unique' parameter is required for the {css} plugin.") . "</strong>");
        }
        expCSS::pushToHead(array("unique" => $params['unique'], "css" => $content, "link" => $params['link'], "corecss" => $params['corecss']));
    }
}
 public function page_not_found()
 {
     global $router;
     $params = $router->params;
     unset($params['controller']);
     unset($params['action']);
     $terms = empty($params[0]) ? '' : $params[0];
     expCSS::pushToHead(array("unique" => "search-results", "link" => $this->asset_path . "css/results.css"));
     $search = new search();
     $page = new expPaginator(array('model' => 'search', 'controller' => $this->params['controller'], 'action' => $this->params['action'], 'records' => $search->getSearchResults(implode(' ', $params)), 'order' => 'score', 'dir' => 'DESC'));
     assign_to_template(array('page' => $page, 'terms' => $terms));
 }
 public function search()
 {
     // include CSS for results
     // auto-include the CSS for pagination links
     expCSS::pushToHead(array("unique" => "search-results", "link" => $this->asset_path . "css/results.css"));
     $terms = $this->params['search_string'];
     // If magic quotes is on and the user uses modifiers like " (quotes) they get escaped. We don't want that in this case.
     if (get_magic_quotes_gpc()) {
         $terms = stripslashes($terms);
     }
     $terms = htmlspecialchars($terms);
     $search = new search();
     $page = new expPaginator(array('controller' => $this->params['controller'], 'action' => $this->params['action'], 'records' => $search->getSearchResults($terms), 'order' => 'score', 'dir' => 'DESC'));
     assign_to_template(array('page' => $page, 'terms' => $terms));
 }
 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;
 }
/**
 * Smarty {permissions} block plugin
 *
 * Type:     block<br>
 * Name:     permissions<br>
 * Purpose:  Set up a permissions block
 *
 * @param $params
 * @param $content
 * @param \Smarty $smarty
 * @param $repeat
 * @return string
 */
function smarty_block_permissions($params, $content, &$smarty, &$repeat)
{
    if ($content) {
        global $user, $css_core;
        if (empty($_GET['recymod'])) {
            $uilevel = 99;
            if (expSession::exists("uilevel")) {
                $uilevel = expSession::get("uilevel");
            }
            if (empty($css_core['admin-global'])) {
                expCSS::pushToHead(array("corecss" => "admin-global"));
            }
            if (isset($uilevel) && $uilevel == UILEVEL_PREVIEW || !$user->isLoggedIn()) {
                $cntnt = "";
            } else {
                $cntnt = isset($uilevel) && $uilevel == UILEVEL_PREVIEW || !$user->isLoggedIn() ? "" : $content;
            }
            return $cntnt;
        }
    }
}
Beispiel #8
0
/**
 * Smarty {help} function plugin
 *
 * Type:     function<br>
 * Name:     help<br>
 * Purpose:  create a help link
 *
 * @param         $params
 * @param \Smarty $smarty
 * @return bool
 */
function smarty_function_help($params, &$smarty)
{
    if (HELP_ACTIVE) {
        if (empty($params['module'])) {
            $module = $smarty->getTemplateVars('__loc')->mod;
        } else {
            $module = $params['module'];
        }
        // figure out the params
        $text = empty($params['text']) ? '&nbsp' : $params['text'];
        $title = empty($params['title']) ? gt('Get Help') . ' for ' . $params['module'] : $params['title'];
        $class = 'helplink';
        $class .= empty($params['class']) ? '' : $params['class'];
        $link = help::makeHelpLink($module);
        if (!empty($params['page'])) {
            echo '<a class="' . $class . '" ' . $title . ' href="' . HELP_URL . $params['page'] . '" target="_blank">' . $text . '</a>';
        } else {
            echo '<a class="' . $class . '" ' . $title . ' href="' . $link . '" target="_blank">' . $text . '</a>';
        }
        expCSS::pushToHead(array("csscore" => "admin-global"));
    }
}
 function controlToHTML($name)
 {
     if ($this->submit . $this->reset . $this->cancel == "") {
         return "";
     }
     if (empty($this->id)) {
         $this->id = $name;
     }
     $html = "";
     if ($this->submit != "") {
         $html .= '<button type="submit" id="' . $this->id . 'Submit" class="submit button awesome ' . BTN_SIZE . ' ' . BTN_COLOR;
         if ($this->disabled) {
             $html .= " disabled";
         }
         $html .= '" type="submit" value="' . $this->submit . '"';
         if ($this->disabled) {
             $html .= " disabled";
         }
         $html .= ' onclick="if (checkRequired(this.form)';
         if (isset($this->onclick)) {
             $html .= ' ' . $this->onclick;
         }
         $html .= ') ';
         if ($this->validateJS != "") {
             $html .= '{ if (' . $this->validateJS . ') { return true; } else { return false; } }';
         } else {
             $html .= '{ return true; }';
         }
         $html .= ' else { return false; }"';
         $html .= ' />';
         $html .= $this->submit;
         $html .= ' </button>';
     }
     //if ($this->reset != "") $html .= '<input class="button" type="reset" value="' . $this->reset . '"' . ($this->disabled?" disabled":"") . ' />';
     if ($this->cancel != "") {
         if ($this->returntype == "") {
             $html .= '<button type="cancel" class="cancel button awesome ' . BTN_SIZE . ' ' . BTN_COLOR . '" onclick="document.location.href=\'' . expHistory::getLastNotEditable() . '\'; return false;"';
         } else {
             $html .= '<button type="cancel" class="cancel button awesome ' . BTN_SIZE . ' ' . BTN_COLOR . '" onclick="document.location.href=\'' . expHistory::getLast($this->returntype) . '\'; return false;"';
         }
         $html .= '>';
         $html .= $this->cancel;
         $html .= '</button>';
     }
     expCSS::pushToHead(array("unique" => "button", "corecss" => "button"));
     return $html;
 }
Beispiel #10
0
 /**
  * expPaginator Constructor
  *
  * This is the main entry point for using the expPaginator.  See example above.
  *
  * @param array $params Use this to set any of the class variables. Ones not passed will be set to a default.
  * @return \expPaginator
  */
 public function __construct($params = array())
 {
     global $router, $db;
     $this->where = empty($params['where']) ? null : $params['where'];
     $this->records = empty($params['records']) ? array() : $params['records'];
     $this->limit = empty($params['limit']) ? 10 : $params['limit'];
     $this->page = empty($_REQUEST['page']) ? 1 : intval($_REQUEST['page']);
     $this->action = empty($params['action']) ? '' : $params['action'];
     $this->controller = empty($params['controller']) ? '' : $params['controller'];
     $this->sql = empty($params['sql']) ? '' : $params['sql'];
     $this->count_sql = empty($params['count_sql']) ? '' : $params['count_sql'];
     $this->order = empty($params['order']) ? 'id' : $params['order'];
     $this->dir = empty($params['dir']) ? 'ASC' : $params['dir'];
     $this->src = empty($params['src']) ? null : $params['src'];
     // if a view was passed we'll use it.
     if (isset($params['view'])) {
         $this->view = $params['view'];
     }
     // setup the model if one was passed.
     if (isset($params['model'])) {
         $this->model = $params['model'];
         $class = new $this->model(null, false, false);
     }
     // auto-include the CSS for pagination links
     expCSS::pushToHead(array("unique" => "pagination", "link" => PATH_RELATIVE . "framework/core/assets/css/pagination.css"));
     $this->start = $this->page * $this->limit - $this->limit;
     //setup the columns and default ordering of records
     if (isset($params['columns'])) {
         $this->columns = array();
         foreach ($params['columns'] as $key => $col) {
             $colparse[$key] = explode('|', $col);
             $column = array($key => $colparse[$key][0]);
             $this->columns = array_merge($this->columns, $column);
             if (!empty($colparse[$key][1])) {
                 $params = explode(',', $colparse[$key][1]);
                 foreach ($params as $paramval) {
                     $prm = explode('=', $paramval);
                     $this->linkables[$key][$prm[0]] = $prm[1];
                 }
             }
         }
     }
     // if we are in an action, see if the action if for this controller/action..if so pull the order
     // and order direction from the request params...this is how the params are passed via the column
     // headers.
     $this->order_direction = $this->dir;
     if (expTheme::inAction()) {
         //FIXME: module/controller glue code
         $mod = !empty($_REQUEST['controller']) ? $_REQUEST['controller'] : $_REQUEST['module'];
         //		    if ($this->controller == $mod && $this->action == $_REQUEST['action']) {
         $this->order = isset($_REQUEST['order']) ? $_REQUEST['order'] : $this->order;
         $this->order_direction = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : $this->dir;
         //			}
     }
     // figure out how many records we're dealing with & grab the records
     //if (!empty($this->records)) { //from Merge <~~ this doesn't work. Could be empty, but still need to hit.
     if (isset($params['records'])) {
         // if we pass $params['records'], we WANT to hit this
         // sort, count and slice the records that were passed in to us
         usort($this->records, array('expPaginator', strtolower($this->order_direction)));
         $this->total_records = count($this->records);
         if ($this->start > $this->total_records) {
             $this->start = $this->total_records - $this->limit;
         }
         $this->records = array_slice($this->records, $this->start, $this->limit);
     } elseif (!empty($class)) {
         //where clause     //FJD: was $this->class, but wasn't working...
         $this->total_records = $class->find('count', $this->where);
         $this->records = $class->find('all', $this->where, $this->order . ' ' . $this->order_direction, $this->limit, $this->start);
     } elseif (!empty($this->where)) {
         //from Merge....where clause
         $this->total_records = $class->find('count', $this->where);
         if ($this->start > $this->total_records) {
             $this->start = $this->total_records - $this->limit;
         }
         $this->records = $class->find('all', $this->where, $this->order . ' ' . $this->order_direction, $this->limit, $this->start);
     } else {
         //sql clause
         //$records = $db->selectObjectsBySql($this->sql);
         //$this->total_records = count($records);
         //this is MUCH faster if you supply a proper count_sql param using a COUNT() function; if not,
         //we'll run the standard sql and do a queryRows with it
         //$this->total_records = $this->count_sql == '' ? $db->queryRows($this->sql) : $db->selectValueBySql($this->count_sql); //From Merge
         $this->total_records = $db->countObjectsBySql($this->count_sql);
         //$db->queryRows($this->sql); //From most current Trunk
         if ($this->start > $this->total_records) {
             $this->start = $this->total_records - $this->limit;
         }
         if (!empty($this->order)) {
             $this->sql .= ' ORDER BY ' . $this->order . ' ' . $this->order_direction;
         }
         if (!empty($this->limit)) {
             $this->sql .= ' LIMIT ' . $this->start . ',' . $this->limit;
         }
         $this->records = array();
         if (isset($this->model) || isset($params['model_field'])) {
             foreach ($db->selectObjectsBySql($this->sql) as $record) {
                 $classname = isset($params['model_field']) ? $record->{$params}['model_field'] : $this->model;
                 //$this->records[] = new $classname($record->id, true, true); //From current trunk // added false, true, as we shouldn't need associated items here, but do need attached. FJD.
                 $this->records[] = new $classname($record->id, false, true);
                 //From Merge //added false, true, as we shouldn't need associated items here, but do need attached. FJD.
             }
         } else {
             $this->records = $db->selectObjectsBySql($this->sql);
         }
     }
     if (!isset($params['records'])) {
         $this->runCallback();
     }
     // isset($params['records']) added to correct search for products.
     //$this->runCallback();
     //eDebug($this->records);
     // get the number of the last record we are showing...this is used in the page links.
     // i.e.  "showing 10-19 of 57"...$this->last would be the 19 in that string
     if ($this->total_records > 0) {
         $this->firstrecord = $this->start + 1;
         $this->lastrecord = $this->total_records < $this->limit ? $this->start + $this->total_records : $this->start + $this->limit;
         if ($this->lastrecord > $this->total_records) {
             $this->lastrecord = $this->total_records;
         }
     } else {
         $this->firstrecord = 0;
         $this->lastrecord = 0;
     }
     // get the page parameters from the router to build the links
     //$page_params = $router->params; //from Current Trunk
     $page_params = $this->cleanParams($router->params);
     //From Merge
     //if (empty($page_params['module'])) $page_params['module'] = $this->controller;
     //if (empty($page_params['action'])) $page_params['action'] = $this->action;
     //if (empty($page_params['src']) && isset($params['src'])) $page_params['src'] = $params['src'];
     if (!empty($this->controller)) {
         unset($page_params['module']);
         $page_params['controller'] = str_replace("Controller", "", $this->controller);
     }
     if (!empty($this->action)) {
         $page_params['action'] = $this->action;
     }
     if (!empty($this->src)) {
         $page_params['src'] = $this->src;
     }
     if (isset($page_params['section'])) {
         unset($page_params['section']);
     }
     if (!empty($this->view)) {
         $page_params['view'] = $this->view;
     }
     //build out a couple links we can use in the views.
     $this->pagelink = $router->makeLink($page_params, null, null, true);
     // if don't have enough records for more than one page then we're done.
     //if ($this->total_records <= $this->limit) return true;
     $this->total_pages = $this->limit > 0 ? ceil($this->total_records / $this->limit) : 0;
     if ($this->page > $this->total_pages) {
         $this->page = $this->total_pages;
     }
     //setup the pages for the links
     if ($this->total_pages > $this->pages_to_show) {
         $this->first_pagelink = max(1, floor($this->page - $this->pages_to_show / 2));
         $this->last_pagelink = $this->first_pagelink + $this->pages_to_show - 1;
         if ($this->last_pagelink > $this->total_pages) {
             $this->first_pagelink = max(1, $this->total_pages - $this->pages_to_show);
             $this->last_pagelink = $this->total_pages;
         }
     } else {
         $this->first_pagelink = 1;
         $this->last_pagelink = $this->total_pages;
     }
     // setup the previous link
     if ($this->page > 1) {
         $page_params['page'] = $this->page - 1;
         $this->previous_page = $router->makeLink($page_params, null, null, true);
     }
     // setup the next link
     if ($this->page < $this->total_pages) {
         $page_params['page'] = $this->page + 1;
         $this->next_page = $router->makeLink($page_params, null, null, true);
     }
     // setup the previous 10 link
     if ($this->page > $this->pages_to_show) {
         $page_params['page'] = $this->first_pagelink - 1;
         $this->previous_shift = $router->makeLink($page_params, null, null, true);
         $page_params['page'] = 1;
         $this->firstpage = $router->makeLink($page_params, null, null, true);
     }
     // setup the next 10 link
     if ($this->page < $this->total_pages - $this->pages_to_show) {
         $page_params['page'] = $this->last_pagelink + 1;
         $this->next_shift = $router->makeLink($page_params, null, null, true);
         $page_params['page'] = $this->total_pages;
         $this->lastpage = $router->makeLink($page_params, null, null, true);
     }
     // setup the links to the pages being displayed.
     for ($i = $this->first_pagelink; $i <= $this->last_pagelink; $i++) {
         $page_params['page'] = $i;
         $this->pages[$i] = $router->makeLink($page_params, null, null, true);
     }
     $links_template = get_common_template('pagination_links', null, 'common');
     $links_template->assign('page', $this);
     $this->links = $links_template->render();
     $this->makeHeaderCols($page_params);
     $sortparams = array_merge($page_params, $router->params);
     //From Merge ****
     if (isset($router->params['page'])) {
         $sortparams['page'] = $router->params['page'];
     } else {
         unset($sortparams['page']);
     }
     //End From Merge ****
     $this->makeSortDropdown($sortparams);
     $table_template = get_common_template('pagination_table', null, 'common');
     $table_template->assign('page', $this);
     $this->table = $table_template->render();
 }
Beispiel #11
0
 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();
 }
Beispiel #12
0
/**
 * 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;
}
/**
 * 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));
        }
    }
}
Beispiel #14
0
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
$f = null;
if (isset($_GET['id'])) {
    $f = $db->selectObject('formbuilder_form', 'id=' . intval($_GET['id']));
}
if ($f) {
    $floc = unserialize($f->location_data);
    if (expPermissions::check('editform', unserialize($f->location_data))) {
        expCSS::pushToHead(array("unique" => "forms", "corecss" => "forms"));
        $form = formbuilder_form::form($f);
        $form->location($loc);
        $form->meta('action', 'save_form');
        $form->meta('m', $floc->mod);
        $form->meta('s', $floc->src);
        $form->meta('i', $floc->int);
        $template = new template('formbuilder', '_edit_form');
        $template->assign('form_html', $form->toHTML($f->id));
        $template->output();
    } else {
        echo SITE_403_HTML;
    }
} else {
    echo SITE_404_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") . " &amp; " . 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;
}
Beispiel #16
0
 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;
 }