} } // save META Keywords if (isset($modx->config['show_meta']) && $modx->config['show_meta'] == 1) { saveMETAKeywords($id); } // invoke OnDocFormSave event $header = ''; // Redirect header $params = array(); $params['mode'] = 'upd'; $params['id'] = $id; $modx->invokeEvent('OnDocFormSave', $params); // secure web documents - flag as private include "{$base_path}manager/includes/secure_web_documents.inc.php"; secureWebDocument($id); // secure manager documents - flag as private include "{$base_path}manager/includes/secure_mgr_documents.inc.php"; secureMgrDocument($id); if ($published != $was['published']) { $clearcache['target'] = 'pagecache,sitecache'; } elseif ($was['alias'] !== $field['alias']) { $clearcache['target'] = 'pagecache,sitecache'; } elseif ($was['parent'] != $field['parent']) { $clearcache['target'] = 'pagecache,sitecache'; } else { $clearcache['target'] = 'pagecache'; } if ($syncsite == 1) { $modx->clearCache($clearcache); }
function Run() { // Include MODx manager language file global $_lang; // Get manager language $manager_language = $this->modx->config['manager_language']; // Individual user language setting (if set) $query = 'SELECT setting_name, setting_value FROM ' . $this->modx->getFullTableName('user_settings') . ' WHERE setting_name=\'manager_language\' AND user='******'mgrInternalKey']; $records = $this->modx->db->query($query); if ($this->modx->db->getRecordCount($records) > 0) { $record = $this->modx->db->getRow($records); $manager_language = $record['setting_value']; } // Include_once the language file if (!isset($manager_language) || !file_exists(MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php")) { $manager_language = "english"; // if not set, get the english language file. } // Include default language include_once MODX_MANAGER_PATH . "includes/lang/english.inc.php"; // Include user language if ($manager_language != "english" && file_exists(MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php")) { include_once MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php"; } // Get event $e =& $this->modx->Event; // Run plugin based on event switch ($e->name) { // Save document case 'OnDocFormSave': // Saving process for Qm only if (intval($_REQUEST['quickmanager']) == 1) { $id = $e->params['id']; $key = $id; // Normal saving document procedure stops to redirect => Before redirecting secure documents and clear cache // Secure web documents - flag as private (code from: manager/processors/save_content.processor.php) include $this->modx->config['base_path'] . "manager/includes/secure_web_documents.inc.php"; secureWebDocument($key); // Secure manager documents - flag as private (code from: manager/processors/save_content.processor.php) include $this->modx->config['base_path'] . "manager/includes/secure_mgr_documents.inc.php"; secureMgrDocument($key); // Clear cache $this->clearCache(); // Different doc to be refreshed than the one we are editing? if (isset($_POST['qmrefresh'])) { $id = intval($_POST['qmrefresh']); } // Redirect to clearer page which refreshes parent window and closes modal box frame $this->modx->sendRedirect($this->modx->config['base_url'] . 'index.php?id=' . $id . '&quickmanagerclose=1', 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); } break; // Display page in front-end // Display page in front-end case 'OnWebPagePrerender': // Get document id $docID = $this->modx->documentIdentifier; // Get page output $output =& $this->modx->documentOutput; // Close modal box after saving (previously close.php) if (isset($_GET['quickmanagerclose'])) { // Set url to refresh $url = $this->modx->makeUrl($docID, '', '', 'full'); $output = ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> </head> <body onload="javascript: parent.location.href = \'' . $url . '\';"> </body> </html> '; break; } // QM+ TV edit if (intval($_GET['quickmanagertv'] == 1) && $_GET['tvname'] != '' && $this->tvbuttons == 'true') { $tvName = ''; $locked = FALSE; $access = FALSE; $save = 0; $imagePreview = ''; // Includes $manager_path = 'manager/'; include_once $manager_path . 'includes/tmplvars.inc.php'; include_once $manager_path . 'includes/tmplvars.commands.inc.php'; include_once $manager_path . 'includes/tmplvars.format.inc.php'; // Get save status if (isset($_POST['save'])) { $save = intval($_POST['save']); } // Get TV name if (preg_match('/^([^\\"\'\\(\\)<>!?]+)/i', $_GET['tvname'])) { $tvName = $_GET['tvname']; } // Get TV array $tv = $this->modx->getTemplateVar($tvName, '*', $docID); // Handle default TVs switch ($tvName) { case 'pagetitle': $tv['type'] = 'text'; $tv['caption'] = $this->getDefaultTvCaption($tvName); $access = TRUE; break; case 'longtitle': $tv['type'] = 'text'; $tv['caption'] = $this->getDefaultTvCaption($tvName); $access = TRUE; break; case 'description': $tv['type'] = 'text'; $tv['caption'] = $this->getDefaultTvCaption($tvName); $access = TRUE; break; case 'content': $tv['type'] = 'richtext'; $tv['caption'] = $this->getDefaultTvCaption($tvName); $access = TRUE; break; case 'menutitle': $tv['type'] = 'text'; $tv['caption'] = $this->getDefaultTvCaption($tvName); $access = TRUE; break; case 'introtext': $tv['type'] = 'textarea'; $tv['caption'] = $this->getDefaultTvCaption($tvName); $access = TRUE; break; } // Check TV access if (!$access) { $access = $this->checkTvAccess($tv['id']); } // User can access TV if ($access) { // Show TV form if ($save == 0) { // Check is document locked? Someone else is editing the document... //$_lang['lock_msg'] if ($this->checkLocked()) { $locked = TRUE; } else { $this->setLocked(1); } // Handle RTE if ($tv['type'] == 'richtext') { // Invoke OnRichTextEditorInit event $eventOutput = $this->modx->invokeEvent("OnRichTextEditorInit", array('editor' => $this->modx->config['which_editor'], 'elements' => array('tv' . $tvName))); if (is_array($eventOutput)) { $editorHtml = implode("", $eventOutput); } } // Render TV html $tvHtml = renderFormElement($tv['type'], $tv['name'], $tv['default_text'], $tv['elements'], $tv['value']); // Get jQuery conflict mode if ($this->noconflictjq == 'true') { $jq_mode = '$j'; } else { $jq_mode = '$'; } } else { // Remove document locked $this->setLocked(0); // Save TV $this->saveTv($tvName); } // Page output: header $output = ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title></title> <link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/style.css" /> <!--[if IE]><link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/ie.css" /><![endif]--> <!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/ie7.css" /><![endif]--> <script src="' . $this->modx->config['site_url'] . $this->jqpath . '" type="text/javascript"></script> </head> '; // Page output: TV form if ($save == 0) { $output .= ' <body id="qm-tv-body"> '; // Document is locked message if ($locked) { $output .= ' <h1>' . $_lang['locked'] . '</h1> <div id="qm-tv-description">' . $_lang['lock_msg'] . '</div> '; } else { // Image preview if ($tv['type'] == 'image') { $imagePreview = ' <div id="qm-tv-image-preview"><img class="qm-tv-image-preview-drskip qm-tv-image-preview-skip" src="' . $this->modx->config['site_url'] . $tv['value'] . '" alt="" /></div> <script type="text/javascript" charset="UTF-8"> $(document).ready(function() { var previewImage = "#tv' . $tvName . '"; var siteUrl = "' . $this->modx->config['site_url'] . '"; OriginalSetUrl = SetUrl; // Copy the existing Image browser SetUrl function SetUrl = function(url, width, height, alt) { // Redefine it to also tell the preview to update OriginalSetUrl(url, width, height, alt); $(previewImage).trigger("change"); } $(previewImage).change(function() { $("#qm-tv-image-preview").empty(); if ($(previewImage).val()!="" ){ $("#qm-tv-image-preview").append("<img class=\\"qm-tv-image-preview-drskip qm-tv-image-preview-skip\\" src=\\"" + siteUrl + $(previewImage).val() + "\\" alt=\\"\\" />"); } else{ $("#qm-tv-image-preview").append(""); } }); }); </script> '; } $output .= ' <form id="qm-tv-form" name="mutate" method="post" enctype="multipart/form-data" action="' . $this->modx->config['site_url'] . 'index.php?id=' . $docID . '&quickmanagertv=1&tvname=' . $tvName . '"> <input type="hidden" name="tvid" value="' . $tv['id'] . '" /> <input id="save" type="hidden" name="save" value="1" /> <div id="qm-tv-actions"> <div class="qm-cancel"><a href="#" onclick="parent.' . $jq_mode . '.fn.colorbox.close(); return false;"><span>' . $_lang['cancel'] . '</span></a></div> <div class="qm-save"><a href="#" onclick="document.forms[\'mutate\'].submit(); return false;"><span>' . $_lang['save'] . '</span></a></div> </div> <h1>' . $tv['caption'] . '</h1> <div id="qm-tv-description">' . $tv['description'] . '</div> <div id="qm-tv-tv" class="qm-tv-' . $tv['type'] . '"> ' . $tvHtml . ' </div> ' . $imagePreview . ' </form> ' . $editorHtml . ' '; } } else { $output .= '<body onload="parent.location.reload();">'; } // Page output: footer $output .= ' </body> </html> '; } else { $output = 'Error: Access denied.'; } } else { if (isset($_SESSION['mgrValidated']) && $_REQUEST['z'] != 'manprev') { // If logout break here if (isset($_REQUEST['logout'])) { $this->Logout(); break; } $userID = $_SESSION['mgrInternalKey']; //$docID = $this->modx->documentIdentifier; $doc = $this->modx->getDocument($docID); // Edit button $editButton = ' <li class="qmEdit"> <a class="qmButton qmEdit colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=27&id=' . $docID . '&quickmanager=1"><span> ' . $_lang['edit_resource'] . '</span></a> </li> '; // Check if user has manager access to current document $access = $this->checkAccess(); // Does user have permissions to edit document if ($access) { $controls .= $editButton; } if ($this->addbutton == 'true' && $access) { // Add button $addButton = ' <li class="qmAdd"> <a class="qmButton qmAdd colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=4&pid=' . $docID . '&quickmanager=1"><span>' . $_lang['create_resource_here'] . '</span></a> </li> '; // Does user have permissions to add document if ($this->modx->hasPermission('new_document')) { $controls .= $addButton; } } // Custom add buttons if not empty and enough permissions if ($this->custombutton != '') { // Replace [*id*] with current doc id $this->custombutton = str_replace("[*id*]", $docID, $this->custombutton); // Handle [~id~] links $this->custombutton = $this->modx->rewriteUrls($this->custombutton); $buttons = explode("||", $this->custombutton); // Buttons are divided by "||" // Custom buttons class index $i = 0; // Parse buttons foreach ($buttons as $key => $field) { $i++; $field = substr($field, 1, -1); // Trim "'" from beginning and from end $buttonParams = explode("','", $field); // Button params are divided by "','" $buttonTitle = $buttonParams[0]; $buttonAction = $buttonParams[1]; // Contains URL if this is not add button $buttonParentId = $buttonParams[2]; // Is empty is this is not add button $buttonTplId = $buttonParams[3]; // Button visible for all if ($buttonParams[4] == '') { $showButton = TRUE; } else { $showButton = FALSE; // Get user roles the button is visible for $buttonRoles = explode(",", $buttonParams[4]); // Roles are divided by ',' // Check if user role is found foreach ($buttonRoles as $key => $field) { if ($field == $_SESSION['mgrRole']) { $showButton = TRUE; } } } // Show custom button if ($showButton) { switch ($buttonAction) { case 'new': $customButton = ' <li class="qm-custom-' . $i . ' qmCustom"> <a class="qmButton qmCustom colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=4&pid=' . $buttonParentId . '&quickmanager=1&customaddtplid=' . $buttonTplId . '"><span>' . $buttonTitle . '</span></a> </li> '; break; case 'link': $customButton = ' <li class="qm-custom-' . $i . ' qmCustom"> <a class="qmButton qmCustom" href="' . $buttonParentId . '" ><span>' . $buttonTitle . '</span></a> </li> '; break; case 'modal': $customButton = ' <li class="qm-custom-' . $i . ' qmCustom"> <a class="qmButton qmCustom colorbox" href="' . $buttonParentId . '" ><span>' . $buttonTitle . '</span></a> </li> '; break; } $controls .= $customButton; } } } // Go to Manager button if ($this->managerbutton == 'true') { $managerButton = ' <li class="qmManager"> <a class="qmButton qmManager" title="' . $_lang['manager'] . '" href="' . $this->modx->config['site_url'] . 'manager/" ><span>' . $_lang['manager'] . '</span></a> </li> '; $controls .= $managerButton; } // Logout button $logout = $this->modx->config['site_url'] . 'manager/index.php?a=8&quickmanager=logout&logoutid=' . $docID; $logoutButton = ' <li class="qmLogout"> <a id="qmLogout" class="qmButton qmLogout" title="' . $_lang['logout'] . '" href="' . $logout . '" ><span>' . $_lang['logout'] . '</span></a> </li> '; $controls .= $logoutButton; // Add action buttons $editor = ' <div id="qmEditorClosed"></div> <div id="qmEditor"> <ul> <li id="qmClose"><a class="qmButton qmClose" href="#" onclick="javascript: return false;">X</a></li> <li><a id="qmLogoClose" class="qmClose" href="#" onclick="javascript: return false;"></a></li> ' . $controls . ' </ul> </div>'; $css = ' <link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/style.css" /> <!--[if IE]><link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/ie.css" /><![endif]--> <!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/ie7.css" /><![endif]--> '; // Autohide toolbar? Default: true if ($this->autohide == 'false') { $css .= ' <style type="text/css"> #qmEditor, #qmEditorClosed { top: 0px; } </style> '; } // Insert jQuery and ColorBox in head if needed if ($this->loadfrontendjq == 'true') { $head .= '<script src="' . $this->modx->config['site_url'] . $this->jqpath . '" type="text/javascript"></script>'; } if ($this->loadtb == 'true') { $head .= ' <link type="text/css" media="screen" rel="stylesheet" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/colorbox.css" /> <style type="text/css"> .cboxIE #cboxTopLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderTopLeft.png, sizingMethod=\'scale\');} .cboxIE #cboxTopCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderTopCenter.png, sizingMethod=\'scale\');} .cboxIE #cboxTopRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderTopRight.png, sizingMethod=\'scale\');} .cboxIE #cboxBottomLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderBottomLeft.png, sizingMethod=\'scale\');} .cboxIE #cboxBottomCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderBottomCenter.png, sizingMethod=\'scale\');} .cboxIE #cboxBottomRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderBottomRight.png, sizingMethod=\'scale\');} .cboxIE #cboxMiddleLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderMiddleLeft.png, sizingMethod=\'scale\');} .cboxIE #cboxMiddleRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderMiddleRight.png, sizingMethod=\'scale\');} </style> <script type="text/javascript" src="' . $this->modx->config['site_url'] . 'assets/plugins/qm/js/jquery.colorbox-min.js"></script> '; } // Insert ColorBox jQuery definitions for QuickManager+ $head .= ' <script type="text/javascript"> '; // jQuery in noConflict mode if ($this->noconflictjq == 'true') { $head .= ' var $j = jQuery.noConflict(); $j(document).ready(function($) '; $jvar = 'j'; } else { $head .= '$(document).ready(function($)'; $jvar = ''; } $head .= ' { $' . $jvar . '("a.colorbox").colorbox({width:"' . $this->tbwidth . '", height:"' . $this->tbheight . '", iframe:true, overlayClose:false, opacity:0.5, transition:"fade", speed:150}); // Bindings $' . $jvar . '(document).bind("cbox_open", function(){ $' . $jvar . '("body").css({"overflow":"hidden"}); $' . $jvar . '("html").css({"overflow":"hidden"}); $' . $jvar . '("#qmEditor").css({"display":"none"}); }); $' . $jvar . '(document).bind("cbox_closed", function(){ $' . $jvar . '("body").css({"overflow":"auto"}); $' . $jvar . '("html").css({"overflow":"auto"}); $' . $jvar . '("#qmEditor").css({"display":"block"}); // Remove manager lock by going to home page $' . $jvar . '.ajax({ type: "GET", url: "' . $this->modx->config['site_url'] . 'manager/index.php?a=2" }); }); // Hide QM+ if cookie found if (getCookie("hideQM") == 1) { $' . $jvar . '("#qmEditor").css({"display":"none"}); $' . $jvar . '("#qmEditorClosed").css({"display":"block"}); } // Hide QM+ $' . $jvar . '(".qmClose").click(function () { $' . $jvar . '("#qmEditor").hide("normal"); $' . $jvar . '("#qmEditorClosed").show("normal"); document.cookie = "hideQM=1; path=/;"; }); // Show QM+ $' . $jvar . '("#qmEditorClosed").click(function () { { $' . $jvar . '("#qmEditorClosed").hide("normal"); $' . $jvar . '("#qmEditor").show("normal"); document.cookie = "hideQM=0; path=/;"; } }); }); function getCookie(cookieName) { var results = document.cookie.match ( "(^|;) ?" + cookieName + "=([^;]*)(;|$)" ); if (results) return (unescape(results[2])); else return null; } </script> '; // Insert QM+ css in head $head .= $css; // Place QM+ head information in head, just before </head> tag $output = preg_replace('~(</head>)~i', $head . '\\1', $output); // Insert editor toolbar right after <body> tag $output = preg_replace('~(<body[^>]*>)~i', '\\1' . $editor, $output); // Search and create edit buttons in to the content if ($this->editbuttons == 'true' && $access) { $output = preg_replace('/<!-- ' . $this->editbclass . ' ([0-9]+) \'([^\\"\'\\(\\)<>!?]+)\' -->/', '<span class="' . $this->editbclass . '"><a class="colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=27&id=$1&quickmanager=1&qmrefresh=' . $docID . '"><span>$2</span></a></span>', $output); } // Search and create new document buttons in to the content if ($this->newbuttons == 'true' && $access) { $output = preg_replace('/<!-- ' . $this->newbclass . ' ([0-9]+) ([0-9]+) \'([^\\"\'\\(\\)<>!?]+)\' -->/', '<span class="' . $this->newbclass . '"><a class="colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=4&pid=$1&quickmanager=1&customaddtplid=$2"><span>$3</span></a></span>', $output); } // Search and create new document buttons in to the content if ($this->tvbuttons == 'true' && $access) { // Set and get user doc groups for TV permissions $this->docGroup = ''; $mrgDocGroups = $_SESSION['mgrDocgroups']; if (!empty($mrgDocGroups)) { $this->docGroup = implode(",", $mrgDocGroups); } // Create TV buttons and check TV permissions $output = preg_replace_callback('/<!-- ' . $this->tvbclass . ' ([^\\"\'\\(\\)<>!?]+) -->/', array(&$this, 'createTvButtons'), $output); } } } break; // Edit document in ThickBox frame (MODx manager frame) // Edit document in ThickBox frame (MODx manager frame) case 'OnDocFormPrerender': // If there is Qm call, add control buttons and modify to edit document page if (intval($_REQUEST['quickmanager']) == 1) { global $content; // Set template for new document, action = 4 if (intval($_GET['a']) == 4) { // Custom add button if (isset($_GET['customaddtplid'])) { // Set template $content['template'] = intval($_GET['customaddtplid']); } else { switch ($this->tpltype) { // Template type is parent case 'parent': // Get parent document id $pid = $content['parent'] ? $content['parent'] : intval($_REQUEST['pid']); // Get parent document $parent = $this->modx->getDocument($pid); // Set parent template $content['template'] = $parent['template']; break; // Template is specific id // Template is specific id case 'id': $content['template'] = $this->tplid; break; // Template is inherited by Inherit Selected Template plugin // Template is inherited by Inherit Selected Template plugin case 'selected': // Get parent document id $pid = $content['parent'] ? $content['parent'] : intval($_REQUEST['pid']); // Get inheritTpl TV $tv = $this->modx->getTemplateVar("inheritTpl", "", $pid); // Set template to inherit if ($tv['value'] != '') { $content['template'] = $tv['value']; } else { $content['template'] = $this->modx->config['default_template']; } break; } } } // Manager control class $mc = new Mcc(); // Hide default manager action buttons $mc->addLine('$("#actions").hide();'); // Get MODx theme $qm_theme = $this->modx->config['manager_theme']; // Get doc id $doc_id = intval($_REQUEST['id']); // Get jQuery conflict mode if ($this->noconflictjq == 'true') { $jq_mode = '$j'; } else { $jq_mode = '$'; } // Add action buttons $mc->addLine('var controls = "<div style=\\"padding:4px 0;position:fixed;top:10px;right:-10px;z-index:1000\\" id=\\"qmcontrols\\" class=\\"actionButtons\\"><ul><li><a href=\\"#\\" onclick=\\"documentDirty=false;document.mutate.save.click();return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/save.png\\" />' . $_lang['save'] . '</a></li><li><a href=\\"#\\" onclick=\\"documentDirty=false; parent.' . $jq_mode . '.fn.colorbox.close(); return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/stop.png\\"/>' . $_lang['cancel'] . '</a></li></ul></div>";'); // Modify head $mc->head = '<script type="text/javascript">document.body.style.display="none";</script>'; if ($this->loadmanagerjq == 'true') { $mc->head .= '<script src="' . $this->modx->config['site_url'] . $this->jqpath . '" type="text/javascript"></script>'; } // Add control button $mc->addLine('$("body").prepend(controls);'); // Hide fields to from front-end editors if ($this->hidefields != '') { $hideFields = explode(",", $this->hidefields); foreach ($hideFields as $key => $field) { $mc->hideField($field); } } // Hide tabs to from front-end editors if ($this->hidetabs != '') { $hideTabs = explode(",", $this->hidetabs); foreach ($hideTabs as $key => $field) { $mc->hideTab($field); } } // Hide sections from front-end editors if ($this->hidesections != '') { $hideSections = explode(",", $this->hidesections); foreach ($hideSections as $key => $field) { $mc->hideSection($field); } } // Hidden field to verify that QM+ call exists $hiddenFields = '<input type="hidden" name="quickmanager" value="1" />'; // Different doc to be refreshed? if (isset($_REQUEST['qmrefresh'])) { $hiddenFields .= '<input type="hidden" name="qmrefresh" value="' . intval($_REQUEST['qmrefresh']) . '" />'; } // Output $e->output($mc->Output() . $hiddenFields); } break; // Where to logout // Where to logout case 'OnManagerLogout': // Only if cancel editing the document and QuickManager is in use if ($_REQUEST['quickmanager'] == 'logout') { // Redirect to document id if ($this->logout != 'manager') { $this->modx->sendRedirect($this->modx->makeUrl($_REQUEST['logoutid']), 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); } } break; } }
function Run() { // Include MODx manager language file global $_lang; include_once $this->modx->config['base_path'] . 'manager/includes/lang/' . $this->modx->config['manager_language'] . '.inc.php'; // Get event $e = $this->modx->Event; // Run plugin based on event switch ($e->name) { // Save document case 'OnDocFormSave': // Saving process for Qm only, confirm HTTP_REFERER if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'quickmanager=true') !== false) { $id = $e->params['id']; $key = $id; // Normal saving document procedure stops to redirect => Before redirecting secure documents and clear cache // Secure web documents - flag as private (code from: manager/processors/save_content.processor.php) include $this->modx->config['base_path'] . "manager/includes/secure_web_documents.inc.php"; secureWebDocument($key); // Secure manager documents - flag as private (code from: manager/processors/save_content.processor.php) include $this->modx->config['base_path'] . "manager/includes/secure_mgr_documents.inc.php"; secureMgrDocument($key); // Clear cache include_once $this->modx->config['base_path'] . "manager/processors/cache_sync.class.processor.php"; $sync = new synccache(); $sync->setCachepath($this->modx->config['base_path'] . "assets/cache/"); $sync->setReport(true); $sync->emptyCache(); // Redirect to clearer page which refreshes parent window and closes ColorBox frame $this->modx->sendRedirect($this->modx->config['base_url'] . 'assets/plugins/qm/close.php?id=' . $id . '&baseurl=' . $this->modx->config['base_url'], 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); } break; // Display page in front-end // Display page in front-end case 'OnWebPagePrerender': // If logged in manager but not in manager preview show control buttons if (isset($_SESSION['mgrValidated']) && $_REQUEST['z'] != 'manprev') { $output =& $this->modx->documentOutput; // If logout break here if (isset($_REQUEST['logout'])) { $this->Logout(); break; } $userID = $_SESSION['mgrInternalKey']; $docID = $this->modx->documentIdentifier; $doc = $this->modx->getDocument($docID); // Edit button $editButton = ' <li> <a class="qmButton qmEdit colorbox" title="' . $doc['pagetitle'] . ' » ' . $_lang['edit_document'] . '" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=27&id=' . $docID . '&quickmanager=true">' . $_lang['edit_document'] . '</a> </li>'; // Does user have permissions to edit document if ($this->modx->hasPermission('edit_document')) { $controls .= $editButton; } if ($this->addbutton == 'true') { // Add button $addButton = ' <li> <a class="qmButton qmAdd colorbox" title="' . $doc['pagetitle'] . ' » ' . $_lang['create_document_here'] . '" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=4&pid=' . $docID . '&quickmanager=true">' . $_lang['create_document_here'] . '</a> </li>'; // Does user have permissions to add document if ($this->modx->hasPermission('new_document')) { $controls .= $addButton; } } // Not implemented yet //$delButton = '<a class="button delete" title="'.$doc['pagetitle'].'» '.$_lang['delete_document'].'" href="#" onclick="if(confirm(\'`'.$doc['pagetitle'].'`\n\n'.$_lang['confirm_delete_document'].'\')==true) document.location.href=\''.$this->modx->config['site_url'].'manager/index.php?a=4&id='.$docID.'\';return false;">'.$_lang['delete_document'].'</a>'; //if($this->modx->hasPermission('delete_document')) $controls.=$delButton; // Logout button $logout = $this->modx->config['site_url'] . 'manager/index.php?a=8'; $logoutButton = ' <li> <a class="qmButton qmLogout" title="' . $_lang['logout'] . '" href="' . $logout . '" ><!--img src="' . MODX_BASE_URL . 'assets/plugins/qm/res/exit.png" alt="Edit" /-->' . $_lang['logout'] . '</a> </li>'; $controls .= $logoutButton; $editor = ' <div id="qmEditor" class="actionButtons"> <ul>' . $controls . ' </ul> </div>'; $css = '<link rel="stylesheet" type="text/css" href="assets/plugins/qm/res/style.css" />'; // Insert jQuery and ColorBox in head if needed if ($this->loadfrontendjq == 'true') { $head .= '<script src="' . $this->modx->config['site_url'] . $this->jqpath . '" type="text/javascript"></script>'; } if ($this->loadtb == 'true') { $head .= ' <script type="text/javascript" src="' . $this->modx->config['site_url'] . 'assets/js/jquery.colorbox-min.js"></script> <link type="text/css" media="screen" rel="stylesheet" href="' . $this->modx->config['site_url'] . 'assets/js/colorbox.css" /> <!--[if IE]> <link type="text/css" media="screen" rel="stylesheet" href="' . $this->modx->config['site_url'] . 'assets/js/colorbox-ie.css" title="example" /> <![endif]--> <script type="text/javascript"> var $j = jQuery.noConflict(); $j(document).ready(function($){ $("a.colorbox").colorbox({width:"' . $this->tbwidth . '", height:"' . $this->tbheight . '", iframe:true}); }); function cb_remove(){ $j.fn.colorbox.close(); } </script> '; } // Insert Qm css in head $head .= $css; // Place Qm head information in head, just before </head> tag $output = preg_replace('~(</head>)~i', $head . '\\1', $output); // Insert editor toolbar right after <body> tag $output = preg_replace('~(<body[^>]*>)~i', '\\1' . $editor, $output); } break; // Edit document in ColorBox frame (MODx manager frame) // Edit document in ColorBox frame (MODx manager frame) case 'OnDocFormPrerender': // If there is Qm call, add control buttons and modify to edit document page if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'manager') === false) { global $content; // Set template for new document, action = 4 if ($_GET['a'] == 4) { switch ($this->tpltype) { // Template type is parent case 'parent': // Get parent document id $pid = $content['parent'] ? $content['parent'] : $_REQUEST['pid']; // Get parent document $parent = $this->modx->getDocument($pid); // Set parent template $content['template'] = $parent['template']; break; // Template is specific id // Template is specific id case 'id': $content['template'] = $this->tplid; break; // Template is inherited by Inherit Selected Template plugin // Template is inherited by Inherit Selected Template plugin case 'selected': // Get parent document id $pid = $content['parent'] ? $content['parent'] : $_REQUEST['pid']; // Get inheritTpl TV $tv = $this->modx->getTemplateVar("inheritTpl", "", $pid); // Set template to inherit if ($tv['value'] != '') { $content['template'] = $tv['value']; } else { $content['template'] = $this->modx->config['default_template']; } break; } } // Manager control class $mc = new Mcc($this->jqpath); // Hide subtitle $mc->addLine('$(".subTitle").hide();'); // Use with ManagerManager => remove sectionBody $qm_theme = $this->modx->config['manager_theme']; if ($this->usemm == 'true') { $mc->addLine('var controls = "<div style=\\"position:fixed;top:10px;right:-10px;z-index:1000\\" id=\\"qmcontrols\\" class=\\"actionButtons\\"><ul><li><a href=\\"#\\" onclick=\\"documentDirty=false;document.mutate.save.click();return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/save.png\\"/>' . $_lang['save'] . '</a></li><li><a href=\\"#\\" onclick=\\"documentDirty=false;document.location.href=\'index.php?a=3&id=' . $_REQUEST['id'] . '&quickmanager=cancel\';return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/stop.png\\"/>' . $_lang['cancel'] . '</a></li></ul></div>";'); } else { $mc->addLine('var controls = "<div id=\\"qmcontrols\\" class=\\"sectionBody actionButtons\\"><ul><li><a href=\\"#\\" onclick=\\"documentDirty=false;document.mutate.save.click();return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/save.png\\"/>' . $_lang['save'] . '</a></li><li><a href=\\"#\\" onclick=\\"documentDirty=false;document.location.href=\'index.php?a=3&id=' . $_REQUEST['id'] . '&quickmanager=cancel\';return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/stop.png\\"/>' . $_lang['cancel'] . '</a></li></ul></div>";'); } // Modify head $mc->head = '<script type="text/javascript">document.body.style.display="none";</script>'; if ($this->loadmanagerjq == 'true') { $mc->head .= '<script src="' . $modx->config['site_url'] . ($jqpath = $this->jqpath . '" type="text/javascript"></script>'); } // Add control button $mc->addLine('$("body").prepend(controls);'); //$mc->addLine('$("body").append(controls);'); // Hide fields to from front-end editors, especially template and parent are problematic $hideFields = explode(",", $this->hidefields); foreach ($hideFields as $key => $field) { $mc->hideField($field); } // Hide templates but not active template => Changing template is not possible with Qm+ $sql = "SELECT id FROM " . $this->modx->getFullTableName('site_templates'); $rs = $this->modx->db->query($sql); while ($row = $this->modx->db->getRow($rs)) { if ($content['template'] != $row['id']) { $hideTpls[] = $row['id']; } } $mc->hideTemplates($hideTpls); // Output $e->output($mc->Output()); } break; // Remove edit document locks // Remove edit document locks case 'OnManagerPageInit': // Only if cancel editing the document and QuickManager is in use if ($_REQUEST['quickmanager'] == 'cancel') { // Redirect to clearer page which closes ColorBox frame $this->modx->sendRedirect($this->modx->config['base_url'] . 'assets/plugins/qm/close.php?action=cancel', 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); } break; } }
if (!($rs = $modx->db->query($sql))) { echo "Failed to link document group to user group"; exit; } } else { //alert user that coupling already exists? } break; case "remove_document_group_from_user_group": $updategroupaccess = true; $coupling = intval($_REQUEST['coupling']); $sql = 'DELETE FROM ' . $tbl_webgroup_access . ' WHERE id=' . $coupling; if (!($rs = $modx->db->query($sql))) { echo "Failed to remove document group from user group"; exit; } break; default: echo "No operation set in request."; exit; } // secure web documents - flag as private if ($updategroupaccess == true) { include $base_path . "manager/includes/secure_web_documents.inc.php"; secureWebDocument(); // Update the private group column $sql = 'UPDATE ' . $tbl_documentgroup_names . ' AS dgn ' . 'LEFT JOIN ' . $tbl_webgroup_access . ' AS wga ON wga.documentgroup = dgn.id ' . 'SET dgn.private_webgroup = (wga.webgroup IS NOT NULL)'; $rs = $modx->db->query($sql); } $header = "Location: index.php?a=91"; header($header);
function Run() { // Include MODx manager language file global $_lang; // Get manager language $manager_language = $this->modx->config['manager_language']; // Include_once the language file if (!isset($manager_language) || !file_exists(MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php")) { $manager_language = "english"; // if not set, get the english language file. } // Include default language include_once MODX_MANAGER_PATH . "includes/lang/english.inc.php"; // Include user language if ($manager_language != "english" && file_exists(MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php")) { include_once MODX_MANAGER_PATH . "includes/lang/" . $manager_language . ".inc.php"; } // Get event $e = $this->modx->Event; // Run plugin based on event switch ($e->name) { // Save document case 'OnDocFormSave': // Saving process for Qm only if (intval($_REQUEST['quickmanager']) == 1) { $id = $e->params['id']; $key = $id; // Normal saving document procedure stops to redirect => Before redirecting secure documents and clear cache // Secure web documents - flag as private (code from: manager/processors/save_content.processor.php) include $this->modx->config['base_path'] . "manager/includes/secure_web_documents.inc.php"; secureWebDocument($key); // Secure manager documents - flag as private (code from: manager/processors/save_content.processor.php) include $this->modx->config['base_path'] . "manager/includes/secure_mgr_documents.inc.php"; secureMgrDocument($key); // Clear cache include_once $this->modx->config['base_path'] . "manager/processors/cache_sync.class.processor.php"; $sync = new synccache(); $sync->setCachepath($this->modx->config['base_path'] . "assets/cache/"); $sync->setReport(true); $sync->emptyCache(); // Redirect to clearer page which refreshes parent window and closes modal box frame $this->modx->sendRedirect($this->modx->config['base_url'] . 'assets/plugins/qm/close.php?id=' . $id, 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); } break; // Display page in front-end // Display page in front-end case 'OnWebPagePrerender': // If logged in manager but not in manager preview show control buttons if (isset($_SESSION['mgrValidated']) && $_REQUEST['z'] != 'manprev') { $output =& $this->modx->documentOutput; // If logout break here if (isset($_REQUEST['logout'])) { $this->Logout(); break; } $userID = $_SESSION['mgrInternalKey']; $docID = $this->modx->documentIdentifier; $doc = $this->modx->getDocument($docID); // Edit button $editButton = ' <li> <a class="qmButton qmEdit colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=27&id=' . $docID . '&quickmanager=1"><span> ' . $_lang['edit_resource'] . '</span></a> </li> '; // Check if user has manager access to current document $access = $this->checkAccess(); // Does user have permissions to edit document if ($access) { $controls .= $editButton; } if ($this->addbutton == 'true' && $access) { // Add button $addButton = ' <li> <a class="qmButton colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=4&pid=' . $docID . '&quickmanager=1">' . $_lang['create_resource_here'] . '</a> </li> '; // Does user have permissions to add document if ($this->modx->hasPermission('new_document')) { $controls .= $addButton; } } // Custom add buttons if not empty and enough permissions if ($this->custombutton != '') { $buttons = explode("||", $this->custombutton); // Buttons are divided by "#" // Parse buttons foreach ($buttons as $key => $field) { $field = substr($field, 1, -1); // Trim "'" from beginning and from end $buttonParams = explode("','", $field); // Button params are divided by "','" $buttonTitle = $buttonParams[0]; $buttonAction = $buttonParams[1]; // Contains URL if this is not add button $buttonParentId = $buttonParams[2]; // Is empty is this is not add button $buttonTplId = $buttonParams[3]; // Button visible for all if ($buttonParams[4] == '') { $showButton = TRUE; } else { $showButton = FALSE; // Get user roles the button is visible for $buttonRoles = explode(",", $buttonParams[4]); // Roles are divided by ',' // Check if user role is found foreach ($buttonRoles as $key => $field) { if ($field == $_SESSION['mgrRole']) { $showButton = TRUE; } } } // Show custom button if ($showButton) { switch ($buttonAction) { case 'new': $customButton = ' <li> <a class="qmButton colorbox" href="' . $this->modx->config['site_url'] . 'manager/index.php?a=4&pid=' . $buttonParentId . '&quickmanager=1&customaddtplid=' . $buttonTplId . '">' . $buttonTitle . '</a> </li> '; break; case 'link': $customButton = ' <li> <a class="qmButton" href="' . $buttonParentId . '" >' . $buttonTitle . '</a> </li> '; break; case 'modal': $customButton = ' <li> <a class="qmButton colorbox" href="' . $buttonParentId . '" >' . $buttonTitle . '</a> </li> '; break; } $controls .= $customButton; } } } // Not implemented yet //$delButton = '<a class="button delete" title="'.$doc['pagetitle'].'» '.$_lang['delete_document'].'" href="#" onclick="if(confirm(\'`'.$doc['pagetitle'].'`\n\n'.$_lang['confirm_delete_document'].'\')==true) document.location.href=\''.$this->modx->config['site_url'].'manager/index.php?a=4&id='.$docID.'\';return false;">'.$_lang['delete_document'].'</a>'; //if($this->modx->hasPermission('delete_document')) $controls.=$delButton; // Go to Manager button if ($this->managerbutton == 'true') { $managerButton = ' <li> <a class="qmButton" title="' . $_lang['manager'] . '" href="' . $this->modx->config['site_url'] . 'manager/" >' . $_lang['manager'] . '</a> </li> '; $controls .= $managerButton; } // Logout button $logout = $this->modx->config['site_url'] . 'manager/index.php?a=8&quickmanager=logout&logoutid=' . $docID; $logoutButton = ' <li> <a id="qmLogout" class="qmButton" title="' . $_lang['logout'] . '" href="' . $logout . '" >' . $_lang['logout'] . '</a> </li> '; $controls .= $logoutButton; // Add action buttons $editor = ' <div id="qmEditorClosed"></div> <div id="qmEditor"> <a id="qmClose" class="qmButton qmClose" href="#" onclick="javascript: return false;">X</a> <ul> <li><a id="qmLogoClose" class="qmClose" href="#" onclick="javascript: return false;"></a></li> ' . $controls . ' </ul> </div>'; $css = ' <link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/style.css" /> <!--[if IE]><link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/ie.css" /><![endif]--> <!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/ie7.css" /><![endif]--> '; // Autohide toolbar? Default: true if ($this->autohide == 'false') { $css .= ' <style type="text/css"> #qmEditor, #qmEditorClosed { top: 0px; } </style> '; } // Insert jQuery and ColorBox in head if needed if ($this->loadfrontendjq == 'true') { $head .= '<script src="' . $this->modx->config['site_url'] . $this->jqpath . '" type="text/javascript"></script>'; } if ($this->loadtb == 'true') { $head .= ' <link type="text/css" media="screen" rel="stylesheet" href="' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/colorbox.css" /> <style type="text/css"> .cboxIE #cboxTopLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderTopLeft.png, sizingMethod=\'scale\');} .cboxIE #cboxTopCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderTopCenter.png, sizingMethod=\'scale\');} .cboxIE #cboxTopRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderTopRight.png, sizingMethod=\'scale\');} .cboxIE #cboxBottomLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderBottomLeft.png, sizingMethod=\'scale\');} .cboxIE #cboxBottomCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderBottomCenter.png, sizingMethod=\'scale\');} .cboxIE #cboxBottomRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderBottomRight.png, sizingMethod=\'scale\');} .cboxIE #cboxMiddleLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderMiddleLeft.png, sizingMethod=\'scale\');} .cboxIE #cboxMiddleRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' . $this->modx->config['site_url'] . 'assets/plugins/qm/css/images/internet_explorer/borderMiddleRight.png, sizingMethod=\'scale\');} </style> <script type="text/javascript" src="' . $this->modx->config['site_url'] . 'assets/plugins/qm/js/jquery.colorbox-min.js"></script> '; } // Insert ColorBox jQuery definitions for QuickManager+ $head .= ' <script type="text/javascript"> '; // jQuery in noConflict mode if ($this->noconflictjq == 'true') { $head .= ' var $j = jQuery.noConflict(); $j(document).ready(function($) '; $jvar = 'j'; } else { $head .= '$(document).ready(function($)'; $jvar = ''; } $head .= ' { $("a.colorbox").colorbox({width:"' . $this->tbwidth . '", height:"' . $this->tbheight . '", iframe:true, overlayClose:false}); // Bindings $().bind("cbox_open", function(){ $("body").css({"overflow":"hidden"}); $("html").css({"overflow":"hidden"}); $("#qmEditor").css({"display":"none"}); }); $().bind("cbox_closed", function(){ $("body").css({"overflow":"auto"}); $("html").css({"overflow":"auto"}); $("#qmEditor").css({"display":"block"}); // Remove manager lock by going to home page $' . $jvar . '.ajax({ type: "GET", url: "' . $this->modx->config['site_url'] . 'manager/index.php?a=2" }); }); // Hide QM+ if cookie found if (getCookie("hideQM") == 1) { $("#qmEditor").css({"display":"none"}); $("#qmEditorClosed").css({"display":"block"}); } // Hide QM+ $(".qmClose").click(function () { $("#qmEditor").hide("normal"); $("#qmEditorClosed").show("normal"); document.cookie = "hideQM=1; path=/;"; }); // Show QM+ $("#qmEditorClosed").click(function () { { $("#qmEditorClosed").hide("normal"); $("#qmEditor").show("normal"); document.cookie = "hideQM=0; path=/;"; } }); }); function getCookie(cookieName) { var results = document.cookie.match ( "(^|;) ?" + cookieName + "=([^;]*)(;|$)" ); if (results) return (unescape(results[2])); else return null; } </script> '; // Insert QM+ css in head $head .= $css; // Place Qm head information in head, just before </head> tag $output = preg_replace('~(</head>)~i', $head . '\\1', $output); // Insert editor toolbar right after <body> tag $output = preg_replace('~(<body[^>]*>)~i', '\\1' . $editor, $output); } break; // Edit document in ThickBox frame (MODx manager frame) // Edit document in ThickBox frame (MODx manager frame) case 'OnDocFormPrerender': // If there is Qm call, add control buttons and modify to edit document page if (intval($_REQUEST['quickmanager']) == 1) { global $content; // Set template for new document, action = 4 if (intval($_GET['a']) == 4) { // Custom add button if (isset($_GET['customaddtplid'])) { // Set template $content['template'] = intval($_GET['customaddtplid']); } else { switch ($this->tpltype) { // Template type is parent case 'parent': // Get parent document id $pid = $content['parent'] ? $content['parent'] : intval($_REQUEST['pid']); // Get parent document $parent = $this->modx->getDocument($pid); // Set parent template $content['template'] = $parent['template']; break; // Template is specific id // Template is specific id case 'id': $content['template'] = $this->tplid; break; // Template is inherited by Inherit Selected Template plugin // Template is inherited by Inherit Selected Template plugin case 'selected': // Get parent document id $pid = $content['parent'] ? $content['parent'] : intval($_REQUEST['pid']); // Get inheritTpl TV $tv = $this->modx->getTemplateVar("inheritTpl", "", $pid); // Set template to inherit if ($tv['value'] != '') { $content['template'] = $tv['value']; } else { $content['template'] = $this->modx->config['default_template']; } break; } } } // Manager control class $mc = new Mcc(); // Hide default manager action buttons $mc->addLine('$("#actions").hide();'); // Get MODx theme $qm_theme = $this->modx->config['manager_theme']; // Get doc id $doc_id = intval($_REQUEST['id']); // Get jQuery conflict mode if ($this->noconflictjq == 'true') { $jq_mode = '$j'; } else { $jq_mode = '$'; } // Add action buttons $mc->addLine('var controls = "<div style=\\"padding:4px 0;position:fixed;top:10px;right:-10px;z-index:1000\\" id=\\"qmcontrols\\" class=\\"actionButtons\\"><ul><li><a href=\\"#\\" onclick=\\"setBaseUrl(\'' . $this->modx->config['base_url'] . '\'); documentDirty=false;document.mutate.save.click();return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/save.png\\" />' . $_lang['save'] . '</a></li><li><a href=\\"#\\" onclick=\\"parent.' . $jq_mode . '.fn.colorbox.close(); return false;\\"><img src=\\"media/style/' . $qm_theme . '/images/icons/stop.png\\"/>' . $_lang['cancel'] . '</a></li></ul></div>";'); // Modify head $mc->head = '<script type="text/javascript">document.body.style.display="none";</script>'; if ($this->loadmanagerjq == 'true') { $mc->head .= '<script src="' . $this->modx->config['site_url'] . $this->jqpath . '" type="text/javascript"></script>'; } // Add control button $mc->addLine('$("body").prepend(controls);'); // Hide fields to from front-end editors if ($this->hidefields != '') { $hideFields = explode(",", $this->hidefields); foreach ($hideFields as $key => $field) { $mc->hideField($field); } } // Hide tabs to from front-end editors if ($this->hidetabs != '') { $hideTabs = explode(",", $this->hidetabs); foreach ($hideTabs as $key => $field) { $mc->hideTab($field); } } // Hide sections from front-end editors if ($this->hidesections != '') { $hideSections = explode(",", $this->hidesections); foreach ($hideSections as $key => $field) { $mc->hideSection($field); } } // Set active doc script (needed if alias is changed) $setActiveDoc = ' <script type="text/javascript"> function setBaseUrl(baseUrl) { // Set base url document.cookie = "baseUrlQM=" + baseUrl + "; path=/;"; } </script> '; // Hidden field to verify that QM+ call exists $hiddenField = '<input type="hidden" name="quickmanager" value="1" />'; // Output $e->output($mc->Output() . $setActiveDoc . $hiddenField); } break; // Where to logout // Where to logout case 'OnManagerLogout': // Only if cancel editing the document and QuickManager is in use if ($_REQUEST['quickmanager'] == 'logout') { // Redirect to document id if ($this->logout != 'manager') { $this->modx->sendRedirect($this->modx->makeUrl($_REQUEST['logoutid']), 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); } } break; } }