diff --git a/assets/plugins/qm/qm.inc.php b/assets/plugins/qm/qm.inc.php index 3fff247f90..95150cedb1 100755 --- a/assets/plugins/qm/qm.inc.php +++ b/assets/plugins/qm/qm.inc.php @@ -10,41 +10,69 @@ if(!class_exists('Qm')) { class Qm { - var $modx; + private $modx; //_______________________________________________________ - function __construct(&$modx, $jqpath='', $loadmanagerjq='', $loadfrontendjq='', $noconflictjq='', $loadfa='', $loadtb='', $tbwidth='', $tbheight='', $hidefields='', $hidetabs='', $hidesections='', $addbutton='', $tpltype='', $tplid='', $custombutton='', $managerbutton='', $logout='', $autohide='', $position='', $editbuttons='', $editbclass='', $newbuttons='', $newbclass='', $tvbuttons='', $tvbclass='', $buttonStyle='', $removeBg='') { + function __construct(&$modx, + $jqpath = '', + $loadmanagerjq = '', + $loadfrontendjq = '', + $noconflictjq = '', + $loadfa = '', + $loadtb = '', + $tbwidth = '', + $tbheight = '', + $hidefields = '', + $hidetabs = '', + $hidesections = '', + $addbutton = '', + $tpltype = '', + $tplid = '', + $custombutton = '', + $managerbutton = '', + $logout = '', + $autohide = '', + $position = '', + $editbuttons = '', + $editbclass = '', + $newbuttons = '', + $newbclass = '', + $tvbuttons = '', + $tvbclass = '', + $buttonStyle = '', + $removeBg = '') + { $this->modx = $modx; // Get plugin parameters - $this->jqpath = $jqpath; - $this->loadmanagerjq = $loadmanagerjq; + $this->jqpath = $jqpath; + $this->loadmanagerjq = $loadmanagerjq; $this->loadfrontendjq = $loadfrontendjq; - $this->noconflictjq = $noconflictjq; - $this->loadfa = $loadfa; - $this->loadtb = $loadtb; - $this->tbwidth = $tbwidth; - $this->tbheight = $tbheight; - $this->usemm = null; - $this->hidefields = $hidefields; - $this->hidetabs = $hidetabs; - $this->hidesections = $hidesections; - $this->addbutton = $addbutton; - $this->tpltype = $tpltype; - $this->tplid = $tplid; - $this->custombutton = $custombutton; - $this->managerbutton = $managerbutton; - $this->logout = $logout; - $this->autohide = $autohide; - $this->position = $position; - $this->editbuttons = $editbuttons; - $this->editbclass = $editbclass; - $this->newbuttons = $newbuttons; - $this->newbclass = $newbclass; - $this->tvbuttons = $tvbuttons; - $this->tvbclass = $tvbclass; - $this->buttonStyle = $buttonStyle; - $this->removeBg = $removeBg; + $this->noconflictjq = $noconflictjq; + $this->loadfa = $loadfa; + $this->loadtb = $loadtb; + $this->tbwidth = $tbwidth; + $this->tbheight = $tbheight; + $this->usemm = null; + $this->hidefields = $hidefields; + $this->hidetabs = $hidetabs; + $this->hidesections = $hidesections; + $this->addbutton = $addbutton; + $this->tpltype = $tpltype; + $this->tplid = $tplid; + $this->custombutton = $custombutton; + $this->managerbutton = $managerbutton; + $this->logout = $logout; + $this->autohide = $autohide; + $this->position = $position; + $this->editbuttons = $editbuttons; + $this->editbclass = $editbclass; + $this->newbuttons = $newbuttons; + $this->newbclass = $newbclass; + $this->tvbuttons = $tvbuttons; + $this->tvbclass = $tvbclass; + $this->buttonStyle = $buttonStyle; + $this->removeBg = $removeBg; // Includes include_once($this->modx->config['base_path'].'assets/plugins/qm/mcc.class.php'); @@ -63,7 +91,9 @@ function Run() { $manager_language = $this->modx->config['manager_language']; // Individual user language setting (if set) - if (isset($_SESSION['mgrUsrConfigSet']['manager_language'])) $manager_language = $_SESSION['mgrUsrConfigSet']['manager_language']; + if (isset($_SESSION['mgrUsrConfigSet']['manager_language'])) { + $manager_language = $_SESSION['mgrUsrConfigSet']['manager_language']; + } // Include_once the language file if(!isset($manager_language) || !file_exists(MODX_MANAGER_PATH."includes/lang/".$manager_language.".inc.php")) { @@ -73,7 +103,7 @@ function Run() { 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")) { + 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"; } @@ -87,7 +117,7 @@ function Run() { case 'OnDocFormSave': // Saving process for Qm only - if(intval($_REQUEST['quickmanager']) == 1) { + if((int)$_REQUEST['quickmanager'] == 1) { $id = $e->params['id']; $key = $id; @@ -95,28 +125,25 @@ function Run() { // Normal saving document procedure stops to redirect => Before redirecting secure documents and clear cache // Secure web documents - flag as private (code from: processors/save_content.processor.php) - include $this->modx->config['site_manager_path']."includes/secure_web_documents.inc.php"; - secureWebDocument($key); + include $this->modx->config['site_manager_path']."includes/secure_web_documents.inc.php"; + secureWebDocument($key); // Secure manager documents - flag as private (code from: processors/save_content.processor.php) - include $this->modx->config['site_manager_path']."includes/secure_mgr_documents.inc.php"; - secureMgrDocument($key); + include $this->modx->config['site_manager_path']."includes/secure_mgr_documents.inc.php"; + secureMgrDocument($key); // Clear cache $this->modx->clearCache('full'); // Different doc to be refreshed than the one we are editing? if (isset($_POST['qmrefresh'])) { - $id = intval($_POST['qmrefresh']); + $id = (int)$_POST['qmrefresh']; } // Redirect to clearer page which refreshes parent window and closes modal box frame - if ($this->modx->config['friendly_urls'] == 1){ - $this->modx->sendRedirect($this->modx->makeUrl($id).'?quickmanagerclose=1', 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); - }else{ - $this->modx->sendRedirect($this->modx->makeUrl($id).'&quickmanagerclose=1', 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently'); - } - + $this->modx->sendRedirect( + $this->modx->makeUrl($id,null,'quickmanagerclose=1'), null, 'REDIRECT_JS' + ); } break; @@ -151,7 +178,7 @@ function Run() { } // QM+ TV edit - if(intval($_GET['quickmanagertv'] == 1) && $_GET['tvname'] != '' && $this->tvbuttons == 'true') { + if((int)($_GET['quickmanagertv'] == 1) && $_GET['tvname'] != '' && $this->tvbuttons == 'true') { $tvName = ''; $locked = FALSE; @@ -165,26 +192,40 @@ function Run() { include_once(MODX_MANAGER_PATH.'includes/tmplvars.format.inc.php'); // Get save status - if (isset($_POST['save'])) $save = intval($_POST['save']); + if (isset($_POST['save'])) $save = (int)$_POST['save']; // Get TV name - if (preg_match('/^([^\\"\'\(\)<>!?]+)/i', $_GET['tvname'])) $tvName = $_GET['tvname']; + 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; + case 'longtitle': + case 'description': + case 'menutitle': + case 'pagetitle' : + $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 'introtext' : + $tv['type'] = 'textarea'; + $tv['caption'] = $this->getDefaultTvCaption($tvName); + $access = TRUE; + break; } // Check TV access - if (!$access) { $access = $this->checkTvAccess($tv['id']); } + if (!$access) { + $access = $this->checkTvAccess($tv['id']); + } // User can access TV if ($access) { @@ -193,13 +234,14 @@ function Run() { if ($save == 0) { // Check is document locked? Someone else is editing the document... //$_lang['lock_msg'] - if ($this->checkLocked()) $locked = TRUE; - - // Set document locked - else $this->setLocked(1); + if ($this->checkLocked()) { + $locked = TRUE; + } else { + $this->setLocked(1); + } // Handle RTE - if($tv['type'] == 'richtext') { + if($tv['type'] === 'richtext') { // Invoke OnRichTextEditorInit event $eventOutput = $this->modx->invokeEvent("OnRichTextEditorInit", array('editor'=>$this->modx->config['which_editor'], 'elements'=>array('tv'.$tvName))); @@ -212,12 +254,12 @@ function Run() { $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 = '$'; - } - - // Save TV - else { + if ($this->noconflictjq == 'true') { + $jq_mode = '$j'; + } else { + $jq_mode = '$'; + } + } else { // Remove document locked $this->setLocked(0); @@ -255,7 +297,7 @@ function Run() { // Normal form else { // Image preview - if ($tv['type'] == 'image') { + if ($tv['type'] === 'image') { $imagePreview = '