Beispiel #1
0
 public static function buildJSONTree($lang = 'en-US')
 {
     $u = Qdmvc_Helper::getCurrentUser();
     $debug_mode = isset($_GET['debugmode']) ? $_GET['debugmode'] : 0;
     $re = array();
     foreach (static::getIndex() as $key => $config) {
         if (!$u->hasPermission(null, null, $key)) {
             continue;
         }
         //quocdunginfo, performance
         $tmp = array();
         $active = isset($config['Active']) ? $config['Active'] : true;
         $p_id = isset($config['ParentId']) ? $config['ParentId'] : -1;
         if (!$active) {
             continue;
         }
         $text = isset($config['Caption']) && isset($config['Caption'][$lang]) ? $config['Caption'][$lang] : $key;
         $tmp['title'] = $debug_mode == 1 ? $key : $text;
         $tmp['key'] = $key;
         $tmp['parentid'] = $p_id;
         if (!Qdmvc_Helper::isNullOrEmpty($config['PageType']) && $config['PageType'] == 'Folder') {
             $tmp['title'] = '[' . $tmp['title'] . ']';
             $tmp['value'] = '';
             $tmp['folder'] = true;
         } else {
             $tmp['value'] = Qdmvc_Helper::getCompactPageListLink($key);
         }
         array_push($re, $tmp);
     }
     return json_encode($re);
 }
    public function render()
    {
        $this->style();
        parent::render();
        $this->onReadyHook();
        ?>
        <div id="qdmvcRootDiv" style="display: none; width: inherit; height: inherit">
            <style>
                #wpbody-content {
                    overflow-y: hidden !important;
                }
            </style>
            <script>
                MYAPP = {};
                MYAPP.openInNewTab = function (url) {
                    if (window == window.parent) {
                        window.open(url, '_blank');
                        return;
                    }
                    window.parent.MYAPP.openInNewTab(url);
                };
                MYAPP.TreeUnflatten = function( array, parent, tree ){

                    tree = typeof tree !== 'undefined' ? tree : [];
                    parent = typeof parent !== 'undefined' ? parent : { key: -1 };

                    var children = _.filter( array, function(child){ return child.parentid == parent.key; });

                    if( !_.isEmpty( children )  ){
                        if( parent.key == -1 ){
                            tree = children;
                        }else{
                            parent['children'] = children
                        }
                        _.each( children, function( child ){ MYAPP.TreeUnflatten( array, child ) } );
                    }

                    return tree;
                };

                (function ($) {
                    $(document).ready(function () {
                        //height = $(window).height()-3;

                        $("#splitter").jqxSplitter({width: '100%', height: '100%', panels: [{size: 230}]});
                        $("#splitter2").jqxSplitter({orientation: 'horizontal', width: '100%', height: '100%', panels: [{size: '90%'}]});

                        // Create jqxTree
                        Array.prototype.insert = function (index, item) {
                            this.splice(index, 0, item);
                        };

                        var data = <?php 
        echo Qdmvc_Page_Index::buildJSONTree($this->data['language']);
        ?>
;
                        data = MYAPP.TreeUnflatten(data);
                        var autoexpand = false;
                        <?php 
        if ($this->data['setup']->autoexpandmenu == true) {
            ?>
                        autoexpand = true;
                        <?php 
        }
        ?>

                        $("#jqxTree").fancytree({
                            extensions: ["filter"],
                            quicksearch: true,
                            checkbox: false,
                            source: data,
                            autoScroll: true,
                            filter: {
                                autoApply: true,  // Re-apply last filter if lazy data is loaded
                                counter: true,  // Show a badge with number of matching child nodes near parent icons
                                fuzzy: false,  // Match single characters in order, e.g. 'fb' will match 'FooBar'
                                hideExpandedCounter: true,  // Hide counter badge, when parent is expanded
                                highlight: true,  // Highlight matches by wrapping inside <mark> tags
                                mode: "hide"  // Grayout unmatched nodes (pass "hide" to remove unmatched node instead)
                            },
                            click: function(event, data) {
                                var node = data.node;
                                //add tab
                                var args = event.args;

                                var label = node.title;
                                var url = node.data.value;
                                if (url == '') {
                                    return;//ignore folder
                                }

                                //check existed
                                var totaltab = $('#jqxTabs').jqxTabs('length');
                                var i = 0;
                                for (i = 0; i < totaltab; i++) {
                                    var title = $('#jqxTabs').jqxTabs('getTitleAt', i);
                                    if (title == label) {
                                        $('#jqxTabs').jqxTabs('select', i);//switch to tab
                                        return;//ignore duplicate tab
                                    }
                                }

                                $('#jqxTabs').jqxTabs('addLast', label, '<iframe id="pagepart" src="' + url + '" width="100%" height="99%" scrolling="yes" frameborder="0"><p>Your browser does not support iframes</p> </iframe>');
                            },
                            create: function(event, data){
                                //alert('create done');
                            },
                            init: function(event, data){
                                if(autoexpand!=undefined && autoexpand==true) {
                                    $("#jqxTree").fancytree("getRootNode").visit(function (node) {
                                        node.setExpanded(true);
                                    });
                                }
                            }
                        });

                        //Tabs
                        $('#jqxTabs').jqxTabs({height: '100%', width: '100%', showCloseButtons: true, reorder: true});


                        /*Handle Tab Panel Context Menu
                        var contextMenu = $("#jqxMenu").jqxMenu({ width: '120px', height: '80px', autoOpenPopup: false, mode: 'popup'});
                        $("#jqxMenu").bind('itemclick', function(event)
                        {
                            var item = $(event.args).text();
                            var tabS = $('#jqxTabs');
                            switch (item)
                            {
                                case "Close Others":
                                    var currentIndex = tabS.jqxTabs('selectedItem');
                                    var currentTabTitle = tabS.jqxTabs('getTitleAt', currentIndex);
                                    for(var kk=currentIndex+1;kk<tabS.jqxTabs('length');kk++)
                                    {
                                        tabS.jqxTabs('removeAt', kk);
                                    }
                                    while(tabS.jqxTabs('length') > 1){
                                        tabS.jqxTabs('removeFirst');
                                    }
                                    break;
                                case "Close All":

                                    while(tabS.jqxTabs('length') > 0){
                                        tabS.jqxTabs('removeLast');
                                    }
                                    break;
                            }
                        });
                        */
                        // open the context menu when the user presses the mouse right button.
                        $("#jqxTabs").bind('mousedown', function (event) {
                            var rightClick = isRightClick(event);
                            if (rightClick) {
                                var scrollTop = $(window).scrollTop();
                                var scrollLeft = $(window).scrollLeft();

                                contextMenu.jqxMenu('open', parseInt(event.clientX) + 5 + scrollLeft, parseInt(event.clientY) + 5 + scrollTop);
                                return false;
                            }
                        });
                        /*

                        // disable the default browser's context menu.
                        $(document).bind('contextmenu', function (e) {
                            //return false;
                        });
                        */

                        function isRightClick(event) {
                            var rightclick;
                            if (!event) var event = window.event;
                            if (event.which) rightclick = (event.which == 3);
                            else if (event.button) rightclick = (event.button == 2);
                            return rightclick;
                        }
                        /*Handle Context Menu*/
                        $("#searchbox").keyup(function(e){
                            var match = $(this).val();
                            var tree = $("#jqxTree").fancytree("getTree");
                            if(e && e.which === $.ui.keyCode.ESCAPE || $.trim(match) === ""){
                                //reset filter
                                tree.clearFilter();
                                return;
                            }

                            // Pass text as filter string (will be matched as substring in the node title)
                            var n = tree.filterNodes(match, {autoExpand: true});
                        }).focus();

                    });
                })(jQuery);
            </script>
            <div id="splitter">
                <div>
                    <div id="splitter2">
                        <div>
                            <div style="width: 100%;">
                                <div style="float: left;">Search:</div>
                                <input id="searchbox" style="float: left;" />
                                <div style="clear: both"></div>
                            </div>

                            <div id='jqxTree' style="height: 95%; overflow: auto;">

                            </div>
                        </div>
                        <div>
                            <a target="_blank" href="<?php 
        echo admin_url('profile.php');
        ?>
"><?php 
        $tmp = wp_get_current_user();
        echo $tmp->user_login;
        ?>
 </a> |
                            <a onclick="return confirm('<?php 
        echo Qdmvc_Message::getMsg('msg_confirm');
        ?>
')"
                               href="<?php 
        echo wp_logout_url(Qdmvc_Helper::getCompactPageListLink('navigation'));
        ?>
">
                                <?php 
        echo Qdmvc_Message::getMsg('msg_logout');
        ?>
                            </a>
                        </div>
                    </div>

                </div>
                <div id="ContentPanel">
                    <!--
                    <div id='jqxMenu'>
                        <ul>
                            <li>Close Others</li>
                            <li>Close All</li>
                        </ul>
                    </div>-->
                    <div id='jqxTabs' style="float: left;">
                        <ul style="margin-left: 30px;" id="unorderedList">
                            <li>Home</li>
                        </ul>
                        <div>
                            Home page content
                        </div>
                    </div>
                </div>
            </div>
            <script>
                (function ($) {
                    $(document).ready(function () {
                        $('#panelContentpaneljqxTree li').click(function () {
                            //alert('wtf');
                        });


                    });
                })(jQuery);
            </script>
            <style>
                #hidden {
                    display: none
                }
            </style>
        </div>
    <?php 
    }
Beispiel #3
0
 public function getPageListURL()
 {
     $filter = $this->getPageView();
     return Qdmvc_Helper::getCompactPageListLink($this->getPageList(), $filter);
 }
Beispiel #4
0
 public function __get($field_name)
 {
     //check cached value
     if (is_array($this->qd_cached_attr) && isset($this->qd_cached_attr[$field_name])) {
         return $this->qd_cached_attr[$field_name];
     }
     //calculate field value
     if (static::ISFLOWFIELD($field_name)) {
         //CALC FlowField First
         return $this->CALCFIELDS($field_name);
     } else {
         if (static::ISSYSTEMFIELD($field_name)) {
             $class_name = $this->getCalledClassName();
             //system preserved field
             if ($field_name == '__sys_note_url') {
                 $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('note', array('model' => $class_name, 'model_id' => $this->id));
                 //COUNT
                 $record = new QdNote();
                 $record->SETRANGE('model', $this->getCalledClassName());
                 $record->SETRANGE('model_id', $this->id);
                 $count = $record->COUNTLIST();
                 return add_query_arg(array('item_count' => $count), $tmp);
             } else {
                 if ($field_name == '__sys_log_url') {
                     $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('log', array('model' => $class_name, 'model_id' => $this->id));
                     //COUNT
                     $record = new QdLog();
                     $record->SETRANGE('model', $this->getCalledClassName());
                     $record->SETRANGE('model_id', $this->id);
                     $count = $record->COUNTLIST();
                     return add_query_arg(array('item_count' => $count), $tmp);
                 } else {
                     if ($field_name == '__sys_image_url') {
                         $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('image', array('model' => $class_name, 'model_id' => $this->id));
                         //COUNT
                         $record = new QdImage();
                         $record->SETRANGE('model', $this->getCalledClassName());
                         $record->SETRANGE('model_id', $this->id);
                         $count = $record->COUNTLIST();
                         return add_query_arg(array('item_count' => $count), $tmp);
                     } else {
                         if ($field_name == '__lasteditor_name') {
                             if ($this->lasteditor_id > 0) {
                                 $user_info = get_userdata($this->lasteditor_id);
                                 return $this->qd_cached_attr[$field_name] = $user_info->user_login;
                             }
                             return Qdmvc_Helper::getNoneText();
                         } else {
                             if ($field_name == '__owner_name') {
                                 if ($this->owner_id > 0) {
                                     $user_info = get_userdata($this->owner_id);
                                     return $this->qd_cached_attr[$field_name] = $user_info->user_login;
                                 }
                                 return Qdmvc_Helper::getNoneText();
                             } else {
                                 if ($field_name == 'date_created' || $field_name == 'date_modified' || $field_name == 'owner_id') {
                                     return parent::__get($field_name);
                                 } else {
                                     // if ($field_name == '__sys_lines_url') {//Default system Lines Field
                                     return $this->getLinesURL($field_name);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return parent::__get($field_name);
 }