diff --git a/assets/docs/changelog.txt b/assets/docs/changelog.txt
index dfbe3601b2..92f019f78f 100644
--- a/assets/docs/changelog.txt
+++ b/assets/docs/changelog.txt
@@ -1,6 +1,37 @@
This file shows the changes in recent releases of Evolution CMS. The most current release is usually the
development release, and is only shown to give an idea of what's currently in the pipeline.
+Evolution CMS 1.3.5 (Sep 01, 2017)
+* [GitHub:#be94d6de] - fix php notice in Ditto (dmi3yy)
+* [GitHub:#16fe3481] - ElementsInTree clean up (Piotr Matysiak)
+* [GitHub:#f171c523] - ElementsInTree restyled for new theme (Piotr Matysiak)
+* [GitHub:#6726580c] - ElementsInTree 1.5.8 (Piotr Matysiak)
+* [GitHub:#4b6c3946] - Fix - <@IF><@ELSEIF><@ELSE><@ENDIF> (yamamoto)
+* [GitHub:#43fc85b3] - Code cleanup (yamamoto)
+* [GitHub:#3a941181] - #188 Ditto in dashboard widget permission issue (yamamoto)
+* [GitHub:#a7c1eb8e] - Fix - $ditto_base directory separator char (yamamoto)
+* [GitHub:#bd785cf9] - Fix - $modx->parseDocumentSource() (yamamoto)
+* [GitHub:#623be60e] - Code cleanup (yamamoto)
+* [GitHub:#2c0ad143] - fix Ditto TV output (dmi3yy)
+* [GitHub:#003c0be9] - Update document.parser.class.inc.php (Dreamer0x01)
+* [GitHub:#6cc75b5e] - Fix Ditto when dateSource emply use createdon #190 (dmi3yy)
+* [GitHub:#cd35be24] - fix tinymce params underfined bug on frontend (dmi3yy)
+* [GitHub:#c0702676] - fix 65 Plugin parameters are lost after update to the new version (dmi3yy)
+* [GitHub:#12c5c36f] - delete deprecated code (dmi3yy)
+* [GitHub:#ac4c1d37] - Refactor (yamamoto)
+* [GitHub:#82c8a6d8] - Remove - $ditto->renderQELinks() (yamamoto)
+* [GitHub:#19cfd326] - #188 Ditto in dashboard widget permission issue (yamamoto)
+* [GitHub:#1bac7219] - #190 Ditto does not recognize &dateSource parameter any more (yamamoto)
+* [GitHub:#d3760b2f] - no need update.php in extras module (dmi3yy)
+* [GitHub:#b8b75b24] - fix #192 (64j)
+* [GitHub:#83535377] - fix variable documentDirty (64j)
+* [GitHub:#3b70064c] - Update to Make sortable list more condensed (Piotr Matysiak)
+* [GitHub:#ffe64306] - Make sortable list more condensed (Piotr Matysiak)
+* [GitHub:#2c2fe39b] - #187 Ditto is missing placeholders when built-in filters are enabled (yamamoto)
+* [GitHub:#7374ccf6] - fix eng translate (dmi3yy)
+* [GitHub:#4903a8bd] - fix saved roles users #130 (Serg)
+
+
Evolution CMS 1.3.4 (Aug 24, 2017)
* [GitHub:#30e0efc9] - fix version (dmi3yy)
* [GitHub:#d03412a7] - Updater one more check for use from manager only (dmi3yy)
diff --git a/assets/lib/MODxAPI/modResource.php b/assets/lib/MODxAPI/modResource.php
index 63bfed59c6..8c6b190915 100644
--- a/assets/lib/MODxAPI/modResource.php
+++ b/assets/lib/MODxAPI/modResource.php
@@ -44,8 +44,6 @@ class modResource extends MODxAPI
'publishedby' => 0,
'menutitle' => '',
'donthit' => 0,
- 'haskeywords' => 0,
- 'hasmetatags' => 0,
'privateweb' => 0,
'privatemgr' => 0,
'content_dispo' => 0,
diff --git a/assets/modules/store/update.php b/assets/modules/store/update.php
deleted file mode 100755
index a2079eb816..0000000000
--- a/assets/modules/store/update.php
+++ /dev/null
@@ -1,46 +0,0 @@
-open(dirname(__FILE__).'/update.zip');
-$zip->extractTo( dirname(__FILE__) );
-$zip->close();
-echo dirname(__FILE__).'/update.zip';
-unlink('update.zip');
-?>
diff --git a/assets/plugins/elementsintree/assets/css_treeButtonsInTab.tpl b/assets/plugins/elementsintree/assets/css_treeButtonsInTab.tpl
index ed93d2ef25..47b661b93e 100644
--- a/assets/plugins/elementsintree/assets/css_treeButtonsInTab.tpl
+++ b/assets/plugins/elementsintree/assets/css_treeButtonsInTab.tpl
@@ -1,33 +1,34 @@
- /* Tree Buttons in Tab */
- #treeHolder {
- padding-top: 10px;
- padding-left: 10px;
- }
-
- #treeMenu {
- display: none;
- margin-left: 0;
- margin-bottom: 6px;
- background-color: transparent !important;
- border-bottom-width: 0;
- }
+/* Tree Buttons in Tab */
- #treeMenu.is-intab {
- display: table;
- }
+#treeHolder {
+ padding-top: 10px;
+ padding-left: 10px;
+}
- .treeButton,
- .treeButtonDisabled {
- padding: 2px 3px;
- }
+#treeMenu {
+ display: none;
+ margin-left: 0;
+ margin-bottom: 6px;
+ background-color: transparent !important;
+ border-bottom-width: 0;
+}
- #tabDoc {
- padding-top: 11px !important;
- padding-left: 13px !important;
- padding-right: 13px !important;
- }
-
- #floater {
- width: 99%;
- top: 94px;
- }
+#treeMenu.is-intab {
+ display: table;
+}
+
+.treeButton,
+.treeButtonDisabled {
+ padding: 2px 3px;
+}
+
+#tabDoc {
+ padding-top: 11px !important;
+ padding-left: 13px !important;
+ padding-right: 13px !important;
+}
+
+#floater {
+ width: 99%;
+ top: 94px;
+}
diff --git a/assets/plugins/elementsintree/assets/css_unifyFrames.tpl b/assets/plugins/elementsintree/assets/css_unifyFrames.tpl
index 387473829a..adbef0d032 100644
--- a/assets/plugins/elementsintree/assets/css_unifyFrames.tpl
+++ b/assets/plugins/elementsintree/assets/css_unifyFrames.tpl
@@ -1,16 +1,17 @@
- /* Unify Frames */
- body,
- div.treeframebody {
- background-color: #f2f2f2 !important;
- }
+/* Unify frames */
- div.treeframebody {
- background-color: transparent !important;
- -webkit-box-shadow: none !important;
- box-shadow: none !important;
- }
+body,
+div.treeframebody {
+ background-color: #f2f2f2 !important;
+}
- #treeMenu {
- background-color: transparent !important;
- border-bottom-color: transparent !important;
- }
+div.treeframebody {
+ background-color: transparent !important;
+ -webkit-box-shadow: none !important;
+ box-shadow: none !important;
+}
+
+#treeMenu {
+ background-color: transparent !important;
+ border-bottom-color: transparent !important;
+}
diff --git a/assets/plugins/elementsintree/assets/txt_content.tpl b/assets/plugins/elementsintree/assets/txt_content.tpl
index 9a98bce384..ae538aa72c 100644
--- a/assets/plugins/elementsintree/assets/txt_content.tpl
+++ b/assets/plugins/elementsintree/assets/txt_content.tpl
@@ -1,198 +1,356 @@
diff --git a/assets/plugins/elementsintree/plugin.elementsintree.php b/assets/plugins/elementsintree/plugin.elementsintree.php
index 83c6dc0a06..ef716b4f41 100644
--- a/assets/plugins/elementsintree/plugin.elementsintree.php
+++ b/assets/plugins/elementsintree/plugin.elementsintree.php
@@ -8,39 +8,47 @@
if(!defined('MODX_BASE_PATH')) die('What are you doing? Get out of here!');
+$role = $_SESSION['mgrRole'];
+
+if ( $adminRoleOnly == 'yes' && $role != 1 ) {
+ return;
+}
+
$eit_base_path = str_replace('\\','/',dirname(__FILE__)) . '/';
+
include_once($eit_base_path.'includes/functions.inc.php');
global $_lang;
+
$e = &$modx->event;
if(!isset($_SESSION['elementsInTree'])) $_SESSION['elementsInTree'] = array();
switch($e->name) {
- case 'OnManagerMainFrameHeaderHTMLBlock': // Trigger reloading tree for relevant actions
- include_once($eit_base_path.'includes/on_manager_main_frame_header_html_block.inc.php'); break;
- case 'OnManagerTreePrerender': // Main elementsInTree-part
- include_once($eit_base_path.'includes/on_manager_tree_prerender.inc.php'); break;
- case 'OnManagerTreeRender':
- if(hasAnyPermission()) include_once($eit_base_path.'includes/on_manager_tree_render.inc.php');
- else $e->output(''); // Issue 1340
- break;
- case 'OnTempFormSave':
- case 'OnTVFormSave':
- case 'OnChunkFormSave':
- case 'OnSnipFormSave':
- case 'OnPluginFormSave':
- case 'OnModFormSave':
- case 'OnTempFormDelete':
- case 'OnTVFormDelete':
- case 'OnChunkFormDelete':
- case 'OnSnipFormDelete':
- case 'OnPluginFormDelete':
- case 'OnModFormDelete':
- // Set reloadTree = true for this events
- $_SESSION['elementsInTree']['reloadTree'] = true; break;
- default:
- if($_GET['r'] == 2) $_SESSION['elementsInTree']['reloadTree'] = true;
- return;
+ case 'OnManagerMainFrameHeaderHTMLBlock': // Trigger reloading tree for relevant actions
+ include_once($eit_base_path.'includes/on_manager_main_frame_header_html_block.inc.php'); break;
+ case 'OnManagerTreePrerender': // Main elementsInTree-part
+ include_once($eit_base_path.'includes/on_manager_tree_prerender.inc.php'); break;
+ case 'OnManagerTreeRender':
+ if(hasAnyPermission()) include_once($eit_base_path.'includes/on_manager_tree_render.inc.php');
+ else $e->output(''); // Issue 1340
+ break;
+ case 'OnTempFormSave':
+ case 'OnTVFormSave':
+ case 'OnChunkFormSave':
+ case 'OnSnipFormSave':
+ case 'OnPluginFormSave':
+ case 'OnModFormSave':
+ case 'OnTempFormDelete':
+ case 'OnTVFormDelete':
+ case 'OnChunkFormDelete':
+ case 'OnSnipFormDelete':
+ case 'OnPluginFormDelete':
+ case 'OnModFormDelete':
+ // Set reloadTree = true for this events
+ $_SESSION['elementsInTree']['reloadTree'] = true; break;
+ default:
+ if($_GET['r'] == 2) $_SESSION['elementsInTree']['reloadTree'] = true;
+ return;
}
return;
\ No newline at end of file
diff --git a/assets/plugins/tinymce4/gsettings/gsettings.rows.inc.php b/assets/plugins/tinymce4/gsettings/gsettings.rows.inc.php
index 876b34ffc2..1a51803705 100644
--- a/assets/plugins/tinymce4/gsettings/gsettings.rows.inc.php
+++ b/assets/plugins/tinymce4/gsettings/gsettings.rows.inc.php
@@ -1,6 +1,6 @@
'', 'skinsDirectory'=>'');
// Hold general settings based on old Modx TinyMCE-Settings
// Settings interface rows configuration
diff --git a/assets/snippets/DocLister/core/controller/site_content.php b/assets/snippets/DocLister/core/controller/site_content.php
index 1e76d834a5..48f4db9f88 100644
--- a/assets/snippets/DocLister/core/controller/site_content.php
+++ b/assets/snippets/DocLister/core/controller/site_content.php
@@ -96,8 +96,6 @@ public function _render($tpl = '')
$tpl = $this->getCFGDef('tpl', '@CODE:[+pagetitle+]
');
}
if ($tpl != '') {
- $date = $this->getCFGDef('dateSource', 'pub_date');
-
$this->toPlaceholders(count($this->_docs), 1, "display"); // [+display+] - сколько показано на странице.
$i = 1;
@@ -143,7 +141,7 @@ public function _render($tpl = '')
$item['url'] = $this->modx->makeUrl($item['id'], '', '', $this->getCFGDef('urlScheme', ''));
}
}
-
+ $date = $this->getCFGDef('dateSource', 'pub_date');
if (isset($item[$date])) {
if (!$item[$date] && $date == 'pub_date' && isset($item['createdon'])) {
$date = 'createdon';
diff --git a/assets/snippets/ditto/classes/debug.class.inc.php b/assets/snippets/ditto/classes/debug.class.inc.php
index 287ce4bb16..66324f37fe 100644
--- a/assets/snippets/ditto/classes/debug.class.inc.php
+++ b/assets/snippets/ditto/classes/debug.class.inc.php
@@ -3,153 +3,151 @@
/*
* Title: Debug Class
* Purpose:
- * The Debug class contains all functions relating to Ditto's
- * implimentation of the MODX debug console
+ * The Debug class contains all functions relating to Ditto's
+ * implimentation of the MODX debug console
*/
class debug extends modxDebugConsole {
- var $debug;
-
- // ---------------------------------------------------
- // Function: render_link
- // Render the links to the debug console
- // ---------------------------------------------------
- function render_link($dittoID,$ditto_base) {
- global $ditto_lang,$modx;
- $base_url = str_replace($modx->config["base_path"],$modx->config["site_url"],$ditto_base);
- return $this->makeLink($ditto_lang["debug"],$ditto_lang["open_dbg_console"], $ditto_lang["save_dbg_console"],$base_url.'debug/',"ditto_".$dittoID);
- }
- // ---------------------------------------------------
- // Function: render_popup
- // Render the contents of the debug console
- // ---------------------------------------------------
- function render_popup($ditto,$ditto_base,$ditto_version, $ditto_params, $IDs, $fields, $summarize, $templates, $orderBy, $start, $stop, $total,$filter,$resource) {
- global $ditto_lang,$modx;
- $tabs = array();
- $fields = (count($fields["db"]) > 0 && count($fields["tv"]) > 0) ? array_merge_recursive($ditto->fields,array("retrieved"=>$fields)) : $ditto->fields;
-
- $tabs[$ditto_lang["info"]] = $this->prepareBasicInfo($ditto,$ditto_version, $IDs, $summarize, $orderBy, $start, $stop, $total);
- $tabs[$ditto_lang["params"]] = $this->makeParamTable($ditto_params,$ditto_lang["params"]);
- $tabs[$ditto_lang["fields"]] = "
".$this->array2table($this->cleanArray($fields), true, true)."
";
- $tabs[$ditto_lang["templates"]] = $this->makeParamTable($this->prepareTemplates($templates),$ditto_lang["templates"]);
-
- if ($filter !== false) {
- $tabs[$ditto_lang["filters"]] = $this->prepareFilters($this->cleanArray($filter));
- }
+ var $debug;
+
+ // ---------------------------------------------------
+ // Function: render_link
+ // Render the links to the debug console
+ // ---------------------------------------------------
+ function render_link($dittoID,$ditto_base) {
+ global $ditto_lang,$modx;
+ $base_url = str_replace($modx->config['base_path'],$modx->config['site_url'],$ditto_base);
+ return $this->makeLink($ditto_lang['debug'],$ditto_lang['open_dbg_console'], $ditto_lang['save_dbg_console'],$base_url.'debug/','ditto_'.$dittoID);
+ }
+ // ---------------------------------------------------
+ // Function: render_popup
+ // Render the contents of the debug console
+ // ---------------------------------------------------
+ function render_popup($ditto,$ditto_base,$ditto_version, $ditto_params, $IDs, $fields, $summarize, $templates, $orderBy, $start, $stop, $total,$filter,$resource) {
+ global $ditto_lang,$modx;
+ $tabs = array();
+ $fields = (count($fields['db']) > 0 && count($fields['tv']) > 0) ? array_merge_recursive($ditto->fields,array('retrieved'=>$fields)) : $ditto->fields;
+
+ $tabs[$ditto_lang['info']] = $this->prepareBasicInfo($ditto,$ditto_version, $IDs, $summarize, $orderBy, $start, $stop, $total);
+ $tabs[$ditto_lang['params']] = $this->makeParamTable($ditto_params,$ditto_lang['params']);
+ $tabs[$ditto_lang['fields']] = "".$this->array2table($this->cleanArray($fields), true, true).'
';
+ $tabs[$ditto_lang['templates']] = $this->makeParamTable($this->prepareTemplates($templates),$ditto_lang['templates']);
+
+ if ($filter !== false) {
+ $tabs[$ditto_lang['filters']] = $this->prepareFilters($this->cleanArray($filter));
+ }
- if ($ditto->prefetch == true) {
- $tabs[$ditto_lang["prefetch_data"]] = $this->preparePrefetch($ditto->prefetch);
- }
- if (count($resource) > 0 && $resource) {
- $tabs[$ditto_lang["retrieved_data"]] = $this->prepareDocumentInfo($resource);
- }
- $base_url = str_replace($modx->config["base_path"],$modx->config["site_url"],$ditto_base);
- $generatedOn = "\r\n\r\n".'';
- return $this->render($tabs,$ditto_lang['debug'],$base_url).$generatedOn;
- }
-
- // ---------------------------------------------------
- // Function: preparePrefetch
- // Create the content of the Prefetch tab
- // ---------------------------------------------------
- function preparePrefetch($prefetch) {
- global $ditto_lang;
- $ditto_IDs = array();
- if (count($prefetch["dbg_IDs_pre"]) > 0) {
- $ditto_IDs[$ditto_lang["ditto_IDs_all"]." (".count($prefetch["dbg_IDs_pre"]).")"] = implode(",",$prefetch["dbg_IDs_pre"]);
- }
- if (count($prefetch["dbg_IDs_post"]) > 0) {
- $ditto_IDs[$ditto_lang["ditto_IDs_selected"]." (".count($prefetch["dbg_IDs_post"]).")"] = implode(", ",$prefetch["dbg_IDs_post"]);
- } else {
- $ditto_IDs[$ditto_lang["ditto_IDs_selected"]." (0)"] = strip_tags($ditto_lang["no_documents"]);
- }
- $out = $this->array2table(array($ditto_lang["prefetch_data"]=>$ditto_IDs),true,true);
- return $out.$this->prepareDocumentInfo($prefetch["dbg_resource"]);
- }
+ if ($ditto->prefetch == true) {
+ $tabs[$ditto_lang['prefetch_data']] = $this->preparePrefetch($ditto->prefetch);
+ }
+ if (count($resource) > 0 && $resource) {
+ $tabs[$ditto_lang['retrieved_data']] = $this->prepareDocumentInfo($resource);
+ }
+ $base_url = str_replace($modx->config['base_path'],$modx->config['site_url'],$ditto_base);
+ $generatedOn = "\r\n\r\n".'';
+ return $this->render($tabs,$ditto_lang['debug'],$base_url).$generatedOn;
+ }
+
+ // ---------------------------------------------------
+ // Function: preparePrefetch
+ // Create the content of the Prefetch tab
+ // ---------------------------------------------------
+ function preparePrefetch($prefetch) {
+ global $ditto_lang;
+ $ditto_IDs = array();
+ if (count($prefetch['dbg_IDs_pre']) > 0) {
+ $ditto_IDs[$ditto_lang['ditto_IDs_all'].' ('.count($prefetch['dbg_IDs_pre']).')'] = implode(',',$prefetch['dbg_IDs_pre']);
+ }
+ if (count($prefetch['dbg_IDs_post']) > 0) {
+ $ditto_IDs[$ditto_lang['ditto_IDs_selected'].' ('.count($prefetch['dbg_IDs_post']).')'] = implode(', ',$prefetch['dbg_IDs_post']);
+ } else {
+ $ditto_IDs[$ditto_lang['ditto_IDs_selected'].' (0)'] = strip_tags($ditto_lang['no_documents']);
+ }
+ $out = $this->array2table(array($ditto_lang['prefetch_data']=>$ditto_IDs),true,true);
+ return $out.$this->prepareDocumentInfo($prefetch['dbg_resource']);
+ }
- // ---------------------------------------------------
- // Function: prepareFilters
- // Create the content of the Filters tab
- // ---------------------------------------------------
- function prepareFilters($filter) {
- $output = "";
- foreach ($filter as $name=>$value) {
- if ($name == "custom") {
- foreach ($value as $name=>$value) {
- $output .= $this->array2table(array($name=>$value), true, true);
- }
- } else {
- $output .= $this->array2table(array($name=>$value), true, true);
- }
- }
- return $output;
- }
-
- // ---------------------------------------------------
- // Function: prepareDocumentInfo
- // Create the output for the Document Info tab
- // ---------------------------------------------------
- function prepareDocumentInfo($resource) {
- global $ditto_lang;
- $output = "";
- if (count($resource) > 0) {
- foreach ($resource as $item) {
- $header = str_replace(array('[+pagetitle+]','[+id+]'),array($item['pagetitle'],$item['id']),$this->templates["item"]);
- $output .= $this->makeParamTable($item,$header,true,true,true,"resource");
- }
- }
- return $output;
- }
+ // ---------------------------------------------------
+ // Function: prepareFilters
+ // Create the content of the Filters tab
+ // ---------------------------------------------------
+ function prepareFilters($filter) {
+ $output = '';
+ foreach ($filter as $name=>$value) {
+ if ($name == 'custom') {
+ foreach ($value as $name=>$value) {
+ $output .= $this->array2table(array($name=>$value), true, true);
+ }
+ } else {
+ $output .= $this->array2table(array($name=>$value), true, true);
+ }
+ }
+ return $output;
+ }
+
+ // ---------------------------------------------------
+ // Function: prepareDocumentInfo
+ // Create the output for the Document Info tab
+ // ---------------------------------------------------
+ function prepareDocumentInfo($resource) {
+ global $ditto_lang;
+ $output = '';
+ if (count($resource) > 0) {
+ foreach ($resource as $item) {
+ $header = str_replace(array('[+pagetitle+]','[+id+]'),array($item['pagetitle'],$item['id']),$this->templates['item']);
+ $output .= $this->makeParamTable($item,$header,true,true,true,'resource');
+ }
+ }
+ return $output;
+ }
- // ---------------------------------------------------
- // Function: prepareBasicInfo
- // Create the outut for the Info ta
- // ---------------------------------------------------
- function prepareBasicInfo($ditto,$ditto_version, $IDs, $summarize, $orderBy, $start, $stop, $total) {
- global $ditto_lang,$dittoID,$modx;
- $items[$ditto_lang['version']] = $ditto_version;
- $items[$ditto_lang['summarize']] = $summarize;
- $items[$ditto_lang['total']] = $total;
- $items[$ditto_lang['start']] = $start;
- $items[$ditto_lang['stop']] = $stop;
- $items[$ditto_lang['ditto_IDs']] = (count($IDs) > 0) ? wordwrap(implode(", ",$IDs),100, "
") : $ditto_lang['none'];
- $output = '';
- if (is_array($orderBy['parsed']) && count($orderBy['parsed']) > 0) {
- $sort = array();
- foreach ($orderBy['parsed'] as $key=>$value) {
- $sort[$key] = array($ditto_lang['sortBy']=>$value[0],$ditto_lang['sortDir']=>$value[1]);
- }
- $output = $this->array2table($this->cleanArray($sort), true, true);
- }
- return $this->makeParamTable($items,$ditto_lang["basic_info"],false,false).$output;
- }
+ // ---------------------------------------------------
+ // Function: prepareBasicInfo
+ // Create the outut for the Info ta
+ // ---------------------------------------------------
+ function prepareBasicInfo($ditto,$ditto_version, $IDs, $summarize, $orderBy, $start, $stop, $total) {
+ global $ditto_lang,$dittoID,$modx;
+ $items[$ditto_lang['version']] = $ditto_version;
+ $items[$ditto_lang['summarize']] = $summarize;
+ $items[$ditto_lang['total']] = $total;
+ $items[$ditto_lang['start']] = $start;
+ $items[$ditto_lang['stop']] = $stop;
+ $items[$ditto_lang['ditto_IDs']] = (count($IDs) > 0) ? wordwrap(implode(', ',$IDs),100, '
') : $ditto_lang['none'];
+ $output = '';
+ if (is_array($orderBy['parsed']) && count($orderBy['parsed']) > 0) {
+ $sort = array();
+ foreach ($orderBy['parsed'] as $key=>$value) {
+ $sort[$key] = array($ditto_lang['sortBy']=>$value[0],$ditto_lang['sortDir']=>$value[1]);
+ }
+ $output = $this->array2table($this->cleanArray($sort), true, true);
+ }
+ return $this->makeParamTable($items,$ditto_lang['basic_info'],false,false).$output;
+ }
- // ---------------------------------------------------
- // Function: prepareTemplates
- // Create the output for the Templates tab
- // ---------------------------------------------------
- function prepareTemplates($templates) {
- global $ditto_lang;
- $displayTPLs = array();
- foreach ($templates as $name=>$value) {
- switch ($name) {
- case "base":
- $displayName = "tpl";
- break;
+ // ---------------------------------------------------
+ // Function: prepareTemplates
+ // Create the output for the Templates tab
+ // ---------------------------------------------------
+ function prepareTemplates($templates) {
+ global $ditto_lang;
+ $displayTPLs = array();
+ foreach ($templates as $name=>$value) {
+ switch ($name) {
+ case 'base':
+ $displayName = 'tpl';
+ break;
- case "default":
- $displayName = "tpl";
- break;
+ case 'default':
+ $displayName = 'tpl';
+ break;
- default:
- $displayName = "tpl".strtoupper($name{0}).substr($name,1);
- break;
- }
- $displayTPLs[$displayName] = $value;
- }
- return $displayTPLs;
- }
+ default:
+ $displayName = 'tpl'.strtoupper($name{0}).substr($name,1);
+ break;
+ }
+ $displayTPLs[$displayName] = $value;
+ }
+ return $displayTPLs;
+ }
}
-
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/classes/ditto.class.inc.php b/assets/snippets/ditto/classes/ditto.class.inc.php
index 023bccc4ad..3c76a09061 100644
--- a/assets/snippets/ditto/classes/ditto.class.inc.php
+++ b/assets/snippets/ditto/classes/ditto.class.inc.php
@@ -12,21 +12,21 @@ class ditto {
function __construct($dittoID,$format,$language,$debug) {
$this->format = $format;
- $GLOBALS["ditto_lang"] = $language;
- $this->prefetch = false;
- $this->advSort = false;
- $this->sqlOrderBy = array();
- $this->customReset = array();
- $this->constantFields[] = array("db","tv");
- $this->constantFields["db"] = array("id","type","contentType","pagetitle","longtitle","description","alias","link_attributes","published","pub_date","unpub_date","parent","isfolder","introtext","content","richtext","template","menuindex","searchable","cacheable","createdby","createdon","editedby","editedon","deleted","deletedon","deletedby","publishedon","publishedby","menutitle","donthit","privateweb","privatemgr","content_dispo","hidemenu");
- $this->constantFields["tv"] = $this->getTVList();
- $GLOBALS["ditto_constantFields"] = $this->constantFields;
- $this->fields = array("display"=>array(),"backend"=>array("tv"=>array(),"db"=>array("id", "published")));
+ $GLOBALS['ditto_lang'] = $language;
+ $this->prefetch = false;
+ $this->advSort = false;
+ $this->sqlOrderBy = array();
+ $this->customReset = array();
+ $this->constantFields[] = array('db','tv');
+ $this->constantFields['db'] = explode(',', 'id,type,contentType,pagetitle,longtitle,description,alias,link_attributes,published,pub_date,unpub_date,parent,isfolder,introtext,content,richtext,template,menuindex,searchable,cacheable,createdby,createdon,editedby,editedon,deleted,deletedon,deletedby,publishedon,publishedby,menutitle,donthit,privateweb,privatemgr,content_dispo,hidemenu');
+ $this->constantFields['tv'] = $this->getTVList();
+ $GLOBALS['ditto_constantFields'] = $this->constantFields;
+ $this->fields = array('display'=>array(),'backend'=>array('tv'=>array(),'db'=>array('id', 'published')));
$this->sortOrder = false;
$this->customPlaceholdersMap = array();
$this->template = new template();
- if (!is_null($debug)) {$this->debug = new debug($debug);}
+ if (!is_null($debug)) $this->debug = new debug($debug);
}
// ---------------------------------------------------
@@ -36,9 +36,8 @@ function __construct($dittoID,$format,$language,$debug) {
function getTVList() {
global $modx;
- $table = $modx->getFullTableName("site_tmplvars");
- $tvs = $modx->db->select("name", $table);
- // TODO: make it so that it only pulls those that apply to the current template
+ // TODO: make it so that it only pulls those that apply to the current template
+ $tvs = $modx->db->select('name', '[+prefix+]site_tmplvars');
$dbfields = $modx->db->getColumn('name', $tvs);
return $dbfields;
}
@@ -52,14 +51,14 @@ function addField($name,$location,$type=false) {
if ($type === false) {
$type = $this->getDocVarType($name);
}
- if ($type == "tv:prefix") {
- $type = "tv";
+ if ($type == 'tv:prefix') {
+ $type = 'tv';
$name = substr($name, 2);
}
- if ($location == "*") {
- $this->fields["backend"][$type][] = $name;
- $this->fields["display"][$type][] = $name;
- } else {
+ if ($location == '*') {
+ if(!in_array($name,$this->fields['backend'][$type])) $this->fields['backend'][$type][] = $name;
+ if(!in_array($name,$this->fields['display'][$type])) $this->fields['display'][$type][] = $name;
+ } elseif(!in_array($name,$this->fields[$location][$type])) {
$this->fields[$location][$type][] = $name;
}
}
@@ -73,11 +72,8 @@ function addField($name,$location,$type=false) {
function addFields($fields,$location='*',$delimiter=',',$callback=false) {
if (empty($fields)) return false;
if (!is_array($fields)) {
- if (strpos($fields,$delimiter) !== false) {
- $fields = explode($delimiter,$fields);
- } else {
- $fields = array($fields);
- }
+ if (strpos($fields,$delimiter)!==false) $fields = explode($delimiter,$fields);
+ else $fields = array($fields);
}
foreach ($fields as $field) {
if (is_array($field)) {
@@ -89,9 +85,7 @@ function addFields($fields,$location='*',$delimiter=',',$callback=false) {
}
$this->addField($name,$location,$type);
- if ($callback !== false) {
- call_user_func_array($callback, array($name));
- }
+ if ($callback !== false) call_user_func_array($callback, array($name));
}
return true;
}
@@ -103,9 +97,7 @@ function addFields($fields,$location='*',$delimiter=',',$callback=false) {
function removeField($name,$location,$type) {
$key = array_search ($name, $this->fields[$location][$type]);
- if ($key !== false) {
- unset($this->fields[$location][$type][$key]);
- }
+ if ($key !== false) unset($this->fields[$location][$type][$key]);
}
// ---------------------------------------------------
@@ -114,13 +106,8 @@ function removeField($name,$location,$type) {
// ---------------------------------------------------
function setDisplayFields($fields,$hiddenFields) {
- $this->fields["display"] = $fields;
- if (count($this->fields["display"]['qe']) > 0) {
- $this->addField("pagetitle","display","db");
- }
- if ($hiddenFields) {
- $this->addFields($hiddenFields,"display");
- }
+ $this->fields['display'] = $fields;
+ if ($hiddenFields) $this->addFields($hiddenFields,'display');
}
// ---------------------------------------------------
@@ -130,18 +117,14 @@ function setDisplayFields($fields,$hiddenFields) {
function getDocVarType($field) {
global $ditto_constantFields;
- $tvFields = $ditto_constantFields["tv"];
- $dbFields = $ditto_constantFields["db"];
- if(in_array($field, $tvFields)){
- return "tv";
- }else if(in_array(substr($field,2), $tvFields)) {
- return "tv:prefix";
- // TODO: Remove TV Prefix support
- } else if(in_array($field, $dbFields)){
- return "db";
- } else {
- return "unknown";
- }
+
+ $tvFields = $ditto_constantFields['tv'];
+ $dbFields = $ditto_constantFields['db'];
+
+ if(in_array($field, $tvFields)) return 'tv';
+ elseif(in_array(substr($field,2), $tvFields)) return 'tv:prefix'; // TODO: Remove TV Prefix support
+ elseif(in_array($field, $dbFields)) return 'db';
+ else return 'unknown';
}
// ---------------------------------------------------
@@ -173,11 +156,11 @@ function parseOrderBy($orderBy,$randomize) {
$sortDir = substr($input,$position);
$sortDir = !empty($sortDir) ? trim($sortDir) : 'asc';
$sortBy = $this->checkAdvSort($sortBy,$sortDir);
- $this->addField($sortBy,"backend");
+ $this->addField($sortBy,'backend');
$orderBy['parsed'][] = array($sortBy,strtoupper($sortDir));
}
}
- $orderBy['sql'] = implode(', ',$this->sqlOrderBy);
+ $orderBy['sql'] = join(', ',$this->sqlOrderBy);
unset($orderBy['unparsed']);
return $orderBy;
}
@@ -187,17 +170,17 @@ function parseOrderBy($orderBy,$randomize) {
// Check the advSortString
// ---------------------------------------------------
function checkAdvSort($sortBy,$sortDir='asc') {
- $advSort = array ("pub_date","unpub_date","editedon","deletedon","publishedon");
+ $advSort = array ('pub_date','unpub_date','editedon','deletedon','publishedon');
$type = $this->getDocVarType($sortBy);
switch($type) {
- case "tv:prefix":
+ case 'tv:prefix':
$sortBy = substr($sortBy, 2);
$this->advSort = true;
break;
- case "tv":
+ case 'tv':
$this->advSort = true;
break;
- case "db":
+ case 'db':
if (in_array($sortBy, $advSort)) {
$this->advSort = true;
$this->customReset[] = $sortBy;
@@ -215,33 +198,33 @@ function checkAdvSort($sortBy,$sortDir='asc') {
// ---------------------------------------------------
function parseFilters($filter=false,$cFilters=false,$pFilters = false,$globalDelimiter,$localDelimiter) {
- $parsedFilters = array("basic"=>array(),"custom"=>array());
+ $parsedFilters = array('basic'=>array(),'custom'=>array());
$filters = explode($globalDelimiter, $filter);
if ($filter && count($filters) > 0) {
foreach ($filters AS $filter) {
if (!empty($filter)) {
$filterArray = explode($localDelimiter, $filter);
$source = $filterArray[0];
- $this->addField($source,"backend");
+ $this->addField($source,'backend');
$value = $filterArray[1];
$mode = (isset ($filterArray[2])) ? $filterArray[2] : 1;
- $parsedFilters["basic"][] = array("source"=>$source,"value"=>$value,"mode"=>$mode);
+ $parsedFilters['basic'][] = array('source'=>$source,'value'=>$value,'mode'=>$mode);
}
}
}
if ($cFilters) {
foreach ($cFilters as $name=>$value) {
if (!empty($name) && !empty($value)) {
- $parsedFilters["custom"][$name] = $value[1];
- $this->addFields($value[0],"backend");
+ $parsedFilters['custom'][$name] = $value[1];
+ $this->addFields($value[0],'backend');
}
} // TODO: Replace addField with addFields with callback
}
if($pFilters) {
foreach ($pFilters as $filter) {
foreach ($filter as $name=>$value) {
- $parsedFilters["basic"][] = $value;
- $this->addFields($value["source"],"backend");
+ $parsedFilters['basic'][] = $value;
+ $this->addFields($value['source'],'backend');
}
} // TODO: Replace addField with addFields with callback
}
@@ -253,122 +236,110 @@ function parseFilters($filter=false,$cFilters=false,$pFilters = false,$globalDel
// Render the document output
// ---------------------------------------------------
- function render($resource, $template, $removeChunk,$dateSource,$dateFormat,$ph=array(),$phx=1,$x=0,$stop=1) {
+ function render($doc, $template, $removeChunk,$dateSource,$dateFormat,$customPlaceholders=array(),$phx=1,$x=0,$stop=1) {
global $modx,$ditto_lang;
- if (!is_array($resource)) {
- return $ditto_lang["resource_array_error"];
- }
- $placeholders = array();
+ if (!is_array($doc)) return $ditto_lang['resource_array_error'];
+
+ $ph = $doc;
$contentVars = array();
- foreach ($resource as $name=>$value) {
- $placeholders["$name"] = $value;
- $contentVars["[*$name*]"] = $value;
- }
-
- // set author placeholder
- if (in_array("author",$this->fields["display"]["custom"])) {
- $placeholders['author'] = $this->getAuthor($resource['createdby']);
- }
-
- // set title placeholder
- if (in_array("title",$this->fields["display"]["custom"])) {
- $placeholders['title'] = $resource['pagetitle'];
+ $exFields =& $this->fields['display']['custom'];
+
+ foreach ($doc as $name=>$value) {
+ $contentVars["[*{$name}*]"] = $value;
}
- // set sequence placeholder
- if (in_array("ditto_iteration",$this->fields["display"]["custom"])) {
- $placeholders['ditto_iteration'] = $x;
- }
+ if (in_array('author',$exFields)) $ph['author'] = $this->getAuthor($doc['createdby']);
+ if (in_array('title',$exFields)) $ph['title'] = $doc['pagetitle'];
+ if (in_array('ditto_iteration',$exFields)) $ph['ditto_iteration'] = $x;
//Added by Andchir
- //if (in_array("ditto_index",$this->fields["display"]["custom"])) {
- $r_start = isset($_GET['start']) ? $_GET['start'] : 0;
- $placeholders['ditto_index'] = $r_start+$x+1;
- //}
+ $r_start = isset($_GET['start']) ? $_GET['start'] : 0;
+ $ph['ditto_index'] = $r_start+$x+1;
//Added by Dmi3yy placeholder ditto_class
- if ($x % 2 == 0) {$class="even";} else {$class="odd";}
- if ($x==0) $class.=" first";
- if ($x==($stop -1)) $class.=" last";
- if ($resource['id'] == $modx->documentObject['id']) $class.=" current";
- $placeholders['ditto_class'] = $class;
+ $class = array();
+ if($x % 2 == 0) $class[] = 'even';
+ else $class[] = 'odd';
+
+ if ($x==0) $class[] = 'first';
+ if ($x==($stop -1)) $class[] = 'last';
+ if ($doc['id'] == $modx->documentIdentifier) $class[] = 'current';
+ $ph['ditto_class'] = join(' ', $class);
// set url placeholder
- if (in_array("url",$this->fields["display"]["custom"])) {
- if($resource['id']==$modx->config['site_start'])
- $placeholders['url'] = $modx->config['site_url'];
- else
- $placeholders['url'] = $modx->makeURL($resource['id'],'','','full');
+ if (in_array('url',$exFields)) {
+ if($doc['id']==$modx->config['site_start']) $ph['url'] = $modx->config['site_url'];
+ else $ph['url'] = $modx->makeURL($doc['id'],'','','full');
}
- if (in_array("date",$this->fields["display"]["custom"])) {
- $timestamp = ($resource[$dateSource] != "0") ? $resource[$dateSource] : $resource["createdon"];
+ if (in_array('date',$exFields)) {
+ $timestamp = ($doc[$dateSource] != '0') ? $doc[$dateSource] : $doc['createdon'];
if (is_array($timestamp)) {
- $timestamp[1] = is_int($timestamp[1]) ? $timestamp[1] : strtotime($timestamp[1]);
+ if(!$this->isNum($timestamp[1])) $timestamp[1] = strtotime($timestamp[1]);
$timestamp = $timestamp[1] + $timestamp[0];
}
- $placeholders['date'] = strftime($dateFormat,$timestamp);
+ $ph['date'] = strftime($dateFormat,$timestamp);
}
- if (in_array("content",$this->fields["display"]["db"]) && $this->format != "html") {
- $placeholders['content'] = $this->relToAbs($resource['content'], $modx->config['site_url']);
+ if (in_array('content',$this->fields['display']['db']) && $this->format != 'html') {
+ $ph['content'] = $this->relToAbs($doc['content'], $modx->config['site_url']);
}
- if (in_array("introtext",$this->fields["display"]["db"]) && $this->format != "html") {
- $placeholders['introtext'] = $this->relToAbs($resource['introtext'], $modx->config['site_url']);
+ if (in_array('introtext',$this->fields['display']['db']) && $this->format != 'html') {
+ $ph['introtext'] = $this->relToAbs($doc['introtext'], $modx->config['site_url']);
}
- $customPlaceholders = $ph;
// set custom placeholder
- foreach ($ph as $name=>$value) {
- if ($name != "*") {
- $placeholders[$name] = call_user_func($value[1],$resource);
+ foreach ($customPlaceholders as $name=>$value) {
+ if ($name != '*') {
+ $ph[$name] = call_user_func($value[1],$doc);
unset($customPlaceholders[$name]);
}
}
foreach ($customPlaceholders as $name=>$value) {
- $placeholders = call_user_func($value,$placeholders);
+ $ph = call_user_func($value,$ph);
}
- if (count($this->fields["display"]['qe']) > 0) {
- $placeholders = $this->renderQELinks($this->template->fields['qe'],$resource,$ditto_lang["edit"]." : ".$resource['pagetitle']." : ",$placeholders);
- // set QE Placeholders
+ if ($phx) $output = $this->parseModifiers($template,$ph,$contentVars);
+ else {
+ $output = $this->template->replace($ph,$template);
+ $output = $this->template->replace($contentVars,$output);
}
- if ($phx == 1 && !$modx->config['enable_filter']) {
- $PHs = $placeholders;
- foreach($PHs as $key=>$output) {
- $placeholders[$key] = str_replace( array_keys( $contentVars ), array_values( $contentVars ), $output );
+ if ($removeChunk) {
+ foreach ($removeChunk as $chunk) {
+ $output = str_replace('{{'.$chunk.'}}','',$output);
+ $output = str_replace($modx->getChunk($chunk),'',$output);
+ // remove chunk that is not wanted
}
- unset($PHs);
- $phx = new prePHx($template);
- $phx->setPlaceholders($placeholders);
- $output = $phx->output();
}
- elseif ($phx == 1 && $modx->config['enable_filter']) {
- $output = $template;
+ return $output;
+ }
+
+ function parseModifiers($tpl,$ph,$contentVars){
+ global $modx;
+ if ($modx->config['enable_filter']) {
+ $content = $tpl;
$i = 0;
while($i<10) {
- $_ = $output;
- $output = $modx->parseText($output,$placeholders);
- if($_===$output) break;
+ $bt = $content;
+ if(strpos($content,'[+')!==false) $content = $modx->parseText($content,$ph);
+ else $content = $modx->parseDocumentSource($content);
+ if($bt===$content) break;
$i++;
}
- } else {
- $output = $this->template->replace($placeholders,$template);
- $output = $this->template->replace($contentVars,$output);
}
- if ($removeChunk) {
- foreach ($removeChunk as $chunk) {
- $output = str_replace('{{'.$chunk.'}}',"",$output);
- $output = str_replace($modx->getChunk($chunk),"",$output);
- // remove chunk that is not wanted
+ else {
+ foreach($ph as $key=>$content) {
+ $ph[$key] = str_replace( array_keys($contentVars), array_values($contentVars), $content );
}
+ $phx = new prePHx($tpl);
+ $phx->setPlaceholders($ph);
+ $content = $phx->output();
}
-
- return $output;
+ return $content;
}
// ---------------------------------------------------
@@ -380,17 +351,17 @@ function parseFields($placeholders,$seeThruUnpub,$dateSource,$randomize) {
$this->parseCustomPlaceholders($placeholders);
$this->parseDBFields($seeThruUnpub);
if ($randomize != 0) {
- $this->addField($randomize,"backend");
+ $this->addField($randomize,'backend');
}
- $this->addField("id","display","db");
- $this->addField("pagetitle","display","db");
- $this->addField("parent","display","db");
- $checkOptions = array("pub_date","unpub_date","editedon","deletedon","publishedon");
+ $this->addField('id','display','db');
+ $this->addField('pagetitle','display','db');
+ $this->addField('parent','display','db');
+ $checkOptions = array('pub_date','unpub_date','editedon','deletedon','publishedon');
if (in_array($dateSource,$checkOptions)) {
- $this->addField("createdon","display");
+ $this->addField('createdon','display');
}
- if (in_array("date",$this->fields["display"]["custom"])) {
- $this->addField($dateSource,"display");
+ if (in_array('date',$this->fields['display']['custom'])) {
+ $this->addField($dateSource,'display');
}
$this->fields = $this->arrayUnique($this->fields);
}
@@ -417,34 +388,28 @@ function arrayUnique($array) {
function parseCustomPlaceholders($placeholders) {
foreach ($placeholders as $name=>$value) {
- $this->addField($name,"display","custom");
- $this->removeField($name,"display","unknown");
+ $this->addField($name,'display','custom');
+ $this->removeField($name,'display','unknown');
$source = $value[0];
- $qe = isset($value[2]) ? $value[2] : '';
if(is_array($source)) {
- if(strpos($source[0],",")!==false){
+ if(strpos($source[0],',')!==false){
$fields = array_filter(array_map('trim', explode(',', $source[0])));
foreach ($fields as $field) {
- $this->addField($field,$source[1]);
- $this->customPlaceholdersMap[$name] = $field;
+ $this->addField($field,$source[1]);
+ $this->customPlaceholdersMap[$name] = $field;
}
} else {
$this->addField($source[0],$source[1]);
$this->customPlaceholdersMap[$name] = $source[0];
} // TODO: Replace addField with addFields with callback
- } else if(is_array($value)) {
+ } elseif(is_array($value)) {
$fields = array_filter(array_map('trim', explode(',', $source)));
foreach ($fields as $field) {
- $this->addField($field,"display");
- $this->customPlaceholdersMap[$name] = $field;
+ $this->addField($field,'display');
+ $this->customPlaceholdersMap[$name] = $field;
}
}
-
- if (!is_null($qe)) {
- $this->customPlaceholdersMap[$name] = array('qe',$qe);
- }
-
}
}
@@ -455,58 +420,16 @@ function parseCustomPlaceholders($placeholders) {
function parseDBFields($seeThruUnpub) {
if (!$seeThruUnpub) {
- $this->addField("parent","backend","db");
+ $this->addField('parent','backend','db');
}
- if (in_array("author",$this->fields["display"]["custom"])) {
- $this->fields["display"]["db"][] = "createdby";
+ if (in_array('author',$this->fields['display']['custom'])) {
+ $this->fields['display']['db'][] = 'createdby';
}
- if (count($this->fields["display"]["tv"]) >= 0) {
- $this->addField("published","display","db");
- }
- }
-
- // ---------------------------------------------------
- // Function: renderQELinks
- // Render QE links when needed
- // ---------------------------------------------------
-
- function renderQELinks($fields, $resource, $QEPrefix,$placeholders) {
- global $modx,$dittoID;
- $table = $modx->getFullTableName("site_modules");
- $idResult = $modx->db->select("id", $table,"name='QuickEdit'","id","1");
- $id = $modx->db->getValue($idResult);
- $custom = array("author","date","url","title");
- $set = $modx->hasPermission('exec_module');
- foreach ($fields as $dv) {
- $ds = $dv;
- if ($dv == "title") {
- $ds = "pagetitle";
- }
- if (!in_array($dv,$custom) && in_array($dv,$this->fields["display"]["custom"])) {
- $value = $this->customPlaceholdersMap[$dv];
- $ds = $value;
- if (is_array($value) && $value[0] == "qe") {
- $value = $value[1];
- if (substr($value,0,7) == "@GLOBAL") {
- $key = trim(substr($value,7));
- $ds = $GLOBALS[$key];
- }
- }
- }
-
- $js = "window.open('".MODX_MANAGER_URL."index.php?a=112&id=".$id."&doc=".$resource["id"]."&var=".$ds."', 'QuickEditor', 'width=525, height=300, toolbar=0, menubar=0, status=0, alwaysRaised=1, dependent=1');";
- $url = $this->buildURL("qe_open=true",$modx->documentIdentifier,$dittoID);
-
- unset($custom[3]);
- if ($set && !in_array($dv,$custom)) {
- $placeholders["#$dv"] = $placeholders["$dv"].'« '.$QEPrefix.$dv.'';
- } else {
- $placeholders["#$dv"] = $placeholders["$dv"];
- }
+ if (count($this->fields['display']['tv']) >= 0) {
+ $this->addField('published','display','db');
}
- return $placeholders;
}
// ---------------------------------------------------
@@ -527,7 +450,7 @@ public static function getAuthor($createdby) {
// get admin user name
$user = $modx->getUserInfo(1);
}
- return ($user['fullname'] != "") ? $user['fullname'] : $user['username'];
+ return ($user['fullname'] != '') ? $user['fullname'] : $user['username'];
}
// ---------------------------------------------------
@@ -540,10 +463,11 @@ function customSort($data, $fields, $order) {
// user contributed
$sortfields = array_filter(array_map('trim', explode(',', $fields)));
- $code = "";
- for ($c = 0; $c < count($sortfields); $c++)
- $code .= "\$retval = strnatcmp(\$a['$sortfields[$c]'], \$b['$sortfields[$c]']); if(\$retval) return \$retval; ";
- $code .= "return \$retval;";
+ $code = '';
+ foreach($sortfields as $field) {
+ $code .= sprintf('$retval = strnatcmp($a["%s"], $b["%s"]); if($retval) return $retval; ',$field,$field);
+ }
+ $code .= 'return $retval;';
$params = ($order == 'ASC') ? '$a,$b' : '$b,$a';
uasort($data, create_function($params, $code));
@@ -570,17 +494,17 @@ function userSort($resource,$sort) {
function multiSort($resource,$orderBy) {
$sort_arr = array();
- foreach($resource AS $uniqid => $row){
- foreach($row AS $key=>$value){
+ foreach($resource as $uniqid => $row){
+ foreach($row as $key=>$value){
$sort_arr[$key][$uniqid] = $value;
}
}
- $array_multisort = 'return array_multisort(';
+ $_ ='';
foreach ($orderBy['parsed'] as $sort) {
- $array_multisort .= '$sort_arr["'.$sort[0].'"], SORT_'.$sort[1].', ';
+ $_ .= sprintf('$sort_arr["%s"], SORT_%s, ', $sort[0], $sort[1]);
}
- $array_multisort .= '$resource);';
+ $array_multisort = sprintf('return array_multisort( %s $resource);', $_);
eval($array_multisort);
return $resource;
}
@@ -592,29 +516,29 @@ function multiSort($resource,$orderBy) {
function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly, $seeThruUnpub, $hideFolders, $hidePrivate, $showInMenuOnly, $myWhere, $dateSource, $limit, $summarize, $filter, $paginate, $randomize) {
global $modx;
- if (($summarize == 0 && $summarize != "all") || count($IDs) == 0 || ($IDs == false && $IDs != "0")) {
+ if (($summarize == 0 && $summarize != 'all') || count($IDs) == 0 || ($IDs == false && $IDs != '0')) {
return array();
}
// Get starting IDs;
switch($IDType) {
- case "parents":
- $IDs = explode(",",$IDs);
+ case 'parents':
+ $IDs = explode(',',$IDs);
$documentIDs = $this->getChildIDs($IDs, $depth);
break;
- case "documents":
+ case 'documents':
if(!preg_match('@^[0-9, ]*$@',$IDs)) exit(sprintf('Illegal value of &documents: %s', $IDs));
- $documentIDs = explode(",",$IDs);
+ $documentIDs = explode(',',$IDs);
break;
}
- if ($this->advSort == false && $hideFolders==0 && $showInMenuOnly==0 && $myWhere == "" && $filter == false && $hidePrivate == 1) {
+ if ($this->advSort == false && $hideFolders==0 && $showInMenuOnly==0 && $myWhere == '' && $filter == false && $hidePrivate == 1) {
$this->prefetch = false;
$documents = $this->getDocumentsIDs($documentIDs, $showPublishedOnly);
$documentIDs = array();
if ($documents) {
foreach ($documents as $null=>$doc) {
- $documentIDs[] = $doc["id"];
+ $documentIDs[] = $doc['id'];
}
}
return $documentIDs;
@@ -633,15 +557,15 @@ function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly,
if ($showInMenuOnly) {
$where[] = 'hidemenu = 0';
}
- $where = implode(" AND ", $where);
- $limit = ($limit == 0) ? "" : $limit;
+ $where = join(' AND ', $where);
+ $limit = ($limit == 0) ? '' : $limit;
// set limit
$customReset = $this->customReset;
- if ($this->debug) {$this->addField("pagetitle","backend","db");}
+ if ($this->debug) {$this->addField('pagetitle','backend','db');}
- if (count($customReset) > 0) {$this->addField("createdon","backend","db");}
- $resource = $this->getDocuments($documentIDs,$this->fields["backend"]["db"],$TVs,$orderBy,$showPublishedOnly,0,$hidePrivate,$where,$limit,$randomize,$dateSource);
+ if (count($customReset) > 0) {$this->addField('createdon','backend','db');}
+ $resource = $this->getDocuments($documentIDs,$this->fields['backend']['db'],$TVs,$orderBy,$showPublishedOnly,0,$hidePrivate,$where,$limit,$randomize,$dateSource);
// EPO - End of change (then see line 692 - if ($limit) array_slice($resource, 0, $limit); )
@@ -657,14 +581,14 @@ function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly,
}
for ($i = 0; $i < $recordCount; $i++) {
if (!$seeThruUnpub) {
- $published = $parentList[$resource[$i]["parent"]];
- if ($published == "0")
+ $published = $parentList[$resource[$i]['parent']];
+ if ($published == '0')
unset ($resource[$i]);
}
if (count($customReset) > 0) {
foreach ($customReset as $field) {
- if ($resource[$i][$field] === "0") {
- $resource[$i][$field] = $resource[$i]["createdon"];
+ if ($resource[$i][$field] === '0') {
+ $resource[$i][$field] = $resource[$i]['createdon'];
}
}
}
@@ -686,9 +610,9 @@ function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly,
}
//intersel - see above in order to limit the array to $limit.
- if ($limit) $resource=array_slice($resource, 0, $limit);
+ if ($limit) $resource=array_slice($resource, 0, $limit);
- $fields = (array_intersect($this->fields["backend"],$this->fields["display"]));
+ $fields = (array_intersect($this->fields['backend'],$this->fields['display']));
$readyFields = array();
foreach ($fields as $field) {
$readyFields = array_merge($readyFields,$field);
@@ -702,7 +626,7 @@ function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly,
if (in_array($key,$readyFields)) {
$keep[$iKey][$key] = $v;
}
- if ($this->getDocVarType($key) == "tv:prefix") {
+ if ($this->getDocVarType($key) == 'tv:prefix') {
if (in_array(substr($key,2),$readyFields)) {
$keep[$iKey][$key] = $v;
}
@@ -710,11 +634,11 @@ function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly,
}
}
- $this->prefetch = array("resource"=>$keep,"fields"=>$fields);
+ $this->prefetch = array('resource'=>$keep,'fields'=>$fields);
if ($this->debug) {
- $this->prefetch["dbg_resource"] = $dbg_resource;
- $this->prefetch["dbg_IDs_pre"] = $documentIDs;
- $this->prefetch["dbg_IDs_post"] = $processedIDs;
+ $this->prefetch['dbg_resource'] = $dbg_resource;
+ $this->prefetch['dbg_IDs_pre'] = $documentIDs;
+ $this->prefetch['dbg_IDs_post'] = $processedIDs;
}
if (count($processedIDs) > 0) {
if ($randomize != 0) {shuffle($processedIDs);}
@@ -735,7 +659,7 @@ function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly,
function weightedRandom($resource,$field,$show) {
$type = $this->getDocVarType($field);
- if ($type == "unknown") {
+ if ($type == 'unknown') {
return $resource;
// handle vad field passed
}
@@ -766,11 +690,11 @@ function getParentList() {
$parents = array();
foreach ($kids as $item => $value) {
if ($item != 0) {
- $pInfo = $modx->getPageInfo($item,0,"published");
+ $pInfo = $modx->getPageInfo($item,0,'published');
} else {
- $pInfo["published"] = "1";
+ $pInfo['published'] = '1';
}
- $parents[$item] = $pInfo["published"];
+ $parents[$item] = $pInfo['published'];
}
return $parents;
}
@@ -780,49 +704,47 @@ function getParentList() {
// Apeend a TV to the documents array
// ---------------------------------------------------
- function appendTV($tvname="",$docIDs){
+ function appendTV($tvname='',$docIDs){
global $modx;
- $baspath= MODX_MANAGER_PATH."/includes";
- include_once $baspath . "/tmplvars.format.inc.php";
- include_once $baspath . "/tmplvars.commands.inc.php";
+ $baspath= MODX_MANAGER_PATH.'/includes';
+ include_once $baspath . '/tmplvars.format.inc.php';
+ include_once $baspath . '/tmplvars.commands.inc.php';
- $tb1 = $modx->getFullTableName("site_tmplvar_contentvalues");
- $tb2 = $modx->getFullTableName("site_tmplvars");
+ $fields = 'stv.name,stc.tmplvarid,stc.contentid,stv.type,stv.display,stv.display_params,stc.value';
+ $from[] = '[+prefix+]site_tmplvar_contentvalues AS stc';
+ $from[] = 'LEFT JOIN [+prefix+]site_tmplvars AS stv ON stv.id=stc.tmplvarid';
+ $where = sprintf("stv.name='%s' AND stc.contentid IN (%s)", $modx->db->escape($tvname), join($docIDs,','));
+ $rs= $modx->db->select($fields, $from, $where, 'stc.contentid ASC');
- $rs= $modx->db->select(
- "stv.name,stc.tmplvarid,stc.contentid,stv.type,stv.display,stv.display_params,stc.value",
- "{$tb1} AS stc LEFT JOIN {$tb2} AS stv ON stv.id=stc.tmplvarid",
- "stv.name='{$tvname}' AND stc.contentid IN (".implode($docIDs,",").")",
- "stc.contentid ASC"
- );
- $resourceArray = array();
+ $docs = array();
while ($row = $modx->db->getRow($rs)) {
- $resourceArray["#".$row['contentid']][$row['name']] = getTVDisplayFormat($row['name'], $row['value'], $row['display'], $row['display_params'], $row['type'],$row['contentid']);
- $resourceArray["#".$row['contentid']]["tv".$row['name']] = $resourceArray["#".$row['contentid']][$row['name']];
+ $docs["#".$row['contentid']][$row['name']] = getTVDisplayFormat($row['name'], $row['value'], $row['display'], $row['display_params'], $row['type'],$row['contentid']);
+ $docs["#".$row['contentid']]["tv".$row['name']] = $docs["#".$row['contentid']][$row['name']];
}
- if (count($resourceArray) != count($docIDs)) {
- $rs = $modx->db->select("id,name,type,display,display_params,default_text", $tb2, "name='{$tvname}'", '', 1);
+ if (count($docs) != count($docIDs)) {
+ $rs = $modx->db->select("name,type,display,display_params,default_text", '[+prefix+]site_tmplvars', "name='{$tvname}'", '', 1);
$row = $modx->db->getRow($rs);
if (strtoupper($row['default_text']) == '@INHERIT') {
foreach ($docIDs as $id) {
$defaultOutput = getTVDisplayFormat($row['name'], $row['default_text'], $row['display'], $row['display_params'], $row['type'], $id);
if (!isset($resourceArray["#".$id])) {
- $resourceArray["#$id"][$tvname] = $defaultOutput;
- $resourceArray["#$id"]["tv".$tvname] = $resourceArray["#$id"][$tvname];
+ $docs["#$id"][$tvname] = $defaultOutput;
+ $docs["#$id"]["tv".$tvname] = $docs["#$id"][$tvname];
}
}
} else {
- $defaultOutput = getTVDisplayFormat($row['name'], $row['default_text'], $row['display'], $row['display_params'], $row['type'],$row['id']);
+ $row['contentid'] = isset($row['contentid']) ? $row['contentid'] : '';
+ $defaultOutput = getTVDisplayFormat($row['name'], $row['default_text'], $row['display'], $row['display_params'], $row['type'],$row['contentid']);
foreach ($docIDs as $id) {
- if (!isset($resourceArray["#".$id])) {
- $resourceArray["#$id"][$tvname] = $defaultOutput;
- $resourceArray["#$id"]["tv".$tvname] = $resourceArray["#$id"][$tvname];
+ if (!isset($docs["#".$id])) {
+ $docs["#$id"][$tvname] = $defaultOutput;
+ $docs["#$id"]["tv".$tvname] = $docs["#$id"][$tvname];
}
}
}
}
- return $resourceArray;
+ return $docs;
}
// ---------------------------------------------------
@@ -849,7 +771,7 @@ function getChildIDs($IDs, $depth) {
// Get documents and append TVs + Prefetch Data, and sort
// ---------------------------------------------------
- function getDocuments($ids= array (), $fields, $TVs, $orderBy, $published= 1, $deleted= 0, $public= 1, $where= '', $limit='',$randomize=0,$dateSource=false) {
+ function getDocuments($ids= array (), $fields, $TVs, $orderBy, $published= 1, $deleted= 0, $pubOnly= 1, $where= '', $limit='',$randomize=0,$dateSource=false) {
global $modx;
if (count($ids) == 0) return false;
@@ -857,7 +779,7 @@ function getDocuments($ids= array (), $fields, $TVs, $orderBy, $published= 1, $d
// modify field names to use sc. table reference
$fields= 'sc.'.join(',sc.',$fields);
- if ($randomize != 0) $sort = 'RAND()';
+ if ($randomize != 0) $sort = 'RAND()';
else $sort= $orderBy['sql'];
//Added by Andchir (http://modx-shopkeeper.ru/)
@@ -869,52 +791,55 @@ function getDocuments($ids= array (), $fields, $TVs, $orderBy, $published= 1, $d
$left_join_tvc = '';
}
- if ($public) {
+ if ($pubOnly) {
if($modx->isFrontend()) $access = 'sc.privateweb=0';
elseif($_SESSION['mgrRole']!=1) $access = 'sc.privatemgr=0';
else $access = '';
- // get document groups for current user
- if ($docgrp= $modx->getUserDocGroups()) {
- if($access) $access .= ' OR ';
- $docgrp= join(',', $docgrp);
- $access .= "dg.document_group IN ({$docgrp})";
- }
+
+ if($access) {
+ $docgrp=$modx->getUserDocGroups();
+ if($docgrp) {
+ $access .= sprintf(' OR dg.document_group IN (%s)', join(',', $docgrp));
+ $access = "({$access})";
+ }
+ }
}
- $published = ($published) ? 'AND sc.published=1' : '';
+ $published = ($published) ? 'AND sc.published=1' : '';
$from = array();
$from[] = "[+prefix+]site_content AS sc {$left_join_tvc}";
$from[] = 'LEFT JOIN [+prefix+]document_groups dg on dg.document = sc.id';
$sqlWhere = array();
- $sqlWhere[] = 'sc.id IN (' . join(',', $ids) . ')';
- $sqlWhere[] =$published;
- $sqlWhere[] ="AND sc.deleted='{$deleted}'";
+ $sqlWhere[] = sprintf('sc.id IN (%s)', join(',', $ids));
+ $sqlWhere[] = $published;
+ $sqlWhere[] = "AND sc.deleted='{$deleted}'";
$sqlWhere[] = $where;
- if($public) $sqlWhere[] = "AND ({$access})";
+ if($pubOnly && $access) $sqlWhere[] = "AND {$access}";
$sqlWhere[] = 'GROUP BY sc.id';
$rs= $modx->db->select("DISTINCT {$fields}",$from,$sqlWhere,$sort,$limit);
if(!$modx->db->getRecordCount($rs)) return false;
- $resourceArray= array ();
+ $docs = array();
$TVData = array();
- $TVIDs = array();
- while ($resource = $modx->db->getRow($rs)) {
+ $TVIDs = array();
+ while ($doc = $modx->db->getRow($rs)) {
if ($dateSource !== false) {
- if(!is_int($resource[$dateSource])) $resource[$dateSource] = strtotime($resource[$dateSource]);
+ if(!$this->isNum($doc[$dateSource])) $doc[$dateSource] = strtotime($doc[$dateSource]);
if($modx->config['server_offset_time'] != 0)
- $resource[$dateSource] += $modx->config['server_offset_time'];
+ $doc[$dateSource] += $modx->config['server_offset_time'];
}
- if ($this->prefetch == true && $this->sortOrder !== false)
- $resource['ditto_sort'] = $this->sortOrder[$resource['id']];
- $TVIDs[] = $resource['id'];
- $resourceArray['#'.$resource['id']] = $resource;
+ if ($this->prefetch && $this->sortOrder!==false) $doc['ditto_sort'] = $this->sortOrder[$doc['id']];
+
+ $k = '#'.$doc['id'];
if (count($this->prefetch['resource']) > 0) {
- $x = '#'.$resource['id'];
- $resourceArray[$x] = array_merge($resource,$this->prefetch['resource'][$x]);
+ $docs[$k] = array_merge($doc,$this->prefetch['resource'][$k]);
// merge the prefetch array and the normal array
}
+ else $docs[$k] = $doc;
+
+ $TVIDs[] = $doc['id'];
}
$TVs = array_unique($TVs);
@@ -924,11 +849,11 @@ function getDocuments($ids= array (), $fields, $TVs, $orderBy, $published= 1, $d
}
}
- $resourceArray = array_merge_recursive($resourceArray,$TVData);
+ $docs = array_merge_recursive($docs,$TVData);
if ($this->prefetch == true && $this->sortOrder !== false)
- $resourceArray = $this->customSort($resourceArray,'ditto_sort','ASC');
+ $docs = $this->customSort($docs,'ditto_sort','ASC');
- return $resourceArray;
+ return $docs;
}
// ---------------------------------------------------
@@ -941,16 +866,29 @@ function getDocumentsIDs($ids= array (), $published= 1) {
if (count($ids) == 0) {
return false;
} else {
- $tblsc= $modx->getFullTableName("site_content");
- $tbldg= $modx->getFullTableName("document_groups");
- if ($docgrp= $modx->getUserDocGroups())
- $docgrp= implode(",", $docgrp);
- $access= ($modx->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") .
- (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
- $published = ($published) ? "AND sc.published=1" : "";
- $result= $modx->db->select("DISTINCT sc.id", "{$tblsc} sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(sc.id IN (" . implode(',', $ids) . ") $published AND sc.deleted=0) AND ({$access}) GROUP BY sc.id");
- $resourceArray = $modx->db->makeArray($result);
- return $resourceArray;
+ $ids = join(',',$ids);
+ $from[] = '[+prefix+]site_content sc';
+ $from[] = 'LEFT JOIN [+prefix+]document_groups dg on dg.document=sc.id';
+ $published = $published ? 'AND sc.published=1' : '';
+ if($modx->isFrontend()) $access = 'sc.privateweb=0';
+ elseif($_SESSION['mgrRole']!=1) $access = 'sc.privatemgr=0';
+ else $access = '';
+
+ if($access) {
+ $docgrp=$modx->getUserDocGroups();
+ if($docgrp) {
+ $access .= sprintf(' OR dg.document_group IN (%s)', join(',', $docgrp));
+ $access = "({$access})";
+ }
+ $access = "AND {$access}";
+ }
+
+ if($published) $where = sprintf('(sc.id IN (%s) AND sc.published=1 AND sc.deleted=0) %s GROUP BY sc.id', $ids, $access);
+ else $where = sprintf('(sc.id IN (%s) AND sc.deleted=0) %s GROUP BY sc.id', $ids, $access);
+
+ $rs= $modx->db->select('DISTINCT sc.id', $from, $where);
+ $docs = $modx->db->makeArray($rs);
+ return $docs;
}
}
@@ -991,9 +929,9 @@ public static function buildURL($args,$id=false,$dittoIdentifier=false) {
}
}
if (!is_array($args)) {
- $args = explode("&",$args);
+ $args = explode('&',$args);
foreach ($args as $arg) {
- $arg = explode("=",$arg);
+ $arg = explode('=',$arg);
$query[$dittoID.$arg[0]] = rawurlencode(trim($arg[1]));
}
} else {
@@ -1001,12 +939,12 @@ public static function buildURL($args,$id=false,$dittoIdentifier=false) {
$query[$dittoID.$name] = rawurlencode(trim($value));
}
}
- $queryString = "";
+ $queryString = '';
foreach ($query as $param=>$value) {
- //$queryString .= '&'.$param.'='.(is_array($value) ? implode(",",$value) : $value);
+ //$queryString .= '&'.$param.'='.(is_array($value) ? join(',',$value) : $value);
if (!is_array($value)) {
- if (!($modx->config['seostrict']=='1' and $param == $dittoID."start" and !$value)) $queryString .= '&'.$param.'='.$value;
+ if (!($modx->config['seostrict']=='1' && $param == $dittoID.'start' && !$value)) $queryString .= '&'.$param.'='.$value;
}
else {
foreach ($value as $key=>$val) {
@@ -1016,7 +954,7 @@ public static function buildURL($args,$id=false,$dittoIdentifier=false) {
}
$cID = ($id !== false) ? $id : $modx->documentObject['id'];
$url = $modx->makeURL(trim($cID), '', $queryString);
- return ($modx->config['xhtml_urls']) ? $url : str_replace("&","&",$url);
+ return ($modx->config['xhtml_urls']) ? $url : str_replace('&','&',$url);
}
// ---------------------------------------------------
@@ -1027,10 +965,10 @@ public static function buildURL($args,$id=false,$dittoIdentifier=false) {
function getParam($param,$langString){
// get a parameter value and if it is not set get the default language string value
global $modx,$ditto_lang;
- $output = "";
+ $output = '';
if (substr($param,0,1)==='@') {
$output = $this->template->fetch($param);
- } else if(!empty($param)) {
+ } elseif(!empty($param)) {
$output = $modx->getChunk($param);
} else {
$output = $ditto_lang[$langString];
@@ -1059,10 +997,10 @@ function paginate($start, $stop, $total, $summarize, $tplPaginateNext, $tplPagin
$previousplaceholder = $this->template->replace(array('lang:previous'=>$ditto_lang['prev']),$tplPaginatePreviousOff);
$nextplaceholder = $this->template->replace(array('lang:next'=>$ditto_lang['next']),$tplPaginateNextOff);
} else {
- $previousplaceholder = "";
- $nextplaceholder = "";
+ $previousplaceholder = '';
+ $nextplaceholder = '';
}
- $split = "";
+ $split = '';
if ($previous > -1 && $next < $total)
$split = $paginateSplitterCharacter;
if ($previous > -1)
@@ -1089,7 +1027,7 @@ function paginate($start, $stop, $total, $summarize, $tplPaginateNext, $tplPagin
$min_x = $max_x - $max_paginate + 1;
}
- $modx->setPlaceholder("dittoID", $dittoID);
+ $modx->setPlaceholder('dittoID', $dittoID);
$pages = '';
for ($x = 0; $x <= $totalpages -1; $x++) {
$inc = $x * $summarize;
@@ -1100,27 +1038,27 @@ function paginate($start, $stop, $total, $summarize, $tplPaginateNext, $tplPagin
if ($inc != $start) {
$pages .= $this->template->replace(array('url'=>$this->buildURL("start=$inc"),'page'=>$display),$tplPaginatePage);
} else {
- $modx->setPlaceholder($dittoID."currentPage", $display);
+ $modx->setPlaceholder($dittoID.'currentPage', $display);
$pages .= $this->template->replace(array('page'=>$display),$tplPaginateCurrentPage);
}
}
if ($totalpages>1){
- $modx->setPlaceholder($dittoID."next", $nextplaceholder);
- $modx->setPlaceholder($dittoID."previous", $previousplaceholder);
- $modx->setPlaceholder($dittoID."pages", $pages);
+ $modx->setPlaceholder($dittoID.'next', $nextplaceholder);
+ $modx->setPlaceholder($dittoID.'previous', $previousplaceholder);
+ $modx->setPlaceholder($dittoID.'pages', $pages);
}elseif($paginateAlwaysShowLinks == 1){
- $modx->setPlaceholder($dittoID."next", $nextplaceholder);
- $modx->setPlaceholder($dittoID."previous", $previousplaceholder);
- $modx->setPlaceholder($dittoID."pages", $pages);
+ $modx->setPlaceholder($dittoID.'next', $nextplaceholder);
+ $modx->setPlaceholder($dittoID.'previous', $previousplaceholder);
+ $modx->setPlaceholder($dittoID.'pages', $pages);
}
- $modx->setPlaceholder($dittoID."splitter", $split);
- $modx->setPlaceholder($dittoID."start", $start +1);
- $modx->setPlaceholder($dittoID."urlStart", $start);
- $modx->setPlaceholder($dittoID."stop", $limiter);
- $modx->setPlaceholder($dittoID."total", $total);
- $modx->setPlaceholder($dittoID."perPage", $summarize);
- $modx->setPlaceholder($dittoID."totalPages", $totalpages);
- $modx->setPlaceholder($dittoID."ditto_pagination_set", true);
+ $modx->setPlaceholder($dittoID.'splitter', $split);
+ $modx->setPlaceholder($dittoID.'start', $start +1);
+ $modx->setPlaceholder($dittoID.'urlStart', $start);
+ $modx->setPlaceholder($dittoID.'stop', $limiter);
+ $modx->setPlaceholder($dittoID.'total', $total);
+ $modx->setPlaceholder($dittoID.'perPage', $summarize);
+ $modx->setPlaceholder($dittoID.'totalPages', $totalpages);
+ $modx->setPlaceholder($dittoID.'ditto_pagination_set', true);
}
// ---------------------------------------------------
@@ -1129,24 +1067,24 @@ function paginate($start, $stop, $total, $summarize, $tplPaginateNext, $tplPagin
// ---------------------------------------------------
function noResults($text,$paginate) {
global $modx, $dittoID;
- $set = $modx->getPlaceholder($dittoID."ditto_pagination_set");
+ $set = $modx->getPlaceholder($dittoID.'ditto_pagination_set');
if ($paginate && $set !== true) {
- $modx->setPlaceholder("dittoID", $dittoID);
- $modx->setPlaceholder($dittoID."next", "");
- $modx->setPlaceholder($dittoID."previous", "");
- $modx->setPlaceholder($dittoID."splitter", "");
- $modx->setPlaceholder($dittoID."start", 0);
- $modx->setPlaceholder($dittoID."urlStart", "#start");
- $modx->setPlaceholder($dittoID."stop", 0);
- $modx->setPlaceholder($dittoID."total", 0);
- $modx->setPlaceholder($dittoID."pages", "");
- $modx->setPlaceholder($dittoID."perPage", 0);
- $modx->setPlaceholder($dittoID."totalPages", 0);
- $modx->setPlaceholder($dittoID."currentPage", 0);
+ $modx->setPlaceholder('dittoID', $dittoID);
+ $modx->setPlaceholder($dittoID.'next', '');
+ $modx->setPlaceholder($dittoID.'previous', '');
+ $modx->setPlaceholder($dittoID.'splitter', '');
+ $modx->setPlaceholder($dittoID.'start', 0);
+ $modx->setPlaceholder($dittoID.'urlStart', '#start');
+ $modx->setPlaceholder($dittoID.'stop', 0);
+ $modx->setPlaceholder($dittoID.'total', 0);
+ $modx->setPlaceholder($dittoID.'pages', '');
+ $modx->setPlaceholder($dittoID.'perPage', 0);
+ $modx->setPlaceholder($dittoID.'totalPages', 0);
+ $modx->setPlaceholder($dittoID.'currentPage', 0);
}
return $text;
}
-
+
// ---------------------------------------------------
// Function: relToAbs
// Convert relative urls to absolute URLs
@@ -1155,4 +1093,8 @@ function noResults($text,$paginate) {
function relToAbs($text, $base) {
return preg_replace('#(href|src)="([^:"]*)(?:")#','$1="'.$base.'$2"',$text);
}
+
+ function isNum($str='') {
+ return preg_match('@^[1-9][0-9]*$@',$str);
+ }
}
diff --git a/assets/snippets/ditto/classes/filter.class.inc.php b/assets/snippets/ditto/classes/filter.class.inc.php
index 6efaeb9c24..aac86f1f94 100644
--- a/assets/snippets/ditto/classes/filter.class.inc.php
+++ b/assets/snippets/ditto/classes/filter.class.inc.php
@@ -3,148 +3,146 @@
/*
* Title: Filter Class
* Purpose:
- * The Filter class contains all functions relating to filtering,
- * the removing of documents from the result set
+ * The Filter class contains all functions relating to filtering,
+ * the removing of documents from the result set
*/
class filter {
- var $array_key, $filtertype, $filterValue, $filterArgs;
+ var $array_key, $filtertype, $filterValue, $filterArgs;
// ---------------------------------------------------
// Function: execute
// Filter documents via either a custom filter or basic filter
// ---------------------------------------------------
- function execute($resource, $filter) {
- global $modx;
- foreach ($filter["basic"] AS $currentFilter) {
- if (is_array($currentFilter) && count($currentFilter) > 0) {
- $this->array_key = $currentFilter["source"];
- if(substr($currentFilter["value"],0,5) != "@EVAL") {
- $this->filterValue = $currentFilter["value"];
- } else {
- $this->filterValue = $modx->safeEval(substr($currentFilter["value"],5));
- }
- if(strpos($this->filterValue,'[+') !== false) {
- $this->filterValue = $modx->mergePlaceholderContent($this->filterValue);
- }
- $this->filtertype = (isset ($currentFilter["mode"])) ? $currentFilter["mode"] : 1;
- $resource = array_filter($resource, array($this, "basicFilter"));
- }
- }
- foreach ($filter["custom"] AS $currentFilter) {
- $resource = array_filter($resource, $currentFilter);
- }
- return $resource;
- }
-
+ function execute($resource, $filter) {
+ global $modx;
+ foreach ($filter['basic'] as $current) {
+
+ if (!is_array($current) || count($current)==0) continue;
+
+ if(substr($current['value'],0,5) == '@EVAL') $this->filterValue = $modx->safeEval(substr($current['value'],5));
+ else $this->filterValue = $current['value'];
+
+ if(strpos($this->filterValue,'[+') !== false) {
+ $this->filterValue = $modx->mergePlaceholderContent($this->filterValue);
+ }
+
+ $this->array_key = $current['source'];
+ $this->filtertype = isset ($current['mode']) ? $current['mode'] : 1;
+ $resource = array_filter($resource, array($this, 'basicFilter'));
+ }
+ foreach ($filter['custom'] as $current) {
+ $resource = array_filter($resource, $current);
+ }
+ return $resource;
+ }
+
// ---------------------------------------------------
// Function: basicFilter
// Do basic comparison filtering
// ---------------------------------------------------
-
- function basicFilter ($value) {
- $unset = 1;
- switch ($this->filtertype) {
- case "!=" :
- case 1 :
- if (!isset ($value[$this->array_key]) || $value[$this->array_key] != $this->filterValue)
- $unset = 0;
- break;
- case "==" :
- case 2 :
- if ($value[$this->array_key] == $this->filterValue)
- $unset = 0;
- break;
- case "<" :
- case 3 :
- if ($value[$this->array_key] < $this->filterValue)
- $unset = 0;
- break;
- case ">" :
- case 4 :
- if ($value[$this->array_key] > $this->filterValue)
- $unset = 0;
- break;
- case "<=" :
- case 5 :
- if (!($value[$this->array_key] <= $this->filterValue))
- $unset = 0;
- break;
- case ">=" :
- case 6 :
- if (!($value[$this->array_key] >= $this->filterValue))
- $unset = 0;
- break;
-
- // Cases 7 & 8 created by MODX Testing Team Member ZAP
- case 7 :
- if (strpos($value[$this->array_key], $this->filterValue)===FALSE)
- $unset = 0;
- break;
- case 8 :
- if (strpos($value[$this->array_key], $this->filterValue)!==FALSE)
- $unset = 0;
- break;
-
- // Cases 9-11 created by highlander
- case 9 : // case insenstive version of #7 - exclude records that do not contain the text of the criterion
- if (strpos(strtolower($value[$this->array_key]), strtolower($this->filterValue))===FALSE)
- $unset = 0;
- break;
- case 10 : // case insenstive version of #8 - exclude records that do contain the text of the criterion
- if (strpos(strtolower($value[$this->array_key]), strtolower($this->filterValue))!==FALSE)
- $unset = 0;
- break;
- case 11 : // checks leading character of the field
- $firstChr = strtoupper(substr($value[$this->array_key], 0, 1));
- if ($firstChr!=$this->filterValue)
- $unset = 0;
- break;
- //Added by Andchir (http://modx-shopkeeper.ru/)
- case 12 :
- $inputArr = explode('~',$value[$this->array_key]);
- $check = 0;
- foreach($inputArr as $val){
- if(empty($this->filterValue) || empty($val))
- return;
- if (strpos($this->filterValue, $val)!==false)
- $check++;
- }
- $unset = $check>0 ? 1 : 0;
- unset($val,$check);
- break;
- //Added by Dmi3yy
- case 13 :
- $inputArr = explode('~',$value[$this->array_key]);
- $check = 0;
- foreach($inputArr as $val){
- if(empty($this->filterValue) || empty($val))
- return;
-
- $iA = explode('~',$this->filterValue);
- foreach($iA as $ii){
- $iB = explode(',',$val);
- foreach($iB as $iii){
- if (trim($ii) == trim($iii))
- $check++;
- }
- }
- }
- $unset = $check>0 ? 1 : 0;
- unset($val,$check);
- break;
- // Cases 21-22 created by Sergey Davydov 08.11.2011
- case 21 : // array version of #1 - exlude records that do not in miltiple values such a "65||115" and have output delimeted list by comma
- if (!isset ($value[$this->array_key]) || !in_array($this->filterValue,explode(',',$value[$this->array_key])))
- $unset = 0;
- break;
- case 22 : // array version of #2 - exlude records that in miltiple values such a "65||115" and have output delimeted list by comma
- if (in_array($this->filterValue,explode(',',$value[$this->array_key])))
- $unset = 0;
- break;
- }
- return $unset;
- }
-
+
+ function basicFilter ($value) {
+ $unset = 1;
+ $key = $this->array_key;
+ switch ($this->filtertype) {
+ case '!=' :
+ case 1 :
+ if (!isset ($value[$key]) || $value[$key] != $this->filterValue)
+ $unset = 0;
+ break;
+ case '==' :
+ case 2 :
+ if ($value[$key] == $this->filterValue)
+ $unset = 0;
+ break;
+ case '<' :
+ case 3 :
+ if ($value[$key] < $this->filterValue)
+ $unset = 0;
+ break;
+ case '>' :
+ case 4 :
+ if ($value[$key] > $this->filterValue)
+ $unset = 0;
+ break;
+ case '<=' :
+ case 5 :
+ if (!($value[$key] <= $this->filterValue))
+ $unset = 0;
+ break;
+ case '>=' :
+ case 6 :
+ if (!($value[$key] >= $this->filterValue))
+ $unset = 0;
+ break;
+
+ // Cases 7 & 8 created by MODX Testing Team Member ZAP
+ case 7 :
+ if (strpos($value[$key], $this->filterValue)===FALSE)
+ $unset = 0;
+ break;
+ case 8 :
+ if (strpos($value[$key], $this->filterValue)!==FALSE)
+ $unset = 0;
+ break;
+
+ // Cases 9-11 created by highlander
+ case 9 : // case insenstive version of #7 - exclude records that do not contain the text of the criterion
+ if (strpos(strtolower($value[$key]), strtolower($this->filterValue))===FALSE)
+ $unset = 0;
+ break;
+ case 10 : // case insenstive version of #8 - exclude records that do contain the text of the criterion
+ if (strpos(strtolower($value[$key]), strtolower($this->filterValue))!==FALSE)
+ $unset = 0;
+ break;
+ case 11 : // checks leading character of the field
+ $firstChr = strtoupper(substr($value[$key], 0, 1));
+ if ($firstChr!=$this->filterValue)
+ $unset = 0;
+ break;
+ //Added by Andchir (http://modx-shopkeeper.ru/)
+ case 12 :
+ $inputArr = explode('~',$value[$key]);
+ $check = 0;
+ foreach($inputArr as $val){
+ if(empty($this->filterValue) || empty($val))
+ return;
+ if (strpos($this->filterValue, $val)!==false)
+ $check++;
+ }
+ $unset = $check>0 ? 1 : 0;
+ unset($val,$check);
+ break;
+ //Added by Dmi3yy
+ case 13 :
+ $inputArr = explode('~',$value[$key]);
+ $check = 0;
+ foreach($inputArr as $val){
+ if(empty($this->filterValue) || empty($val))
+ return;
+
+ $iA = explode('~',$this->filterValue);
+ foreach($iA as $ii){
+ $iB = explode(',',$val);
+ foreach($iB as $iii){
+ if (trim($ii) == trim($iii)) $check++;
+ }
+ }
+ }
+ $unset = $check>0 ? 1 : 0;
+ unset($val,$check);
+ break;
+ // Cases 21-22 created by Sergey Davydov 08.11.2011
+ case 21 : // array version of #1 - exlude records that do not in miltiple values such a '65||115' and have output delimeted list by comma
+ if (!isset ($value[$key]) || !in_array($this->filterValue,explode(',',$value[$key])))
+ $unset = 0;
+ break;
+ case 22 : // array version of #2 - exlude records that in miltiple values such a '65||115' and have output delimeted list by comma
+ if (in_array($this->filterValue,explode(',',$value[$key])))
+ $unset = 0;
+ break;
+ }
+ return $unset;
+ }
}
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/classes/random.class.inc.php b/assets/snippets/ditto/classes/random.class.inc.php
index 23642c2cb6..38c5a1a085 100644
--- a/assets/snippets/ditto/classes/random.class.inc.php
+++ b/assets/snippets/ditto/classes/random.class.inc.php
@@ -7,126 +7,125 @@
Info : Please email me if there is any feature you want
or there is any bugs. I will fix them as soon as possible.
*********************************/
-
+
class random{
-var $data = array();
-function add($string,$weight=1){
- $this->data[] = array('s' => $string, 'w' => $weight);
+ var $data = array();
+ function add($string,$weight=1){
+ $this->data[] = array('s' => $string, 'w' => $weight);
+ }
+ function optimize(){
+ foreach($this->data as $var){
+ if($new[$var['s']]){
+ $new[$var['s']] += $var['w'];
+ }else{
+ $new[$var['s']] = $var['w'];
+ }
+ }
+ unset($this->data);
+ foreach($new as $key=>$var){
+ $this->data[] = array('s' => $key, 'w' => $var);
+ }
+ }
+
+ function select($amount=1){
+ if($amount == 1){
+ $rand = array_rand($this->data);
+ $result = $this->data[$rand]['s'];
+ }else{
+ $i = 0;
+ while($i<$amount){
+ $result[] = $this->data[array_rand($this->data)]['s'];
+ ++$i;
+ }
+ }
+ return $result;
+ }
+
+ function select_unique($amount=1){
+ if($amount == 1){
+ $rand = array_rand($this->data);
+ $result = $this->data[$rand]['s'];
+ }else{
+ $rand = array_rand($this->data, $amount);
+ foreach($rand as $var){
+ $result[] = $this->data[$var]['s'];
+ }
+ }
+ return $result;
+ }
+
+ function select_weighted($amount=1){
+ $count = count($this->data);
+ $i = 0;
+ $max = -1;
+ while($i < $count){
+ $max += $this->data[$i]['w'];
+ ++$i;
+ }
+ if(1 == $amount){
+ $rand = mt_rand(0, $max);
+ $w = 0; $n = 0;
+ while($w <= $rand){
+ $w += $this->data[$n]['w'];
+ ++$n;
+ }
+ $key = $this->data[$n-1]['s'];
+ }else{
+ $i = 0;
+ while($i<$amount){
+ $random[] = mt_rand(0, $max);
+ ++$i;
+ }
+ sort($random);
+ $i = 0;
+ $n = 0;
+ $w = 0;
+ while($i<$amount){
+ while($w<=$random[$i]){
+ $w += $this->data[$n]['w'];
+ ++$n;
+ }
+ $key[] = $this->data[$n-1]['s'];
+ ++$i;
+ }
+ }
+ return $key;
+ }
+
+ function select_weighted_unique($amount=1){
+ $count = count($this->data);
+ $i = 0;
+ if($amount >= $count){
+ while($i < $count){
+ $return[] = $this->data[$i]['s'];
+ ++$i;
+ }
+ return $return;
+ }else{
+ $max = -1;
+ while($i < $count){
+ $max += $this->data[$i]['w'];
+ ++$i;
+ }
+
+ $i = 0;
+ while($i < $amount){
+ $max -= $sub;
+ $w = 0;
+ $n = 0;
+ $num = mt_rand(0,$max);
+ while($w <= $num){
+ $w += $this->data[$n]['w'];
+ ++$n;
+ }
+ $sub = $this->data[$n-1]['w'];
+ $key[] = $this->data[$n-1]['s'];
+
+ unset($this->data[$n-1]);
+ $this->data = array_merge($this->data);
+ ++$i;
+ }
+ return $key;
+ }
+ }
}
-function optimize(){
- foreach($this->data as $var){
- if($new[$var['s']]){
- $new[$var['s']] += $var['w'];
- }else{
- $new[$var['s']] = $var['w'];
- }
- }
- unset($this->data);
- foreach($new as $key=>$var){
- $this->data[] = array('s' => $key, 'w' => $var);
- }
-}
-
-function select($amount=1){
- if($amount == 1){
- $rand = array_rand($this->data);
- $result = $this->data[$rand]['s'];
- }else{
- $i = 0;
- while($i<$amount){
- $result[] = $this->data[array_rand($this->data)]['s'];
- ++$i;
- }
- }
- return $result;
-}
-
-function select_unique($amount=1){
- if($amount == 1){
- $rand = array_rand($this->data);
- $result = $this->data[$rand]['s'];
- }else{
- $rand = array_rand($this->data, $amount);
- foreach($rand as $var){
- $result[] = $this->data[$var]['s'];
- }
- }
- return $result;
-}
-
-function select_weighted($amount=1){
- $count = count($this->data);
- $i = 0;
- $max = -1;
- while($i < $count){
- $max += $this->data[$i]['w'];
- ++$i;
- }
- if(1 == $amount){
- $rand = mt_rand(0, $max);
- $w = 0; $n = 0;
- while($w <= $rand){
- $w += $this->data[$n]['w'];
- ++$n;
- }
- $key = $this->data[$n-1]['s'];
- }else{
- $i = 0;
- while($i<$amount){
- $random[] = mt_rand(0, $max);
- ++$i;
- }
- sort($random);
- $i = 0;
- $n = 0;
- $w = 0;
- while($i<$amount){
- while($w<=$random[$i]){
- $w += $this->data[$n]['w'];
- ++$n;
- }
- $key[] = $this->data[$n-1]['s'];
- ++$i;
- }
- }
- return $key;
-}
-
-function select_weighted_unique($amount=1){
- $count = count($this->data);
- $i = 0;
- if($amount >= $count){
- while($i < $count){
- $return[] = $this->data[$i]['s'];
- ++$i;
- }
- return $return;
- }else{
- $max = -1;
- while($i < $count){
- $max += $this->data[$i]['w'];
- ++$i;
- }
-
- $i = 0;
- while($i < $amount){
- $max -= $sub;
- $w = 0;
- $n = 0;
- $num = mt_rand(0,$max);
- while($w <= $num){
- $w += $this->data[$n]['w'];
- ++$n;
- }
- $sub = $this->data[$n-1]['w'];
- $key[] = $this->data[$n-1]['s'];
-
- unset($this->data[$n-1]);
- $this->data = array_merge($this->data);
- ++$i;
- }
- return $key;
- }
-}
-}
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/classes/template.class.inc.php b/assets/snippets/ditto/classes/template.class.inc.php
index ac53c1b065..e71a5fe7b4 100644
--- a/assets/snippets/ditto/classes/template.class.inc.php
+++ b/assets/snippets/ditto/classes/template.class.inc.php
@@ -3,241 +3,206 @@
/*
* Title: Template Class
* Purpose:
- * The Template class contains all functions relating to Ditto's
- * handling of templates and any supporting functions they need
+ * The Template class contains all functions relating to Ditto's
+ * handling of templates and any supporting functions they need
*/
class template{
- var $language,$fields,$current;
+ var $language,$fields,$current;
- // ---------------------------------------------------
- // Function: template
- // Set the class language and fields variables
- // ---------------------------------------------------
- function __construct() {
- $this->language = $GLOBALS["ditto_lang"];
- $this->fields = array (
- "db" => array (),
- "tv" => array (),
- "custom" => array (),
- "item" => array (),
- "qe" => array (),
- "phx" => array (),
- "rss" => array (),
- "json" => array (),
- "xml" => array (),
- "unknown" => array()
- );
- }
+ // ---------------------------------------------------
+ // Function: template
+ // Set the class language and fields variables
+ // ---------------------------------------------------
+ function __construct() {
+ $this->language = $GLOBALS['ditto_lang'];
+ $this->fields = array (
+ 'db' => array (),
+ 'tv' => array (),
+ 'custom' => array (),
+ 'item' => array (),
+ 'phx' => array (),
+ 'rss' => array (),
+ 'json' => array (),
+ 'xml' => array (),
+ 'unknown' => array()
+ );
+ }
- // ---------------------------------------------------
- // Function: process
- // Take the templates and parse them for tempalte variables,
- // Check to make sure they have fields, and sort the fields
- // ---------------------------------------------------
- function process($template) {
- if (!isset($template["base"])) {
- $template["base"] = $template["default"];
- } else {
- unset($template["default"]);
- }
- foreach ($template as $name=>$tpl) {
- if(!empty($tpl) && $tpl != "") {
- $templates[$name] = $this->fetch($tpl);
- }
- }
- $fieldList = array();
- foreach ($templates as $tplName=>$tpl) {
- $check = $this->findTemplateVars($tpl);
- if (is_array($check)) {
- $fieldList = array_merge($check, $fieldList);
- } else {
- switch ($tplName) {
- case "base":
- $displayName = "tpl";
- break;
-
- case "default":
- $displayName = "tpl";
- break;
-
- default:
- $displayName = "tpl".$tplName;
- break;
- }
- $templates[$tplName] = str_replace("[+tpl+]",$displayName,$this->language["bad_tpl"]);
- }
- }
+ // ---------------------------------------------------
+ // Function: process
+ // Take the templates and parse them for tempalte variables,
+ // Check to make sure they have fields, and sort the fields
+ // ---------------------------------------------------
+ function process($template) {
+ if (!isset($template['base'])) $template['base'] = $template['default'];
+ else unset($template['default']);
+
+ foreach ($template as $name=>$tpl) {
+ if(!empty($tpl) && $tpl != '') $templates[$name] = $this->fetch($tpl);
+ }
+ $fieldList = array();
+ foreach ($templates as $tplName=>$tpl) {
+ $check = $this->findTemplateVars($tpl);
+ if (is_array($check)) $fieldList = array_merge($check, $fieldList);
+ else {
+ switch ($tplName) {
+ case 'base' :
+ case 'default': $displayName = 'tpl';break;
+ default : $displayName = 'tpl'.$tplName;
+ }
+ $templates[$tplName] = str_replace('[+tpl+]',$displayName,$this->language['bad_tpl']);
+ }
+ }
- $fieldList = array_unique($fieldList);
- $fields = $this->sortFields($fieldList);
- $checkAgain = array ("qe", "json", "xml");
- foreach ($checkAgain as $type) {
- $fields = array_merge_recursive($fields, $this->sortFields($fields[$type]));
- }
- $this->fields = $fields;
- return $templates;
- }
+ $fieldList = array_unique($fieldList);
+ $fields = $this->sortFields($fieldList);
+ $checkAgain = array ('json', 'xml');
+ foreach ($checkAgain as $type) {
+ $fields = array_merge_recursive($fields, $this->sortFields($fields[$type]));
+ }
+ $this->fields = $fields;
+ return $templates;
+ }
- // ---------------------------------------------------
- // Function: findTemplateVars
- // Find al the template variables in the template
- // ---------------------------------------------------
- function findTemplateVars($tpl) {
- preg_match_all('~\[\+(.*?)\+\]~', $tpl, $matches);
- $TVs = array();
- foreach($matches[1] as $tv) {
- $match = explode(":", $tv);
- $TVs[strtolower($match[0])] = $match[0];
- }
- if (count($TVs) >= 1) {
- return array_values($TVs);
- } else {
- return false;
- }
- }
+ // ---------------------------------------------------
+ // Function: findTemplateVars
+ // Find al the template variables in the template
+ // ---------------------------------------------------
+ function findTemplateVars($tpl) {
+ preg_match_all('~\[\+(.*?)\+\]~', $tpl, $matches);
+ $TVs = array();
+ foreach($matches[1] as $tv) {
+ $match = explode(':', $tv);
+ $TVs[strtolower($match[0])] = $match[0];
+ }
+ if (count($TVs) >= 1) {
+ return array_values($TVs);
+ } else {
+ return false;
+ }
+ }
- // ---------------------------------------------------
- // Function: sortFields
- // Sort the array of fields provided by type
- // ---------------------------------------------------
- function sortFields ($fieldList) {
- global $ditto_constantFields;
- $dbFields = $ditto_constantFields["db"];
- $tvFields = $ditto_constantFields["tv"];
- $fields = array (
- "db" => array (),
- "tv" => array (),
- "custom" => array (),
- "item" => array (),
- "qe" => array (),
- "phx" => array (),
- "rss" => array (),
- "json" => array (),
- "xml" => array (),
- "unknown" => array()
- );
-
- $custom = array("author","date","url","title","ditto_iteration");
+ // ---------------------------------------------------
+ // Function: sortFields
+ // Sort the array of fields provided by type
+ // ---------------------------------------------------
+ function sortFields ($fieldList) {
+ global $ditto_constantFields;
+ $dbFields = $ditto_constantFields['db'];
+ $tvFields = $ditto_constantFields['tv'];
+ $fields = array (
+ 'db' => array (),
+ 'tv' => array (),
+ 'custom' => array (),
+ 'item' => array (),
+ 'phx' => array (),
+ 'rss' => array (),
+ 'json' => array (),
+ 'xml' => array (),
+ 'unknown' => array()
+ );
+
+ $custom = array('author','date','url','title','ditto_iteration');
- foreach ($fieldList as $field) {
- if (substr($field, 0, 4) == "rss_") {
- $fields['rss'][] = substr($field,4);
- }else if (substr($field, 0, 4) == "xml_") {
- $fields['xml'][] = substr($field,4);
- }else if (substr($field, 0, 5) == "json_") {
- $fields['json'][] = substr($field,5);
- }else if (substr($field, 0, 5) == "item[") {
- $fields['item'][] = substr($field, 4);
- }else if (substr($field, 0, 1) == "#") {
- $fields['qe'][] = substr($field,1);
- }else if (substr($field, 0, 4) == "phx:") {
- $fields['phx'][] = $field;
- }else if (in_array($field, $dbFields)) {
- $fields['db'][] = $field;
- }else if(in_array($field, $tvFields)){
- $fields['tv'][] = $field;
- }else if(substr($field, 0, 2) == "tv" && in_array(substr($field,2), $tvFields)) {
- $fields['tv'][] = substr($field,2);
- // TODO: Remove TV Prefix support in Ditto
- }else if (in_array($field, $custom)) {
- $fields['custom'][] = $field;
- }else {
- $fields['unknown'][] = $field;
- }
- }
- return $fields;
- }
+ foreach ($fieldList as $field) {
+ if (substr($field, 0, 4) == 'rss_') $fields['rss'][] = substr($field,4);
+ elseif(substr($field, 0, 4) == 'xml_') $fields['xml'][] = substr($field,4);
+ elseif(substr($field, 0, 5) == 'json_') $fields['json'][] = substr($field,5);
+ elseif(substr($field, 0, 5) == 'item[') $fields['item'][] = substr($field,4);
+ elseif(substr($field, 0, 4) == 'phx:') $fields['phx'][] = $field;
+ elseif(in_array($field, $dbFields)) $fields['db'][] = $field;
+ elseif(in_array($field, $tvFields)) $fields['tv'][] = $field;
+ elseif(substr($field, 0, 2) == 'tv' && in_array(substr($field,2), $tvFields))
+ $fields['tv'][] = substr($field,2);
+ // TODO: Remove TV Prefix support in Ditto
+ elseif(in_array($field, $custom)) $fields['custom'][] = $field;
+ else $fields['unknown'][] = $field;
+ }
+ return $fields;
+ }
- // ---------------------------------------------------
- // Function: replace
- // Replcae placeholders with their values
- // ---------------------------------------------------
+ // ---------------------------------------------------
+ // Function: replace
+ // Replcae placeholders with their values
+ // ---------------------------------------------------
public static function replace( $placeholders, $tpl ) {
- $keys = array();
- $values = array();
- foreach ($placeholders as $key=>$value) {
- $keys[] = '[+'.$key.'+]';
- $values[] = $value;
- }
- return str_replace($keys,$values,$tpl);
- }
+ $keys = array();
+ $values = array();
+ foreach ($placeholders as $key=>$value) {
+ $keys[] = '[+'.$key.'+]';
+ $values[] = $value;
+ }
+ return str_replace($keys,$values,$tpl);
+ }
- // ---------------------------------------------------
- // Function: determine
- // Determine the correct template to apply
- // ---------------------------------------------------
- function determine($templates,$x,$start,$stop,$id) {
- global $modx;
+ // ---------------------------------------------------
+ // Function: determine
+ // Determine the correct template to apply
+ // ---------------------------------------------------
+ function determine($templates,$x,$start,$stop,$id) {
+ global $modx;
- // determine current template
- $currentTPL = "base";
- if ($x % 2 && !empty($templates["alt"])) {
- $currentTPL = "alt";
- }
- if ($id == $modx->documentObject['id'] && !empty($templates["current"])){
- $currentTPL = "current";
- }
- if ($x == 0 && !empty($templates["first"])) {
- $currentTPL = "first";
- }
- if ($x == ($stop -1) && !empty($templates["last"])) {
- $currentTPL = "last";
- }
- $this->current = $currentTPL;
- return $templates[$currentTPL];
- }
+ // determine current template
+ if ($x == ($stop -1) && !empty($templates['last'])) $currentTPL = 'last';
+ elseif ($x == 0 && !empty($templates['first'])) $currentTPL = 'first';
+ elseif ($id == $modx->documentIdentifier && !empty($templates['current']))
+ $currentTPL = 'current';
+ elseif ($x % 2 && !empty($templates['alt'])) $currentTPL = 'alt';
+ else $currentTPL = 'base';
+
+ $this->current = $currentTPL;
+ return $templates[$currentTPL];
+ }
- // ---------------------------------------------------
- // Function: fetch
- // Get a template, based on version by Doze
- //
- // http://forums.modx.com/thread/41066/support-comments-for-ditto?page=2#dis-post-237942
- // ---------------------------------------------------
- function fetch($tpl){
- global $modx;
- $template = '';
- if(substr($tpl, 0, 6) == '@CHUNK') {
- $template = $modx->getChunk(substr($tpl, 7));
- } elseif(substr($tpl, 0, 5) == '@FILE') {
- $path = trim(substr($tpl, 6));
- if(strpos($path, $modx->config['base_url'].'manager/includes/config.inc.php')===false)
- $template = file_get_contents($path);
- } elseif(substr($tpl, 0, 5) == '@CODE') {
- $template = substr($tpl, 6);
- } elseif(strpos($tpl, '[+') !==false) {
- $template = $tpl;
- } elseif(substr($tpl, 0, 9) == '@DOCUMENT') {
- $docid = trim(substr($tpl, 10));
- if(preg_match('@^[1-9][0-9]*$@',$docid))
- $template = $modx->getField('content',$docid);
- } else {
- $template = $modx->getChunk($tpl);
- }
-
- if(strpos($template,'[!')!==false)
- $template = str_replace(array('[!','!]'),array('[[',']]'),$template);
- elseif($template===''||$template===false)
- $template = $this->language['missing_placeholders_tpl'];
- return $template;
- }
+ // ---------------------------------------------------
+ // Function: fetch
+ // Get a template, based on version by Doze
+ //
+ // http://forums.modx.com/thread/41066/support-comments-for-ditto?page=2#dis-post-237942
+ // ---------------------------------------------------
+ function fetch($tpl){
+ global $modx;
+ $template = '';
+ if(substr($tpl, 0, 6) == '@CHUNK') {
+ $template = $modx->getChunk(substr($tpl, 7));
+ } elseif(substr($tpl, 0, 5) == '@FILE') {
+ $path = trim(substr($tpl, 6));
+ if(strpos($path, 'manager/includes/config.inc.php')===false)
+ $template = file_get_contents($path);
+ } elseif(substr($tpl, 0, 5) == '@CODE') {
+ $template = substr($tpl, 6);
+ } elseif(strpos($tpl, '[+') !==false) {
+ $template = $tpl;
+ } elseif(substr($tpl, 0, 9) == '@DOCUMENT') {
+ $docid = trim(substr($tpl, 10));
+ if(preg_match('@^[1-9][0-9]*$@',$docid))
+ $template = $modx->getField('content',$docid);
+ } else {
+ $template = $modx->getChunk($tpl);
+ }
+
+ if(strpos($template,'[!')!==false)
+ $template = str_replace(array('[!','!]'),array('[[',']]'),$template);
+ elseif($template===''||$template===false)
+ $template = $this->language['missing_placeholders_tpl'];
+ return $template;
+ }
- // ---------------------------------------------------
- // Function: get_file_contents
- // Returns the contents of file name passed
- //
- // From http://www.nutt.net/2006/07/08/file_get_contents-function-for-php-4/#more-210
- // ---------------------------------------------------
- function get_file_contents($filename) {
- if (!function_exists('file_get_contents')) {
- $fhandle = fopen($filename, "r");
- $fcontents = fread($fhandle, filesize($filename));
- fclose($fhandle);
- } else {
- $fcontents = file_get_contents($filename);
- }
- return $fcontents;
- }
+ // ---------------------------------------------------
+ // Function: get_file_contents
+ // Returns the contents of file name passed
+ //
+ // From http://www.nutt.net/2006/07/08/file_get_contents-function-for-php-4/#more-210
+ // ---------------------------------------------------
+ function get_file_contents($filename) {
+ if (!function_exists('file_get_contents')) {
+ $fhandle = fopen($filename, 'r');
+ $fcontents = fread($fhandle, filesize($filename));
+ fclose($fhandle);
+ } else {
+ $fcontents = file_get_contents($filename);
+ }
+ return $fcontents;
+ }
}
-
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/andFilter.extender.inc.php b/assets/snippets/ditto/extenders/andFilter.extender.inc.php
index 49f749d730..16f32a2e48 100644
--- a/assets/snippets/ditto/extenders/andFilter.extender.inc.php
+++ b/assets/snippets/ditto/extenders/andFilter.extender.inc.php
@@ -9,37 +9,33 @@
// ---------------------------------------------------
// If no fieldname value has been supplied, don't do anything else
-if ($andFilterTv === false) {
- return false;
-}
-
+if ($andFilterTv === false) return false;
+
global $tvsarray;
$tmparray = explode ( ';', $andFilterTv);
foreach ( $tmparray as $tmpvalue ) {
- $tmpexplode = explode ( ':', $tmpvalue );
- $tvsarray[] = $tmpexplode;
- $filtertvs .= (empty($filtertvs)?"":",") . $tmpexplode[0];
- }
-
-
-
-$filters["custom"]["andFilter"] = array( $filtertvs, "andFilter");
+ $tmpexplode = explode ( ':', $tmpvalue );
+ $tvsarray[] = $tmpexplode;
+ $filtertvs .= (empty($filtertvs)?'':',') . $tmpexplode[0];
+}
+
+$filters['custom']['andFilter'] = array( $filtertvs, 'andFilter');
-if (!function_exists("andFilter")) {
+if (!function_exists('andFilter')) {
function andFilter($resource) {
global $modx,$tvsarray;
$good = true;
foreach ( $tvsarray as $tv ) {
$values = explode( ',', $tv[1] );
- if ( array_search($resource[$tv[0]], $values) !== false ) {
+ if ( array_search($resource[$tv[0]], $values) !== false ) {
$good = $good && true;
} else {
$good = $good && false;
}
}
- if ($good) { return 1; } else { return 0; }
-
+ if ($good) return 1;
+ else return 0;
+
}
}
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/countDocs.extender.inc.php b/assets/snippets/ditto/extenders/countDocs.extender.inc.php
index e0a55809c7..6cd7f3bdc2 100644
--- a/assets/snippets/ditto/extenders/countDocs.extender.inc.php
+++ b/assets/snippets/ditto/extenders/countDocs.extender.inc.php
@@ -14,9 +14,11 @@
*/
$GLOBALS['docCounter'] = 0;
-
+
$filters['custom']['countDocs'] = array('id', 'countDocuments');
-
+
+$placeholders['count'] = array('id', 'setCountPlaceholder');
+
if (!function_exists('countDocuments')) {
function countDocuments($resource) {
# count documents
@@ -24,13 +26,9 @@ function countDocuments($resource) {
return 1;
}
}
-
-$placeholders['count'] = array('id', 'setCountPlaceholder');
-
+
if (!function_exists('setCountPlaceholder')) {
function setCountPlaceholder($resource) {
return $GLOBALS['docCounter'];
}
}
-
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/customsort.extender.inc.php b/assets/snippets/ditto/extenders/customsort.extender.inc.php
index f480cdbb00..49b90d41af 100644
--- a/assets/snippets/ditto/extenders/customsort.extender.inc.php
+++ b/assets/snippets/ditto/extenders/customsort.extender.inc.php
@@ -1,18 +1,15 @@
advSort = true;
-?>
\ No newline at end of file
+
+if (!function_exists('customsort')){
+ function customsort($a, $b){
+ $pos_a = array_search($a['id'], $GLOBALS['documents']);
+ $pos_b = array_search($b['id'], $GLOBALS['documents']);
+
+ if ($pos_a == $pos_b) return 0;
+
+ return ($pos_a < $pos_b) ? -1 : 1;
+ }
+}
diff --git a/assets/snippets/ditto/extenders/dateFilter.extender.inc.php b/assets/snippets/ditto/extenders/dateFilter.extender.inc.php
index 38ed17566a..8888e20264 100644
--- a/assets/snippets/ditto/extenders/dateFilter.extender.inc.php
+++ b/assets/snippets/ditto/extenders/dateFilter.extender.inc.php
@@ -101,7 +101,7 @@ function execute($value) {
$year = (!empty($_GET[$dittoID.'year']) && $_GET[$dittoID.'year'] != 'false') ? intval($_GET[$dittoID.'year']) : 0;
$month = (!empty($_GET[$dittoID.'month']) && $_GET[$dittoID.'month'] != 'false') ? intval($_GET[$dittoID.'month']) : 0;
$day = (!empty($_GET[$dittoID.'day']) && $_GET[$dittoID.'day'] != 'false') ? intval($_GET[$dittoID.'day']) : 0;
-} else if ($source == 'params'){
+} elseif ($source == 'params'){
$month = isset($month) ? intval($month) : 0;
/*
Param: month
@@ -226,5 +226,3 @@ function execute($value) {
$dateFilterOject = new dateFilter($month,$year,$day,$dateSource);
$filters["custom"]["dateFilter"] = array($dateSource,array($dateFilterOject,"execute"));
}
-
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/distinct.extender.inc.php b/assets/snippets/ditto/extenders/distinct.extender.inc.php
index b337178a82..2f64c52901 100755
--- a/assets/snippets/ditto/extenders/distinct.extender.inc.php
+++ b/assets/snippets/ditto/extenders/distinct.extender.inc.php
@@ -5,41 +5,39 @@
*
* Return only distinct / unique results, based on a fieldname supplied as &distinct parameter
*
- * @Installation: Put file "distinct.extender.inc.php" into /assets/snippets/ditto/extenders
+ * @Installation: Put file 'distinct.extender.inc.php' into /assets/snippets/ditto/extenders
*
* @Usage:
- * In the Ditto call, add "distinct" to the extenders param, and specify the &distinct parameter with the name(s) of the field which you would like to be unique.
- * If you would like to make the combined values of more than one field unique, separate them with commas
- * e.g. [[Ditto? &tpl=`myTemplate` &extenders=`distinct` &distinct=`pagetitle`]] -- will return only unique page titles.
- * e.g. [[Ditto? &tpl=`myTemplate` &extenders=`distinct` &distinct=`pagetitle,pub_date`]] -- will return only unique page titles for each date.
+ * In the Ditto call, add 'distinct' to the extenders param, and specify the &distinct parameter with the name(s) of the field which you would like to be unique.
+ * If you would like to make the combined values of more than one field unique, separate them with commas
+ * e.g. [[Ditto? &tpl=`myTemplate` &extenders=`distinct` &distinct=`pagetitle`]] -- will return only unique page titles.
+ * e.g. [[Ditto? &tpl=`myTemplate` &extenders=`distinct` &distinct=`pagetitle,pub_date`]] -- will return only unique page titles for each date.
*
* @Changelog:
- * 1.0.3 (2011-12-30) By Sergey Davydov: Set placeholders distinctCount - common count and distinctIds - ids of distinted items
- * 1.0.2 (2012-04-05) by DivanDesign: Now use the DittoID (need for many Ditto calls).
- * 1.0.1 by Nick Crossland: Bugfixes only.
- * 1.0 by Nick Crossland: initial release.
+ * 1.0.3 (2011-12-30) By Sergey Davydov: Set placeholders distinctCount - common count and distinctIds - ids of distinted items
+ * 1.0.2 (2012-04-05) by DivanDesign: Now use the DittoID (need for many Ditto calls).
+ * 1.0.1 by Nick Crossland: Bugfixes only.
+ * 1.0 by Nick Crossland: initial release.
*
* @Author: Nick Crossland (ncrossland), DivanDesign (http://www.DivanDesign.biz)
*/
$distinct = isset($distinct) ? $distinct : false;
/*
- Param: distinct
+ Param: distinct
- Purpose:
- What field should we search for being distinct?
+ Purpose:
+ What field should we search for being distinct?
- Options:
- Fieldname
-
- Default:
- "default"
+ Options:
+ Fieldname
+
+ Default:
+ 'default'
*/
// If no fieldname value has been supplied, don't do anything else
-if ($distinct === false) {
- return false;
-}
+if ($distinct === false) return false;
// It would be nice if this was class based, so it doesn't pollute the global namespace
// But - create an array of document values we've seen, and the fieldnames we're making distinct
@@ -54,68 +52,65 @@
// Remove any extra spaces from the fieldnames (in case they have been supplied with commas and spaces)
$distinct_fieldname[$ddDittoID] = array_map('trim', $distinct_fieldname[$ddDittoID]);
-$placeholders['distinctCount'] = array(implode(',',$distinct_fieldname[$ddDittoID]),"distinctCount");
+$placeholders['distinctCount'] = array(implode(',',$distinct_fieldname[$ddDittoID]),'distinctCount');
-if(!function_exists('distinctCount')){
- function distinctCount($resource){ //Not sure if the $resource is needed
- global $seen;
- global $distinct_fieldname;
- global $ddDittoID;
+$placeholders['distinctIds'] = array(implode(',',$distinct_fieldname[$ddDittoID]),'distinctIds');
- $distinct_string = '';
- foreach ($distinct_fieldname[$ddDittoID] as $f) {
- $distinct_string .= '~'. $f.'|'.$resource[$f];
- }
- if (isset($seen[$ddDittoID][$distinct_string]))
- return count($seen[$ddDittoID][$distinct_string]);
- }
-}
+// Add the custom function
+$filters['custom']['distinct'] = array(implode(',',$distinct_fieldname[$ddDittoID]) ,'makeDistinct');
-$placeholders['distinctIds'] = array(implode(',',$distinct_fieldname[$ddDittoID]),"distinctIds");
-if(!function_exists('distinctIds')){
- function distinctIds($resource){ //Not sure if the $resource is needed
- global $seen;
- global $distinct_fieldname;
- global $ddDittoID;
- $distinct_string = '';
- foreach ($distinct_fieldname[$ddDittoID] as $f) {
- $distinct_string .= '~'. $f.'|'.$resource[$f];
- }
- if (isset($seen[$ddDittoID][$distinct_string]))
- return implode(",",$seen[$ddDittoID][$distinct_string]);
- }
+if(!function_exists('distinctCount')){
+ function distinctCount($resource){ //Not sure if the $resource is needed
+ global $seen;
+ global $distinct_fieldname;
+ global $ddDittoID;
+
+ $distinct_string = '';
+ foreach ($distinct_fieldname[$ddDittoID] as $f) {
+ $distinct_string .= '~'. $f.'|'.$resource[$f];
+ }
+ if (isset($seen[$ddDittoID][$distinct_string])) return count($seen[$ddDittoID][$distinct_string]);
+ }
+}
+if(!function_exists('distinctIds')){
+ function distinctIds($resource){ //Not sure if the $resource is needed
+ global $seen;
+ global $distinct_fieldname;
+ global $ddDittoID;
+
+ $distinct_string = '';
+ foreach ($distinct_fieldname[$ddDittoID] as $f) {
+ $distinct_string .= '~'. $f.'|'.$resource[$f];
+ }
+ if (isset($seen[$ddDittoID][$distinct_string])) return implode(',',$seen[$ddDittoID][$distinct_string]);
+ }
}
-
// The filter function
-if (!function_exists("makeDistinct")) {
-
- function makeDistinct($resource) {
- global $ddDittoID;
- global $seen;
- global $distinct_fieldname;
-
- // Make a unique string based on the fieldname and value of each field we've been asked to make distinct
- $distinct_string = '';
- foreach ($distinct_fieldname[$ddDittoID] as $f) {
- $distinct_string .= '~'. $f.'|'.$resource[$f];
- }
-
- // Check if this string has been seen yet -- if it has, don't include it in the results
- if (isset($seen[$ddDittoID][$distinct_string]) && $seen[$ddDittoID][$distinct_string] ) { // If this value of the fieldname has been seen before, remove it from the list
- $seen[$ddDittoID][$distinct_string][] = $resource["id"];
- return false;
- } else {
-// Otherwise, remember the value has been seen, and allow it in the list (this time)
- $seen[$ddDittoID][$distinct_string] = array($resource["id"]);
- return true;
- }
-
- }
+if (!function_exists('makeDistinct')) {
+
+ function makeDistinct($resource) {
+ global $ddDittoID;
+ global $seen;
+ global $distinct_fieldname;
+
+ // Make a unique string based on the fieldname and value of each field we've been asked to make distinct
+ $distinct_string = '';
+ foreach ($distinct_fieldname[$ddDittoID] as $f) {
+ $distinct_string .= '~'. $f.'|'.$resource[$f];
+ }
+
+ // Check if this string has been seen yet -- if it has, don't include it in the results
+ if (isset($seen[$ddDittoID][$distinct_string]) && $seen[$ddDittoID][$distinct_string] ) {
+ // If this value of the fieldname has been seen before, remove it from the list
+ $seen[$ddDittoID][$distinct_string][] = $resource['id'];
+ return false;
+ } else {
+ // Otherwise, remember the value has been seen, and allow it in the list (this time)
+ $seen[$ddDittoID][$distinct_string] = array($resource['id']);
+ return true;
+ }
+ }
}
-
-// Add the custom function
-$filters["custom"]["distinct"] = array(implode(',',$distinct_fieldname[$ddDittoID]) ,"makeDistinct");
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/example.extender.inc.php b/assets/snippets/ditto/extenders/example.extender.inc.php
index b4dc44fcfd..a63752698f 100644
--- a/assets/snippets/ditto/extenders/example.extender.inc.php
+++ b/assets/snippets/ditto/extenders/example.extender.inc.php
@@ -3,7 +3,7 @@
/*
* Title: Example
* Purpose:
- * Example file for basing new Extenders on
+ * Example file for basing new Extenders on
*/
// ---------------------------------------------------
@@ -11,18 +11,18 @@
// Define any parameters needed in the extender or to override Ditto defaults
// ---------------------------------------------------
-$param = isset($param) ? $param : "default";
+if(!isset($param)) $param = 'default';
/*
- Param: param
+ Param: param
- Purpose:
- The purpose of your parameter goes here
+ Purpose:
+ The purpose of your parameter goes here
- Options:
- Any options that your parameter can have go here
-
- Default:
- "default"
+ Options:
+ Any options that your parameter can have go here
+
+ Default:
+ 'default'
*/
// ---------------------------------------------------
@@ -30,67 +30,60 @@
// Defin the values of custom placeholders for access in the tpl like so [+phname+]
// ---------------------------------------------------
-$placeholders['example'] = array(array("pagetitle","*"),"exampleFunction","pagetitle");
- // Variable: $placeholders['example']
- // Add the placeholder example to the custom placeholders list
- // with the source pagetitle in both display and backend using the
- // exampleFunction callback and pagetitle as the field for QuickEdit.
- // If you only needed the placeholder in the frontent you would just
- // use "pagetitle" as the first value of the array. If the callback
- // was in a class use the array($initialized_class,"member") method.
-
-if (!function_exists("exampleFunction")) {
- // wrap functions in !functino_exists statements to ensure that they are not defined twice
-
- // ---------------------------------------------------
- // Function: exampleFunction
- //
- // Takes the resource array for an individual document
- // and returns the value of the placeholder, in this
- // case the uppercase version of the pagetitle
- // ---------------------------------------------------
- function exampleFunction($resource) {
- return strtoupper($resource['pagetitle']);
- }
-}
+$placeholders['example'] = array(array('pagetitle','*'),'exampleFunction','pagetitle');
+ // Variable: $placeholders['example']
+ // Add the placeholder example to the custom placeholders list
+ // with the source pagetitle in both display and backend using the
+ // exampleFunction callback and pagetitle as the field for QuickEdit.
+ // If you only needed the placeholder in the frontent you would just
+ // use 'pagetitle' as the first value of the array. If the callback
+ // was in a class use the array($initialized_class,'member') method.
// ---------------------------------------------------
// Group: Filters
// Define custom or basic filters within the extender to expand Ditto's filtering capabilities
// ---------------------------------------------------
-$filters["custom"]["exampleFilter"] = array("pagetitle","exampleFilter");
- // Variable: $filters["custom"]["exampleFilter"]
- // Add the filter exampleFilter to the custom filters
- // list with the source pagetitle and the callback
- // exampleFilter
-
-if (!function_exists("exampleFilter")) {
- // wrap functions in !functino_exists statements to ensure that they are not defined twice
-
- // ---------------------------------------------------
- // Function: exampleFilter
- //
- // Takes the resource array for an individual document
- // and asks for the return of a 0 or 1 with 1 removing
- // the document and 0 leaving it in the result set.
- // In this case, if the lower case value of the pagetitle
- // is foo, it is removed while all other documents are shown
- // ---------------------------------------------------
- function exampleFilter($resource) {
- if (strtolower($resource['pagetitle']) == "foo") {
- return 1;
- } else {
- return 0;
- }
- }
-}
-
-$filters["parsed"][] = array('exampleFilter' => array("source"=>"id","value"=>"9239423942","mode"=>"2"));
- // Variable: $filters["parsed"][]
- // Add the pre-parsed filter to the parsed filters list with the
- // source as id, the value of 9239423942 and the mode 2
+$filters['custom']['exampleFilter'] = array('pagetitle','exampleFilter');
+ // Variable: $filters['custom']['exampleFilter']
+ // Add the filter exampleFilter to the custom filters
+ // list with the source pagetitle and the callback
+ // exampleFilter
+$filters['parsed'][] = array('exampleFilter' => array('source'=>'id','value'=>'9239423942','mode'=>'2'));
+ // Variable: $filters['parsed'][]
+ // Add the pre-parsed filter to the parsed filters list with the
+ // source as id, the value of 9239423942 and the mode 2
+if (!function_exists('exampleFunction')) {
+ // wrap functions in !functino_exists statements to ensure that they are not defined twice
+
+ // ---------------------------------------------------
+ // Function: exampleFunction
+ //
+ // Takes the resource array for an individual document
+ // and returns the value of the placeholder, in this
+ // case the uppercase version of the pagetitle
+ // ---------------------------------------------------
+ function exampleFunction($resource) {
+ return strtoupper($resource['pagetitle']);
+ }
+}
-?>
\ No newline at end of file
+if (!function_exists('exampleFilter')) {
+ // wrap functions in !functino_exists statements to ensure that they are not defined twice
+
+ // ---------------------------------------------------
+ // Function: exampleFilter
+ //
+ // Takes the resource array for an individual document
+ // and asks for the return of a 0 or 1 with 1 removing
+ // the document and 0 leaving it in the result set.
+ // In this case, if the lower case value of the pagetitle
+ // is foo, it is removed while all other documents are shown
+ // ---------------------------------------------------
+ function exampleFilter($resource) {
+ if (strtolower($resource['pagetitle'])=='foo') return 1;
+ else return 0;
+ }
+}
diff --git a/assets/snippets/ditto/extenders/glossaryFilter.extender.inc.php b/assets/snippets/ditto/extenders/glossaryFilter.extender.inc.php
index ca2ba4db8d..a08c38f995 100644
--- a/assets/snippets/ditto/extenders/glossaryFilter.extender.inc.php
+++ b/assets/snippets/ditto/extenders/glossaryFilter.extender.inc.php
@@ -39,16 +39,14 @@
$filters['custom']['glossaryFilter'] = array($GLOBALS['filterVar'], 'glossaryFilter');
if (!function_exists('glossaryFilter')) {
- function glossaryFilter($resource) {
- if (!$GLOBALS['filterBy']) {
- # do nothing (simply leave document within final dataset)
- return 1;
- }
+ function glossaryFilter($resource) {
+ if (!$GLOBALS['filterBy']) {
+ // do nothing (simply leave document within final dataset)
+ return 1;
+ }
$regExpBegin = preg_match('/^(chunk|custom)$/', $GLOBALS['filterMode']) ? '' : '/^[';
$regExpEnd = preg_match('/^(chunk|custom)$/', $GLOBALS['filterMode']) ? '' : ']/i' . $GLOBALS['forceUTF8'];
- # do filtering
+ // do filtering
return preg_match($regExpBegin . $GLOBALS['filterBy'] . $regExpEnd, $resource[$GLOBALS['filterVar']]) ? 1 : 0;
- }
+ }
}
-
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/jotcount.extender.inc.php b/assets/snippets/ditto/extenders/jotcount.extender.inc.php
index 0f465873b4..483e95b33e 100644
--- a/assets/snippets/ditto/extenders/jotcount.extender.inc.php
+++ b/assets/snippets/ditto/extenders/jotcount.extender.inc.php
@@ -1,23 +1,21 @@
db->select('uparent, COUNT(*)', $modx->getFullTableName("jot_content"), 'published=1 AND deleted=0 GROUP BY uparent', 'COUNT(*) DESC');
+$where = 'published=1 AND deleted=0 GROUP BY uparent';
+$result = $modx->db->select('uparent, COUNT(*)', '[+prefix+]jot_content', $where, 'COUNT(*) DESC');
$counts = $modx->db->makeArray( $result );
-// document_id => comments_count
$jotcount = array();
-foreach($counts as $k=>$v) $jotcount[$v['uparent']] = $v['COUNT(*)'];
-// "" jotph()
+foreach($counts as $k=>$v) {
+ $jotcount[$v['uparent']] = $v['COUNT(*)'];
+}
+
$GLOBALS['jotcount'] = $jotcount;
-// [+jotcount+] ditto
-$placeholders['jotcount'] = array(array("id","*"),"jotph","id");
+$placeholders['jotcount'] = array(array('id','*'),'jotph','id');
-// , [+jotcount+] &tpl
-if(!function_exists("jotph")) {
- function jotph($resource) {
- global $jotcount;
- if(!$r = $jotcount[$resource['id']]) $r = 0;
- return $r;
- }
+if(!function_exists('jotph')) {
+ function jotph($resource) {
+ global $jotcount;
+ if(!$r = $jotcount[$resource['id']]) $r = 0;
+ return $r;
+ }
}
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/level.extender.inc.php b/assets/snippets/ditto/extenders/level.extender.inc.php
index 245fe50b4f..e646e4ce3d 100644
--- a/assets/snippets/ditto/extenders/level.extender.inc.php
+++ b/assets/snippets/ditto/extenders/level.extender.inc.php
@@ -3,16 +3,13 @@
Параметр &level — уровень от корня сайта
*/
-$GLOBALS["level"] = isset($level) ? (int)$level : 1;
-$filters["custom"]["levelFilter"] = array("id","levelFilter");
-if (!function_exists("levelFilter")) {
- function levelFilter($resource) {
- global $modx,$level;
- if (count($modx->getParentIds($resource['id'])) == $level) {
- return 1;
- } else {
- return 0;
- }
- }
+$GLOBALS['level'] = isset($level) ? (int)$level : 1;
+$filters['custom']['levelFilter'] = array('id','levelFilter');
+
+if (!function_exists('levelFilter')) {
+ function levelFilter($resource) {
+ global $modx,$level;
+ if (count($modx->getParentIds($resource['id'])) == $level) return 1;
+ else return 0;
+ }
}
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/request.extender.inc.php b/assets/snippets/ditto/extenders/request.extender.inc.php
index 6020d719b7..90c68f14bf 100644
--- a/assets/snippets/ditto/extenders/request.extender.inc.php
+++ b/assets/snippets/ditto/extenders/request.extender.inc.php
@@ -2,101 +2,99 @@
/*
* Title: Request
* Purpose:
- * Adds support for changing Ditto parameters via URL
+ * Adds support for changing Ditto parameters via URL
*
* Note:
- * - All variables must be prefixed with ditto_ for the snippet to recognize them!
- * - If a Ditto id is set use the sntax
+ * - All variables must be prefixed with ditto_ for the snippet to recognize them!
+ * - If a Ditto id is set use the sntax
*/
$variables = array();
$stripTags = isset($stripTags) ? $stripTags : 1;
/*
- Param: stripTags
-
- Purpose:
- Remove HTML tags from the parameters provided
+ Param: stripTags
+
+ Purpose:
+ Remove HTML tags from the parameters provided
- Options:
- 0 - off
- 1 - on
-
- Default:
- 1 - on
+ Options:
+ 0 - off
+ 1 - on
+
+ Default:
+ 1 - on
*/
-$bad = isset($bad) ? explode(",",$bad) : array("seeThroughtUnpub","showInMenuOnly","showPublishedOnly","debug","start","config","extenders","dittoID");
+$bad = isset($bad) ? explode(',',$bad) : explode(',', 'seeThroughtUnpub,showInMenuOnly,showPublishedOnly,debug,start,config,extenders,dittoID');
/*
- Param: bad
-
- Purpose:
- Parameters that are not allowed to be set
-
- Options:
- Any valid Ditto options separated by commas
-
- Default:
- "seeThroughtUnpub,showInMenuOnly,showPublishedOnly,debug,start,config,extenders,dittoID"
+ Param: bad
+
+ Purpose:
+ Parameters that are not allowed to be set
+
+ Options:
+ Any valid Ditto options separated by commas
+
+ Default:
+ 'seeThroughtUnpub,showInMenuOnly,showPublishedOnly,debug,start,config,extenders,dittoID'
*/
-$good = isset($good) ? explode(",",$good) : false;
+$good = isset($good) ? explode(',',$good) : false;
/*
- Param: good
-
- Purpose:
- Parameters that are allowed to be set
-
- Options:
- Any valid Ditto options separated by commas
-
- Default:
- All parameters execpt those in &bad
+ Param: good
+
+ Purpose:
+ Parameters that are allowed to be set
+
+ Options:
+ Any valid Ditto options separated by commas
+
+ Default:
+ All parameters execpt those in &bad
*/
foreach ($_REQUEST as $name=>$value) {
- $saneName = str_replace($dittoID, "", substr($name, 6));
- $dID = ($dittoID == "") ? true : strpos($name, $dittoID);
- if ((substr($name, 0, 6) == "ditto_" && $dID) && !in_array($saneName,$bad) && ($good == false || in_array($saneName,$good)) && !preg_match("/[\^`~!\/@\\#\}\$%:;\)\(\{&\*=\|'\+]/", $value)){
- if ($stripTags) $var = $modx->stripTags($value);
- if ($saneName == 'orderBy') {
- $variables[$saneName] = array('parsed'=>array(),'custom'=>array(),'unparsed'=>trim($value));
- }else{
- $variables[$saneName] = trim($value);
- }
- }
+ $saneName = str_replace($dittoID, '', substr($name, 6));
+ $dID = ($dittoID == '') ? true : strpos($name, $dittoID);
+ if ((substr($name, 0, 6) == 'ditto_' && $dID) && !in_array($saneName,$bad) && ($good == false || in_array($saneName,$good)) && !preg_match("/[\^`~!\/@\\#\}\$%:;\)\(\{&\*=\|'\+]/", $value)){
+ if ($stripTags) $var = $modx->stripTags($value);
+ if ($saneName == 'orderBy') {
+ $variables[$saneName] = array('parsed'=>array(),'custom'=>array(),'unparsed'=>trim($value));
+ }else{
+ $variables[$saneName] = trim($value);
+ }
+ }
}
/*
- Param: dbg
-
- Purpose:
- Output variables being set
-
- Options:
- 0 - off
- 1 - on
-
- Default:
- 0 - off
+ Param: dbg
+
+ Purpose:
+ Output variables being set
+
+ Options:
+ 0 - off
+ 1 - on
+
+ Default:
+ 0 - off
*/
-if ($_REQUEST[$dittoID."dbg"]==1) {print_r($variables);}
+if ($_REQUEST[$dittoID.'dbg']==1) print_r($variables);
extract($variables);
// ------------------------------------------------------------------------------//
-// Kudo's MultiFilter Code //
+// Kudo's MultiFilter Code //
// ------------------------------------------------------------------------------//
-// Accepts ditto_filter, ditto_filter_2, with continuous numbering //
+// Accepts ditto_filter, ditto_filter_2, with continuous numbering //
// Note: For complex filtering start with ditto_filter_1 (with one as number)! //
// ------------------------------------------------------------------------------//
if (isset($filter) && isset($filter_2)) {
- $i = 2;
- while (isset(${'filter_'.$i})) {
- $filter .= '|'.${'filter_'.$i};
- $i++;
- }
- } elseif (!isset($filter) && isset($filter_1)) {
- $filter = $filter_1;
- $i = 2;
- while (isset(${'filter_'.$i})) {
- $filter .= '|'.${'filter_'.$i};
- $i++;
- }
+ $i = 2;
+ while (isset(${'filter_'.$i})) {
+ $filter .= '|'.${'filter_'.$i};
+ $i++;
+ }
+} elseif (!isset($filter) && isset($filter_1)) {
+ $filter = $filter_1;
+ $i = 2;
+ while (isset(${'filter_'.$i})) {
+ $filter .= '|'.${'filter_'.$i};
+ $i++;
+ }
}
-
-?>
\ No newline at end of file
diff --git a/assets/snippets/ditto/extenders/tagging.extender.class.inc.php b/assets/snippets/ditto/extenders/tagging.extender.class.inc.php
new file mode 100644
index 0000000000..cfaa019caf
--- /dev/null
+++ b/assets/snippets/ditto/extenders/tagging.extender.class.inc.php
@@ -0,0 +1,174 @@
+delimiter = $delimiter;
+ $this->source = $this->parseTagData($source);
+ $this->mode = $mode;
+ $this->landing = $landing;
+ $this->format = $format;
+ $this->givenTags = $this->prepGivenTags($givenTags);
+ $this->caseSensitive = $caseSensitive;
+ $this->displayDelimiter = $displayDelimiter;
+ $this->sort = $sort;
+ $this->displayMode = $displayMode;
+ $this->tpl = $tpl;
+ $this->callback = $callback;
+ }
+
+ function prepGivenTags ($givenTags) {
+ global $modx,$_GET,$dittoID;
+
+ $getTags = !empty($_GET[$dittoID.'tags']) ? $modx->stripTags(trim($_GET[$dittoID.'tags'])) : false;
+ // Get tags from the $_GET array
+
+ $tags1 = array();
+ $tags2 = array();
+
+ if ($getTags !== false) $tags1 = explode($this->delimiter,$getTags);
+
+ if ($givenTags !== false) $tags2 = explode($this->delimiter,$givenTags);
+
+ $kTags = array();
+ $tags = array_merge($tags1,$tags2);
+ foreach ($tags as $tag) {
+ if (empty($tag)) continue;
+
+ if (!$this->caseSensitive) $tag = strtolower($tag);
+ $tag = trim($tag);
+ $kTags[strtolower($tag)] = $tag;
+ }
+ return $kTags;
+ }
+
+ function tagFilter ($value) {
+ if ($this->caseSensitive == false) {
+ $documentTags = array_values(array_flip($this->givenTags));
+ $filterTags = array_values(array_flip($this->combineTags($this->source, $value,true)));
+ } else {
+ $documentTags = $this->givenTags;
+ $filterTags =$this->combineTags($this->source, $value,true);
+ }
+ $compare = array_intersect($filterTags, $documentTags);
+ $commonTags = count($compare);
+ $totalTags = count($filterTags);
+ $docTags = count($documentTags);
+
+ $unset = 1;
+ switch ($this->mode) {
+ case 'onlyAllTags' :
+ if ($commonTags != $docTags) $unset = 0;
+ break;
+ case 'removeAllTags' :
+ if ($commonTags == $docTags) $unset = 0;
+ break;
+ case 'onlyTags' :
+ if ($commonTags > $totalTags || $commonTags == 0) $unset = 0;
+ break;
+ case 'removeTags' :
+ if ($commonTags <= $totalTags && $commonTags != 0) $unset = 0;
+ break;
+ }
+ return $unset;
+ }
+
+ function makeLinks($resource) {
+ return $this->tagLinks($this->combineTags($this->source,$resource,true), $this->delimiter, $this->landing, $this->format);
+ }
+
+ function parseTagData($tagData,$names=array()) {
+ return explode(',',$tagData);
+ }
+
+ function combineTags($tagData, $resource, $array=false) {
+ if ($this->callback !== false) {
+ return call_user_func_array($this->callback,array('tagData'=>$tagData,'resource'=>$resource,'array'=>$array));
+ }
+ $tags = array();
+ foreach ($tagData as $source) {
+ if(!empty($resource[$source])) {
+ $tags[] = $resource[$source];
+ }
+ }
+ $kTags = array();
+ $tags = explode($this->delimiter,implode($this->delimiter,$tags));
+ foreach ($tags as $tag) {
+ if (!empty($tag)) {
+ if ($this->caseSensitive) {
+ $kTags[trim($tag)] = trim($tag);
+ } else {
+ $kTags[strtolower(trim($tag))] = trim($tag);
+ }
+ }
+ }
+ return ($array == true) ? $kTags : implode($this->delimiter,$kTags);
+ }
+
+ function tagLinks($tags, $tagDelimiter, $tagID=false, $format='html') {
+ global $ditto_lang,$modx;
+ if(count($tags) == 0 && $format=='html') {
+ return $ditto_lang['none'];
+ } else if (count($tags) == 0 && ($format=='rss' || $format=='xml' || $format == 'xml'))
+ {
+ return ''.$ditto_lang['none'].'';
+ }
+
+ $output = '';
+ if ($this->sort) {
+ ksort($tags);
+ }
+
+ // set templates array
+ $tplRss = "\r\n".' [+tag+]';
+ $tpl = ($this->tpl == false) ? '[+tag+]' : $this->tpl;
+
+ $tpl = (in_array($format, array('rss','xml','atom')) && $templates['user'] == false) ? $tplRss : $tpl;
+
+ if ($this->displayMode == 1) {
+ foreach ($tags as $tag) {
+ $tagDocID = (!$tagID) ? $modx->documentObject['id'] : $tagID;
+ $url = ditto::buildURL("tags={$tag}&start=0",$tagDocID);
+ $output .= template::replace(array('url'=>$url,'tag'=>$tag),$tpl);
+ $output .= ($format != 'rss' && $format != 'xml' && $format != 'atom') ? $this->displayDelimiter : '';
+ }
+ } else if (!in_array($format, array('rss','xml','atom')) && $this->displayMode == 2) {
+ $tagList = array();
+ foreach ($tags as $tag) {
+ $tagDocID = (!$tagID) ? $modx->documentObject['id'] : $tagID;
+ $url = ditto::buildURL("tags={$tag}&start=0",$tagDocID);
+ $tagList[] = template::replace(array('url'=>$url,'tag'=>$tag),$tpl);
+ }
+ $output = $this->makeList($tagList, 'ditto_tag_list', 'ditto_tag_');
+ }
+
+ return (!in_array($format, array('rss','xml','atom'))) ? substr($output,0,-1*strlen($this->displayDelimiter)) : $output;
+ }
+
+ function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) {
+ // first find out whether the value passed is an array
+ if (!is_array($array)) {
+ return '';
+ }
+ if (!empty ($type)) {
+ $typestr= " style='list-style-type: {$type}'";
+ } else {
+ $typestr= '';
+ }
+ $tabs= '';
+ for ($i= 0; $i < $tablevel; $i++) {
+ $tabs .= "\t";
+ }
+ $listhtml= $ordered == true ? $tabs . "\n" : $tabs . "\n";
+ foreach ($array as $key => $value) {
+ if (is_array($value)) {
+ $listhtml .= $tabs . "\t- " . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix, $type, $ordered, $tablevel +2) . $tabs . "\t
\n";
+ } else {
+ $listhtml .= $tabs . "\t- " . $value . "
\n";
+ }
+ }
+ $listhtml .= $ordered == true ? $tabs . "
\n" : $tabs . "\n";
+ return $listhtml;
+ }
+}
diff --git a/assets/snippets/ditto/extenders/tagging.extender.inc.php b/assets/snippets/ditto/extenders/tagging.extender.inc.php
index 6ba6ec9aff..3b2152182f 100644
--- a/assets/snippets/ditto/extenders/tagging.extender.inc.php
+++ b/assets/snippets/ditto/extenders/tagging.extender.inc.php
@@ -1,5 +1,7 @@
delimiter = $delimiter;
- $this->source = $this->parseTagData($source);
- $this->mode = $mode;
- $this->landing = $landing;
- $this->format = $format;
- $this->givenTags = $this->prepGivenTags($givenTags);
- $this->caseSensitive = $caseSensitive;
- $this->displayDelimiter = $displayDelimiter;
- $this->sort = $sort;
- $this->displayMode = $displayMode;
- $this->tpl = $tpl;
- $this->callback = $callback;
- }
-
- function prepGivenTags ($givenTags) {
- global $modx,$_GET,$dittoID;
-
- $getTags = !empty($_GET[$dittoID.'tags']) ? $modx->stripTags(trim($_GET[$dittoID.'tags'])) : false;
- // Get tags from the $_GET array
-
- $tags1 = array();
- $tags2= array();
-
- if ($getTags !== false) {
- $tags1 = explode($this->delimiter,$getTags);
- }
-
- if ($givenTags !== false) {
- $tags2 = explode($this->delimiter,$givenTags);
- }
-
- $kTags = array();
- $tags = array_merge($tags1,$tags2);
- foreach ($tags as $tag) {
- if (!empty($tag)) {
- if ($this->caseSensitive) {
- $kTags[trim($tag)] = trim($tag);
- } else {
- $kTags[strtolower(trim($tag))] = trim($tag);
- }
- }
- }
- return $kTags;
- }
-
- function tagFilter ($value) {
- if ($this->caseSensitive == false) {
- $documentTags = array_values(array_flip($this->givenTags));
- $filterTags = array_values(array_flip($this->combineTags($this->source, $value,true)));
- } else {
- $documentTags = $this->givenTags;
- $filterTags =$this->combineTags($this->source, $value,true);
- }
- $compare = array_intersect($filterTags, $documentTags);
- $commonTags = count($compare);
- $totalTags = count($filterTags);
- $docTags = count($documentTags);
- $unset = 1;
-
- switch ($this->mode) {
- case "onlyAllTags" :
- if ($commonTags != $docTags)
- $unset = 0;
- break;
- case "removeAllTags" :
- if ($commonTags == $docTags)
- $unset = 0;
- break;
- case "onlyTags" :
- if ($commonTags > $totalTags || $commonTags == 0)
- $unset = 0;
- break;
- case "removeTags" :
- if ($commonTags <= $totalTags && $commonTags != 0)
- $unset = 0;
- break;
- }
- return $unset;
- }
-
- function makeLinks($resource) {
- return $this->tagLinks($this->combineTags($this->source,$resource,true), $this->delimiter, $this->landing, $this->format);
- }
-
- function parseTagData($tagData,$names=array()) {
- return explode(",",$tagData);
- }
-
- function combineTags($tagData, $resource, $array=false) {
- if ($this->callback !== false) {
- return call_user_func_array($this->callback,array('tagData'=>$tagData,'resource'=>$resource,'array'=>$array));
- }
- $tags = array();
- foreach ($tagData as $source) {
- if(!empty($resource[$source])) {
- $tags[] = $resource[$source];
- }
- }
- $kTags = array();
- $tags = explode($this->delimiter,implode($this->delimiter,$tags));
- foreach ($tags as $tag) {
- if (!empty($tag)) {
- if ($this->caseSensitive) {
- $kTags[trim($tag)] = trim($tag);
- } else {
- $kTags[strtolower(trim($tag))] = trim($tag);
- }
- }
- }
- return ($array == true) ? $kTags : implode($this->delimiter,$kTags);
- }
-
- function tagLinks($tags, $tagDelimiter, $tagID=false, $format="html") {
- global $ditto_lang,$modx;
- if(count($tags) == 0 && $format=="html") {
- return $ditto_lang['none'];
- } else if (count($tags) == 0 && ($format=="rss" || $format=="xml" || $format == "xml"))
- {
- return "".$ditto_lang['none']."";
- }
-
- $output = "";
- if ($this->sort) {
- ksort($tags);
- }
-
- // set templates array
- $tplRss = "\r\n"." [+tag+]";
- $tpl = ($this->tpl == false) ? '[+tag+]' : $this->tpl;
-
- $tpl = (($format == "rss" || $format == "xml" || $format == "atom") && $templates['user'] == false) ? $tplRss : $tpl;
-
- if ($this->displayMode == 1) {
- foreach ($tags as $tag) {
- $tagDocID = (!$tagID) ? $modx->documentObject['id'] : $tagID;
- $url = ditto::buildURL("tags=$tag&start=0",$tagDocID);
- $output .= template::replace(array('url'=>$url,'tag'=>$tag),$tpl);
- $output .= ($format != "rss" && $format != "xml" && $format != "atom") ? $this->displayDelimiter : '';
- }
- } else if ($format != "rss" && $format != "xml" && $format != "atom" && $this->displayMode == 2) {
- $tagList = array();
- foreach ($tags as $tag) {
- $tagDocID = (!$tagID) ? $modx->documentObject['id'] : $tagID;
- $url = ditto::buildURL("tags=$tag&start=0",$tagDocID);
- $tagList[] = template::replace(array('url'=>$url,'tag'=>$tag),$tpl);
- }
- $output = $this->makeList($tagList, $ulroot='ditto_tag_list', $ulprefix='ditto_tag_', $type='', $ordered=false, $tablevel=0);
- }
-
- return ($format != "rss" && $format != "xml" && $format != "atom") ? substr($output,0,-1*strlen($this->displayDelimiter)) : $output;
- }
-
- function makeList($array, $ulroot= 'root', $ulprefix= 'sub_', $type= '', $ordered= false, $tablevel= 0) {
- // first find out whether the value passed is an array
- if (!is_array($array)) {
- return "";
- }
- if (!empty ($type)) {
- $typestr= " style='list-style-type: $type'";
- } else {
- $typestr= "";
- }
- $tabs= "";
- for ($i= 0; $i < $tablevel; $i++) {
- $tabs .= "\t";
- }
- $listhtml= $ordered == true ? $tabs . "\n" : $tabs . "\n";
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $listhtml .= $tabs . "\t- " . $key . "\n" . $this->makeList($value, $ulprefix . $ulroot, $ulprefix, $type, $ordered, $tablevel +2) . $tabs . "\t
\n";
- } else {
- $listhtml .= $tabs . "\t- " . $value . "
\n";
- }
- }
- $listhtml .= $ordered == true ? $tabs . "
\n" : $tabs . "\n";
- return $listhtml;
- }
- }
-}
-
// ---------------------------------------------------
// Tagging Parameters
// ---------------------------------------------------
diff --git a/assets/snippets/ditto/snippet.ditto.php b/assets/snippets/ditto/snippet.ditto.php
index dbc6341f3c..47ad3f8be5 100644
--- a/assets/snippets/ditto/snippet.ditto.php
+++ b/assets/snippets/ditto/snippet.ditto.php
@@ -6,7 +6,7 @@
* Summarizes and lists pages to create blogs, catalogs, PR archives, bio listings and more
*
* @category snippet
- * @version 2.1.2
+ * @version 2.1.2
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
* @internal @properties
* @internal @modx_category Content
@@ -22,11 +22,11 @@
//---Core Settings---------------------------------------------------- //
-$ditto_version = "2.1.2";
+$ditto_version = '2.1.2';
// Ditto version being executed
-if(!isset($ditto_base)) $ditto_base = 'assets/snippets/ditto/';
-$ditto_base = $modx->config['base_path'].ltrim($ditto_base,'/');
+if(isset($ditto_base)) $ditto_base = $modx->config['base_path'].ltrim($ditto_base,'/');
+else $ditto_base = str_replace('\\','/',__DIR__) . '/';
/*
Param: ditto_base
@@ -54,11 +54,11 @@
This is case sensitive
Default:
- "" - blank
+ '' - blank
*/
if(!isset($language)) $language = $modx->config['manager_language'];
if (!is_file("{$ditto_base}lang/{$language}.inc.php")) {
- $language ="english";
+ $language ='english';
}
/*
Param: language
@@ -70,9 +70,9 @@
Any language name with a corresponding file in the &ditto_base/lang folder
Default:
- "english"
+ 'english'
*/
-$format = (isset($format)) ? strtolower($format) : "html" ;
+$format = (isset($format)) ? strtolower($format) : 'html' ;
/*
Param: format
@@ -80,16 +80,16 @@
Output format to use
Options:
- - "html"
- - "json"
- - "xml"
- - "atom"
- - "rss"
+ - 'html'
+ - 'json'
+ - 'xml'
+ - 'atom'
+ - 'rss'
Default:
- "html"
+ 'html'
*/
-$config = (isset($config)) ? $config : "default";
+$config = (isset($config)) ? $config : 'default';
/*
Param: config
@@ -97,11 +97,11 @@
Load a custom configuration
Options:
- "default" - default blank config file
+ 'default' - default blank config file
CONFIG_NAME - Other configs installed in the configs folder or in any folder within the MODX base path via @FILE
Default:
- "default"
+ 'default'
Related:
-
@@ -137,7 +137,7 @@
Default:
1 - on
*/
-$extenders = isset($extenders) ? explode(",",$extenders) : array();
+$extenders = isset($extenders) ? explode(',',$extenders) : array();
/*
Param: extenders
@@ -160,81 +160,81 @@
// Variable: placeholders
// Initialize custom placeholders array for configs or extenders to add to
-$filters = array("custom"=>array(),"parsed"=>array());
+$filters = array('custom'=>array(),'parsed'=>array());
// Variable: filters
// Holds both the custom filters array for configs or extenders to add to
// and the parsed filters array. To add to this array, use the following format
// (code)
- // $filters["parsed"][] = array("name" => array("source"=>$source,"value"=>$value,"mode"=>$mode));
- // $filters["custom"][] = array("source","callback_function");
+ // $filters['parsed'][] = array('name' => array('source'=>$source,'value'=>$value,'mode'=>$mode));
+ // $filters['custom'][] = array('source','callback_function');
$orderBy = array('parsed'=>array(),'custom'=>array(),'unparsed'=>(isset($orderBy) ? $orderBy : ''));
// Variable: orderBy
// An array that holds all criteria to sort the result set by.
// Note that using a custom sort will disable all other sorting.
// (code)
- // $orderBy["parsed"][] = array("sortBy","sortDir");
- // $orderBy["custom"][] = array("sortBy","callback_function");
+ // $orderBy['parsed'][] = array('sortBy','sortDir');
+ // $orderBy['custom'][] = array('sortBy','callback_function');
//---Includes-------------------------------------------------------- //
$files = array (
- "base_language" => $ditto_base."lang/english.inc.php",
- "language" => $ditto_base."lang/$language.inc.php",
- "main_class" => $ditto_base."classes/ditto.class.inc.php",
- "template_class" => $ditto_base."classes/template.class.inc.php",
- "filter_class" => $ditto_base."classes/filter.class.inc.php",
- "format" => $ditto_base."formats/$format.format.inc.php",
- "config" => $ditto_base."configs/default.config.php",
- "user_config" => (substr($config, 0, 5) != "@FILE") ? $ditto_base."configs/$config.config.php" : $modx->config['base_path'].trim(substr($config, 5))
+ 'base_language' => "{$ditto_base}lang/english.inc.php",
+ 'language' => "{$ditto_base}lang/{$language}.inc.php",
+ 'main_class' => "{$ditto_base}classes/ditto.class.inc.php",
+ 'template_class' => "{$ditto_base}classes/template.class.inc.php",
+ 'filter_class' => "{$ditto_base}classes/filter.class.inc.php",
+ 'format' => "{$ditto_base}formats/$format.format.inc.php",
+ 'config' => "{$ditto_base}configs/default.config.php",
+ 'user_config' => (substr($config, 0, 5) != '@FILE') ? "{$ditto_base}configs/{$config}.config.php" : $modx->config['base_path'].trim(substr($config, 5))
);
-if ($phx == 1) {
- $files["prePHx_class"] = $ditto_base."classes/phx.pre.class.inc.php";
+if ($phx == 1 && !$modx->config['enable_filter']) {
+ $files['prePHx_class'] = $ditto_base.'classes/phx.pre.class.inc.php';
}
if (isset($randomize)) {
- $files["randomize_class"] = $ditto_base."classes/random.class.inc.php";
+ $files['randomize_class'] = $ditto_base.'classes/random.class.inc.php';
}
if ($debug == 1) {
- $files["modx_debug_class"] = $ditto_base."debug/modxDebugConsole.class.php";
- $files["debug_class"] = $ditto_base."classes/debug.class.inc.php";
- $files["debug_templates"] = $ditto_base."debug/debug.templates.php";
+ $files['modx_debug_class'] = $ditto_base."debug/modxDebugConsole.class.php";
+ $files['debug_class'] = $ditto_base."classes/debug.class.inc.php";
+ $files['debug_templates'] = $ditto_base."debug/debug.templates.php";
}
$files = array_unique($files);
foreach ($files as $filename => $filevalue) {
- if (file_exists($filevalue) && strpos($filename,"class")) {
+ if (is_file($filevalue) && strpos($filename,'class')!==false) {
include_once($filevalue);
- } else if (file_exists($filevalue)) {
+ } elseif (is_file($filevalue)) {
include($filevalue);
- } else if ($filename == "language") {
- $modx->logEvent(1, 3, "Language file does not exist Please check: " . $filevalue, "Ditto " . $ditto_version);
- return "Language file does not exist Please check: " . $filevalue;
+ } elseif ($filename == 'language') {
+ $modx->logEvent(1, 3, 'Language file does not exist Please check: ' . $filevalue, 'Ditto ' . $ditto_version);
+ return 'Language file does not exist Please check: ' . $filevalue;
} else {
- $modx->logEvent(1, 3, $filevalue . " " . $_lang['file_does_not_exist'], "Ditto " . $ditto_version);
- return $filevalue . " " . $_lang['file_does_not_exist'];
+ $modx->logEvent(1, 3, $filevalue . ' ' . $_lang['file_does_not_exist'], 'Ditto ' . $ditto_version);
+ return $filevalue . ' ' . $_lang['file_does_not_exist'];
}
}
//---Initiate Class-------------------------------------------------- //
if (class_exists('ditto')) {
- $dbg_templates = (isset($dbg_templates)) ? $dbg_templates : NULL;
- $ditto = new ditto($dittoID, $format, $_lang, $dbg_templates);
- // create a new Ditto instance in the specified format and language with the requested debug level
+ $dbg_templates = (isset($dbg_templates)) ? $dbg_templates : NULL;
+ $ditto = new ditto($dittoID, $format, $_lang, $dbg_templates);
+ // create a new Ditto instance in the specified format and language with the requested debug level
} else {
- $modx->logEvent(1,3,$_lang['invalid_class'],"Ditto ".$ditto_version);
+ $modx->logEvent(1,3,$_lang['invalid_class'],'Ditto '.$ditto_version);
return $_lang['invalid_class'];
}
//---Initiate Extenders---------------------------------------------- //
if (isset($tagData)) {
- $extenders[] = "tagging";
+ $extenders[] = 'tagging';
}
if(count($extenders) > 0) {
$extenders = array_unique($extenders);
foreach ($extenders as $extender) {
- if(substr($extender, 0, 5) != "@FILE") {
- $extender_path = $ditto_base."extenders/".$extender.".extender.inc.php";
+ if(substr($extender, 0, 5) != '@FILE') {
+ $extender_path = "{$ditto_base}extenders/{$extender}.extender.inc.php";
} else {
$extender_path = $modx->config['base_path'].trim(substr($extender, 5));
}
@@ -242,8 +242,8 @@
if (file_exists($extender_path)){
include($extender_path);
} else {
- $modx->logEvent(1, 3, $extender . " " . $_lang['extender_does_not_exist'], "Ditto ".$ditto_version);
- return $extender . " " . $_lang['extender_does_not_exist'];
+ $modx->logEvent(1, 3, $extender . ' ' . $_lang['extender_does_not_exist'], 'Ditto '.$ditto_version);
+ return $extender . ' ' . $_lang['extender_does_not_exist'];
}
}
}
@@ -254,12 +254,12 @@
if (isset($limit)) {$queryLimit = $limit;}
if (isset($sortBy) || isset($sortDir) || is_null($orderBy['unparsed'])) {
$sortDir = isset($sortDir) ? strtoupper($sortDir) : 'DESC';
- $sortBy = isset($sortBy) ? $sortBy : "createdon";
+ $sortBy = isset($sortBy) ? $sortBy : 'createdon';
$orderBy['parsed'][]=array($sortBy,$sortDir);
}
// Allow backwards compatibility
-$idType = isset($documents) ? "documents" : "parents";
+$idType = isset($documents) ? 'documents' : 'parents';
// Variable: idType
// type of IDs provided; can be either parents or documents
@@ -298,7 +298,7 @@
-
*/
-$IDs = ($idType == "parents") ? $parents : $documents;
+$IDs = ($idType == 'parents') ? $parents : $documents;
// Variable: IDs
// Internal variable which holds the set of IDs for Ditto to fetch
@@ -339,7 +339,7 @@
-
-
*/
-$dateSource = isset($dateSource) ? $dateSource : "createdon";
+$dateSource = isset($dateSource) ? $dateSource : 'createdon';
/*
Param: dateSource
@@ -350,12 +350,12 @@
# - Any UNIX timestamp from MODX fields or TVs such as createdon, pub_date, or editedon
Default:
- "createdon"
+ 'createdon'
Related:
-
*/
-$dateFormat = isset($dateFormat)? $dateFormat : $_lang["dateFormat"];
+$dateFormat = isset($dateFormat)? $dateFormat : $_lang['dateFormat'];
/*
Param: dateFormat
@@ -371,7 +371,7 @@
Related:
-
*/
-$display = isset($display) ? $display : "all";
+$display = isset($display) ? $display : 'all';
/*
Param: display
@@ -380,16 +380,16 @@
Options:
# - Any number
- "all" - All documents found
+ 'all' - All documents found
Default:
- "all"
+ 'all'
Related:
-
-
*/
-$total = isset($total) ? $total : "all";
+$total = isset($total) ? $total : 'all';
/*
Param: total
@@ -398,10 +398,10 @@
Options:
# - Any number
- "all" - All documents found
+ 'all' - All documents found
Default:
- "all" - All documents found
+ 'all' - All documents found
Related:
-
@@ -521,7 +521,7 @@
Related:
-
*/
-$where = (isset($where))? $where : "";
+$where = (isset($where))? $where : '';
/*
Param: where
@@ -537,7 +537,7 @@
Related:
-
*/
-$noResults = isset($noResults)? $ditto->getParam($noResults,"no_documents") : $_lang['no_documents'];
+$noResults = isset($noResults)? $ditto->getParam($noResults,'no_documents') : $_lang['no_documents'];
/*
Param: noResults
@@ -550,7 +550,7 @@
Default:
[LANG]
*/
-$removeChunk = isset($removeChunk) ? explode(",",$removeChunk) : false;
+$removeChunk = isset($removeChunk) ? explode(',',$removeChunk) : false;
/*
Param: removeChunk
@@ -564,7 +564,7 @@
Default:
[NULL]
*/
-$hiddenFields = isset($hiddenFields) ? explode(",",$hiddenFields) : false;
+$hiddenFields = isset($hiddenFields) ? explode(',',$hiddenFields) : false;
/*
Param: hiddenFields
@@ -591,7 +591,7 @@
Default:
0
*/
-$globalFilterDelimiter = isset($globalFilterDelimiter) ? $globalFilterDelimiter : "|";
+$globalFilterDelimiter = isset($globalFilterDelimiter) ? $globalFilterDelimiter : '|';
/*
Param: globalFilterDelimiter
@@ -602,7 +602,7 @@
Any character not used in the filters
Default:
- "|"
+ '|'
Related:
-
@@ -610,7 +610,7 @@
-
*/
-$localFilterDelimiter = isset($localFilterDelimiter) ? $localFilterDelimiter : ",";
+$localFilterDelimiter = isset($localFilterDelimiter) ? $localFilterDelimiter : ',';
/*
Param: localFilterDelimiter
@@ -621,17 +621,17 @@
Any character not used in the filter itself
Default:
- ","
+ ','
Related:
-
-
-
*/
-$filters["custom"] = isset($cFilters) ? array_merge($filters["custom"],$cFilters) : $filters["custom"];
-$filters["parsed"] = isset($parsedFilters) ? array_merge($filters["parsed"],$parsedFilters) : $filters["parsed"];
+$filters['custom'] = isset($cFilters) ? array_merge($filters['custom'],$cFilters) : $filters['custom'];
+$filters['parsed'] = isset($parsedFilters) ? array_merge($filters['parsed'],$parsedFilters) : $filters['parsed'];
// handle 2.0.0 compatibility
-$filter = (isset($filter) || ($filters["custom"] != false) || ($filters["parsed"] != false)) ? $ditto->parseFilters($filter,$filters["custom"],$filters["parsed"],$globalFilterDelimiter,$localFilterDelimiter) : false;
+$filter = (isset($filter) || ($filters['custom'] != false) || ($filters['parsed'] != false)) ? $ditto->parseFilters($filter,$filters['custom'],$filters['parsed'],$globalFilterDelimiter,$localFilterDelimiter) : false;
/*
Param: filter
@@ -700,12 +700,12 @@
0 - off; returns output
*/
$templates = array(
- "default" => "@CODE" . $_lang['default_template'],
- "base" => (isset($tpl)) ? $tpl : NULL,
- "alt" => (isset($tplAlt)) ? $tplAlt : NULL,
- "first" => (isset($tplFirst)) ? $tplFirst : NULL,
- "last" => (isset($tplLast)) ? $tplLast : NULL,
- "current" => (isset($tplCurrentDocument)) ? $tplCurrentDocument : NULL
+ 'default' => '@CODE' . $_lang['default_template'],
+ 'base' => (isset($tpl)) ? $tpl : NULL,
+ 'alt' => (isset($tplAlt)) ? $tplAlt : NULL,
+ 'first' => (isset($tplFirst)) ? $tplFirst : NULL,
+ 'last' => (isset($tplLast)) ? $tplLast : NULL,
+ 'current' => (isset($tplCurrentDocument)) ? $tplCurrentDocument : NULL
);
/*
Param: tpl
@@ -800,7 +800,7 @@
$ditto->parseFields($placeholders,$seeThruUnpub,$dateSource,$randomize);
// parse the fields into the field array
-$documentIDs = $ditto->determineIDs($IDs, $idType, $ditto->fields["backend"]["tv"], $orderBy, $depth, $showPublishedOnly, $seeThruUnpub, $hideFolders, $hidePrivate, $showInMenuOnly, $where, $dateSource, $queryLimit, $display, $filter,$paginate, $randomize);
+$documentIDs = $ditto->determineIDs($IDs, $idType, $ditto->fields['backend']['tv'], $orderBy, $depth, $showPublishedOnly, $seeThruUnpub, $hideFolders, $hidePrivate, $showInMenuOnly, $where, $dateSource, $queryLimit, $display, $filter,$paginate, $randomize);
// retrieves a list of document IDs that meet the criteria and populates the $resources array with them
$count = count($documentIDs);
// count the number of documents to be retrieved
@@ -810,13 +810,13 @@
if ($count > 0) {
// if documents are returned continue with execution
- $total = ($total == "all") ? $count : min($total,$count);
+ $total = ($total == 'all') ? $count : min($total,$count);
// set total equal to count if all documents are to be included
- $display = ($display == "all") ? min($count,$total) : min($display,$total);
+ $display = ($display == 'all') ? min($count,$total) : min($display,$total);
// allow show to use all option
- $stop = ($save != "1") ? min($total-$start,$display) : min($count,$total);
+ $stop = ($save != '1') ? min($total-$start,$display) : min($count,$total);
// set initial stop count
if($paginate == 1) {
@@ -857,7 +857,7 @@
-
-
*/
- $tplPaginatePrevious = isset($tplPaginatePrevious)? $ditto->template->fetch($tplPaginatePrevious) : "[+lang:previous+]";
+ $tplPaginatePrevious = isset($tplPaginatePrevious)? $ditto->template->fetch($tplPaginatePrevious) : '[+lang:previous+]';
/*
Param: tplPaginatePrevious
@@ -877,7 +877,7 @@
-
-
*/
- $tplPaginateNext = isset($tplPaginateNext)? $ditto->template->fetch($tplPaginateNext) : "[+lang:next+]";
+ $tplPaginateNext = isset($tplPaginateNext)? $ditto->template->fetch($tplPaginateNext) : '[+lang:next+]';
/*
Param: tplPaginateNext
@@ -897,7 +897,7 @@
-
-
*/
- $tplPaginateNextOff = isset($tplPaginateNextOff)? $ditto->template->fetch($tplPaginateNextOff) : "[+lang:next+]";
+ $tplPaginateNextOff = isset($tplPaginateNextOff)? $ditto->template->fetch($tplPaginateNextOff) : '[+lang:next+]';
/*
Param: tplPaginateNextOff
@@ -916,7 +916,7 @@
-
-
*/
- $tplPaginatePreviousOff = isset($tplPaginatePreviousOff)? $ditto->template->fetch($tplPaginatePreviousOff) : "[+lang:previous+]";
+ $tplPaginatePreviousOff = isset($tplPaginatePreviousOff)? $ditto->template->fetch($tplPaginatePreviousOff) : '[+lang:previous+]';
/*
Param: tplPaginatePreviousOff
@@ -979,17 +979,17 @@
// generate the pagination placeholders
}
- $dbFields = $ditto->fields["display"]["db"];
+ $dbFields = $ditto->fields['display']['db'];
// get the database fields
- $TVs = $ditto->fields["display"]["tv"];
+ $TVs = $ditto->fields['display']['tv'];
// get the TVs
if(isset($orderBy['parsed'][0][1])) {
switch($orderBy['parsed'][0][1]) {
- case "DESC":
+ case 'DESC':
$stop = ($ditto->prefetch === false) ? $stop + $start + $offset : $stop + $offset;
$start += $offset;
break;
- case "ASC":
+ case 'ASC':
$start += $offset;
$stop += $start;
break;
@@ -999,16 +999,16 @@
if ($ditto->prefetch !== false) {
$documentIDs = array_slice($documentIDs,$start,$stop);
// set the document IDs equal to the trimmed array
- $dbFields = array_diff($dbFields,$ditto->prefetch["fields"]["db"]);
+ $dbFields = array_diff($dbFields,$ditto->prefetch['fields']['db']);
// calculate the difference between the database fields and those already prefetched
- $dbFields[] = "id";
+ $dbFields[] = 'id';
// append id to the db fields array
- $TVs = array_diff($TVs,$ditto->prefetch["fields"]["tv"]);
+ $TVs = array_diff($TVs,$ditto->prefetch['fields']['tv']);
// calculate the difference between the tv fields and those already prefetched
$start = 0;
$stop = min($display,($queryLimit != 0) ? $queryLimit : $display,count($documentIDs));
} else {
- $queryLimit = ($queryLimit == 0) ? "" : $queryLimit;
+ $queryLimit = ($queryLimit == 0) ? '' : $queryLimit;
}
$resource = $ditto->getDocuments($documentIDs, $dbFields, $TVs, $orderBy, $showPublishedOnly, 0, $hidePrivate, $where, $queryLimit, $randomize, $dateSource);
@@ -1017,7 +1017,7 @@
// initialize the output variable and send the header
if ($resource) {
- if ($randomize != "0" && $randomize != "1") {
+ if ($randomize != '0' && $randomize != '1') {
$resource = $ditto->weightedRandom($resource,$randomize,$stop);
// randomize the documents
}
@@ -1025,11 +1025,11 @@
$resource = array_values($resource);
for ($x=$start;$x<$stop;$x++) {
- $template = $ditto->template->determine($templates,$x,0,$stop,$resource[$x]["id"]);
+ $template = $ditto->template->determine($templates,$x,0,$stop,$resource[$x]['id']);
// choose the template to use and set the code of that template to the template variable
$renderedOutput = $ditto->render($resource[$x], $template, $removeChunk, $dateSource, $dateFormat, $placeholders,$phx,abs($start-$x),$stop);
// render the output using the correct template, in the correct format and language
- $modx->setPlaceholder($dittoID."item[".abs($start-$x)."]",$renderedOutput);
+ $modx->setPlaceholder($dittoID.'item['.abs($start-$x).']',$renderedOutput);
/*
Placeholder: item[x]
@@ -1051,8 +1051,8 @@
// ---------------------------------------------------
if($save) {
- $modx->setPlaceholder($dittoID."ditto_object", $ditto);
- $modx->setPlaceholder($dittoID."ditto_resource", ($save == "1") ? array_slice($resource,$display) : $resource);
+ $modx->setPlaceholder($dittoID.'ditto_object', $ditto);
+ $modx->setPlaceholder($dittoID.'ditto_resource', ($save == '1') ? array_slice($resource,$display) : $resource);
}
} else {
$output = $header.$ditto->noResults($noResults,$paginate).$footer;
@@ -1063,16 +1063,16 @@
if ($debug == 1) {
$ditto_params =& $modx->event->params;
- if (!isset($_GET["ditto_".$dittoID."debug"])) {
- $_SESSION["ditto_debug_$dittoID"] = $ditto->debug->render_popup($ditto, $ditto_base, $ditto_version, $ditto_params, $documentIDs, array("db"=>$dbFields,"tv"=>$TVs), $display, $templates, $orderBy, $start, $stop, $total,$filter,$resource);
+ if (!isset($_GET['ditto_'.$dittoID.'debug'])) {
+ $_SESSION['ditto_debug_$dittoID'] = $ditto->debug->render_popup($ditto, $ditto_base, $ditto_version, $ditto_params, $documentIDs, array('db'=>$dbFields,'tv'=>$TVs), $display, $templates, $orderBy, $start, $stop, $total,$filter,$resource);
}
- if (isset($_GET["ditto_".$dittoID."debug"])) {
- switch ($_GET["ditto_".$dittoID."debug"]) {
- case "open" :
- exit($_SESSION["ditto_debug_$dittoID"]);
+ if (isset($_GET['ditto_'.$dittoID.'debug'])) {
+ switch ($_GET['ditto_'.$dittoID.'debug']) {
+ case 'open' :
+ exit($_SESSION['ditto_debug_$dittoID']);
break;
- case "save" :
- $ditto->debug->save($_SESSION["ditto_debug_$dittoID"],"ditto".strtolower($ditto_version)."_debug_doc".$modx->documentIdentifier.".html");
+ case 'save' :
+ $ditto->debug->save($_SESSION['ditto_debug_$dittoID'],'ditto'.strtolower($ditto_version).'_debug_doc'.$modx->documentIdentifier.'.html');
break;
}
} else {
@@ -1081,8 +1081,8 @@
}
// outerTpl by Dmi3yy & Jako
if (isset($outerTpl) && $resource) {
- $outerTpl = $ditto->template->fetch($outerTpl);
- $output = str_replace(array('[+ditto+]', '[+wrapper+]'), $output, $outerTpl);
+ $outerTpl = $ditto->template->fetch($outerTpl);
+ $output = str_replace(array('[+ditto+]', '[+wrapper+]'), $output, $outerTpl);
}
-return ($save != 3) ? $output : "";
\ No newline at end of file
+return ($save != 3) ? $output : '';
\ No newline at end of file
diff --git a/install/assets/plugins/ElementsInTree.tpl b/install/assets/plugins/ElementsInTree.tpl
index 1f3f3ca223..0088ad8fe8 100644
--- a/install/assets/plugins/ElementsInTree.tpl
+++ b/install/assets/plugins/ElementsInTree.tpl
@@ -5,9 +5,9 @@
* Get access to all Elements and Modules inside Manager sidebar
*
* @category plugin
- * @version 1.5.7
+ * @version 1.5.8
* @license http://creativecommons.org/licenses/GPL/2.0/ GNU Public License (GPL v2)
- * @internal @properties &tabTreeTitle=Tree Tab Title;text;Docs;;Custom title of Site Tree tab. &useIcons=Use icons in tabs;list;yes,no;yes;;Icons available in EVO version 1.2 or newer. &treeButtonsInTab=Tree Buttons in tab;list;yes,no;yes;;Move Tree Buttons into Site Tree tab. &unifyFrames=Unify Frames;list;yes,no;yes;;Unify Tree and Main frame style.
+ * @internal @properties &adminRoleOnly=Administrators only;list;yes,no;yes;;Show tabs only for users with administrator role. &treeButtonsInTab=Tree buttons in tab;list;yes,no;yes;;Move Tree buttons into Site Tree tab. &useIcons=Tab icons;list;yes,no;yes;;Use icons in tabs. &unifyFrames=Unify frames;list;yes,no;yes;;Unify style of Tree and Main frame style. &tabTreeTitle=Tree tab title;text;Site;;Custom title of Site Tree tab.
* @internal @events OnManagerTreePrerender,OnManagerTreeRender,OnManagerMainFrameHeaderHTMLBlock,OnTempFormSave,OnTVFormSave,OnChunkFormSave,OnSnipFormSave,OnPluginFormSave,OnModFormSave,OnTempFormDelete,OnTVFormDelete,OnChunkFormDelete,OnSnipFormDelete,OnPluginFormDelete,OnModFormDelete
* @internal @modx_category Manager and Admin
* @internal @installset base
@@ -20,7 +20,7 @@
* @author Nicola1971 https://github.com/Nicola1971
* @author Deesen https://github.com/Deesen
* @author yama https://github.com/yama
- * @lastupdate 27/12/2016
+ * @lastupdate 31/08/2017
*/
require MODX_BASE_PATH.'assets/plugins/elementsintree/plugin.elementsintree.php';
diff --git a/install/assets/snippets/DLcrumbs.tpl b/install/assets/snippets/DLcrumbs.tpl
index 1b817ba189..5ab3642a30 100644
--- a/install/assets/snippets/DLcrumbs.tpl
+++ b/install/assets/snippets/DLcrumbs.tpl
@@ -1,8 +1,8 @@
//conn, "INSERT INTO $dbase.`".$table_prefix."site_plugins` (name,description,plugincode,properties,moduleguid,disabled,category) VALUES('$name','$desc','$plugin','$properties','$guid','0',$category);")) {
echo "".mysqli_error($sqlParser->conn)."
";
return;
diff --git a/manager/actions/help/version_notices/1.3.5.php b/manager/actions/help/version_notices/1.3.5.php
new file mode 100644
index 0000000000..96e7b0659e
--- /dev/null
+++ b/manager/actions/help/version_notices/1.3.5.php
@@ -0,0 +1,17 @@
+INCLUDE_ORDERING_ERROR
Please use the MODX Content Manager instead of accessing this file directly.");
+?>
+
+
+ - ElementsInTree restyled for new theme, version 1.5.8 (Piotr Matysiak)
+ - Fix - <@IF><@ELSEIF><@ELSE><@ENDIF> (yamamoto)
+ - Fix Bugs in Ditto with date and placeholders from version 1.3.4 (yamamoto, Dmi3yy)
+ - Fix tinymce params underfined bug on frontend (dmi3yy)
+ - Fix 65 Plugin parameters are lost after update to the new version (dmi3yy)
+ - no need update.php in extras module (dmi3yy)
+ - Fix variable documentDirty (64j)
+ - Make sortable list more condensed (Piotr Matysiak)
+ - #187 Ditto is missing placeholders when built-in filters are enabled (yamamoto)
+ - Fix saved roles users #130 (64j)
+ - Fix #192 evo.checkConnectionToServer function (64j)
+
diff --git a/manager/actions/mutate_role.dynamic.php b/manager/actions/mutate_role.dynamic.php
index 1a185317c9..f6b3fa31a6 100644
--- a/manager/actions/mutate_role.dynamic.php
+++ b/manager/actions/mutate_role.dynamic.php
@@ -131,7 +131,6 @@ function changestate(element) {
echo render_form('publish_document', $_lang['role_publish_doc']);
echo render_form('delete_document', $_lang['role_delete_doc']);
echo render_form('empty_trash', $_lang['role_empty_trash']);
- echo render_form('edit_doc_metatags', $_lang['role_edit_doc_metatags']);
echo render_form('empty_cache', $_lang['role_cache_refresh']);
echo render_form('view_unpublished', $_lang['role_view_unpublished']);
?>
@@ -276,7 +275,6 @@ function changestate(element) {
echo render_form('logs', $_lang['role_view_logs']);
echo render_form('settings', $_lang['role_edit_settings']);
echo render_form('bk_manager', $_lang['role_bk_manager']);
- echo render_form('manage_metatags', $_lang['role_manage_metatags']);
echo render_form('import_static', $_lang['role_import_static']);
echo render_form('export_static', $_lang['role_export_static']);
echo render_form('remove_locks', $_lang['role_remove_locks']);
diff --git a/manager/includes/document.parser.class.inc.php b/manager/includes/document.parser.class.inc.php
index f3ee6c79fb..8f00f0a074 100644
--- a/manager/includes/document.parser.class.inc.php
+++ b/manager/includes/document.parser.class.inc.php
@@ -1190,108 +1190,96 @@ function mergePlaceholderContent($content,$ph=false) {
function mergeConditionalTagsContent($content, $iftag='<@IF:', $elseiftag='<@ELSEIF:', $elsetag='<@ELSE>', $endiftag='<@ENDIF>')
{
- if(strpos($content,'')!==false) $content = str_replace('', $elsetag, $content);
- if(strpos($content,'')!==false) $content = str_replace('',$endiftag,$content);
- if(strpos($content,'<@ENDIF-->')!==false) $content = str_replace('<@ENDIF-->',$endiftag,$content);
-
- $bt = md5($content);
+ $content = $this->_prepareCTag($content, $iftag, $elseiftag, $elsetag, $endiftag);
+ if(strpos($content,$iftag)===false) return $content;
+
+ $sp = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#';
+ $content = str_replace(array(''),array("{$sp}b","{$sp}e"),$content);
- $_ = '#'.md5('ConditionalTags'.$_SERVER['REQUEST_TIME']).'#';
- $s = array('<@IF:' , '<@ELSEIF:', '<@ELSE>', '<@ENDIF>');
- $r = array("{$_}<@IF:", "{$_}<@ELSEIF:", "{$_}<@ELSE>", "{$_}<@ENDIF>");
- $content = str_replace($s, $r, $content);
- $splits = explode($_, $content);
- unset($_);
- foreach($splits as $i=>$split) {
+ $pieces = explode('<@IF:', $content);
+ foreach($pieces as $i=>$split) {
if($i===0) {
$content = $split;
- $excute = false;
- $depth = 0;
continue;
}
-
- if (substr($split,0,5)==='<@IF:') $scope = '@IF';
- elseif(substr($split,0,9)==='<@ELSEIF:') $scope = '@ELSEIF';
- elseif(substr($split,0,6)==='<@ELSE') $scope = '@ELSE';
- elseif(substr($split,0,7)==='<@ENDIF') $scope = '@ENDIF';
- else exit('Unknown error '.__LINE__);
-
- if($scope==='@IF') $depth++;
- if(1<$depth) {
- if($scope==='@ENDIF') $depth--;
- if($excute) $content .= $split;
+ list($cmd, $text) = explode('>', $split, 2);
+ $cmd = str_replace("'","\'",$cmd);
+ $content .= "_parseCTagCMD('" . $cmd . "')): ?>";
+ $content .= $text;
+ }
+ $pieces = explode('<@ELSEIF:', $content);
+ foreach($pieces as $i=>$split) {
+ if($i===0) {
+ $content = $split;
continue;
}
- if($scope==='@ENDIF') $depth--;
-
- if($scope==='@IF' || $scope==='@ELSEIF') {
- if($excute) continue;
- $_ = md5('@:>@');
- if(strpos($split,':>')!==false) $split = str_replace(':>', ':'.$_, $split);
- list($cmd, $text) = explode('>', $split, 2);
- $cmd = rtrim($cmd,'-');
- if(strpos($cmd,$_)!==false) $cmd = str_replace($_, '>', $cmd);
- if(strpos($text,$_)!==false) $text = str_replace($_, '>', $text);
- $cmd = substr($cmd,strpos($cmd,':')+1);
- $cmd = trim($cmd);
- $reverse = substr($cmd,0,1)==='!' ? true : false;
- if($reverse) $cmd = ltrim($cmd,'!');
-
- if(strpos($cmd,'[!')!==false) $cmd = str_replace(array('[!','!]'),array('[[',']]'),$cmd);
- $safe=0;
- $bt=md5('');
- $_ = $this->config['enable_filter'];
- $this->config['enable_filter'] = 1;
- while($bt!==md5($cmd)) {
- $bt = md5($cmd);
- if(strpos($cmd,'[*')!==false) $cmd= $this->mergeDocumentContent($cmd);
- if(strpos($cmd,'[(')!==false) $cmd= $this->mergeSettingsContent($cmd);
- if(strpos($cmd,'{{')!==false) $cmd= $this->mergeChunkContent($cmd);
- if(strpos($cmd,'[[')!==false) $cmd= $this->evalSnippets($cmd);
- if(strpos($cmd,'[+')!==false
- &&strpos($cmd,'[[')===false) $cmd= $this->mergePlaceholderContent($cmd);
- $safe++;
- if(20<$safe) break;
- }
- $this->config['enable_filter'] = $_;
- $cmd = ltrim($cmd);
- $cmd = rtrim($cmd,'-');
- $cmd = trim($cmd);
- $cmd = str_ireplace(array(' and ',' or '),array('&&','||'),$cmd);
-
- if($cmd!=='' && !preg_match('@^[0-9]*$@', $cmd) && preg_match('@^[0-9<= \-\+\*/\(\)%!&|]*$@', $cmd))
- $cmd = (int) eval("return {$cmd};");
- if($cmd < 0) $cmd = 0;
-
- if( (!$reverse && !empty($cmd)) || ($reverse && empty($cmd)) ) {
- $content .= $text;
- $excute = true;
- }
- else $excute = false;
- }
- elseif($scope==='@ELSE') {
- if($excute) continue;
- list(, $text) = explode('>', $split, 2);
- $content .= $text;
- $excute = true;
- }
- elseif($scope==='@ENDIF') {
- list(, $text) = explode('>', $split, 2);
- $content .= $text;
- $excute = false;
- }
- }
+ list($cmd, $text) = explode('>', $split, 2);
+ $cmd = str_replace("'","\'",$cmd);
+ $content .= "_parseCTagCMD('" . $cmd . "')): ?>";
+ $content .= $text;
+ }
- if(strpos($content,$iftag) && $bt!==md5($content))
- $content = $this->mergeConditionalTagsContent($content, $iftag, $elseiftag, $elsetag, $endiftag);
+ $content = str_replace(array('<@ELSE>','<@ENDIF>'), array('',''), $content);
+ ob_start();
+ $content = eval('?>'.$content);
+ $content = ob_get_clean();
+ $content = str_replace(array("{$sp}b","{$sp}e"),array(''),$content);
return $content;
}
+ private function _prepareCTag($content, $iftag='<@IF:', $elseiftag='<@ELSEIF:', $elsetag='<@ELSE>', $endiftag='<@ENDIF>') {
+ if(strpos($content,'')!==false) $content = str_replace('', $elsetag, $content); // for jp
+ if(strpos($content,'')!==false) $content = str_replace('',$endiftag,$content); // for jp
+ if(strpos($content,'<@ENDIF-->')!==false) $content = str_replace('<@ENDIF-->',$endiftag,$content);
+ $tags = array($iftag, $elseiftag, $elsetag, $endiftag);
+ $content = str_ireplace($tags,$tags,$content); // Change to capital letters
+ return $content;
+ }
+
+ private function _parseCTagCMD($cmd) {
+ $cmd = trim($cmd);
+ $reverse = substr($cmd,0,1)==='!' ? true : false;
+ if($reverse) $cmd = ltrim($cmd,'!');
+ if(strpos($cmd,'[!')!==false) $cmd = str_replace(array('[!','!]'),array('[[',']]'),$cmd);
+ $safe=0;
+ $bt='';
+ while($safe < 20) {
+ $bt = md5($cmd);
+ if(strpos($cmd,'[*')!==false) $cmd= $this->mergeDocumentContent($cmd);
+ if(strpos($cmd,'[(')!==false) $cmd= $this->mergeSettingsContent($cmd);
+ if(strpos($cmd,'{{')!==false) $cmd= $this->mergeChunkContent($cmd);
+ if(strpos($cmd,'[[')!==false) $cmd= $this->evalSnippets($cmd);
+ if(strpos($cmd,'[+')!==false
+ &&strpos($cmd,'[[')===false) $cmd= $this->mergePlaceholderContent($cmd);
+ if($bt===md5($cmd)) break;
+ $safe++;
+ }
+ $cmd = ltrim($cmd);
+ $cmd = rtrim($cmd,'-');
+ $cmd = str_ireplace(array(' and ',' or '),array('&&','||'),$cmd);
+
+ if(!preg_match('@^[0-9]*$@', $cmd) && preg_match('@^[0-9<= \-\+\*/\(\)%!&|]*$@', $cmd))
+ $cmd = (int) eval("return {$cmd};");
+ else {
+ $_ = explode(',', '[*,[(,{{,[[,[!,[+');
+ foreach($_ as $left) {
+ if(strpos($cmd,$left)!==false) {
+ $cmd = 0;
+ break;
+ }
+ }
+ $cmd = (int) $cmd;
+ }
+ if($cmd < 0) $cmd = 0;
+ if($reverse) $cmd = !$cmd;
+ return $cmd;
+ }
+
/**
* Remove Comment-Tags from output like
*/
@@ -2044,7 +2032,7 @@ function parseDocumentSource($source) {
for ($i= 0; $i < $passes; $i++) {
// get source length if this is the final pass
if ($i == ($passes -1))
- $st= strlen($source);
+ $st= md5($source);
if ($this->dumpSnippets == 1) {
$this->snippetsCode .= "
";
}
if ($i == ($passes -1) && $i < ($this->maxParserPasses - 1)) {
- // check if source length was changed
- $et= strlen($source);
- if ($st != $et)
+ // check if source content was changed
+ if ($st != md5($source))
$passes++; // if content change then increase passes because
} // we have not yet reached maxParserPasses
}
@@ -3570,7 +3557,8 @@ function parseText($tpl='', $ph=array(), $left= '[+', $right= '+]', $execModifie
list($key,$modifiers)=$this->splitKeyAndFilter($key);
else $modifiers = false;
- if(!isset($ph[$key])) continue;
+// if(!isset($ph[$key])) continue;
+ if(!array_key_exists($key,$ph)) continue; //NULL values must be saved in placeholders, if we got them from database string
$value = $ph[$key];
diff --git a/manager/includes/header.inc.php b/manager/includes/header.inc.php
index 38b8d87d3d..d453bd8841 100644
--- a/manager/includes/header.inc.php
+++ b/manager/includes/header.inc.php
@@ -106,15 +106,18 @@
b = b || {};
}
let o = {
- el: null, handleClass: b.handleClass || 'ghost', complete: function() {
+ el: null,
+ handleClass: b.handleClass || 'ghost',
+ complete: function(c) {
if ('function' === typeof b.complete) {
- b.complete();
+ b.complete(c);
}
- }, change: function() {
+ },
+ change: function(c) {
if ('function' === typeof b.change) {
- b.change();
+ b.change(c);
}
- },
+ }
};
function onmousedown(e)
@@ -152,7 +155,7 @@ function onmousemove(e)
o.el.style.transform = 'translateY(' + y + 'px)';
}
- function onmouseup(e)
+ function onmouseup()
{
o.el.style.webkitTransform = '';
o.el.style.transform = '';
@@ -160,7 +163,7 @@ function onmouseup(e)
document.removeEventListener('mousemove', onmousemove);
document.removeEventListener('mouseup', onmouseup);
document.onselectstart = null;
- o.complete();
+ o.complete(o.el);
}
for (let i = 0; i < a.length; i++) {
@@ -181,18 +184,24 @@ function onmouseup(e)
handle: {
start: function(c) {
'function' === typeof b.handle.start ? b.handle.start.call(c) : '';
- }, end: function(c) {
- 'function' === typeof b.handle.end ? b.handle.end.call(c) : '';
},
- }, container: {
- className: b.container.className || 'drop', classOver: b.container.classOver || 'over', over: function(c) {
+ end: function(c) {
+ 'function' === typeof b.handle.end ? b.handle.end.call(c) : '';
+ }
+ },
+ container: {
+ className: b.container.className || 'drop',
+ classOver: b.container.classOver || 'over',
+ over: function(c) {
'function' === typeof b.container.over ? b.container.over.call(c) : '';
- }, leave: function(c) {
+ },
+ leave: function(c) {
'function' === typeof b.container.leave ? b.container.leave.call(c) : '';
- }, drop: function(c, i) {
- 'function' === typeof b.container.drop ? b.container.drop.call(c, i) : '';
},
- },
+ drop: function(c, i) {
+ 'function' === typeof b.container.drop ? b.container.drop.call(c, i) : '';
+ }
+ }
};
o.container.els = document.querySelectorAll('.' + o.container.className);
@@ -224,7 +233,7 @@ function onmousemove(e)
}
}
- function onmouseup(e)
+ function onmouseup()
{
document.removeEventListener('mousemove', onmousemove);
document.removeEventListener('mouseup', onmouseup);
@@ -267,7 +276,7 @@ function onmouseup(e)
a = 'string' === typeof a ? document.querySelectorAll(a) : a;
}
let h = {
- containerClass: b && b.containerClass || 'tab-body',
+ containerClass: b && b.containerClass || 'tab-body'
};
for (let i = 0; i < a.length; i++) {
@@ -281,7 +290,7 @@ function onmouseup(e)
a[i].nextElementSibling.classList.add('in');
a[i].classList.remove('collapsed');
}
- };
+ }
}
}
};
@@ -289,7 +298,7 @@ function onmouseup(e)
// check connection to server
evo.checkConnectionToServer = function() {
let xhr = new ( window.ActiveXObject || XMLHttpRequest )('Microsoft.XMLHTTP');
- xhr.open('HEAD', '//' + window.location.hostname + window.location.pathname.replace('index.php', 'includes/version.inc.php') + '?time=' + new Date().getTime(), false);
+ xhr.open('HEAD', '= MODX_MANAGER_URL ?>includes/version.inc.php?time=' + new Date().getTime(), false);
try {
xhr.send();
return (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304);
@@ -391,8 +400,8 @@ function doRefresh(r)
}
}
- let documentDirty = false;
- let timerForUnload;
+ var documentDirty = false;
+ var timerForUnload;
function checkDirt(evt)
{
diff --git a/manager/includes/lang/english.inc.php b/manager/includes/lang/english.inc.php
index 1e339f5e48..1d69bdfd8e 100644
--- a/manager/includes/lang/english.inc.php
+++ b/manager/includes/lang/english.inc.php
@@ -1081,8 +1081,8 @@
$_lang["top_howmany_message"] = 'When viewing reports, how large should the \'Top ...\' lists be?';
$_lang["top_howmany_title"] = 'Top how many';
$_lang["total"] = 'total';
-$_lang["track_visitors_message"] = 'Provides a hook for analytics Plugins, for example to flag whether or not visits to a specific Resource are logged.';
-$_lang["track_visitors_title"] = 'Enable Stats Tracking';
+$_lang["track_visitors_message"] = 'Check to show the child resources in the document tree';
+$_lang["track_visitors_title"] = 'Show child resources';
$_lang["tree_page_click"] = 'Page Click Behavior';
$_lang["tree_page_click_message"] = 'The default behavior when clicking on a page in the site tree.';
$_lang["use_breadcrumbs"] = 'Show navigation';
diff --git a/manager/includes/version.inc.php b/manager/includes/version.inc.php
index e9301eeb5d..f3f678117e 100755
--- a/manager/includes/version.inc.php
+++ b/manager/includes/version.inc.php
@@ -1,5 +1,5 @@
div { max-height: calc(100vh - 11rem) !important; overflow: auto; }
-.ElementsInTree #tree .tab-page .panel-group { overflow: visible !important; max-height: none !important; box-sizing: border-box !important }
-.ElementsInTree #tree .tab-row { padding: 0; margin-bottom: -1px; }
-.ElementsInTree #tree .tab-row .tab { height: 2rem; line-height: 2rem; }
-.ElementsInTree #tree .tab-page { background-color: #fff; border: 1px solid #ddd; box-shadow: none }
-.ElementsInTree #tree .form-control { padding: 0.25rem; font-size: 0.8rem; }
-.ElementsInTree #tree .eltree { line-height: 1.5 }
-.ElementsInTree #tree .eltree img { width: 0.8em; height: 0.8em }
-.ElementsInTree.treeframebody { -webkit-box-shadow: none; box-shadow: none }
-.dark.ElementsInTree #tree .treeframebody { background-color: #1d2023 !important; color: #828282 }
-.dark.ElementsInTree #tree .tab-row .tab { color: #7b7b7b; }
-.dark.ElementsInTree #tree .tab-row .tab.selected { background-color: #1d2023; border-color: rgba(255, 255, 255, .1); color: #bfbfbf; }
-.dark.ElementsInTree #tree .tab-page { background-color: transparent; border-color: rgba(255, 255, 255, .1) }
-.dark.ElementsInTree #tree .form-control { background-color: rgba(0, 0, 0, 0.4); border-color: rgba(255, 255, 255, 0.09); color: #c7c7c7; }
-.dark.ElementsInTree #tree a { color: #b7b7b7 }
-.dark.ElementsInTree #tree .disabledPlugin a { color: #b68282 }
+.dark #mainloader { background-color: rgba(236, 240, 241, 0.64); }
\ No newline at end of file
diff --git a/manager/processors/save_role.processor.php b/manager/processors/save_role.processor.php
index 68360fae00..0f7d952961 100644
--- a/manager/processors/save_role.processor.php
+++ b/manager/processors/save_role.processor.php
@@ -75,8 +75,6 @@
'exec_module' => $exec_module,
'view_eventlog' => $view_eventlog,
'delete_eventlog' => $delete_eventlog,
- 'manage_metatags' => $manage_metatags,
- 'edit_doc_metatags' => $edit_doc_metatags,
'new_web_user' => $new_web_user,
'edit_web_user' => $edit_web_user,
'save_web_user' => $save_web_user,