diff --git a/assets/modules/docmanager/tv.ajax.php b/assets/modules/docmanager/tv.ajax.php
index bf3d2f7dbd..ae6da012e3 100755
--- a/assets/modules/docmanager/tv.ajax.php
+++ b/assets/modules/docmanager/tv.ajax.php
@@ -150,7 +150,7 @@ function renderFormElement($field_type, $field_id, $default_text, $field_element
if (strlen($itemvalue) == 0) {
$itemvalue = $item;
}
- $field_html .= '' . $item . ' ';
+ $field_html .= '' . $item . ' ';
$i++;
}
break;
@@ -183,21 +183,21 @@ function OpenServerBrowser(url, width, height ) {
sOptions += ',top=' + iTop ;
var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
- }
+ }
function BrowseServer(ctrl) {
lastImageCtrl = ctrl;
var w = screen.width * 0.7;
var h = screen.height * 0.7;
OpenServerBrowser('media/browser/{$which_browser}/browser.php?Type=images', w, h);
}
-
+
function BrowseFileServer(ctrl) {
lastFileCtrl = ctrl;
var w = screen.width * 0.7;
var h = screen.height * 0.7;
OpenServerBrowser('media/browser/{$which_browser}/browser.php?Type=files', w, h);
}
-
+
function SetUrl(url, width, height, alt){
if(lastFileCtrl) {
var c = document.templatevariables[lastFileCtrl];
@@ -238,21 +238,21 @@ function OpenServerBrowser(url, width, height ) {
var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
}
-
+
function BrowseServer(ctrl) {
lastImageCtrl = ctrl;
var w = screen.width * 0.7;
var h = screen.height * 0.7;
OpenServerBrowser('media/browser/{$which_browser}/browser.php?Type=images', w, h);
}
-
+
function BrowseFileServer(ctrl) {
lastFileCtrl = ctrl;
var w = screen.width * 0.7;
var h = screen.height * 0.7;
OpenServerBrowser('media/browser/{$which_browser}/browser.php?Type=files', w, h);
}
-
+
function SetUrl(url, width, height, alt){
if(lastFileCtrl) {
var c = document.templatevariables[lastFileCtrl];
diff --git a/assets/plugins/qm/qm.inc.php b/assets/plugins/qm/qm.inc.php
index a82a3175a7..3fff247f90 100755
--- a/assets/plugins/qm/qm.inc.php
+++ b/assets/plugins/qm/qm.inc.php
@@ -1,8 +1,8 @@
modx = $modx;
-
+
// Get plugin parameters
$this->jqpath = $jqpath;
$this->loadmanagerjq = $loadmanagerjq;
@@ -27,8 +27,8 @@ function __construct(&$modx, $jqpath='', $loadmanagerjq='', $loadfrontendjq='',
$this->tbheight = $tbheight;
$this->usemm = null;
$this->hidefields = $hidefields;
- $this->hidetabs = $hidetabs;
- $this->hidesections = $hidesections;
+ $this->hidetabs = $hidetabs;
+ $this->hidesections = $hidesections;
$this->addbutton = $addbutton;
$this->tpltype = $tpltype;
$this->tplid = $tplid;
@@ -45,71 +45,71 @@ function __construct(&$modx, $jqpath='', $loadmanagerjq='', $loadfrontendjq='',
$this->tvbclass = $tvbclass;
$this->buttonStyle = $buttonStyle;
$this->removeBg = $removeBg;
-
+
// Includes
include_once($this->modx->config['base_path'].'assets/plugins/qm/mcc.class.php');
-
+
// Run plugin
$this->Run();
}
-
+
//_______________________________________________________
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)
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")) {
$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: processors/save_content.processor.php)
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);
-
+
// 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']);
}
-
+
// 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');
@@ -118,24 +118,24 @@ function Run() {
}
}
-
+
break;
-
+
// 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 = '
@@ -149,82 +149,82 @@ function Run() {
';
break;
}
-
+
// QM+ TV edit
if(intval($_GET['quickmanagertv'] == 1) && $_GET['tvname'] != '' && $this->tvbuttons == 'true') {
-
+
$tvName = '';
$locked = FALSE;
$access = FALSE;
$save = 0;
$imagePreview = '';
-
+
// Includes
include_once(MODX_MANAGER_PATH.'includes/tmplvars.inc.php');
include_once(MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php');
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 = 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 '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;
-
+
// Set document locked
- else $this->setLocked(1);
-
+ 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)));
-
+
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 = '$';
}
-
+
// Save TV
else {
// Remove document locked
- $this->setLocked(0);
-
+ $this->setLocked(0);
+
// Save TV
$this->saveTv($tvName);
}
-
+
// Page output: header
$output = '
@@ -237,21 +237,21 @@ function Run() {
';
-
+
// Page output: TV form
if ($save == 0) {
- $output .= '
+ $output .= '
';
-
+
// Document is locked message
if ($locked) {
$output .= '
'.$_lang['locked'].'
- '.$_lang['lock_msg'].'
- ';
+ '.$_lang['lock_msg'].'
+ ';
}
-
+
// Normal form
else {
// Image preview
@@ -259,18 +259,18 @@ function Run() {
$imagePreview = '
';
}
$amp = ($this->modx->config['friendly_urls'] == 1) ? '?' : '&';
- $output .= '
+ $output .= '
'.$editorHtml.'
';
}
}
-
+
// Page output: close modal box and refresh parent frame
- else $output .= '';
-
+ else $output .= '';
+
// Page output: footer
$output .= '
- ';
+ ';
}
-
+
else {
- $output = 'Error: Access denied.';
+ $output = 'Error: Access denied.';
}
}
-
+
// QM+ with toolbar
else {
if(isset($_SESSION['mgrValidated']) && $_REQUEST['z'] != 'manprev') {
-
+
// If logout break here
if(isset($_REQUEST['logout'])) {
$this->Logout();
break;
}
-
+
$userID = $_SESSION['mgrInternalKey'];
-
+
// Add ID
$controls .= 'ID: '.$docID.' ';
// Go to Manager button
@@ -352,57 +352,57 @@ function Run() {
$controls .= $managerButton;
}
// Edit button
-
+
$editButton = '
'.$_lang['edit_resource'].'
';
-
+
// Check if user has manager access to current document
$access = $this->checkAccess();
-
- // Does user have permissions to edit document
+
+ // Does user have permissions to edit document
if($access) $controls .= $editButton;
-
- if ($this->addbutton == 'true' && $access) {
+
+ if ($this->addbutton == 'true' && $access) {
// Add button
$addButton = '
'.$_lang['create_resource_here'].'
';
-
+
// Does user have permissions to add document
- if($this->modx->hasPermission('new_document')) $controls .= $addButton;
- }
-
+ if($this->modx->hasPermission('new_document')) $controls .= $addButton;
+ }
+
// Custom add buttons if not empty and enough permissions
- if ($this->custombutton != '') {
-
+ if ($this->custombutton != '') {
+
// Replace [*id*] with current doc id
- $this->custombutton = str_replace("[*id*]", $docID, $this->custombutton);
-
+ $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;
@@ -410,12 +410,12 @@ function Run() {
// Button is visible for specific user roles
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) {
+ foreach($buttonRoles as $key => $field) {
if ($field == $_SESSION['mgrRole']) {
$showButton = TRUE;
}
@@ -433,30 +433,30 @@ function Run() {
';
break;
-
+
case 'link':
$customButton = '
'.$buttonTitle.'
- ';
+ ';
break;
-
+
case 'modal':
$customButton = '
'.$buttonTitle.'
- ';
+ ';
break;
}
- $controls .= $customButton;
- }
- }
- }
-
+ $controls .= $customButton;
+ }
+ }
+ }
+
+
-
// Logout button
$logout = $this->modx->config['site_manager_url'].'index.php?a=8&quickmanager=logout&logoutid='.$docID;
$logoutButton = '
@@ -464,34 +464,34 @@ function Run() {
'.$_lang['logout'].'
';
-
+
$controls .= $logoutButton;
-
+
$username = $_SESSION['mgrShortname'];
// Add action buttons
$editor = '
-
+
-
+
'.$username.'
-
+
'.$controls.'
';
-
+
$MGR_DIR = $this->modx->getManagerPath( );
$css = '
';
-
+
$css .= '
';
-
+
// font-awesome
if ($this->loadfa == 'true') {
$css .= '
@@ -521,10 +521,10 @@ function Run() {
.butttext {display:none}
#qmUser {display:none}
}
- @media only screen
- and (min-device-width: 768px)
- and (max-device-width: 1024px)
- and (orientation: portrait)
+ @media only screen
+ and (min-device-width: 768px)
+ and (max-device-width: 1024px)
+ and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.butttext {display:none}
.butticon {display:inline!important}
@@ -532,7 +532,7 @@ function Run() {
';
}
- else
+ else
// Top toolbar Autohide true
if (($this->autohide == 'true') && ($this->position == 'top')) {
$css .= '
@@ -544,10 +544,10 @@ function Run() {
.butttext {display:none}
#qmUser {display:none}
}
- @media only screen
- and (min-device-width: 768px)
- and (max-device-width: 1024px)
- and (orientation: portrait)
+ @media only screen
+ and (min-device-width: 768px)
+ and (max-device-width: 1024px)
+ and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.butttext {display:none}
.butticon {display:inline!important}
@@ -555,7 +555,7 @@ function Run() {
';
}
- else
+ else
// Top toolbar Relative
if ($this->position == 'before') {
$css .= '
@@ -567,10 +567,10 @@ function Run() {
.butttext {display:none}
#qmUser {display:none}
}
- @media only screen
- and (min-device-width: 768px)
- and (max-device-width: 1024px)
- and (orientation: portrait)
+ @media only screen
+ and (min-device-width: 768px)
+ and (max-device-width: 1024px)
+ and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.butttext {display:none}
.butticon {display:inline!important}
@@ -578,7 +578,7 @@ function Run() {
';
}
- else
+ else
// Bottom toolbar Autohide true
if (($this->autohide == 'true') && ($this->position == 'bottom')) {
$css .= '
@@ -590,10 +590,10 @@ function Run() {
.butttext {display:none}
#qmUser {display:none}
}
- @media only screen
- and (min-device-width: 768px)
- and (max-device-width: 1024px)
- and (orientation: portrait)
+ @media only screen
+ and (min-device-width: 768px)
+ and (max-device-width: 1024px)
+ and (orientation: portrait)
and (-webkit-min-device-pixel-ratio: 1) {
.butttext {display:none}
.butticon {display:inline!important}
@@ -608,15 +608,15 @@ function Run() {
';
}
@@ -714,7 +714,7 @@ function Run() {
if ($this->loadtb == 'true') {
$head .= '
-
+
-
+
';
}
-
+
// Insert ColorBox jQuery definitions for QuickManager+
$head .= '
';
@@ -850,86 +850,86 @@ function updateMODXsession() {
});
";
-
+
// Insert QM+ css in head
$head .= $css;
-
+
// Place QM+ head information in head, just before tag
$output = preg_replace('~()~i', $head . '\1', $output);
-
+
// Insert editor toolbar right after tag
$output = preg_replace('~(]*>)~i', '\1' . $editor, $output);
-
+
// Search and create edit buttons in to the content
if ($this->editbuttons == 'true' && $access) {
$output = preg_replace('//', '$2 ', $output);
}
-
+
// Search and create new document buttons in to the content
if ($this->newbuttons == 'true' && $access) {
$output = preg_replace('//', '$3 ', $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);
+ if (!empty($mrgDocGroups)) $this->docGroup = implode(",", $mrgDocGroups);
// Create TV buttons and check TV permissions
$output = preg_replace_callback('//', array(&$this, 'createTvButtons'), $output);
- }
+ }
}
}
-
+
break;
-
+
// 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, $_style;
-
+
// Set template for new document, action = 4
- if(intval($_GET['a']) == 4) {
-
+ if(intval($_GET['a']) == 4) {
+
// Custom add button
if (isset($_GET['customaddtplid'])) {
// Set template
- $content['template'] = intval($_GET['customaddtplid']);
+ $content['template'] = intval($_GET['customaddtplid']);
}
-
+
// Normal add button
- else {
+ 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
case 'id':
$content['template'] = $this->tplid;
-
+
break;
-
+
// Template is inherited by Inherit Selected Template plugin
case 'selected': // Template is inherited by Inherit Selected Template plugin
case 'sibling':
// Get parent document id
$pid = $content['parent'] ? $content['parent'] : intval($_REQUEST['pid']);
-
+
if ($this->modx->config['auto_template_logic'] === 'sibling') {
// Eoler: template_autologic in Evolution 1.0.5+
// http://tracker.modx.com/issues/9586
@@ -948,7 +948,7 @@ function updateMODXsession() {
// 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'];
@@ -959,74 +959,74 @@ function updateMODXsession() {
// Manager control class
$mc = new Mcc();
-
+
// Hide default manager action buttons
$mc->addLine('$("#actions").hide();');
-
+
// Get doc id
$doc_id = intval($_REQUEST['id']);
-
+
// Different doc to be returned to for cancel?
if (isset($_REQUEST['qmrefresh'])) {
$doc_id = intval($_REQUEST['qmrefresh']);
- }
-
+ }
+
// Get jQuery conflict mode
if ($this->noconflictjq == 'true') $jq_mode = '$j';
else $jq_mode = '$';
-
+
// Add action buttons
$url = $this->modx->makeUrl($doc_id,'','','full');
$mc->addLine('var controls = "";');
-
+
// Modify head
$mc->head = '';
if ($this->loadmanagerjq == 'true') $mc->head .= '';
-
+
// 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);
+ $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);
+ $mc->hideTab($field);
}
}
-
+
// Hide sections from front-end editors
if ($this->hidesections != '') {
$hideSections = explode(",", $this->hidesections);
-
+
foreach($hideSections as $key => $field) {
- $mc->hideSection($field);
+ $mc->hideSection($field);
}
}
-
+
// Hidden field to verify that QM+ call exists
$hiddenFields = ' ';
-
+
// Different doc to be refreshed?
if (isset($_REQUEST['qmrefresh'])) {
$hiddenFields .= ' ';
}
-
+
// Output
$e->output($mc->Output().$hiddenFields);
}
-
+
break;
-
+
// Where to logout
case 'OnManagerLogout':
// Only if cancel editing the document and QuickManager is in use
@@ -1036,54 +1036,54 @@ function updateMODXsession() {
$this->modx->sendRedirect($this->modx->makeUrl($_REQUEST['logoutid']), 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently');
}
}
-
+
break;
}
}
-
- // Check if user has manager access permissions to current document
+
+ // Check if user has manager access permissions to current document
//_______________________________________________________
function checkAccess() {
$access = FALSE;
// If user is admin (role = 1)
if ($_SESSION['mgrRole'] == 1) $access = TRUE;
-
+
else {
$docID = $this->modx->documentIdentifier;
-
+
// Database table
$table= $this->modx->getFullTableName("document_groups");
-
+
// Check if current document is assigned to one or more doc groups
$result = $this->modx->db->select('count(id)', $table, "document='{$docID}'");
$rowCount= $this->modx->db->getValue($result);
-
+
// If document is assigned to one or more doc groups, check access
if ($rowCount >= 1) {
-
+
// Get document groups for current user
$mrgDocGroups = $_SESSION['mgrDocgroups'];
if (!empty($mrgDocGroups)) {
- $docGroup = implode(",", $mrgDocGroups);
-
- // Check if user has access to current document
+ $docGroup = implode(",", $mrgDocGroups);
+
+ // Check if user has access to current document
$result = $this->modx->db->select('count(id)', $table, "document = '{$docID}' AND document_group IN ({$docGroup})");
$rowCount = $this->modx->db->getValue($result);
-
+
if ($rowCount >= 1) $access = TRUE;
}
-
+
else $access = FALSE;
}
-
+
else $access = TRUE;
}
-
+
return $access;
}
-
- // Function from: processors/cache_sync.class.processor.php
+
+ // Function from: processors/cache_sync.class.processor.php
//_____________________________________________________
function getParents($id, $path = '') { // modx:returns child's parent
if(empty($this->aliases)) {
@@ -1098,88 +1098,88 @@ function getParents($id, $path = '') { // modx:returns child's parent
return $this->getParents($this->parents[$id], $path);
}
return $path;
- }
-
+ }
+
// Create TV buttons if user has permissions to TV
//_____________________________________________________
function createTvButtons($matches) {
-
+
$access = FALSE;
$table = $this->modx->getFullTableName('site_tmplvar_access');
$docID = $this->modx->documentIdentifier;
-
+
// Get TV caption for button title
$tv = $this->modx->getTemplateVar($matches[1]);
$caption = $tv['caption'];
-
+
// If caption is empty this must be a "build-in-tv-field" like pagetitle etc.
if ($caption == '') {
-
+
// Allowed for all
- $access = TRUE;
-
+ $access = TRUE;
+
// Resolve caption
$caption = $this->getDefaultTvCaption($matches[1]);
}
-
+
// Check TV access
else {
$access = $this->checkTvAccess($tv['id']);
}
-
+
// Return TV button link if access
if ($access && $caption != '') {
$amp = ($this->modx->config['friendly_urls'] == 1) ? '?' : '&';
return ''.$caption.' ';
- }
+ }
}
-
+
// Check user access to TV
//_____________________________________________________
function checkTvAccess($tvId) {
$access = FALSE;
$table = $this->modx->getFullTableName('site_tmplvar_access');
-
+
// If user is admin (role = 1)
if ($_SESSION['mgrRole'] == 1 && !$access) { $access = TRUE; }
-
- // Check permission to TV, is TV in document group?
+
+ // Check permission to TV, is TV in document group?
if (!$access) {
$result = $this->modx->db->select('count(id)', $table, "tmplvarid = '{$tvId}'");
$rowCount = $this->modx->db->getValue($result);
// TV is not in any document group
- if ($rowCount == 0) { $access = TRUE; }
+ if ($rowCount == 0) { $access = TRUE; }
}
-
- // Check permission to TV, TV is in document group
+
+ // Check permission to TV, TV is in document group
if (!$access && $this->docGroup != '') {
$result = $this->modx->db->select('count(id)', $table, "tmplvarid = '{$tvId}' AND documentgroup IN ({$this->docGroup})");
$rowCount = $this->modx->db->getValue($result);
if ($rowCount >= 1) { $access = TRUE; }
- }
-
+ }
+
return $access;
}
-
+
// Get default TV ("build-in" TVs) captions
//_____________________________________________________
function getDefaultTvCaption($name) {
-
+
global $_lang;
$caption = '';
-
+
switch ($name) {
- case 'pagetitle' : $caption = $_lang['resource_title']; break;
+ case 'pagetitle' : $caption = $_lang['resource_title']; break;
case 'longtitle' : $caption = $_lang['long_title']; break;
case 'description' : $caption = $_lang['resource_description']; break;
case 'content' : $caption = $_lang['resource_content']; break;
case 'menutitle' : $caption = $_lang['resource_opt_menu_title']; break;
case 'introtext' : $caption = $_lang['resource_summary']; break;
}
-
+
return $caption;
}
-
+
// Check that a document isn't locked for editing
//_____________________________________________________
function checkLocked() {
@@ -1193,49 +1193,49 @@ function checkLocked() {
return $locked;
}
-
+
// Set document locked on/off
//_____________________________________________________
function setLocked($locked) {
$pageId = $this->modx->documentIdentifier;
-
+
// Set document locked
if ($locked == 1) {
$this->modx->lockElement(7, $pageId);
}
-
+
// Set document unlocked
else {
- $this->modx->unlockElement(7, $pageId);
+ $this->modx->unlockElement(7, $pageId);
}
}
-
+
// Save TV
//_____________________________________________________
function saveTv($tvName) {
-
+
$tmplvarContentValuesTable = $this->modx->getFullTableName('site_tmplvar_contentvalues');
$siteContentTable = $this->modx->getFullTableName('site_content');
$pageId = $this->modx->documentIdentifier;
$result = null;
$time = time();
- $user = $_SESSION['mgrInternalKey'];
+ $user = $_SESSION['mgrInternalKey'];
$tvId = isset($_POST['tvid']) ? intval($_POST['tvid']) : '';
$tvContent = isset($_POST['tv'.$tvName]) ? $_POST['tv'.$tvName] : '';
$tvContentTemp = '';
-
+
// Escape TV content
$tvContent = $this->modx->db->escape($tvContent);
-
+
// Invoke OnBeforeDocFormSave event
$this->modx->invokeEvent('OnBeforeDocFormSave', array('mode'=>'upd', 'id'=>$pageId));
-
+
// Handle checkboxes and other arrays, TV to be saved must be e.g. value1||value2||value3
if (is_array($tvContent)) {
$tvContent = implode("||", $tvContent);
}
-
+
// Save TV
if ($tvId != '') {
$fields = array(
@@ -1244,27 +1244,27 @@ function saveTv($tvName) {
'value' => $tvContent,
);
$result = $this->modx->db->select('count(id)', $tmplvarContentValuesTable, "tmplvarid = '{$fields['tmplvarid']}' AND contentid = '{$fields['contentid']}'");
-
- // TV exists, update TV
+
+ // TV exists, update TV
if($this->modx->db->getValue($result)) {
$this->modx->db->update($fields, $tmplvarContentValuesTable, "tmplvarid = '{$fields['tmplvarid']}' AND contentid = '{$fields['contentid']}'");
- }
-
- // TV does not exist, create new TV
+ }
+
+ // TV does not exist, create new TV
else {
$this->modx->db->insert($fields, $tmplvarContentValuesTable);
}
-
+
// Page edited by
$this->modx->db->update(
array(
'editedon' => $time,
'editedby' => $user
), $siteContentTable, "id = '{$pageId}'");
- }
-
+ }
+
// Save default field, e.g. pagetitle
- else {
+ else {
$this->modx->db->update(
array(
$tvName => $tvContent,
@@ -1272,13 +1272,13 @@ function saveTv($tvName) {
'editedby' => $user
), $siteContentTable, "id = '{$pageId}'");
}
-
+
// Invoke OnDocFormSave event
$this->modx->invokeEvent('OnDocFormSave', array('mode'=>'upd', 'id'=>$pageId));
-
+
// Clear cache
$this->modx->clearCache('full');
}
-
+
}
}
diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php
index bf8d5b2e73..4c4f33fcd0 100755
--- a/manager/includes/document.parser.class.inc.php
+++ b/manager/includes/document.parser.class.inc.php
@@ -85,16 +85,16 @@ class DocumentParser
/**
* @var array
*/
- public $pluginEvent = array();
+ public $pluginEvent = [];
/**
* @var array
*/
- public $config = array();
+ public $config = [];
/**
* @var array
*/
- public $dbConfig = array();
+ public $dbConfig = [];
public $configGlobal = null; // contains backup of settings overwritten by user-settings
public $rs;
public $result;
@@ -128,7 +128,7 @@ class DocumentParser
*/
public $dumpSnippets = false;
public $snippetsCode;
- public $snippetsTime = array();
+ public $snippetsTime = [];
public $chunkCache;
public $snippetCache;
public $contentTypes;
@@ -136,21 +136,21 @@ class DocumentParser
public $queryCode;
public $virtualDir;
public $placeholders;
- public $sjscripts = array();
- public $jscripts = array();
- public $loadedjscripts = array();
+ public $sjscripts = [];
+ public $jscripts = [];
+ public $loadedjscripts = [];
public $documentMap;
public $forwards = 3;
public $error_reporting = 1;
public $dumpPlugins = false;
public $pluginsCode;
- public $pluginsTime = array();
- public $pluginCache = array();
+ public $pluginsTime = [];
+ public $pluginCache = [];
public $aliasListing;
public $lockedElements = null;
- public $tmpCache = array();
- private $version = array();
- public $extensions = array();
+ public $tmpCache = [];
+ private $version = [];
+ public $extensions = [];
public $cacheKey = null;
public $recentUpdate = 0;
public $useConditional = false;
@@ -316,61 +316,65 @@ public function getMicroTime()
* Redirect
*
* @param string $url
- * @param int $count_attempts
- * @param string $type $type
+ * @param bool $count_attempts
+ * @param string $type
* @param string $responseCode
- * @return bool|null
- * @global string $base_url
- * @global string $site_url
+ * @return bool
*/
- public function sendRedirect($url, $count_attempts = 0, $type = '', $responseCode = '')
+ public function sendRedirect($url, $count_attempts = false, $type = 'REDIRECT_HEADER', $responseCode = null)
{
- $header = '';
if (empty ($url)) {
return false;
}
- if ($count_attempts == 1) {
+ if ($count_attempts) {
// append the redirect count string to the url
- $currentNumberOfRedirects = isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0;
+ $currentNumberOfRedirects = $_GET['err'] ?? 0;
if ($currentNumberOfRedirects > 3) {
- $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. Redirection URL: ' . $url . '
');
- } else {
- $currentNumberOfRedirects += 1;
- if (strpos($url, "?") > 0) {
- $url .= "&err=$currentNumberOfRedirects";
- } else {
- $url .= "?err=$currentNumberOfRedirects";
- }
+ $this->messageQuit(
+ "Redirection attempt failed - please ensure the document you're trying to redirect to exist. Redirection URL: " . $url . '
'
+ );
+ exit;
}
+ $url .= sprintf(
+ '%serr=%s',
+ strpos($url, '?') > 0 ? '?' : '&',
+ ($currentNumberOfRedirects + 1)
+ );
}
- if ($type == 'REDIRECT_REFRESH') {
- $header = 'Refresh: 0;URL=' . $url;
- } elseif ($type == 'REDIRECT_META') {
- $header = ' ';
- echo $header;
+ if ($type === 'REDIRECT_REFRESH') {
+ header('Refresh: 0;URL=' . $url);
exit;
- } elseif ($type == 'REDIRECT_HEADER' || empty ($type)) {
- // check if url has /$base_url
- global $base_url, $site_url;
- if (substr($url, 0, strlen($base_url)) == $base_url) {
- // append $site_url to make it work with Location:
- $url = $site_url . substr($url, strlen($base_url));
- }
- if (strpos($url, "\n") === false) {
- $header = 'Location: ' . $url;
- } else {
- $this->messageQuit('No newline allowed in redirect url.');
- }
}
+
+ if ($type === 'REDIRECT_META') {
+ echo ' ';
+ exit;
+ }
+
+ if ($type === 'REDIRECT_JS') {
+ echo sprintf("", $url);
+ exit;
+ }
+
+ if ($type !== 'REDIRECT_HEADER') {
+ return true;
+ }
+
if ($responseCode && (strpos($responseCode, '30') !== false)) {
header($responseCode);
}
- if(!empty($header)) {
- header($header);
+ if (strpos($url, "\n") !== false) {
+ $this->messageQuit('No newline allowed in redirect url.');
+ exit;
}
-
- exit();
+ if (strpos($url, MODX_BASE_URL) === 0) {
+ $url = MODX_SITE_URL . substr($url, strlen(MODX_BASE_URL));
+ }
+ if ($responseCode && (strpos($responseCode, '30') !== false)) {
+ header('Location: ' . $url);
+ }
+ exit;
}
/**
@@ -549,7 +553,7 @@ public function getUserSettings()
$tbl_user_settings = $this->getFullTableName('user_settings');
// load user setting if user is logged in
- $usrSettings = array();
+ $usrSettings = [];
if ($id = $this->getLoginUserID()) {
$usrType = $this->getLoginUserType();
if (isset ($usrType) && $usrType == 'manager') {
@@ -587,7 +591,7 @@ public function getUserSettings()
}
}
if ($this->isFrontend() && $mgrid = $this->getLoginUserID('mgr')) {
- $musrSettings = array();
+ $musrSettings = [];
if (isset ($_SESSION['mgrUsrConfigSet'])) {
$musrSettings = &$_SESSION['mgrUsrConfigSet'];
} else {
@@ -796,7 +800,7 @@ public function getHashFile($key)
public function makePageCacheKey($id){
$hash = $id;
$tmp = null;
- $params = array();
+ $params = [];
if(!empty($this->systemCacheKey)){
$hash = $this->systemCacheKey;
}else {
@@ -1065,7 +1069,7 @@ public function RecoveryEscapedTags($contents)
public function getTagsForEscape($tags = '{{,}},[[,]],[!,!],[*,*],[(,)],[+,+],[~,~],[^,^]')
{
$srcTags = explode(',', $tags);
- $repTags = array();
+ $repTags = [];
foreach ($srcTags as $tag) {
$repTags[] = '\\' . $tag[0] . '\\' . $tag[1];
}
@@ -1078,7 +1082,7 @@ public function getTagsForEscape($tags = '{{,}},[[,]],[!,!],[*,*],[(,)],[+,+],[~
*/
public function getTimerStats($tstart)
{
- $stats = array();
+ $stats = [];
$stats['totalTime'] = ($this->getMicroTime() - $tstart);
$stats['queryTime'] = $this->queryTime;
@@ -1214,9 +1218,9 @@ public function getTagsFromContent($content, $left = '[+', $right = '+]')
{
$_ = $this->_getTagsFromContent($content, $left, $right);
if (empty($_)) {
- return array();
+ return [];
}
- $tags = array();
+ $tags = [];
foreach ($_ as $v) {
$tags[0][] = "{$left}{$v}{$right}";
$tags[1][] = $v;
@@ -1233,7 +1237,7 @@ public function getTagsFromContent($content, $left = '[+', $right = '+]')
public function _getTagsFromContent($content, $left = '[+', $right = '+]')
{
if (strpos($content, $left) === false) {
- return array();
+ return [];
}
$spacer = md5('<<>>');
if($left==='{{' && strpos($content,';}}')!==false) $content = str_replace(';}}', sprintf(';}%s}', $spacer),$content);
@@ -1249,7 +1253,7 @@ public function _getTagsFromContent($content, $left = '[+', $right = '+]')
}
$lp = explode($left, $content);
- $piece = array();
+ $piece = [];
foreach ($lp as $lc => $lv) {
if ($lc !== 0) {
$piece[] = $left;
@@ -1269,7 +1273,7 @@ public function _getTagsFromContent($content, $left = '[+', $right = '+]')
$lc = 0;
$rc = 0;
$fetch = '';
- $tags = array();
+ $tags = [];
foreach ($piece as $v) {
if ($v === $left) {
if (0 < $lc) {
@@ -2166,7 +2170,7 @@ private function _get_snip_result($piece)
public function getParamsFromString($string = '')
{
if (empty($string)) {
- return array();
+ return [];
}
if (strpos($string, '&_PHX_INTERNAL_') !== false) {
@@ -2181,7 +2185,7 @@ public function getParamsFromString($string = '')
$_tmp = $string;
$_tmp = ltrim($_tmp, '?&');
- $temp_params = array();
+ $temp_params = [];
$key = '';
$value = null;
while ($_tmp !== '') {
@@ -2480,7 +2484,7 @@ public function rewriteUrls($documentSource)
{
// rewrite the urls
if ($this->config['friendly_urls'] == 1) {
- $aliases = array();
+ $aliases = [];
if (is_array($this->documentListing)) {
foreach ($this->documentListing as $path => $docid) { // This is big Loop on large site!
$aliases[$docid] = $path;
@@ -2690,7 +2694,7 @@ public function getDocumentObject($method, $identifier, $isPrepareResponse = fal
$rs = $this->db->select("tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value", $this->getFullTableName("site_tmplvars") . " tv
INNER JOIN " . $this->getFullTableName("site_tmplvar_templates") . " tvtpl ON tvtpl.tmplvarid = tv.id
LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues") . " tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '{$documentObject['id']}'", "tvtpl.templateid = '{$documentObject['template']}'");
- $tmplvars = array();
+ $tmplvars = [];
while ($row = $this->db->getRow($rs)) {
$tmplvars[$row['name']] = array(
$row['name'],
@@ -3084,7 +3088,7 @@ public function _getTemplateCodeFromDB($templateID)
*/
public function getParentIds($id, $height = 10)
{
- $parents = array();
+ $parents = [];
while ($id && $height--) {
$thisid = $id;
if ($this->config['aliaslistingfolder'] == 1 || (isset($this->config['full_aliaslisting']) && $this->config['full_aliaslisting'] == 1)) {
@@ -3129,7 +3133,7 @@ public function getUltimateParentId($id, $top = 0)
* @param array $children Optional array of docids to merge with the result.
* @return array Contains the document Listing (tree) like the sitemap
*/
- public function getChildIds($id, $depth = 10, $children = array())
+ public function getChildIds($id, $depth = 10, $children = [])
{
$cacheKey = md5(print_r(func_get_args(), true));
@@ -3140,7 +3144,7 @@ public function getChildIds($id, $depth = 10, $children = array())
if ($this->config['aliaslistingfolder'] == 1 || (isset($this->config['full_aliaslisting']) && $this->config['full_aliaslisting'] == 1)) {
$res = $this->db->select("id,alias,isfolder,parent", $this->getFullTableName('site_content'), "parent IN (" . $id . ") AND deleted = '0'");
- $idx = array();
+ $idx = [];
while ($row = $this->db->getRow($res)) {
$pAlias = '';
if (isset($this->aliasListing[$row['parent']])) {
@@ -3165,7 +3169,7 @@ public function getChildIds($id, $depth = 10, $children = array())
} else {
// Initialise a static array to index parents->children
- static $documentMap_cache = array();
+ static $documentMap_cache = [];
if (!count($documentMap_cache)) {
foreach ($this->documentMap as $document) {
foreach ($document as $p => $c) {
@@ -3329,7 +3333,7 @@ public function getLockedElements($type = 0, $minimumDetails = false)
$lockedElements = $this->lockedElements;
} else {
// Minimum details for HTML / Ajax-requests
- $lockedElements = array();
+ $lockedElements = [];
foreach ($this->lockedElements as $elType => $elements) {
foreach ($elements as $elId => $el) {
$lockedElements[$elType][$elId] = array(
@@ -3349,7 +3353,7 @@ public function getLockedElements($type = 0, $minimumDetails = false)
if (isset($lockedElements[$type])) {
return $lockedElements[$type];
} else {
- return array();
+ return [];
}
}
@@ -3359,7 +3363,7 @@ public function getLockedElements($type = 0, $minimumDetails = false)
public function buildLockedElementsCache()
{
if (is_null($this->lockedElements)) {
- $this->lockedElements = array();
+ $this->lockedElements = [];
$this->cleanupExpiredLocks();
$rs = $this->db->select('sid,internalKey,elementType,elementId,lasthit,username', $this->getFullTableName('active_user_locks') . " ul
@@ -3394,7 +3398,7 @@ public function cleanupExpiredLocks()
$count = $this->db->getRecordCount($rs);
if ($count) {
$rs = $this->db->makeArray($rs);
- $userSids = array();
+ $userSids = [];
foreach ($rs as $row) {
$userSids[] = $row['sid'];
}
@@ -3414,7 +3418,7 @@ public function cleanupMultipleActiveUsers()
$timeout = 20 * 60; // Delete multiple user-sessions after 20min
$validSessionTimeLimit = $this->time - $timeout;
- $activeUserSids = array();
+ $activeUserSids = [];
$rs = $this->db->select('sid', $this->getFullTableName('active_user_sessions'));
$count = $this->db->getRecordCount($rs);
if ($count) {
@@ -3427,7 +3431,7 @@ public function cleanupMultipleActiveUsers()
$rs = $this->db->select("sid,internalKey,lasthit", "{$this->getFullTableName('active_users')}", "", "lasthit DESC");
if ($this->db->getRecordCount($rs)) {
$rs = $this->db->makeArray($rs);
- $internalKeyCount = array();
+ $internalKeyCount = [];
$deleteSids = '';
foreach ($rs as $row) {
if (!isset($internalKeyCount[$row['internalKey']])) {
@@ -3619,7 +3623,7 @@ public function logEvent($evtid, $type, $msg, $source = 'Parser')
* @param array $files
* @return mixed
*/
- public function sendmail($params = array(), $msg = '', $files = array())
+ public function sendmail($params = [], $msg = '', $files = [])
{
if (isset($params) && is_string($params)) {
if (strpos($params, '=') === false) {
@@ -3693,7 +3697,7 @@ public function sendmail($params = array(), $msg = '', $files = array())
$this->mail->IsHTML(false);
}
if (!is_array($files)) {
- $files = array();
+ $files = [];
}
foreach ($files as $f) {
if (file_exists(MODX_BASE_PATH . $f) && is_file(MODX_BASE_PATH . $f) && is_readable(MODX_BASE_PATH . $f)) {
@@ -3895,7 +3899,7 @@ public function getDocumentChildren($parentid = 0, $published = 1, $deleted = 0,
*
* @return {array; false} - Result array with documents, or false.
*/
- public function getDocuments($ids = array(), $published = 1, $deleted = 0, $fields = '*', $where = '', $sort = 'menuindex', $dir = 'ASC', $limit = '')
+ public function getDocuments($ids = [], $published = 1, $deleted = 0, $fields = '*', $where = '', $sort = 'menuindex', $dir = 'ASC', $limit = '')
{
$cacheKey = md5(print_r(func_get_args(), true));
@@ -4331,11 +4335,11 @@ public function getConfig($name = '')
public function getVersionData($data = null)
{
- $out = array();
+ $out = [];
if (empty($this->version) || !is_array($this->version)) {
//include for compatibility modx version < 1.0.10
include MODX_MANAGER_PATH . "includes/version.inc.php";
- $this->version = array();
+ $this->version = [];
$this->version['version'] = isset($modx_version) ? $modx_version : '';
$this->version['branch'] = isset($modx_branch) ? $modx_branch : '';
$this->version['release_date'] = isset($modx_release_date) ? $modx_release_date : '';
@@ -4352,7 +4356,7 @@ public function getVersionData($data = null)
* @param array $params Default: Empty array
* @return string
*/
- public function runSnippet($snippetName, $params = array())
+ public function runSnippet($snippetName, $params = [])
{
if (isset ($this->snippetCache[$snippetName])) {
$snippet = $this->snippetCache[$snippetName];
@@ -4427,7 +4431,7 @@ public function getChunk($chunkName)
* @internal param $suffix {string} - Placeholders suffix. Default: '+]'. - Placeholders suffix. Default: '+]'.
*
*/
- public function parseText($tpl = '', $ph = array(), $left = '[+', $right = '+]', $execModifier = true)
+ public function parseText($tpl = '', $ph = [], $left = '[+', $right = '+]', $execModifier = true)
{
if (empty($ph) || empty($tpl)) {
return $tpl;
@@ -4671,13 +4675,13 @@ public function toTimeStamp($str)
* Default: ASC
* @return array|bool
*/
- public function getDocumentChildrenTVars($parentid = 0, $tvidnames = array(), $published = 1, $docsort = "menuindex", $docsortdir = "ASC", $tvfields = "*", $tvsort = "rank", $tvsortdir = "ASC")
+ public function getDocumentChildrenTVars($parentid = 0, $tvidnames = [], $published = 1, $docsort = "menuindex", $docsortdir = "ASC", $tvfields = "*", $tvsort = "rank", $tvsortdir = "ASC")
{
$docs = $this->getDocumentChildren($parentid, $published, 0, '*', '', $docsort, $docsortdir);
if (!$docs) {
return false;
} else {
- $result = array();
+ $result = [];
// get user defined template variables
if ($tvfields) {
$_ = array_filter(array_map('trim', explode(',', $tvfields)));
@@ -4737,7 +4741,7 @@ public function getDocumentChildrenTVars($parentid = 0, $tvidnames = array(), $p
* @param int $parentid {integer}
* - Id of parent document. Default: 0 (site root).
* @param array $tvidnames {array; '*'}
- * - Which TVs to fetch. In the form expected by getTemplateVarOutput(). Default: array().
+ * - Which TVs to fetch. In the form expected by getTemplateVarOutput(). Default: [].
* @param int $published {0; 1; 'all'}
* - Document publication status. Once the parameter equals 'all', the result will be returned regardless of whether the ducuments are published or they are not. Default: 1.
* @param string $sortBy {string}
@@ -4751,14 +4755,14 @@ public function getDocumentChildrenTVars($parentid = 0, $tvidnames = array(), $p
* @return array {array; false} - Result array, or false.
* - Result array, or false.
*/
- public function getDocumentChildrenTVarOutput($parentid = 0, $tvidnames = array(), $published = 1, $sortBy = 'menuindex', $sortDir = 'ASC', $where = '', $resultKey = 'id')
+ public function getDocumentChildrenTVarOutput($parentid = 0, $tvidnames = [], $published = 1, $sortBy = 'menuindex', $sortDir = 'ASC', $where = '', $resultKey = 'id')
{
$docs = $this->getDocumentChildren($parentid, $published, 0, 'id', $where, $sortBy, $sortDir);
if (!$docs) {
return false;
} else {
- $result = array();
+ $result = [];
$unsetResultKey = false;
@@ -4836,7 +4840,7 @@ public function getTemplateVar($idname = "", $fields = "*", $docid = "", $publis
*
* @return array|bool Result array, or false.
*/
- public function getTemplateVars($idnames = array(), $fields = '*', $docid = '', $published = 1, $sort = 'rank', $dir = 'ASC')
+ public function getTemplateVars($idnames = [], $fields = '*', $docid = '', $published = 1, $sort = 'rank', $dir = 'ASC')
{
$cacheKey = md5(print_r(func_get_args(), true));
if (isset($this->tmpCache[__FUNCTION__][$cacheKey])) {
@@ -4927,12 +4931,12 @@ public function getTemplateVars($idnames = array(), $fields = '*', $docid = '',
* @return array {array; false} - Result array, or false.
* - Result array, or false.
*/
- public function getTemplateVarOutput($idnames = array(), $docid = '', $published = 1, $sep = '')
+ public function getTemplateVarOutput($idnames = [], $docid = '', $published = 1, $sep = '')
{
if (is_array($idnames) && empty($idnames) ) {
return false;
} else {
- $output = array();
+ $output = [];
$vars = ($idnames == '*' || is_array($idnames)) ? $idnames : array($idnames);
$docid = (int)$docid > 0 ? (int)$docid : $this->documentIdentifier;
@@ -5237,7 +5241,7 @@ public function getUserDocGroups($resolveIds = false)
return $dgn;
} else if (is_array($dg)) {
// resolve ids to names
- $dgn = array();
+ $dgn = [];
$ds = $this->db->select('name', $this->getFullTableName("documentgroup_names"), "id IN (" . implode(",", $dg) . ")");
while ($row = $this->db->getRow($ds)) {
$dgn[] = $row['name'];
@@ -5299,7 +5303,7 @@ public function changeWebUserPassword($oldPwd, $newPwd)
* @param array $groupNames
* @return boolean
*/
- public function isMemberOfWebGroup($groupNames = array())
+ public function isMemberOfWebGroup($groupNames = [])
{
if (!is_array($groupNames)) {
return false;
@@ -5377,7 +5381,7 @@ public function regClientScript($src, $options = array('name' => '', 'version' =
{
$options = array('name' => $options);
} else {
- $options = array();
+ $options = [];
}
}
$name = isset($options['name']) ? strtolower($options['name']) : '';
@@ -5487,7 +5491,7 @@ public function addEventListener($evtName, $pluginName)
return false;
}
if (!array_key_exists($evtName, $this->pluginEvent)) {
- $this->pluginEvent[$evtName] = array();
+ $this->pluginEvent[$evtName] = [];
}
return array_push($this->pluginEvent[$evtName], $pluginName); // return array count
}
@@ -5512,7 +5516,7 @@ public function removeEventListener($evtName)
public function removeAllEventListener()
{
unset ($this->pluginEvent);
- $this->pluginEvent = array();
+ $this->pluginEvent = [];
}
/**
@@ -5522,7 +5526,7 @@ public function removeAllEventListener()
* @param array $extParams Parameters available to plugins. Each array key will be the PHP variable name, and the array value will be the variable value.
* @return boolean|array
*/
- public function invokeEvent($evtName, $extParams = array())
+ public function invokeEvent($evtName, $extParams = [])
{
if (!$evtName) {
return false;
@@ -5557,7 +5561,7 @@ public function invokeEvent($evtName, $extParams = array())
// load default params/properties
$parameter = $this->parseProperties($pluginProperties);
if (!is_array($parameter)) {
- $parameter = array();
+ $parameter = [];
}
if (!empty($extParams)) {
$parameter = array_merge($parameter, $extParams);
@@ -5608,7 +5612,7 @@ public function invokeEvent($evtName, $extParams = array())
*/
public function getPluginCode($pluginName)
{
- $plugin = array();
+ $plugin = [];
if (isset ($this->pluginCache[$pluginName])) {
$pluginCode = $this->pluginCache[$pluginName];
$pluginProperties = isset($this->pluginCache[$pluginName . "Props"]) ? $this->pluginCache[$pluginName . "Props"] : '';
@@ -5642,7 +5646,7 @@ public function parseProperties($propertyString, $elementName = null, $elementTy
$propertyString = trim($propertyString);
$propertyString = str_replace('{}', '', $propertyString);
$propertyString = str_replace('} {', ',', $propertyString);
- $property = array();
+ $property = [];
if (!empty($propertyString) && $propertyString != '{}') {
$jsonFormat = $this->isJson($propertyString, true);
// old format
@@ -5719,7 +5723,7 @@ public function parseProperties($propertyString, $elementName = null, $elementTy
*/
public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = false)
{
- $params = array();
+ $params = [];
$fullpath = $element_dir . '/' . $filename;
if (is_readable($fullpath)) {
$tpl = @fopen($fullpath, "r");
@@ -5749,7 +5753,7 @@ public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = f
if (!empty($param)) {
if (in_array($param, $arrayParams)) {
if (!isset($params[$param])) {
- $params[$param] = array();
+ $params[$param] = [];
}
$params[$param][] = $escapeValues ? $this->db->escape($val) : $val;
} else {
@@ -5772,7 +5776,7 @@ public function parseDocBlockFromFile($element_dir, $filename, $escapeValues = f
*/
public function parseDocBlockFromString($string, $escapeValues = false)
{
- $params = array();
+ $params = [];
if (!empty($string)) {
$string = str_replace('\r\n', '\n', $string);
$exp = explode('\n', $string);
@@ -5799,7 +5803,7 @@ public function parseDocBlockFromString($string, $escapeValues = false)
if (!empty($param)) {
if (in_array($param, $arrayParams)) {
if (!isset($params[$param])) {
- $params[$param] = array();
+ $params[$param] = [];
}
$params[$param][] = $escapeValues ? $this->db->escape($val) : $val;
} else {
@@ -6078,7 +6082,7 @@ public function safeEval($phpcode = '', $evalmode = '', $safe_functions = '')
$echo = ob_get_clean();
if (is_array($return)) {
- return 'array()';
+ return '[]';
}
$output = $echo . $return;
@@ -6302,7 +6306,7 @@ public function messageQuit($msg = 'unspecified error', $query = '', $is_error =
$MakeTable->setRowAlternateClass('gridAltItem');
$MakeTable->setColumnWidths(array('100px'));
- $table = array();
+ $table = [];
$version = isset ($GLOBALS['modx_version']) ? $GLOBALS['modx_version'] : '';
$release_date = isset ($GLOBALS['release_date']) ? $GLOBALS['release_date'] : '';
@@ -6376,7 +6380,7 @@ public function messageQuit($msg = 'unspecified error', $query = '', $is_error =
$str .= $MakeTable->create($table, array('Error information', ''));
$str .= " ";
- $table = array();
+ $table = [];
$table[] = array('REQUEST_URI', $request_uri);
if ($this->manager->action) {
@@ -6399,7 +6403,7 @@ public function messageQuit($msg = 'unspecified error', $query = '', $is_error =
$str .= $MakeTable->create($table, array('Basic info', ''));
$str .= " ";
- $table = array();
+ $table = [];
$table[] = array('MySQL', '[^qt^] ([^q^] Requests)');
$table[] = array('PHP', '[^p^]');
$table[] = array('Total', '[^t^]');
@@ -6503,7 +6507,7 @@ public function get_backtrace($backtrace)
$MakeTable->setTableClass('grid');
$MakeTable->setRowRegularClass('gridItem');
$MakeTable->setRowAlternateClass('gridAltItem');
- $table = array();
+ $table = [];
$backtrace = array_reverse($backtrace);
foreach ($backtrace as $key => $val) {
$key++;
@@ -6526,7 +6530,7 @@ public function get_backtrace($backtrace)
}
$tmp = 1;
$_ = (!empty($val['args'])) ? count($val['args']) : 0;
- $args = array_pad(array(), $_, '$var');
+ $args = array_pad([], $_, '$var');
$args = implode(", ", $args);
$modx = &$this;
$args = preg_replace_callback('/\$var/', function () use ($modx, &$tmp, $val) {
@@ -6639,7 +6643,7 @@ public function getHiddenIdFromAlias($parentid, $alias)
$out = false;
if ($alias !== '') {
$table = $this->getFullTableName('site_content');
- $query = $this->db->query("SELECT
+ $query = $this->db->query("SELECT
`sc`.`id` AS `hidden_id`,
`children`.`id` AS `child_id`,
children.alias AS `child_alias`,
@@ -6984,7 +6988,7 @@ class SystemEvent
public $_output;
public $activated = false;
public $activePlugin = '';
- public $params = array();
+ public $params = [];
/**
* Previous event object
diff --git a/manager/includes/extenders/dbapi.mysqli.class.inc.php b/manager/includes/extenders/dbapi.mysqli.class.inc.php
index 8fe9fde06d..cc7a2f785d 100644
--- a/manager/includes/extenders/dbapi.mysqli.class.inc.php
+++ b/manager/includes/extenders/dbapi.mysqli.class.inc.php
@@ -217,27 +217,29 @@ public function query($sql, $watchError = true)
public function delete($from, $where = '', $orderBy = '', $limit = '')
{
$modx = evolutionCMS();
- $out = false;
if (!$from) {
$modx->messageQuit("Empty \$from parameters in DBAPI::delete().");
- } else {
- $from = $this->replaceFullTableName($from);
- $where = trim($where);
- $orderBy = trim($orderBy);
- $limit = trim($limit);
- if ($where !== '' && stripos($where, 'WHERE') !== 0) {
- $where = "WHERE {$where}";
- }
- if ($orderBy !== '' && stripos($orderBy, 'ORDER BY') !== 0) {
- $orderBy = "ORDER BY {$orderBy}";
- }
- if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) {
- $limit = "LIMIT {$limit}";
- }
+ return false;
+ }
- $out = $this->query("DELETE FROM {$from} {$where} {$orderBy} {$limit}");
+ $where = trim($where);
+ if(!$where && !$limit) {
+ return $this->truncate($from);
}
- return $out;
+
+ $from = $this->replaceFullTableName($from);
+ $orderBy = trim($orderBy);
+ $limit = trim($limit);
+ if ($where !== '' && stripos($where, 'WHERE') !== 0) {
+ $where = "WHERE {$where}";
+ }
+ if ($orderBy !== '' && stripos($orderBy, 'ORDER BY') !== 0) {
+ $orderBy = "ORDER BY {$orderBy}";
+ }
+ if ($limit !== '' && stripos($limit, 'LIMIT') !== 0) {
+ $limit = "LIMIT {$limit}";
+ }
+ return $this->query("DELETE FROM {$from} {$where} {$orderBy} {$limit}");
}
/**
@@ -294,31 +296,27 @@ public function select($fields = "*", $from = "", $where = "", $orderBy = "", $l
public function update($fields, $table, $where = "")
{
$modx = evolutionCMS();
- $out = false;
if (!$table) {
$modx->messageQuit('Empty '.$table.' parameter in DBAPI::update().');
- } else {
- $table = $this->replaceFullTableName($table);
- if (is_array($fields)) {
- foreach ($fields as $key => $value) {
- if ($value === null || strtolower($value) === 'null') {
- $f = 'NULL';
- } else {
- $f = "'" . $value . "'";
- }
- $fields[$key] = "`{$key}` = " . $f;
+ return;
+ }
+ $table = $this->replaceFullTableName($table);
+ if (is_array($fields)) {
+ foreach ($fields as $key => $value) {
+ if ($value === null || strtolower($value) === 'null') {
+ $f = 'NULL';
+ } else {
+ $f = "'" . $value . "'";
}
- $fields = implode(',', $fields);
+ $fields[$key] = "`{$key}` = " . $f;
}
- $where = trim($where);
- if ($where !== '' && stripos($where, 'WHERE') !== 0) {
- $where = 'WHERE '.$where;
- }
-
- return $this->query('UPDATE '.$table.' SET '.$fields.' '.$where);
+ $fields = implode(',', $fields);
}
- return $out;
- }
+ if ($where && stripos(trim($where), 'WHERE') !== 0) {
+ $where = 'WHERE '.$where;
+ }
+ return $this->query('UPDATE '.$table.' SET '.$fields.' '.$where);
+}
/**
* @param string|array $fields
@@ -689,7 +687,7 @@ public function optimize($table_name)
*/
public function truncate($table_name)
{
- return $this->query('TRUNCATE '.$table_name);
+ return $this->query('TRUNCATE '.$this->replaceFullTableName($table_name));
}
/**
@@ -733,7 +731,7 @@ public function _getFromStringFromArray($tables = array())
{
$_ = array();
foreach ($tables as $k => $v) {
- $_[] = $v;
+ $_[] = is_int($k) ? $v : $v . $v.' '.$k;
}
return implode(' ', $_);
diff --git a/manager/includes/lang/japanese-utf8.inc.php b/manager/includes/lang/japanese-utf8.inc.php
index a731be37f5..9d49e9af4b 100755
--- a/manager/includes/lang/japanese-utf8.inc.php
+++ b/manager/includes/lang/japanese-utf8.inc.php
@@ -1284,7 +1284,7 @@
$_lang["login_processor_captcha_config"] = "Captcha is not configured properly.";
$_lang["dp_dayNames"] = "['日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日']";
-$_lang["dp_monthNames"] = "['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']";
+$_lang["dp_monthNames"] = "['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']";
$_lang["dp_startDay"] = "1";
$_lang["check_all"] = "Select all";
diff --git a/manager/includes/tmplvars.inc.php b/manager/includes/tmplvars.inc.php
index bbcd1d80f0..82116c8aad 100755
--- a/manager/includes/tmplvars.inc.php
+++ b/manager/includes/tmplvars.inc.php
@@ -138,7 +138,7 @@ function renderFormElement($field_type, $field_id, $default_text = '', $field_el
$checked = in_array($value, $values) ? ' checked="checked"' : '';
$param = array(
$modx->htmlspecialchars($value),
- $i,
+ $field_id,
$field_id,
$checked,
$name
@@ -156,7 +156,7 @@ function renderFormElement($field_type, $field_id, $default_text = '', $field_el
if(strlen($itemvalue) == 0) {
$itemvalue = $item;
}
- $field_html .= '' . $item . ' ';
+ $field_html .= '' . $item . ' ';
$i++;
}
break;
@@ -181,7 +181,7 @@ function OpenServerBrowser(url, width, height ) {
sOptions += ',top=' + iTop ;
var oWindow = window.open( url, 'FCKBrowseWindow', sOptions ) ;
- }
+ }
function BrowseServer(ctrl) {
lastImageCtrl = ctrl;
var w = screen.width * 0.5;
diff --git a/manager/media/browser/mcpuk/config.php b/manager/media/browser/mcpuk/config.php
index acae3c46a0..5b11dcc1f3 100755
--- a/manager/media/browser/mcpuk/config.php
+++ b/manager/media/browser/mcpuk/config.php
@@ -18,18 +18,18 @@
$modx = evolutionCMS();
$_CONFIG = array(
- 'disabled' => false,
- 'denyZipDownload' => $modx->config['denyZipDownload'],
- 'denyExtensionRename' => $modx->config['denyExtensionRename'],
- 'showHiddenFiles' => $modx->config['showHiddenFiles'],
- 'theme' => "evo",
- 'uploadURL' => rtrim($modx->config['rb_base_url'], '/'),
- 'uploadDir' => rtrim($modx->config['rb_base_dir'], '/'),
- 'siteURL' => $modx->config['site_url'],
- 'assetsURL' => rtrim($modx->config['rb_base_url'], '/'),
- 'dirPerms' => intval($modx->config['new_folder_permissions'], 8),
- 'filePerms' => intval($modx->config['new_file_permissions'], 8),
- 'maxfilesize' => (int)$modx->config['upload_maxsize'],
+ 'disabled' => false,
+ 'denyZipDownload' => $modx->config['denyZipDownload'],
+ 'denyExtensionRename' => $modx->config['denyExtensionRename'],
+ 'showHiddenFiles' => $modx->config['showHiddenFiles'],
+ 'theme' => "evo",
+ 'uploadURL' => rtrim($modx->config['rb_base_url'], '/'),
+ 'uploadDir' => rtrim($modx->config['rb_base_dir'], '/'),
+ 'siteURL' => $modx->config['site_url'],
+ 'assetsURL' => rtrim($modx->config['rb_base_url'], '/'),
+ 'dirPerms' => intval($modx->config['new_folder_permissions'], 8),
+ 'filePerms' => intval($modx->config['new_file_permissions'], 8),
+ 'maxfilesize' => (int)$modx->config['upload_maxsize'],
'noThumbnailsRecreation' => $modx->config['noThumbnailsRecreation'],
'access' => array(
@@ -71,9 +71,10 @@
'maxImageWidth' => $modx->config['maxImageWidth'],
'maxImageHeight' => $modx->config['maxImageHeight'],
- 'clientResize' => $modx->config['clientResize'] && ($modx->config['maxImageWidth'] || $modx->config['maxImageHeight']) ? array('maxWidth' => $modx->config['maxImageWidth'],
- 'maxHeight' => $modx->config['maxImageHeight'],
- 'quality' => $modx->config['jpegQuality'] / 100
+ 'clientResize' => $modx->config['clientResize'] && ($modx->config['maxImageWidth'] || $modx->config['maxImageHeight']) ? array(
+ 'maxWidth' => $modx->config['maxImageWidth'],
+ 'maxHeight' => $modx->config['maxImageHeight'],
+ 'quality' => $modx->config['jpegQuality'] / 100
) : array(),
'thumbWidth' => $modx->config['thumbWidth'],