namespace service\sis_page_manager;/*new_model*/

define(__NAMESPACE__ . '\_PGM_MAIN_CTP_ID', getImportId('ctp_id:9711e4c6-209b-11e6-9196-00505698354f'));
define(__NAMESPACE__ . '\_PGM_MAIN_WD_ID', getImportId('wd_id:ee4e0510-209b-11e6-9196-00505698354f'));
define(__NAMESPACE__ . '\_PGM_PAGES_MANAGEMENT_WD_ID', getImportId('wd_id:dbe3a3da-4dc0-11e7-8e3a-00505698354f'));
define(__NAMESPACE__ . '\_PGM_PAGES_LIST_WD_ID', getImportId('wd_id:130d14b4-209c-11e6-9196-00505698354f'));
define(__NAMESPACE__ . '\_PGM_PAGE_PROPERTIES_WD_ID', getImportId('wd_id:c31ae5b6-2496-11e6-baca-00505698354f'));
define(__NAMESPACE__ . '\_PGM_PAGES_DESIGN_WD_ID', getImportId('wd_id:17c438fc-24bb-11e6-baca-00505698354f'));
define(__NAMESPACE__ . '\_PGM_PAGE_DESIGN_WD_ID', getImportId('wd_id:09fce309-2587-11e6-baca-00505698354f'));
define(__NAMESPACE__ . '\_PGM_BLOCK_PROPERTIES_WD_ID', getImportId('wd_id:d8ed1c94-26e7-11e6-baca-00505698354f'));
define(__NAMESPACE__ . '\_PGM_BLOCK_PERMS_WD_ID', getImportId('wd_id:4ae8c53b-7536-11e9-ab63-00505698354f'));
define(__NAMESPACE__ . '\_PGM_PAGE_IMAGE_PATH', sisGetSetting('sisUPLOADPATH') . 'sis_page_manager/Image/');
define(__NAMESPACE__ . '\_PGM_PAGE_IMAGE_PATH_HTTP', sisGetSetting('sisUPLOADPATH_HTTP') . 'sis_page_manager/Image/');
define(__NAMESPACE__ . '\_PGM_LAYOUT_TEMPLATE_LIST_WD_ID', getImportId('wd_id:8dac7c5c-209c-11e6-9196-00505698354f'));
define(__NAMESPACE__ . '\_PGM_LAYOUT_TEMPLATE_EDIT_WD_ID', getImportId('wd_id:0aef8fdb-2fcd-11e6-9cdb-00505698354f'));
define(__NAMESPACE__ . '\_PGM_MASTERPAGE_LIST_WD_ID', getImportId('wd_id:92f7d744-209c-11e6-9196-00505698354f'));
define(__NAMESPACE__ . '\_PGM_MASTERPAGE_EDIT_WD_ID', getImportId('wd_id:846665e7-306d-11e6-9cdb-00505698354f'));
define(__NAMESPACE__ . '\_PGM_HOME_PAGES_LIST_WD_ID', getImportId('wd_id:614561c5-32e3-11e6-9cdb-00505698354f'));
define(__NAMESPACE__ . '\_PGM_SERVICES_PAGES_LIST_WD_ID', getImportId('wd_id:67201276-32e3-11e6-9cdb-00505698354f'));
define(__NAMESPACE__ . '\_PGM_SERVICE_PAGES_LIST_WD_ID', getImportId('wd_id:4c51c842-32ed-11e6-9cdb-00505698354f'));
define(__NAMESPACE__ . '\_PGM_BLOCK_LIST_WD_ID', getImportId('wd_id:8e32055e-41b3-11e6-91d6-00505698354f'));
define(__NAMESPACE__ . '\_PGM_BLOCK_EDIT_WD_ID', getImportId('wd_id:9906c075-41b3-11e6-91d6-00505698354f'));

class service extends \sisToolsService {

    function loadLangs() {
        $services = sisRunQuery("SELECT ctp_id FROM saman_content_types", true);
        foreach ($services as $service) {
            sisLoadContentTypeLang($service['ctp_id']);
        }
    }

    function pagesListTree() {
        if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) {
            die();
        }
        $parentWdId = intval(sisParam('parentWdId'));
        if ($parentWdId) {
            sisSetPageTitle(_LNG_PGM_SERVICE_UI);
        }
        else {
            sisSetPageTitle(_LNG_PGM_SERVICE_TITLE);
        }
        $this->loadLangs();
        $serviceUI = false;
        if ($parentWdId) {
            $directoryInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $parentWdId));
            $contentType = getContentType(str_replace('cdk_', '', $directoryInfo['type_name']));
        }
        if ($parentWdId && (sisIsDevelopmentVersion() || !$contentType['is_system'])) {
            if (!$contentType['ctp_id']) {
                die();
            }
            $cats = sisServiceAPIFunc('web_directory', 'admin', 'getAll', array('portal_id' => sisGlobal('portal_id'), 'hide_syetem_node' => false, 'level' => 3, 'display_childs_count' => true, 'parent_id' => $parentWdId, 'show_parent' => true, 'node_type' => array(WD_NODE_TYPE_SERIVCE, WD_NODE_TYPE_SERVICE_CATEGORY, WD_NODE_TYPE_CATEGORY_ITEM)));
            $items = sisServiceFunc('web_directory', 'admin', 'createJSTree', array('cats' => $cats, 'ajaxLoad' => true)) ;
            $otherDirectories = array_slice($items[0]['children'], 0, count($items[0]['children']), true);
            $items[0]['children'] = array_merge(
                array(
                    array('li_attr' => array('wd_id' => -1, 'wd_type' => -1, 'is_system' => 1, 'is_admin' => 0), 'id' => 'wd_-1', 'parent_id' => $items[0]['li_attr']['wd_id'], 'text' => _LNG_PGM_USER_PAGES, 'type' => 'userPages', 'children' => true),
                    array('li_attr' => array('wd_id' => -2, 'wd_type' => -2, 'is_system' => 1, 'is_admin' => 1), 'id' => 'wd_-2', 'parent_id' => $items[0]['li_attr']['wd_id'], 'text' => _LNG_PGM_ADMIN_PAGES, 'type' => 'adminPages', 'children' => true)
                ),
                $otherDirectories ? $otherDirectories : array()
            );
            $serviceUI = true;
    		$dimensions = [];
    		$dimensions[] = ['subject' => 'cdk', 'key' => 'ctpId', 'value' => $contentType['ctp_id']];
            sisRaiseEvent('sis_page_manager', 'VIEW_PAGES_TREE_DEVELOPER', SIS_EVENT_TYPE_READ, array('objectName' => "Service : " . $contentType['type_name'], 'objectId' => $contentType['ctp_id'], 'dimensions' => $dimensions));
        }
        else {
            $cats = sisServiceAPIFunc('web_directory', 'admin', 'getAll', array('portal_id' => sisGlobal('portal_id'), 'hide_syetem_node' => true, 'level' => 2, 'display_childs_count' => true/*, 'extra_where' => 'sp_type_name <> "cdk_' . _PGM_MAIN_CTP_ID . '"'*/));
            $items = sisServiceFunc('web_directory', 'admin', 'createJSTree', array('cats' => $cats, 'ajaxLoad' => true)) ;
            usort($items[0]['children'], function ($a, $b) {return $a['text'] >= $b['text'];});
            $pageServiceNode = null;
            for ($idx = 0; $idx < count($items[0]['children']); $idx ++) {
                if ($items[0]['children'][$idx]['id'] == "wd_" . _PGM_MAIN_WD_ID) {
                    $pageServiceNode = $items[0]['children'][$idx];
                    unset($items[0]['children'][$idx]);
                    break;
                }
            }
            $pageServiceNode['type'] = 'pages';
            $pageServiceNode['text'] = _LNG_PGM_PAGES;
            $items[0]['children'] = array_merge(array($pageServiceNode), $items[0]['children']);
            sisRaiseEvent('sis_page_manager', 'VIEW_PAGES_TREE_DESIGNER', SIS_EVENT_TYPE_READ, array('objectName' => "Page : " . $items[0]['li_attr']['wd_id'], 'objectId' => $items[0]['li_attr']['wd_id']));
        }
       	div('', NULL, 'id="__divPGMMenuTree__" style="height:100%;"');
        div_();
    	script();
    		t('(function() {
    		    var tree = ' . json_encode($items) . ';
    		    var serviceUI = ' . ($serviceUI ? 'true' : 'false') . ';
    		    var parentWdId = ' . ($parentWdId) . ';
    		    var movingNode = false;
    		    tree[0].state = {"opened" : true};
    		    var $treeContainer = $("#__divPGMMenuTree__")
    		    .jstree({
    		        "types" : {
                        "' . WD_NODE_TYPE_SIMPLE . '" : {
                            "icon" : "fa fa-file-code-o"
                        },
                        "' . WD_NODE_TYPE_PORTAL . '" : {
                            "icon" : "fa fa-globe fa-lg"
                        },
                        "' . WD_NODE_TYPE_SERIVCE . '" : {
                            "icon" : "fa fa-gear fa-lg"
                        },
                        "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" : {
                            "icon" : "fa fa-folder-open"
                        },
                        "' . WD_NODE_TYPE_CATEGORY_ITEM . '" : {
                            "icon" : "fa fa-folder-open-o"
                        },
                        "services" : {
                            "icon" : "fa fa-cogs fa-lg"
                        },
                        "pages" : {
                            "icon" : "fa fa-sitemap fa-lg"
                        },
                        "page" : {
                            "icon" : "fa fa-file-o"
                        },
                        "userPages" : {
                            "icon" : "fa fa-globe"
                        },
                        "adminPages" : {
                            "icon" : "fa fa-window-maximize"
                        },
    		        },
        		    "core" : {
        		        "data" : pgmLoadTree,
        		        "animation" : true,
                        "multiple" : false,
                        "themes" : {
                            "dots" : false,

                        },
                        "check_callback" : function(operation, node, parent, position, more) {
                            if((operation === "move_node" || operation === "copy_node") && more && more.dnd) {
                                return pgmCanMove(node, more.ref, more.pos);
                            }

                            if ((operation === "move_node" || operation === "copy_node") && more && more.core) {
                                var prevNode = null;
                                if (position) {
                                    prevNode = jstreeObj.get_node(parent.children[position - 1]);
                                }
                                if (more.origin) {
                                    sisConfirm(\'' . _LNG_PGM_MOVE_NODE_CONFIRM . '\'.replace("%s", node.text), null, null, function() {
                                        movingNode = true;
                                        moveNode(node, parent, prevNode, position, function() {
                                            jstreeObj.move_node(node, parent, position);
                                            jstreeObj.open_node(parent, function() {
                                                jstreeObj.deselect_all();
                                                jstreeObj.select_node(node);
                                            });
                                        });
                                    });
                                    return false;
                                }
                                else if (!movingNode) {
                                    movingNode = true;
                                    moveNode(node, parent, prevNode, position, function() {
                                        jstreeObj.move_node(node, parent, position);
                                        jstreeObj.open_node(parent, function() {
                                            jstreeObj.deselect_all();
                                            jstreeObj.select_node(node);
                                        });
                                    });
                                    return false;
                                }
                                movingNode = false;
                            }
                            return true;
                        }
        		    },
        		    "dnd" : {
        		        "copy" : false,
        		        "inside_pos" : "last",
            		    "is_draggable" : function (nodes, e) {
            		        if (nodes[0].type == "' . WD_NODE_TYPE_PORTAL . '") {
            		            return false;
            		        }
                            return true;
            		    },
        		    },
        		    "plugins" : ["types", "contextmenu", "dnd", "conditionalselect"],
        		    "contextmenu" : {
        		        "select_node" : false,
        		        "items" :
        		        function(node) {
                            if (!$treeContainer.displayContextMenu || (!serviceUI && node.type == "services")) {
                                return false;
                            }

                            $treeContainer.displayContextMenu = false;
        		            var canNew = (serviceUI && (node.type == "' . WD_NODE_TYPE_SIMPLE . '" || node.type == "userPages" || node.type == "adminPages") ) || (!serviceUI && (node.type == "pages" || node.type == "page"));
        		            var canDelete = (serviceUI && node.type == "' . WD_NODE_TYPE_SIMPLE . '") || (!serviceUI && node.type == "page");
        		            var canDesign = (serviceUI && node.type != "userPages" && node.type != "adminPages") || (!serviceUI && node.type != "pages");
        		            var canDesignNode = canDesign;
        		            var canDesignItems = canDesign && node.type != "pages" && node.type != "page" && node.type != "' . WD_NODE_TYPE_SIMPLE . '";
        		            var canDesignEdit = canDesign && node.type != "pages" && node.type != "page" && node.type != "' . WD_NODE_TYPE_SIMPLE . '";
        		            var canProperties = canDesign;

        		            var canMoveDown = pgmCanMove(node, jstreeObj.get_next_dom(node, true), "a");
        		            var canMoveUp = pgmCanMove(node, jstreeObj.get_prev_dom(node, true), "b");
        		            var canMoveLeft = pgmCanMove(node, jstreeObj.get_prev_dom(node, true), "i");
        		            var canMoveRight = pgmCanMove(node, jstreeObj.get_parent(node, true), "a");
        		            var canMove = (canMoveDown || canMoveUp || canMoveLeft || canMoveRight) && node.type != "userPages" && node.type != "adminPages";
                            if (node.type == "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" || node.type == "' . WD_NODE_TYPE_CATEGORY_ITEM . '") {
                                if ($("#" + node.id).prev().attr("wd_type") == "' . WD_NODE_TYPE_SIMPLE . '") {
                                   canMoveLeft = false;
                                }
                            }
                            var items = {
        		                "designPage" : {
        		                    "separator_after": true,
                                    "label": "' . _LNG_PGM_DESIGN_PAGE . '",
                                    "icon": "fa fa-th-large",
                                    "_disabled": !canDesign,
                                    "submenu" : {
                		                "designNodePage" : {
                                            "label": "' . _LNG_PGM_DESIGN_NODE_PAGE . '" + (node.original.pages && node.original.pages && node.original.pages.node > 0 ? " (P)" : ""),
                                            "icon": "fa fa-sitemap",
                                            "_disabled": !canDesignNode,
                                            "action": function (obj) {
                                                $treeContainer.jstree().deselect_all();
                                                $treeContainer.jstree("select_node", obj.reference.attr("id"));
                                                var $treeItem = obj.reference.closest("[role=treeitem]");
                                                changeWindowLocation($treeItem.get(0), "index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=" + $treeItem.attr("wd_id") + "&nodeType=node&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=" + $treeItem.find(".jstree-anchor:first").text() + " | ' . _LNG_PGM_DESIGN_NODE_PAGE . '&sisAPTabExtraId=node" + $treeItem.attr("wd_id"), true);
                                            }
                		                },
                		                "designContentPage" : {
                                            "label": "' . _LNG_PGM_DESIGN_CONTENT_PAGE . '" + (node.original.pages && node.original.pages && node.original.pages.view > 0 ? " (P)" : ""),
                                            "icon": "fa fa-newspaper-o",
                                            "_disabled": !canDesignItems,
                                            "action": function (obj) {
                                                $treeContainer.jstree().deselect_all();
                                                $treeContainer.jstree("select_node", obj.reference.attr("id"));
                                                var $treeItem = obj.reference.closest("[role=treeitem]");
                                                changeWindowLocation($treeItem.get(0), "index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=" + $treeItem.attr("wd_id") + "&nodeType=view&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=" + $treeItem.find(".jstree-anchor:first").text() + " | ' . _LNG_PGM_DESIGN_CONTENT_PAGE . '&sisAPTabExtraId=view" + $treeItem.attr("wd_id"), true);
                                            }
                		                },
                		                "designContentEditPage" : {
                                            "label": "' . _LNG_PGM_DESIGN_CONTENT_EDIT_PAGE . '" + (node.original.pages && node.original.pages && node.original.pages.edit > 0 ? " (P)" : ""),
                                            "icon": "fa fa-edit",
                                            "_disabled": !canDesignEdit,
                                            "action": function (obj) {
                                                $treeContainer.jstree().deselect_all();
                                                $treeContainer.jstree("select_node", obj.reference.attr("id"));
                                                var $treeItem = obj.reference.closest("[role=treeitem]");
                                                changeWindowLocation($treeItem.get(0), "index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=" + $treeItem.attr("wd_id") + "&nodeType=edit&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=" + $treeItem.find(".jstree-anchor:first").text() + " | ' . _LNG_PGM_DESIGN_CONTENT_EDIT_PAGE . '&sisAPTabExtraId=edit" + $treeItem.attr("wd_id") + $treeItem.attr("wd_id"), true);
                                            }
                		                },
                                    }
                                },
        		                "newPage" : {
                                    "label": "' . _LNG_PGM_CREATE_NEW_PAGE . '",
                                    "icon": "fa fa-plus",
                                    "_disabled": !canNew,
                                    "action": function (obj) {
                                        var node = jstreeObj.get_node(obj.reference.closest("[role=treeitem]"));
                                        if (!serviceUI && node.type != "pages" && node.type != "page") {
                                            sisAlert("' . _LNG_PGM_CAN_NOT_ADD_PAGE_INSIDE . '");
                                            return;
                                        }
                                        sisPrompt("' . _LNG_PGM_ENTER_PAGE_TITLE . '", null, null, function(pageTitle) {
                                            pageTitle = pageTitle.replace(/(<([^>]+)>)/ig, "").trim();
                                            if (!pageTitle) {
                                                sisAlert("' . _LNG_PGM_PAGE_TITLE_MANDATORY . '");
                                                return false;
                                            }
                                            sisAdminPanel.startLoading();
                                            $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addNewPage') . '&parentWdId=" + node.li_attr.wd_id + "&pageTitle=" + pageTitle + "&serviceWdId=" + parentWdId + "&serviceUI=" + serviceUI + "&isAdmin=" + node.li_attr.is_admin), function(pageId) {
                                                if (!isNaN(pageId)) {
                                                    if (jstreeObj.is_open(node)) {
                                                        jstreeObj.create_node(node,  { "id" : "wd_" + pageId , "text" : pageTitle, "type" : (serviceUI ? "' . WD_NODE_TYPE_SIMPLE . '" : "page"), "li_attr" : {"wd_id" : pageId, "wd_type" : ' . WD_NODE_TYPE_SIMPLE . ', "is_admin" : node.li_attr.is_admin}, "pages" : [] }, "last");
                                                    }
                                                    else {
                                                        node.state.loaded = false;
                                                        jstreeObj.open_node(node);
                                                    }
                                                    showPortalMessage("' . _GLB_OPERATION_DONE . '");
                                                }
                                            })
                                            .always(function() {
                                                sisAdminPanel.stopLoading();
                                            });
                                        });
                                    }
        		                },
        		                "deletePage" : {
                                    "label": "' . _LNG_PGM_DELETE_PAGE . '",
                                    "icon": "fa fa-remove",
                                    "_disabled": !canDelete,
                                    "action": function (obj) {
                                        var $treeItem = obj.reference.closest("[role=treeitem]");
                                        sisConfirm("' . _LNG_PGM_DELETE_COMPLETE_PAGE_CONFIRM . '", null, null, function() {
                                            sisAdminPanel.startLoading();
                                            $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteNode') . '&pageWdId=" + $treeItem.attr("wd_id")), function(result) {
                                                if (result) {
                                                    showPortalMessage(result, "error");
                                                }
                                                else {
                                                    jstreeObj.delete_node($treeItem.attr("id"));
                                                    showPortalMessage("' . _GLB_OPERATION_DONE . '");
                                                }
                                            })
                                            .always(function() {
                                                sisAdminPanel.stopLoading();
                                            });
                                        });
                                    }
        		                },
        		                "moveUp" : {
                                    "separator_before": true,
                                    "label": "' . _LNG_PGM_MOVE_UP . '",
                                    "icon": "fa fa-arrow-up",
                                    "_disabled": !canMoveUp,
                                    "action": function (obj) {
                                        var $treeItem = obj.reference.closest("[role=treeitem]");
                                        jstreeObj.move_node($treeItem,  $treeItem.prev(), "before");
                                    }
        		                },
        		                "moveDown" : {
                                    "label": "' . _LNG_PGM_MOVE_DOWN . '",
                                    "icon": "fa fa-arrow-down",
                                    "_disabled": !canMoveDown,
                                    "action": function (obj) {
                                        var $treeItem = obj.reference.closest("[role=treeitem]");
                                        jstreeObj.move_node($treeItem,  $treeItem.next(), "after");
                                    }
        		                },
        		                "moveRight" : {
                                    "label": "' . _LNG_PGM_MOVE_RIGHT . '",
                                    "icon": "fa fa-arrow-right",
                                    "_disabled": !canMoveRight,
                                    "action": function (obj) {
                                        var $treeItem = obj.reference.closest("[role=treeitem]");
                                        jstreeObj.move_node($treeItem,  $treeItem.parents("li.jstree-node:first"), "after");
                                    }
        		                },
        		                "moveLeft" : {
                                    "label": "' . _LNG_PGM_MOVE_LEFT . '",
                                    "icon": "fa fa-arrow-left",
                                    "_disabled": !canMoveLeft,
                                    "action": function (obj) {
                                        var $treeItem = obj.reference.closest("[role=treeitem]");
                                        jstreeObj.move_node($treeItem, $treeItem.prev(), "last", function(node, parent, position) {
                                            jstreeObj.open_node(parent);
                                        });
                                    }
        		                },
        		                "pageProperties" : {
                                    "label": "' . _LNG_PGM_PAGE_PROPERTIES . '",
                                    "icon": "fa fa-gear",
                                    "_disabled": !canProperties,
                                    "separator_before": true,
                                    "action": function (obj) {
                                        $treeContainer.jstree().deselect_all();
                                        $treeContainer.jstree("select_node", obj.reference.attr("id"));
                                        var $treeItem = obj.reference.closest("[role=treeitem]");
                                        changeWindowLocation(obj.reference.parent().get(0), "index.php?module=web_directory&wd_id=' . _PGM_PAGE_PROPERTIES_WD_ID . '&pageWdId=" + $treeItem.attr("wd_id") + "&serviceUI=" + serviceUI + "&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=" + $treeItem.find(".jstree-anchor:first").text() + " | ' . _LNG_PGM_PAGE_PROPERTIES . '&sisAPTabExtraId=properties" + $treeItem.attr("wd_id"), true);
                                    }
        		                },
        		            }

        		            if (!canDesign) {
        		                delete items.designPage;
        		            }
        		            else {
        		                if (!canDesignNode) {
        		                    delete items.designPage.submenu.designNodePage;
        		                }
        		                if (!canDesignItems) {
        		                    delete items.designPage.submenu.designContentPage;
        		                }
        		                if (!canDesignEdit) {
        		                    delete items.designPage.submenu.designContentEditPage;
        		                }

        		            }
        		            if (!canNew) {
        		                delete items.newPage;
        		            }
        		            if (!canDelete) {
        		                delete items.deletePage;
        		            }
        		            if (!canMove) {
        		                delete items.moveUp;
        		                delete items.moveDown;
        		                delete items.moveRight;
        		                delete items.moveLeft;
        		            }
        		            if (!canProperties) {
        		                delete items.pageProperties;
        		            }
        		            return items;
        		        }
        		    },
                    "conditionalselect" : function(node) {
                        $treeContainer.displayContextMenu = true;
                        setTimeout(function() {$("#" + node.id + " a").eq(0).trigger("contextmenu")}, 100);
                        return false;
                    },
    		    }).bind("select_node.jstree", function (event, data) {});
                $treeContainer.closest(".sis-block").addClass("sisAPBlockFullHeight");
    		    var jstreeObj = $treeContainer.jstree()

                function pgmLoadTree(node, cb) {
                    if (node.id === "#") {
                        return cb(tree);
                    }
                    else {
                        $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'loadNodeItems') . '&parentWdId=" + node.li_attr.wd_id + "&serviceWdId=" + parentWdId + "&serviceUI=" + (serviceUI ? "true" : "false")), function(data) {
                            cb(data);
                        });
                    }
                }

                function pgmCanMove(srcNode, destNode, pos) {
                    if (srcNode.id < 0 || destNode.id < 0) {
                        return false;
                    }
                    if (!srcNode || !destNode) {
                        return false;
                    }
                    if (!srcNode.id) {
                        srcNode = jstreeObj.get_node(srcNode)
                    }
                    if (!destNode.id) {
                        destNode = jstreeObj.get_node(destNode)
                    }
                    if ((srcNode && srcNode.li_attr && destNode && destNode.li_attr) && (srcNode.li_attr.is_admin != destNode.li_attr.is_admin)) {
                        return false;
                    }
                    if (!srcNode || srcNode.type == "' . WD_NODE_TYPE_PORTAL . '" || srcNode.type == "' . WD_NODE_TYPE_SERIVCE . '" || (!serviceUI && (srcNode.type == "' . WD_NODE_TYPE_SIMPLE . '" || srcNode.type == "' . WD_NODE_TYPE_SERVICE_CATEGORY . '")) || srcNode.type == "pages") {
                        return false;
                    }
                    if (srcNode.type != "page" && !serviceUI && srcNode.type != "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" && srcNode.type != "' . WD_NODE_TYPE_CATEGORY_ITEM . '") {
                        return false;
                    }
                    var srcNodeParent = pgmGetMainParentNode(srcNode);
                    var destNodeParent = pgmGetMainParentNode(destNode);
                    if (!srcNodeParent || !destNodeParent || srcNodeParent != destNodeParent) {
                        return false;
                    }
                    switch (pos) {
                        case "b":
                            if (!destNode) {
                                return false;
                            }
                        break;
                        case "i":
                            if (srcNode.type == "' . WD_NODE_TYPE_SERIVCE . '" || destNode.type == "' . WD_NODE_TYPE_SERIVCE . '") {
                                return false;
                            }
                            if ((srcNode.type == "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" || srcNode.type == "' . WD_NODE_TYPE_CATEGORY_ITEM . '") && (destNode.type != "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" && destNode.type != "' . WD_NODE_TYPE_CATEGORY_ITEM . '")) {
                                return false;
                            }
                            if (srcNode.type == "' . WD_NODE_TYPE_SIMPLE . '" && destNode.type != "' . WD_NODE_TYPE_SIMPLE . '") {
                                return false;
                            }
                        break;
                        case "a":
                            if (!destNode) {
                                return false;
                            }
                        break;
                    }
                    return true;
                }

                function moveNode(node, parent, prevNode, position, callbackFunc) {
                    sisAdminPanel.startLoading();
                    $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'moveNode') . '&srcNodeWdId=" + node.li_attr.wd_id + "&destNodeWdId=" + parent.li_attr.wd_id + "&prevNodeWdId=" + (prevNode ? prevNode.li_attr.wd_id : 0) + "&serviceUI=" + (serviceUI ? "true" : "false") + "&serviceWdId=" + parentWdId), function(result) {
                        if (!result) {
                            if (typeof(callbackFunc) == "function") {
                                callbackFunc(node, parent, prevNode, position);
                            }
                            showPortalMessage("' . _GLB_OPERATION_DONE . '");
                        }
                        else {
                            showPortalMessage(result, "error");
                        }

                    })
                    .always(function() {
                        sisAdminPanel.stopLoading();
                    });
                }

                function pgmGetMainParentNode(node) {
                    try {
                        var parent = jstreeObj.get_node($("#" + jstreeObj.get_parent(node)));
                        while (parent.type != "' . WD_NODE_TYPE_SERIVCE . '" && parent.type != "' . WD_NODE_TYPE_PORTAL . '" && parent.type != "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" && parent.type != "pages") {
                            parent = jstreeObj.get_node($("#" + jstreeObj.get_parent(parent)));
                        }
                        return parent;
                    }
                    catch (ex) {

                    }
                    return false;
                }

                setTimeout(function() {
                    $windowObj = $(sisAdminPanel.getCurrentWindow($treeContainer));
                    $windowObj.find(".sisAPOp[rel=searchNode]").click(function() {
                        sisPrompt("' . _LNG_PGM_PAGE_ID_FOR_SEARCH . '", null, null, function(data) {
                            /*if (!data || isNaN(data)) {
                                sisAlert("' . _LNG_PGM_PAGE_ID_NOT_VALID . '");
                                return false;
                            }*/
                            $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'searchPageId') . '&searchPageId=" + data + "&parentWdId=" + parentWdId + "&serviceUI=" + serviceUI), function(data) {
                                if (!data) {
                                    sisAlert("' . _LNG_PGM_PAGE_ID_NOT_FOUND . '");
                                    return;
                                }
                                var ids = data.split("/");
                                ids.reverse().pop();
                                var wdId = ids.pop();
                                var lastWdId = null;
                                var callbackFunc = function(e, data) {
                                    lastWdId = wdId;
                                    wdId = ids.pop();
                                    if (wdId) {
                                        jstreeObj.open_node($("#wd_" + wdId), callbackFunc);
                                    }
                                    else {
                                        jstreeObj.deselect_all();
                                        jstreeObj.select_node($("#wd_" + lastWdId));
                                        var offset = $("#wd_" + lastWdId).offset();
                                        $($("#wd_" + lastWdId).closest(".sisAPContent:scrollable")).animate({
                                            scrollTop: offset.top - ((offset.top * 20)/100),
                                            scrollLeft: offset.left
                                        });
                                    }
                                }
                                jstreeObj.open_node($("#wd_" + wdId), callbackFunc);
                            });
                        });
                    });
                }, 100)
    		})();
            ');
    	script_();

    	sisAddToAdminOperationBar(_LNG_PGM_SEARCH, 'fa-search', '', null, 'after', 'rel="searchNode"');
    }

    function pageProperties() {
        if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) {
            die();
        }
        $pageWdId = intval(sisParam('pageWdId'));
        if (!$pageWdId) {
            die();
        }
        $contentLang = sisUserGetLang();
        $languages = getLanguages();
        $serviceUI = sisParam('serviceUI') == "true" && sisIsDevelopmentVersion();
        sisCacheDel('web_directory_info_' . $pageWdId);

        if (sisParam('REQUEST_METHOD') == 'POST') {
            $directoryInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $pageWdId));
            if (!$directoryInfo) {
                die();
            }
            $newRecord = array();

            $newRecord['is_system'] = $directoryInfo['is_system'];
            if ($serviceUI && sisCheckUserLicense(PORTAL_CORE_DEVELOPER) && sisIsDevelopmentVersion()) {
                $newRecord['is_system'] = sisParam('is_system') == 1 ? '1' : '0';
            }
            $newRecord['no_page'] = sisParam('no_page') == 1 ? '1' : '0';
            $newRecord['no_menu'] = sisParam('no_menu') == 1 ? '1' : '0';
            $newRecord['show_in_sitemap'] = sisParam('show_in_sitemap') == 1 ? '1' : '0';
            $newRecord['lang'] = sisParam('lang') ? sisParam('lang') : $directoryInfo['lang'];
            $newRecord['title'] = sisParam('title');
            //$newRecord['title'] = $directoryInfo['title'];
            //$newRecord['title'][$contentLang] = sisParam('title');
            //foreach ($languages as $key => $value) {
            //    if (!is_string($newRecord['title'][$key])) {
            //        $newRecord['title'][$key] = $newRecord['title'][$contentLang];
            //    }
            //}
            $newRecord['seo_title'] = sisParam('seo_title');
            //$newRecord['seo_title'] = $directoryInfo['seo_title'];
            //$newRecord['seo_title'][$contentLang] = sisParam('seo_title');
            //foreach ($languages as $key => $value) {
            //    if (!is_string($newRecord['seo_title'][$key])) {
            //        $newRecord['seo_title'][$key] = $newRecord['seo_title'][$contentLang];
            //    }
            //}
            $newRecord['description'] = sisParam('description');
            //$newRecord['description'] = $directoryInfo['description'];
            ///$newRecord['description'][$contentLang] = sisParam('description');
            //foreach ($languages as $key => $value) {
            //  if (!is_string($newRecord['description'][$key])) {
            //        $newRecord['description'][$key] = $newRecord['description'][$contentLang];
            //    }
            //}
            $newRecord['keywords'] = sisParam('keywords');
            //$newRecord['keywords'] = $directoryInfo['keywords'];
            //$newRecord['keywords'][$contentLang] = sisParam('keywords');
            //foreach ($languages as $key => $value) {
            //    if (!is_string($newRecord['keywords'][$key])) {
            //        $newRecord['keywords'][$key] = $newRecord['keywords'][$contentLang];
            //    }
            //}
            $newRecord['redirect_to'] = sisParam('redirect_to');
            $newRecord['alias'] = sisParam('alias');

    		if (sisParam('del_image')) {
    			@unlink(_PGM_PAGE_IMAGE_PATH . $directoryInfo['image']);
    			$newRecord['image'] = null;
    		}
    		if ($_FILES['image']['name']) {
    			@unlink(_PGM_PAGE_IMAGE_PATH . $directoryInfo['image']);

    			$pathInfo = pathinfo($_FILES['image']['name']);
    			$pathInfo['extension'] = strtolower($pathInfo['extension']);
    			if ($pathInfo['extension'] == 'jpg' || $pathInfo['extension'] == 'jpeg' || $pathInfo['extension'] == 'gif' || $pathInfo['extension'] == 'png') {
    				if (move_uploaded_file($_FILES['image']['tmp_name'], _PGM_PAGE_IMAGE_PATH . 'wd_' . intval($pageWdId) . '.' . $pathInfo['extension'])) {
    					$newRecord['image'] = 'wd_' . intval($pageWdId) . '.' . $pathInfo['extension'];
    				}
    				else {
    				    sisRaiseException(_LNG_PGM_PAGE_IMAGE_UPLOAD_ERROR);
    				    sisServerTransfer(sisParam('REQUEST_URI'), true);
    				}
    			}
    		}
    		if ($directoryInfo['is_admin']) {
                $updateSql = "
                    UPDATE
        		        saman_web_directories
        			SET
        				sp_title = '" . sisVarPrepForStore(serialize($newRecord['title'])) . "',
        				sp_redirect_to = " . ($newRecord['redirect_to'] ? ("'" . sisVarPrepForStore($newRecord['redirect_to']) . "'") : 'null') . "
        			 WHERE
                        sp_portal_id = " . intval(sisGlobal('portal_id')) . " AND
        			 	sp_id = '" . intval($pageWdId) . "'";
    		}
    		else {
                $updateSql = "
                    UPDATE
        		        saman_web_directories
        			SET
        				sp_is_system = '" . $newRecord['is_system'] . "',
        				sp_no_page = " . ($newRecord['no_page'] == 1 ? '1' : 'null') . ",
        				sp_no_menu = " . ($newRecord['no_menu'] == 1 ? '1' : 'null') . ",
        				sp_show_in_sitemap = " . ($newRecord['show_in_sitemap'] == 1 ? '1' : 'null') . ",
        				sp_lang = " . ($newRecord['lang'] != 'all'  ? ("'" . sisVarPrepForStore($newRecord['lang']) . "'") : 'null') . ",
        				sp_title = '" . sisVarPrepForStore($newRecord['title']) . "',
        				sp_seo_title = '" . sisVarPrepForStore($newRecord['seo_title']) . "',
        				sp_descrption = '" . sisVarPrepForStore($newRecord['description']) . "',
        				sp_keywords = '" . sisVarPrepForStore($newRecord['keywords']) . "',
        				SP_redirect_to = " . ($newRecord['redirect_to'] ? ("'" . sisVarPrepForStore($newRecord['redirect_to']) . "'") : 'null') . ",
        				sp_alias = " . ($newRecord['alias'] ? ("'" . sisVarPrepForStore($newRecord['alias']) . "'") : 'null') . ",
        				sp_image = " . ($newRecord['image'] ? ("'" . sisVarPrepForStore($newRecord['image']) . "'") : 'null') . "
        			 WHERE
        			 	sp_id = '" . intval($pageWdId) . "'
        			 	AND sp_portal_id = '" . sisGlobal('portal_id') . "'";

    		}
            if (sisRunQuery($updateSql)) {
                sisSetStatusMsg();
            }
            $dimensions = [];
            $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId];
            sisRaiseEvent('sis_page_manager', 'UPDATE_PAGE_PROPERTIES', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'oldRecord' => $directoryInfo, 'newRecord' => $newRecord, 'dimensions' => $dimensions), 'EDIT_PAGE');
            sisServerTransfer(sisParam('REQUEST_URI'), true);
        }
        $directoryInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $pageWdId));
        if (!$directoryInfo) {
            die();
        }

        if ($directoryInfo['type_name']) {
            registerContentTypeLangConsts(intval(str_replace("cdk_", "", $directoryInfo['type_name'])));
        }
        else {
            $record = sisRunQuery("SELECT sp_type_name FROM saman_web_directories WHERE '{$directoryInfo['path']}' LIKE CONCAT('%/', sp_id, '/%') AND sp_node_type IN (" . WD_NODE_TYPE_SERIVCE . ") ORDER BY sp_level DESC LIMIT 1", true);
            if ($record[0]['sp_type_name']) {
                registerContentTypeLangConsts(intval(str_replace("cdk_", "", $record[0]['sp_type_name'])));
            }
        }
        $this->loadLangs();
        if (!sisParam('sisAPWindowTitle')) {
            sisSetPageTitle(localizedStr($directoryInfo['title']) . ' | ' . _LNG_PGM_PAGE_PROPERTIES);
        }
        $languagesDomain = sisGetLanguagesDomain();
        $languages = getLanguages();
        $directoryInfo['lang'] = $directoryInfo['lang'] ? $directoryInfo['lang'] : 'all';
        $dimensions = [];
        $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId];
        sisRaiseEvent('sis_page_manager', 'VIEW_PAGE_PROPERTIES', SIS_EVENT_TYPE_READ, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'dimensions' => $dimensions), 'VIEW_PAGE');
        sisPage(array('treat'=>'IGONRE_HISTORY', 'identifier'=>'pgmPageSettings'), '', false);
            form('frmPgmPageProperties', sisParam('REQUEST_URI'), NULL, NULL, NULL, 'ENCTYPE="multipart/form-data" class="sisDataForm"');
                sisFormGroup();
                    sisCaption();
                        t(_LNG_PGM_WD_ID);
                    sisCaption_();
                    sisData();
                        t($directoryInfo['id']);
                    sisData_();
                sisFormGroup_();
                sisFormGroup();
                    sisCaption();
                        t(_LNG_PGM_OBJECT_ID);
                    sisCaption_();
                    sisData();
                        t($directoryInfo['object_id']);
                    sisData_();
                sisFormGroup_();
    			if (!$directoryInfo['is_system'] && !$directoryInfo['is_admin'] && $serviceUI && sisCheckUserLicense(PORTAL_CORE_DEVELOPER) && sisIsDevelopmentVersion()) {
                    sisFormGroup();
                        sisCaption();
                            t(_LNG_PGM_IS_SYSTEM);
                        sisCaption_();
                        sisData();
    					    $options = array(array('value' => '0', 'caption' => _LNG_PGM_NO), array('value' => '1', 'caption' => _LNG_PGM_YES));
    						radioGroup('is_system', $options, null, $directoryInfo['is_system']);
                        sisData_();
                    sisFormGroup_();
    			}
        		if (!$directoryInfo['is_admin']) {
                    sisFormGroup();
                        sisCaption();
                        sisCaption_();
                        sisData();
                            CheckBox('no_page', 1, _LNG_PGM_NO_LINK, $directoryInfo['no_page']);
                        sisData_();
                    sisFormGroup_();
                    sisFormGroup();
                        sisCaption();
                        sisCaption_();
                        sisData();
                            CheckBox('no_menu', 1, _LNG_PGM_HIDE_LINK, $directoryInfo['no_menu']);
                        sisData_();
                    sisFormGroup_();
                    /*if ($directoryInfo['node_type'] != 3) {
                        sisFormGroup();
                            sisCaption();
                            sisCaption_();
                            sisData();
                                CheckBox('show_in_sitemap', 1, _LNG_PGM_SHOW_SITEMAP, $directoryInfo['show_in_sitemap']);
                            sisData_();
                        sisFormGroup_();
                    }*/
                }
        		if(!$directoryInfo['is_admin'] && $directoryInfo['node_type'] == WD_NODE_TYPE_CATEGORY_ITEM){
                    sisFormGroup();
                        sisCaption();
                            t(_LNG_PGM_LANG);
                        sisCaption_();
                        sisData();
                            comboBox('lang', $languagesDomain, $directoryInfo['lang']);
                        sisData_();
                    sisFormGroup_();
        		}
                sisFormGroup();
                    sisCaption();
                        t(_LNG_PGM_REDIRECT_ADDRESS);
                    sisCaption_();
                    sisData();
                        Edit("redirect_to", $directoryInfo['redirect_to'], '80', 'style="direction:ltr"', NULL, NULL, 'TEXT', 'col-xs-12');
                        br();
                        t(_LNG_PGM_PAGE_REDIRECT_SAMPLE, 'form_comment');
                    sisData_();
                sisFormGroup_();
                sisFormGroup();
                    sisCaption();
                        t(_LNG_PGM_PAGE_TITLE);
                    sisCaption_(array('mandatory' => true));
                    sisData();
                        Edit("title", localizedStr($directoryInfo['title'], null, false), '80', NULL, NULL, NULL, 'TEXT', 'col-xs-6');
                    sisData_();
                sisFormGroup_();
        		if (!$directoryInfo['is_admin']) {
                    sisFormGroup();
                        sisCaption();
                            t(_LNG_PGM_PAGE_URL_TITLE);
                        sisCaption_();
                        sisData();
                            Edit("seo_title", localizedStr($directoryInfo['seo_title'], null, false), '80', NULL, NULL, NULL, 'TEXT', 'col-xs-6');
                        sisData_();
                    sisFormGroup_();
                    sisFormGroup();
                        sisCaption();
                            t(_LNG_PGM_PAGE_DESCRIPTION);
                        sisCaption_();
                        sisData();
                            @mkdir(_PGM_PAGE_IMAGE_PATH);
                            textArea("description", 3, 80, 'style="height:100px"', NULL, 'col-xs-12');
                                 t(localizedStr($directoryInfo['desc'], null, false));
                            textArea_();
            			    //htmlEditor("description", _PGM_PAGE_IMAGE_PATH, '100%', '200px', localizedStr($directoryInfo['desc'], null, false), 'Basic');
                        sisData_();
                    sisFormGroup_();
                    sisFormGroup();
                        sisCaption();
                            t(_LNG_PGM_PAGE_KEYWORDS);
                        sisCaption_();
                        sisData();
            				textArea("keywords", 3, 80, 'style="height:100px"', NULL, 'col-xs-12');
            					t(localizedStr($directoryInfo['keywords'], null, false));
            				textArea_();
                		sisData_();
                    sisFormGroup_();
                    //sisFormGroup();
                   //     sisCaption();
                    //        t(_LNG_PGM_PAGE_IMAGE);
                    //    sisCaption_();
                    //    sisData();
    				//		if ($directoryInfo['image']) {
    				//			$size = getimagesize(_PGM_PAGE_IMAGE_PATH . $directoryInfo['image']);
    				//			$imageExtra = '';
    				//			if ($size[0] > 300 || $size[1] > 300)
    				//				$imageExtra = 'width="300px" height="300px"';
    				//			else
    				//				$imageExtra = $size[3];
    				//			img(_PGM_PAGE_IMAGE_PATH_HTTP . $directoryInfo['image'], $imageExtra);
    				//			br();
    				//		}
    				//		t('');
    				//		if ($directoryInfo['image']) {
    				//			CheckBox('del_image', 1, _LNG_PGM_PAGE_DELETE_IMAGE);
    				//		}
                	//	sisData_();
                    //sisFormGroup_();
                    sisFormGroup();
                        sisCaption();
                            t(_LNG_PGM_PAGE_ALIAS);
                        sisCaption_();
                        sisData();
    						Edit("alias", $directoryInfo['alias'], '80', 'style="direction:ltr;"', NULL, NULL, 'TEXT', 'col-xs-6');
    						br();
    						t(_LNG_PGM_PAGE_ALIAS_SAMPLE, 'form_comment');
                		sisData_();
                    sisFormGroup_();
        		}
                operationBar(_LNG_PGM_SAVE);
            form_();
        sisPage_();
        script();
            t('if ($("#wd_' . $pageWdId . ' a").get(0)) {$("#wd_' . $pageWdId . ' a").get(0).lastChild.nodeValue = "' . localizedStr($directoryInfo['title']) . '";}');
            beginCheckForm('frmPgmPageProperties');
                jsCheckNotNull("title", _LNG_PGM_PAGE_TITLE_MANDATORY);
            endCheckForm();
        script_();
    }

    function designPages() {
        if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) {
            die();
        }
        $pageWdId = intval(sisParam('pageWdId'));
        $portalId = intval(sisGlobal('portal_id'));
        if (!$pageWdId) {
            die();
        }
        $directoryInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $pageWdId));
        if (!$directoryInfo) {
            sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR);
            sisCloseCurrentWindow();
        }
        $this->loadLangs();
        $languages = getLanguages();
        if ($directoryInfo['lang']) {
            $languages = array($directoryInfo['lang'] => $languages[$directoryInfo['lang']]);
        }
        if ($directoryInfo['is_admin']) {
            $channels = array(
                'all' => array('title' => _LNG_PGM_CHANNEL_ALL, 'icon' => 'globe', 'id' => 0),
                'mobile' => array('title' => _LNG_PGM_CHANNEL_MOBILE, 'icon' => 'mobile', 'id' => 2),
                );
        }
        else {
            $channels = array(
                'all' => array('title' => _LNG_PGM_CHANNEL_ALL, 'icon' => 'globe', 'id' => DEVICE_ALL),
                'desktop' => array('title' => _LNG_PGM_CHANNEL_DESKTOP, 'icon' => 'desktop', 'id' => DEVICE_DESKTOP),
                'mobile' => array('title' => _LNG_PGM_CHANNEL_MOBILE, 'icon' => 'mobile', 'id' => DEVICE_MOBILE),
                'tablet' => array('title' => _LNG_PGM_CHANNEL_TABLET, 'icon' => 'tablet', 'id' => DEVICE_TABLET),
                'weak_person' => array('title' => _LNG_PGM_CHANNEL_WEAK_PERSON, 'icon' => 'universal-access', 'id' => DEVICE_UNIVERSAL_ACCESS),
                'bot' => array('title' => _LNG_PGM_CHANNEL_BOT, 'icon' => 'bug', 'id' => DEVICE_BOT),
                'old_browser' => array('title' => _LNG_PGM_CHANNEL_OLD_BROWSER, 'icon' => 'internet-explorer', 'id' => DEVICE_OLD_BROWSER),
                'high_traffic' => array('title' => _LNG_PGM_CHANNEL_HIGH_TRAFFIC, 'icon' => 'line-chart', 'id' => DEVICE_HIGHTRAFFIC),
                'low_speed' => array('title' => _LNG_PGM_CHANNEL_LOW_SPEED, 'icon' => 'hourglass-start', 'id' => DEVICE_LOW_SPEED),
                );
        }
        $fieldName = '';
        $nodeType = '';
        switch (sisParam('nodeType')) {
            case 'node':
                $title = _LNG_PGM_DESIGN_NODE_PAGE;
                $fieldName = 'sp_node_page_id';
                $nodeType = 'node';
            break;
            case 'view':
                $title = _LNG_PGM_DESIGN_CONTENT_PAGE;
                $fieldName = 'sp_view_page_id';
                $nodeType = 'view';
            break;
            case 'edit':
                $title = _LNG_PGM_DESIGN_CONTENT_EDIT_PAGE;
                $fieldName = 'sp_edit_page_id';
                $nodeType = 'edit';
            break;
        }
        if (!$nodeType) {
            die();
        }
        $pages = array();
        $disablePages = array();
        if ($directoryInfo['wd_pages'][$nodeType]) {
            $result = sisRunQuery("SELECT sp_page_detail_id as detail_id, sp_language as lang, sp_device as device, sp_status as status, 0 as design FROM saman_pages_detail WHERE sp_page_id = " . $directoryInfo['wd_pages'][$nodeType] . " AND sp_portal_id = $portalId");
            while (!$result->EOF()) {
                if (!$result->fields['lang']) {
                    $result->fields['lang'] = 'all';
                }
                $pages[$result->fields['device']][$result->fields['design']][$result->fields['lang']] = $result->fields['detail_id'];
                if ($result->fields['status'] != 1) {
                    $disablePages[$result->fields['detail_id']] = true;
                }
                $result->moveNext();
            }
        }
        $dimensions = [];
        $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId];
        sisRaiseEvent('sis_page_manager', 'VIEW_PAGE_DETAIL_DESIGN', SIS_EVENT_TYPE_READ, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageType' => $nodeType, 'dimensions' => $dimensions), 'VIEW_PAGE');
        div(null, 'pgmDesign', $directoryInfo['is_admin'] ? ' data-isAdmin=true' : '');
            $pageTitle = sisParam('sisAPWindowTitle') ? sisParam('sisAPWindowTitle') : localizedStr($directoryInfo['title'])  . ' | ' . $title;
            sisSetPageTitle($pageTitle);
            div('', 'pgmTableContainer');
                table('100%', 0, 'class="sisDataListTable table-no-bordered" id="tblPgmLiveVersion"');
                    thead();
                        /*tr();
                            th(null, 'style="text-align: center" colspan=' . (count($languages) + 2));
                                t(_LNG_PGM_LIVE_VERSION);
                            th_();
                        tr_();*/
                        tr();
                            th();
                                t(_LNG_PGM_CHANNEL);
                            th_();
                            if (!$directoryInfo['lang']) {
                                th(NULL, 'style="width:6%;text-align:center"');
                                    t(_LNG_PGM_ALL_LANGS);
                                th_();
                            }
                            foreach ($languages as $key => $value) {
                                th(null, 'style="width:6%;text-align:center"');
                                    t($value);
                                th_();
                            }
                        tr_();
                    thead_();
                    //$index = 0;
                    foreach ($channels as $channel => $info) {
                        $index = $info['id'];
                        tr();
                            td();
                                t('');
                                t($info['title']);
                            td_();
                            if (!$directoryInfo['lang']) {
                                td();
                                    if ($pages[$index][0]['all']) {
                                        t('' . ($disablePages[$pages[$index][0]['all']] ? ' ' : ''));
                                    }
                                    else {
                                        t('');
                                    }
                                td_();
                            }
                            foreach ($languages as $key => $value) {
                                td();
                                    if ($pages[$index][0][$key]) {
                                        t('' . ($disablePages[$pages[$index][0][$key]] ? ' ' : ''));
                                    }
                                    else {
                                        t('');
                                    }
                                td_();
                            }
                        tr_();
                        //$index++;
                    }
                table_();
                /*sisAddToAdminOperationBar(_LNG_PGM_LIVE_VERSION, 'fa-bullhorn', null, null, 'after', 'id="btnPgmLiveVersion"');
                sisAddToAdminOperationBar(_LNG_PGM_DEVELOP_VERSION, 'fa-wrench', null, null, 'after', 'id="btnPgmDevelopVersion"');*/
                /*table('100%', 0, 'class="sisDataListTable"  id="tblPgmDevelopVersion"');
                    thead();
                        tr();
                            th(null, 'style="text-align: center" colspan=' . (count($languages) + 2));
                                t(_LNG_PGM_DEVELOP_VERSION);
                            th_();
                        tr_();
                        tr();
                            th();
                                t(_LNG_PGM_CHANNEL);
                            th_();
                            th(NULL, 'style="width:6%;text-align:center"');
                                t(_LNG_PGM_ALL_LANGS);
                            th_();
                            foreach ($languages as $key => $value) {
                                th(NULL, 'style="width:6%;text-align:center"');
                                    t($value);
                                th_();
                            }
                        tr_();
                    thead_();
                    $index = 0;
                    foreach ($channels as $channel => $info) {
                        tr();
                            td();
                                t('');
                                t($info['title']);
                            td_();
                            td();
                                if ($pages[$index][1]['all']) {
                                    t('' . ($disablePages[$pages[$index][1]['all']] ? ' ' : ''));
                                }
                                else {
                                    t('');
                                }
                            td_();
                            foreach ($languages as $key => $value) {
                                td();
                                    if ($pages[$index][1][$key]) {
                                        t('' . ($disablePages[$pages[$index][1][$key]] ? ' ' : ''));
                                    }
                                    else {
                                        t('');
                                    }
                                td_();
                            }
                        tr_();
                        $index++;
                    }
                table_();*/
            div_();
        div_();
        $languages['all'] = _LNG_PGM_ALL_LANGS;
        script();
            t('
            setTimeout(function() {
                var pgmLanguages = ' . json_encode($languages) . ';
                var designMode = ' . intval(sisParam('pageIsDesign')) . ';
                $("#btnPgmLiveVersion").addClass("sisAPActive");
                if (designMode) {
                    $("#tblPgmLiveVersion").closest(".bootstrap-table").hide();
                    $("#tblPgmDevelopVersion").closest(".bootstrap-table").show();
                    $("#btnPgmLiveVersion").removeClass("sisAPActive");
                    $("#btnPgmDevelopVersion").addClass("sisAPActive");
                }
                else {
                    $("#tblPgmLiveVersion").closest(".bootstrap-table").show();
                    $("#tblPgmDevelopVersion").closest(".bootstrap-table").hide();
                }

                function pgmToggleTables() {
                    if ($(this).hasClass("sisAPActive")) {
                        return;
                    }
                    $("#tblPgmDevelopVersion").closest(".bootstrap-table").toggle();
                    $("#tblPgmLiveVersion").closest(".bootstrap-table").toggle();
                    $("#btnPgmDevelopVersion").toggleClass("sisAPActive");
                    $("#btnPgmLiveVersion").toggleClass("sisAPActive");
                }

                $("#btnPgmLiveVersion").click(pgmToggleTables);
                $("#btnPgmDevelopVersion").click(pgmToggleTables);

                $(".pgmDesign .pgmPageAction").click(function(e) {
                    var items = [];
                    var $obj = $(this);
                    var isDesign = $(this).hasClass("pgmDesignPageAction");
                    var isAdmin = $(this).closest(".pgmDesign").attr("data-isAdmin");
                    if ($(this).attr("rel") == "create") {
                        items.push(
                            {"title" : "' . _LNG_PGM_CREATE_PAGE . '", "icon" : "fa-plus", "action" : function(e) {
                                sisConfirm("' . _LNG_PGM_CREATE_PAGE_CONFIRM . '".replace("%s", pgmLanguages[$obj.attr("pgmLang")]).replace("%s", $(this).closest("tr").find("td:first").text()), null, null, function() {
                                    changeWindowLocation($obj.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'createNodePage', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType)) . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab", true);
                                });
                            }});
                        if (isDesign) {
                            if ($(this).attr("pgmMainPageDetailId")) {
                                var mainPageDetailId = $(this).attr("pgmMainPageDetailId");
                                items.push({"title" : "' . _LNG_PGM_DUPLICATE_MAIN_PAGE . '", "icon" : "fa-clone", "action" : function(e) {
                                        sisConfirm("' . _LNG_PGM_CREATE_PAGE_CONFIRM . '".replace("%s", pgmLanguages[$obj.attr("pgmLang")]).replace("%s", $(this).closest("tr").find("td:first").text()), null, null, function() {
                                            changeWindowLocation($obj.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'createNodePageBased', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType)) . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&pageMainPageDetailId=" + mainPageDetailId + "&sisAPTabsheetName=pgmPageDesignTab", true);
                                        });
                                    }});
                            }
                        }
                        /*items.push({"title" : "' . _LNG_PGM_DUPLICATE_PARENT_PAGE . '", "icon" : "fa-clone", "action" : function(e) {
                                sisConfirm("' . _LNG_PGM_CREATE_PAGE_CONFIRM . '".replace("%s", pgmLanguages[$obj.attr("pgmLang")]).replace("%s", $(this).closest("tr").find("td:first").text()), null, null, function() {
                                    changeWindowLocation($obj.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'createNodePageBased', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType)) . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab", true);
                                });
                            }});*/
                        if ($(this).closest("tbody").find("i[rel=edit]").length) {
                            items.push({"title" : "' . _LNG_PGM_DUPLICATE_SELECTED_PAGE . '", "icon" : "fa-magic", "action" : pgmDuplicateExistingPage});
                        }
                    }
                    else {' );
                        if ($nodeType == 'node') {
                            t('
                            if (!isAdmin) {
                                items.push(
                                    {"title" : "' . _LNG_PGM_PREVIEW . '", "icon" : "fa-eye", "action" : function(e) {
                                        var url = "index.php?module=web_directory&wd_id=' . $pageWdId . '&previewChannel=" + $obj.attr("pgmChannel") + "&previewLang=" + $obj.attr("pgmLang");
                                        window.open(url);
                                    }}
                                );
                                items.push({});
                            }');
                        }
                    t('items.push(
                            {"title" : "' . _LNG_PGM_EDIT_PAGE . '", "icon" : "fa-edit", "action" : function(e) {
                                changeWindowLocation(this, "index.php?module=web_directory&wd_id=' . _PGM_PAGE_DESIGN_WD_ID .'&pageWdId=' . $pageWdId . '&pageNodeType=' . $nodeType . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab&pageTitle='. urlencode($pageTitle) . '", true);
                            }}
                        );
                        if (!isDesign) {
                            items.push(
                                {"title" : !$(this).attr("pgmDisable") ? "' . _LNG_PGM_DISABLE_PAGE . '" : "' . _LNG_PGM_ENABLE_PAGE . '", "icon" : !$(this).attr("pgmDisable") ? "fa-pause" : "fa-play", "action" : function(e) {
                                    sisConfirm((!$(this).attr("pgmDisable") ? "' . _LNG_PGM_PAGE_DISABLE_CONFIRM . '" : "' . _LNG_PGM_PAGE_ENABLE_CONFIRM . '").replace("%s", pgmLanguages[$obj.attr("pgmLang")]).replace("%s", $(this).closest("tr").find("td:first").text()), null, null, function() {
                                        changeWindowLocation($obj.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'setNodePageStatus', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType, 'pageTitle' => $pageTitle)) . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageStatus=" + (!$obj.attr("pgmDisable") ? "0" : "1") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab", false);
                                    });
                                }}
                            );
                        }
                        items.push(
                            {"title" : "' . _LNG_PGM_DELETE_PAGE . '", "icon" : "fa-remove", "action" : function(e) {
                                sisConfirm("' . _LNG_PGM_DELETE_PAGE_CONFIRM . '".replace("%s", pgmLanguages[$obj.attr("pgmLang")]).replace("%s", $(this).closest("tr").find("td:first").text()), null, null, function() {
                                    changeWindowLocation($obj.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteNodePage', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType, 'pageTitle' => $pageTitle)) . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab", false);
                                });
                            }}
                        );
                        if (isDesign) {
                            items.push({});
                            items.push(
                                {"title" : "' . _LNG_PGM_MOVE_TO_MAIN_PAGE . '", "icon" : "fa-upload", "action" : function(e) {
                                    sisConfirm("' . _LNG_PGM_MOVE_TO_MAIN_PAGE_CONFIRM . '", "' . _LNG_PGM_MOVE_TO_MAIN_PAGE_CONFIRM_MESSAGE . '", "' . _LNG_PGM_CONFIRM_MESSAGE_CONFIRM . '", function() {
                                        changeWindowLocation($obj.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'uploadChanges', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType)) . '&pageChannel=" + $obj.attr("pgmChannel") + "&pageLang=" + $obj.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab", false);
                                    });
                                }}
                            );
                        }
                        else {
                        }
                    }
                    showQuickMenu(this, {
                        "items" : items
                    }, e);
                });

                function pgmDuplicateExistingPage(e) {
                    var isDesign = $(this).hasClass("pgmDesignPageAction");
                    var $cover = $("
"); $(this).closest("tbody").find("i[rel=edit]").each(function () { var $icon = $(""); $icon.data("orgIcon", this); $icon.css({"top" : $(this).offset().top, "left" : $(this).offset().left, "cursor" : "pointer"}); $icon.click(function() { var $destIcon = $($(this).parent().find("i[rel=destPage]").data("orgIcon")); var $srcIcon = $($(this).data("orgIcon")); sisConfirm("' . _LNG_PGM_CREATE_PAGE_CONFIRM . '".replace("%s", pgmLanguages[$destIcon.attr("pgmLang")]).replace("%s", $destIcon.closest("tr").find("td:first").text()), null, null, function() { $("#pgmDuplicateCover").remove(); changeWindowLocation($destIcon.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'createNodePageBasedExisting', array('pageWdId' => $pageWdId, 'pageNodeType' => $nodeType)) . '&destPageChannel=" + $destIcon.attr("pgmChannel") + "&destPageLang=" + $destIcon.attr("pgmLang") + "&srcPageChannel=" + $srcIcon.attr("pgmChannel") + "&srcPageLang=" + $srcIcon.attr("pgmLang") + "&pageIsDesign=" + (isDesign ? 1 : 0) + "&sisAPTabsheetName=pgmPageDesignTab", true); }); }); $cover.append($icon); }); var $icon = $(""); $icon.data("orgIcon", this); $icon.css({"top" : $(this).offset().top, "left" : $(this).offset().left, "cursor" : "not-allowed"}); $cover.append($icon); $cover.append("
' . _LNG_PGM_SELECT_DUPLICATE_PAGE_MESSAGE . '
"); $cover.find(".pgmDuplicateCoverMessage i").click(function() { $("#pgmDuplicateCover").fadeOut(400, function() { $(this).remove(); }) }); $(document.body).append($cover); $cover.fadeIn(400); $(document.body).keydown(function (e) { e = e || window.event; if (e.which === 27) { $("#pgmDuplicateCover").fadeOut(400, function() { $(this).remove(); }); } }); } }, 100); function showQuickMenu(obj, options, e) { options = $.extend({ "items" : [], "position" : {"y" : "bottom", "x" : "center"}, "margin": {"y" : 8, "x" : 0}, }, options, true); e = e || window.event; $(obj).addClass("sisAPQucikAccessElement"); var $menu = $("#sisAPQuickMenu"); if (!$menu.length) { $menu = $("
") $(document.body).append($menu); var hideFunc = function(e) { e = e || window.event; var $menu = $("#sisAPQuickMenu"); if ($menu.css("display") != "block") { return; } if (e.type == "mousewheel") { e.preventDefault(); } else if (e.type == "keydown") { e.preventDefault(); if (e.which === 27) { $menu.stop(); $menu.fadeOut("fast"); } } else { if (!$(e.target).hasClass("sisAPQucikAccessElement")) { $menu.stop(); $menu.fadeOut("fast"); } } } $(document.body).mousedown(hideFunc).keydown(hideFunc).bind("mousewheel", hideFunc); } var $container = $menu.find("ul"); $container.html(""); for (var idx = 0; idx < options.items.length; idx++) { var $item = null; if (options.items[idx].title) { $item = $("
  • " + options.items[idx].title + "
  • "); if (typeof(options.items[idx].action) == "function") { $item.data("clickFunc", options.items[idx].action); $item.data("item", obj); $item.click(function(e) { $(this).data("clickFunc").call($(this).data("item"), e)}); } } else { $item = $("
  • "); } $container.append($item); } $menu.stop(); $menu.fadeIn("fast"); var top = 0; var left = 0; if (options.position.y == "bottom") { top = $(obj).offset().top + $(obj).outerHeight(true); } if (options.position.x == "center") { left = $(obj).offset().left + ($(obj).outerWidth(true) / 2) - ($menu.outerWidth(true) / 2); } top += options.margin.y || 0; left += options.margin.x || 0; $menu.css("top", top + "px"); $menu.css("left", left + "px"); $menu.find("div").css({"width" : "100%", "text-align" : "center", "top" : "-15px", "left" : "-2px"}); } '); script_(); } function designPage() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageWdId = intval(sisParam('pageWdId')); $this->updateLastViewTime(intval($pageWdId)); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } $pageLang = sisParam('pageLang'); $pageChannel = intval(sisParam('pageChannel')); $portalId = sisGlobal('portal_id'); $pageIsDesign = intval(sisParam('pageIsDesign')); $pageTheme = sisParam('pageTheme') ? sisParam('pageTheme') : sisUserGetTheme(); switch (sisParam('pageNodeType')) { case 'node': $title = _LNG_PGM_DESIGN_NODE_PAGE; $fieldName = 'sp_node_page_id'; $pageNodeType = 'node'; break; case 'view': $title = _LNG_PGM_DESIGN_CONTENT_PAGE; $fieldName = 'sp_view_page_id'; $pageNodeType = 'view'; break; case 'edit': $title = _LNG_PGM_DESIGN_CONTENT_EDIT_PAGE; $fieldName = 'sp_edit_page_id'; $pageNodeType = 'edit'; break; } $channels = array( 'all' => array('title' => _LNG_PGM_CHANNEL_ALL, 'icon' => 'globe'), 'desktop' => array('title' => _LNG_PGM_CHANNEL_DESKTOP, 'icon' => 'desktop'), 'mobile' => array('title' => _LNG_PGM_CHANNEL_MOBILE, 'icon' => 'mobile'), 'tablet' => array('title' => _LNG_PGM_CHANNEL_TABLET, 'icon' => 'tablet'), 'weak_person' => array('title' => _LNG_PGM_CHANNEL_WEAK_PERSON, 'icon' => 'wheelchair'), 'bot' => array('title' => _LNG_PGM_CHANNEL_BOT, 'icon' => 'bug'), 'old_browser' => array('title' => _LNG_PGM_CHANNEL_OLD_BROWSER, 'icon' => 'internet-explorer'), 'high_traffic' => array('title' => _LNG_PGM_CHANNEL_HIGH_TRAFFIC, 'icon' => 'line-chart'), 'low_speed' => array('title' => _LNG_PGM_CHANNEL_LOW_SPEED, 'icon' => 'hourglass-start'), ); $channels = array_values($channels); $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; if (!$pageLang) { $pageLang = 'all'; } $themes = $GLOBALS['thmEngine']->sisGetThemes(true); if (!$pageWdId || !$pageNodeType || !$languages[$pageLang] || !$channels[$pageChannel]) { die(); } if (sisParam('pageTitle')) { $title = urldecode(sisParam('pageTitle')); } else { $title = localizedStr($wdInfo['title']) . ' | ' . $title; } sisSetPageTitle($title . ' | ' . $channels[$pageChannel]['title'] . ' | ' . $languages[$pageLang]); $thmLayouts = sisServiceAPIFunc('pmk', 'admin', 'getPageTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); $pageLayouts = sisServiceAPIFunc('pmk', 'admin', 'getLayoutTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme, 'lang' => $pageLang)); $masterpages = sisServiceAPIFunc('pmk', 'admin', 'getMasterPages', array('portal_id' => $portalId, 'theme' => $pageTheme)); $pageId = $wdInfo['wd_pages'][$pageNodeType]; if (!$pageId) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } $pageDetailRecord = sisRunQuery("SELECT * FROM saman_pages_detail WHERE sp_page_id = $pageId AND " . ($pageLang != "all" ? "sp_language = '" . sisVarPrepForStore($pageLang) . "'" : " (sp_language IS NULL OR sp_language = '' OR sp_language = 'all') ") . " AND sp_device = $pageChannel AND sp_portal_id = $portalId", true); $pageDetailRecord = $pageDetailRecord[0]; if (!$pageDetailRecord) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } if ($wdInfo['is_admin']) { //$pageDetailRecord['sp_page_template'] = 'onecolumn'; $pageLayouts = array( array( 'template_title' => _LNG_PGM_LAYOUT_TEMPLATE_ONE_COLUMN, 'template_id' => 'onecolumn', 'template_content' => file_get_contents(sisServiceResource('layout_onecolumn.tpl', 'other', 'sis_control_panel')) ), array( 'template_title' => _LNG_PGM_LAYOUT_TEMPLATE_TWO_COLUMN, 'template_id' => 'twocolumn', 'template_content' => file_get_contents(sisServiceResource('layout_twocolumn.tpl', 'other', 'sis_control_panel')) ), ); } sisAddToAdminOperationBar(_LNG_PGM_PAGE_DESIGN_SETTINGS, 'fa-gear', 'javascript:(function() { showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'pageDesignSettings', array('pageWdId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageNodeType' => $pageNodeType, 'pageTheme' => $pageTheme, 'pageTitle' => sisParam('pageTitle'))) . '", null, "dialogWidth:350px;dialogMinHeight:110px;ajax:true;title:' . _LNG_PGM_PAGE_DESIGN_SETTINGS . '"); })()'); if (!$wdInfo['is_admin'] && $pageNodeType == 'node') { sisAddToAdminOperationBar(_LNG_PGM_PREVIEW, 'fa-eye', 'window.open("index.php?module=web_directory&wd_id=' . $pageWdId . '")'); } //if (count($themes) && !$wdInfo['is_admin'] && !$pageDetailRecord['sp_masterpage_id']) { // sisAddToAdminOperationBar(_LNG_PGM_SELECT_THEME . '   (' . _LNG_PGM_CURRENT_THEME . ' : ' . $themes[$pageTheme]['title'] . ')', 'fa-paint-brush', 'javascript:(function() { // showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'selectActiveTheme', array('pageWdId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageNodeType' => $pageNodeType, 'pageTheme' => $pageTheme, 'pageTitle' => sisParam('pageTitle'))) . '", null, "dialogWidth:350px;dialogMinHeight:110px;ajax:true;title:' . _LNG_PGM_SELECT_THEME . '"); // })()'); //} $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageId]; sisRaiseEvent('sis_page_manager', 'VIEW_PAGE_DESIGN', SIS_EVENT_TYPE_READ, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageType' => $nodeType, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageDetailId' => $pageId, 'dimensions' => $dimensions), 'VIEW_PAGE'); div(null, 'codeContainer' . ($pageIsDesign ? ' codeContainerDesign' : ''), 'style="height:100%"'); $hasMasterpage = false; $orgPageDetailRecord = null; if ($pageDetailRecord['sp_masterpage_id']) { $orgPageDetailRecord = $pageDetailRecord; $pageDetailRecord = sisRunQuery("SELECT * FROM saman_pages_detail WHERE sp_page_id = {$pageDetailRecord['sp_masterpage_id']} AND (sp_portal_id = $portalId OR sp_portal_id = 0)", true); $pageDetailRecord = $pageDetailRecord[0]; $hasMasterpage = true; } $selectedTemplate = ''; foreach ($pageLayouts as $template) { if ($template['template_id'] == $pageDetailRecord['sp_page_template']) { $selectedTemplate = $template['template_content']; break; } } if (unserialize($selectedTemplate)) { $selectedTemplate = unserialize($selectedTemplate); $selectedTemplate = $selectedTemplate[$pageLang] ? $selectedTemplate[$pageLang] : $selectedTemplate['all']; } $pageItemsTmp = sisServiceAPIFunc('pmk', 'admin', 'getPageItems', array('main_page_id' => $pageDetailRecord['sp_page_id'], 'page_id' => $pageDetailRecord['sp_page_detail_id'])); $pageItems = array(); foreach ($pageItemsTmp as $pageItem) { $pageItems[$pageItem['item_position']][] = $pageItem; } $masterPageItems = array(); if ($hasMasterpage) { $masterPageItemsTmp = sisServiceAPIFunc('pmk', 'admin', 'getPageItems', array('main_page_id' => $orgPageDetailRecord['sp_page_id'], 'page_id' => $orgPageDetailRecord['sp_page_detail_id'], 'masterpageItems' => true)); foreach ($masterPageItemsTmp as $masterPageItem) { $masterPageItems[$masterPageItem['item_container_id']][] = $masterPageItem; } } if (stripos($selectedTemplate, "panelStyle=")) { $selectedTemplate = str_replace("class=", "class_disable=", $selectedTemplate); $selectedTemplate = str_ireplace("style=", "style_disable=", $selectedTemplate); $selectedTemplate = str_ireplace("panelStyle_disable=", "style=", $selectedTemplate); } preg_match_all("/##zone:([0-9]*)##/", $selectedTemplate, $pageZones, PREG_PATTERN_ORDER); foreach($pageZones[0] as $idx => $zone) { $pageItemsBlocks = ''; foreach ($pageItems[$pageZones[1][$idx]] as $pageItem) { if (strpos($pageItem['item_title'], "#D:") === 0) { $pageItem['item_title'] = substr($pageItem['item_title'], 3, strlen($pageItem['item_title']) - 4); } if ($pageItem['item_bkey'] == 'masterpage_container') { $pageItemsBlocks .= '
    ' . _LNG_PGM_CONTAINER . ($pageItem['item_language'] ? " {$languages[$pageItem['item_language']]}" : "") . '
    '; foreach ($masterPageItems[$pageItem['item_bid']] as $masterPageItem) { $masterPageItemInfo = $this->getPageItemExtraInfo($masterPageItem); $pageItemsTmpResponsive = $masterPageItem['item_responsive_settings']; $classBlocks = $this->createBlockCssClass($pageItemsTmpResponsive); $pageItemsBlocks .= '
    ' . localizedStr($masterPageItem['item_title'], null, true, true) . '' . ($masterPageItem['item_language'] ? " {$languages[$masterPageItem['item_language']]}" : "") . '
    '; } $pageItemsBlocks .= '
    '; $masterPageItems[$pageItem['item_bid']] = null; } else { $pageItemInfo = $this->getPageItemExtraInfo($pageItem); $pageItemsTmpResponsive = $pageItem['item_responsive_settings']; $classBlocks = $this->createBlockCssClass($pageItemsTmpResponsive); $pageItemsBlocks .= '
    ' . $pageItem['item_bid'] . ' - ' . localizedStr($pageItem['item_title'], null, true, true) . '' . ($pageItem['item_language'] ? " {$languages[$pageItem['item_language']]}" : "") . '
    ' . (!$hasMasterpage ? '
    ' : '') . '
    '; } } $selectedTemplate = str_replace($zone, "
    " . _LNG_PGM_ZONE . " {$pageZones[1][$idx]}
    $pageItemsBlocks
    " . (!$hasMasterpage ? "
    " : "") . "
    ", $selectedTemplate); $pageItems[$pageZones[1][$idx]] = null; } $hiddenPageBlocks = ''; foreach ($hasMasterpage ? $masterPageItems : $pageItems as $hiddenPageItems) { if (is_array($hiddenPageItems)) { foreach ($hiddenPageItems as $hiddenPageItem) { if (strpos($hiddenPageItem['item_title'], "#D:") === 0) { $hiddenPageItem['item_title'] = substr($hiddenPageItem['item_title'], 3, strlen($hiddenPageItem['item_title']) - 4); } $pageItemInfo = $this->getPageItemExtraInfo($hiddenPageItem); $pageItemsTmpResponsive = $hiddenPageItem['item_responsive_settings']; $classBlocks = $this->createBlockCssClass($pageItemsTmpResponsive); $hiddenPageBlocks .= '
    ' . localizedStr($hiddenPageItem['item_title'], null, true, true) . '' . ($hiddenPageItem['item_language'] ? " {$languages[$hiddenPageItem['item_language']]}" : "") . '
    '; } } } if ($hiddenPageBlocks) { $selectedTemplate .= "
    " . _LNG_PGM_HIDDEN_PAGE_ITEMS . "
    $hiddenPageBlocks
    "; } div(null, 'pgmDesignerContainer' . ($hasMasterpage ? ' pgmMasterpageContainer' : '')); echo $selectedTemplate; div_(); div_(); ob_start(); div(null, 'sisDataForm'); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_PROPERTIES_TITLE); sisCaption_(); sisData(array('extraClass' => 'pgmBITitle')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_WD_ID); sisCaption_(); sisData(array('extraClass' => 'pgmBIId')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_SERVICE); sisCaption_(); sisData(array('extraClass' => 'pgmBIParentService')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_BLOCK); sisCaption_(); sisData(array('extraClass' => 'pgmBIParentBlock')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_SERVICE_BASE); sisCaption_(); sisData(array('extraClass' => 'pgmBIBaseService')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_BLOCK_BASE); sisCaption_(); sisData(array('extraClass' => 'pgmBIBaseBlock')); sisData_(); sisFormGroup_(); div_(); $info = ob_get_clean(); t(sisModalMessage('pgmBlockInfo', ' ' . _LNG_PGM_BLOCK_INFO, $info, '30%', null, true)); script(); t('(function() { var toolbarHeight = $(".pgmDesignerContainer").prev().outerHeight(true); if (!toolbarHeight) { toolbarHeight = "0"; } $(".pgmDesignerContainer").height("calc(100% - " + toolbarHeight + "px)"); $(".codeContainer").disableSelection(); $(".codeContainer").find("input, select") .bind("mousedown.ui-disableSelection selectstart.ui-disableSelection", function(e) { e.stopImmediatePropagation(); }); $(".pgmDragDropContainer").sortable({ placeholder : "pgmPageItemPlaceholder", connectWith : ".pgmDragDropContainer", scroll : true, refreshPositions : true, appendTo : ".pgmDesignerContainer", containment : "window", helper : "clone" }); $(".pgmDragDropContainer").droppable({ activate: function(e, ui) { $(".pgmPageItemPlaceholder").attr("class", "pgmPageItemPlaceholder " + ui.draggable.attr("class")); }, drop: function (e, ui) { if (!ui.draggable.hasClass("ui-sortable-handle")) { return; } setTimeout(function() { pgmDisableAll(); var eventId = sisAdminPanel.addEventListener("loadURLEnd", function() { pgmEnableAll(); sisAdminPanel.removeEventListener("loadURLEnd", eventId); }); var param = ""; var $itemContainer = ui.draggable.closest(".pgmMasterpageContainer, .pgmZone"); if ($itemContainer.hasClass("pgmZone")) { param = "&pageZoneId=" + $itemContainer.attr("pgmId"); } else { param = "&masterpageContainerId=" + $itemContainer.attr("pgmId"); } changeWindowLocation(ui.draggable.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'pageAction', array('pageWdId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageNodeType' => $pageNodeType, 'pageTheme' => $pageTheme, 'pageTitle' => urlencode(sisParam('pageTitle')))) . '&pmgAction=movePageItem&pageItemId=" + ui.draggable.find(".pgmPageItem").attr("data-blockId") + param + "&sisAPHiddenRequest=true&pagePreviousItemId=" + ui.draggable.prev().find(".pgmPageItem").attr("data-blockId") || 0); }, 100); } }); $(".codeContainer").parent().css("overflow", "hidden"); $(".pgmPageItem i[rel=properties]").click(function(e) { changeWindowLocation(this, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_PROPERTIES_WD_ID . '&pageItemId=" + $(this).closest(".pgmPageItem").attr("pgmId") + "&pageWdId=' . $pageWdId . '&pageLang=' . $pageLang . '&sisAPNewWindow=true&sisAPWindowSize=6", true); //showModalDialog("index.php?module=web_directory&wd_id=' . _PGM_BLOCK_PROPERTIES_WD_ID . '&pageItemId=" + $(this).closest(".pgmPageItem").attr("pgmId") + "&pageWdId=' . $pageWdId . '&pageLang=' . $pageLang . '&sisAPNewWindow=true", null, "dialogWidth:90%;dialogHeight:70%;ajax:true;title:' . _LNG_PGM_PAGE_BLOCK_PROPERTIES . '"); }); $(".pgmPageItem i[rel=perms]").click(function(e) { changeWindowLocation(this, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_PERMS_WD_ID . '&pageItemId=" + $(this).closest(".pgmPageItem").attr("pgmId") + "&pageWdId=' . $pageWdId . '&pageLang=' . $pageLang . '&sisAPNewWindow=true&sisAPWindowSize=4", true); }); $(".pgmPageItem i[rel=info]").click(function(e) { var $infoDialog = $("#pgmBlockInfo"); $infoDialog.find(".pgmBITitle").text($(this).closest(".pgmPageItem").find(".pgmPageItemHeader span:first").text()); $infoDialog.find(".pgmBIId").text($(this).closest(".pgmPageItem").attr("data-blockId")); $infoDialog.find(".pgmBIBaseService").text($(this).closest(".pgmPageItem").attr("data-baseService")); $infoDialog.find(".pgmBIBaseBlock").text($(this).closest(".pgmPageItem").attr("data-baseBlock")); $infoDialog.find(".pgmBIParentService").text($(this).closest(".pgmPageItem").attr("data-parentService")); $infoDialog.find(".pgmBIParentBlock").text($(this).closest(".pgmPageItem").attr("data-parentBlock")); sisShowModal("#pgmBlockInfo"); }); $(".pgmPageItem i[rel=delete]").click(function(e) { var $pageItem = $(this).closest(".pgmPageItem"); sisConfirm("' . _LNG_PGM_DELETE_PAGE_ITEM_CONFIRM . '", null, null, function() { sisAdminPanel.startLoading(); $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deletePageItem') . '&pageItemId=" + $pageItem.attr("data-blockId") + "&pageWdId=' . $pageWdId . '"), function(data) { $pageItem.remove(); showPortalMessage("' . _GLB_OPERATION_DONE . '"); }) .always(function() { sisAdminPanel.stopLoading(); }); }); }); $(".pgmPageItem i[rel=export]").click(function(e) { var $pageItem = $(this).closest(".pgmPageItem"); window.open(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'exportBlock') . '&pageItemId=" + $pageItem.attr("data-blockId") + "&pageWdId=' . $pageWdId . '"), "_blank"); }); $(".pgmZone .pgmZoneOperation i[rel=addBlock], .pgmMasterOperation i[rel=addBlock]").click(function(e) { var $itemContainer = $(this).closest(".pgmMasterpageContainer, .pgmZone"); var param = "&pageWdId=' . $pageWdId . '"; if ($itemContainer.hasClass("pgmZone")) { param += "&zoneId=" + $itemContainer.attr("data-zoneId"); } else { param += "&masterpageContainerId=" + $itemContainer.attr("pgmId"); } showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addBlockUI') . '&showAllModule=1&pageDetailId=" + $itemContainer.attr("data-pageDetailId") + param + "&windowId=" + $(this).closest(".sisAPWindow").attr("id") + "&includeMasterpage=0", null, "dialogWidth:70%;dialogHeight:500px;ajax:true;title:' . _LNG_PGM_ADD_BLOCK_PAGE . '"); }); $(".pgmZone .pgmZoneOperation i[rel=zoneAction], .pgmMasterOperation i[rel=zoneAction]").click(function(e) { var $itemContainer = $(this).closest(".pgmMasterpageContainer, .pgmZone"); var param = "&pageWdId=' . $pageWdId . '"; if ($itemContainer.hasClass("pgmZone")) { param += "&zoneId=" + $itemContainer.attr("data-zoneId"); } else { param += "&masterpageContainerId=" + $itemContainer.attr("pgmId"); } showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'zoneAction') . '&pageLang=' . $pageLang . '&pageDetailId=" + $itemContainer.attr("data-pageDetailId") + param, null, "dialogWidth:50%;dialogHeight:400px;ajax:true;title:' . _LNG_PGM_ZONE_ACTION . '"); }); function pgmDisableAll() { $(".codeContainer select").prop("disabled", true); $(".pgmDesignerContainer").not(".pgmMasterpageContainer").find(".pgmZoneContainer").sortable("disable"); } function pgmEnableAll() { $(".codeContainer select").prop("disabled", false); $(".pgmDesignerContainer").not(".pgmMasterpageContainer").find(".pgmZoneContainer").sortable("enable"); } })();'); script_(); sisEventLogView(array('subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $orgPageDetailRecord['sp_page_detail_id'] ? $orgPageDetailRecord['sp_page_detail_id'] : $pageDetailRecord['sp_page_detail_id'])); sisDie(); } function getPageItem($pageItemId, $params = array(), $portalId = null) { if (!intval($pageItemId)) { return null; } if ($portalId === null) { $portalId = sisGlobal('portal_id'); } $record = sisRunQuery("SELECT * FROM saman_page_items WHERE sp_bid = " . intval($pageItemId) . " AND sp_portal_id = " . intval($portalId), true); return $record[0]; } function rearrangePageItems($pageDetailId, $params = array(), $portalId = null) { $pageDetailId = intval($pageDetailId); if (!$pageDetailId) { return false; } if ($portalId === null) { $portalId = sisGlobal('portal_id'); } $records = sisRunQuery("SELECT sp_bid FROM saman_page_items WHERE sp_page_id = $pageDetailId AND sp_portal_id = " . intval($portalId) . " ORDER BY sp_weight", true); $index = 1; foreach($records as $record) { $sqlStr = "UPDATE saman_page_items SET sp_weight = $index WHERE sp_bid = $record[sp_bid] AND sp_portal_id = " . intval($portalId); if ($params['sqlObj']) { $params['sqlObj']->setSql($sqlStr); if (!$params['sqlObj']->runQuery()) { return false; } } else { if (!sisRunQuery($sqlStr)) { return false; } } $index++; } return true; } function getPageItemExtraInfo($pageItem) { $result = array(); $result['blockBaseService'] = '-'; $result['blockBaseBlock'] = '-'; $result['blockParentService'] = '-'; $result['blockParentBlock'] = '-'; if ($pageItem['item_mid']) { $modInfo = sisServiceGetInfo($pageItem['item_mid']); $baseBlockInfo = sisPortletLoad($modInfo['name'], $pageItem['item_bkey']); $result['blockBaseService'] = sisConstant($modInfo['name']); $result['blockBaseBlock'] = localizedStr($baseBlockInfo['default_title'] ? $baseBlockInfo['default_title'] : $baseBlockInfo['text_type_long']); } else if ($pageItem['item_bkey'] == 'shareblock') { $parentBlockInfo = sisPortletGetInfo($pageItem['item_content']); $result['blockBaseService'] = _LNG_PGM_GLOBAL_BLOCK; $result['blockBaseBlock'] = localizedStr($parentBlockInfo['default_title'] ? $parentBlockInfo['default_title'] : $parentBlockInfo['title']); } else { $baseBlockInfo = sisPortletLoad('Core', $pageItem['item_bkey']); $result['blockBaseService'] = _LNG_PGM_GLOBAL_BLOCK; $result['blockBaseBlock'] = localizedStr($baseBlockInfo['default_title'] ? $baseBlockInfo['default_title'] : $baseBlockInfo['text_type_long']); } if ($pageItem['item_block_id']) { $parentBlockInfo = sisPortletGetInfo($pageItem['item_block_id']); if ($parentBlockInfo['ctp_id']) { $parentService = getContentType($parentBlockInfo['ctp_id']); $result['blockParentService'] = localizedStr($parentService['title']); } $result['blockParentBlock'] = localizedStr($parentBlockInfo['title']); } return $result; } function duplicateNodePage($parentPageId, $pageWdId, $pageNodeType, $pageChannel, $pageLang, $parentPageChannel = null, $parentPageLang = null, $pageIsDesign = 0, $parentPageIsDesign = null) { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return false; } $portalId = sisGlobal('portal_id'); $parentPageId = intval($parentPageId); $pageWdId = intval($pageWdId); $pageNodeType = $pageNodeType; $pageChannel = intval($pageChannel); $pageLang = $pageLang; $pageIsDesign = intval($pageIsDesign); $parentPageChannel = $parentPageChannel === null ? $pageChannel : intval($parentPageChannel); $parentPageLang = $parentPageLang === null ? $pageLang : $parentPageLang; $parentPageIsDesign = $parentPageIsDesign === null ? $pageIsDesign : $parentPageIsDesign; if (!$parentPageId || !$pageWdId || !$pageNodeType || !$pageLang) { return false; } switch ($pageNodeType) { case 'node'; $wdPageField = 'sp_node_page_id'; break; case 'view'; $wdPageField = 'sp_view_page_id'; break; case 'edit'; $wdPageField = 'sp_edit_page_id'; break; } if (!$wdPageField) { return false; } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { return false; } if ($wdInfo['wd_pages'][$pageNodeType]) { $pageId = $wdInfo['wd_pages'][$pageNodeType]; $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages WHERE sp_page_id = $pageId AND sp_portal_id = $portalId", true); if (!$record[0]['rec_count']) { $pageId = 0; } } if (!$pageId) { $pageId = sisServiceAPIFunc('pmk', 'admin', 'createPage', array( 'page_show_in_menu' => 0, 'page_code' => "page_{$pageWdId}_{$pageIsDesign}_{$pageNodeType}_{$pageChannel}_{$pageLang}", 'page_type' => $pageNodeType, 'page_portal_id' => $portalId )); if (!$pageId) { die(); } } $record = sisRunQuery("SELECT sp_page_id FROM saman_pages_detail WHERE sp_page_id = $pageId AND sp_language = '" . ($pageLang != 'all' ? sisVarPrepForStore($pageLang) : '' ) . "' AND sp_device = $pageChannel AND sp_portal_id = $portalId", true); if ($record[0]['sp_page_id']) { return true; } $record = sisRunQuery("SELECT * FROM saman_pages_detail WHERE sp_page_id = $parentPageId AND sp_language = '" . ($parentPageLang != 'all' ? sisVarPrepForStore($parentPageLang) : '' ) . "' AND sp_device = $parentPageChannel AND sp_portal_id = $portalId", true); if (!$record[0]['sp_page_id']) { return false; } $pageDetailId = sisServiceAPIFunc('pmk', 'admin', 'createPageDetail', array( 'page_id' => $pageId, 'page_language' => $pageLang, 'page_device' => $pageChannel, 'page_status' => $record[0]['sp_status'], 'page_layout_template_id' => $record[0]['sp_layout_template'], 'page_show_title' => $record[0]['sp_page_show_title'], 'page_page_template_id' => $record[0]['sp_page_template'], 'page_deletable' => $record[0]['sp_deletable'], 'master_page' => $record[0]['sp_masterpage_id'] )); sisRunQuery("INSERT INTO saman_page_items ( sp_page_id, sp_bkey, sp_title, sp_content, sp_type, sp_mid, sp_position, sp_weight, sp_active, sp_collapsable, sp_refresh, sp_last_update, sp_language, sp_title_link, sp_header, sp_footer, sp_template, sp_block_id, sp_conditions, sp_portal_id, sp_property_values, sp_block_css_class, sp_is_css_sprite, sp_css_sprite_class, sp_header_image, sp_footer_image, sp_back_image, sp_back_image_position, sp_back_image_repeat, sp_header_image_position, sp_footer_image_position, sp_container_id, _import_id ) SELECT $pageDetailId as sp_page_id, itm.sp_bkey, itm.sp_title, itm.sp_content, itm.sp_type, itm.sp_mid, itm.sp_position, itm.sp_weight, itm.sp_active, itm.sp_collapsable, itm.sp_refresh, NOW() as sp_last_update, itm.sp_language, itm.sp_title_link, itm.sp_header, itm.sp_footer, itm.sp_template, itm.sp_block_id, itm.sp_conditions, itm.sp_portal_id, itm.sp_property_values, itm.sp_block_css_class, itm.sp_is_css_sprite, itm.sp_css_sprite_class, itm.sp_header_image, itm.sp_footer_image, itm.sp_back_image, itm.sp_back_image_position, itm.sp_back_image_repeat, itm.sp_header_image_position, itm.sp_footer_image_position, itm.sp_container_id, itm.sp_bid as _import_id FROM saman_page_items itm INNER JOIN saman_pages_detail dtl ON (itm.sp_page_id = dtl.sp_page_detail_id AND itm.sp_portal_id = dtl.sp_portal_id) WHERE dtl.sp_page_id = $parentPageId AND dtl.sp_language = '" . ($parentPageLang != 'all' ? sisVarPrepForStore($parentPageLang) : '') . "' AND dtl.sp_portal_id = $portalId "); $itemsRecord = sisRunQuery("SELECT sp_bid, _import_id FROM saman_page_items WHERE sp_page_id = $pageDetailId AND sp_portal_id = $portalId", true); foreach ($itemsRecord as $record) { if (is_dir(PORTAL_DATA_PATH . 'sis_page_manager/block_images/' . $record['_import_id'])) { @mjdir(PORTAL_DATA_PATH . 'sis_page_manager/block_images/' . $record['sp_bid']); sisCopy(PORTAL_DATA_PATH . 'sis_page_manager/block_images/' . $record['_import_id'], PORTAL_DATA_PATH . 'sis_page_manager/block_images/' . $record['sp_bid']); } } sisRunQuery("UPDATE saman_page_items SET _import_id = null WHERE sp_page_id = $pageDetailId AND sp_portal_id = $portalId"); if (!$wdInfo['wd_pages'][$pageNodeType]) { sisRunQuery(" UPDATE saman_web_directories SET $wdPageField = $pageId WHERE sp_id = $pageWdId AND sp_portal_id = $portalId AND sp_lang = " . ($pageLang != "all" ? "'" . sisVarPrepForStore($pageLang) . "'" : "null")); } $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageDetailId]; sisRaiseEvent('sis_page_manager', 'CREATE_PAGE', SIS_EVENT_TYPE_CREATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageId' => $pageId, 'pageType' => $pageNodeType, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageDetailId' => $pageId, 'originPageDetailId' => $parentPageId, 'dimensions' => $dimensions)); return $pageDetailId; } function layoutTemplatesList() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return false; } $portalId = sisGlobal('portal_id'); $templates = sisRunQuery("SELECT * FROM saman_page_layout_templates WHERE sp_portal_id = $portalId", true); t(''); usort($templates, function ($a, $b) {return localizedStr($a['sp_title']) >= localizedStr($b['sp_title']);}); sisRaiseEvent('sis_page_manager', 'VIEW_LAYOUT_TEMPLATES', SIS_EVENT_TYPE_READ); table('100%', 0, 'class="list sisDataListTable" cellspacing="0" cellpadding="5" data-auto-height=true'); t(''); tr(); th(null, 'style="text-align:'.notAlign().';" colspan=5'); t(''); th_(); tr_(); tr(); th('list-header-etc', "width='5%' style='text-align:center'"); if (count($templates) > 0) { t(''); } th_(); th('list-header-etc', "data-sortable=true"); t(_LNG_PGM_TITLE); th_(); th('list-header-etc', "width='10%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_IS_SYSTEM); th_(); th('list-header-etc', "width='25%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_LAST_MODIFIED_DATE); th_(); th('list-header-etc', "width='13%' style='text-align:center'"); t(_LNG_PGM_OPERATION); th_(); tr_(); t(''); foreach($templates as $template) { $trClass = 'sp-odd'; $tdClass = 'listrow1'; if ($i % 2 != 0) { $trClass = 'sp-even'; $tdClass = 'listrow2'; } tr("trThmListRow $trClass"); td($tdClass); if (!$template['sp_is_system'] || sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { t(''); } td_(); td($tdClass); t(localizedStr($template['sp_title'])); td_(); td($tdClass); t($template['sp_is_system'] ? '*' : ''); td_(); td($tdClass); $template['sp_reg_date'] = explode(" ", $template['sp_reg_date']); t(sisFormat($template['sp_reg_date'][0], sisGetLocalizedDateFormat(), 'GREGORIANDATE', true)); t(" - "); $template['sp_reg_date'][1] = explode(":", $template['sp_reg_date'][1]); array_pop($template['sp_reg_date'][1]); $template['sp_reg_date'][1] = implode($template['sp_reg_date'][1], ":"); t(sisFormat($template['sp_reg_date'][1], null, null, true)); td_(); td($tdClass); a('index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_EDIT_WD_ID . '&sisAPTabsheetName=pgmTemplateDesignTab&sisAPWindowSize=4&templateId=' . $template['sp_page_id']); sisEditIcon(); a_(); if (!$template['sp_is_system'] || sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { nbsp(); a('#a', 'onclick="sisConfirm(\'' . _LNG_PGM_TEMPLATE_DELETE_CONFIRM . '\', null, null, function() {changeWindowLocation(this, \'index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_EDIT_WD_ID . '&templateId=' . $template['sp_page_id'] . '&sisOp=del\')});"'); sisDeleteIcon(); a_(); } td_(); tr_(); $i++; } if (count($template) > 0) { t(''); tr(); td(null, 'colspan=5'); t(''); td_(); tr_(); t(''); } table_(); script(); t('function pgmPageTemplateSearchKeyUp(obj, e) { var rows = $(obj).closest(".list").find("tr.trThmListRow"); if (!$(obj).val()) { rows.show(); return; } rows.hide(); rows.each(function() { if ($(this).text().toLowerCase().indexOf($(obj).val().toLowerCase()) != -1) { $(this).show(); } }); return true; } function pgmTemplateSelectAll(obj) { var $checkBoxes = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]"); $checkBoxes.prop("checked", $(obj).prop("checked")); $checkBoxes.each(function() { if ($(this).prop("checked")) { $(this).closest("tr").addClass("sisAPActive"); } else { $(this).closest("tr").removeClass("sisAPActive"); } }); } function pgmTemplateSelectRow(obj) { $(obj).closest("tr").toggleClass("sisAPActive"); } function pgmTemplateDeleteMultiple(obj) { var $items = $(obj).closest("table").find("input[type=checkbox][value]:checked"); if ($items.length == 0) { sisAlert("' . _LNG_PGM_DELETE_SELECTED_EMPTY . '"); return; } sisConfirm("' . _LNG_PGM_DELETE_SELECTED_CONFIRM . '", null, null, function() { var items = new Array(); $items.each(function() { items.push($(this).val()); }); changeWindowLocation(obj, "index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_EDIT_WD_ID . '&templateId=" + items.join(",") + "&sisOp=del"); }); } '); script_(); sisDie(); } function designLayoutTemplate() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $templateId = sisParam('templateId'); if ($templateId && sisParam('sisOp') == 'del') { $templateIds = explode(',', $templateId); foreach ($templateIds as $templateId) { $template = sisServiceAPIFunc('pmk', 'admin', 'gettemplate', array('template_id' => $templateId, 'rawTemplate' => true)); if (!$template || ($template['is_system'] && !sisCheckUserLicense(PORTAL_CORE_DEVELOPER))) { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_LAYOUT_TEMPLATE_LIST_WD_ID, true); } $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages_detail WHERE sp_page_template = $templateId", true); if ($record[0]['rec_count']) { sisRaiseException(_LNG_PGM_TEMPLATE_DELETE_ERROR . '[' . localizedStr($template['title']) . ']'); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_LAYOUT_TEMPLATE_LIST_WD_ID, true); } sisServiceAPIFunc('pmk', 'admin', 'deletetemplate', array('template_id' => $templateId)); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'layoutTemplateId', 'value' => $templateId]; sisRaiseEvent('sis_page_manager', 'DELETE_LAYOUT_TEMPLATE', SIS_EVENT_TYPE_DELETE, array('objectName' => "Layout template : " . localizedStr($template['title']), 'objectId' => $template['id'], 'dimensions' => $dimensions)); } sisSetStatusMsg(); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_LAYOUT_TEMPLATE_LIST_WD_ID, true); } $templateId = intval($templateId); if (sisParam('REQUEST_METHOD') == 'POST') { $templateContent = json_decode(sisParam('pgmTemplateContent'), true); $templateContent[sisParam('pgmTemplateLanguage')] = sisParam('pgmTemplateBody'); $record = array(); $record['template_id'] = $templateId; $record['template_title'] = sisParam('pgmTemplateTitle'); $record['template_content'] = serialize($templateContent); if (sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { $record['template_is_system'] = intval(sisParam('pgmTemplateIsSystem')); } if ($templateId) { $oldRecord = sisServiceAPIFunc('pmk', 'admin', 'gettemplate', array('template_id' => $templateId, 'rawTemplate' => true)); if (sisServiceAPIFunc('pmk', 'admin', 'edittemplate', $record)) { $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'layoutTemplateId', 'value' => $record['template_id']]; sisRaiseEvent('sis_page_manager', 'EDIT_LAYOUT_TEMPLATE', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Layout template : " . localizedStr($record['template_title']), 'objectId' => $record['template_id'], 'newRecord' => $record, 'oldRecord' => $oldRecord, 'dimensions' => $dimensions)); sisSetStatusMsg(); } else { sisRaiseException(_LNG_PGM_TEMPLATE_NAME_EXISTS); } } else { $templateId = sisServiceAPIFunc('pmk', 'admin', 'createtemplate', $record); if ($templateId) { sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'layoutTemplateId', 'value' => $templateId]; sisRaiseEvent('sis_page_manager', 'CREATE_LAYOUT_TEMPLATE', SIS_EVENT_TYPE_CREATE, array('objectName' => "Layout template : " . localizedStr($record['template_title']), 'objectId' => $templateId, 'newRecord' => $record, 'dimensions' => $dimensions)); sisRefreshParentWindow(false, false); } else { sisRaiseException(_LNG_PGM_TEMPLATE_NAME_EXISTS); } } } $template = sisServiceAPIFunc('pmk', 'admin', 'gettemplate', array('template_id' => $templateId, 'rawTemplate' => true)); if ($templateId && !$template) { die(); } $languages = getLanguages(); $languages = array('all' => _LNG_PGM_ALL_LANGS) + $languages; $templateLang = sisParam('pgmTemplateLang'); if ($template) { sisSetPageTitle(localizedStr($template['title'])); } else { sisSetPageTitle(_LNG_PGM_NEW_TEMPLATE); } if (!is_array($template['content'])) { $template['content'] = array('all' => $template['content']); } $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'layoutTemplateId', 'value' => $template['id']]; sisRaiseEvent('sis_page_manager', 'VIEW_LAYOUT_TEMPLATE', SIS_EVENT_TYPE_READ, array('objectName' => "Layout template : " . localizedStr($template['title']), 'objectId' => $template['id'], 'dimensions' => $dimensions)); sisPage(NULL, NULL, false); form('pgmFrmLayoutTemplate', 'index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_EDIT_WD_ID . '&templateId=' . $templateId, null, null, null, "class='sisDataForm' style='height:100%' " . ($template['id'] ? 'sisAPSilentSubmit=true' : '')); ob_start(); table('100%', 0, 'class="sisForm sisDataForm"'); tr(); td('caption', 'style="width:10%"'); t(_LNG_PGM_TITLE . ':'); td_(); td('data', 'style="width:30%"'); Edit('pgmTemplateTitle', localizedStr($template['title']), 10, 'style="width: 150px;"', null, 'REQUIRE'); td_(); td('caption', 'style="width:10%"'); t(_LNG_PGM_LANG . ':'); td_(); td('data', 'style="width:30%"'); t(''); td_(); if (sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { td('caption', 'style="width:10%"'); t(_LNG_PGM_IS_SYSTEM . ':'); td_(); td('data'); t(''); td_(); } else { td(); td_(); } tr_(); table_(); $formContent = ob_get_clean(); div(null, 'divPgmtplBody sisCodeEditorContainer', 'style="height:98%"'); sisCodeEditor('pgmTemplateBody', '100%', 'auto', 'html', null, null, null, $formContent); textArea('pgmTemplateBody'); t(htmlspecialchars($template['content']['all'] ? $template['content']['all'] : sisParam('pgmTemplateBody'))); textArea_(); sisCodeEditor_(); div_(); hidden("pgmTemplateContent", json_encode($template['content']), false, 'id="pgmTemplateContent"'); operationBar(_LNG_THM_SAVE); form_(); script(); t('(function() { var templateContent = ' . json_encode($template['content']) . '; var lastSelectedLang = "all"; var editorObj = ace.edit("divpgmTemplateBody"); $(".divPgmtplBody .tmplEditorBtn").removeClass("tmplEditorBtn"); $(".divPgmtplBody #pgmTemplateLanguage").change(function() { var tmpContent = jQuery.parseJSON($("#pgmTemplateContent").val()); tmpContent[lastSelectedLang] = editorObj.getValue(); editorObj.setValue(tmpContent[$(this).val()] || "", -1); lastSelectedLang = $(this).val(); $("#pgmTemplateContent").val(JSON.stringify(tmpContent)); }) })(); '); beginCheckForm('pgmFrmLayoutTemplate'); jsCheckNotNull("pgmTemplateTitle", _LNG_PGM_TEMPLATE_TITLE_MANDATORY); endCheckForm(); script_(); sisPage_(); sisDie(); } function masterPagesList() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return false; } $portalId = sisGlobal('portal_id'); $masterpages = sisRunQuery("SELECT * FROM saman_pages WHERE sp_is_master = 1 AND sp_portal_id = $portalId ORDER BY sp_code", true); //t(''); sisRaiseEvent('sis_page_manager', 'VIEW_MASTER_PAGES', SIS_EVENT_TYPE_READ); table('100%', 0, 'class="list sisDataListTable table-no-bordered" cellspacing="0" cellpadding="5" data-search=true data-auto-height=true'); t(''); tr(); th('list-header-etc', "width='5%' style='text-align:center'"); $menuItems = array(); $menuItems[] = array( 'action' => "pgmNewMasterpage(event, this)", 'icon' => 'fa-plus', 'hint' => _LNG_PGM_NEW_MASTERPAGE ); if (count($masterpages) > 0) { t(''); $menuItems[] = array( 'action' => "pgmMasterpageDeleteMultiple(this)", 'icon' => 'fa-close', 'hint' => _LNG_PGM_DELETE_SELECTED_ITMES ); } sisAddToListOperationBar($menuItems); th_(); th('list-header-etc', "data-sortable=true"); t(_LNG_PGM_NAME); th_(); th('list-header-etc', "width='10%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_IS_SYSTEM); th_(); th('list-header-etc', "width='25%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_REGISTER_DATE); th_(); th('list-header-etc', "width='13%' style='text-align:center'"); t(_LNG_PGM_OPERATION); th_(); tr_(); t(''); foreach($masterpages as $masterpage) { $trClass = 'sp-odd'; $tdClass = 'listrow1'; if ($i % 2 != 0) { $trClass = 'sp-even'; $tdClass = 'listrow2'; } tr("trThmListRow $trClass"); td($tdClass); if (!$masterpage['sp_is_system'] || sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { t(''); } td_(); td($tdClass); t(localizedStr($masterpage['sp_code'])); td_(); td($tdClass); t($masterpage['sp_is_system'] ? '*' : ''); td_(); td($tdClass); t(sisFormat(sisDisplayDateTime($masterpage['sp_reg_date']))); /*$masterpage['sp_reg_date'] = explode(" ", $masterpage['sp_reg_date']); t(sisFormat($masterpage['sp_reg_date'][0], sisGetLocalizedDateFormat(), 'GREGORIANDATE', true)); t(" - "); $masterpage['sp_reg_date'][1] = explode(":", $masterpage['sp_reg_date'][1]); array_pop($masterpage['sp_reg_date'][1]); $masterpage['sp_reg_date'][1] = implode($masterpage['sp_reg_date'][1], ":"); t(sisFormat($masterpage['sp_reg_date'][1], null, null, true));*/ td_(); td($tdClass); $items = array(); $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_PAGE ; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&sisAPTabsheetName=pgmMasterpageDesignTab&sisAPWindowSize=5&masterpageId=' . $masterpage['sp_page_id']; $items[] = $item; $item = array(); $item['icon'] = 'fa-clone fa-fw'; $item['title'] = _LNG_PGM_COPY_PAGE_ACTION; $item['action'] = 'sisPrompt("' . _LNG_PGM_ENTER_MASTERPAGE_NAME . '", "", "", function(pageNewTitle) { if (pageNewTitle.trim()) { pageNewTitle = pageNewTitle.trim(); var re = new RegExp("[A-Za-z_0-9\\-\\.]*"); if (pageNewTitle != re.exec(pageNewTitle)) { sisAlert("' . _LNG_PGM_NAME_MUST_ENGLISH . '"); return false; } changeWindowLocation(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'duplicateMaterpage', 'masterpageId=' . $masterpage['sp_page_id'] . '&backWdId=' . _PGM_MASTERPAGE_LIST_WD_ID . '©=1&masterpageNewTitle=" + pageNewTitle') . '); } else { sisAlert("' . _LNG_PGM_PAGE_TITLE_MANDATORY . '"); return false; } });'; $items[] = $item; if (!$masterpage['sp_is_system'] || sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { $item = array(); $item['icon'] = 'fa-remove fa-fw'; $item['title'] = _SIS_LIB_DELETE; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . _LNG_PGM_MASTERPAGE_DELETE_CONFIRM . '\', null, null, function() {changeWindowLocation(this, \'index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&masterpageId=' . $masterpage['sp_page_id'] . '&sisOp=del\')});"'; $items[] = $item; } sisListOperationMenu(false, $items); /*a('index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&sisAPTabsheetName=pgmMasterpageDesignTab&sisAPWindowSize=5&masterpageId=' . $masterpage['sp_page_id']); sisEditIcon(); a_(); if (!$masterpage['sp_is_system'] || sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { nbsp(); a('#a', 'onclick="sisConfirm(\'' . _LNG_PGM_MASTERPAGE_DELETE_CONFIRM . '\', null, null, function() {changeWindowLocation(this, \'index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&masterpageId=' . $masterpage['sp_page_id'] . '&sisOp=del\')});"'); sisDeleteIcon(); a_(); }*/ td_(); tr_(); $i++; } /*if (count($masterpages) > 0) { t(''); tr(); td(null, 'colspan=5'); t(''); td_(); tr_(); t(''); }*/ table_(); script(); t(' function pgmNewMasterpage(e, obj) { sisPrompt("' . _LNG_PGM_ENTER_MASTERPAGE_NAME . '", null, null, function(name) { name = name.trim(); var re = new RegExp("[A-Za-z_0-9\\-\\.]*"); if (!name || name != re.exec(name)) { sisAlert("' . _LNG_PGM_NAME_MUST_ENGLISH . '"); return false; } changeWindowLocation(obj, "index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&sisAPTabsheetName=pgmMasterpageDesignTab&sisAPWindowSize=5&sisOp=new&masterpageName=" + name, true); }) } function pgmMasterpageSelectAll(obj) { var $checkBoxes = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]"); $checkBoxes.prop("checked", $(obj).prop("checked")); $checkBoxes.each(function() { if ($(this).prop("checked")) { $(this).closest("tr").addClass("sisAPActive"); } else { $(this).closest("tr").removeClass("sisAPActive"); } }); } function pgmMasterpageSelectRow(obj) { $(obj).closest("tr").toggleClass("sisAPActive"); } function pgmMasterpageDeleteMultiple(obj) { var $items = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]:checked"); if ($items.length == 0) { sisAlert("' . _LNG_PGM_DELETE_SELECTED_EMPTY . '"); return; } sisConfirm("' . _LNG_PGM_DELETE_SELECTED_CONFIRM . '", null, null, function() { var items = new Array(); $items.each(function() { items.push($(this).val()); }); changeWindowLocation(obj, "index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&masterpageId=" + items.join(",") + "&sisOp=del"); }); } '); script_(); sisEventLogView(array('eventTypes' => array( 'sis_page_manager:CREATE_MASTER_PAGE', 'sis_page_manager:EDIT_MASTER_PAGE', 'sis_page_manager:DELETE_MASTER_PAGE', 'sis_page_manager:VIEW_MASTER_PAGE', ))); } function designMasterpage() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return false; } $masterpageId = sisParam('masterpageId'); sisServiceAPIFunc('sis_masterpage_manager', 'updateLastViewTime', array(intval($masterpageId))); $portalId = sisGlobal('portal_id'); $pageTheme = sisParam('pageTheme') ? sisParam('pageTheme') : sisUserGetTheme(); $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; if ($masterpageId && sisParam('sisOp') == 'del') { $masterpageIds = explode(',', $masterpageId); foreach ($masterpageIds as $masterpageId) { $masterpageRecord = sisRunQuery("SELECT * FROM saman_pages WHERE sp_page_id = $masterpageId AND sp_portal_id = $portalId AND sp_is_master = 1", true); if (!$masterpageRecord[0]['sp_page_id'] || ($masterpageRecord[0]['sp_is_system'] && !sisCheckUserLicense(PORTAL_CORE_DEVELOPER))) { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_MASTERPAGE_LIST_WD_ID, true); } $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages_detail WHERE sp_masterpage_id = $masterpageId", true); if ($record[0]['rec_count']) { sisRaiseException(_LNG_PGM_MASTERPAGE_DELETE_ERROR . '[' . localizedStr($masterpageRecord[0]['sp_code']) . ']'); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_MASTERPAGE_LIST_WD_ID, true); } foreach ($languages as $langKey => $langTitle) { $this->deletePage($masterpageId, $langKey, $portalId); } $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId' , 'value'=> $masterpageRecord[0]['sp_page_id']]; sisRaiseEvent('sis_page_manager', 'DELETE_MASTER_PAGE', SIS_EVENT_TYPE_DELETE, array('objectName' => "Master page : " . $masterpageRecord[0]['sp_page_id'], 'objectId' => $masterpageRecord[0]['sp_page_id'], 'dimensions' => $dimensions)); } sisSetStatusMsg(); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_MASTERPAGE_LIST_WD_ID, true); } if (sisParam('sisOp') == 'new' && sisParam('masterpageName')) { $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages WHERE sp_code = '" . sisVarPrepForStore(sisParam('masterpageName')) . "' AND sp_is_master = 1 AND sp_portal_id = $portalId", true); if ($record[0]['rec_count']) { sisRaiseException(_LNG_PGM_MASTERPAGE_NAME_EXISTS); sisCloseCurrentWindow(); } $masterpageId = sisServiceAPIFunc('pmk', 'admin', 'createPage', array( 'page_show_in_menu' => 0, 'page_code' => sisParam('masterpageName'), 'page_portal_id' => $portalId, 'masterpage' => 1 )); if (!$masterpageId) { sisCloseCurrentWindow(); } $pageDetailId = sisServiceAPIFunc('pmk', 'admin', 'createPageDetail', array( 'page_id' => $masterpageId, 'page_language' => '', 'page_status' => 1, 'page_layout_template_id' => 'general', 'page_show_title' => '1', 'page_page_template_id' => 'onecolumn', 'page_deletable' => 0 )); sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $masterpageId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageDetailId]; sisRaiseEvent('sis_page_manager', 'CREATE_MASTER_PAGE', SIS_EVENT_TYPE_CREATE, array('objectName' => "Master page : " . $masterpageId, 'objectId' => $masterpageId, 'dimensions' => $dimensions)); //sisRefreshParentWindow(false, false); sisServerTransfer("fa/index.php?module=web_directory&type=user&func=main&apServiceName=web_directory&sisOp=edit&wd_id=" . _PGM_MASTERPAGE_EDIT_WD_ID . "&masterpageId=" . $masterpageId, true ); } $masterpageId = intval($masterpageId); $masterpageRecord = sisRunQuery(" SELECT * FROM saman_pages pg INNER JOIN saman_pages_detail pd ON (pg.sp_page_id = pd.sp_page_id) WHERE pg.sp_page_id = $masterpageId AND pg.sp_portal_id = $portalId AND pg.sp_is_master = 1", true); if (!$masterpageId || !$masterpageRecord[0]['sp_page_id']) { sisRaiseException(_LNG_PGM_MASTERPAGE_NOT_EXSITS); sisCloseCurrentWindow(); } $masterpageRecord = $masterpageRecord[0]; $themes = $GLOBALS['thmEngine']->sisGetThemes(true); $thmLayouts = sisServiceAPIFunc('pmk', 'admin', 'getPageTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); $pageLayouts = sisServiceAPIFunc('pmk', 'admin', 'getLayoutTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); sisAddToAdminOperationBar(_LNG_PGM_PAGE_DESIGN_SETTINGS, 'fa-gear', 'javascript:(function() { showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'masterpageDesignSettings', array('masterpageId' => $masterpageId, 'pageTheme' => sisParam('pageTheme'))) . '", null, "dialogWidth:350px;dialogMinHeight:110px;ajax:true;title:' . _LNG_PGM_PAGE_DESIGN_SETTINGS . '"); })()'); /*if (count($themes)) { sisAddToAdminOperationBar(_LNG_PGM_SELECT_THEME . '   (' . _LNG_PGM_CURRENT_THEME . ' : ' . $themes[$pageTheme]['title'] . ')', 'fa-paint-brush', 'javascript:(function() { showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'selectActiveTheme', array('masterpageId' => $masterpageId, 'pageTheme' => sisParam('pageTheme'))) . '", null, "dialogWidth:350px;dialogMinHeight:110px;ajax:true;title:' . _LNG_PGM_SELECT_THEME . '"); })()'); }*/ sisSetPageTitle($masterpageRecord['sp_code']); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $masterpageRecord['sp_page_id']]; sisRaiseEvent('sis_page_manager', 'VIEW_MASTER_PAGE', SIS_EVENT_TYPE_READ, array('objectName' => "Master page : " . $masterpageRecord['sp_page_id'], 'objectId' => $masterpageRecord['sp_page_id'], 'dimensions' => $dimensions)); div(null, 'codeContainer', 'style="height:100%"'); $selectedTemplate = ''; foreach ($pageLayouts as $template) { if ($template['template_id'] == $masterpageRecord['sp_page_template']) { $selectedTemplate = $template['template_content']; } } $pageItemsTmp = sisServiceAPIFunc('pmk', 'admin', 'getPageItems', array('main_page_id' => $masterpageRecord['sp_page_id'], 'page_id' => $masterpageRecord['sp_page_detail_id'])); $pageItems = array(); foreach ($pageItemsTmp as $pageItem) { $pageItems[$pageItem['item_position']][] = $pageItem; } if (unserialize($selectedTemplate)) { $selectedTemplate = unserialize($selectedTemplate); $selectedTemplate = $selectedTemplate[$pageLang] ? $selectedTemplate[$pageLang] : $selectedTemplate['all']; } if (stripos($selectedTemplate, "panelStyle=")) { $selectedTemplate = str_replace("class=", "class_disable=", $selectedTemplate); $selectedTemplate = str_ireplace("style=", "style_disable=", $selectedTemplate); $selectedTemplate = str_ireplace("panelStyle_disable=", "style=", $selectedTemplate); } preg_match_all("/##zone:([0-9]*)##/", $selectedTemplate, $pageZones, PREG_PATTERN_ORDER); foreach($pageZones[0] as $idx => $zone) { $pageItemsBlocks = ''; foreach ($pageItems[$pageZones[1][$idx]] as $pageItem) { if (strpos($pageItem['item_title'], "#D:") === 0) { $pageItem['item_title'] = substr($pageItem['item_title'], 3, strlen($pageItem['item_title']) - 4); } $pageItemInfo = $this->getPageItemExtraInfo($pageItem); $pageItemsTmpResponsive = $pageItem['item_responsive_settings']; $classBlocks = $this->createBlockCssClass($pageItemsTmpResponsive); $pageItemsBlocks .= '
    ' . ($pageItem['item_bkey'] != 'masterpage_container' ? localizedStr($pageItem['item_title'], null, true, true) : _LNG_PGM_CONTAINER) . '' . ($pageItem['item_language'] ? " {$languages[$pageItem['item_language']]}" : "") . '
    '; } $selectedTemplate = str_replace($zone, "
    " . _LNG_PGM_ZONE . " {$pageZones[1][$idx]}
    $pageItemsBlocks
    ", $selectedTemplate); $pageItems[$pageZones[1][$idx]] = null; } $hiddenPageBlocks = ''; foreach ($pageItems as $hiddenPageItems) { if (is_array($hiddenPageItems)) { foreach ($hiddenPageItems as $hiddenPageItem) { if (strpos($hiddenPageItem['item_title'], "#D:") === 0) { $hiddenPageItem['item_title'] = substr($hiddenPageItem['item_title'], 3, strlen($hiddenPageItem['item_title']) - 4); } $pageItemInfo = $this->getPageItemExtraInfo($hiddenPageItem); $pageItemsTmpResponsive = $hiddenPageItem['item_responsive_settings']; $classBlocks = $this->createBlockCssClass($pageItemsTmpResponsive); $hiddenPageBlocks .= '
    ' . localizedStr($hiddenPageItem['item_title'], null, true, true) . '' . ($hiddenPageItem['item_language'] ? " {$languages[$hiddenPageItem['item_language']]}" : "") . '
    '; } } } if ($hiddenPageBlocks) { $selectedTemplate .= "
    " . _LNG_PGM_HIDDEN_PAGE_ITEMS . "
    $hiddenPageBlocks
    "; } div(null, 'pgmDesignerContainer'); echo $selectedTemplate; div_(); div_(); ob_start(); div(null, 'sisDataForm'); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_PROPERTIES_TITLE); sisCaption_(); sisData(array('extraClass' => 'pgmBITitle')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_WD_ID); sisCaption_(); sisData(array('extraClass' => 'pgmBIId')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_SERVICE); sisCaption_(); sisData(array('extraClass' => 'pgmBIParentService')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_BLOCK); sisCaption_(); sisData(array('extraClass' => 'pgmBIParentBlock')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_BLOCK_BASE); sisCaption_(); sisData(array('extraClass' => 'pgmBIBaseService')); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_SERVICE_BASE); sisCaption_(); sisData(array('extraClass' => 'pgmBIBaseBlock')); sisData_(); sisFormGroup_(); div_(); /*table('100%', '0', 'class="sisDataForm"'); tr(); td('caption sisColorCaption', 'style="width: 25%"'); t(_LNG_PGM_BLOCK_PROPERTIES_TITLE . ':'); td_(); td('pgmBITitle'); td_(); tr_(); tr(); td('caption sisColorCaption'); t(_LNG_PGM_WD_ID . ':'); td_(); td('pgmBIId'); td_(); tr_(); tr(); td('caption sisColorCaption'); t(_LNG_PGM_BLOCK_SERVICE . ':'); td_(); td('pgmBIParentService'); td_(); tr_(); tr(); td('caption sisColorCaption'); t(_LNG_PGM_BLOCK_BLOCK . ':'); td_(); td('pgmBIParentBlock'); td_(); tr_(); tr(); td('caption sisColorCaption'); t(_LNG_PGM_BLOCK_SERVICE_BASE . ':'); td_(); td('pgmBIBaseService'); td_(); tr_(); tr(); td('caption sisColorCaption'); t(_LNG_PGM_BLOCK_BLOCK_BASE . ':'); td_(); td('pgmBIBaseBlock'); td_(); tr_(); table_();*/ $info = ob_get_clean(); t(sisModalMessage('pgmBlockInfo', ' ' . _LNG_PGM_BLOCK_INFO, $info, '30%', null, true)); script(); t('(function() { var toolbarHeight = $(".pgmDesignerContainer").prev().outerHeight(true); if (!toolbarHeight) { toolbarHeight = "0"; } $(".pgmDesignerContainer").height("calc(100% - " + toolbarHeight + "px)"); $(".codeContainer").disableSelection(); $(".codeContainer").find("input, select") .bind("mousedown.ui-disableSelection selectstart.ui-disableSelection", function(e) { e.stopImmediatePropagation(); }); $( ".pgmDragDropContainer" ).sortable({ placeholder : "pgmPageItemPlaceholder", connectWith : ".pgmDragDropContainer", scroll : true, refreshPositions : true, appendTo : ".pgmDesignerContainer", containment : "window", helper : "clone" }); $( ".pgmDragDropContainer" ).droppable({ activate: function(e, ui) { $(".pgmPageItemPlaceholder").attr("class", "pgmPageItemPlaceholder " + ui.draggable.attr("class")); }, drop : function (e, ui) { if (!ui.draggable.hasClass("ui-sortable-handle")) { return; } setTimeout(function() { pgmDisableAll(); var eventId = sisAdminPanel.addEventListener("loadURLEnd", function() { pgmEnableAll(); sisAdminPanel.removeEventListener("loadURLEnd", eventId); }); var param = ""; var $itemContainer = ui.draggable.closest(".pgmMasterpageContainer, .pgmZone"); if ($itemContainer.hasClass("pgmZone")) { param = "&pageZoneId=" + $itemContainer.attr("pgmId"); } else { param = "&masterpageContainerId=" + $itemContainer.attr("pgmId"); } changeWindowLocation(ui.draggable.get(0), "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'pageAction', array('masterpageId' => $masterpageId, 'pageTheme' => $pageTheme)) . '&pmgAction=movePageItem&pageItemId=" + ui.draggable.find(".pgmPageItem").attr("data-blockId") + "&pageZoneId=" + ui.draggable.closest(".pgmZone").attr("pgmId") + "&sisAPHiddenRequest=true&pagePreviousItemId=" + ui.draggable.prev().find(".pgmPageItem").attr("data-blockId") || 0); }, 100); } }); $(".codeContainer").parent().css("overflow", "hidden"); $(".pgmPageItem i[rel=properties]").click(function(e) { changeWindowLocation(this, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_PROPERTIES_WD_ID . '&pageItemId=" + $(this).closest(".pgmPageItem").attr("pgmId") + "&sisAPNewWindow=true&sisAPWindowSize=6", true); //showModalDialog("index.php?module=web_directory&wd_id=' . _PGM_BLOCK_PROPERTIES_WD_ID . '&pageItemId=" + $(this).closest(".pgmPageItem").attr("pgmId") + "&sisAPNewWindow=true", null, "dialogWidth:90%;dialogHeight:80%;ajax:true;title:' . _LNG_PGM_PAGE_BLOCK_PROPERTIES . '"); }); $(".pgmPageItem i[rel=info]").click(function(e) { var $infoDialog = $("#pgmBlockInfo"); $infoDialog.find(".pgmBITitle").text($(this).closest(".pgmPageItem").find(".pgmPageItemHeader span:first").text()); $infoDialog.find(".pgmBIId").text($(this).closest(".pgmPageItem").attr("data-blockId")); $infoDialog.find(".pgmBIBaseService").text($(this).closest(".pgmPageItem").attr("data-baseService")); $infoDialog.find(".pgmBIBaseBlock").text($(this).closest(".pgmPageItem").attr("data-baseBlock")); $infoDialog.find(".pgmBIParentService").text($(this).closest(".pgmPageItem").attr("data-parentService")); $infoDialog.find(".pgmBIParentBlock").text($(this).closest(".pgmPageItem").attr("data-parentBlock")); sisShowModal("#pgmBlockInfo"); }); $(".pgmPageItem i[rel=delete]").click(function(e) { var $pageItem = $(this).closest(".pgmPageItem"); sisConfirm("' . _LNG_PGM_DELETE_PAGE_ITEM_CONFIRM . '", null, null, function() { sisAdminPanel.startLoading(); $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deletePageItem') . '&pageItemId=" + $pageItem.attr("data-blockId")), function(data) { $pageItem.remove(); showPortalMessage("' . _GLB_OPERATION_DONE . '"); }) .always(function() { sisAdminPanel.stopLoading(); }); }); }); $(".pgmPageItem i[rel=perms]").click(function(e) { changeWindowLocation(this, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_PERMS_WD_ID . '&pageItemId=" + $(this).closest(".pgmPageItem").attr("pgmId") + "&pageWdId=' . $pageWdId . '&pageLang=' . $pageLang . '&sisAPNewWindow=true&sisAPWindowSize=4", true); }); $(".pgmPageItem i[rel=export]").click(function(e) { var $pageItem = $(this).closest(".pgmPageItem"); window.open(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'exportBlock') . '&pageItemId=" + $pageItem.attr("data-blockId")), "_blank"); }); $(".pgmZone .pgmZoneOperation i[rel=addBlock]").click(function(e) { var $zone = $(this).closest(".pgmZone"); showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addBlockUI') . '&showAllModule=1&pageDetailId=" + $zone.attr("data-pageDetailId") + "&zoneId=" + $zone.attr("data-zoneId") + "&windowId=" + $(this).closest(".sisAPWindow").attr("id") + "&includeMasterpage=1", null, "dialogWidth:70%;dialogHeight:500px;ajax:true;title:' . _LNG_PGM_ADD_BLOCK_PAGE . '"); }); $(".pgmZone .pgmZoneOperation i[rel=zoneAction]").click(function(e) { var $zone = $(this).closest(".pgmZone"); showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'zoneAction') . '&pageDetailId=" + $zone.attr("data-pageDetailId") + "&zoneId=" + $zone.attr("data-zoneId"), null, "dialogWidth:50%;dialogHeight:400px;ajax:true;title:' . _LNG_PGM_ZONE_ACTION . '"); }); function pgmDisableAll() { $(".codeContainer select").prop("disabled", true); $(".pgmZoneContainer").sortable("disable"); } function pgmEnableAll() { $(".codeContainer select").prop("disabled", false); $(".pgmZoneContainer").sortable("enable"); } })();'); script_(); sisEventLogView(array('subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $masterpageRecord['sp_page_detail_id'])); sisDie(); } function deletePage($pageId, $pageLang, $portalId) { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageId = intval($pageId); $portalId = intval($portalId); if (!$pageId) { return false; } if ($pageLang == 'all') { $pageLang = ''; } $pageDetailRecords = sisRunQuery("SELECT sp_page_detail_id FROM saman_pages_detail WHERE sp_page_id = $pageId AND sp_language = '" . sisVarPrepForStore($pageLang) . "' AND sp_portal_id = $portalId", true); if (!$pageDetailRecords[0]['sp_page_detail_id']) { return false; } foreach ($pageDetailRecords as $pageDetailRecord) { $pageItemsRecords = sisRunQuery("SELECT sp_bid FROM saman_page_items WHERE sp_page_id = '{$pageDetailRecord['sp_page_detail_id']}' AND sp_portal_id = $portalId", true); foreach ($pageItemsRecords as $record) { sisDeletePath(PORTAL_DATA_PATH . 'sis_page_manager/block_images/' . $record['sp_bid']); } sisRunQuery("DELETE FROM saman_page_items WHERE sp_page_id = '{$pageDetailRecord['sp_page_detail_id']}' AND sp_portal_id = $portalId"); sisRunQuery("DELETE FROM saman_pages_detail WHERE sp_page_detail_id = '{$pageDetailRecord['sp_page_detail_id']}' AND sp_portal_id = $portalId"); $records = sisRunQuery(" SELECT count(*) as rec_count FROM saman_pages p INNER JOIN saman_pages_detail pd ON (p.sp_page_id = pd.sp_page_id AND p.sp_portal_id = pd.sp_portal_id) WHERE p.sp_page_id = '$pageId' AND p.sp_portal_id = $portalId", true); if ($records[0]['rec_count'] == 0) { $wdRecord = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE (sp_node_page_id = '$pageId' OR sp_edit_page_id = '$pageId' OR sp_view_page_id = '$pageId') AND sp_portal_id = $portalId", true); if ($wdRecord[0]['sp_id']) { sisCacheDel('web_directory_info_' . $wdRecord[0]['sp_id']); sisRunQuery("UPDATE saman_web_directories SET sp_node_page_id = null WHERE (sp_node_page_id = '$pageId' AND sp_portal_id = $portalId)"); sisRunQuery("UPDATE saman_web_directories SET sp_edit_page_id = null WHERE (sp_edit_page_id = '$pageId' AND sp_portal_id = $portalId)"); sisRunQuery("UPDATE saman_web_directories SET sp_view_page_id = null WHERE (sp_view_page_id = '$pageId' AND sp_portal_id = $portalId)"); } sisRunQuery("DELETE FROM saman_pages WHERE sp_page_id = '$pageId' AND sp_portal_id = $portalId"); } } return true; } function homePagesList() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return sisForbidden(); } $portalId = intval(sisGlobal('portal_id')); /*t('');*/ $this->loadLangs(); $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; $pages = array(); $homePage = sisServiceAPIFunc('web_directory', 'user', 'getPortalRootDirectory'); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $homePage)); $pages[] = array( 'id' => $homePage, 'title' => _LNG_PGM_PORTAL_MAIN_PAGE, 'lang' => $wdInfo['lang'], 'regDate' => $wdInfo['reg_date'], 'pageType' => 'node', 'nodeType' => WD_NODE_TYPE_PORTAL ); $records = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_parent_id = $homePage AND sp_node_type = -1 AND sp_portal_id = $portalId ORDER BY sp_id", true); foreach ($records as $record) { $pages[] = array( 'id' => $record['sp_id'], 'lang' => $wdInfo['lang'], 'regDate' => $wdInfo['reg_date'], 'pageType' => 'copy:' . $record['sp_id'], 'copy' => true ); } $otherPages = sisRunQuery("SELECT sp_id, sp_title, sp_lang, sp_reg_date FROM saman_web_directories WHERE sp_parent_id = " . _PGM_MAIN_WD_ID . " AND sp_portal_id = $portalId AND sp_node_type = " . WD_NODE_TYPE_CATEGORY_ITEM, true); foreach ($otherPages as $otherPage) { $pages[] = array( 'id' => $otherPage['sp_id'], 'title' => localizedStr($otherPage['sp_title']), 'lang' => $otherPage['sp_lang'], 'regDate' => $otherPage['sp_reg_date'], 'pageType' => 'node', 'nodeType' => WD_NODE_TYPE_CATEGORY_ITEM, ); $records = sisRunQuery("SELECT sp_id, sp_reg_date, sp_lang FROM saman_web_directories WHERE sp_parent_id = $otherPage[sp_id] AND sp_node_type = -1 AND sp_portal_id = $portalId ORDER BY sp_id", true); foreach ($records as $record) { $pages[] = array( 'id' => $record['sp_id'], 'lang' => $otherPage['sp_lang'], 'regDate' => $otherPage['sp_reg_date'], 'pageType' => 'copy:' . $record['sp_id'], 'copy' => true ); } } sisRaiseEvent('sis_page_manager', 'VIEW_HOME_PAGES', SIS_EVENT_TYPE_READ); form('frmHomepageList'); table('100%', 0, 'class="list sisDataListTable pgmPagesList table-no-bordered" cellspacing="0" cellpadding="5" data-search="true" data-auto-height=true'); t(''); tr(); sisAddToListOperationBar(array( array( 'action' => "(function() { sisPrompt('" . _LNG_PGM_ENTER_PAGE_TITLE . "', null, null, function(pageTitle) { pageTitle = pageTitle.replace(/(<([^>]+)>)/ig, '').trim(); if (!pageTitle) { sisAlert('" . _LNG_PGM_PAGE_TITLE_MANDATORY . "'); return false; } sisAdminPanel.startLoading(); $.getJSON(sisUtility.correctUrl('" . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addNewPage') . "&parentWdId=" . _PGM_MAIN_WD_ID . "&pageTitle=' + pageTitle), function(pageId) { if (!isNaN(pageId)) { sisAdminPanel.stopLoading(); changeWindowLocation(null, 'index.php?module=web_directory&wd_id=" . _PGM_PAGES_DESIGN_WD_ID . "&pageWdId=' + pageId + '&nodeType=node&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' + pageTitle + '&sisAPTabId=pgmNodePage' + pageId, true); } }) .fail(function() { sisAdminPanel.stopLoading(); }); }); })()", 'icon' => 'fa-plus', 'hint' => _LNG_PGM_NEW_PAGE, ), array( 'action' => "pgmPageDeleteMultiple(this)", 'icon' => 'fa-close', 'hint' => _LNG_PGM_DELETE_SELECTED_ITMES ) )); th('list-header-etc', "width='2%' align='center'"); t(''); th_(); th('list-header-etc', "width='5%' align='center'"); t(_LNG_PGM_WD_ID); th_(); th('list-header-etc'); t(_LNG_PGM_PAGE); th_(); th('list-header-etc', "width='15%' align='center'"); t(_LNG_PGM_LANG); th_(); th('list-header-etc', "width='15%' align='center'"); t(_LNG_PGM_REGISTER_DATE); th_(); th('list-header-etc', "width='10%' align='center'"); t(_LNG_PGM_OPERATION); th_(); tr_(); t(''); $lastTitle = null; $lastPageType = null; $lastPageId = null; $index = 1; foreach ($pages as $page) { $trClass = 'sp-odd'; $tdClass = 'listrow1'; if ($idx % 2 != 0) { $trClass = 'sp-even'; $tdClass = 'listrow2'; } tr("trThmListRow $trClass", "data-wdId=$page[id]"); $title = ''; td($tdClass); if ($page['nodeType'] != WD_NODE_TYPE_PORTAL && sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { t(''); } td_(); td($tdClass); t($page['id'], 'sis-no-wrap'); td_(); td($tdClass); $isCopy = strpos($page['pageType'], 'copy:') !== false; if ($isCopy) { t(''); } if ($page['nodeType'] == WD_NODE_TYPE_PORTAL) { t(''); } elseif (!$isCopy) { t(''); } $title = localizedStr($page['title']); if ($isCopy) { $title = "$lastTitle (" . _LNG_PGM_DUPLICATE_PAGE . " $index)"; $index++; } else { $lastTitle = $title; $lastPageType = $page['pageType']; $lastPageId = $page['id']; $index = 1; } nbsp(); t($title); td_(); td($tdClass); if (!$page['lang']) { $page['lang'] = 'all'; } t($languages[$page['lang']]); td_(); td($tdClass); t(sisFormat(sisDisplayDateTime($page['regDate'])), 'sis-no-wrap'); td_(); td("$tdClass pgmActions"); $items = array(); $item = array(); $item['icon'] = 'fa-eye fa-fw'; $item['title'] = _LNG_PGM_PREVIEW; $item['link'] = 'index.php?module=web_directory&wd_id=' . $page['id']; $item['extra'] = 'sisAPIgnore=true'; $items[] = $item; if (sisServiceAvailable('sis_url_shortener')) { $item = array(); $item['icon'] = 'fa-link fa-fw'; $item['title'] = _SIS_LIB_RECORD_SHORTURL_ADDR; $item['action'] = 'sisPrompt("Control + C to copy:", "' . sisServiceAPIFunc('sis_url_shortener', 'shortenPageUrl', ['wdId' => $page['id']]) . '")'; $item['extra'] = 'sisAPIgnore=true'; $items[] = $item; } if (!$isCopy) { $item = array(); $item['icon'] = 'fa-clone fa-fw'; $item['title'] = _LNG_PGM_COPY_PAGE_ACTION; $item['action'] = 'sisPrompt("' . _LNG_PGM_PAGE_TITLE . '", "", "", function(pageNewTitle) { if (pageNewTitle.trim()) { changeWindowLocation(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'duplicatePage', 'pageWdId=' . $page['id'] . '&nodeType=' . $page['pageType'] . '&backWdId=' . _PGM_HOME_PAGES_LIST_WD_ID . '©=1&pageNewTitle=" + pageNewTitle') . '); } else { sisAlert("' . _LNG_PGM_PAGE_TITLE_MANDATORY . '"); return false; } });'; $items[] = $item; $item = array(); $item['icon'] = 'fa-cog fa-fw'; $item['title'] = _LNG_PGM_PAGE_PROPERTIES; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGE_PROPERTIES_WD_ID . '&pageWdId=' . $page['id'] . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($page['title']) . ' | ' . _LNG_PGM_PAGE_PROPERTIES); $items[] = $item; $item = array(); $item['icon'] = 'fa-clone fa-fw'; $item['title'] = _LNG_PGM_DUPLICATE_PAGE_ACTION; $item['action'] = 'sisConfirm("' . sprintf(_LNG_PGM_DUPLICATE_PAGE_CONFIRM, localizedStr($title)) . '", null, null, function() {changeWindowLocation("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'duplicatePage', array('pageWdId' => $page['id'], 'nodeType' => $page['pageType'], 'backWdId' => _PGM_HOME_PAGES_LIST_WD_ID)) . '")});'; $items[] = $item; } else { $item = array(); $item['icon'] = 'fa-upload fa-fw'; $item['title'] = _LNG_PGM_UPLOAD_PAGE_CHANGES; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . sprintf(_LNG_PGM_UPLOAD_PAGE_CHANGES_MESSAGE, localizedStr($lastTitle)) . '\', \'' . _LNG_PGM_UPLOAD_PAGE_CHANGES_MESSAGE_DESC . '\', \'' . _LNG_PGM_UPLOAD_PAGE_CHANGES_MESSAGE_DESC_CONFIRM . '\', function() {changeWindowLocation(\'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'uploadPageChanges', array('pageWdId' => $lastPageId, 'copyPageWdId' => $page['id'], 'nodeType' => $lastPageType, 'backWdId' => _PGM_HOME_PAGES_LIST_WD_ID)) . '\')})"'; $items[] = $item; } $pageWdId = intval($page['id']); $portalId = intval(sisGlobal('portal_id')); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); $pageId = $wdInfo['wd_pages']['node']; $strSql = "SELECT * FROM saman_pages_detail WHERE sp_page_id = $pageId AND sp_device = 0 AND sp_portal_id = $portalId "; $pageDetailRecords = sisRunQuery($strSql, true); if (count($pageDetailRecords)) { if (count($pageDetailRecords) == 1) { $pageLang = $pageDetailRecords[0]["sp_language"]; if(!$pageLang) { $pageLang = 'all'; } } else { $pageLang = sisUserGetLang(); $pageDetail = sisRunQuery($strSql . " AND sp_language = '" . sisVarPrepForStore($pageLang) . "'", true); if (count($pageDetail) == 0) { $pageLang = 'all'; $pageDetail = sisRunQuery($strSql . " AND (sp_language IS NULL OR sp_language = '' OR sp_language = 'all')" , true); } } $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_PAGE; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGE_DESIGN_WD_ID .'&pageWdId=' . $page['id'] . '&pageNodeType=node&pageChannel=0&pageLang=' . $pageLang . '&pageIsDesign=0&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowSize=5&pageTitle='. urlEncode(localizedStr($title) . ' | ' . _LNG_PGM_EDIT_PAGE); $items[] = $item; } $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_ADVANCED_PAGE; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=' . $page['id'] . '&nodeType=node&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($title) . ' | ' . _LNG_PGM_EDIT_PAGE) . '&sisAPTabId1=pgmNodePage' . $page['id']; $items[] = $item; if ($page['nodeType'] == WD_NODE_TYPE_CATEGORY_ITEM || $isCopy) { $item = array(); $item['icon'] = 'fa-remove fa-fw'; $item['title'] = _LNG_PGM_DELETE_PAGE; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . sprintf(_LNG_PGM_DELETE_PAGE_WD_CONFIRM, localizedStr($title)) . '\', null, null, function() {changeWindowLocation(null, \'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteWDPage', array('pageWdId' => $page['id'] , 'nodeType' => $lastPageType, 'backUrl' => base64_encode('index.php?module=web_directory&wd_id=' . _PGM_HOME_PAGES_LIST_WD_ID))) . '\')})"'; $items[] = $item; } $logEventViewUrl = sisEventLogView(array('subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $page['id'], 'returnLink' => true)); if ($logEventViewUrl) { $item = array(); $item['icon'] = 'fa-user-secret fa-fw'; $item['title'] = _SIS_EVENT_LOG_VIEW; $item['link'] = '#a'; $item['extra'] = 'onclick="changeWindowLocation(this, \'' . $logEventViewUrl . '&sisAPNewWindow=true\', true);"'; $items[] = $item; } if (isAdminUser()) { if ($page['nodeType'] == WD_NODE_TYPE_PORTAL) { $reportVisitUrl = "index.php?module=web_directory&wd_id=" . getImportId('wd_id:8a5bb419-cbce-11e4-8fb1-0050569f5821') . "&pageId=-1&sisAPWindowSize=5"; } else { $reportVisitUrl = "index.php?module=web_directory&wd_id=" . getImportId('wd_id:8a5bb419-cbce-11e4-8fb1-0050569f5821') . "&pageId=" . $page['id'] . "&sisAPWindowSize=5"; } $item = array(); $item['icon'] = 'fa-line-chart fa-fw'; $item['title'] = _SIS_CNT_CONTENT_ADVANCED_SETTINGS_VISIT_REPORT; $item['link'] = '#a'; $item['extra'] = 'onclick="changeWindowLocation(this, \'' . $reportVisitUrl . '&sisAPNewWindow=true\', true);"'; $items[] = $item; } sisListOperationMenu(false, $items); /*t('
    '); if (!$isCopy) { a('index.php?module=web_directory&wd_id=' . _PGM_PAGE_PROPERTIES_WD_ID . '&pageWdId=' . $page['id'] . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($page['title']) . ' | ' . _LNG_PGM_PAGE_PROPERTIES), 'target="_blank" title="' . _LNG_PGM_PAGE_PROPERTIES . '" alt="' . _LNG_PGM_PAGE_PROPERTIES . '"'); t(''); a_(); } else { t(''); } if (!$isCopy) { t(''); } else { t(''); } a('index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=' . $page['id'] . '&nodeType=node&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($title) . ' | ' . _LNG_PGM_EDIT_PAGE) . '&sisAPTabId1=pgmNodePage' . $page['id'], 'target="_blank" title="' . _LNG_PGM_EDIT_PAGE . '" alt="' . _LNG_PGM_EDIT_PAGE . '"'); t(''); a_(); if ($page['nodeType'] == WD_NODE_TYPE_CATEGORY_ITEM || $isCopy) { t(''); } else { t(''); }*/ td_(); tr_(); $idx++; } table_(); script(); t('function pgmPageDeleteMultiple(obj) { var $items = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]:checked"); if ($items.length == 0) { sisAlert("' . _LNG_PGM_DELETE_SELECTED_EMPTY . '"); return; } sisConfirm("' . _LNG_PGM_DELETE_SELECTED_CONFIRM . '", null, null, function() { var items = new Array(); $items.each(function() { items.push($(this).val()); }); //changeWindowLocation(null, \'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteWDPage', array('pageWdId' => $page['id'] , 'nodeType' => $lastPageType, 'backUrl' => base64_encode('index.php?module=web_directory&wd_id=' . _PGM_HOME_PAGES_LIST_WD_ID))) . '\'); //alert("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteMultiplePage', 'backUrl' . base64_encode('index.php?module=web_directory&wd_id=' . _PGM_HOME_PAGES_LIST_WD_ID) . '&pagesId=" + items.join(",")' ) . '); changeWindowLocation(obj, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteMultiplePage', '&pageId=" + items.join(",")' ) . '); }); } function pgmPageSelectAll(obj) { var $checkBoxes = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]"); $checkBoxes.prop("checked", $(obj).prop("checked")); $checkBoxes.each(function() { if ($(this).prop("checked")) { $(this).closest("tr").addClass("sisAPActive"); } else { $(this).closest("tr").removeClass("sisAPActive"); } }); } function pgmPageSelectRow(obj) { $(obj).closest("tr").toggleClass("sisAPActive"); } '); script_(); form_(); /*sisEventLogView(array('eventTypes' => array( 'sis_page_manager:CREATE_PAGE', 'sis_page_manager:EDIT_PAGE', 'sis_page_manager:DELETE_PAGE', 'sis_page_manager:VIEW_PAGE', )));*/ } function servicesPagesList() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = intval(sisGlobal('portal_id')); $this->loadLangs(); $services = sisRunQuery(" SELECT sp_id, sp_title, sp_type_name FROM saman_web_directories WHERE sp_portal_id = $portalId AND sp_node_type = " . WD_NODE_TYPE_SERIVCE, true); usort($services, function ($a, $b) { return localizedStr($a['sp_title']) >= localizedStr($b['sp_title']); }); $servicesList = array(); foreach($services as $service) { $type = sisRunQuery(" SELECT type_name, is_system, (SELECT COUNT(*) FROM saman_web_directories WHERE (sp_id = '$service[sp_id]' OR sp_path LIKE '%/$service[sp_id]/%') AND sp_is_admin = 0 AND ((sp_node_page_id IS NOT NULL AND sp_node_page_id <> 0) OR (sp_edit_page_id IS NOT NULL AND sp_edit_page_id <> 0) OR (sp_view_page_id IS NOT NULL AND sp_view_page_id <> 0))) as pages_count FROM saman_content_types INNER JOIN saman_application_modules ON (sp_name = type_name AND sp_app_name NOT IN('BI','integrationFramework','reportBuilder','BPMS','applicationBuilderExtender','collaboration','samanSuite')) WHERE ctp_id = " . intval(str_replace("cdk_", "", $service['sp_type_name'])), true); if ($type[0] && ($type[0]['pages_count'] || !$type[0]['is_system'])) { $servicesList[] = array( 'name' => 'pgmSrv' . ($type[0]['type_name'] ? $type[0]['type_name'] : rand()), 'title' => localizedStr($service['sp_title']), 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_SERVICE_PAGES_LIST_WD_ID . '&serviceWdId=' . $service['sp_id'] . '&sisAPTabsheetName=pgmServicePagesTab&sisAPWindowSize=3'); } } usort($servicesList, function($a, $b) { return trim($a['title']) >= trim($b['title']); }); sisRaiseEvent('sis_page_manager', 'VIEW_SERVICES', SIS_EVENT_TYPE_READ); div(null, 'pgmMenu'); t(sisServiceAPIFunc('control_panel', 'admin', 'generateVerticalMenu', array('items' => $servicesList))); div_(); sisDie(); } function servicePagesList() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = intval(sisGlobal('portal_id')); $serviceWdId = intval(sisParam('serviceWdId')); if (!$serviceWdId) { die(); } $directoryInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $serviceWdId)); $contentType = getContentType(str_replace('cdk_', '', $directoryInfo['type_name'])); if (!$contentType['ctp_id']) { die(); } $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_web_directories WHERE sp_parent_id = $serviceWdId AND sp_node_type IN (" . WD_NODE_TYPE_SERVICE_CATEGORY . ", " . WD_NODE_TYPE_CATEGORY_ITEM . ") AND sp_portal_id = $portalId", true); $directories = sisServiceAPIFunc('web_directory', 'admin', 'getAll', array('portal_id' => $portalId, 'hide_syetem_node' => false, 'parent_id' => $serviceWdId, 'show_parent' => true, 'extra_where' => 'sp_is_admin = 0')); $this->loadLangs(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $serviceWdId]; $dimensions[] = ['subject' => 'cdk', 'key' => 'ctpId', 'value' => $contentType['ctp_id']]; sisRaiseEvent('sis_page_manager', 'VIEW_SERVICE_PAGES', SIS_EVENT_TYPE_READ, array('objectName' => "Service : " . $contentType['type_name'], 'objectId' => $contentType['ctp_id'], 'servicePageId' => $serviceWdId, 'dimensions' => $dimensions)); table('100%', 0, 'class="list sisDataListTable pgmPagesList table-no-bordered" cellspacing="0" cellpadding="5" data-search=true data-auto-height=true'); t(''); tr(); th('list-header-etc'); t(_LNG_PGM_PAGE); $menuItems= array( 'icon' => 'fa-plus', 'hint' => _LNG_PGM_CUSTOMIZE_CATEGORY_PAGES, 'items' => array( array( 'action' => 'newPage()', 'title' => _LNG_PGM_CREATE_NEW_PAGE ), ), ); if ($record[0]['rec_count']) { $menuItems['items'][] = array( 'action' => "(function() { showModalDialog.call(this, '" . callFunctionUrl(_PGM_MAIN_CTP_ID, 'customizePage', array('serviceWdId' => $serviceWdId, 'ctpId' => $contentType['ctp_id'])) . "', null, 'dialogWidth:400px;dialogHeight:400px;ajax:true;title:" . _LNG_PGM_CUSTOMIZE_CATEGORY_PAGES . "'); })()", 'title' => _LNG_PGM_CUSTOMIZE_CATEGORY_PAGES ); } sisAddToListOperationBar($menuItems); th_(); th('list-header-etc', "width='20%' align='center'"); t(_LNG_PGM_OPERATION); th_(); tr_(); t(''); script(); t('function newPage() { sisPrompt("' . _LNG_PGM_ENTER_PAGE_TITLE . '", null, null, function(pageTitle) { pageTitle = pageTitle.replace(/(<([^>]+)>)/ig, "").trim(); if (!pageTitle) { sisAlert("' . _LNG_PGM_PAGE_TITLE_MANDATORY . '"); return false; } $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addNewPage') . '&modulePagesUI=true&isAdmin=0&parentWdId=' . $serviceWdId . '&pageTitle=" + pageTitle), function(pageId) { if (!isNaN(pageId)) { sisAdminPanel.refreshCurrentWindow(); } }); }); }'); script_(); $idx = 0; foreach($directories as $dir) { if (count($dir['wd_pages']) == 0) { continue; } $pages = $dir['wd_pages']; $tmpPages = array(); if(!($pages['node'] || $pages['view'] || $pages['edit']) && !$dir['is_system'] && !$dir['is_admin'] && !$dir['node_type']){ $tmpPages['node'] = 0; } foreach ($pages as $pageType => $pageId) { if (!$pageId) { continue; } $tmpPages[$pageType] = $pageId; $copyWdIds = sisRunQuery(" SELECT sp_id FROM saman_web_directories WHERE sp_parent_id = $dir[id] AND sp_{$pageType}_page_id <> 0 AND sp_node_type = -1 AND sp_portal_id = $portalId ORDER BY sp_id", true); if (count($copyWdIds) > 0) { foreach($copyWdIds as $copyWdId) { $tmpPages['copy:' . $copyWdId['sp_id']] = $copyWdId['sp_id']; } } } $pages = $tmpPages; $lastTitle = null; $lastPageType = null; $index = 1; foreach ($pages as $pageType => $pageId) { $trClass = 'sp-odd'; $tdClass = 'listrow1'; if ($idx % 2 != 0) { $trClass = 'sp-even'; $tdClass = 'listrow2'; } tr("trThmListRow $trClass", "data-wdId=$dir[id]"); $title = ''; td($tdClass); $isCopy = strpos($pageType, 'copy:') !== false; if ($isCopy) { t(''); } if ($dir['node_type'] == WD_NODE_TYPE_SERIVCE) { if ($pageType == 'node') { t(''); $title = _LNG_PGM_SERVICE_MAIN_PAGE; } else if ($pageType == 'view') { t(''); $title = _LNG_PGM_SERVICE_VIEW_PAGE; } else if ($pageType == 'edit') { t(''); $title = _LNG_PGM_SERVICE_EDIT_PAGE; } nbsp(); } else if ($dir['node_type'] != WD_NODE_TYPE_SIMPLE) { if ($pageType == 'node') { t(''); $title = _LNG_PGM_CATEGORY_MAIN_PAGE; } else if ($pageType == 'view') { t(''); $title = _LNG_PGM_CATEGORY_VIEW_PAGE; } else if ($pageType == 'edit') { t(''); $title = _LNG_PGM_CATEGORY_EDIT_PAGE; } } else if (!$isCopy) { t(''); } $title .= ' ' . localizedStr($dir['title']); if ($isCopy) { $title = "$lastTitle (" . _LNG_PGM_DUPLICATE_PAGE . " $index)"; $index++; } else { $lastTitle = $title; $lastPageType = $pageType; $index = 1; } nbsp(); if (!$isCopy) { $pathTitles = sisServiceAPIFunc('web_directory', 'user', 'getPath', array('wd_id' => $dir['id'], 'get_full_path' => true)); array_shift($pathTitles); foreach ($pathTitles as $pathTitle) { t(localizedStr($pathTitle['title']) . '  '); } } t($title); td_(); td("$tdClass pgmActions"); $items = array(); if ($pageType == 'node' && !(!$dir['is_admin'] && !$dir['is_system'] && $pages['node'] == 0)) { $item = array(); $item['icon'] = 'fa-eye fa-fw'; $item['title'] = _LNG_PGM_PREVIEW; $item['link'] = 'index.php?module=web_directory&wd_id=' . $dir['id']; $item['extra'] = 'sisAPIgnore=true'; $items[] = $item; if (sisServiceAvailable('sis_url_shortener')) { $item = array(); $item['icon'] = 'fa-link fa-fw'; $item['title'] = _SIS_LIB_RECORD_SHORTURL_ADDR; $item['action'] = 'sisPrompt("Control + C to copy:", "' . sisServiceAPIFunc('sis_url_shortener', 'shortenPageUrl', ['wdId' => $dir['id']]) . '")'; $item['extra'] = 'sisAPIgnore=true'; $items[] = $item; } } if (!$isCopy) { $pageWdId = intval($dir['id']); $portalId = intval(sisGlobal('portal_id')); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); $pageId = intval($wdInfo['wd_pages'][$pageType]); $strSql = "SELECT * FROM saman_pages_detail WHERE sp_page_id = $pageId AND sp_device = 0 AND sp_portal_id = $portalId "; $pageDetailRecords = sisRunQuery($strSql, true); if ($pageType == 'node') { $item = array(); $item['icon'] = 'fa-cog fa-fw'; $item['title'] = _LNG_PGM_PAGE_PROPERTIES; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGE_PROPERTIES_WD_ID . '&pageWdId=' . $pageWdId . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($dir['title']) . ' | ' . _LNG_PGM_PAGE_PROPERTIES); $item['extra'] = 'target="_blank"'; $items[] = $item; } if (!($pageType == 'node' && !$dir['is_admin'] && !$dir['is_system'] && $pages['node'] == 0)) { $item = array(); $item['icon'] = 'fa-clone fa-fw'; $item['title'] = _LNG_PGM_DUPLICATE_PAGE_ACTION; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . sprintf(_LNG_PGM_DUPLICATE_PAGE_CONFIRM, localizedStr($title)) . '\', null, null, function() {changeWindowLocation(\'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'duplicatePage', array('pageWdId' => $dir['id'], 'nodeType' => $pageType, 'serviceWdId' => $serviceWdId, 'backWdId' => _PGM_SERVICE_PAGES_LIST_WD_ID)) . '\')})"'; $items[] = $item; } if (count($pageDetailRecords)) { if (count($pageDetailRecords) == 1) { $pageLang = $pageDetailRecords[0]["sp_language"]; if(!$pageLang){ $pageLang = 'all'; } } else { $pageLang = sisUserGetLang(); $pageDetail = sisRunQuery($strSql . " AND sp_language = '" . sisVarPrepForStore($pageLang) . "'", true); if (count($pageDetail) == 0) { $pageLang = 'all'; $pageDetail = sisRunQuery($strSql . " AND (sp_language IS NULL OR sp_language = '' OR sp_language = 'all')" , true); } } $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_PAGE; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGE_DESIGN_WD_ID .'&pageWdId=' . $pageWdId . '&pageNodeType=' . $pageType . '&pageChannel=0&pageLang=' . $pageLang . '&pageIsDesign=0&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&pageTitle='. urlEncode(localizedStr($title) . ' | ' . _LNG_PGM_EDIT_PAGE); $item['extra'] = 'target="_blank"'; $items[] = $item; } $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_ADVANCED_PAGE; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=' . $pageWdId . '&nodeType=' . $pageType . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($directories[0]['title']) . ' | ' . $title . ' | ' . _LNG_PGM_EDIT_PAGE) . '&sisAPTabId1=pgmNodePage' . $pageId; $item['extra'] = 'target="_blank"'; $items[] = $item; } else { if ($pageType == 'node') { $item = array(); $item['icon'] = 'fa-eye fa-fw'; $item['title'] = _LNG_PGM_PREVIEW; $item['link'] = 'index.php?module=web_directory&wd_id=' . $pageId; $item['extra'] = 'sisAPIgnore=true'; $items[] = $item; if (sisServiceAvailable('sis_url_shortener')) { $item = array(); $item['icon'] = 'fa-link fa-fw'; $item['title'] = _SIS_LIB_RECORD_SHORTURL_ADDR; $item['action'] = 'sisPrompt("Control + C to copy:", "' . sisServiceAPIFunc('sis_url_shortener', 'shortenPageUrl', ['wdId' => $pageId]) . '")'; $item['extra'] = 'sisAPIgnore=true'; $items[] = $item; } } $item = array(); $item['icon'] = 'fa-upload fa-fw'; $item['title'] = _LNG_PGM_UPLOAD_PAGE_CHANGES; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . sprintf(_LNG_PGM_UPLOAD_PAGE_CHANGES_MESSAGE, localizedStr($lastTitle)) . '\', \'' . _LNG_PGM_UPLOAD_PAGE_CHANGES_MESSAGE_DESC . '\', \'' . _LNG_PGM_UPLOAD_PAGE_CHANGES_MESSAGE_DESC_CONFIRM . '\', function() {changeWindowLocation(\'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'uploadPageChanges', array('pageWdId' => $dir['id'], 'copyPageWdId' => $pageId, 'nodeType' => $lastPageType, 'serviceWdId' => $serviceWdId, 'backWdId' => _PGM_SERVICE_PAGES_LIST_WD_ID)) . '\')})"'; $items[] = $item; $pageWdId = intval($dir['id']); $portalId = intval(sisGlobal('portal_id')); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); //$pageId = intval($wdInfo['wd_pages']['node']); $strSql = "SELECT * FROM saman_pages_detail WHERE sp_page_id = $pageId AND sp_device = 0 AND sp_portal_id = $portalId "; $pageDetailRecords = sisRunQuery($strSql, true); if (count($pageDetailRecords)) { if (count($pageDetailRecords) == 1) { $pageLang = $pageDetailRecords[0]["sp_language"]; } else { $pageLang = sisUserGetLang(); $pageDetail = sisRunQuery($strSql . " AND sp_language = '" . sisVarPrepForStore($pageLang) . "'", true); if (count($pageDetail) == 0) { $pageLang = 'all'; $pageDetail = sisRunQuery($strSql . " AND (sp_language IS NULL OR sp_language = '' OR sp_language = 'all')" , true); } } } $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_PAGE; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGE_DESIGN_WD_ID .'&pageWdId=' . $pageId . '&pageNodeType=' . $lastPageType . '&pageChannel=0&pageLang=' . $pageLang . '&pageIsDesign=0&sisAPTabsheetName=pgmPageDesignTab&pageTitle='. urlEncode(localizedStr($title) . ' | ' . _LNG_PGM_EDIT_PAGE); $item['extra'] = 'target="_blank"'; $items[] = $item; $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_EDIT_ADVANCED_PAGE; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=' . $pageId . '&nodeType=' . $lastPageType . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($directories[0]['title']) . ' | ' . $title . ' | ' . _LNG_PGM_EDIT_PAGE) . '&sisAPTabId1=pgmNodePage' . $pageId; $item['extra'] = 'target="_blank"'; $items[] = $item; } if ($dir['node_type'] == WD_NODE_TYPE_SERVICE_CATEGORY || $dir['node_type'] == WD_NODE_TYPE_CATEGORY_ITEM || $isCopy || (!$dir["is_admin"] && !$dir["is_system"])) { $item = array(); $item['icon'] = 'fa-remove fa-fw'; $item['title'] = _LNG_PGM_DELETE_PAGE; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . sprintf(_LNG_PGM_DELETE_PAGE_WD_CONFIRM, localizedStr($title)) . '\', null, null, function() {changeWindowLocation(null, \'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteWDPage', array('pageWdId' => !$isCopy ? $dir['id'] : $pageId , 'nodeType' => $lastPageType, 'backUrl' => base64_encode('index.php?module=web_directory&wd_id=' . _PGM_SERVICE_PAGES_LIST_WD_ID . '&serviceWdId=' . $serviceWdId))) . '\')})"'; $items[] = $item; } if (isAdminUser() && $pageType == 'node' ) { $reportVisitUrl = "index.php?module=web_directory&wd_id=" . getImportId('wd_id:8a5bb419-cbce-11e4-8fb1-0050569f5821') . "&pageId=" . $dir['id'] . "&sisAPWindowSize=5"; $item = array(); $item['icon'] = 'fa-line-chart fa-fw'; $item['title'] = _SIS_CNT_CONTENT_ADVANCED_SETTINGS_VISIT_REPORT; $item['link'] = '#a'; $item['extra'] = 'onclick="changeWindowLocation(this, \'' . $reportVisitUrl . '&sisAPNewWindow=true\', true);"'; $items[] = $item; } sisListOperationMenu(false, $items); /*t(''); if (!$isCopy) { t(''); } else { t(''); } if (!$isCopy) { a('index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=' . $dir['id'] . '&nodeType=' . $pageType . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($directories[0]['title']) . ' | ' . $title . ' | ' . _LNG_PGM_EDIT_PAGE) . '&sisAPTabId1=pgmNodePage' . $pageId, 'target="_blank" title="' . _LNG_PGM_EDIT_PAGE . '" alt="' . _LNG_PGM_EDIT_PAGE . '"'); } else { a('index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=' . $pageId . '&nodeType=' . $lastPageType . '&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=' . urlEncode(localizedStr($directories[0]['title']) . ' | ' . $title . ' | ' . _LNG_PGM_EDIT_PAGE) . '&sisAPTabId1=pgmNodePage' . $pageId, 'target="_blank" title="' . _LNG_PGM_EDIT_PAGE . '" alt="' . _LNG_PGM_EDIT_PAGE . '"'); } t(''); a_(); if ($dir['node_type'] == WD_NODE_TYPE_SERVICE_CATEGORY || $dir['node_type'] == WD_NODE_TYPE_CATEGORY_ITEM || $isCopy) { t(''); } else { t(''); }*/ td_(); tr_(); $idx++; } } table_(); /*sisEventLogView(array( 'subject' => 'cdk', 'key' => 'ctpId', 'value' => $contentType['ctp_id'], 'eventTypes' => array( 'sis_page_manager:CREATE_PAGE', 'sis_page_manager:EDIT_PAGE', 'sis_page_manager:DELETE_PAGE', 'sis_page_manager:VIEW_PAGE', )));*/ } function blocksList() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $blocks = sisServiceAPIFunc('portlets', 'user', 'getall', array('block_type' => 1, 'show_all' => 1, 'orderby' => 'sp_bid DESC')); foreach($blocks as $idx => $block) { $block['title'] = localizedStr($block['title']); if($block['service_bid']){ $blockInfoParent = sisPortletGetInfo($block['service_bid']); $typeInfo = sisServiceAPIFunc('cdk','user','getType',array('ctp_id' => $blockInfoParent['ctp_id'])); $modName = localizedStr($typeInfo['title']); $blocks[$idx]['bkey'] = $blockInfoParent['title']; $blocks[$idx]['modTitle'] = localizedStr($typeInfo['title']); $blocks[$idx]['modName'] = $typeInfo['type_name']; } else{ if ($block['mid'] == 0) { $blocks[$idx]['modTitle'] = _LNG_PGM_PORTAL_CORE; } else { $modinfo = sisServiceGetInfo($block['mid']); $blocks[$idx]['modTitle'] = $modinfo['name']; } } } //usort($blocks, function($a, $b) {return $a['title'] >= $b['title'];}); //t(''); sisRaiseEvent('sis_page_manager', 'VIEW_BLOCKS', SIS_EVENT_TYPE_READ); table('100%', 0, 'class="list sisDataListTable table-no-bordered" cellspacing="0" cellpadding="5" data-search=true data-auto-height=true '); t(''); tr(); th('list-header-etc', "width='5%' style='text-align:center'"); if (count($blocks) > 0) { t(''); $menuItems[] = array( 'action' => "pgmNewBlock(event, this)", 'icon' => 'fa-plus', 'hint' => _LNG_PGM_NEW_BLOCK ); $menuItems[] = array( 'action' => "pgmBlocksDeleteMultiple(this)", 'icon' => 'fa-close', 'hint' => _LNG_PGM_DELETE_SELECTED_ITMES ); $menuItems[] = array( 'action' => "pgmBlocksChangeStatus(this, 'active')", 'icon' => 'fa-play', 'hint' => _LNG_PGM_ACTIVE_SELECTED_ITMES ); $menuItems[] = array( 'action' => "pgmBlocksChangeStatus(this, 'deactive')", 'icon' => 'fa-pause', 'hint' => _LNG_PGM_DEACTIVE_SELECTED_ITMES ); sisAddToListOperationBar($menuItems); } th_(); th('list-header-etc', "data-sortable=true width='5%' data-order=desc"); t(_LNG_PGM_BLOCK_ID); th_(); th('list-header-etc', "data-sortable=true"); t(_LNG_PGM_TITLE); th_(); th('list-header-etc', "width='20%' data-sortable=true"); t(_LNG_PGM_BLOCK_TYPE); th_(); th('list-header-etc', "width='15%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_LAST_MODIFIED_DATE); th_(); if ($portalId == 0) { th('list-header-etc', "width='18%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_PUBLISH_AREA); th_(); } else { th('list-header-etc', "width='10%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_BLOCK_POSITION); th_(); } th('list-header-etc', "width='8%' style='text-align:center' data-sortable=true"); t(_LNG_PGM_BLOCK_STATUS); th_(); th('list-header-etc', "width='10%' style='text-align:center'"); t(_LNG_PGM_OPERATION); th_(); tr_(); t(''); foreach($blocks as $block) { $trClass = 'sp-odd'; $tdClass = 'listrow1'; if ($i % 2 != 0) { $trClass = 'sp-even'; $tdClass = 'listrow2'; } tr("trThmListRow $trClass", "data-text='$block[modName]'"); td($tdClass); if ($block['portal_id'] == $portalId) { t(''); } td_(); td($tdClass); t($block['bid']); td_(); td($tdClass); t(localizedStr($block['title'])); td_(); td($tdClass); t($block['modTitle'] . ' / ' . localizedStr($block['bkey'])); td_(); td($tdClass); //$block['last_update'] = explode(" ", $block['last_update']); //$date = sisFormat($block['last_update'][0], sisGetLocalizedDateFormat(), 'GREGORIANDATE', true); //if ($date) { if ($block['last_update']) { t(sisFormat(sisDisplayDateTime($block['last_update']))); /* t($date); t(" - "); $block['last_update'][1] = explode(":", $block['last_update'][1]); array_pop($masterpage['last_update'][1]); $block['last_update'][1] = implode($block['last_update'][1], ":"); t(sisFormat($block['last_update'][1], null, null, true));*/ } td_(); if ($portalId == 0) { td($tdClass); if ($block['publish_scope'] == 1) { t(_LNG_PGM_PUBLISH_AREA_MAIN_PORTAL); } else { t(_LNG_PGM_PUBLISH_AREA_ALL_PORTALS); } td_(); } else { td($tdClass); if ($block['portal_id'] == $portalId) { t(_LNG_PGM_BLOCK_POSITION_SUBPORTAL); } else { t(_LNG_PGM_BLOCK_POSITION_MAIN_PORTAL); } td_(); } td($tdClass); if ($block['active']) { t(_LNG_PGM_BLOCK_STATUS_ACTIVE); } else { t(_LNG_PGM_BLOCK_STATUS_DEACTIVE); } td_(); td($tdClass); $items = array(); $item = array(); $item['icon'] = 'fa-download fa-fw'; $item['title'] = _LNG_PGM_EXPORT_BLOCK; $item['action'] = 'window.open(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'exportBlock') . '&blockId=' . $block['bid'] . '"), "_blank");'; $items[] = $item; if ($block['portal_id'] == $portalId) { $item = array(); $item['icon'] = 'fa-pencil fa-fw'; $item['title'] = _LNG_PGM_BLOCK_EDIT; $item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_BLOCK_EDIT_WD_ID . '&blockId=' . $block['bid'] . '&sisAPWindowSize=6&sisAPWindowTitle=' . urlEncode($block['title']); //$item['link'] = 'index.php?module=web_directory&wd_id=' . _PGM_BLOCK_EDIT_WD_ID . '&blockId=' . $block['bid'] . '&sisAPWindowSize=6&sisAPTabsheetName=blockEditTab&sisAPWindowTitle=' . urlEncode($block['title']); $item['extra'] = 'target="_blank"'; $items[] = $item; $item = array(); $item['icon'] = 'fa-close fa-fw'; $item['title'] = _LNG_PGM_DELETE_BLOCK; $item['link'] = '#a'; $item['extra'] = 'onclick="sisConfirm(\'' . sprintf(_LNG_PGM_DELETE_BLOCK_CONFIRM, localizedStr($block['title'])) . '\', null, null, function() {changeWindowLocation(null, \'' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteBlock', array('blockId' => $block['bid'])) . '\')})"'; $items[] = $item; } sisListOperationMenu(false, $items); /*a(callFunctionUrl(_PGM_MAIN_CTP_ID, 'exportBlock', array('blockId' => $block['bid'])), 'target="_blank" sisAPIgnore="true"'); t(''); a_(); if ($block['portal_id'] == $portalId) { a('index.php?module=web_directory&wd_id=' . _PGM_BLOCK_EDIT_WD_ID . '&blockId=' . $block['bid'] . '&sisAPWindowSize=6&sisAPTabsheetName=blockEditTab&sisAPWindowTitle=' . urlEncode($block['title']), 'target="_blank" title="' . _LNG_PGM_BLOCK_EDIT . '"'); t(''); a_(); t(''); }*/ td_(); tr_(); $i++; } table_(); script(); t(' function pgmNewBlock(e, obj) { showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addBlockUI') . '&showAllModule=1&windowId=" + $(this).closest(".sisAPWindow").attr("id") + "&globalBlocks=1", null, "dialogWidth:70%;dialogHeight:500px;ajax:true;title:' . _LNG_PGM_ADD_NEW_BLOCK . '"); } function pgmBlocksSelectAll(obj) { var $checkBoxes = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]"); $checkBoxes.prop("checked", $(obj).prop("checked")); $checkBoxes.each(function() { if ($(this).prop("checked")) { $(this).closest("tr").addClass("sisAPActive"); } else { $(this).closest("tr").removeClass("sisAPActive"); } }); } function pgmBlocksSelectRow(obj) { $(obj).closest("tr").toggleClass("sisAPActive"); } function pgmBlocksDeleteMultiple(obj) { var $items = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]:checked"); if ($items.length == 0) { sisAlert("' . _LNG_PGM_DELETE_SELECTED_EMPTY . '"); return; } sisConfirm("' . _LNG_PGM_DELETE_SELECTED_CONFIRM . '", null, null, function() { var items = new Array(); $items.each(function() { items.push($(this).val()); }); changeWindowLocation(obj, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'deleteBlock') . '&blockId=" + items.join(",")); }); } function pgmBlocksChangeStatus(obj, action) { var $items = $(obj).closest(".bootstrap-table").find("input[type=checkbox][value]:checked"); if ($items.length == 0) { sisAlert("' . _LNG_PGM_CHANGE_STATUS_SELECTED_EMPTY . '"); return; } sisConfirm(action == "active" ? "' . _LNG_PGM_ACTIVATE_SELECTED_CONFIRM . '" : "' . _LNG_PGM_DEACTIVATE_SELECTED_CONFIRM . '", null, null, function() { var items = new Array(); $items.each(function() { items.push($(this).val()); }); changeWindowLocation(obj, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'setBlockStatus') . '&blockId=" + items.join(",") + "&action=" + action); }); } '); script_(); } function BlockEdit() { $this->blockProperties(); } function createBlockCssClass($pageItemsTmpResponsive) { $classBlocks = ''; if (!$pageItemsTmpResponsive['block']['size']['xs']) { $pageItemsTmpResponsive['block']['size']['xs'] = 12; } if ($pageItemsTmpResponsive['block']['size']['lg'] == 'none') { $pageItemsTmpResponsive['block']['size']['lg'] = 12; //$classBlocks .= ' hidden-lg'; } if ($pageItemsTmpResponsive['block']['size']['md'] == 'none') { //$classBlocks .= ' hidden-md'; if (!intval($pageItemsTmpResponsive['block']['size']['lg'])) { $pageItemsTmpResponsive['block']['size']['lg'] = 12; } $pageItemsTmpResponsive['block']['size']['md'] = 12; } if ($pageItemsTmpResponsive['block']['size']['sm'] == 'none') { //$classBlocks .= ' hidden-sm'; if (!intval($pageItemsTmpResponsive['block']['size']['lg']) && !intval($pageItemsTmpResponsive['block']['size']['md'])) { $pageItemsTmpResponsive['block']['size']['md'] = 12; } $pageItemsTmpResponsive['block']['size']['sm'] = 12; } if ($pageItemsTmpResponsive['block']['size']['xs'] == 'none') { //$classBlocks .= ' hidden-xs'; if (!intval($pageItemsTmpResponsive['block']['size']['lg']) && !intval($pageItemsTmpResponsive['block']['size']['md']) && !intval($pageItemsTmpResponsive['block']['size']['sm'])) { $pageItemsTmpResponsive['block']['size']['sm'] = 12; } $pageItemsTmpResponsive['block']['size']['xs'] = 12; } if ($pageItemsTmpResponsive['block']['size']['lg'] != 0) { $classBlocks .= ' col-lg-' . $pageItemsTmpResponsive['block']['size']['lg']; } if ($pageItemsTmpResponsive['block']['size']['md'] != 0) { $classBlocks .= ' col-md-' . $pageItemsTmpResponsive['block']['size']['md']; } if ($pageItemsTmpResponsive['block']['size']['sm'] != 0) { $classBlocks .= ' col-sm-' . $pageItemsTmpResponsive['block']['size']['sm']; } if ($pageItemsTmpResponsive['block']['size']['xs'] != 0) { $classBlocks .= ' col-xs-' . $pageItemsTmpResponsive['block']['size']['xs']; } if ($pageItemsTmpResponsive['block']['offset']['lg'] != -1) { $classBlocks .= ' col-lg-offset-' . intval($pageItemsTmpResponsive['block']['offset']['lg']); } if ($pageItemsTmpResponsive['block']['offset']['md'] != -1) { $classBlocks .= ' col-md-offset-' . intval($pageItemsTmpResponsive['block']['offset']['md']); } if ($pageItemsTmpResponsive['block']['offset']['sm'] != -1) { $classBlocks .= ' col-sm-offset-' . intval($pageItemsTmpResponsive['block']['offset']['sm']); } if ($pageItemsTmpResponsive['block']['offset']['xs'] != -1) { $classBlocks .= ' col-xs-offset-' . intval($pageItemsTmpResponsive['block']['offset']['xs']); } if ($pageItemsTmpResponsive['block']['push']['lg'] != 0) { $classBlocks .= ' col-lg-push-' . $pageItemsTmpResponsive['block']['push']['lg']; } if ($pageItemsTmpResponsive['block']['push']['md'] != 0) { $classBlocks .= ' col-md-push-' . $pageItemsTmpResponsive['block']['push']['md']; } if ($pageItemsTmpResponsive['block']['push']['sm'] != 0) { $classBlocks .= ' col-sm-push-' . $pageItemsTmpResponsive['block']['push']['sm']; } if ($pageItemsTmpResponsive['block']['push']['xs'] != 0) { $classBlocks .= ' col-xs-push-' . $pageItemsTmpResponsive['block']['push']['xs']; } if ($pageItemsTmpResponsive['block']['pull']['lg'] != 0) { $classBlocks .= ' col-lg-pull-' . $pageItemsTmpResponsive['block']['pull']['lg']; } if ($pageItemsTmpResponsive['block']['pull']['md'] != 0) { $classBlocks .= ' col-md-pull-' . $pageItemsTmpResponsive['block']['pull']['md']; } if ($pageItemsTmpResponsive['block']['pull']['sm'] != 0) { $classBlocks .= ' col-sm-pull-' . $pageItemsTmpResponsive['block']['pull']['sm']; } if ($pageItemsTmpResponsive['block']['pull']['xs'] != 0) { $classBlocks .= ' col-xs-pull-' . $pageItemsTmpResponsive['block']['pull']['xs']; } return $classBlocks; } private function getPageServiceId($wdId) { $wdId = intval($wdId); $result = sisRunQuery(" SELECT wd2.sp_type_name type_name FROM saman_web_directories wd1 INNER JOIN saman_web_directories wd2 ON (wd1.sp_path LIKE CONCAT('%/', wd2.sp_id, '/%') OR wd1.sp_id = wd2.sp_id) WHERE wd1.sp_id = $wdId AND wd2.sp_type_name IS NOT NULL AND wd2.sp_type_name <> '' "); if ($result->fields['type_name']) { $serviceId = explode("_", $result->fields['type_name']); return intval($serviceId[1]); } return null; } function updateLastViewTime($spId) { sisRunQuery("UPDATE saman_web_directories SET last_view_date = '" . CurrentGDate() . "', last_view_time = '" . CurrentTime() . "' WHERE (sp_id = " . intval($spId) . ") "); } function recentViewRecord() { $result = sisRunQuery("SELECT sp_title, sp_id, sp_node_type, sp_lang FROM saman_web_directories WHERE (sp_parent_id = 0 OR sp_parent_id = " . _PGM_MAIN_WD_ID . ") AND sp_portal_id = " . sisGlobal("portal_id") . " AND (sp_node_type = " . WD_NODE_TYPE_CATEGORY_ITEM . " OR sp_node_type = -1 OR sp_node_type = 2) ORDER BY last_view_date DESC, last_view_time DESC LIMIT 0, 5", true); $subItems = array(); for ($i = 0; $i < count($result); $i++) { $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $result[$i]['sp_id'])); $pageId = $wdInfo['wd_pages']['node']; if ($result[$i]['sp_node_type'] == -1) { $title = localizedStr( $result[$i]['sp_title']) . " (" . _LNG_PGM_DUPLICATE_PAGE_ACTION . ")"; } if ($result[$i]['sp_node_type'] == 2) { $title = _LNG_PGM_PORTAL_MAIN_PAGE; } else { $title = $result[$i]['sp_title']; } $strSql = "SELECT * FROM saman_pages_detail WHERE sp_page_id =" . intval($pageId) . " AND sp_device = 0 AND sp_portal_id = " . intval(sisGlobal("portal_id")); $pageDetailRecords = sisRunQuery($strSql, true); if (count($pageDetailRecords)) { if (count($pageDetailRecords) == 1) { $pageLang = $pageDetailRecords[0]["sp_language"]; if(!$pageLang) { $pageLang = 'all'; } } else { $pageLang = sisUserGetLang(); $pageDetail = sisRunQuery($strSql . " AND sp_language = '" . sisVarPrepForStore($pageLang) . "'", true); if (count($pageDetail) == 0) { $pageLang = 'all'; $pageDetail = sisRunQuery($strSql . " AND (sp_language IS NULL OR sp_language = '' OR sp_language = 'all')" , true); } } } $subItems[$i] = array( 'title' => $result[$i]['sp_title'], 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_PAGE_DESIGN_WD_ID .'&pageWdId=' . $result[$i]['sp_id'] . '&pageNodeType=node&pageChannel=0&pageLang=' . $pageLang . '&pageIsDesign=0&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowSize=5&pageTitle='. $result[$i]['sp_title'] . ' | ' . _LNG_PGM_EDIT_PAGE, 'img' => 'fa fa-newspaper-o', ); } $menuItems = array( array( 'title' => _LNG_PGM_RECENT_VIEW, 'subItems' => $subItems, ) ); return $menuItems; } /*rest_method*/ function _getAdminPanelMenu() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $menuItems = array(); $menuItems[] = array('title' => '' . _LNG_PGM_NEW_PAGE, 'name' => 'pgmNewPage', 'url' => 'javascript:pgmMainMenuNewPage()', 'ignoreSearch' => true, 'dragData' => 'default'); $menuItems[] = array('title' => '' . _LNG_PGM_NEW_LAYOUT_TEMPLATE, 'name' => 'pgmNewLayoutTemplate', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_EDIT_WD_ID . '&sisAPTabsheetName=pgmTemplateDesignTab&sisAPWindowSize=4', 'ignoreSearch' => true, 'dragData' => 'default'); $menuItems[] = array('title' => '' . _LNG_PGM_NEW_MASTER_PAGE, 'name' => 'pgmNewMasterPage', 'url' => 'javascript:pgmMainMenuNewMasterPage()', 'ignoreSearch' => true, 'dragData' => 'default'); $menuItems[] = array('name' => 'pgmLists'); $menuItems[] = array('title' => _LNG_PGM_PAGES_LIST, 'name' => 'pgmNewPage', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_PAGES_LIST_WD_ID . '&sisAPWindowSize=1&sisAPHistory=reset', 'dragData' => 'default'); $menuItems[] = array('title' => _LNG_PGM_LAYOUT_TEMPLATES_LIST, 'name' => 'pgmNewLayoutTemplate', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_LIST_WD_ID . '&sisAPWindowSize=3&sisAPHistory=reset', 'dragData' => 'default'); //$menuItems[] = array('title' => _LNG_PGM_MASTER_PAGES_LIST, 'name' => 'pgmNewMasterPage', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_LIST_WD_ID. '&sisAPWindowSize=3&sisAPHistory=reset', 'dragData' => 'default'); $retValue = array(); $retValue['content'] = sisServiceAPIFunc('control_panel', 'admin', 'generateVerticalMenu', array('items' => $menuItems)); $retValue['size'] = 1; ob_start(); script(); t(' function pgmMainMenuNewPage() { sisPrompt("' . _LNG_PGM_ENTER_PAGE_TITLE . '", null, null, function(pageTitle) { pageTitle = pageTitle.replace(/(<([^>]+)>)/ig, "").trim(); if (!pageTitle) { sisAlert("' . _LNG_PGM_PAGE_TITLE_MANDATORY . '"); return false; } $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addNewPage') . '&parentWdId=' . _PGM_MAIN_WD_ID . '&pageTitle=" + pageTitle), function(pageId) { if (!isNaN(pageId)) { changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_PAGES_DESIGN_WD_ID . '&pageWdId=" + pageId + "&nodeType=node&sisAPWindowSize=5&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=" + pageTitle + "&sisAPTabId=pgmNodePage" + pageId, true); } }) }); } function pgmMainMenuNewMasterPage() { sisPrompt("' . _LNG_PGM_ENTER_MASTERPAGE_NAME . '", null, null, function(name) { name = name.trim(); var re = new RegExp("[A-Za-z_0-9\\-\\.]*"); if (!name || name != re.exec(name)) { sisAlert("' . _LNG_PGM_NAME_MUST_ENGLISH . '"); return false; } changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&sisAPTabsheetName=pgmMasterpageDesignTab&sisAPWindowSize=5&sisOp=new&masterpageName=" + name, true); }) } '); script_(); $retValue['content'] .= ob_get_clean(); return $retValue; } /*rest_method*/ function getAdminPanelMenu() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $menuItems = array(); $menuItems[] = array('title' => '' . _LNG_PGM_NEW_PAGE, 'name' => 'pgmNewPage', 'url' => 'javascript:pgmMainMenuNewPage()', 'ignoreSearch' => true, 'dragData' => 'default'); $menuItems[] = array('title' => '' . _LNG_PGM_NEW_MASTER_PAGE, 'name' => 'pgmNewMasterPage', 'url' => 'javascript:pgmMainMenuNewMasterPage()', 'ignoreSearch' => true, 'dragData' => 'default'); $menuItems[] = array('title' => '' . _LNG_PGM_NEW_BLOCK, 'name' => 'pgmNewBlock', 'url' => 'javascript:pgmMainMenuNewBlock()', 'ignoreSearch' => true, 'dragData' => 'default'); //$menuItems[] = array('title' => '' . _LNG_PGM_NEW_LAYOUT_TEMPLATE, 'name' => 'pgmNewLayoutTemplate', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_EDIT_WD_ID . '&sisAPTabsheetName=pgmTemplateDesignTab&sisAPWindowSize=4&sisAPHistory=reset', 'ignoreSearch' => true, 'dragData' => 'default'); $menuItems[] = array('name' => 'pgmLists'); //$menuItems[] = array('title' => _LNG_PGM_PAGES_LIST, 'name' => 'pgmNewPage', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_PAGES_LIST_WD_ID . '&sisAPWindowSize=1&sisAPHistory=reset', 'dragData' => 'default'); $menuItems[] = array('title' => _LNG_PGM_HOME_PAGES_LIST, 'name' => 'pgmHomePages', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_HOME_PAGES_LIST_WD_ID . '&sisAPWindowSize=3', 'dragData' => 'default'); $menuItems[] = array('title' => _LNG_PGM_MASTER_PAGES_LIST, 'name' => 'pgmMasterPages', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_LIST_WD_ID. '&sisAPWindowSize=3', 'dragData' => 'default'); $menuItems[] = array('title' => _LNG_PGM_BLOCKS_LIST, 'name' => 'pgmBlocks', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID . '&sisAPWindowSize=6', 'dragData' => 'default'); //$menuItems[] = array('title' => _LNG_PGM_LAYOUT_TEMPLATES_LIST, 'name' => 'pgmLayoutTemplates', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_LAYOUT_TEMPLATE_LIST_WD_ID . '&sisAPWindowSize=3&sisAPHistory=reset', 'dragData' => 'default'); $menuItems[] = array('title' => _LNG_PGM_SERVICE_PAGES_LIST, 'name' => 'pgmServicePages', 'url' => 'index.php?module=web_directory&wd_id=' . _PGM_SERVICES_PAGES_LIST_WD_ID . '&sisAPWindowSize=1', 'dragData' => 'default'); $retValue = array(); $retValue['content'] = sisServiceAPIFunc('control_panel', 'admin', 'generateVerticalMenu', array('items' => $menuItems)); $retValue['size'] = 1; ob_start(); script(); t(' function pgmMainMenuNewPage() { sisPrompt("' . _LNG_PGM_ENTER_PAGE_TITLE . '", null, null, function(pageTitle) { pageTitle = pageTitle.replace(/(<([^>]+)>)/ig, "").trim(); if (!pageTitle) { sisAlert("' . _LNG_PGM_PAGE_TITLE_MANDATORY . '"); return false; } $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addNewPage') . '&parentWdId=' . _PGM_MAIN_WD_ID . '&pageTitle=" + pageTitle + "&backUrl=index.php?module=web_directory&wd_id=' . _PGM_SERVICE_PAGES_LIST_WD_ID . '&serviceWdId=' . $serviceWdId . '"), function(pageId) { }) }); } function pgmMainMenuNewMasterPage() { sisPrompt("' . _LNG_PGM_ENTER_MASTERPAGE_NAME . '", null, null, function(name) { name = name.trim(); var re = new RegExp("[A-Za-z_0-9\\-\\.]*"); if (!name || name != re.exec(name)) { sisAlert("' . _LNG_PGM_NAME_MUST_ENGLISH . '"); return false; } changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&sisAPTabsheetName=pgmMasterpageDesignTab&sisAPWindowSize=5&sisOp=new&masterpageName=" + name + "&sisAPHistory=reset", true); }) } function pgmMainMenuNewBlock() { showModalDialog.call(this, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addBlockUI') . '&showAllModule=1&globalBlocks=1", null, "dialogWidth:70%;dialogHeight:500px;ajax:true;title:' . _LNG_PGM_ADD_NEW_BLOCK . '"); } '); script_(); $retValue['content'] .= ob_get_clean(); $retValue = json_encode($retValue); die($retValue); } /*rest_method*/ function loadNodeItems() { Header("Content-Type: application/json"); if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $this->loadLangs(); $serviceWdId = intval(sisParam('serviceWdId')); $directoryInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $serviceWdId)); $contentType = getContentType(str_replace('cdk_', '', $directoryInfo['type_name'])); $serviceUI = sisParam('serviceUI') == "true" && (sisIsDevelopmentVersion() || !$contentType['is_system']); $parentWdId = intval(sisVarFromInput('parentWdId')); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $parentWdId > 0 ? $parentWdId : $serviceWdId)); if (!$wdInfo) { die(); } $extraWhere = 'sp_id != ' . _PGM_MAIN_WD_ID; if (!$serviceUI && ($parentWdId == _PGM_MAIN_WD_ID || strpos($wdInfo['path'], '/' . _PGM_MAIN_WD_ID . '/') !== false)) { $changeNodeType = 'page'; $extraWhere .= ' AND sp_node_type = ' . WD_NODE_TYPE_CATEGORY_ITEM; } if ($serviceUI && $parentWdId < 0) { $extraWhere .= ' AND sp_node_type = ' . WD_NODE_TYPE_SIMPLE; if ($parentWdId == -1) { $extraWhere .= ' AND sp_is_admin = 0'; } if ($parentWdId == -2) { $extraWhere .= ' AND sp_is_admin = 1'; } } $cats = sisServiceAPIFunc('web_directory', 'admin', 'getAll', array('portal_id' => sisGlobal('portal_id'), 'hide_syetem_node' => !$serviceUI, 'parent_id' => $parentWdId > 0 ? $parentWdId : $serviceWdId, 'level' => $wdInfo['level'] + 1, 'display_childs_count' => true, 'extra_where' => $extraWhere)); for ($idx = 0; $idx < $catsCount; $idx++) { $cats[$idx]['title'][$lang] = localizedStr($cats[$idx]['title'][$lang]); } $items = sisServiceFunc('web_directory', 'admin', 'createJSTree', array('cats'=>$cats, 'changeNodeType' => $changeNodeType, 'ajaxLoad' => true)) ; if ($wdInfo['node_type'] == WD_NODE_TYPE_PORTAL) { usort($items, function($a, $b) { return $a['text'] >= $b['text'];}); } die(json_encode($items)); } /*rest_method*/ function searchPageId() { Header("Content-Type: application/json"); if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $searchPageId = sisParam('searchPageId'); $parentWdId = intval(sisParam('parentWdId')); $serviceUI = sisParam('serviceUI') == "true" && sisIsDevelopmentVersion(); if (!$searchPageId) { die(); } $result = sisRunQuery("SELECT sp_id, sp_path FROM saman_web_directories WHERE (sp_id = " . intval($searchPageId) . " OR sp_object_id = '" . sisVarPrepForDisplay($searchPageId) . "') AND sp_portal_id = " . sisGlobal("portal_id"), true); if (!$result[0]['sp_path']) { die(); } if ($serviceUI) { $result[0]['sp_path'] = substr($result[0]['sp_path'], strpos($result[0]['sp_path'], '/' . $parentWdId . '/')); } else { if (strpos($result[0]['sp_path'], '/' . _PGM_MAIN_WD_ID . '/') === false) { $path = explode("/", $result[0]['sp_path']); $path = array_merge(array_slice($path, 0, 2, true), array(0 => 'services'), array_slice($path, 2, count($path) - 1, true)); $result[0]['sp_path'] = implode($path, "/"); } } $searchPageId = $result[0]['sp_id']; $path = explode("/", $result[0]['sp_path'] . $searchPageId); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $path[2])); if ($wdInfo['node_type'] == WD_NODE_TYPE_SIMPLE) { if ($wdInfo['is_admin']) { $result = array_slice($path, 0, 2); $result[] = '-2'; $result = array_merge($result, array_slice($path, 2) ? array_slice($path, 2) : array()); } else { $result = array_slice($path, 0, 2); $result[] = '-1'; $result = array_merge($result, array_slice($path, 2) ? array_slice($path, 2) : array()); } $path = $result; } die(json_encode(implode($path, '/'))); } /*rest_method*/ function addNewPage() { Header("Content-Type: application/json"); if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $modulePagesUI = sisParam('modulePagesUI'); $pageTitle = trim(sisParam('pageTitle')); $parentWdId = intval(sisParam('parentWdId')); $serviceUI = sisParam('serviceUI') == "true" /*&& sisIsDevelopmentVersion()*/; $serviceWdId = intval(sisParam('serviceWdId')); $isAdmin = intval(sisParam('isAdmin')); if (!$pageTitle || !$parentWdId) { die(); } $params['title'] = $pageTitle; $params['parent_id'] = $parentWdId > 0 ? $parentWdId : $serviceWdId; $params['portal_id'] = sisGlobal('portal_id'); $params['node_type'] = $serviceUI || $modulePagesUI ? WD_NODE_TYPE_SIMPLE : WD_NODE_TYPE_CATEGORY_ITEM; $params['is_admin'] = $isAdmin; if ($serviceUI && !$modulePagesUI) { $params['is_system'] = 1; } $retValue = sisServiceAPIFunc('web_directory', 'admin', 'create', $params); if ($retValue) { $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $retValue]; sisRaiseEvent('sis_page_manager', 'CREATE_PAGE', SIS_EVENT_TYPE_CREATE, array('objectName' => 'Page : ' . $retValue, 'objectId' => $retValue, 'newRecord' => $params, 'dimensions' => $dimensions)); sisSetStatusMsg(); } if (sisParam('backUrl')) { sisServerTransfer($backUrl, true); } else { die(json_encode($retValue)); } } /*rest_method*/ function deleteNode($pageWdId = null) { Header("Content-Type: application/json"); if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageWdId = $pageWdId !== null ? intval($pageWdId) : intval(sisParam('pageWdId')); $portalId = intval(sisGlobal('portal_id')); if (!$pageWdId) { return; } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { return; } $childPagesCount = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_web_directories WHERE sp_parent_id = $pageWdId AND sp_portal_id = $portalId", true); if ($childPagesCount[0]['rec_count']) { die(json_encode(_LNG_PGM_DELETE_PAGE_ERROR)); } $copyRecords = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_parent_id = $pageWdId AND sp_node_type = -1 AND sp_portal_id = " . sisGlobal('portal_id'), true); foreach ($copyRecords as $copyRecord) { $this->deleteWDPage($copyRecord['sp_id']); } foreach ($wdInfo['wd_pages'] as $deletePage) { if ($deletePage) { $record = sisRunQuery("SELECT sp_language FROM saman_pages_detail WHERE sp_page_id = $deletePage AND sp_portal_id = $portalId", true); foreach ($record as $lang) { $this->deletePage($deletePage, $lang['sp_language'], $portalId); } } } sisRunQuery("DELETE FROM saman_web_directories WHERE sp_id = $pageWdId AND sp_portal_id = " . sisGlobal('portal_id')); sisRunQuery("DELETE FROM saman_page_services WHERE sp_service = 'web_$pageWdId' AND sp_portal_id = " . sisGlobal('portal_id'), true); sisCacheDel('web_directory_info_' . $pageWdId); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; sisRaiseEvent('sis_page_manager', 'DELETE_PAGE', SIS_EVENT_TYPE_DELETE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageType' => $nodeType, 'extraInfo' => $wdInfo, 'dimensions' => $dimensions)); die(); } /*rest_method*/ function deleteWDPage($pageWdId = null, $nodeType = null, $redirect = true) { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageWdId = $pageWdId !== null ? intval($pageWdId) : intval(sisParam('pageWdId')); $portalId = intval(sisGlobal('portal_id')); if (!$pageWdId) { return; } $nodeType = $nodeType !== null ? $nodeType : sisParam('nodeType'); $redirect = sisParam('backUrl') ? $redirect : false; $fieldName = ''; switch ($nodeType) { case 'node': $fieldName = 'sp_node_page_id'; $nodeType = 'node'; break; case 'view': $fieldName = 'sp_view_page_id'; $nodeType = 'view'; break; case 'edit': $fieldName = 'sp_edit_page_id'; $nodeType = 'edit'; break; } if (!$fieldName && $redirect) { sisServerTransfer(base64_decode(sisParam('backUrl')), true); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { if ($redirect) { sisRaiseException(_LNG_PGM_DELETE_PAGE_ERROR); sisServerTransfer(base64_decode(sisParam('backUrl')), true); } return; } $copyRecords = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_parent_id = $pageWdId AND sp_node_type = -1 AND sp_portal_id = " . sisGlobal('portal_id'), true); foreach ($copyRecords as $copyRecord) { $this->deleteWDPage($copyRecord['sp_id'], $nodeType, false); } foreach ($wdInfo['wd_pages'] as $deletePage) { if ($deletePage) { $record = sisRunQuery("SELECT sp_language FROM saman_pages_detail WHERE sp_page_id = $deletePage AND sp_portal_id = $portalId", true); foreach ($record as $lang) { $this->deletePage($deletePage, $lang['sp_language'], $portalId); } } } sisRunQuery("UPDATE saman_web_directories SET $fieldName = 0 WHERE sp_id = $pageWdId AND sp_portal_id = $portalId"); if (($wdInfo['node_type'] == '-1' || $wdInfo['parent_id'] == _PGM_MAIN_WD_ID) || ($wdInfo['node_type'] == '0' && $wdInfo['is_admin'] == '0' && $wdInfo['is_system'] == '0')) { $record = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_id = $pageWdId AND sp_portal_id = $portalId AND sp_node_page_id = 0 AND sp_edit_page_id = 0 AND sp_view_page_id = 0", true); if ($record[0]['sp_id']) { sisRunQuery("DELETE FROM saman_web_directories WHERE sp_id = $pageWdId AND sp_portal_id = " . sisGlobal('portal_id')); sisCacheDel('web_directory_info_' . $pageWdId); } } sisRunQuery("DELETE FROM saman_page_services WHERE sp_service = 'web_$pageWdId' AND sp_portal_id = " . sisGlobal('portal_id'), true); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; sisRaiseEvent('sis_page_manager', 'DELETE_PAGE', SIS_EVENT_TYPE_DELETE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageType' => $nodeType, 'extraInfo' => $wdInfo, 'dimensions' => $dimensions)); if ($redirect) { sisSetStatusMsg(); sisServerTransfer(base64_decode(sisParam('backUrl')), true); } } /*rest_method*/ function deleteMultiplePage($pages = null, $redirect = true) { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pages = $pages !== null ? $pages : sisParam('pageId'); $portalId = intval(sisGlobal('portal_id')); if (!$pages) { return; } $arrPage = split(",", $pages); for ($i = 0; $i< count($arrPage); $i++) { if ($arrPage[$i]) { $this->deleteWDPage($arrPage[$i], 'node', false); } } sisServerTransfer('index.php?module=web_directory&wd_id=' . _PGM_HOME_PAGES_LIST_WD_ID, true); } /*rest_method*/ function moveNode() { Header("Content-Type: application/json"); if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $srcNodeWdId = intval(sisParam('srcNodeWdId')); $destNodeWdId = intval(sisParam('destNodeWdId')); if ($destNodeWdId < 0) { $destNodeWdId = intval(sisParam('serviceWdId')); } $prevNodeWdId = intval(sisParam('prevNodeWdId')); if (!$srcNodeWdId || !$destNodeWdId | $prevNodeWdId < 0) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } $srcNode = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $srcNodeWdId)); $destNode = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $destNodeWdId)); $serviceUI = sisParam('serviceUI') == "true" && sisIsDevelopmentVersion(); if (!$serviceUI && (!$srcNode['id'] || !$destNode['id'] || $srcNode['node_type'] != WD_NODE_TYPE_CATEGORY_ITEM || strpos($srcNode['path'], '/' . _PGM_MAIN_WD_ID . '/') === false || ($destNode['node_type'] != WD_NODE_TYPE_CATEGORY_ITEM && $destNode['node_type'] != WD_NODE_TYPE_SERIVCE) || (strpos($destNode['path'], '/' . _PGM_MAIN_WD_ID . '/') === false && $destNode['id'] != _PGM_MAIN_WD_ID))) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } if ($prevNodeWdId) { $prevNode = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $prevNodeWdId)); if (!$prevNode['id']) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } } $record = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE '{$srcNode['path']}' LIKE CONCAT('%/', sp_id, '/%') AND sp_node_type IN (" . WD_NODE_TYPE_SERIVCE . ", " . WD_NODE_TYPE_PORTAL . ") ORDER BY sp_level DESC LIMIT 1", true); if (!$record[0]['sp_id']) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } $srcNodeParent = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $record[0]['sp_id'])); if (!$srcNodeParent['id']) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } $record = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE '{$destNode['path']}' LIKE CONCAT('%/', sp_id, '/%') AND sp_node_type IN (" . WD_NODE_TYPE_SERIVCE . ", " . WD_NODE_TYPE_PORTAL . ") ORDER BY sp_level DESC LIMIT 1", true); if ($serviceUI || $destNodeWdId == _PGM_MAIN_WD_ID) { $destNodeParent = $destNode; } else { $destNodeParent = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $record[0]['sp_id'])); } if ($srcNode['node_type'] == WD_NODE_TYPE_SERIVCE && $destNode['node_type'] != WD_NODE_TYPE_PORTAL) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } if (($srcNode['node_type'] == WD_NODE_TYPE_SERVICE_CATEGORY || $srcNode['node_type'] == WD_NODE_TYPE_CATEGORY_ITEM) && $destNode['node_type'] == WD_NODE_TYPE_SIMPLE) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } if ($srcNode['node_type'] == WD_NODE_TYPE_SIMPLE && ($destNode['node_type'] == WD_NODE_TYPE_SERVICE_CATEGORY || $destNode['node_type'] == WD_NODE_TYPE_CATEGORY_ITEM)) { die(json_encode(_LNG_PGM_MOVE_NODE_ERROR)); } $record = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_parent_id = $destNodeWdId AND sp_portal_id = " . sisGlobal('portal_id') . " ORDER BY sp_order", true); for ($idx = 0; $idx < count($record); $idx++) { sisRunQuery("UPDATE saman_web_directories SET sp_order = $idx WHERE sp_id = {$record[$idx]['sp_id']} AND sp_portal_id = " . sisGlobal('portal_id')); } $newPath = $destNode['path'] . $destNode['id'] . '/'; $newChildPath = $newPath . $srcNode['id'] . '/'; $oldChildPath = $srcNode['path'] . $srcNode['id'] . '/'; $newOrder = 0; if ($prevNode) { $newOrder = $prevNode['order'] + 1; } sisRunQuery("UPDATE saman_web_directories SET sp_order = sp_order + 1 WHERE sp_parent_id = $destNodeWdId AND sp_order >= $newOrder AND sp_portal_id = " . sisGlobal('portal_id')); sisRunQuery("UPDATE saman_web_directories SET sp_order = $newOrder, sp_path = '$newPath', sp_parent_id = $destNodeWdId WHERE sp_id = $srcNodeWdId AND sp_portal_id = " . sisGlobal('portal_id')); sisRunQuery("UPDATE saman_web_directories SET sp_path = REPLACE(sp_path, '$oldChildPath', '$newChildPath') WHERE sp_path LIKE '%$oldChildPath%' AND sp_portal_id = " . sisGlobal('portal_id')); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $srcNodeWdId]; sisRaiseEvent('sis_page_manager', 'MOVE_PAGE', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $srcNodeWdId", 'objectId' => $srcNodeWdId, 'newOrder' => $newOrder, 'newPath' => $newPath, 'extraInfo' => $srcNode, 'dimensions' => $dimensions), 'EDIT_PAGE'); die(json_encode(null)); } /*rest_method*/ function pageAction() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageWdId = intval(sisParam('pageWdId')); $masterpageId = intval(sisParam('masterpageId')); $action = sisParam('pmgAction'); $portalId = sisGlobal('portal_id'); $pageIsDesign = intval(sisParam('pageIsDesign')); $pageTheme = sisParam('pageTheme'); $pageTitle = sisParam('pageTitle'); $source = ''; if ($pageWdId) { $source = 'page'; $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { die(); } $pageLang = sisParam('pageLang'); $pageChannel = intval(sisParam('pageChannel')); if (!$action) { die(); } switch (sisParam('pageNodeType')) { case 'node': $fieldName = 'sp_node_page_id'; $pageNodeType = 'node'; break; case 'view': $fieldName = 'sp_view_page_id'; $pageNodeType = 'view'; break; case 'edit': $fieldName = 'sp_edit_page_id'; $pageNodeType = 'edit'; break; } $channels = array( 'all' => array('title' => _LNG_PGM_CHANNEL_ALL, 'icon' => 'globe', 'name' => 'all'), 'desktop' => array('title' => _LNG_PGM_CHANNEL_DESKTOP, 'icon' => 'desktop', 'name' => 'desktop'), 'mobile' => array('title' => _LNG_PGM_CHANNEL_MOBILE, 'icon' => 'mobile', 'name' => 'mobile'), 'tablet' => array('title' => _LNG_PGM_CHANNEL_TABLET, 'icon' => 'tablet', 'name' => 'tablet'), 'weak_person' => array('title' => _LNG_PGM_CHANNEL_WEAK_PERSON, 'icon' => 'wheelchair'), 'bot' => array('title' => _LNG_PGM_CHANNEL_BOT, 'icon' => 'bug', 'name' => 'bot'), 'old_browser' => array('title' => _LNG_PGM_CHANNEL_OLD_BROWSER, 'icon' => 'internet-explorer', 'name' => 'old_browser'), 'high_traffic' => array('title' => _LNG_PGM_CHANNEL_HIGH_TRAFFIC, 'icon' => 'line-chart', 'name' => 'high_traffic'), 'low_speed' => array('title' => _LNG_PGM_CHANNEL_LOW_SPEED, 'icon' => 'hourglass-start'), ); $channels = array_values($channels); $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; if (!$pageWdId || !$pageNodeType || !$languages[$pageLang] || !$channels[$pageChannel]) { die(); } $pageId = $wdInfo['wd_pages'][$pageNodeType]; if (!$pageId) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } $pageDetailRecord = sisRunQuery("SELECT * FROM saman_pages_detail WHERE sp_page_id = $pageId AND " . ($pageLang != "all" ? "sp_language = '" . sisVarPrepForStore($pageLang) . "'" : " (sp_language IS NULL OR sp_language = '' OR sp_language = 'all') ") . " AND sp_device = $pageChannel AND sp_portal_id = $portalId", true); if (!$pageDetailRecord[0]) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } } else if ($masterpageId) { $source = 'masterpage'; $pageDetailRecord = sisRunQuery(" SELECT pd.* FROM saman_pages pg INNER JOIN saman_pages_detail pd ON (pg.sp_page_id = pd.sp_page_id) WHERE pg.sp_page_id = $masterpageId AND pg.sp_portal_id = $portalId AND pg.sp_is_master = 1", true); if (!$pageDetailRecord[0]) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } } else { die(); } switch ($action) { case 'changeMasterpageProperties': if (!sisParam('newThemeTemplate') || !sisParam('newLayoutTemplate')) { die(); } $newThemeTemplate = sisParam('newThemeTemplate'); $newLayoutTemplate = sisParam('newLayoutTemplate'); $newCode = sisParam('newCode'); $newIsSystem = intval(sisParam('newIsSystem')); $newShowTitle = intval(sisParam('newShowTitle')); $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages WHERE sp_code = '" . sisVarPrepForStore($newCode) . "' AND sp_page_id <> '$masterpageId' AND sp_is_master = 1 AND sp_portal_id = $portalId", true); if ($record[0]['rec_count']) { sisRaiseException(_LNG_PGM_MASTERPAGE_NAME_EXISTS); } else { sisRunQuery("UPDATE saman_pages pg INNER JOIN saman_pages_detail pd ON (pg.sp_page_id = pd.sp_page_id) SET pg.sp_code = '" . sisVarPrepForStore($newCode) . "', pd.sp_layout_template = '" . sisVarPrepForStore($newThemeTemplate) . "', pd.sp_show_title = '" . sisVarPrepForStore($newShowTitle) . "', pd.sp_page_template = '" . sisVarPrepForStore($newLayoutTemplate) . "' " . (sisCheckUserLicense(PORTAL_CORE_DEVELOPER) ? ", pg.sp_is_system = " . intval($newIsSystem) : "") . " WHERE pg.sp_page_id = '$masterpageId' AND sp_page_detail_id = {$pageDetailRecord[0][sp_page_detail_id]} AND pg.sp_portal_id = $portalId"); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $masterpageId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageDetailRecord[0]['sp_page_detail_id']]; sisRaiseEvent('sis_page_manager', 'CHANGE_MASTER_PAGE_TEMPLATE', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Master page : $masterpageId", 'objectId' => $masterpageId, 'newRecord' => array('sp_code' => $newCode, 'sp_layout_template' => $newThemeTemplate, 'sp_page_template' => $newLayoutTemplate, 'sp_show_title' => intval($newShowTitle),'sp_is_system' => intval($newIsSystem)), 'oldRecord' => $pageDetailRecord[0], 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); sisSetStatusMsg(); } break; case 'changeProperties': if (!sisParam('newMasterpage') && (!sisParam('newThemeTemplate') || !sisParam('newLayoutTemplate'))) { die(); } $newThemeTemplate = sisParam('newThemeTemplate'); $newShowTitle = sisParam('newShowTitle'); $newLayoutTemplate = sisParam('newLayoutTemplate'); $newMasterpage = intval(sisParam('newMasterpage')); if ($newMasterpage) { sisRunQuery("UPDATE saman_pages_detail SET sp_masterpage_id = '" . $newMasterpage . "' WHERE sp_page_detail_id = {$pageDetailRecord[0][sp_page_detail_id]} AND sp_portal_id = $portalId"); } else { sisRunQuery("UPDATE saman_pages_detail SET sp_layout_template = '" . sisVarPrepForStore($newThemeTemplate) . "', sp_show_title = '" . intval($newShowTitle) . "', sp_page_template = '" . sisVarPrepForStore($newLayoutTemplate) . "', sp_masterpage_id = null WHERE sp_page_detail_id = {$pageDetailRecord[0][sp_page_detail_id]} AND sp_portal_id = $portalId"); } $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageDetailRecord[0]['sp_page_detail_id']]; sisRaiseEvent('sis_page_manager', 'CHANGE_PAGE_TEMPLATE', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $channels[$pageChannel]['name'], 'pageType' => $pageNodeType, 'pageDetailId' => $pageDetailRecord[0]['sp_page_detail_id'], 'newRecord' => array('sp_layout_template' => $newThemeTemplate, 'sp_show_title' => $newShowTitle, 'sp_page_template' => $newLayoutTemplate), 'oldRecord' => $pageDetailRecord[0], 'dimensions' => $dimensions), 'EDIT_PAGE'); sisSetStatusMsg(); break; case 'movePageItem': $pageItemId = intval(sisParam('pageItemId')); $pageZoneId = intval(sisParam('pageZoneId')); $masterpageContainerId = intval(sisParam('masterpageContainerId')); $pagePreviousItemId = intval(sisParam('pagePreviousItemId')); if (!$pageItemId) { die(); } $pageItemInfo = $this->getPageItem($pageItemId); if (!$pageItemInfo) { die(); } $pageRecord = sisRunQuery("SELECT sp_page_id FROM saman_pages_detail WHERE sp_page_detail_id = $pageItemInfo[sp_page_id] AND sp_portal_id = $portalId", true); $positionWhereClause = ''; $positionUpdateClause = ''; if ($masterpageContainerId) { $positionWhereClause = "sp_container_id = $masterpageContainerId"; $positionUpdateClause = "sp_container_id = $masterpageContainerId"; } else { $positionWhereClause = "sp_position = $pageZoneId"; $positionUpdateClause = "sp_position = $pageZoneId"; } $previousWeight = -9999; $pageId = $pageItemInfo['sp_page_id']; if ($pagePreviousItemId) { $pagePreviousItemInfo = $this->getPageItem($pagePreviousItemId); if (!$pagePreviousItemInfo) { die(); } $previousWeight = $pagePreviousItemInfo['sp_weight']; } $sqlObj = new \sisSQL(); $sqlObj->db->BeginTrans(); $sqlObj->setSql(" UPDATE saman_page_items SET sp_weight = sp_weight * 100 WHERE sp_page_id = $pageId AND $positionWhereClause AND sp_weight > " . intval($previousWeight) . " AND sp_portal_id = $portalId"); $sqlObj->runQuery(); $sqlObj->setSql(" UPDATE saman_page_items SET sp_weight = '" . ($previousWeight + 1) . "', $positionUpdateClause WHERE sp_bid = $pageItemId AND sp_portal_id = $portalId"); $sqlObj->runQuery(); if (!$this->rearrangePageItems($pageId, array('sqlObj' => &$sqlObj)) && ($pageItemInfo['sp_page_id'] != $pageId && !$this->rearrangePageItems($pageItemInfo['sp_page_id'], array('sqlObj' => &$sqlObj)))) { $sqlObj->db->RollbackTrans(); } else { if ($source == 'page') { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageItemInfo['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $pageItemInfo['sp_bid']]; sisRaiseEvent('sis_page_manager', 'MOVE_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $pageItemInfo['sp_bid'], 'pageDetailId' => $pageItemInfo['sp_page_id'], 'pageLang' => $pageLang, 'pageChannel' => $channels[$pageChannel]['name'], 'pageType' => $pageNodeType, 'containerId' => $masterpageContainerId, 'position' => $pageZoneId, 'weight' => ($previousWeight + 1), 'oldRecord' => $pageItemInfo, 'dimensions' => $dimensions), 'EDIT_PAGE'); } else { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageItemInfo['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $pageItemInfo['sp_bid']]; sisRaiseEvent('sis_page_manager', 'MOVE_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'] , 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $pageItemInfo['sp_bid'], 'pageDetailId' => $pageItemInfo['sp_page_id'], 'pageLang' => $pageLang, 'pageChannel' => $channels[$pageChannel]['name'], 'containerId' => $masterpageContainerId, 'position' => $pageZoneId, 'weight' => ($previousWeight + 1), 'oldRecord' => $pageItemInfo, 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); } $sqlObj->db->CommitTrans(); } break; } if ($source == 'page') { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGE_DESIGN_WD_ID . "&pageWdId=$pageWdId&pageNodeType=$pageNodeType&pageChannel=$pageChannel&pageLang=$pageLang&pageIsDesign=$pageIsDesign&pageTheme=$pageTheme&pageTitle=" . urlencode($pageTitle), true); } else if ($source == 'masterpage') { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_MASTERPAGE_EDIT_WD_ID . "&masterpageId=$masterpageId&pageTheme=$pageTheme", true); } } /*rest_method*/ function savePageItem() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $items = sisParam('items'); $properties = sisParam('properties'); $content = sisParam('content'); $pageItemId = intval($items['bid']); $portalId = sisGlobal('portal_id'); $pageWdId = sisParam('pageWdId'); if (!$pageItemId) { die(); } $itemInfoOld = sisServiceAPIFunc('pmk', 'admin', 'getItemInfo', array('item_id' => $pageItemId)); if (!$itemInfoOld) { die(); } $pageRecord = sisRunQuery("SELECT pd.sp_page_id, pg.sp_is_master FROM saman_pages_detail pd INNER JOIN saman_pages pg ON (pd.sp_page_id = pg.sp_page_id) WHERE pd.sp_page_detail_id = $itemInfoOld[item_page_id] AND pd.sp_portal_id = $portalId AND pg.sp_portal_id = $portalId", true); foreach ($items as $key => $value) { $itemInfoOld["item_$key"] = $value; } $modinfo = sisServiceGetInfo($itemInfoOld['item_mid']); if ($itemInfoOld['item_type'] == 1 && !sisPortletLoad($modinfo['name'], $itemInfoOld['item_bkey'])) { die(); } $itemInfoTmp = array(); foreach ($itemInfoOld as $key => $value) { if (strpos($key, "item_") === 0) { $itemInfoTmp[substr($key, 5)] = $value; } else { $itemInfoTmp[$key] = $value; } } $itemInfo = $itemInfoTmp; unset($itemInfoTmp); if ($itemInfo['block_id']) { $blockInfoParent = sisPortletGetInfo($itemInfo['block_id']); $blockParentVars = sisPortletVarsFromContent($blockInfoParent['content']); } if ($blockInfoParent['settings'] && is_array($blockInfoParent['settings'])) { $GLOBALS['object_settings'] = array(); foreach ($blockInfoParent['settings'] as $key => $value) { $GLOBALS['object_settings'][$itemInfo['bkey']][] = $key; } } $usname = preg_replace('/ /', '_', $modinfo['name']); $updatefunc = $usname . '_' . $itemInfo['bkey'] . 'block_update'; if (function_exists($updatefunc)) { $itemInfo = $updatefunc($itemInfo); if (!$itemInfo) { die(); } } else { // Old way $itemsModules = $GLOBALS['blocks_modules'][$itemInfo['mid']]; if (!empty($itemsModules[$itemInfo['bkey']]) && !empty($itemsModules[$itemInfo['bkey']]['func_update'])) { if (function_exists($itemsModules[$itemInfo['bkey']]['func_update'])) { $itemInfo = $itemsModules[$itemInfo['bkey']]['func_update'](array_merge($_POST, $itemInfo)); } } } if ($itemInfo['block_id'] || $GLOBALS['block_extra_properties'][$itemInfo['bkey']]){ if ($itemInfo['block_id']) { $blockinfo = sisPortletGetInfo($itemInfo['block_id']); $propertiesTmp1 = array(); if ($blockinfo['service_bid']) { $blockInfoOtherService = sisPortletGetInfo($blockinfo['service_bid']); try { @eval("\$propertiesTmp1=array($blockInfoOtherService[properties]);"); } catch (\ParseError $ex) {} if (count($propertiesTmp1) == 0) { try { @eval("\$propertiesTmp1 = $blockInfoOtherService[properties];"); } catch (\ParseError $ex) {} } foreach ($propertiesTmp1 as $key => $value) { if ($blockInfoOtherService['settings'][$key]) unset($propertiesTmp1[$key]); } } $propertiesTmp2 = array(); if (!empty($blockinfo['properties'])) { try { @eval("\$propertiesTmp2 = array($blockinfo[properties]);"); } catch (\ParseError $ex) {} if (count($propertiesTmp2) == 0) { try { @eval("\$propertiesTmp2 = $blockinfo[properties];"); } catch (\ParseError $ex) {} } } $propertiesTmp = array_merge($propertiesTmp1, $propertiesTmp2); /* if ($blockinfo['properties']){ eval("\$propertiesTmp = array($blockinfo[properties]);"); }*/ } else { $propertiesTmp = $GLOBALS['block_extra_properties'][$itemInfo['bkey']]; } if ($propertiesTmp){ $propertyValues = array(); foreach ($propertiesTmp as $key=>$value) { $postKey = str_replace(array(" ", ".", "#", ":"), array("__b__", "__d__", "__s__", "__c__"), $key); $propertyValues[$key] = array(); $propertyValues[$key]['value'] = $properties[$postKey]; } $itemInfo['property_values'] = serialize($propertyValues); } } if ($properties['_params_']) { $itemInfo['property_values'] = unserialize($itemInfo['property_values']); $itemInfo['property_values']['_params_'] = $properties['_params_']; $itemInfo['property_values'] = serialize($itemInfo['property_values']); } $itemInfoNew = array(); foreach ($itemInfo as $key => $value) { $itemInfoNew["item_$key"] = $value; } if ($_FILES['items']['name']['header_image']) { $itemInfoNew["item_header_image"] = array('name' => $_FILES['items']['name']['header_image'], 'type' => $_FILES['items']['type']['header_image'], 'tmp_name' => $_FILES['items']['tmp_name']['header_image'], 'error' => $_FILES['items']['error']['header_image'], 'size' => $_FILES['items']['size']['header_image']); } if ($_FILES['items']['name']['footer_image']) { $itemInfoNew["item_footer_image"] = array('name' => $_FILES['items']['name']['footer_image'], 'type' => $_FILES['items']['type']['footer_image'], 'tmp_name' => $_FILES['items']['tmp_name']['footer_image'], 'error' => $_FILES['items']['error']['footer_image'], 'size' => $_FILES['items']['size']['footer_image']); } if ($_FILES['items']['name']['back_image']) { $itemInfoNew["item_back_image"] = array('name' => $_FILES['items']['name']['back_image'], 'type' => $_FILES['items']['type']['back_image'], 'tmp_name' => $_FILES['items']['tmp_name']['back_image'], 'error' => $_FILES['items']['error']['back_image'], 'size' => $_FILES['items']['size']['back_image']); } if ($content) { if (is_array($content)) { $itemInfoNew['item_content'] = unserialize($itemInfoNew['item_content']); foreach ($content as $key => $value) { $itemInfoNew['item_content'][$key] = $value; } $itemInfoNew['item_content'] = serialize($itemInfoNew['item_content']); } else { $itemInfoNew['item_content'] = $content; } } $itemInfoNew['item_responsive_settings'] = serialize(sisParam('responsive_settings')); sisCacheDel("cache_block_$itemInfoNew[item_bkey]_$itemInfoNew[item_bid]", true); sisServiceAPIFunc('pmk', 'admin', 'updateBlockPageItem', $itemInfoNew); if (!$pageRecord[0]['sp_is_master']) { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $itemInfoOld['item_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $itemInfoOld['item_bid']]; sisRaiseEvent('sis_page_manager', 'EDIT_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $itemInfoOld['item_bid'], 'pageDetailId' => $itemInfoOld['item_page_id'], 'newRecord' => $itemInfoNew, 'oldRecord' => $pageItemInfo, 'dimensions' => $dimensions), 'EDIT_PAGE'); } else { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $itemInfoOld['item_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $itemInfoOld['item_bid']]; sisRaiseEvent('sis_page_manager', 'EDIT_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'], 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $itemInfoOld['item_bid'], 'pageDetailId' => $itemInfoOld['item_page_id'], 'newRecord' => $itemInfoNew, 'oldRecord' => $pageItemInfo, 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); } //sisRefreshParentWindow(false, false); sisSetStatusMsg(); $this->blockProperties(); /*if (sisParam('backUrl')) { sisServerTransfer(sisDecrypt2(sisParam('backUrl')), true); }*/ //sisCloseCurrentWindow(true, true); } /*rest_method*/ function saveBlock() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $items = sisParam('items'); $properties = sisParam('properties'); $content = sisParam('content'); $blockId = intval($items['bid']); $portalId = sisGlobal('portal_id'); if (!$blockId) { die(); } $blockinfoOld = sisPortletGetInfo($blockId, '', $portalId); if ($blockinfoOld['portal_id'] != $portalId) { die(); } if ($items['header_image_delete']) { $items['header_image'] = 'del'; } if ($items['footer_image_delete']) { $items['footer_image'] = 'del'; } if ($items['back_image_delete']) { $items['back_image'] = 'del'; } if ($_FILES['items']['name']['header_image']) { $items["item_header_image"] = array('name' => $_FILES['items']['name']['header_image'], 'type' => $_FILES['items']['type']['header_image'], 'tmp_name' => $_FILES['items']['tmp_name']['header_image'], 'error' => $_FILES['items']['error']['header_image'], 'size' => $_FILES['items']['size']['header_image']); } if ($_FILES['items']['name']['footer_image']) { $items["item_footer_image"] = array('name' => $_FILES['items']['name']['footer_image'], 'type' => $_FILES['items']['type']['footer_image'], 'tmp_name' => $_FILES['items']['tmp_name']['footer_image'], 'error' => $_FILES['items']['error']['footer_image'], 'size' => $_FILES['items']['size']['footer_image']); } if ($_FILES['items']['name']['back_image']) { $items["item_back_image"] = array('name' => $_FILES['items']['name']['back_image'], 'type' => $_FILES['items']['type']['back_image'], 'tmp_name' => $_FILES['items']['tmp_name']['back_image'], 'error' => $_FILES['items']['error']['back_image'], 'size' => $_FILES['items']['size']['back_image']); } $blockinfo = $blockinfoOld; foreach ($items as $key => $value) { $blockinfo[$key] = $value; } if(!empty($blockinfo['service_bid'])){ $blockInfoParent = sisPortletGetInfo($blockinfo['service_bid']); $blockParentVars = sisPortletVarsFromContent($blockInfoParent['content']); $blockinfo['mid'] = $blockInfoParent['mid']; $blockinfo['bkey'] = $blockInfoParent['bkey']; $blockinfo['ctp_id'] = $blockInfoParent['ctp_id']; $blockinfo['block_id'] = $blockInfoParent['bid']; } $modinfo = sisServiceGetInfo($blockinfo['mid']); if (!sisPortletLoad($modinfo['name'], $blockinfo['bkey'])) { die(); } if (!empty($blockInfoParent['settings']) && is_array($blockInfoParent['settings'])) { $GLOBALS['object_settings'] = array(); foreach ($blockInfoParent['settings'] as $key => $value) { $GLOBALS['object_settings'][$itemInfo['bkey']][] = $key; } } $blockinfo['responsive_settings'] = serialize(sisParam('responsive_settings')); $usname = preg_replace('/ /', '_', $modinfo['name']); $updatefunc = $usname . '_' . $blockinfo['bkey'] . 'block_update'; if (function_exists($updatefunc)) { $blockinfo = $updatefunc($blockinfo); if (!$blockinfo) { die(); } } else { // Old way $blocks_modules = $GLOBALS['blocks_modules'][$blockinfo['mid']]; if (!empty($blocks_modules[$blockinfo['bkey']]) && !empty($blocks_modules[$blockinfo['bkey']]['func_update'])) { if (function_exists($blocks_modules[$blockinfo['bkey']]['func_update'])) { $blockinfo = $blocks_modules[$blockinfo['bkey']]['func_update'](array_merge($_POST, $blockinfo)); } } } if (!empty($blockinfo['service_bid']) || $GLOBALS['block_extra_properties'][$blockinfo['bkey']]){ if (!empty($blockInfoParent['properties']) || $GLOBALS['block_extra_properties'][$blockinfo['bkey']]){ if (!empty($blockInfoParent['properties'])) { try { @eval("\$propertiesTmp = array($blockInfoParent[properties]);"); } catch (\ParseError $ex) {} if (count($propertiesTmp) == 0) { try { @eval("\$propertiesTmp = $blockInfoParent[properties];"); } catch (\ParseError $ex) {} } } else { $propertiesTmp = $GLOBALS['block_extra_properties'][$blockinfo['bkey']]; } $property_values = array(); foreach ($propertiesTmp as $key=>$value) { $postKey = str_replace(array(" ", ".", "#", ":"), array("__b__", "__d__", "__s__", "__c__"), $key); $property_values[$key] = array(); $property_values[$key]['value'] = $properties[$postKey]; } } $blockinfo['property_values'] = serialize($property_values); } if ($properties['_params_']) { $blockinfo['property_values'] = unserialize($blockinfo['property_values']); $blockinfo['property_values']['_params_'] = $properties['_params_']; $blockinfo['property_values'] = serialize($blockinfo['property_values']); } sisCacheDel("cache_block_$blockinfo[bkey]_$blockinfo[bid]", true); if (sisServiceAPIFunc('portlets', 'admin', 'update', $blockinfo)) { $dimensions = []; $dimensions[] = ['subject' => 'sis_block_manager', 'key' => 'blockId', 'value' => $blockId]; sisRaiseEvent('sis_page_manager', 'EDIT_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Block : $blockId", 'objectId' => $blockId, 'newRecord' => $itemInfo, 'oldRecord' => $blockinfoOld, 'dimensions' => $dimensions)); } sisSetStatusMsg(); if (sisParam('backUrl')) { sisServerTransfer(sisDecrypt2(sisParam('backUrl')), true); } } /*rest_method*/ function deletePageItem() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageItemId = intval(sisParam('pageItemId')); $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); if (!$pageItemId) { die(); } $itemInfo = sisServiceAPIFunc('pmk', 'admin', 'getItemInfo', array('item_id' => $pageItemId)); $pageRecord = sisRunQuery("SELECT pd.sp_page_id, pg.sp_is_master FROM saman_pages_detail pd INNER JOIN saman_pages pg ON (pd.sp_page_id = pg.sp_page_id) WHERE pd.sp_page_detail_id = $itemInfo[item_page_id] AND pd.sp_portal_id = $portalId AND pg.sp_portal_id = $portalId", true); sisServiceAPIFunc('pmk', 'admin', 'deletePageItem', array('item_id' => $pageItemId)); if (!$pageRecord[0]['sp_is_master']) { $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $itemInfo['item_bid']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $itemInfo['item_page_id']]; sisRaiseEvent('sis_page_manager', 'DELETE_PAGE_BLOCK', SIS_EVENT_TYPE_DELETE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $itemInfo['item_bid'], 'pageDetailId' => $itemInfo['item_page_id'], 'dimensions' => $dimensions), 'EDIT_PAGE'); } else { $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $itemInfo['item_bid']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $itemInfo['item_page_id']]; sisRaiseEvent('sis_page_manager', 'DELETE_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_DELETE, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'], 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $itemInfo['item_bid'], 'pageDetailId' => $itemInfo['item_page_id'], 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); } } /*rest_method*/ function deleteBlock() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $blockIds = sisParam('blockId'); $portalId = sisGlobal('portal_id'); if (!$blockIds) { die(); } $blockIds = explode(",", $blockIds); foreach ($blockIds as $blockId) { $blockInfo = sisPortletGetInfo(intval($blockId)); if ($blockInfo && $blockInfo['portal_id'] == $portalId) { if(sisServiceAPIFunc('pmk', 'user', 'isObjectItemUse', array('bid' => $blockId))) { sisSetStatusMsg(_BLOCKDELETED_USE_IN_PAGE, 'error'); break; } if (sisServiceAPIFunc('portlets', 'admin', 'delete', array('bid' => $blockId))) { sisServiceAPIFunc('pmk', 'admin', 'deleteShareBlock', $blockInfo); sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_block_manager', 'key' => 'blockId', 'value' => $blockId]; sisRaiseEvent('sis_page_manager', 'DELETE_BLOCK', SIS_EVENT_TYPE_DELETE, array('objectName' => "blockId : $blockId", 'objectId' => $blockId, 'record' => $blockInfo, 'dimensions' => $dimensions)); } } } sisServerTransfer('index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID, true); } /*rest_method*/ function exportBlock() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageItemId = intval(sisParam('pageItemId')); $blockId = intval(sisParam('blockId')); $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); if (!$pageItemId && !$blockId) { die(); } $fileName = ''; if ($pageItemId) { $itemInfo = sisServiceAPIFunc('pmk','admin', 'getItemInfo', array('item_id' => $pageItemId)); foreach ($itemInfo as $key => $value) { if (is_array($value)) { $itemInfo[$key] = serialize($value); } } $pageRecord = sisRunQuery("SELECT pd.sp_page_id, pg.sp_is_master FROM saman_pages_detail pd INNER JOIN saman_pages pg ON (pd.sp_page_id = pg.sp_page_id) WHERE pd.sp_page_detail_id = $itemInfo[item_page_id] AND pd.sp_portal_id = $portalId AND pg.sp_portal_id = $portalId", true); $output = base64_encode(convert_uuencode(serialize($itemInfo))); $fileName = "item$pageItemId.sis"; $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $itemInfo['item_bid']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $itemInfo['item_page_id']]; if (!$pageRecord[0]['sp_is_master']) { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; sisRaiseEvent('sis_page_manager', 'EXPORT_PAGE_BLOCK', SIS_EVENT_TYPE_READ, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $itemInfo['item_bid'], 'pageDetailId' => $itemInfo['item_page_id'], 'dimensions' => $dimensions), 'VIEW_PAGE'); } else { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; sisRaiseEvent('sis_page_manager', 'EXPORT_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_READ, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'], 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $itemInfo['item_bid'], 'pageDetailId' => $itemInfo['item_page_id'], 'dimensions' => $dimensions), 'VIEW_MASTER_PAGE'); } } else if ($blockId) { $blockInfo = sisPortletGetInfo($blockId); $output = base64_encode(convert_uuencode(serialize($blockInfo))); $fileName = "block$blockId.sis"; $dimensions = []; $dimensions[] = ['subject' => 'sis_block_manager', 'key' => 'blockId', 'value' => $blockId]; sisRaiseEvent('sis_page_manager', 'EXPORT_BLOCK', SIS_EVENT_TYPE_READ, array('objectName' => "Block : $blockId", 'objectId' => $blockId, 'dimensions' => $dimensions), 'VIEW_BLOCK'); } Header("Content-Type: text/plain"); Header("Content-Disposition: attachment; filename=$fileName"); Header("Content-Transfer-Encoding: binary"); die($output); } /*rest_method*/ function addBlockUI() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $pageWdId = intval(sisParam('pageWdId')); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); $serviceId = $this->getPageServiceId($pageWdId); $portalId = sisGlobal('portal_id'); $includeMasterpage = sisParam('includeMasterpage'); $globalBlocks = sisParam('globalBlocks'); //$serviceDesign = sisGetAdminPanelScope() == 'develop'; //$serviceDesign = intval($wdInfo['is_admin']) == 1; $serviceDesign = intval($wdInfo['is_admin']) == 1; $this->loadLangs(); $serviceList = sisServiceAPIFunc('service_manager', 'admin', 'list', array('state' => _SERVICE_STATE_ACTIVE, 'portalId' => $portalId)); $services = array(); $services[0] = array('id' => 0,'name' => 'core'); if (!$globalBlocks) { $shareBlocks = sisServiceAPIFunc('portlets', 'user', 'getall', array('alphabetic' => 1, 'block_type' => 1)); foreach ($shareBlocks as $key => $shareBlock) { $shareBlocks[$key]['text_type_long'] = $shareBlock['title']; $shareBlocks[$key]['mid'] = -1; $shareBlocks[$key]['bkey'] = $shareBlock['bid']; } $services[-1] = array('id' => -1, 'name' => 'shareBlocks', 'displayname' => 'shareBlocks', 'blocks' => $shareBlocks, 'blockCount' => count($shareBlocks)); } foreach ($serviceList as $service) { $modversion = array(); if (file_exists($file = "services/$service[directory]/license.php")) { include_once($file); } $service['allowAddInPage'] = $modversion['allowAddInPage']; if ($GLOBALS['portal_id'] != 0 && !sisSecurityAuthAction(0, '.*', ".*", ACCESS_ADMIN)) { $module['allowAddInPage'] = 0; } $service['displayname'] = defined($service['name']) ? constant($service['name']) : $service['displayname']; $services[$service['id']] = $service; } $blocks = sisPortletLoadAll(); foreach ($blocks as $moduleBlocks) { foreach ($moduleBlocks as $block) { if (!$services[$block['mid']] || $block['just_in_develop']) { continue; } if ($block['hidden_block'] != 1 && ($GLOBALS['portal_id'] == 0 || $block['allow_subportal_add'] || sisSecurityAuthAction(0, '.*', ".*", ACCESS_ADMIN))) { if (!$includeMasterpage && $block['bkey'] == 'masterpage_container') { continue; } $services[$block['mid']]['blocks'][] = $block; } } } foreach ($services as $key => $service) { $services[$key]['blockCount'] = count($service['blocks']); if (($service['allowAddInPage'] != 1 && !isset($service['blocks']) && (count($service['blocks'])==0 )) || ($GLOBALS['portal_id'] != 0 && count($service['blocks']) == 0 && sisSecurityAuthAction(0, '.*', ".*", ACCESS_ADMIN))) { unset($services[$key]); } } $lang = sisUserGetLang(); $direction = sisGetDirection(); if ($direction == 'rtl'){ @require_once("services/control_panel/lang/$lang/menu.php"); } $dynamicServices = sisServiceAPIFunc('cdk','user','getDynamicModules', array('portalId' => $portalId)); foreach ($dynamicServices as $dynamicService) { $ctpBlocks = sisServiceAPIFunc('portlets', 'user', 'getall', array('alphabetic' => 1, 'block_type' => 2, 'ctp_id' => $dynamicService['type_id'], 'show_system_blocks' => $serviceDesign)); $dynamicServiceBlocks = array(); foreach ($ctpBlocks as $ctpBlock) { if($ctpBlock['active'] == 1) { $dynamicServiceBlocks[] = array('text_type' => $ctpBlock['title'], 'module' => '', 'text_type_long' => $ctpBlock['title'], 'allow_multiple' => 1, 'form_content' => '', 'form_refresh' => '', 'show_preview' => '', 'default_title' => $ctpBlock['title'], 'allow_user_add' => 1, 'group' => 2, 'block_description' => $ctpBlock['description'], 'bkey' => $ctpBlock['bkey'], 'mid' => 'ctp_' . $ctpBlock['mid'] . '_' . $dynamicService['type_id'] . '_' . $ctpBlock['bid']); } } define($dynamicService['name'], $dynamicService['displayname']); $services['ctp_' . $dynamicService['type_id']] = array('id' => 'ctp_' . $dynamicService['type_id'], 'name' => $dynamicService['name'], 'displayname' => $dynamicService['displayname'], 'description' => $dynamicService['description'], 'directory' => '', 'state' => 3, 'version' => $dynamicService['version'], 'type' => 2, 'dynamicModule' => 1, 'admin_capable' => 1, 'user_capable' => 1, 'allowAddInPage' => 1, 'blocks' => $dynamicServiceBlocks, 'blockCount' => count($dynamicServiceBlocks) ); } $services[0]['blocks'][] = array('text_type_long' => _LNG_PGM_CURRENT_SERVICE, 'allow_user_add' => 1, 'allow_subportal_add' => 1, 'module' => 'Core'); $sortServices = array(); foreach ($services as $id => $service) { if(!($id == '-1' || $id == '0')) { $sortServices[$id] = $service['displayname']; } } asort($sortServices); $pageService = null; if ($services['ctp_' . $serviceId]) { $pageService = $services['ctp_' . $serviceId]; unset($sortServices['ctp_' . $serviceId]); } $sortServices = ($pageService ? array($pageService['id'] => $pageService['displayname']) : array()) + (!$globalBlocks ? array('-1' => _LNG_PGM_SHARED_BLOCKS) : array()) + array('0' => _LNG_PGM_CORE_BLOCKS) + $sortServices; $blocks = array(); div('', 'pgmModalDialog pgmAddBlockUI'); div('', 'pgmModalContainer'); div('', 'pgmAddBlockUIServices'); div('', 'search input-group', 'style="padding:5px;"'); t(''); div_(); div('', '', 'style="overflow:auto;direction:' . notDirection() . ';margin-' . align() . ':5px;"'); t(''); div_(); div_(); div('', 'pgmAddBlockUIBlocks'); div('', '', 'style="padding: 0 5px;font-size: large"'); t(' '); div('', 'search input-group', 'style="float:' . notAlign() . ';width:40%;margin-top:5px"'); t(''); div_(); div_(); div('', '', 'style="overflow:auto;padding: 10px"'); foreach ($blocks as $block) { t($block); } div_(); div_(); div('', 'pgmAddBlockUISelectedBlocks'); div('', '', 'style="padding: 0 5px;font-size: larger"'); t(_LNG_PGM_SELECTED_BLOCKS); div_(); div('', '', 'style="overflow:auto;padding: 0 10px;position:relative"'); div('', '', 'style="position:absolute;top:0;left:0;text-align:center;width:100%;color:#aaa" rel="message"'); t(_LNG_PGM_NO_BLOCK_SELECT); div_(); t(''); div_(); div_(); div_(); div('', 'pgmModalOperationBar'); t(''); t(''); div_(); div_(); script(); t(' function pgmImportBlock(result, files) { for (var file in files) { var text = $(".pgmAddBlockUIBlocks div").eq(0).text() + " | " + files[file].name; var $selected = $("
  • " + text + "
  • "); $(".pgmAddBlockUISelectedBlocks ul").append($selected.fadeIn(\'fast\')); $selected.find("i").click(function(e) { e.stopPropagation(); var $parent = $(this).closest(".pgmAddBlockUISelectedBlock"); $(".sisAsyncFileUploaderFile[data-fileId=" + $parent.attr("data-fileId") + "]").fadeOut("fast", function() {$(this).remove();}); $(this).closest(".pgmAddBlockUISelectedBlock").fadeOut("fast", function() { $(this).remove(); if (!$(".pgmAddBlockUISelectedBlocks li").length) { $(".pgmAddBlockUISelectedBlocks div[rel=message]").fadeIn("fast"); } }); }); $selected.click(function() { var blockId = $(this).attr("data-ref"); $(".pgmAddBlockUIServices li[data-serviceId=" + $(this).attr("data-serviceId") + "]").click(); $(".pgmAddBlockUIServices li[data-serviceId=" + $(this).attr("data-serviceId") + "]").get(0).scrollIntoView(); }); } if ($(".pgmAddBlockUISelectedBlocks li").length) { $(".pgmAddBlockUISelectedBlocks div[rel=message]").fadeOut("fast"); } } function pgmSelectBlock($container) { if (!$container.hasClass("pgmAddBlockUIActive")) { var text = $(".pgmAddBlockUIBlocks div").eq(0).text() + " | " + $container.find("span").text(); var $selected = $("
  • " + text + "
  • "); $(".pgmAddBlockUISelectedBlocks ul").append($selected.fadeIn("fast")); $selected.find("i").click(function(e) { e.stopPropagation(); var $parent = $(this).closest(".pgmAddBlockUISelectedBlock"); $("#" + $parent.attr("data-ref")).click(); }); $selected.click(function() { var blockId = $(this).attr("data-ref"); $(".pgmAddBlockUIServices li[data-serviceId=" + $(this).attr("data-serviceId") + "]").click(); $(".pgmAddBlockUIServices li[data-serviceId=" + $(this).attr("data-serviceId") + "]").get(0).scrollIntoView(); $("#" + blockId).get(0).scrollIntoView(); }); } else { $(".pgmAddBlockUISelectedBlocks li[data-ref=" + $container.attr("id") + "]").fadeOut("fast", function() { $(this).remove(); if (!$(".pgmAddBlockUISelectedBlocks li").length) { $(".pgmAddBlockUISelectedBlocks div[rel=message]").fadeIn("fast"); } }); } if ($(".pgmAddBlockUISelectedBlocks li").length) { $(".pgmAddBlockUISelectedBlocks div[rel=message]").fadeOut("fast"); } } (function(){ var $parentWindow = $("#" + $(".pgmAddBlockUI").closest(".sisModalDialog").attr("sisAPParentWindowId")); var globalBlocks = ' . intval($globalBlocks) . '; $(".pgmAddBlockUI .pgmModalContainer").height("calc(100% - " + $(".pgmAddBlockUI .pgmModalOperationBar").outerHeight() + "px)"); $(".pgmAddBlockUIServices div").eq(1).height("calc(100% - " + $(".pgmAddBlockUIServices div").eq(0).outerHeight() + "px)"); $(".pgmAddBlockUIBlocks > div").eq(0).css("line-height", $(".pgmAddBlockUIServices div").eq(0).outerHeight() + "px"); $(".pgmAddBlockUIBlocks > div").eq(1).height("calc(100% - " + $(".pgmAddBlockUIBlocks div").eq(0).outerHeight() + "px)"); $(".pgmAddBlockUISelectedBlocks div").eq(0).css("line-height", $(".pgmAddBlockUIServices div").eq(0).outerHeight() + "px"); $(".pgmAddBlockUISelectedBlocks div").eq(1).height("calc(100% - " + $(".pgmAddBlockUISelectedBlocks div").eq(0).outerHeight() + "px)"); $(".pgmAddBlockUIContainer").height("calc(100% - " + $(".pgmAddBlockUI .pgmModalOperationBar").height() + "px)"); $(".pgmAddBlockUISelectedBlocks div[rel=message]").css("line-height", $(".pgmAddBlockUISelectedBlocks div").eq(1).outerHeight() + "px"); $(".pgmAddBlockUIServices li").not(".pgmAddBlockUIDelimiter").click(function() { if ($(this).hasClass("pgmAddBlockUISelected")) { return; } $(".pgmAddBlockUIBlocks div.pgmAddBlockUIBlockList:visible").fadeOut("fast"); $("#pgmBlocks" + $(this).attr("data-serviceId")).fadeIn("fast"); if ($(this).attr("data-serviceId") == "__import__") { $(".sisAsyncFileUploader").not("[refreshed]").data("uploader").refresh(); $(".sisAsyncFileUploader").attr("refreshed", 1); } $(".pgmAddBlockUIServices li.pgmAddBlockUISelected").removeClass("pgmAddBlockUISelected"); $(this).addClass("pgmAddBlockUISelected"); $(".pgmAddBlockUIBlocks div:first span:first").text($(this).text()); $(".pgmAddBlockUIBlockList:visible .pgmAddBlockUIBlockItemContainer").show(); $(".pgmAddBlockUIBlocks input[type=text]").val(""); }); $(".pgmAddBlockUIBlocks input[rel=search]").keyup(function() { var $items = $(".pgmAddBlockUIBlockList:visible .pgmAddBlockUIBlockItemContainer"); $items.show(); var value = jQuery.trim($(this).val()).toLowerCase(); if (!value) { return; } $items.each(function() { if ($(this).text().toLowerCase().indexOf(value) != -1) { $(this).show(); } else { $(this).hide(); } }); }); $(".pgmAddBlockUIServices input[rel=search]").keyup(function() { var $items = $(".pgmAddBlockUIServices li[data-searchable=1]"); $items.show(); var value = jQuery.trim($(this).val()).toLowerCase(); if (!value) { return; } $items.each(function() { if ($(this).text().toLowerCase().indexOf(value) != -1 || $(this).attr("data-serviceName").toLowerCase().indexOf(value) != -1) { $(this).show(); } else { $(this).hide(); } }); }); $(".pgmAddBlockUIBlockItemContainer").click(function(e) { $(this).find("input[type=checkbox]").click(); }); $(".pgmAddBlockUIBlocks input[type=checkbox]").click(function(e) { pgmSelectBlock($(this).closest(".pgmAddBlockUIBlockItemContainer")); $(this).closest(".pgmAddBlockUIBlockItemContainer").toggleClass("pgmAddBlockUIActive"); e.stopPropagation(); }); $(".pgmAddBlockUIBlocks table input, .pgmAddBlockUIBlocks table select").click(function(e) { e.stopPropagation(); }); $(".pgmAddBlockUI").disableSelection(); $(".pgmAddBlockUI").find("input, select") .bind("mousedown.ui-disableSelection selectstart.ui-disableSelection", function(e) { e.stopImmediatePropagation(); }); if (!globalBlocks) { $( ".pgmAddBlockUISelectedBlocks ul" ).sortable({ connectWith : ".pgmAddBlockUISelectedBlocks ul", scroll : true, refreshPositions : true, appendTo : ".pgmAddBlockUISelectedBlocks ul", containment : "parent", helper : "clone" }); } $(".pgmAddBlockUI .pgmModalOperationBar .closeDialog").click(function() { var $box = $(this).closest(".lightBoxMe"); if ($(".pgmAddBlockUISelectedBlocks ul li").length) { sisConfirm("' . _LNG_PGM_CLOSE_CONFIRM . '", null, null, function() { window.setTimeout(function() {$box.trigger("close");}, 500); }); } else { $box.trigger("close"); } }); $(".pgmAddBlockUI .pgmModalOperationBar input[rel=add]").click(function() { var $filesRow = $(".pgmAddBlockUI .sisAsyncFileUploaderFile"); if ($filesRow.not(".sisAsyncFileUploaderFileSuccess").not(".sisAsyncFileUploaderFileError").length) { sisAlert("' . _LNG_PGM_UPLOADING_IN_PROGRESS . '"); return; } var $selectedBlocks = $(".pgmAddBlockUISelectedBlocks ul li"); if (!$selectedBlocks.length) { sisAlert("' . _LNG_PGM_NO_BLOCK_SELECT_MESSAGE . '"); return; } var blocks = []; $selectedBlocks.each(function() { var ref = $(this).attr("data-ref"); var block = {}; if ($(this).attr("data-serviceId") == "__import__") { block.file = $(this).attr("data-fileId"); block.name = $(this).attr("data-fileName"); } else { ref = ref.split("-_-"); if (ref[1].indexOf("ctp_") == 0) { ref = ref[1].split("_"); block.dynamic = 1; block.service = ref[1]; if (ref[3]) { block.bkey = ref[3]; } else { ref = $(this).attr("data-ref"); var $extra = $("#" + ref) block.type = $extra.find("select").val(); block.function = $extra.find("input").eq(1).val(); block.parameters = $extra.find("input").eq(2).val(); } } else { block.service = ref[1]; block.bkey = ref[2]; } } blocks.push(block); }); $(this).closest(".lightBoxMe").trigger("close"); if ($parentWindow.is(":visible")) { sisAdminPanel.startLoading($parentWindow); } $.ajax({ type: "POST", data: {blocks: blocks, pageDetailId : ' . intval(sisParam('pageDetailId')) . ', zoneId : ' . intval(sisParam('zoneId')) . ', masterpageContainerId : ' . intval(sisParam('masterpageContainerId')) . ', pageWdId : ' . intval($pageWdId) . ', globalBlocks : globalBlocks}, url: sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'addBlock') . '"), success: function(msg){ if ($parentWindow.is(":visible")) { sisAdminPanel.stopLoading($parentWindow); if (!' . $pageWdId . ') { if (document.getElementById("sisAPTabsheetblockEditTab") === null) { // sisAdminPanel.changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID . '&sisAPWindowSize=6&sisAPTabsheetName=blockEditTab&sisAPTabId=listblock&sisAPWindowTitle=' . _LNG_PGM_LIST . '" , 1); sisAdminPanel.changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID . '&sisAPWindowSize=6&sisAPTabId=listblock&sisAPWindowTitle=' . _LNG_PGM_LIST . '" , 1); } sisAdminPanel.refreshCurrentWindow(); } else { sisAdminPanel.refreshCurrentWindow(); } } else { //sisAdminPanel.changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID . '&sisAPWindowSize=6&sisAPTabsheetName=blockEditTab&sisAPTabId=listblock&sisAPWindowTitle=' . _LNG_PGM_LIST . '" , 1); sisAdminPanel.changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID . '&sisAPWindowSize=6&sisAPTabId=listblock&sisAPWindowTitle=' . _LNG_PGM_LIST . '" , 1); } } }); }); $(".pgmAddBlockUIServices li").eq(1).click(); })();'); script_(); } /*rest_method*/ function addBlock() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageDetailId = intval(sisParam('pageDetailId')); $zoneId = intval(sisParam('zoneId')); $masterpageContainerId = intval(sisParam('masterpageContainerId')); $blocks = sisParam('blocks'); $pageWdId = intval(sisParam('pageWdId')); $wdInfo = null; if ($pageWdId) { $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); } $globalBlocks = intval(sisParam('globalBlocks')); if (!$globalBlocks) { if (!$pageDetailId || (!$zoneId && !$masterpageContainerId) || !is_array($blocks)) { die(); } $pageDetailInfo = sisServiceAPIFunc('pmk', 'user', 'getPageDetailInfo', array('page_detail_id' => $pageDetailId, 'portal_id' => $portalId)); if (!$pageDetailInfo) { die(); } $pageRecord = sisRunQuery("SELECT sp_page_id, sp_is_master FROM saman_pages WHERE sp_page_id = $pageDetailInfo[page_id] AND sp_portal_id = $portalId", true); } sisServiceLangLoad("pmk", "admin"); foreach ($blocks as $block) { $pageItem = null; $itemType = null; $blockId = null; $bkey = $block['bkey']; $mid = $block['service']; $itemContent = null; $itemTitle = null; $blockId = null; $itemType = 1; if ($block['file']) { $file = sisConfigGetVar('temp') . DIRECTORY_SEPARATOR . "plupload/" . $block['file']; if (!$file) { sisRaiseException(sprintf(_LNG_PGM_IMPORT_ERROR, $block['name'])); return; continue; } $itemInfo = unserialize(convert_uudecode(base64_decode(file_get_contents($file)))); $itemPrefix = ''; if ($itemInfo['item_bid']) { $itemPrefix = 'item_'; } @unlink($file); if(!is_array($itemInfo) || empty($itemInfo[$itemPrefix . 'bid']) || empty($itemInfo[$itemPrefix . 'bkey'])) { sisRaiseException(sprintf(_LNG_PGM_IMPORT_ERROR, $block['name'])); return; continue; } $prefix = 'item_'; if ($globalBlocks) { $prefix = ''; } $pageItem = $itemInfo; $pageItem[$prefix . 'page_id'] = $pageDetailId; $pageItem[$prefix . 'main_page_id'] = $pageDetailInfo['page_id']; $pageItem[$prefix . 'position'] = $zoneId; $pageItem[$prefix . 'portal_id'] = $pageDetailInfo['page_portal_id']; $pageItem[$prefix . 'container_id'] = $masterpageContainerId; if (!$globalBlocks) { $bid = sisServiceAPIFunc('pmk', 'admin', 'importPageItem', $pageItem); } else { $bid = sisServiceAPIFunc('portlets', 'admin', 'create', $pageItem); } if ($bid) { $dimensions = []; if ($globalBlocks) { $dimensions[] = ['subject' => 'sis_block_manager', 'key' => 'blockId', 'value' => $bid]; sisRaiseEvent('sis_page_manager', 'IMPORT_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Block : $bid", 'objectId' => $bid, 'newRecord' => $pageItem, 'dimensions' => $dimensions), 'ADD_BLOCK'); } else if (!$pageRecord[0]['sp_is_master']) { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $bid]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailId]; sisRaiseEvent('sis_page_manager', 'IMPORT_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $bid, 'pageDetailId' => $pageDetailId, 'newRecord' => $pageItem, 'dimensions' => $dimensions), 'EDIT_PAGE'); } else { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $bid]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailId]; sisRaiseEvent('sis_page_manager', 'IMPORT_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'], 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $bid, 'pageDetailId' => $pageDetailId, 'newRecord' => $pageItem, 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); } } continue; } else if ($mid == 0 && !$bkey) { $bkey = 'core'; $itemType = 2; } else if ($block['dynamic']) { if ($block['type']) { $bkey = 'cdk'; $itemType = 2; $mid = 0; } else { $blockInfo = sisPortletGetInfo($block['bkey']); $bkey = $blockInfo['bkey']; $blockId = $block['bkey']; $itemTitle = $blockInfo['title']; $itemContent = $blockInfo['content']; } } else if ($mid == "-1") { $blockInfo = sisPortletGetInfo($block['bkey']); $mid = 0; $itemContent = $block['bkey']; $bkey = 'shareblock'; $itemTitle = $blockInfo['title']; } else if ($bkey) { $modInfo = sisServiceGetInfo($mid); $blockInfo = sisPortletLoad($modInfo['name'], $bkey); $itemTitle = trim($blockInfo['text_type_long']); } if (!$pageItem) { $pageItem = array( 'page_id' => $pageDetailId, 'main_page_id' => $pageDetailInfo['page_id'], 'zone' => $zoneId, 'mid' => $mid, 'bkey' => $bkey, 'serviceType' => $block['type'], 'serviceFunc' => $block['function'], 'serviceParams' => $block['parameters'], 'itemType' => $itemType, 'itemContent' => $itemContent, 'itemTitle' => $itemTitle, 'block_id' => $blockId, 'portal_id' => $pageDetailInfo['page_portal_id'], 'container_id' => $masterpageContainerId, 'title' => $itemTitle, 'content' => $itemContent, 'service_bid' => $blockId ); } if ($wdInfo['is_admin']) { $pageItem['template'] = 'standalone'; } if (!$globalBlocks) { $bid = sisServiceAPIFunc('pmk', 'admin', 'createPageItem', $pageItem); } else { $bid = sisServiceAPIFunc('portlets', 'admin', 'create', $pageItem); } if ($bid) { if (!$globalBlocks) { $dimensions = []; if (!$pageRecord[0]['sp_is_master']) { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $bid]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageDetailId]; sisRaiseEvent('sis_page_manager', 'ADD_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $bid, 'pageDetailId' => $pageDetailId, 'newRecord' => $pageItem, 'dimensions' => $dimensions), 'EDIT_PAGE'); } else { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $bid]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $pageDetailId]; sisRaiseEvent('sis_page_manager', 'ADD_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'], 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $bid, 'pageDetailId' => $pageDetailId, 'newRecord' => $pageItem, 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); } } else { $dimensions[] = ['subject' => 'sis_block_manager', 'key' => 'blockId', 'value' => $bid]; sisRaiseEvent('sis_page_manager', 'CREATE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Block : $bid", 'objectId' => $bid, 'newRecord' => $pageItem, 'dimensions' => $dimensions)); } } } sisSetStatusMsg(); } /*rest_method*/ function zoneAction() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageDetailId = intval(sisParam('pageDetailId')); $zoneId = intval(sisParam('zoneId')); $pageWdId = intval(sisParam('pageWdId')); $pageLang = sisParam('pageLang'); $masterpageContainerId = intval(sisParam('masterpageContainerId')); if (!$pageDetailId || (!$zoneId && !$masterpageContainerId)) { die(); } $pageDetailInfo = sisServiceAPIFunc('pmk', 'user', 'getPageDetailInfo', array('page_detail_id' => $pageDetailId)); if (!$pageDetailInfo) { die(); } $pageItems = sisServiceAPIFunc('pmk', 'admin', 'getPageItems', array('main_page_id' => $pageDetailInfo['page_id'], 'page_id' => $pageDetailInfo['page_detail_id'], 'zone' => $zoneId, 'container_id' => $masterpageContainerId)); $this->loadLangs(); $languages = getLanguages(); $languages = array_merge(array('all' => _LNG_PGM_ALL_LANGS), $languages); $blockTemplates = sisServiceFunc('pmk', 'admin', 'getitemtemplates'); asort($blockTemplates); div('', 'pgmModalDialog pgmZoneActionUI'); form('frmPgmZoneAction', callFunctionUrl(_PGM_MAIN_CTP_ID, 'doZoneAction'), NULL, NULL, NULL, 'ENCTYPE="multipart/form-data" style="height:100%"'); hidden('pageDetailId', $pageDetailId); hidden('zoneId', $zoneId); hidden('masterpageContainerId', $masterpageContainerId); hidden('pageWdId', $pageWdId); div('', 'pgmModalContainer'); table('100%', 0, 'class="sisDataListTable" id="tblPgmBlocksAction"'); thead(); tr(); th(null, 'style="width: 5%;text-align:center"'); if (count($pageItems) > 0) { t(''); } th_(); th(); t(_LNG_PGM_BLOCK_TITLE); th_(); th(); t(_LNG_PGM_BLOCK_TYPE); th_(); th(null, 'style="width: 10%;text-align:center"'); t(_LNG_PGM_BLOCK_STATUS); th_(); if ($pageLang == 'all') { th(null, 'style="width: 15%;text-align:center"'); t(_LNG_PGM_BLOCK_LANGUAGE); th_(); } th(null, 'style="width: 5%;text-align:center"'); t(_LNG_PGM_BLOCK_ID); th_(); tr_(); thead_(); foreach ($pageItems as $pageItem) { if ($pageItem['item_bkey'] == 'masterpage_container') { continue; } $extraInfo = $this->getPageItemExtraInfo($pageItem); tr(); td(); if (count($pageItems) > 0) { t(''); } td_(); td(); if (strpos($pageItem['item_title'], "#D:") === 0) { $pageItem['item_title'] = substr($pageItem['item_title'], 3, strlen($pageItem['item_title']) - 4); } t(localizedStr($pageItem['item_title'], null, true, true)); td_(); td(); t(localizedStr($extraInfo['blockBaseBlock'])); td_(); td(); if ($pageItem['item_active'] == 1) { t(_LNG_PGM_BLOCK_STATUS_ACTIVE); } else { t(_LNG_PGM_BLOCK_STATUS_DEACTIVE); } td_(); if ($pageLang == 'all') { td(); $pageItem['item_language'] = $pageItem['item_language'] ? $pageItem['item_language'] : 'all'; t($languages[$pageItem['item_language']]); td_(); } td(); t($pageItem['item_bid']); td_(); tr_(); } table_(); if (count($pageItems) > 0) { div(null, null, 'style="margin-top: 20px"'); itemsGroup('itgPgmBlocksAction', _LNG_PGM_BLOCKS_ACTION); div(null, null, 'style="margin-top:20px"'); sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_STATUS); sisCaption_(); sisData(); t(''); sisData_(); sisFormGroup_(); if ($pageLang == 'all') { sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_LANGUAGE); sisCaption_(); sisData(); t(''); sisData_(); sisFormGroup_(); } sisFormGroup(); sisCaption(); t(_LNG_PGM_BLOCK_TEMPLATE); sisCaption_(); sisData(); t(''); sisData_(); sisFormGroup_(); div_(); itemsGroup_(); div_(); } div_(); div('', 'pgmModalOperationBar'); if (count($pageItems) > 0) { t(''); } t(''); div_(); form_(); div_(); script(); t(' function pgmPageItemsSelectAll(obj) { $(obj).closest("table").find("input[rel=selector]").prop("checked", $(obj).prop("checked")); } (function() { $(".pgmZoneActionUI .pgmModalContainer").height("calc(100% - " + $(".pgmZoneActionUI .pgmModalOperationBar").outerHeight() + "px)"); })(); '); script_(); } /*rest_method*/ function doZoneAction() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageDetailId = intval(sisParam('pageDetailId')); $zoneId = intval(sisParam('zoneId')); $masterpageContainerId = intval(sisParam('masterpageContainerId')); if (!$pageDetailId || (!$zoneId && !$masterpageContainerId)) { die(); } $pageRecord = sisRunQuery("SELECT sp_page_id, sp_is_master FROM saman_pages WHERE sp_page_id = $pageDetailId AND sp_portal_id = $portalId", true); $pageItems = array(-1); if (is_array(sisParam('pageItems'))) { $pageItems = sisParam('pageItems'); } $updateSql = " UPDATE saman_page_items SET " . (sisParam('pageItemActive') != "no" ? "sp_active = " . intval(sisParam('pageItemActive')) . "," : "") . " " . (sisParam('pageItemLanguage') != "no" ? "sp_language = '" . sisVarStore(sisParam('pageItemLanguage') != "all" ? sisParam('pageItemLanguage') : "") . "'," : "") . " " . (sisParam('pageItemTemplate') != "no" ? "sp_template = '" . sisVarStore(sisParam('pageItemTemplate')) . "'," : "") . " sp_bid = sp_bid WHERE sp_bid IN (" . implode($pageItems, ",") . ") AND sp_portal_id = $portalId "; sisRunQuery($updateSql); foreach ($pageItems as $bid) { if ($bid) { $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $bid]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailId]; if (!$pageRecord[0]['sp_is_master']) { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; sisRaiseEvent('sis_page_manager', 'UPDATE_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $bid, 'pageDetailId' => $pageDetailId, 'pageItemActive' => sisParam('pageItemActive'), 'pageItemLanguage' => sisParam('pageItemLanguage'), 'pageItemTemplate' => sisParam('pageItemTemplate'), 'dimensions' => $dimensions), 'EDIT_PAGE'); } else { $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'masterPageId', 'value' => $pageRecord[0]['sp_page_id']]; sisRaiseEvent('sis_page_manager', 'UPDATE_MASTER_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Master page : " . $pageRecord[0]['sp_page_id'], 'objectId' => $pageRecord[0]['sp_page_id'], 'blockId' => $bid, 'pageDetailId' => $pageDetailId, 'pageItemActive' => sisParam('pageItemActive'), 'pageItemLanguage' => sisParam('pageItemLanguage'), 'pageItemTemplate' => sisParam('pageItemTemplate'), 'dimensions' => $dimensions), 'EDIT_MASTER_PAGE'); } } } sisSetStatusMsg(); sisCloseCurrentWindow(true, true); } /*rest_method*/ function createNodePage() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return sisForbidden(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageLang = sisParam('pageLang'); $pageChannel = intval(sisParam('pageChannel')); $pageNodeType = sisParam('pageNodeType'); $pageIsDesign = intval(sisParam('pageIsDesign')); if (!$pageWdId || !$pageLang || !$pageNodeType) { die(); } if ($pageNodeType != 'node' && $pageNodeType != 'view' && $pageNodeType != 'edit') { die(); } if ($pageChannel < 0 || $pageChannel > 7) { die(); } $languages = getLanguages(); if ($pageLang == 'all') { $pageLang = ''; } if ($pageLang && !$languages[$pageLang]) { die(); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { die(); } if ($wdInfo['wd_pages'][$pageNodeType]) { $pageId = $wdInfo['wd_pages'][$pageNodeType]; $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages WHERE sp_page_id = $pageId AND sp_portal_id = $portalId", true); if (!$record[0]['rec_count']) { $pageId = 0; } } if (!$pageId) { $pageId = sisServiceAPIFunc('pmk', 'admin', 'createPage', array( 'page_show_in_menu' => 0, 'page_code' => "page_{$pageWdId}_{$pageNodeType}_{$pageChannel}_{$pageLang}", 'page_type' => $pageNodeType, 'page_portal_id' => $portalId )); if (!$pageId) { die(); } } $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages_detail WHERE sp_page_id = '$pageId' AND sp_language = '" . sisVarPrepForStore($pageLang) . "' AND sp_device = $pageChannel AND sp_portal_id = $portalId", true); if ($record[0]['rec_count']) { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGE_DESIGN_WD_ID . "&pageWdId=$pageWdId&pageNodeType=$pageNodeType&pageChannel=$pageChannel&pageLang=$pageLang&pageIsDesign=$pageIsDesign", true); } $pageDetailId = sisServiceAPIFunc('pmk', 'admin', 'createPageDetail', array( 'page_id' => $pageId, 'page_language' => $pageLang, 'page_device' => $pageChannel, 'page_status' => 1, 'page_layout_template_id' => 'general', 'page_show_title' => '1', 'page_page_template_id' => 'onecolumn' )); sisServiceAPIFunc('pmk', 'admin', 'assignpage', array( 'wd_id' => $pageWdId, 'page_id' => $pageId, 'node_type' => $pageNodeType) ); sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailId]; sisRaiseEvent('sis_page_manager', 'CREATE_PAGE', SIS_EVENT_TYPE_CREATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageDetailId' => $pageDetailId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageType' => $pageNodeType, 'dimensions' => $dimensions)); sisCacheDel('web_directory_info_' . $pageWdId); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGE_DESIGN_WD_ID . "&pageWdId=$pageWdId&pageNodeType=$pageNodeType&pageChannel=$pageChannel&pageLang=$pageLang&pageIsDesign=$pageIsDesign&sisAPTabsheetName=pgmPageDesignTab", true); } /*rest_method*/ function deleteNodePage() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageNodeType = sisParam('pageNodeType'); $pageChannel = intval(sisParam('pageChannel')); $pageLang = sisParam('pageLang'); $pageIsDesign = intval(sisParam('pageIsDesign')); if (!$pageWdId || !$pageNodeType || !$pageLang) { die(); } if ($pageLang == 'all') { $pageLang = ''; } $wdPageField = ''; switch ($pageNodeType) { case 'node'; $wdPageField = 'sp_node_page_id'; break; case 'view'; $wdPageField = 'sp_view_page_id'; break; case 'edit'; $wdPageField = 'sp_edit_page_id'; break; } if (!$wdPageField) { die(); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); $pageId = $wdInfo['wd_pages'][$pageNodeType]; if (!$wdInfo || !$pageId) { die(); } $pageDetailRecord = sisRunQuery("SELECT sp_page_detail_id FROM saman_pages_detail WHERE sp_page_id = $pageId AND sp_language = '" . sisVarPrepForStore($pageLang) . "' AND sp_device = $pageChannel AND sp_portal_id = $portalId", true); if (!$pageDetailRecord[0]['sp_page_detail_id']) { die(); } $pageItemsRecord = sisRunQuery("SELECT sp_bid FROM saman_page_items WHERE sp_page_id = '{$pageDetailRecord[0]['sp_page_detail_id']}' AND sp_portal_id = $portalId", true); foreach ($pageItemsRecord as $record) { sisDeletePath(PORTAL_DATA_PATH . 'sis_page_manager/block_images/' . $record['sp_bid']); } sisRunQuery("DELETE FROM saman_page_items WHERE sp_page_id = '{$pageDetailRecord[0]['sp_page_detail_id']}' AND sp_portal_id = $portalId"); sisRunQuery("DELETE FROM saman_pages_detail WHERE sp_page_detail_id = '{$pageDetailRecord[0]['sp_page_detail_id']}' AND sp_portal_id = $portalId"); $records = sisRunQuery("SELECT count(*) as rec_count FROM saman_pages p INNER JOIN saman_pages_detail pd ON (p.sp_page_id = pd.sp_page_id AND p.sp_portal_id = pd.sp_portal_id) WHERE p.sp_page_id = '$pageId' AND p.sp_portal_id = $portalId", true); if ($records[0]['rec_count'] == 0) { sisRunQuery("DELETE FROM saman_pages WHERE sp_page_id = '$pageId' AND sp_portal_id = $portalId"); sisServiceAPIFunc('pmk', 'admin', 'delassignpage', array( 'wd_id' => $pageWdId, 'page_id' => $pageId, 'node_type' => $pageNodeType) ); } sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailRecord[0]['sp_page_detail_id']]; sisRaiseEvent('sis_page_manager', 'DELETE_PAGE', SIS_EVENT_TYPE_DELETE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageDetailId' => $pageDetailRecord[0]['sp_page_detail_id'], 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageType' => $pageNodeType, 'dimensions' => $dimensions)); sisCacheDel('web_directory_info_' . $pageWdId); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGES_DESIGN_WD_ID . "&pageWdId=$pageWdId&nodeType=$pageNodeType&pageIsDesign=$pageIsDesign&sisAPWindowTitle=" . urlencode(sisParam('pageTitle')), true); } /*rest_method*/ function createNodePageBased() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageNodeType = sisParam('pageNodeType'); $pageChannel = intval(sisParam('pageChannel')); $pageLang = sisParam('pageLang'); $pageIsDesign = intval(sisParam('pageIsDesign')); $pageMainPageDetailId = intval(sisParam('pageMainPageDetailId')); if (!$pageWdId || !$pageNodeType || !$pageLang) { die(); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { die(); } $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; $channels = array( _LNG_PGM_CHANNEL_ALL, _LNG_PGM_CHANNEL_DESKTOP, _LNG_PGM_CHANNEL_MOBILE, _LNG_PGM_CHANNEL_TABLET, _LNG_PGM_CHANNEL_WEAK_PERSON, _LNG_PGM_CHANNEL_BOT, _LNG_PGM_CHANNEL_OLD_BROWSER, _LNG_PGM_CHANNEL_HIGH_TRAFFIC, _LNG_PGM_CHANNEL_LOW_SPEED ); $wdPageField = ''; switch ($pageNodeType) { case 'node'; $wdPageField = 'sp_node_page_id'; break; case 'view'; $wdPageField = 'sp_view_page_id'; break; case 'edit'; $wdPageField = 'sp_edit_page_id'; break; } if (!$wdPageField) { die(); } if ($pageMainPageDetailId) { $parentRecord = sisRunQuery("SELECT sp_page_id as page_id FROM saman_pages_detail WHERE sp_page_detail_id = $pageMainPageDetailId AND sp_portal_id = $portalId", true); } else { $parentRecord = sisRunQuery(" SELECT $wdPageField as page_id FROM saman_web_directories WHERE '$wdInfo[path]' LIKE CONCAT('%/', sp_wd_id ,'/%') AND sp_portal_id = $portalId AND sp_device = $pageChannel AND sp_lang = '" . ($pageLang == 'all' ? '' : sisVarPrepForStore($pageLang)) . "'", true); } if (!$parentRecord[0]['page_id']) { sisRaiseException(sprintf(_LNG_PGM_CREATE_PAGE_BASED_PARENT_ERROR, $languages[$pageLang], $channels[$pageChannel])); sisCloseCurrentWindow(); } $pageDetailId = $this->duplicateNodePage($parentRecord[0]['page_id'], $pageWdId, $pageNodeType, $pageChannel, $pageLang, null, null, $pageIsDesign); if (!$pageDetailId) { die(); } sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailId]; sisRaiseEvent('sis_page_manager', 'CREATE_PAGE_DETAIL', SIS_EVENT_TYPE_CREATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageType' => $pageNodeType, 'dimensions' => $dimensions), 'UPDATE_PAGE'); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGE_DESIGN_WD_ID . "&pageWdId=$pageWdId&pageNodeType=$pageNodeType&pageChannel=$pageChannel&pageLang=$pageLang&pageIsDesign=$pageIsDesign&sisAPTabsheetName=pgmPageDesignTab", true); } /*rest_method*/ function createNodePageBasedExisting() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageNodeType = sisParam('pageNodeType'); $destPageChannel = intval(sisParam('destPageChannel')); $destPageLang = sisParam('destPageLang'); $srcPageChannel = intval(sisParam('srcPageChannel')); $srcPageLang = sisParam('srcPageLang'); $pageIsDesign = intval(sisParam('pageIsDesign')); if (!$pageWdId || !$pageNodeType || !$destPageLang || !$srcPageLang) { die(); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo || !$wdInfo['wd_pages'][$pageNodeType]) { sisRaiseException(_LNG_PGM_PAGE_DELETED_ERROR); sisCloseCurrentWindow(); } $record = sisRunQuery("SELECT sp_page_id FROM saman_pages_detail WHERE sp_page_id = {$wdInfo['wd_pages'][$pageNodeType]} AND sp_language = '" . ($destPageLang != 'all' ? sisVarPrepForStore($destPageLang) : '') . "' AND sp_device = $destPageChannel AND sp_portal_id = $portalId", true); if ($record[0]['sp_page_id']) { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGE_DESIGN_WD_ID . "&pageWdId=$pageWdId&pageNodeType=$pageNodeType&pageChannel=$destPageChannel&pageLang=$destPageLang&pageIsDesign=$pageIsDesign&sisAPTabsheetName=pgmPageDesignTab", true); } $pageDetailId = $this->duplicateNodePage($wdInfo['wd_pages'][$pageNodeType], $pageWdId, $pageNodeType, $destPageChannel, $destPageLang, $srcPageChannel, $srcPageLang, $pageIsDesign); if (!$pageDetailId) { die(); } sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $pageDetailId]; sisRaiseEvent('sis_page_manager', 'CREATE_PAGE_DETAIL', SIS_EVENT_TYPE_CREATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageType' => $pageNodeType, 'dimensions' => $dimensions), 'UPDATE_PAGE'); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGE_DESIGN_WD_ID . "&pageWdId=$pageWdId&pageNodeType=$pageNodeType&pageChannel=$destPageChannel&pageLang=$destPageLang&pageIsDesign=$pageIsDesign&sisAPTabsheetName=pgmPageDesignTab", true); } /*rest_method*/ function setNodePageStatus() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageNodeType = sisParam('pageNodeType'); $pageChannel = intval(sisParam('pageChannel')); $pageStatus = intval(sisParam('pageStatus')); $pageLang = sisParam('pageLang'); $pageIsDesign = intval(sisParam('pageIsDesign')); if (!$pageWdId || !$pageNodeType || !$pageLang) { die(); } $wdPageField = ''; switch ($pageNodeType) { case 'node'; $wdPageField = 'sp_node_page_id'; break; case 'view'; $wdPageField = 'sp_view_page_id'; break; case 'edit'; $wdPageField = 'sp_edit_page_id'; break; } if (!$wdPageField) { die(); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { die(); } if (!$wdInfo['wd_pages'][$pageNodeType]) { die(); } sisRunQuery("UPDATE saman_pages_detail SET sp_status = " . ($pageStatus ? '1' : '0') . " WHERE sp_page_id = {$wdInfo['wd_pages'][$pageNodeType]} AND sp_language = '" . ($pageLang != 'all' ? sisVarPrepForStore($pageLang) : "") . "' AND sp_portal_id = $portalId AND sp_device = $pageChannel"); sisSetStatusMsg(); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value'=> $wdInfo['wd_pages'][$pageNodeType]]; sisRaiseEvent('sis_page_manager', 'CHANGE_PAGE_STATUS', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageType' => $pageNodeType, 'pageStatus' => $pageStatus, 'dimensions' => $dimensions), 'EDIT_PAGE'); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGES_DESIGN_WD_ID . "&pageWdId=$pageWdId&nodeType=$pageNodeType&sisAPTabsheetName=pgmPageDesignTab&sisAPWindowTitle=" . urlencode(sisParam('pageTitle')), true); } /*rest_method*/ function uploadChanges() { /*$portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $pageNodeType = sisParam('pageNodeType'); $pageChannel = intval(sisParam('pageChannel')); $pageLang = sisParam('pageLang'); $pageIsDesign = intval(sisParam('pageIsDesign')); if (!$pageWdId || !$pageNodeType || !$pageLang) { die(); } $wdPageField = ''; switch ($pageNodeType) { case 'node'; $wdPageField = 'sp_node_page_id'; break; case 'view'; $wdPageField = 'sp_view_page_id'; break; case 'edit'; $wdPageField = 'sp_edit_page_id'; break; } if (!$wdPageField) { die(); } $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { die(); } if (!$wdInfo['wd_pages'][$pageChannel][1][$pageNodeType]) { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGES_DESIGN_WD_ID . "&pageWdId=$pageWdId&nodeType=$pageNodeType&pageIsDesign=0", true); } if ($wdInfo['wd_pages'][$pageChannel][0][$pageNodeType]) { $this->deletePage($wdInfo['wd_pages'][$pageChannel][0][$pageNodeType], $pageLang, $portalId); $record = sisRunQuery("SELECT COUNT(*) as rec_count FROM saman_pages WHERE sp_page_id = {$wdInfo['wd_pages'][$pageChannel][0][$pageNodeType]} AND sp_portal_id = $portalId", true); if ($record[0]['rec_count'] == 0) { sisRunQuery(" UPDATE saman_web_directories SET $wdPageField = 0 WHERE sp_wd_id = $pageWdId AND sp_device = $pageChannel AND sp_device = $pageChannel AND sp_portal_id = $portalId"); } } if (!$this->duplicateNodePage($wdInfo['wd_pages'][$pageChannel][1][$pageNodeType], $pageWdId, $pageNodeType, $pageChannel, $pageLang, null, null, 0, 1)) { sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGES_DESIGN_WD_ID . "&pageWdId=$pageWdId&nodeType=$pageNodeType&pageIsDesign=0", true); } sisSetStatusMsg(); //sisRaiseEvent('sis_page_manager', 'UPLOAD_COPY_PAGE_CHANGES', SIS_EVENT_TYPE_UPDATE, array('objectName' => $pageWdId, 'objectId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageNodeType' => $pageNodeType), 'EDIT_PAGE'); sisServerTransfer("index.php?module=web_directory&wd_id=" . _PGM_PAGES_DESIGN_WD_ID . "&pageWdId=$pageWdId&nodeType=$pageNodeType&pageIsDesign=0", true); */ } /*rest_method*/ function duplicatePage($pageWdId = null, $newWdId = null, $nodeType = null, $serviceWdId = null, $backWdId = null, $redirect = true, $copy = false, $pageNewTitle = null) { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = $pageWdId !== null ? intval($pageWdId) : intval(sisParam('pageWdId')); $serviceWdId = $serviceWdId !== null ? intval($serviceWdId) : intval(sisParam('serviceWdId')); $backWdId = $backWdId !== null ? intval($backWdId) : intval(sisParam('backWdId')); $copy = $copy ? intval($copy) : intval(sisParam('copy')); $pageNewTitle = $pageNewTitle !== null ? $pageNewTitle : sisParam('pageNewTitle'); if (!$pageWdId || (!$serviceWdId && !$backWdId)) { die(); } $directoryInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $pageWdId)); if (!$directoryInfo) { die(); } $fieldName = ''; $nodeType = $nodeType !== null ? $nodeType : sisParam('nodeType'); switch ($nodeType) { case 'node': $fieldName = 'sp_node_page_id'; $nodeType = 'node'; break; case 'view': $fieldName = 'sp_view_page_id'; $nodeType = 'view'; break; case 'edit': $fieldName = 'sp_edit_page_id'; $nodeType = 'edit'; break; } if (!$fieldName) { die(); } $pages = array(); if ($directoryInfo['wd_pages'][$nodeType]) { $result = sisRunQuery("SELECT sp_page_detail_id as detail_id, sp_language as lang, sp_status as status, sp_device as device FROM saman_pages_detail WHERE sp_page_id = " . $directoryInfo['wd_pages'][$nodeType] . " AND sp_portal_id = " . sisGlobal('portal_id')); while (!$result->EOF()) { if (!$result->fields['lang']) { $result->fields['lang'] = 'all'; } $pages[$result->fields['device']][$result->fields['lang']] = $result->fields['detail_id']; $result->moveNext(); } } if ($newWdId === null) { if ($copy) { $newNodeType = $directoryInfo['node_type'] == 2 ? 5 : $directoryInfo['node_type']; $insertSql = "INSERT INTO saman_web_directories ( sp_title, sp_parent_id, sp_reg_date, sp_portal_id, sp_level, sp_path, sp_node_type, sp_no_page, sp_no_menu, sp_keywords, sp_descrption, sp_lang, sp_seo_title, sp_image, sp_is_admin, sp_is_system, sp_redirect_to, sp_show_in_sitemap, sp_alias, sp_uid ) VALUES ( '" . sisVarPrepForStore($pageNewTitle) . "', " . (intval($directoryInfo['parent_id']) > 0 ? intval($directoryInfo['parent_id']) : _PGM_MAIN_WD_ID) . ", NOW()," . intval($directoryInfo['portal_id']) . ", " . intval($directoryInfo['level']) . ", '" . ($directoryInfo['path'] == '/' ? $directoryInfo['path'] . $directoryInfo['id'] . '/' . _PGM_MAIN_WD_ID . '/' : $directoryInfo['path']) . "', " . intval($newNodeType) . ", " . ($directoryInfo['no_page'] !== null ? $directoryInfo['no_page'] : 'NULL') . ", " . ($directoryInfo['no_menu'] !== null ? $directoryInfo['no_menu'] : 'NULL') . ", " . ($directoryInfo['keywords'] !== null ? "'" . sisVarPrepForStore(serialize($directoryInfo['keywords'])) . "'" : 'NULL') . ", " . ($directoryInfo['desc'] !== null ? "'" . sisVarPrepForStore(serialize($directoryInfo['desc'])) . "'" : 'NULL') . ", " . ($directoryInfo['lang'] !== null ? "'" . sisVarPrepForStore($directoryInfo['lang']) . "'" : 'NULL') . ", " . ($directoryInfo['seo_title'] !== null ? "'" . sisVarPrepForStore(serialize($directoryInfo['seo_title'])) . "'" : 'NULL') . ", " . ($directoryInfo['image'] !== null ? "'" . sisVarPrepForStore($directoryInfo['image']) . "'" : 'NULL') . ", " . ($directoryInfo['is_admin'] !== null ? intval($directoryInfo['is_admin']) : 'NULL') . ", " . ($directoryInfo['is_system'] !== null ? intval($directoryInfo['is_system']) : 'NULL') . ", " . ($directoryInfo['redirect_to'] !== null ? "'" . sisVarPrepForStore($directoryInfo['redirect_to']) . "'" : 'NULL') . ", " . ($directoryInfo['show_in_sitemap'] !== null ? intval($directoryInfo['show_in_sitemap']) : 'NULL') . ", " . ($directoryInfo['alias'] !== null ? "'" . sisVarPrepForStore($directoryInfo['alias']) : 'NULL') . ", " . intval(sisSessionGetVar('__sisUserID')) . " )"; $newId = sisRunQuery($insertSql); $insertedWdRecord = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_id =" . intval($newId->db->dbLink->INSERT_ID()) . " AND sp_portal_id = $directoryInfo[portal_id] AND sp_node_type = " . intval($newNodeType) . " ORDER BY sp_id DESC LIMIT 1", true); $newWdId = $insertedWdRecord[0]['sp_id']; } else { $insertSql = "INSERT INTO saman_web_directories ( sp_title, sp_parent_id, sp_reg_date, sp_portal_id, sp_level, sp_path, sp_node_type, sp_no_page, sp_no_menu ) VALUES ( '" . sisVarPrepForStore(serialize($directoryInfo['title'])) . "', " . intval($directoryInfo[id]) . ", NOW(), $directoryInfo[portal_id], " . ($directoryInfo['level'] + 1) . ", '$directoryInfo[path]$directoryInfo[id]/', '-1', 1, 1 )"; sisRunQuery($insertSql); $insertedWdRecord = sisRunQuery("SELECT sp_id FROM saman_web_directories WHERE sp_parent_id = $directoryInfo[id] AND sp_portal_id = $directoryInfo[portal_id] AND sp_node_type = -1 ORDER BY sp_id DESC LIMIT 1", true); $newWdId = $insertedWdRecord[0]['sp_id']; } } if (count($pages) == 0) { $newPageId = sisServiceAPIFunc('pmk', 'admin', 'createPage', array( 'page_show_in_menu' => 0, 'page_code' => "{$pageWdId}_" . rand() . "_copy", 'page_type' => $nodeType, 'page_portal_id' => $portalId )); if ($redirect) { sisServiceAPIFunc('pmk', 'admin', 'assignpage', array('page_id' => $newPageId, 'node_type' => $nodeType, 'wd_id' => $newWdId, 'device' => $channel, 'design' => 0)); } else { return; } } else { $newWdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $newWdId)); foreach ($pages as $channel => $chPages) { $newPageId = $newWdInfo['wd_page'][$nodeType]; foreach ($chPages as $lang => $pageId) { if ($lang == 'all') { $lang = ''; } if (!$newPageId) { $pageRecord = sisRunQuery(" SELECT pg.* FROM saman_pages pg INNER JOIN saman_pages_detail pd WHERE pd.sp_page_detail_id = $pageId AND pg.sp_portal_id = $portalId LIMIT 1", true); $newPageId = sisServiceAPIFunc('pmk', 'admin', 'createPage', array( 'page_show_in_menu' => 0, 'page_code' => "{$pageRecord[0]['sp_code']}_copy", 'page_type' => $pageRecord[0]['sp_page_type'], 'page_portal_id' => $portalId )); $newWdInfo['wd_page'][$nodeType] = $newPageId; sisServiceAPIFunc('pmk', 'admin', 'assignpage', array('page_id' => $newPageId, 'node_type' => $nodeType, 'wd_id' => $newWdId)); } $pageDetailRecords = sisRunQuery("SELECT * FROM saman_pages_detail WHERE sp_page_detail_id = $pageId AND sp_language = '$lang' AND sp_device = '$channel' AND sp_portal_id = $portalId", true); if ($newWdInfo['lang']) { $tmpPageDetailRecords = array(); foreach ($pageDetailRecords as $pageDetailRecord) { if ($pageDetailRecord['sp_language'] == '' || $pageDetailRecord['sp_language'] == $newWdInfo['lang']) { $tmpLang = $pageDetailRecord['sp_language']; if ($tmpLang == '') { $tmpLang = 'all'; } $tmpPageDetailRecords[$tmpLang] = $pageDetailRecord; } } if (count($tmpPageDetailRecords) > 1) { unset($tmpPageDetailRecords['all']); } else { $tmpPageDetailRecords['all']['sp_language'] = $newWdInfo['lang']; } $pageDetailRecords = array_values($tmpPageDetailRecords); } foreach ($pageDetailRecords as $pageDetailRecord) { //$pageDetailRecord['sp_language'] = 'fa'; $newPageDetailId = sisServiceAPIFunc('pmk', 'admin', 'createPageDetail', array( 'page_id' => $newPageId, 'page_language' => $pageDetailRecord['sp_language'], 'page_device' => $pageDetailRecord['sp_device'], 'page_status' => $pageDetailRecord['sp_status'], 'page_layout_template_id' => $pageDetailRecord['sp_layout_template'], 'page_show_title' => $pageDetailRecord['sp_show_title'], 'page_page_template_id' => $pageDetailRecord['sp_page_template'], 'page_deletable' => $pageDetailRecord['sp_deletable'], 'master_page' => $pageDetailRecord['sp_masterpage_id'], 'portal_id' => $pageDetailRecord['sp_portal_id'] )); sisRunQuery("INSERT INTO saman_page_items ( sp_page_id, sp_bkey, sp_title, sp_content, sp_type, sp_mid, sp_position, sp_weight, sp_active, sp_collapsable, sp_refresh, sp_last_update, sp_language, sp_title_link, sp_header, sp_footer, sp_template, sp_block_id, sp_conditions, sp_portal_id, sp_property_values, sp_block_css_class, sp_is_css_sprite, sp_css_sprite_class, sp_header_image, sp_footer_image, sp_back_image, sp_back_image_position, sp_back_image_repeat, sp_header_image_position, sp_footer_image_position, sp_container_id, sp_responsive_settings, _import_id ) SELECT $newPageDetailId as sp_page_id, itm.sp_bkey, itm.sp_title, itm.sp_content, itm.sp_type, itm.sp_mid, itm.sp_position, itm.sp_weight, itm.sp_active, itm.sp_collapsable, itm.sp_refresh, NOW() as sp_last_update, itm.sp_language, itm.sp_title_link, itm.sp_header, itm.sp_footer, itm.sp_template, itm.sp_block_id, itm.sp_conditions, itm.sp_portal_id, itm.sp_property_values, itm.sp_block_css_class, itm.sp_is_css_sprite, itm.sp_css_sprite_class, itm.sp_header_image, itm.sp_footer_image, itm.sp_back_image, itm.sp_back_image_position, itm.sp_back_image_repeat, itm.sp_header_image_position, itm.sp_footer_image_position, itm.sp_container_id, itm.sp_responsive_settings, itm.sp_bid as _import_id FROM saman_page_items itm INNER JOIN saman_pages_detail dtl ON (itm.sp_page_id = dtl.sp_page_detail_id AND itm.sp_portal_id = dtl.sp_portal_id) WHERE dtl.sp_page_detail_id =" . intval($pageDetailRecord["sp_page_detail_id"]) ." AND dtl.sp_portal_id = " . intval($pageDetailRecord["sp_portal_id"]) ." "); } } } } $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $newWdId]; sisRaiseEvent('sis_page_manager', 'DUPLICATE_PAGE', SIS_EVENT_TYPE_CREATE, array('objectName' => "Page : $newWdId", 'objectId' => $newWdId, 'basePage' => $pageWdId, 'dimensions' => $dimensions), 'CREATE_PAGE'); if ($redirect) { sisSetStatusMsg(); sisServerTransfer('index.php?module=web_directory&wd_id=' . $backWdId . '&serviceWdId=' . $serviceWdId, true); } } /*rest_method*/ function customizePage() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $serviceWdId = intval(sisParam('serviceWdId')); $ctpId = intval(sisParam('ctpId')); if (!getContentType($ctpId)) { return; } div('', 'pgmModalDialog pgmCustomizePage'); div('', 'pgmModalContainer'); sisFormGroup(); sisCaption(); t(_LNG_PGM_PAGE_TYPE); sisCaption_(); sisData(); t(' '); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(); t(_LNG_PGM_PAGE); sisCaption_(); sisData(); $cats = sisServiceAPIFunc('web_directory', 'admin', 'getAll', array('portal_id' => sisGlobal('portal_id'), 'hide_syetem_node' => true, 'level' => 3, 'display_childs_count' => true, 'parent_id' => $serviceWdId, 'show_parent' => true, 'node_type' => array(WD_NODE_TYPE_CATEGORY_ITEM, WD_NODE_TYPE_SERVICE_CATEGORY), 'translate' => true, 'all_lang' => true)); $items = sisServiceFunc('web_directory', 'admin', 'createJSTree', array('cats' => $cats, 'ajaxLoad' => true)) ; div(null, 'sisAPInputArea', 'style="width:100%;height:220px;overflow:auto;padding:5px"'); div('', NULL, 'id="__divPGMPagesTree__" style="height:100%;"'); div_(); div_(); sisData_(); sisFormGroup_(); div(null, 'clearfix'); div_(); div_(); div('', 'pgmModalOperationBar'); t(''); t(''); div_(); div_(); script(); t('(function() { var tree = ' . json_encode($items) . '; var movingNode = false; var $treeContainer = $("#__divPGMPagesTree__") .jstree({ "types" : { "' . WD_NODE_TYPE_SIMPLE . '" : { "icon" : "fa fa-file-code-o" }, "' . WD_NODE_TYPE_PORTAL . '" : { "icon" : "fa fa-globe fa-lg" }, "' . WD_NODE_TYPE_SERIVCE . '" : { "icon" : "fa fa-gear fa-lg" }, "' . WD_NODE_TYPE_SERVICE_CATEGORY . '" : { "icon" : "fa fa-folder-open" }, "' . WD_NODE_TYPE_CATEGORY_ITEM . '" : { "icon" : "fa fa-folder-open-o" }, "services" : { "icon" : "fa fa-cogs fa-lg" }, "pages" : { "icon" : "fa fa-sitemap fa-lg" }, "page" : { "icon" : "fa fa-file-o" } }, "core" : { "data" : pgmLoadTree, "animation" : true, "multiple" : false, "themes" : { "dots" : false, } }, "plugins" : ["types"], }); var jstreeObj = $treeContainer.jstree(); function pgmLoadTree(node, cb) { if (node.id === "#") { return cb(tree); } else { $.getJSON(sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'loadNodeItems') . '&parentWdId=" + node.li_attr.wd_id + "&serviceUI=false"), function(data) { cb(data); }); } } //$(".pgmCustomizePage .pgmModalContainer").height("calc(100% - " + $(".pgmCustomizePage .pgmModalOperationBar").outerHeight() + "px)"); $(".pgmCustomizePage .pgmModalOperationBar input[rel=add]").click(function() { if (!$("#cmbPgmPageType").val()) { sisAlert("' . _LNG_PGM_PAGE_TYPE_MANDATORY . '"); return; } var selectedNode = jstreeObj.get_node(jstreeObj.get_selected()); if (!selectedNode) { sisAlert("' . _LNG_PGM_PAGE_MANDATORY . '"); return; } var $parentWindow = $("#" + $(this).closest(".lightBoxMe").attr("sisAPParentWindowId")); $(this).closest(".lightBoxMe").trigger("close"); sisAdminPanel.startLoading($parentWindow); $.ajax({ type: "GET", data: {pageWdId: selectedNode.li_attr.wd_id, nodeType : $("#cmbPgmPageType").val(), serviceWdId : ' . $serviceWdId . '}, url: sisUtility.correctUrl("' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'customizeSelectedPage') . '"), success: function(msg){ sisAdminPanel.stopLoading($parentWindow); sisAdminPanel.refreshCurrentWindow(); if(msg == "OK") { sisAdminPanel.showMessage("' . _GLB_OPERATION_DONE . '", "info"); } } }); }); $(".pgmCustomizePage .pgmModalOperationBar .closeDialog").click(function() { var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); }); })();'); script_(); } /*rest_method*/ function customizeSelectedPage() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $serviceWdId = intval(sisParam('serviceWdId')); $nodeType = sisParam('nodeType'); if (!$pageWdId || !$serviceWdId || !$nodeType) { die(); } $directoryInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $pageWdId)); if (!$directoryInfo || ($directoryInfo['node_type'] != WD_NODE_TYPE_CATEGORY_ITEM && $directoryInfo['node_type'] != WD_NODE_TYPE_SERVICE_CATEGORY)) { die(); } $fieldName = ''; switch ($nodeType) { case 'node': $fieldName = 'sp_node_page_id'; $nodeType = 'node'; break; case 'view': $fieldName = 'sp_view_page_id'; $nodeType = 'view'; break; case 'edit': $fieldName = 'sp_edit_page_id'; $nodeType = 'edit'; break; } if (!$fieldName) { die(); } /*if (!$directoryInfo['wd_pages'][$nodeType]) { die(); }*/ $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; foreach ($languages as $lang => $dummy) { $parentRecord = sisRunQuery(" SELECT DISTINCT wd.sp_id FROM saman_web_directories wd INNER JOIN saman_pages_detail dtl ON ($fieldName = dtl.sp_page_id) WHERE '$directoryInfo[path]' LIKE CONCAT('%/', wd.sp_id ,'/%') AND wd.sp_portal_id = $portalId ORDER BY wd.sp_level DESC LIMIT 1", true); if ($parentRecord[0]['sp_id']) { $this->duplicatePage($parentRecord[0]['sp_id'], $pageWdId, $nodeType, $serviceWdId, _PGM_SERVICE_PAGES_LIST_WD_ID, false); } else { $newPageId = sisServiceAPIFunc('pmk', 'admin', 'createPage', array( 'page_show_in_menu' => 0, 'page_code' => "page_{$pageWdId}_0_{$nodeType}_0_all", 'page_type' => $nodeType, 'page_portal_id' => $portalId )); sisServiceAPIFunc('pmk', 'admin', 'assignpage', array('page_id' => $newPageId, 'node_type' => $nodeType, 'wd_id' => $pageWdId, 'device' => 0, 'design' => 0)); } } $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; sisRaiseEvent('sis_page_manager', 'CUSTOMIZE_SERVICE_PAGE', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'pageType' => $nodeType, 'servicePageId' => $serviceWdId, 'dimensions' => $dimensions), 'CREATE_PAGE'); die('OK'); } /*rest_method*/ function uploadPageChanges() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $pageWdId = intval(sisParam('pageWdId')); $copyPageWdId = intval(sisParam('copyPageWdId')); $serviceWdId = intval(sisParam('serviceWdId')); $backWdId = intval(sisParam('backWdId')); $nodeType = sisParam('nodeType'); if (!$pageWdId || (!$serviceWdId && !$backWdId) || !$nodeType || !$copyPageWdId) { die(); } $wdInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $pageWdId)); $copyWdInfo = sisServiceAPIFunc("web_directory", "user", "getWebDirectoryInfo", array('wd_id' => $copyPageWdId)); if (!$wdInfo || !$copyWdInfo) { die(); } $fieldName = ''; switch ($nodeType) { case 'node': $fieldName = 'sp_node_page_id'; $nodeType = 'node'; break; case 'view': $fieldName = 'sp_view_page_id'; $nodeType = 'view'; break; case 'edit': $fieldName = 'sp_edit_page_id'; $nodeType = 'edit'; break; } if (!$fieldName) { die(); } $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; foreach ($wdInfo['wd_pages'] as $pageId) { if ($pageId) { foreach ($languages as $langKey => $langTitle) { $this->deletePage($pageId, $langKey, $portalId); } } } sisRunQuery("UPDATE saman_web_directories SET $fieldName = 0 WHERE sp_id = $pageWdId AND sp_portal_id = $portalId"); $this->duplicatePage($copyPageWdId, $pageWdId, $nodeType, $serviceWdId, _PGM_SERVICE_PAGES_LIST_WD_ID, false); $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $copyPageWdId]; sisRaiseEvent('sis_page_manager', 'OVERWRITE_PAGE', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'copyPageId' => $copyPageWdId, 'servicePageId' => $serviceWdId, 'pageType' => $nodeType, 'dimensions' => $dimensions), 'EDIT_PAGE'); sisSetStatusMsg(); sisServerTransfer('index.php?module=web_directory&wd_id=' . $backWdId . '&serviceWdId=' . $serviceWdId, true); } /*rest_method*/ function setBlockStatus() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $blockIds = sisParam('blockId'); $action = sisParam('action'); if (!$blockIds) { die(); } $blockIds = explode(",", $blockIds); foreach ($blockIds as $blockId) { $blockId = intval($blockId); if ($blockId) { sisRunQuery(" UPDATE saman_blocks SET sp_active = " . ($action == 'deactive' ? '0' : '1') . " WHERE sp_bid = '$blockId' AND sp_portal_id = '$portalId'"); } } sisSetStatusMsg(); sisServerTransfer('index.php?module=web_directory&wd_id=' . _PGM_BLOCK_LIST_WD_ID, true); } /*rest_method*/ function selectActiveTheme() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } $portalId = sisGlobal('portal_id'); $masterpageId = intval(sisParam('masterpageId')); $pageWdId = intval(sisParam('pageWdId')); $pageLang = sisParam('pageLang'); $pageChannel = intval(sisParam('pageChannel')); $pageTheme = sisParam('pageTheme'); $pageNodeType = sisParam('pageNodeType'); div('', 'pgmModalDialog pgmSelectActiveTheme'); div('', 'pgmModalContainer'); sisFormGroup(); sisCaption(array('colSize' => 3)); t(_LNG_PGM_CURRENT_THEME); sisCaption_(); sisData(array('colSize' => 9)); $themes = $GLOBALS['thmEngine']->sisGetThemes(true); t(''); sisData_(); sisFormGroup_(); div_(); div('', 'pgmModalOperationBar'); t(''); t(''); div_(); div_(); script(); t('(function() { var masterpageId = ' . $masterpageId . '; //$(".pgmSelectActiveTheme .pgmModalContainer").height("calc(100% - " + $(".pgmSelectActiveTheme .pgmModalOperationBar").outerHeight() + "px)"); $(".pgmSelectActiveTheme .pgmModalOperationBar input[rel=add]").click(function() { var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); if (masterpageId) { changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_MASTERPAGE_EDIT_WD_ID . '&masterpageId=' . $masterpageId . '&pageTheme=" + $("#cmbPgmTheme").val()); } else { changeWindowLocation(null, "index.php?module=web_directory&wd_id=' . _PGM_PAGE_DESIGN_WD_ID . '&pageWdId=' . $pageWdId . '&pageLang=' . $pageLang . '&pageChannel=' . $pageChannel . '&pageNodeType=' . $pageNodeType . '&pageTitle=' . urlencode(sisParam('pageTitle')) . '&pageTheme=" + $("#cmbPgmTheme").val()); } }); $(".pgmSelectActiveTheme .pgmModalOperationBar .closeDialog").click(function() { var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); }); })();'); script_(); sisDie(); } /*rest_method*/ function pageDesignSettings() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return sisForbidden(); } $portalId = sisGlobal('portal_id'); $masterpageId = intval(sisParam('masterpageId')); $pageWdId = intval(sisParam('pageWdId')); $pageLang = sisParam('pageLang'); $pageChannel = intval(sisParam('pageChannel')); $pageTheme = sisParam('pageTheme'); $pageNodeType = sisParam('pageNodeType'); $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if (!$wdInfo) { return sisForbidden(); } $pageId = $wdInfo['wd_pages'][$pageNodeType]; if (!$pageId) { return sisForbidden(); } $pageDetailRecord = sisRunQuery("SELECT * FROM saman_pages_detail WHERE sp_page_id = $pageId AND " . ($pageLang != "all" ? "sp_language = '" . sisVarPrepForStore($pageLang) . "'" : " (sp_language IS NULL OR sp_language = '' OR sp_language = 'all') ") . " AND sp_device = $pageChannel AND sp_portal_id = $portalId", true); $pageDetailRecord = $pageDetailRecord[0]; if (!$pageDetailRecord) { return sisForbidden(); } if ($wdInfo['is_admin']) { $pageLayouts = array( array( 'template_title' => _LNG_PGM_LAYOUT_TEMPLATE_ONE_COLUMN, 'template_id' => 'onecolumn', 'template_content' => file_get_contents(sisServiceResource('layout_onecolumn.tpl', 'other', 'sis_control_panel')) ), array( 'template_title' => _LNG_PGM_LAYOUT_TEMPLATE_TWO_COLUMN, 'template_id' => 'twocolumn', 'template_content' => file_get_contents(sisServiceResource('layout_twocolumn.tpl', 'other', 'sis_control_panel')) ), ); } else { $pageLayouts = sisServiceAPIFunc('pmk', 'admin', 'getLayoutTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); $thmLayouts = sisServiceAPIFunc('pmk', 'admin', 'getPageTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); $masterpages = sisServiceAPIFunc('pmk', 'admin', 'getMasterPages', array('portal_id' => $portalId, 'theme' => $pageTheme)); } div('', 'pgmModalDialog pgmPageDesignSettings'); div('', 'pgmModalContainer'); if (!$wdInfo['is_admin']) { sisFormGroup(); sisCaption(array('colSize' => 3)); t(_LNG_PGM_MASTER_PAGE); sisCaption_(); sisData(array('colSize' => 9)); t(''); sisData_(); sisFormGroup_(); sisFormGroup(array('extraClass' => 'tdPgmTemplateSelect', 'extra' => 'style="' . ($pageDetailRecord['sp_masterpage_id'] ? 'display:none' : '') . '"')); sisCaption(array('colSize' => 3)); t(_LNG_PGM_THEME_TEMPLATE); sisCaption_(); sisData(array('colSize' => 9)); t(''); sisData_(); sisFormGroup_(); } sisFormGroup(array('extraClass' => 'tdPgmTemplateSelect', 'extra' => 'style="' . ($pageDetailRecord['sp_masterpage_id'] ? 'display:none' : '') . '"')); sisCaption(array('colSize' => 3)); t(_LNG_PGM_LAYOUT_TEMPLATE); sisCaption_(); sisData(array('colSize' => 9)); $selectedTemplate = ''; t(''); if ($wdInfo['is_admin']) { hidden('cmbPgmThemeTemplate', 'general', false, 'id="cmbPgmThemeTemplate"'); } sisData_(); sisFormGroup_(); sisFormGroup(array('extraClass' => 'tdPgmTemplateSelect', 'extra' => 'style="' . ($pageDetailRecord['sp_masterpage_id'] ? 'display:none' : '') . '"')); sisCaption(array('colSize' => 3)); t(_LNG_PGM_SHOW_TITLE); sisCaption_(); sisData(array('colSize' => 9)); t(''); sisData_(); sisFormGroup_(); div_(); div('', 'pgmModalOperationBar'); t(''); t(''); div_(); div_(); script(); t('(function() { var masterpageId = ' . $masterpageId . '; $(".pgmPageDesignSettings .pgmModalOperationBar input[rel=add]").click(function() { var newLayoutTemplate = $("#cmbPgmLayoutTemplate").val(); var newShowTitle = $("#cmbPgmShowTitle").val(); var newThemeTemplate = $("#cmbPgmThemeTemplate").val(); var newMasterpage = $("#cmbPgmMasterpage").val(); if ($("#cmbPgmLayoutTemplate:visible").length) { if (!newLayoutTemplate) { sisAlert("' . _LNG_PGM_LAYOUT_TEMPLATE_EMPTY_MESSAGE . '"); return; } if (!newThemeTemplate) { sisAlert("' . _LNG_PGM_THEME_TEMPLATE_EMPTY_MESSAGE . '"); return; } } var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); changeWindowLocation(null, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'pageAction', array('pageWdId' => $pageWdId, 'pageLang' => $pageLang, 'pageChannel' => $pageChannel, 'pageNodeType' => $pageNodeType, ' pageIsDesign' => $pageIsDesign, 'pageTheme' => $pageTheme, 'pageTitle' => urlencode(sisParam('pageTitle')))) . '&pmgAction=changeProperties&newThemeTemplate=" + newThemeTemplate + "&newLayoutTemplate=" + newLayoutTemplate + "&newShowTitle=" + newShowTitle + "&newThemeTemplate=" + newThemeTemplate + "&newShowTitle=" + newShowTitle + "&newMasterpage=" + newMasterpage); }); $(".pgmPageDesignSettings .pgmModalOperationBar .closeDialog").click(function() { var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); }); $("#cmbPgmMasterpage").change(function() { if ($(this).val().trim()) { $(".tdPgmTemplateSelect").hide(); } else { $(".tdPgmTemplateSelect").show(); } }); })();'); script_(); sisDie(); } /*rest_method*/ function masterpageDesignSettings() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { return sisForbidden(); } $masterpageId = sisParam('masterpageId'); $portalId = sisGlobal('portal_id'); $pageTheme = sisParam('pageTheme') ? sisParam('pageTheme') : sisUserGetTheme(); $languages = getLanguages(); $languages['all'] = _LNG_PGM_ALL_LANGS; $masterpageId = intval($masterpageId); $masterpageRecord = sisRunQuery(" SELECT * FROM saman_pages pg INNER JOIN saman_pages_detail pd ON (pg.sp_page_id = pd.sp_page_id) WHERE pg.sp_page_id = $masterpageId AND pg.sp_portal_id = $portalId AND pg.sp_is_master = 1", true); if (!$masterpageId || !$masterpageRecord[0]['sp_page_id']) { return sisForbidden(); } $masterpageRecord = $masterpageRecord[0]; $thmLayouts = sisServiceAPIFunc('pmk', 'admin', 'getPageTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); $pageLayouts = sisServiceAPIFunc('pmk', 'admin', 'getLayoutTemplates', array('portal_id' => $portalId, 'theme' => $pageTheme)); div('', 'pgmModalDialog pgmPageDesignSettings'); div('', 'sisDataForm pgmModalContainer'); sisFormGroup(); sisCaption(array('colSize' => 4)); t(_LNG_PGM_NAME); sisCaption_(array('mandatory' => true)); sisData(array('colSize' => 8)); t(''); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(array('colSize' => 4)); t(_LNG_PGM_THEME_TEMPLATE); sisCaption_(array('mandatory' => true)); sisData(array('colSize' => 8)); t(''); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(array('colSize' => 4)); t(_LNG_PGM_LAYOUT_TEMPLATE); sisCaption_(array('mandatory' => true)); sisData(array('colSize' => 8)); $selectedTemplate = ''; t(''); sisData_(); sisFormGroup_(); sisFormGroup(); sisCaption(array('colSize' => 4)); t(_LNG_PGM_SHOW_TITLE); sisCaption_(); sisData(array('colSize' => 8)); t(''); sisData_(); sisFormGroup_(); if (sisCheckUserLicense(PORTAL_CORE_DEVELOPER)) { sisFormGroup(); sisCaption(array('colSize' => 4)); t(_LNG_PGM_IS_SYSTEM); sisCaption_(); sisData(array('colSize' => 8)); t(''); sisData_(); sisFormGroup_(); } div_(); div('', 'pgmModalOperationBar'); t(''); t(''); div_(); div_(); script(); t('(function() { var masterpageId = ' . $masterpageId . '; $(".pgmPageDesignSettings .pgmModalContainer").height("calc(100% - " + $(".pgmPageDesignSettings .pgmModalOperationBar").outerHeight() + "px)"); $(".pgmPageDesignSettings .pgmModalOperationBar input[rel=add]").click(function() { var layoutTemplate = $("#cmbPgmLayoutTemplate").val(); var showTitle = $("#cmbPgmShowTitle").val(); var themeTemplate = $("#cmbPgmThemeTemplate").val(); var code = $("#txtPgmMSName").val(); if (!layoutTemplate) { sisAlert("' . _LNG_PGM_LAYOUT_TEMPLATE_EMPTY_MESSAGE . '"); return; } if (!themeTemplate) { sisAlert("' . _LNG_PGM_THEME_TEMPLATE_EMPTY_MESSAGE . '"); return; } if (!code.trim() || !checkFileName($("#txtPgmMSName").get(0))) { sisAlert("' . _LNG_PGM_NAME_MUST_ENGLISH . '"); return; } var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); changeWindowLocation(null, "' . callFunctionUrl(_PGM_MAIN_CTP_ID, 'pageAction', array('masterpageId' => $masterpageId, 'pageTheme' => $pageTheme)) . '&pmgAction=changeMasterpageProperties&newThemeTemplate=" + themeTemplate + "&newLayoutTemplate=" + layoutTemplate + "&newShowTitle=" + showTitle + "&newCode=" + code + "&newIsSystem=" + $("#cmbPgmMSIsSystem").val()); }); $(".pgmPageDesignSettings .pgmModalOperationBar .closeDialog").click(function() { var $box = $(this).closest(".lightBoxMe"); $box.trigger("close"); }); $("#cmbPgmMasterpage").change(function() { if ($(this).val().trim()) { $(".tdPgmTemplateSelect").hide(); } else { $(".tdPgmTemplateSelect").show(); } }); })();'); script_(); sisDie(); } /*rest_method*/ function blockProperties() { if (!sisHasRole(_PGM_MAIN_CTP_ID, 'moduleAdmin')) { die(); } if (function_exists('sisSetFormGroupSize')) { sisSetFormGroupSize(12, 2, 10); } $portalId = sisGlobal('portal_id'); $pageItemId = intval(sisParam('pageItemId')); $blockId = intval(sisParam('blockId')); $pageWdId = intval(sisParam('pageWdId')); $pageLang = sisParam('pageLang'); $adminSideBlock = false; sisServiceAPIFunc('sis_block_manager', 'updateLastViewTime', array(intval($blockId))); if (!$pageItemId && !$blockId) { die(); } if ($pageItemId) { $itemInfo = sisServiceAPIFunc('pmk', 'admin', 'getItemInfo', array('item_id' => $pageItemId)); } else { $itemInfo = sisPortletGetInfo($blockId, '', $portalId); $itemInfo['header'] = $itemInfo['block_header']; $itemInfo['footer'] = $itemInfo['block_footer']; if ($itemInfo['portal_id'] != $portalId) { sisCloseCurrentWindow(); } } $adminPageBlock = false; if ($itemInfo['item_page_id']) { $record = sisRunQuery("SELECT sp_page_id FROM saman_pages_detail WHERE sp_page_detail_id = " . intval($itemInfo['item_page_id']) . " AND sp_portal_id = " . sisGlobal('portal_id'), true); $record = sisRunQuery("SELECT sp_is_admin FROM saman_web_directories WHERE (sp_node_page_id =" . intval($record[0]['sp_page_id']) . " OR sp_edit_page_id =" . intval($record[0]['sp_page_id']) . " OR sp_view_page_id =" . intval($record[0]['sp_page_id']) . ") AND sp_portal_id = " . sisGlobal('portal_id'), true); $adminPageBlock = $record[0]['sp_is_admin']; } if (!$itemInfo) { if ($blockId) { sisCloseCurrentWindow(); } else { die(); } } if ($pageWdId) { $wdInfo = sisServiceAPIFunc('web_directory', 'user', 'getWebDirectoryInfo', array('wd_id' => $pageWdId)); if ($wdInfo['is_admin']) { $adminSideBlock = true; } } $itemInfoTmp = array(); foreach ($itemInfo as $key => $value) { if (strpos($key, "item_") === 0) { $itemInfoTmp[substr($key, 5)] = $value; } else { $itemInfoTmp[$key] = $value; } } $itemInfo = $itemInfoTmp; unset($itemInfoTmp); $this->loadLangs(); $pageTitle = $itemInfo['title']; if (strpos($pageTitle, "#D:") === 0) { $pageTitle = substr($pageTitle, 3, strlen($pageTitle) - 4); } if ($itemInfo['bkey'] == 'shareblock') { $blockInfoShare = sisPortletGetInfo($itemInfo['content']); $itemInfo['title'] = $blockInfoShare['title']; $itemInfo['title_link'] = $blockInfoShare['title_link']; if($itemInfo['header'] =="") $itemInfo['header'] = $blockInfoShare['block_header']; if($itemInfo['footer'] =="") $itemInfo['footer'] = $blockInfoShare['block_footer']; } if ($itemInfo['block_id']) { $blockInfoParent = sisPortletGetInfo($itemInfo['block_id']); if ($blockInfoParent['service_bid']) { $blockInfoOtherService = sisPortletGetInfo($blockInfoParent['service_bid']); $itemInfo['mid'] = $blockInfoOtherService['mid']; $itemInfo['bkey'] = $blockInfoOtherService['bkey']; if ($blockInfoOtherService['ctp_id']) { getContentType($blockInfoOtherService['ctp_id']); } } } if ($itemInfo['service_bid']) { $blockInfoParent = sisPortletGetInfo($itemInfo['service_bid']); if ($blockInfoParent['ctp_id']) { getContentType($blockInfoParent['ctp_id']); } } $modinfo = sisServiceGetInfo($itemInfo['mid']); if ($itemInfo['type'] == 1 && !sisPortletLoad($modinfo['name'], $itemInfo['bkey'])) { die(); } if($itemInfo['block_id'] || $itemInfo['service_bid']){ $blockInfoParent = sisPortletGetInfo($itemInfo['block_id'] ? $itemInfo['block_id'] : $itemInfo['service_bid']); $blockParentVars = sisPortletVarsFromContent($blockInfoParent['content']); $vars = sisPortletVarsFromContent($itemInfo['content']); $itemInfo['block_id'] = $blockInfoParent['bid']; if (!empty($blockInfoParent['settings']) && is_array($blockInfoParent['settings'])) { $GLOBALS['object_settings'] = array(); foreach ($blockInfoParent['settings'] as $key => $value) { $GLOBALS['object_settings'][$itemInfo['bkey']][] = $key; } } if ($GLOBALS['object_settings'][$itemInfo['bkey']] == '*') { $vars = $blockParentVars; } else { foreach ($GLOBALS['object_settings'][$itemInfo['bkey']] as $value) { $vars[$value] = $blockParentVars[$value]; } } if ($itemInfo['bkey'] == 'html' || $itemInfo['bkey'] == 'php') { $itemInfo['content'] = $blockInfoParent['content']; } else { $itemInfo['content'] = sisPortletVarsToContent($vars); } /* if ($itemInfo['bkey'] == 'html' || $itemInfo['bkey'] == 'php') { $itemInfo['content'] = $blockInfoParent['content']; } else { $itemInfo['content'] = sisPortletVarsToContent($vars); }*/ } $propertiesTmp1 = array(); if ($blockInfoParent['service_bid']) { try { @eval("\$propertiesTmp1 = array($blockInfoOtherService[properties]);"); } catch (\ParseError $ex) {} if (count($propertiesTmp1) == 0) { try { @eval("\$propertiesTmp1 = $blockInfoOtherService[properties];"); } catch (\ParseError $ex) {} } foreach ($propertiesTmp1 as $key => $value) { if ($blockInfoOtherService['settings'][$key]) unset($propertiesTmp1[$key]); } } $propertiesTmp2 = array(); try { @eval("\$propertiesTmp2 = array($blockInfoParent[properties]);"); } catch (\ParseError $ex) {} if (count($propertiesTmp2) == 0) { try { @eval("\$propertiesTmp2 = $blockInfoParent[properties];"); } catch (\ParseError $ex) {} } $propertiesTmp = array_merge($propertiesTmp1, $propertiesTmp2); if (empty($itemInfo['property_values'])) { $propertiesValues = unserialize($blockInfoParent['property_values']); } else { $propertiesValues = unserialize($itemInfo['property_values']); } $properties = array(); $lang= sisUserGetLang(); foreach ($propertiesTmp as $key => $value) { $postKey = str_replace(array(" ", ".", "#", ":"), array("__b__", "__d__", "__s__", "__c__"), $key); if(in_array($key, $GLOBALS['object_settings'][$itemInfo['bkey']])) continue; /*if ($value['type'] == 'style') { $value['position'] = 'style'; } if ($value['type'] == 'template') { $value['position'] = 'template'; } if (!$value['position']) { $value['position'] = 'top'; }*/ if (!$value['section']) { $value['section'] = 'specific'; } $properties[$value['section']][$postKey] = array(); $properties[$value['section']][$postKey]['title'] = localizedStr($value['title']); if (isset($propertiesValues[$key])) { $properties[$value['section']][$postKey]['value'] = $propertiesValues[$key]['value']; } else { $properties[$value['section']][$postKey]['value'] = $value['default_value']; } $properties[$value['section']][$postKey]['type'] = $value['type']; $properties[$value['section']][$postKey]['items_type'] = $value['items_type']; $properties[$value['section']][$postKey]['mandatory'] = $value['mandatory']; $properties[$value['section']][$postKey]['extra'] = $value['extra']; $properties[$value['section']][$postKey]['customJsCode'] = $value['customJsCode']; if ($value['group']) { $properties[$value['section']][$postKey]['group'] = $value['group']; } if ($value['section'] == 'template') { $properties[$value['section']][$postKey]['fields'] = json_encode($value['fields']); } if ($value['type'] == 'radio' || $value['type'] == 'combobox' || $value['type'] == 'multiple') { $properties[$value['section']][$postKey]['items'] = array(); if ($value['type'] == 'combobox' && $value['blank_item']) { $properties[$value['section']][$postKey]['items'][] = array('value' => '', 'caption' => ''); } if ($value['items_type'] == 'static') { $items = split(",", sisVarPrepForStore($value['items'])); foreach ($items as $item) { $valueItem = substr($item, 0, strpos($item, ':')); $caption = str_replace($valueItem.':', '', $item); $captionlang = sisUserGetLang(); if(sisUserGetLang()!='en' && !ereg(sisUserGetLang().':', $item)) { $captionlang = 'fa'; } if (ereg($captionlang.':', $item)) { $caption = substr($caption, strpos($caption, $captionlang.':') + 3); if (strpos($caption, ';')) { $caption = substr($caption, 0, strpos($caption, ';')); } } else { $caption = substr($item, strpos($item, ':') + 1); } $tag = ''; if (ereg(':', $caption)) { $tag = substr($caption, strrpos($caption, ':') + 1); $caption = str_replace(":$tag", "", $caption); } $properties[$value['section']][$postKey]['items'][] = array('value' => $valueItem, 'caption' => $caption, 'tag'=>$tag); } } else if ($value['items_type'] == 'query') { $dbconn = &sisDBGetConn(true); $spTable = &sisDBGetTables(); $sql = $value['items']; if (trim($sql)) { $result =& $dbconn->Execute($sql); if (!($dbconn->ErrorNo() != 0)) { while (!$result->EOF) { $tmp = $result->GetRowAssoc(false); $caption = localizedStr($tmp['caption']); if (isset($tmp['caption_'.sisUserGetLang()])) { $caption = $tmp['caption_'.sisUserGetLang()]; } $properties[$value['section']][$postKey]['items'][] = array('value' => $tmp['value'], 'caption' => $caption); $result->MoveNext(); } } } } else if ($value['items_type'] == 'func'){ } } } $usname = preg_replace('/ /', '_', $modinfo['name']); $modfunc = $usname . '_' . $itemInfo['bkey'] . 'block_modify'; $itemOutput = ''; $specificProperties = array(); if (function_exists($modfunc)) { $itemOutput = $modfunc($itemInfo); } else { $itemsModules = $GLOBALS['blocks_modules'][$itemInfo['mid']]; if (!empty($itemsModules[$itemInfo['bkey']]) && !empty($itemsModules[$itemInfo['bkey']]['func_edit'])) { if (function_exists($itemsModules[$itemInfo['bkey']]['func_edit'])) { $itemOutput = $itemsModules[$itemInfo['bkey']]['func_edit'](array_merge($_GET, $_POST, $itemInfo)); } } } if (is_array($itemOutput)) { $blockSpecificProperties = $itemOutput; $itemOutput = ''; foreach ($blockSpecificProperties as $propertyName => $blockSpecificProperty) { if (!$blockSpecificProperty['section']) { $blockSpecificProperty['section'] = 'specific'; } $specificProperties[$blockSpecificProperty['section']][$propertyName] = $blockSpecificProperty; } } $itemContentflag = null; $itemContentHtmlEditor = null; if (!empty($itemsModules[$itemInfo['bkey']]) && ($itemsModules[$itemInfo['bkey']]['form_content'] == true) && !$itemInfo['block_id']) { if (sisPortletIsObjectSetting($itemInfo['block_id'], $itemInfo['bkey'], 'content')) { $itemContentflag = true; } else { $itemContentflag = false; } /*if ($itemInfo['bkey'] != 'html'){ $itemContentflag = 1; } if ($itemInfo['bkey'] == 'html') { $itemContentHtmlEditor = 'enable_editor=true'; } if ($itemInfo['bkey'] == 'php') { $itemContentHtmlEditor = 'direction:ltr;font-family: Courier New; font-size: 11px;'; if (sisPortletIsObjectSetting($itemInfo['block_id'], 'php', 'content')) { $itemContentflag = 1; } else { $itemContentflag = 0; } } else if ($itemInfo['block_id'] ) { $itemContentflag = 0; }*/ } else { $itemContentflag = false; } if ($itemContentflag) { $contentProperty = array( 'id' => 'content', 'title' => 'text', 'type' => 'memo', ); if ($itemInfo['bkey'] == 'html') { $contentProperty['type'] = 'memo'; } if ($itemInfo['bkey'] == 'php') { $contentProperty['type'] = 'codeEditor'; $contentProperty['width'] = '100%'; $contentProperty['height'] = '500px'; } $specificProperties['specific']['content'] = $contentProperty; } if (!$properties['bottom']) { $properties['bottom'] = array(); } if (!$properties['style']) { $properties['style'] = array(); } if (!$properties['template']) { $properties['template'] = array(); } foreach ($properties as $key => $group) { foreach ($group as $id => $property) { $itemId = str_replace(array(" ", ".", "#", ":"), array("__b__", "__d__", "__s__", "__c__"), $id); $properties[$key][$id]['id'] = "properties[$itemId]"; } } $languages = getLanguages(); $languages = array_merge(array('all' => _LNG_PGM_ALL_LANGS), $languages); $refresh = array( '0' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_REALTIME, '300' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_5M, '600' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_10M, '900' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_15M, '1800' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_30M, '3600' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_1H, '7200' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_2H, '14400' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_4H, '43200' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_12H, '86400' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH_1D ); $publishArea = array( 1 => _LNG_PGM_PUBLISH_AREA_MAIN_PORTAL, 2 => _LNG_PGM_PUBLISH_AREA_ALL_PORTALS ); $imagePosition = array( 'right' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_RIGHT, 'left' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_LEFT, 'center' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_CENTER, ); $backgroundPosition = array( 'top right' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_TOP . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_RIGHT, 'top left' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_TOP . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_LEFT, 'top center' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_TOP . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_CENTER, 'center right' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_MIDDLE . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_RIGHT, 'center left' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_MIDDLE . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_LEFT, 'center center' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_MIDDLE . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_CENTER, 'bottom right' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_BOTTOM . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_RIGHT, 'bottom left' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_BOTTOM . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_LEFT, 'bottom center' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION_BOTTOM . '-' . _LNG_PGM_BLOCK_PROPERTIES_BLOCK_IMAGE_POSITION_CENTER ); $backgroundRepeat = array( 'repeat-y' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_REPEAT_Y, 'repeat-x' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_REPEAT_X, 'no-repeat' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_REPEAT_NO, ); $boolean = array( '1' => _LNG_PGM_YES, '0' => _LNG_PGM_NO, ); $responsiveCols = array( '0' => _LNG_PGM_DEFAULT, '12' => '12 ' . _LNG_PGM_RESPONSIVE_COLS, '11' => '11 ' . _LNG_PGM_RESPONSIVE_COLS, '10' => '10 ' . _LNG_PGM_RESPONSIVE_COLS, '9' => '9 ' . _LNG_PGM_RESPONSIVE_COLS, '8' => '8 ' . _LNG_PGM_RESPONSIVE_COLS, '7' => '7 ' . _LNG_PGM_RESPONSIVE_COLS, '6' => '6 ' . _LNG_PGM_RESPONSIVE_COLS, '5' => '5 ' . _LNG_PGM_RESPONSIVE_COLS, '4' => '4 ' . _LNG_PGM_RESPONSIVE_COLS, '3' => '3 ' . _LNG_PGM_RESPONSIVE_COLS, '2' => '2 ' . _LNG_PGM_RESPONSIVE_COLS, '1' => '1 ' . _LNG_PGM_RESPONSIVE_COLS, 'none' => _LNG_PGM_RESPONSIVE_HIDDEN, ); $responsiveOffset = array( '-1' => _LNG_PGM_RESPONSIVE_NO_OFFSET, '0' => '0 ' . _LNG_PGM_RESPONSIVE_COLS, '1' => '1 ' . _LNG_PGM_RESPONSIVE_COLS, '2' => '2 ' . _LNG_PGM_RESPONSIVE_COLS, '3' => '3 ' . _LNG_PGM_RESPONSIVE_COLS, '4' => '4 ' . _LNG_PGM_RESPONSIVE_COLS, '5' => '5 ' . _LNG_PGM_RESPONSIVE_COLS, '6' => '6 ' . _LNG_PGM_RESPONSIVE_COLS, '7' => '7 ' . _LNG_PGM_RESPONSIVE_COLS, '8' => '8 ' . _LNG_PGM_RESPONSIVE_COLS, '9' => '9 ' . _LNG_PGM_RESPONSIVE_COLS, '10' => '10 ' . _LNG_PGM_RESPONSIVE_COLS, '11' => '11 ' . _LNG_PGM_RESPONSIVE_COLS, '12' => '12 ' . _LNG_PGM_RESPONSIVE_COLS, ); $blockTemplates = sisServiceFunc('pmk', 'admin', 'getitemtemplates'); asort($blockTemplates); if ($adminSideBlock) { foreach ($blockTemplates as $key => $value) { if ($key != 'default' && $key != 'standalone') { unset($blockTemplates[$key]); } } } foreach ($blockTemplates as $key => $value) { $blockTemplates[$key] = localizedStr($blockTemplates[$key]); } if (!$properties['top']) { $properties['top'] = array(); } if (!$properties['bottom']) { $properties['bottom'] = array(); } foreach ($properties['style'] as $key => $value) { $properties['style'][$key]['group'] = _LNG_PGM_BLOCK_CONTENT_STYLE; } $dynamicProperties = $properties; $properties = array( _LNG_PGM_BLOCK_PROPERTIES_GENERAL => array( 'title' => array('id' => 'items[title]','title' => _LNG_PGM_BLOCK_PROPERTIES_TITLE, 'type' => 'text', 'extra' => 'class="col-xs-12"', 'disabled' => $itemInfo['bkey'] == 'shareblock'), 'title_link' => array('id' => 'items[title_link]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_TITLE_LINK, 'type' => 'text', 'extra' => 'style="direction:ltr" class="col-xs-12"', 'disabled' => $itemInfo['bkey'] == 'shareblock'), 'conditions' => array('id' => 'items[conditions]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_DISPLAY_CONDITION, 'type' => 'codeEditor', 'language' => 'php-inline'), 'active' => array('id' => 'items[active]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_STATUS, 'type' => 'radio', 'items' => array('1' => _LNG_PGM_BLOCK_PROPERTIES_STATUS_ACTIVE, '0' => _LNG_PGM_BLOCK_PROPERTIES_STATUS_DEACTIVE)), 'language' => array('id' => 'items[language]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_LANGUAGE, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $languages), 'publish_scope' => array('id' => 'items[publish_scope]', 'title' => _LNG_PGM_PUBLISH_AREA, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $publishArea), 'refresh' => array('id' => 'items[refresh]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_REFRESH, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $refresh), ), _LNG_PGM_BLOCK_PROPERTIES_DATA => array( ), _LNG_PGM_BLOCK_PROPERTIES_SPECIFIC => array_merge($properties['top'], trim($itemOutput) && $itemInfo['bkey'] != 'shareblock' ? array('-' => $itemOutput) : array(), $properties['bottom']), _LNG_PGM_BLOCK_PROPERTIES_LAYOUT => array( ), _LNG_PGM_RESPONSIVE_SETTINGS => array( 'block_responsive' => array('title' => _LNG_PGM_BLOCK_BOX, 'id' => 'block', 'type' => 'responsive', 'responsive_items' => array('column', 'offset', 'new_row', 'push', 'pull')), ), _LNG_PGM_BLOCK_PROPERTIES_STYLE => array_merge(array( 'template' => array('id' => 'items[template]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_TEMPLATE, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $blockTemplates), 'header' => array('id' => 'items[header]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_HEADER, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'codeEditor', 'language' => 'html'), 'footer' => array('id' => 'items[footer]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_FOOTER, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'codeEditor', 'language' => 'html'), /*'header_image' => array('id' => 'items[header_image]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_HEADER_IMAGE, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'image'), 'header_image_position' => array('id' => 'items[header_image_position]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_HEADER_IMAGE_POSITION, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $imagePosition, 'blankItem' => true), 'footer_image' => array('id' => 'items[footer_image]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_FOOTER_IMAGE, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'image'), 'footer_image_position' => array('id' => 'items[footer_image_position]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_FOOTER_IMAGE_POSITION, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $imagePosition, 'blankItem' => true), 'back_image' => array('id' => 'items[back_image]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'image'), 'back_image_position' => array('id' => 'items[back_image_position]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_POSITION, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $backgroundPosition, 'blankItem' => true), 'back_image_repeat' => array('id' => 'items[back_image_repeat]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_IMAGE_REPEAT, 'group' => _LNG_PGM_BLOCK_BOX, 'type' => 'combobox', 'extra' => 'class="col-xs-4"', 'items' => $backgroundRepeat, 'blankItem' => true),*/ 'block_css_class' => array('id' => 'items[block_css_class]', 'title' => _LNG_PGM_BLOCK_PROPERTIES_BLOCK_BACKGROUND_CSS_CLASS, 'group' => _LNG_PGM_BLOCK_CONTENT_STYLE, 'type' => 'text', 'extra' => 'style="direction:ltr" class="col-xs-4"'), 'is_css_sprite' => array('id' => 'items[is_css_sprite]', 'title' => _LNG_PGM_GNERATE_CSS_SPRITE_IMAGES, 'group' => _LNG_PGM_BLOCK_CONTENT_STYLE, 'type' => 'checkbox'), 'css_sprite_class' => array('id' => 'items[css_sprite_class]', 'title' => _LNG_PGM_CSS_SPRITE_CLASS, 'group' => _LNG_PGM_BLOCK_CONTENT_STYLE, 'type' => 'text', 'extra' => 'style="direction:ltr" class="col-xs-4"'), ), $properties['style'], $properties['template'] ), ); $propertiesSectionTitle = array ( _LNG_PGM_BLOCK_PROPERTIES_DATA => 'data', _LNG_PGM_BLOCK_PROPERTIES_LAYOUT => 'layout', _LNG_PGM_BLOCK_PROPERTIES_GENERAL => 'general', _LNG_PGM_BLOCK_PROPERTIES_SPECIFIC => 'specific', _LNG_PGM_BLOCK_PROPERTIES_STYLE => 'style', _LNG_PGM_RESPONSIVE_SETTINGS => 'responsive', ); if ($itemInfo['bkey'] == 'shareblock') { foreach ($properties[_LNG_PGM_BLOCK_PROPERTIES_STYLE] as $key => $dummy) { if ($key != 'template' && $key != 'is_css_sprite' && $key != 'css_sprite_class' && $key != 'block_css_class') { unset($properties[_LNG_PGM_BLOCK_PROPERTIES_STYLE][$key]); } } } if ($itemInfo['type'] == 2) { unset($properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL]['title_link']); unset($properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL]['refresh']); unset($properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC]); unset($properties[_LNG_PGM_BLOCK_PROPERTIES_STYLE]); if ($itemInfo['bkey'] == 'cdk') { $properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC] = array(); $properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC]['type'] = array('id' => 'content[type]', 'title' => _LNG_PGM_SERVICE_OUTPUT_TYPE, 'type' => 'combobox', 'items' => array('user' => 'User', 'admin' => 'Admin'), 'extra' => 'style="width:30%"'); $properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC]['func'] = array('id' => 'content[func]', 'title' => _LNG_PGM_SERVICE_OUTPUT_FUNCTION, 'type' => 'text', 'extra' => 'style="width:30%"'); $properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC]['params'] = array('id' => 'content[params]', 'title' => _LNG_PGM_SERVICE_OUTPUT_PARAMETERS, 'type' => 'text', 'extra' => 'style="width:70%"'); $itemInfo['content'] = unserialize($itemInfo['content']); } } if ($pageLang != 'all') { unset($properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL]['language']); } if ($portalId != 0 || $pageItemId) { unset($properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL]['publish_scope']); } $properties[_LNG_PGM_BLOCK_PROPERTIES_DATA] = array_merge($properties[_LNG_PGM_BLOCK_PROPERTIES_DATA], $dynamicProperties['data'] ? $dynamicProperties['data'] : array(), $specificProperties['data'] ? $specificProperties['data'] : array()); $properties[_LNG_PGM_BLOCK_PROPERTIES_LAYOUT] = array_merge($properties[_LNG_PGM_BLOCK_PROPERTIES_LAYOUT], $dynamicProperties['layout'] ? $dynamicProperties['layout'] : array(), $specificProperties['layout'] ? $specificProperties['layout'] : array()); if ($specificProperties['general']) { $properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL] = array_merge($properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL], $specificProperties['general']); } if ($specificProperties['responsive']) { $properties[_LNG_PGM_RESPONSIVE_SETTINGS] = array_merge($properties[_LNG_PGM_RESPONSIVE_SETTINGS], $specificProperties['responsive']); } if ($specificProperties['specific']) { $properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC] = array_merge($properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC], $specificProperties['specific']); } if ($dynamicProperties['specific']) { $properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC] = array_merge($properties[_LNG_PGM_BLOCK_PROPERTIES_SPECIFIC], $dynamicProperties['specific']); } if ($dynamicProperties['responsive']) { $properties[_LNG_PGM_RESPONSIVE_SETTINGS] = array_merge($properties[_LNG_PGM_RESPONSIVE_SETTINGS], $dynamicProperties['responsive']); } if ($specificProperties['style']) { $properties[_LNG_PGM_BLOCK_PROPERTIES_STYLE] = array_merge($properties[_LNG_PGM_BLOCK_PROPERTIES_STYLE], $specificProperties['style']); } if ($blockId) { $dimensions = []; $dimensions[] = ['subject' => 'sis_block_manager', 'key' => 'blockId', 'value' => $blockId]; //unset($properties[_LNG_PGM_RESPONSIVE_SETTINGS]); unset($properties[_LNG_PGM_BLOCK_PROPERTIES_GENERAL]['conditions']); sisRaiseEvent('sis_page_manager', 'VIEW_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Block : $blockId", 'objectId' => $blockId, 'dimensions' => $dimensions)); } else { $dimensions = []; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'wdId', 'value' => $pageWdId]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageDetailId', 'value' => $itemInfo['page_id']]; $dimensions[] = ['subject' => 'sis_page_manager', 'key' => 'pageItemId', 'value' => $itemInfo['bid']]; sisRaiseEvent('sis_page_manager', 'VIEW_PAGE_BLOCK', SIS_EVENT_TYPE_UPDATE, array('objectName' => "Page : $pageWdId", 'objectId' => $pageWdId, 'blockId' => $itemInfo['bid'], 'pageDetailId' => $itemInfo['page_id'], 'dimensions' => $dimensions), 'VIEW_PAGE'); } if (!$itemInfo['responsive_settings']['content']) { $itemInfo['responsive_settings']['content'] = ['size' => ['xs' => 12]]; } sisSetPageTitle(_LNG_PGM_BLOCK_BLOCK . ' : ' . localizedStr($itemInfo['title'])); //div('', ($pageItemId ? 'pgmModalDialog ' : ''). 'pgmBlockPropertiesUI', $blockId ? 'style="height:100%"' : ''); form('frmPgmBlockProperties', callFunctionUrl(_PGM_MAIN_CTP_ID, $pageItemId ? 'savePageItem' : 'saveBlock'), NULL, NULL, NULL, 'ENCTYPE="multipart/form-data" class="sisDataForm" style="height:100%" sisAPSilentSubmit=true'); //div('', $pageItemId ? 'pgmModalContainer' : '', $blockId ? 'style="height:100%"' : ''); hidden('items[bid]', $itemInfo['bid']); hidden('items[portal_id]', $itemInfo['portal_id']); hidden('items[page_id]', $itemInfo['page_id']); if ($itemInfo['bkey'] == 'shareblock') { t($itemOutput); } //hidden('backUrl', sisEncrypt2(sisParam('REQUEST_URI'))); if ($blockId) { hidden('blockType', 'block'); hidden('blockId', $blockId); } else { hidden('blockType', 'pageItem'); hidden('pageItemId', $pageItemId); } if ($pageWdId) { hidden('pageWdId', $pageWdId); hidden('pageItemId', $pageItemId); } div(null, 'pgmTabBlockProperties' . ($adminPageBlock ? ' pgmTabAdminBlockProperties' : '')); sisTabSheet('tbsPgmBlockProperties', null, true); $index = 0; foreach ($properties as $title => $items) { if (!count($items)) { continue; } sisTab('tbPgmBlockPropertyGroup' . $index++, $title); $groups = array(); $otherGroup = array(); $prevGroup = null; foreach ($items as $itemName => $item) { if (is_array($item) && $item['group']) { $groups[$item['group']][$itemName] = $item; $prevGroup = $item['group']; } else { $otherGroup[$itemName] = $item; } } if (count($otherGroup)) { if ($prevGroup) { $groups[$prevGroup] += $otherGroup; } else { $groups[_LNG_PGM_PROP_OTHER_GROUP] = $otherGroup; } } foreach($groups as $groupTitle => $items) { $fieldsetOpen = false; if (count($groups) > 1 || !isset($groups[_LNG_PGM_PROP_OTHER_GROUP])) { fieldset($groupTitle); $fieldsetOpen = true; $messages = array_filter($items, function($item) { if ($item['type'] == 'message') { return true; } return false; }); if (count($messages)) { foreach ($messages as $message) { div(null, 'col-xs-12 pgmMessage'); t($message['content']); div_(); } } } else { $messages = array_filter($items, function($item) { if ($item['type'] == 'message') { return true; } return false; }); if (count($messages)) { foreach ($messages as $message) { div(null, 'col-xs-12 pgmMessage'); t($message['content']); div_(); } } } foreach($items as $itemName => $item) { if ($itemName == '-') { t($item); continue; } if ($item['content'] && !$item['type']) { t($item['content']); continue; } $itemId = $item['id'] ? $item['id'] : $itemName; $propItemName = str_replace(array("__b__", "__d__", "__s__", "__c__"), array(" ", ".", "#", ":"), $itemName); $itemValue = ''; if (strpos($itemId, "content[") === 0 && $itemInfo['content'][$itemName]) { $itemValue = sisVarPrepForDisplay($itemInfo['content'][$itemName]); } else if (strpos($itemId, "responsive_settings[") === 0 && $itemInfo['responsive_settings'][$itemName]) { $itemValue = sisVarPrepForDisplay($itemInfo['responsive_settings'][$itemName]); } else if ($itemInfo[$itemName]) { $itemValue = sisVarPrepForDisplay($itemInfo[$itemName]); } else if ($propertiesValues[$propItemName]) { if (is_array($propertiesValues[$propItemName]['value'])) { $itemValue = $propertiesValues[$propItemName]['value']; } else { $itemValue = sisVarPrepForDisplay($propertiesValues[$propItemName]['value']); } } else if (!isset($propertiesValues[$propItemName])) { $itemValue = sisVarPrepForDisplay($item['value']); } if ($item['type'] == 'message') { continue; } $item['type'] != 'responsive' && sisFormGroup(); if ($item['type'] != 'responsive') { sisCaption(); if ($item['type'] != 'checkbox') { t($item['title']); } sisCaption_(); } $item['type'] != 'responsive' && sisData(array('colSize' => $item['type'] != 'responsive' ? null : 12)); switch ($item['type']) { case 'text': t(""); if ($item['disabled']) { t($itemValue ? sisVarPrepForDisplay($itemValue) : '-'); } if ($item['id'] == 'items[title_link]') { t(_LNG_PGM_PAGE_LINK_TITLE_SAMPLE, 'form_comment'); } break; case 'codeEditor': sisCodeEditor($itemId, $item['width'] ? $item['width'] : '100%', $item['height'] ? $item['height'] : '100px', $item['language']); t(""); sisCodeEditor_(); break; case 'memo': t(""); break; case 'style': sisCodeEditor($itemId, $item['width'] ? $item['width'] : '100%', $item['height'] ? $item['height'] : '100px', 'text', null, null, null, '  ' . _LNG_PGM_BLOCK_PROPERTIES_STYLE_EDITOR . ''); t(""); sisCodeEditor_(); break; case 'template': sisCodeEditor($itemId, $item['width'] ? $item['width'] : '100%', $item['height'] ? $item['height'] : '100px', 'html', null, null, null, '  ' . _LNG_PGM_BLOCK_PROPERTIES_TEMPLATE_EDITOR . ''); t(""); sisCodeEditor_(); t(''); break; case 'combobox': t(""); break; case 'checkbox': t('
    '); break; case 'multiple': t(""); break; case 'radio': foreach($item['items'] as $value => $caption) { $tag = ''; if (is_array($caption)) { $value = $caption['value']; $tag = $caption['tag']; $caption = localizedStr($caption['caption']); } t("
    "); } break; case 'boolean': t('
    '); break; case 'image': $imageExists = false; if (is_file(PORTAL_DATA_PATH . $itemValue)) { $imageExists = true; div(); img(PORTAL_DATA_PATH . $itemValue . '?' . rand(), 'style="max-height: 50px"'); div_(); } t(""); if ($imageExists) { nbsp(2); t(""); nbsp(); t(_LNG_PGM_BLOCK_PROPERTIES_DELETE_IMAGE); } break; case 'responsive': table('100%', '0', 'class="sisDataListTable table-no-bordered" '); thead(); tr(); th(NULL, 'style="text-align:center" colspan=6'); t($item['title']); th_(); tr_(); tr(); th(NULL, 'style="text-align:center"'); t(_LNG_PGM_RESPONSIVE_PAGE_SIZE); th_(); foreach (array('column', 'offset', 'new_row', 'push', 'pull') as $responsiveItem) { th(NULL, 'style="width:19%;text-align:center"'); t(constant('_LNG_PGM_RESPONSIVE_ITEM_' . strtoupper($responsiveItem))); th_(); } tr_(); thead_(); foreach (array('lg', 'md', 'sm', 'xs') as $pageSize) { tr(); td(); switch ($pageSize) { case 'lg': t(' '); break; case 'md': t(' '); break; case 'sm': t(' '); break; case 'xs': t(' '); break; } //t(constant('_LNG_PGM_RESPONSIVE_PAGE_SIZE_' . strtoupper($pageSize))); td_(); if (!$item['responsive_items']) { $item['responsive_items'] = array(0 => 'column', 1 => 'offset', 2 => 'new_row', 3 => 'push', 4 => 'pull'); } foreach ($item['responsive_items'] as $responsiveItem) { switch ($responsiveItem) { case 'column': $value = $itemInfo['responsive_settings'][$item['id']]['size'][$pageSize]; td(); t(''); td_(); break; case 'offset': $value = $itemInfo['responsive_settings'][$item['id']]['offset'][$pageSize]; td(); t(''); td_(); break; case 'new_row': $value = $itemInfo['responsive_settings'][$item['id']]['new_row'][$pageSize]; td(); t(''); td_(); break; case 'pull': $value = $itemInfo['responsive_settings'][$item['id']]['pull'][$pageSize]; td(); t(''); td_(); break; case 'push': $value = $itemInfo['responsive_settings'][$item['id']]['push'][$pageSize]; td(); t(''); td_(); break; } } tr_(); } /*tfoot(); tr(); td(NULL, 'colspan=6'); td_(); tr_(); tfoot_(); */ table_(); if ($item['responsive_adjustment']) { div('','sisDataForm'); sisFormGroup(); sisData(); CheckBox("responsive_settings[". $item['id'] . "][auto_adjustment]", 1, _LNG_PGM_RESPONSIVE_AUTO_ADJUSTMENT, $itemInfo['responsive_settings'][$item['id']]['auto_adjustment'] ? true : false); sisData_(); sisFormGroup_(); div_(); } break; } if ($item['desc']) { br(); t($item['desc'], 'form_comment'); } $item['type'] != 'responsive' && sisData_(); $item['type'] != 'responsive' && sisFormGroup_(); if ($item['customJsCode']) { script(); t($item['customJsCode']); script_(); } } if ($fieldsetOpen) { fieldset_(); } } div(null, null, 'id="divPropertySection' . $propertiesSectionTitle[$title] . '" data-propertySection=1'); div_(); sisTab_(); } sisTabSheet_(); div_(); if (!$adminPageBlock) { div(null, 'pgmTabBlockPreview'); sisTabSheet('tbsPgmBlockPreview', null, true); sisTab('tbPgmBlockPreviewTab', _LNG_PGM_BLOCK_PREVIEW); div(null, 'pgmBlockPreviewContainer'); div(null, 'pgmToolbar'); t(''); t(''); t(''); t('');\ div_(); div(null, 'pgmBlockPreview'); div(null, 'pgmLoading'); t(''); div_(); t('