diff --git a/.gitignore b/.gitignore index 0fd30f6a6c..9173642252 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,10 @@ # and the config file /manager/includes/config.inc.php +# Windows and Mac +Thumbs.db +Desktop.ini +.DS_Store + # except do not ignore .gitignore !.gitignore diff --git a/README.md b/README.md index 88d1036b7d..fe19bb5334 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,36 @@ # Evolution CMS -**What is EVO** +![PHP version](https://img.shields.io/badge/PHP->=v5.4-green.svg?php=5.4) [![GitHub release](https://img.shields.io/github/release/evolution-cms/evolution.svg)](https://github.com/evolution-cms/evolution/) -EVO is an open source Content Management System and Application Framework. Initially inspired by Etomite 0.6, then it been MODX Evolution 0.7 - 1.0.8 is an ongoing project written by Raymond Irving and a core team of contributors MODX, and now its Evolution CMS maintained by Dmytro Lukianenko and a core team of contributors at the EVO Project. EVO is distributed under the GPL license and is now run by a professional team of developers from all over the world. Visit the Forums for more information. +Evolution CMS requires **PHP >= 5.4**, but snippet FormLister need **PHP >=5.6** -EVO provides a fast, lightweight and powerful framework on which to deploy and secure your website and web applications. For example, it gives you a true system for registered web users and groups that is separate from administration users. You can grant some web users access to one page and others access to another page. For content management, you can easily duplicate documents, folders (and all their children!), chunks and snippets. Most significant, though, is EVO's ability to empower you to quickly and easily create and maintain a rich and dynamic website like never before. -Evolution CMS requires **PHP version 5.4 and higher**. +## What is EVO + +**EVO** is an open source Content Management System and Application Framework. + +## History + +Initially inspired by **Etomite 0.6**, then it been **MODX Evolution 0.7 - 1.0.8** is an ongoing project written by *Raymond Irving* and a core team of contributors **MODX**, and now its **Evolution CMS** maintained by *Dmytro Lukianenko* and a core team of contributors at the **EVO Project**. + +## License + +**EVO** is distributed under the **GPL license** and is now run by a professional team of developers from all over the world. Visit the Forums for more information. + +## Features + +**EVO** provides a fast, lightweight and powerful framework on which to deploy and secure your website and web applications. + +For example, it gives you a true system for registered web users and groups that is separate from administration users. You can grant some web users access to one page and others access to another page. + +For content management, you can easily duplicate documents, folders (and all their children!), chunks and snippets. + +Most significant, though, is **EVO's** ability to empower you to quickly and easily create and maintain a rich and dynamic website like never before. + + +## Install +Just use [Evo Installer](https://github.com/evolution-cms/installer) + ### Screenshots @@ -31,4 +55,4 @@ Extras: https://extras.evolution-cms.com Documentation: -https://evolution-docs.com \ No newline at end of file +https://evolution-docs.com diff --git a/assets/docs/changelog.txt b/assets/docs/changelog.txt index 68242bcf83..92f019f78f 100644 --- a/assets/docs/changelog.txt +++ b/assets/docs/changelog.txt @@ -1,7 +1,329 @@ -This file shows the changes in recent releases of MODX. The most current release is usually the +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.0(Jul 10, 2017) +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) +* [GitHub:#ec2c7f23] - update FormLister to 1.7.8 (dmi3yy) +* [GitHub:#60619960] - update DocLister (dmi3yy) +* [GitHub:#e3c58c40] - fix Ditto sorting by pub_date leads to no results #179 (dmi3yy) +* [GitHub:#46074033] - correct #184 (Serg) +* [GitHub:#ee3128ac] - update style buttons in manage elements add margin (64j) +* [GitHub:#2c3785ca] - [E] Quick Manager : New "Load Font Awesome css in front-end" plugin setting (Nicola) +* [GitHub:#139d0cc0] - update forms.css add style buttons (64j) +* [GitHub:#c3e02422] - Update README.md (Anton Kolesnikov) +* [GitHub:#7ee2ef4d] - Update README.md (Anton Kolesnikov) +* [GitHub:#0fc55da6] - Update README.md (Anton Kolesnikov) +* [GitHub:#afb7b0d7] - refactor datePicker javascript es2015 standard for job in IE11 (64j) +* [GitHub:#0dc8d416] - update forms.css change color radio and checkbox (64j) +* [GitHub:#2e8a052d] - Fix - mm_widget_showimagetvs by https url (yamamoto) +* [GitHub:#6b015400] - fix DocManager which_browser for tvars add DatePicker format code (64j) +* [GitHub:#15346ef7] - update css default theme (64j) +* [GitHub:#9832bbd3] - fix quickly filter elements disabled press enter (64j) +* [GitHub:#f30fd5aa] - refactor css default theme (64j) +* [GitHub:#54b89c95] - refactor Document Manager remove mootools (64j) +* [GitHub:#ac62798a] - remove unused DBAPI methods (Pathologic) +* [GitHub:#05a7b383] - fix #24 (Pathologic) +* [GitHub:#2139dcb5] - fix #23 (Pathologic) +* [GitHub:#74fc4606] - refactor Manage Gategories deleted mootools (64j) +* [GitHub:#51993f44] - update header.php add evo.draggable (64j) +* [GitHub:#84cfb156] - fix (Pathologic) +* [GitHub:#eb7956c8] - fix warning tabPage in FF (64j) +* [GitHub:#d9f95baf] - fix #38 (Pathologic) +* [GitHub:#d541bcc7] - fix inputs and buttons padding, width (64j) +* [GitHub:#c59efff4] - fix (Pathologic) +* [GitHub:#f52a6e96] - Remove Japanese comment (yamamoto) +* [GitHub:#8370c6b4] - New - [*value:makeUrl*] modifier (yamamoto) +* [GitHub:#616cfb17] - New - Core modifier math (yamamoto) +* [GitHub:#b00cd21b] - Refactor (yamamoto) +* [GitHub:#6573becd] - Code cleanup (yamamoto) +* [GitHub:#e8bb914b] - Code cleanup (yamamoto) +* [GitHub:#25117c60] - Fix - :id modifier (yamamoto) +* [GitHub:#ec6168a3] - Fix - typo (yamamoto) +* [GitHub:#f3c5a4b8] - Code cleanup (yamamoto) +* [GitHub:#cfcff99d] - [F] #173 Wayfinder [+wf.level+] no output any more (yamamoto) +* [GitHub:#4889cf8f] - Ditto - Code clean up (yamamoto) +* [GitHub:#abc194e2] - refactor MODxMailer (Pathologic) +* [GitHub:#48c5e2fa] - [F] #143 Fix sorting of items in element-listings (Deesen) +* [GitHub:#11318883] - Fix #168 Ditto sees single Resources as Folders (yamamoto) +* [GitHub:#a376de86] - Minor fix (yamamoto) +* [GitHub:#ea15209e] - [DocListre] $modx->config['enable_filter'] (yamamoto) +* [GitHub:#a4f60166] - Fix #127 (yamamoto) +* [GitHub:#72f160f0] - fix bug tree sorting (Serg) +* [GitHub:#243d0cbd] - DocLister 2.3.10 (Pathologic) +* [GitHub:#ad493fc5] - DocLister 2.3.10 (Pathologic) +* [GitHub:#eca89655] - update transition inputs radio and checkbox (64j) +* [GitHub:#47ddae9b] - Refactor (yamamoto) +* [GitHub:#7028c2d3] - Code cleanup - DBAPI (yamamoto) +* [GitHub:#241ba661] - Fix DBAPI (yamamoto) +* [GitHub:#5026cbd4] - Fix - Related @d723915 (yamamoto) +* [GitHub:#14ea7e3f] - update style checkboxes and radio buttons (64j) +* [GitHub:#d7239159] - fix #167 (Pathologic) +* [GitHub:#9e576658] - fix #149 (Pathologic) +* [GitHub:#3c80664d] - remove transition blur text when hovering (Serg) +* [GitHub:#e618355b] - fix padding input-group-addon class (Serg) +* [GitHub:#e99a030d] - normalize style inputs, buttons, list select (64j) +* [GitHub:#3ab388c6] - normalize style inputs, buttons, list select in FF (64j) +* [GitHub:#1ac70c76] - fix #158 (64j) +* [GitHub:#ec8f7ee0] - normalize style inputs, buttons, list select added cross browser style for check boxes, radio buttons, list select (64j) +* [GitHub:#16403889] - Refactor (yamamoto) +* [GitHub:#b58b87a7] - Refactor cache_sync (yamamoto) +* [GitHub:#36e2ab81] - Refactor $modx->checkPublishStatus() (yamamoto) +* [GitHub:#35625fa3] - Update english.inc.php (Mr B) +* [GitHub:#360678b0] - Refactor - Remove $modx->getDocumentMethod() (yamamoto) +* [GitHub:#2c190f2d] - Refactor - $modx->_IIS_furl_fix() (yamamoto) +* [GitHub:#2d4571cf] - Refactor - $modx->postProcess() (yamamoto) +* [GitHub:#5ebcada9] - Refactor - $modx->checkPublishStatus() (yamamoto) +* [GitHub:#a06aecd6] - Remove $modx->setRequestQ() (yamamoto) +* [GitHub:#7b38336d] - Update changelog.txt (Mr B) +* [GitHub:#26ac6b39] - Update 01About_EVO.php (Mr B) +* [GitHub:#10d5ce61] - fix css line-height for textarea (64j) +* [GitHub:#4520b3f9] - fix index name (Pathologic) +* [GitHub:#6d20167f] - Update 02Documentation.php (Mr B) +* [GitHub:#a247e118] - fix #155 (Pathologic) +* [GitHub:#2c40a6d0] - add unique index to document_groups and site_tmplvar_contentvalues (Pathologic) +* [GitHub:#6b99aab8] - normalize vertical inputs and buttons (64j) +* [GitHub:#ed0c10c4] - resolve #148 (64j) +* [GitHub:#8b441bcb] - update css class sectionBody, sectionHeader (64j) +* [GitHub:#9072e966] - Change class styles and new layout of sections (64j) +* [GitHub:#0de44795] - Update 02Documentation.php (Mr B) +* [GitHub:#5d8b5ad9] - [I] #147 $modx->sendForward() (yamamoto) +* [GitHub:#d1d74e85] - resolve issue #151 (64j) +* [GitHub:#dbd67dce] - [F] #151 Errors saving system configuration (yamamoto) +* [GitHub:#413f6bd6] - add evo.collapse (64j) +* [GitHub:#0d7a7319] - Fix (yamamoto) +* [GitHub:#f5092ab1] - Refactor - $modx->db->select() (yamamoto) +* [GitHub:#87df7125] - removing deprecated css classes (64j) +* [GitHub:#c88ac9b1] - fix codemirror border in one-dark theme (64j) +* [GitHub:#3368e8fc] - fix min-height input search in top menu (64j) +* [GitHub:#21e57787] - fix css image height (64j) +* [GitHub:#1ef08655] - [I] array data into $modx->db->query() (yamamoto) +* [GitHub:#d2feee38] - Translate ru to english (yamamoto) +* [GitHub:#92fc062a] - [I] #116 For vue.js (yamamoto) +* [GitHub:#8f23175e] - Fix (yamamoto) +* [GitHub:#02943e4a] - DIRECTORY_SEPARATOR (yamamoto) +* [GitHub:#640dd225] - [R] $ditto->fetch() (yamamoto) +* [GitHub:#3f108c9b] - [I] DocLister - Using Core modifiers (yamamoto) +* [GitHub:#1c6ac02e] - fix btn-sm padding (64j) +* [GitHub:#cc091b53] - update check mail ajax (64j) +* [GitHub:#f4514b99] - update check conection to server (64j) +* [GitHub:#c181c71a] - no message (64j) +* [GitHub:#eade0468] - added lang error_internet_connection english russian (64j) +* [GitHub:#b37ed9e8] - remove style button format code (64j) +* [GitHub:#23b37c09] - update style buttons, inputs (64j) +* [GitHub:#6367c0c5] - fix show help description format code (64j) +* [GitHub:#b934ab46] - add check conection to server refactor code (64j) +* [GitHub:#9a081655] - fix favicon form login (64j) +* [GitHub:#f5728a10] - refactor getSettings (Pathologic) +* [GitHub:#10cb5dd8] - [F] fix for check version in update with version_compare (dmi3yy) +* [GitHub:#c3d1109c] - fix file names (dmi3yy) +* [GitHub:#d8aabd61] - fix my local (dmi3yy) +* [GitHub:#eaba6e8e] - fix trouble with my local git (dmi3yy) +* [GitHub:#b7a8e801] - refactor evoTooltips in header.php (Serg) +* [GitHub:#3c862c21] - no message (dmi3yy) +* [GitHub:#c7fef5a3] - no message (dmi3yy) +* [GitHub:#8c123fc5] - refactor evoTooltips in header.php (Serg) +* [GitHub:#4edf578d] - update evoTooltips in header.php (Serg) +* [GitHub:#805667dc] - refactor evoSortable in header.php (Serg) +* [GitHub:#389480ed] - Update categories.js (Serg) +* [GitHub:#58d75d20] - Update .gitignore (yamamoto) +* [GitHub:#f7ea5e48] - update evoSortable in header.php (64j) +* [GitHub:#3cc61fad] - update evoSortable in header.php (64j) +* [GitHub:#053269be] - update manager categories remove mootools sortable, replace evoSortable (64j) +* [GitHub:#452d879b] - add evoSortable in header.php refactor code (64j) +* [GitHub:#01d63014] - Fix @396814f#commitcomment-23456321 (yamamoto) +* [GitHub:#8219b64f] - 1.3x version noticies draft (Nicola) +* [GitHub:#581cd64b] - modx evo version noticies (Nicola) +* [GitHub:#8745f307] - added support for both (modx and evo) cms name in version noticies (Nicola) +* [GitHub:#7ab5558c] - updated help logs tab for evo (Nicola) +* [GitHub:#9d64b02f] - updated help documentation tab for evo (Nicola) +* [GitHub:#f7505a33] - updated about tab for Evo (Nicola) +* [GitHub:#36e4bc09] - updated help templates path (Nicola) +* [GitHub:#f8e41287] - moved help templates to manager/actions (Nicola) +* [GitHub:#2fb69eab] - update default style refactor (64j) +* [GitHub:#35070b9e] - remove unused css files (64j) +* [GitHub:#48767ee7] - update manager categories refactor code, replace jQuery, Mootools (64j) +* [GitHub:#7df8acaf] - update evo tooltip (64j) +* [GitHub:#9906b5a9] - update document.static (64j) +* [GitHub:#72fa4754] - update evo tooltip (64j) +* [GitHub:#65dfe495] - update messages.static (64j) +* [GitHub:#0b747ac6] - update style move_document.php (64j) +* [GitHub:#4bc440a1] - update style table data base add tooltips (64j) +* [GitHub:#f4d30ca7] - resolve #135 (64j) +* [GitHub:#fcd6b4ee] - Refactor - Use $_SERVER['REQUEST_TIME'] (yamamoto) +* [GitHub:#7f986c70] - [I] New - $modx->config['enable_cache'] (yamamoto) +* [GitHub:#40514b5c] - Code cleanup (readable flow) (yamamoto) +* [GitHub:#2e81ff4b] - [Fix] Missing parse modifier (yamamoto) +* [GitHub:#b45cc3a7] - [F] Cross References bug [*pagetitle@parent*] (yamamoto) +* [GitHub:#396814fe] - [F] #134 Fix bug Cross References (yamamoto) +* [GitHub:#26a9c185] - Fix @7f3a73f (yamamoto) +* [GitHub:#0fbb8c6b] - Fix @LITERAL (yamamoto) +* [GitHub:#7f3a73f3] - remove etomite "compatibility" (Pathologic) +* [GitHub:#d6b4f634] - add css class tab-content (64j) +* [GitHub:#b3ecfd0f] - refactor bkmanager (64j) +* [GitHub:#387dd53b] - add tooltips in header.php (64j) +* [GitHub:#0cbe8999] - [I] #116 Display EVO tags on page (yamamoto) +* [GitHub:#4d984082] - Refactor (yamamoto) +* [GitHub:#7d7b44d6] - fix #130 (Serg) +* [GitHub:#a6d99c4c] - fix #130 (Serg) +* [GitHub:#d36bf3f9] - https://github.com/evolution-cms/evolution/issues/135 reverted the css fix and changed class in the module (Nicola) +* [GitHub:#c5ec13ed] - revert https://github.com/Nicola1971/evolution/commit/0a6889f553e1ea59406a29638fc311b59f22f37a (Nicola) +* [GitHub:#9b2b89f4] - update DLMenu (Pathologic) +* [GitHub:#60e644c6] - fix redundant tag (Pathologic) +* [GitHub:#268da0f6] - update install (Pathologic) +* [GitHub:#3de4fda4] - fix #127 (Pathologic) +* [GitHub:#456b6e20] - update demo content (Pathologic) +* [GitHub:#eba6019b] - solve #130 (Pathologic) +* [GitHub:#9fa434b2] - [I] #116 Display EVO tags on page (yamamoto) +* [GitHub:#0a6889f5] - [f] for Manage Categories Help Toggle Not Work https://github.com/evolution-cms/evolution/issues/135 (Nicola) +* [GitHub:#594e693a] - [F] Replace "\" by "/" to fit MODX_BASE_PATH (Deesen) +* [GitHub:#3b3f6a8e] - [I] $modx->db->lastQuery (yamamoto) +* [GitHub:#74fbdbf9] - [C]: Code clean-up (yamamoto) +* [GitHub:#90391b27] - fix contextmenu (64j) +* [GitHub:#71f2aa95] - fix #127 (Pathologic) +* [GitHub:#3315496d] - remove mootools (64j) +* [GitHub:#ff34df05] - remove mootools addEvent (64j) +* [GitHub:#e6729fae] - remove mootools in datepicker.js (64j) +* [GitHub:#96b11bf3] - add quotes install/config.tpl (64j) +* [GitHub:#80def3ae] - fix #132 (64j) +* [GitHub:#73af528e] - add newline at end of file #126 (64j) +* [GitHub:#3884e3ed] - added createdon, editedon (64j) +* [GitHub:#63741625] - update DocLister and FormLister (Pathologic) +* [GitHub:#9ea9881d] - fix #127 (Pathologic) +* [GitHub:#a6a2abd6] - update #126 add cache name and props disable snippets and chunks (64j) +* [GitHub:#4787482d] - revert https://github.com/evolution-cms/evolution/commit/fb9f8cc4f864c4ef8db7e9e6d744e66d602835c9 (Pathologic) +* [GitHub:#27df9335] - fix #127 (Pathologic) +* [GitHub:#fb9f8cc4] - fix #127 (Pathologic) +* [GitHub:#a039d981] - fix #129 (64j) +* [GitHub:#f9dab1a3] - add check role #126 (64j) +* [GitHub:#3d24e2a4] - added disable/enable snippets and chuncks #126 (64j) +* [GitHub:#7a7428a6] - fix errors PHP7 undefined variables (64j) +* [GitHub:#696d96e7] - add createdon, editedon to tv-parameters (#126 related) (Pathologic) +* [GitHub:#39f7f8f3] - resolve #126 (Pathologic) +* [GitHub:#b3717c22] - add newline at end of file (64j) +* [GitHub:#ce25057f] - fix #128 (64j) +* [GitHub:#87e768f0] - fix #83 format code (64j) +* [GitHub:#6ab7fce9] - fix issue #83 (64j) +* [GitHub:#ae1112b1] - format code modules.static (64j) +* [GitHub:#47cb461c] - fix issue #105 (64j) +* [GitHub:#e5ec1383] - update issue #105 (64j) +* [GitHub:#c941e22a] - resolve issue #105 (64j) +* [GitHub:#e902a162] - solved #124 (Pathologic) +* [GitHub:#d2e38987] - updated manager italian language for evo1.3.3 (Nicola) +* [GitHub:#8d387fed] - updated italian language for evo1.3.3 (Nicola) +* [GitHub:#f3136b07] - fix form-check in bkmanager (64j) +* [GitHub:#29781a47] - update viewport (64j) +* [GitHub:#d4230da8] - update style table nowrap format code (64j) +* [GitHub:#91a53c45] - update searchbar refactor code (64j) +* [GitHub:#94ddd2fd] - Refactor (yamamoto) +* [GitHub:#9927da82] - update width columns (64j) +* [GitHub:#87bf03d2] - format code (64j) +* [GitHub:#33414537] - resolve #90 (64j) +* [GitHub:#58da6fe7] - fix #121 (64j) +* [GitHub:#48e9dfff] - [F] #99 Use config['docid_incrmnt_method'] when duplicating resources (Deesen) +* [GitHub:#6dce1e32] - Delete 090_Восстановление паролей пользователями.md (Anton Kolesnikov) +* [GitHub:#268d46aa] - Delete 075_Активация учетных записей.md (Anton Kolesnikov) +* [GitHub:#11b1366f] - Delete 070_Регистрация пользователей.md (Anton Kolesnikov) +* [GitHub:#129a0a4c] - Delete 060_Авторизация пользователей.md (Anton Kolesnikov) +* [GitHub:#07a6e604] - [I] #55 @FILE for chunks - {{@FILE:assets/chunks/header.html}} (Deesen) +* [GitHub:#d62b4f9b] - update data sortable (64j) +* [GitHub:#aa951d9c] - update style system info (64j) +* [GitHub:#7d6d1305] - remove extra character (64j) +* [GitHub:#1d7082c8] - format code PSR2 (64j) +* [GitHub:#33a7d473] - format code (64j) +* [GitHub:#aa04a374] - update sort columns (64j) +* [GitHub:#4d62717c] - fix #112 (64j) +* [GitHub:#4ed6f32e] - foram code (64j) +* [GitHub:#76a38432] - update for porblem OnManagerTopPrerender (64j) +* [GitHub:#be8031ff] - fix z-index action buttons for codeMirror full screen (64j) +* [GitHub:#e26b2bee] - Update style.css (Serg) +* [GitHub:#2759f4f6] - fix mce buttons (Serg) +* [GitHub:#d37f6323] - fix #110 (Serg) +* [GitHub:#58b89e16] - fix #110 (Serg) +* [GitHub:#2b899254] - update style buttons actions (64j) +* [GitHub:#dcaca322] - fix codemirror remove mootools fix hotkeys (64j) +* [GitHub:#48aa4b44] - [R] update style tvars image / file (64j) +* [GitHub:#e4a1360f] - [R] update style mutate password (64j) +* [GitHub:#ddd98de5] - [R] update style logging static (64j) +* [GitHub:#893f83fc] - [R] update style search page (64j) +* [GitHub:#9ef5b101] - [R] update style page clear cache (64j) +* [GitHub:#cde514e7] - [R] update style managment roles (64j) +* [GitHub:#38e267c9] - [R] update style managment users / roles (64j) +* [GitHub:#db46e561] - [F] fix #107 (64j) +* [GitHub:#71ad7bd6] - [F] fix #106 (64j) +* [GitHub:#d84c5433] - [R] update style elements (64j) +* [GitHub:#873bf1fa] - [R] update style page webusers permissions (64j) +* [GitHub:#14096b71] - [R] update style page managers permissions (64j) +* [GitHub:#b3cdd621] - [F] fix #63 (64j) +* [GitHub:#4b0a4fc3] - [F] fix #103 (Pathologic) +* [GitHub:#c90042e4] - [F] fix #83 (64j) +* [GitHub:#45a8aa77] - [C]remove deprecated libs (Pathologic) +* [GitHub:#a7243bb3] - [F] #92 (Pathologic) +* [GitHub:#a3bac9d8] - [F] #71 (64j) +* [GitHub:#7b60d2cc] - [F] #71 fix permissions (64j) +* [GitHub:#2b2a2a62] - [C]remove redundant code - tags are cleaned in cleanUpMODXTags (Pathologic) +* [GitHub:#8fd7d31f] - [F] Avoid "Fatal error: Call to undefined function curl_init()" (Deesen) +* [GitHub:#60a77940] - [F] fix #94 Hide rss widgets if rss_url_news and rss_url_security settings are empty (dmi3yy) +* [GitHub:#bd649a9f] - [F] #93 (Pathologic) +* [GitHub:#12007dec] - [F] #87 missing OnManagerTopPrerender (Nicola) + + +Evolution CMS 1.3.3 (Jul 20, 2017) +* [GitHub:#f83719a0] - [F] fix for multiTV<10.0.12 (need branch name Evolution) (dmi3yy) +* [GitHub:#3ac1ef3f] - [F] fix issues #73 update login form (64j) +* [GitHub:#c469b0ed] - [I] Update README.md add version informer (Dmytro Lukianenko) +* [GitHub:#aa00f6c8] - [F] fix issues #71 (64j) +* [GitHub:#2c71ff6a] - [F] update Readme add php informer (Anton Kolesnikov) +* [GitHub:#900854ba] - [F] fix issues #66 format code (64j) +* [GitHub:#ee27d087] - [C] remove unused files DLUsers (dmi3yy) +* [GitHub:#d4c67e6a] - [I] FormLister need PHP >= 5.6 (Anton Kolesnikov) +* [GitHub:#8e4594f8] - [F] fix issues #72 forma code (64j) + + +Evolution CMS 1.3.2 (Jul 19, 2017) +* [GitHub:#a8fc2fdf] - [F] updater plugin (dmi3yy) +* [GitHub:#ad14254c] - [F] fix #75 (Pathologic) +* [GitHub:#d29faf9a] - [R] refactor sortableList (64j) +* [GitHub:#ffa63034] - [F] fix #68 (for hide widget better use $widgets['welcome']['hide'] = 1;) (dmi3yy) + + +Evolution CMS 1.3.1 (Jul 19, 2017) +* [GitHub:#c2348530] - [F] DocLister 2.3.5 fix paginate (dmi3yy) +* [GitHub:#6daadd0f] - [F] version in top menu (dmi3yy) + + +Evolution CMS 1.3.0 (Jul 19, 2017) * [GitHub:#3dda520a] - [R] update sortables list delete mootools sortables (64j) * [GitHub:#9cafe6db] - [F] fix toggle menu (64j) * [GitHub:#6c316c18] - [I] Update DocLister add DLmenu (dmi3yy) @@ -3084,4 +3406,4 @@ Additional Improvements & Updates: - Updated RSS feeds to more manageable number of entries for welcome page. - Updated snoopy class to latest version 1.2.4 (used by magpierss). -For earlier changelog entries, please see the /install/changelog.txt file included with the MODX 0.9.6.3 distribution \ No newline at end of file +For earlier changelog entries, please see the /install/changelog.txt file included with the MODX 0.9.6.3 distribution diff --git a/assets/images/noimage.jpg b/assets/images/noimage.jpg deleted file mode 100755 index e0de171897..0000000000 Binary files a/assets/images/noimage.jpg and /dev/null differ diff --git a/assets/js/.htaccess b/assets/js/.htaccess new file mode 100644 index 0000000000..6c1cc6e2da --- /dev/null +++ b/assets/js/.htaccess @@ -0,0 +1,5 @@ +IndexIgnore */* + + Order Deny,Allow + Deny from all + diff --git a/assets/js/easy-ui/editors/imageBrowser.js b/assets/js/easy-ui/editors/imageBrowser.js index 4d6dd40343..62d65a5cc1 100755 --- a/assets/js/easy-ui/editors/imageBrowser.js +++ b/assets/js/easy-ui/editors/imageBrowser.js @@ -51,4 +51,4 @@ } } }); -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/assets/lib/APIHelpers.class.php b/assets/lib/APIHelpers.class.php index 030318aae7..f84f8060e0 100644 --- a/assets/lib/APIHelpers.class.php +++ b/assets/lib/APIHelpers.class.php @@ -158,7 +158,7 @@ public static function genPass($len, $data = '') * @param $data * @return bool|false|string */ - private static function _getEnv($data) + public static function getEnv($data) { switch (true) { case (isset($_SERVER[$data])): @@ -197,25 +197,25 @@ public static function getUserIP($default = '127.0.0.1') { //Порядок условий зависит от приоритетов switch (true) { - case ($tmp = self::_getEnv('HTTP_COMING_FROM')): + case ($tmp = self::getEnv('HTTP_COMING_FROM')): $out = $tmp; break; - case ($tmp = self::_getEnv('HTTP_X_COMING_FROM')): + case ($tmp = self::getEnv('HTTP_X_COMING_FROM')): $out = $tmp; break; - case ($tmp = self::_getEnv('HTTP_VIA')): + case ($tmp = self::getEnv('HTTP_VIA')): $out = $tmp; break; - case ($tmp = self::_getEnv('HTTP_FORWARDED')): + case ($tmp = self::getEnv('HTTP_FORWARDED')): $out = $tmp; break; - case ($tmp = self::_getEnv('HTTP_FORWARDED_FOR')): + case ($tmp = self::getEnv('HTTP_FORWARDED_FOR')): $out = $tmp; break; - case ($tmp = self::_getEnv('HTTP_X_FORWARDED')): + case ($tmp = self::getEnv('HTTP_X_FORWARDED')): $out = $tmp; break; - case ($tmp = self::_getEnv('HTTP_X_FORWARDED_FOR')): + case ($tmp = self::getEnv('HTTP_X_FORWARDED_FOR')): $out = $tmp; break; case (!empty($_SERVER['REMOTE_ADDR'])): diff --git a/assets/lib/Helpers/Config.php b/assets/lib/Helpers/Config.php old mode 100755 new mode 100644 index b0c9667590..4500ca7ad5 --- a/assets/lib/Helpers/Config.php +++ b/assets/lib/Helpers/Config.php @@ -86,10 +86,10 @@ public function getConfig() * @param array $cfg массив настроек * @return int результат сохранения настроек */ - public function setConfig($cfg) + public function setConfig($cfg, $overwrite = false) { if (is_array($cfg)) { - $this->_cfg = array_merge($this->_cfg, $cfg); + $this->_cfg = $overwrite ? $cfg : array_merge($this->_cfg, $cfg); $ret = count($this->_cfg); } else { $ret = false; @@ -98,6 +98,11 @@ public function setConfig($cfg) return $ret; } + /** + * @param $name + * @param null $def + * @return mixed + */ public function getCFGDef($name, $def = null) { return \APIhelpers::getkey($this->_cfg, $name, $def); diff --git a/assets/lib/Helpers/FS.php b/assets/lib/Helpers/FS.php index b7423eb2e4..2694f40ae4 100644 --- a/assets/lib/Helpers/FS.php +++ b/assets/lib/Helpers/FS.php @@ -290,8 +290,9 @@ public function relativePath($path, $owner = null) if (is_null($owner)) { $owner = MODX_BASE_PATH; } + $path = str_replace('\\', '/', $path); if (!(empty($path) || !is_scalar($path)) && !preg_match("/^http(s)?:\/\/\w+/", $path)) { - $path = trim(preg_replace("#^" . $owner . "#", '', $path), '/'); + $path = trim(preg_replace("#^" . preg_quote($owner) . "#", '', $path), DIRECTORY_SEPARATOR); } else { $path = ''; } diff --git a/assets/lib/Helpers/Mailer.php b/assets/lib/Helpers/Mailer.php old mode 100755 new mode 100644 index b60d77f9f4..e64c466dcf --- a/assets/lib/Helpers/Mailer.php +++ b/assets/lib/Helpers/Mailer.php @@ -1,6 +1,7 @@ modx = $modx; - $modx->loadExtension('MODxMailer'); - $this->mail = $modx->mail; + $this->mail = new \MODxMailer(); + $this->mail->init($modx); $this->config = $cfg; $this->debug = $debug; + $this->applyMailConfig(); } /** @@ -88,15 +90,7 @@ public function send($report) return false; } - $this->mail->IsHTML($this->getCFGDef('isHtml', 1)); - $this->mail->From = $this->getCFGDef('from', $this->modx->config['site_name']); - $this->mail->FromName = $this->getCFGDef('fromName', $this->modx->config['emailsender']); - $this->mail->Subject = $this->getCFGDef('subject'); $this->mail->Body = $report; - $this->addAddressToMailer("replyTo", $this->getCFGDef('replyTo')); - $this->addAddressToMailer("to", $this->getCFGDef('to')); - $this->addAddressToMailer("cc", $this->getCFGDef('cc')); - $this->addAddressToMailer("bcc", $this->getCFGDef('bcc')); $result = $this->mail->send(); if ($result) { @@ -107,6 +101,124 @@ public function send($report) return $result; } + /** + * @param $report + * @return bool + */ + public function toQueue($report) + { + //если отправлять некуда или незачем, то делаем вид, что отправили + if (!$this->getCFGDef('to') || $this->getCFGDef('noemail')) { + return true; + } elseif (empty($report)) { + return false; + } + + $this->mail->Body = $report; + + $this->Body = $this->modx->removeSanitizeSeed($this->mail->Body); + $this->Subject = $this->modx->removeSanitizeSeed($this->mail->Subject); + try { + $result = $this->mail->preSend() && $this->saveMessage(); + } catch (\phpmailerException $e) { + $this->mail->SetError($e->getMessage()); + + $result = false; + } + + if ($result) { + $this->mail->ClearAllRecipients(); + $this->mail->ClearAttachments(); + $result = $this->getFileName(); + } + + return $result; + } + + /** + * @param string $path + * @return bool + */ + public function setQueuePath($path = '') { + if (!empty($path)) { + $this->queuePath = $path; + return true; + } else { + return false; + } + } + + /** + * @return mixed + */ + protected function saveMessage() + { + $data = serialize(array( + "header" => $this->mail->getMIMEHeader(), + "body" => $this->mail->getMIMEBody(), + "config" => $this->config + )); + $file = $this->getFileName(); + $dir = MODX_BASE_PATH . $this->queuePath; + if (!is_dir($dir)) { + @mkdir($dir); + } + $result = @file_put_contents($dir . $file, $data) !== false; + if ($result) { + $result = $file; + } + + return $result; + } + + /** + * @return string + */ + protected function getFileName() { + return $this->mail->getMessageID() . '.eml'; + } + + /** + * @param $file + * @return bool + */ + public function fromQueue($file) + { + $result = false; + $dir = MODX_BASE_PATH . $this->queuePath; + if (file_exists($dir . $file) && is_readable($dir . $file)) { + $message = unserialize(file_get_contents($dir . $file)); + $this->config = $message['config']; + $this->applyMailConfig(); + $this->mail->setMIMEHeader($message['header'])->setMIMEBody($message['body']); + unset($message); + $result = $this->mail->postSend(); + if ($result) { + $this->mail->setMIMEBody()->setMIMEHeader(); + @unlink($dir . $file); + } + } + + return $result; + } + + /** + * @return $this + */ + protected function applyMailConfig() + { + $this->mail->IsHTML($this->getCFGDef('isHtml', 1)); + $this->mail->From = $this->getCFGDef('from', $this->modx->config['emailsender']); + $this->mail->FromName = $this->getCFGDef('fromName', $this->modx->config['site_name']); + $this->mail->Subject = $this->getCFGDef('subject'); + $this->addAddressToMailer("replyTo", $this->getCFGDef('replyTo')); + $this->addAddressToMailer("to", $this->getCFGDef('to')); + $this->addAddressToMailer("cc", $this->getCFGDef('cc')); + $this->addAddressToMailer("bcc", $this->getCFGDef('bcc')); + + return $this; + } + /** * @param string $param * @param mixed $default diff --git a/assets/lib/MODxAPI/MODx.php b/assets/lib/MODxAPI/MODx.php index 96b21682f6..dd7507e793 100644 --- a/assets/lib/MODxAPI/MODx.php +++ b/assets/lib/MODxAPI/MODx.php @@ -186,6 +186,25 @@ public function getDefaultFields() return $this->default_field; } + /** + * @param $value + * @return int|mixed|string + */ + protected function getTime($value) + { + $value = trim($value); + if (!empty($value)) { + if (!is_numeric($value)) { + $value = (int)strtotime($value); + } + if (!empty($value)) { + $value += $this->modxConfig('server_offset_time'); + } + } + + return $value; + } + /** * @param string $name * @param null $default diff --git a/assets/lib/MODxAPI/autoTable.abstract.php b/assets/lib/MODxAPI/autoTable.abstract.php index 23deca4d8b..15b2891c87 100755 --- a/assets/lib/MODxAPI/autoTable.abstract.php +++ b/assets/lib/MODxAPI/autoTable.abstract.php @@ -77,6 +77,14 @@ public function edit($id) */ public function save($fire_events = null, $clearCache = false) { + foreach ($this->jsonFields as $field) { + if ($this->get($field) === null + && isset($this->default_field[$field]) + && is_array($this->default_field[$field])) + { + $this->set($field, $this->default_field[$field]); + } + } $fld = $this->encodeFields()->toArray(); foreach ($this->default_field as $key => $value) { if ($this->newDoc && $this->get($key) === null && $this->get($key) !== $value) { diff --git a/assets/lib/MODxAPI/modManagers.php b/assets/lib/MODxAPI/modManagers.php index e72d314b3e..f9d722bbf7 100644 --- a/assets/lib/MODxAPI/modManagers.php +++ b/assets/lib/MODxAPI/modManagers.php @@ -11,15 +11,15 @@ class modManagers extends MODxAPI */ protected $default_field = array( 'user' => array( - 'username' => "", - 'password' => "", + 'username' => '', + 'password' => '', ), 'attribute' => array( - 'fullname' => "", + 'fullname' => '', 'role' => 0, - 'email' => "", - 'phone' => "", - 'mobilephone' => "", + 'email' => '', + 'phone' => '', + 'mobilephone' => '', 'blocked' => 0, 'blockeduntil' => 0, 'blockedafter' => 0, @@ -27,17 +27,19 @@ class modManagers extends MODxAPI 'lastlogin' => 0, 'thislogin' => 0, 'failedlogincount' => 0, - 'sessionid' => "", + 'sessionid' => '', 'dob' => 0, - 'gender' => "", - 'country' => "", - 'state' => "", - 'city' => "", - 'street' => "", - 'zip' => "", - 'fax' => "", - 'photo' => "", - 'comment' => "" + 'gender' => 0, + 'country' => '', + 'state' => '', + 'city' => '', + 'street' => '', + 'zip' => '', + 'fax' => '', + 'photo' => '', + 'comment' => '', + 'createdon' => 0, + 'editedon' => 0 ), 'hidden' => array( 'internalKey' @@ -97,6 +99,18 @@ protected function findUser($data) return $find; } + /** + * @param array $data + * @return $this + */ + public function create($data = array()) + { + parent::create($data); + $this->set('createdon', time()); + + return $this; + } + /** * @param $id * @return $this @@ -111,6 +125,7 @@ public function edit($id) if (!$find = $this->findUser($id)) { $this->id = null; } else { + $this->set('editedon', time()); $result = $this->query(" SELECT * from {$this->makeTable('user_attributes')} as attribute LEFT JOIN {$this->makeTable('manager_users')} as user ON user.id=attribute.internalKey @@ -149,6 +164,10 @@ public function set($key, $value) session_regenerate_id(false); $value = session_id(); break; + case 'editedon': + case 'createdon': + $value = $this->getTime($value); + break; } $this->field[$key] = $value; } @@ -582,10 +601,12 @@ public function getUserGroups($userID = 0) $member_groups = $this->makeTable('member_groups'); $membergroup_names = $this->makeTable('membergroup_names'); - $sql = "SELECT `ugn`.`name` FROM {$member_groups} as `ug` + $rs = $this->query("SELECT `ug`.`user_group`, `ugn`.`name` FROM {$member_groups} as `ug` INNER JOIN {$membergroup_names} as `ugn` ON `ugn`.`id`=`ug`.`user_group` - WHERE `ug`.`member` = " . $user->getID(); - $out = $this->modx->db->getColumn('name', $this->query($sql)); + WHERE `ug`.`member` = " . $user->getID()); + while ($row = $this->modx->db->getRow($rs)) { + $out[$row['user_group']] = $row['name']; + } } unset($user); @@ -610,6 +631,10 @@ public function setUserGroups($userID = 0, $groupIds = array()) foreach ($groupIds as $gid) { $this->query("REPLACE INTO {$this->makeTable('member_groups')} (`user_group`, `member`) VALUES ('{$gid}', '{$uid}')"); } + if (!$this->newDoc) { + $groupIds = empty($groupIds) ? '0' : implode(',', $groupIds); + $this->query("DELETE FROM {$this->makeTable('member_groups')} WHERE `member`={$uid} AND `user_group` NOT IN ({$groupIds})"); + } } unset($user); $this->groupIds = array(); diff --git a/assets/lib/MODxAPI/modResource.php b/assets/lib/MODxAPI/modResource.php index 55c83d5f69..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, @@ -152,7 +150,8 @@ class modResource extends MODxAPI * @var DLCollection */ private $managerUsers = null; - + /** @var array группы документов */ + protected $groupIds = array(); /** * modResource constructor. * @param DocumentParser $modx @@ -433,25 +432,6 @@ protected function findUserBy($data) return $find; } - /** - * @param $value - * @return int|mixed|string - */ - protected function getTime($value) - { - $value = trim($value); - if (!empty($value)) { - if (!is_numeric($value)) { - $value = (int)strtotime($value); - } - if (!empty($value)) { - $value += $this->modxConfig('server_offset_time'); - } - } - - return $value; - } - /** * @param array $data * @return $this @@ -509,7 +489,7 @@ public function edit($id) /** * @param bool $fire_events * @param bool $clearCache - * @return bool|null|void + * @return bool|null */ public function save($fire_events = false, $clearCache = false) { @@ -603,9 +583,9 @@ public function save($fire_events = false, $clearCache = false) } } - $_deleteTVs = $_updateTVs = $_insertTVs = array(); + $_deleteTVs = $_insertTVs = array(); foreach ($fld as $key => $value) { - if (empty($this->tv[$key]) || !$this->isChanged($key)) { + if (empty($this->tv[$key]) || !$this->isChanged($key) || !$this->belongsToTemplate($this->tv[$key])) { continue; } elseif ($value === '') { $_deleteTVs[] = $this->tv[$key]; @@ -614,29 +594,14 @@ public function save($fire_events = false, $clearCache = false) } } - if (!$this->newDoc && !empty($_insertTVs)) { - $ids = implode(',', array_keys($_insertTVs)); - $result = $this->query("SELECT `tmplvarid` FROM {$this->makeTable('site_tmplvar_contentvalues')} WHERE `contentid`={$this->id} AND `tmplvarid` IN ({$ids})"); - $existedTVs = $this->modx->db->getColumn('tmplvarid', $result); - foreach ($existedTVs as $id) { - $_updateTVs[$id] = $_insertTVs[$id]; - unset($_insertTVs[$id]); - } - } - - if (!empty($_updateTVs)) { - foreach ($_updateTVs as $id => $value) { - $this->query("UPDATE {$this->makeTable('site_tmplvar_contentvalues')} SET `value` = '{$value}' WHERE `contentid` = {$this->id} AND `tmplvarid` = {$id}"); - } - } - if (!empty($_insertTVs)) { $values = array(); foreach ($_insertTVs as $id => $value) { $values[] = "({$this->id}, {$id}, '{$value}')"; } $values = implode(',', $values); - $this->query("INSERT into {$this->makeTable('site_tmplvar_contentvalues')} (`contentid`,`tmplvarid`,`value`) VALUES {$values}"); + $this->query("INSERT INTO {$this->makeTable('site_tmplvar_contentvalues')} (`contentid`,`tmplvarid`,`value`) VALUES {$values} ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`)"); } if (!empty($_deleteTVs)) { @@ -648,6 +613,8 @@ public function save($fire_events = false, $clearCache = false) $this->mode = $this->newDoc ? "new" : "upd"; $this->newDoc = false; } + + if ($this->groupIds) $this->setDocumentGroups($this->id, $this->groupIds); $this->invokeEvent('OnDocFormSave', array( 'mode' => $this->mode, 'id' => $this->id, @@ -663,6 +630,16 @@ public function save($fire_events = false, $clearCache = false) return $this->id; } + /** + * @param $tvId + * @return bool + */ + protected function belongsToTemplate($tvId) { + $template = $this->get('template'); + + return isset($this->tvTpl[$template]) && in_array($tvId, $this->tvTpl[$template]); + } + /** * @param $ids * @return $this @@ -1074,4 +1051,55 @@ public function markAllDecode() return $this; } + + /** + * @param int $docId + */ + public function getDocumentGroups($docId = 0) { + $out = array(); + $doc = $this->switchObject($docId); + if (null !== $doc->getID()) { + $doc_groups = $this->makeTable('document_groups'); + $docgroup_names = $this->makeTable('documentgroup_names'); + + $rs = $this->query("SELECT `dg`.`document_group`, `dgn`.`name` FROM {$doc_groups} as `dg` INNER JOIN {$docgroup_names} as `dgn` ON `dgn`.`id`=`dg`.`document_group` + WHERE `dg`.`document` = " . $doc->getID()); + while ($row = $this->modx->db->getRow($rs)) { + $out[$row['document_group']] = $row['name']; + } + + } + unset($doc); + + return $out; + } + + /** + * @param int $docId + * @param array $groupIds + * @return $this + */ + public function setDocumentGroups($docId = 0, $groupIds = array()) + { + if (!is_array($groupIds)) return $this; + if ($this->newDoc && $docId == 0) { + $this->groupIds = $groupIds; + } else { + $doc = $this->switchObject($docId); + if ($id = $doc->getID()) { + foreach ($groupIds as $gid) { + $this->query("REPLACE INTO {$this->makeTable('document_groups')} (`document_group`, `document`) VALUES ('{$gid}', '{$id}')"); + } + if (!$this->newDoc) { + $groupIds = empty($groupIds) ? '0' : implode(',', $groupIds); + $this->query("DELETE FROM {$this->makeTable('document_groups')} WHERE `document`={$id} AND `document_group` NOT IN ({$groupIds})"); + } + } + unset($doc); + $this->groupIds = array(); + } + + return $this; + } + } diff --git a/assets/lib/MODxAPI/modUsers.php b/assets/lib/MODxAPI/modUsers.php index db8fc9e1c3..1089dfd41d 100644 --- a/assets/lib/MODxAPI/modUsers.php +++ b/assets/lib/MODxAPI/modUsers.php @@ -11,34 +11,36 @@ class modUsers extends MODxAPI */ protected $default_field = array( 'user' => array( - 'username' => null, - 'password' => null, - 'cachepwd' => null + 'username' => '', + 'password' => '', + 'cachepwd' => '' ), 'attribute' => array( - 'fullname' => null, - 'role' => null, - 'email' => null, - 'phone' => null, - 'mobilephone' => null, - 'blocked' => null, - 'blockeduntil' => null, - 'blockedafter' => null, - 'logincount' => null, - 'lastlogin' => null, - 'thislogin' => null, - 'failedlogincount' => null, - 'sessionid' => null, - 'dob' => null, - 'gender' => null, - 'country' => null, - 'state' => null, - 'city' => null, - 'street' => null, - 'zip' => null, - 'fax' => null, - 'photo' => null, - 'comment' => null + 'fullname' => '', + 'role' => '', + 'email' => '', + 'phone' => '', + 'mobilephone' => '', + 'blocked' => 0, + 'blockeduntil' => 0, + 'blockedafter' => 0, + 'logincount' => 0, + 'lastlogin' => 0, + 'thislogin' => 0, + 'failedlogincount' => 0, + 'sessionid' => '', + 'dob' => 0, + 'gender' => 0, + 'country' => '', + 'state' => '', + 'city' => '', + 'street' => '', + 'zip' => '', + 'fax' => '', + 'photo' => '', + 'comment' => '', + 'createdon' => 0, + 'editedon' => 0 ), 'hidden' => array( 'internalKey' @@ -84,6 +86,18 @@ protected function findUser($data) return $find; } + /** + * @param array $data + * @return $this + */ + public function create($data = array()) + { + parent::create($data); + $this->set('createdon', time()); + + return $this; + } + /** * @param $id * @return $this @@ -98,6 +112,7 @@ public function edit($id) if (!$find = $this->findUser($id)) { $this->id = null; } else { + $this->set('editedon', time()); $result = $this->query(" SELECT * from {$this->makeTable('web_user_attributes')} as attribute LEFT JOIN {$this->makeTable('web_users')} as user ON user.id=attribute.internalKey @@ -132,6 +147,10 @@ public function set($key, $value) session_regenerate_id(false); $value = session_id(); break; + case 'editedon': + case 'createdon': + $value = $this->getTime($value); + break; } $this->field[$key] = $value; } @@ -174,6 +193,7 @@ public function save($fire_events = false, $clearCache = false) return false; } + $time = $this->set('sessionid', ''); $fld = $this->toArray(); foreach ($this->default_field['user'] as $key => $value) { @@ -554,10 +574,12 @@ public function getUserGroups($userID = 0) $web_groups = $this->makeTable('web_groups'); $webgroup_names = $this->makeTable('webgroup_names'); - $sql = "SELECT `ugn`.`name` FROM {$web_groups} as `ug` + $rs = $this->query("SELECT `ug`.`webgroup`, `ugn`.`name` FROM {$web_groups} as `ug` INNER JOIN {$webgroup_names} as `ugn` ON `ugn`.`id`=`ug`.`webgroup` - WHERE `ug`.`webuser` = " . $user->getID(); - $out = $this->modx->db->getColumn('name', $this->query($sql)); + WHERE `ug`.`webuser` = " . $user->getID()); + while ($row = $this->modx->db->getRow($rs)) { + $out[$row['webgroup']] = $row['name']; + } } unset($user); @@ -580,6 +602,10 @@ public function setUserGroups($userID = 0, $groupIds = array()) foreach ($groupIds as $gid) { $this->query("REPLACE INTO {$this->makeTable('web_groups')} (`webgroup`, `webuser`) VALUES ('{$gid}', '{$uid}')"); } + if (!$this->newDoc) { + $groupIds = empty($groupIds) ? '0' : implode(',', $groupIds); + $this->query("DELETE FROM {$this->makeTable('web_groups')} WHERE `webuser`={$uid} AND `webgroup` NOT IN ({$groupIds})"); + } } unset($user); $this->groupIds = array(); diff --git a/assets/lib/class.modxRTEbridge.php b/assets/lib/class.modxRTEbridge.php index 1a554dae9d..5fb858fe9a 100644 --- a/assets/lib/class.modxRTEbridge.php +++ b/assets/lib/class.modxRTEbridge.php @@ -33,7 +33,7 @@ public function __construct($editorKey = NULL, $bridgeConfig=array(), $tvOptions // Check right path $file = !empty($basePath) ? $basePath : __FILE__; - $current_path = str_replace('\\', '/', dirname($file)) . '/'; + $current_path = str_replace('\\', '/', dirname($file) . '/'); if (strpos($current_path, MODX_BASE_PATH) !== false) { $path = substr($current_path, strlen(MODX_BASE_PATH)); $basePath = MODX_BASE_PATH . $path; @@ -266,6 +266,7 @@ public function getEditorScript() // Loop through tvs $output .= file_get_contents("{$this->pluginParams['base_path']}tpl/tpl.{$this->editorKey}.init.html") ."\n"; $output = $modx->parseText($output, $ph); + $output = str_replace('\\', '/', $output); } } else { @@ -652,7 +653,7 @@ public function getThemeNames() } foreach (glob("{$themeDir}*") as $file) { - $file = str_replace('\\', '/', $file); + //$file = str_replace('\\', '/', $file); $file = str_replace($themeDir, '', $file); $file = str_replace('theme.' . $this->editorKey . '.', '', $file); @@ -689,7 +690,7 @@ public function getSkinNames() break; } foreach (glob("{$skinDir}*", GLOB_ONLYDIR) as $dir) { - $dir = str_replace('\\', '/', $dir); + //$dir = str_replace('\\', '/', $dir); $skin_name = substr($dir, strrpos($dir, '/') + 1); $skins[$skin_name][] = 'default'; $styles = glob("{$dir}/ui_*.css"); diff --git a/assets/lib/document.class.inc.php b/assets/lib/document.class.inc.php deleted file mode 100644 index 888c41b596..0000000000 --- a/assets/lib/document.class.inc.php +++ /dev/null @@ -1,283 +0,0 @@ -Set('parent',$folder); - $doc->Set('alias','post'.time()); - $doc->Set('content','document content'); - $doc->Set('template','GuestBookComments'); - $doc->Set('tvComment','post to comment'); - $doc->Save(); - - Area of use: - guestbooks, blogs, forums, frontend manager modules - - TODO: - * document_groups - - Important: - 2) Not to be used just for receiving TV values or deleting docs. Use - $modx->getTemplateVars(); and $modx->db->delete(); instead. - -***************************************************************/ -class Document{ - public $fields; // doc fields array - public $tvs; // TV array - - public $tvNames; // TV names array - public $oldTVs; // TV values array - public $isNew; // true - new doc, false - existing doc - - /*********************************************** - Initializing class - $id - existing doc id or 0 for new doc - $fields - comma delimited field list - ************************************************/ - function __construct($id=0,$fields="*"){ - global $modx; - $this->isNew = $id==0; - if(!$this->isNew){ - $this->fields = $modx->getPageInfo($id,0,$fields); - $this->fields['id']=$id; - } - else - $this->fields = array( - 'pagetitle' => 'New document', - 'alias' => '', - 'parent' => 0, - 'createdon' => time(), - 'createdby' => '0', - 'editedon' => '0', - 'editedby' => '0', - 'published' => '1', - 'deleted' => '0', - 'hidemenu' => '1', - 'template' => '0', - 'content' => '' - ); - $this->oldTVs=$this->fillOldTVValues(); - } - - /*********************************************** - Saving/Updating document - ************************************************/ - function Save($clearcache=1){ - global $modx; - $tablename=$modx->getFullTableName('site_content'); - $fields = $modx->db->escape($this->fields); - if($this->isNew){ - $this->fields['id']=$modx->db->insert($fields, $tablename); - $this->isNew = false; - } else { - $id=$this->fields['id']; - $modx->db->update($fields, $tablename, "id='{$id}'"); - } - if(is_array($this->tvs)) $this->saveTVs(); - if ($clearcache == 1) { - $modx->clearCache('full'); - } - } - - - /*********************************************** - Receiving doc values ot TV - $field - doc value or TV with 'tv' prefix - Result: doc value, TV or null - ************************************************/ - function Get($field){ - switch(1){ - case substr($field,0,2)=='tv': return $this->GetTV(substr($field,2)); - default: return isset($this->fields[$field]) ? $this->fields[$field] : null; - } - } - - /*********************************************** - Setting doc or TV value - $field - doc or TV (with prefix 'tv') name - $value - value - Result: true or false - ************************************************/ - function Set($field, $value){ - switch(1){ - case substr($field,0,2)=='tv': return $this->SetTV(substr($field,2), $value); - case $field=='template': return $this->SetTemplate($value); - default: $this->fields[$field]=$value; return true; - } - } - - - /*********************************************** - Receiving TV - $name - TV name - ************************************************/ - function GetTV($tv){ - if(!is_array($this->tvs)){ - if($this->isNew) return null; - $this->tvs=array(); - } - // Look in the values created by Set() function - if(isset($this->tvs[$tv])) return $this->tvs[$tv]; - // Look in the TVs already defined for the document - // Call fillOldTVValues() if not yet retrieved - if(!is_array($this->oldTVs)){ - if($this->isNew) return null; - $this->oldTVs=$this->fillOldTVValues(); - } - if(isset($this->oldTVs[$tv])) return $this->oldTVs[$tv]; - return null; - } - - /*********************************************** - Setting TV value - ************************************************/ - function SetTV($tv,$value){ - if(!is_array($this->tvs)) $this->tvs=array(); - $this->tvs[$tv]=$value; - } - - /*********************************************** - Setting doc template - $tpl - template name or id - ************************************************/ - function SetTemplate($tpl){ - global $modx; - // Retrieve id of template if name is given - if(!is_numeric($tpl)) { - $tpl = $modx->db->getValue($modx->db->select('id', $modx->getFullTableName('site_templates'), "templatename='{$tpl}'", '', 1)); - if(empty($tpl)) return false; - } - - $this->fields['template']=$tpl; - return true; - } - - /************************************************************ - Deleting doc with TVs - *************************************************************/ - function Delete(){ - if($this->isNew) return; - global $modx; - $id=$this->fields['id']; - $modx->db->delete($modx->getFullTableName('site_content'),"id='{$id}'"); - $modx->db->delete($modx->getFullTableName('site_tmplvar_contentvalues'),"contentid='{$id}'"); - $this->isNew=true; - } - - /************************************************************ - Duplicatig doc with TVs - *************************************************************/ - function Duplicate(){ - if($this->isNew) return; - $all_tvs=$this->fillOldTVValues(); - foreach($all_tvs as $tv=>$value) - if(!isset($this->tvs[$tv])) $this->tvs[$tv]=$value; - $this->oldTVs=array(); - $this->isNew=true; - unset($this->fields['id']); - } - - /************************************************************ - Saving TV values, maintenance function. Only $tvNames values are saved, - If a TV exists in oldTVs, then updating, else inserting - *************************************************************/ - function saveTVs(){ - global $modx; - if(!is_array($this->tvNames))$this->fillTVNames(); - //if(!is_array($this->oldTVs) && !$this->isNew) - if(!$this->isNew) - $this->oldTVs=$this->fillOldTVValues(); - else - $this->oldTVs = array(); - - $tvc = $modx->getFullTableName('site_tmplvar_contentvalues'); - foreach($this->tvs as $tv=>$value) - if(isset($this->tvNames[$tv])){ - $fields = array( - 'tmplvarid' => $this->tvNames[$tv], - 'contentid' => $this->fields['id'], - 'value' => $value, - ); - $fields = $modx->db->escape($fields); - if(isset($this->oldTVs[$tv])){ - if($this->oldTVs[$tv]==$this->tvNames[$tv]) continue; - $modx->db->update($fields, $tvc, "tmplvarid='{$fields['tmplvarid']}' AND contentid='{$fields['contentid']}'"); - } - else - $modx->db->insert($fields, $tvc); - } - } - - /************************************************************ - Filling TV array ($oldTVs), maintenance function. - Differs from $modx->getTemplateVars - *************************************************************/ - function fillOldTVValues(){ - global $modx; - if (($this->isNew) && (!$this->fields['id'] || $this->fields['id'] == '')) { - return array(); - } - $tvc = $modx->getFullTableName('site_tmplvar_contentvalues'); - $tvs = $modx->getFullTableName('site_tmplvars'); - $result = $modx->db->select( - 'tvs.name as name, tvc.value as value', - $modx->getFullTableName('site_tmplvar_contentvalues')." tvc - INNER JOIN ".$modx->getFullTableName('site_tmplvars')." tvs ON tvs.id=tvc.tmplvarid WHERE tvc.contentid =".$this->fields['id']."" - ); - $TVs = array(); - while ($row = $modx->db->getRow($result)) $TVs[$row['name']] = $row['value']; - return $TVs; - } - - /************************************************************ - Fillin TV names array ($tvNames)), maintenance function. - *************************************************************/ - function fillTVNames(){ - global $modx; - $this->tvNames = array(); - $result = $modx->db->select('id, name', $modx->getFullTableName('site_tmplvars')); - while ($row = $modx->db->getRow($result)) $this->tvNames[$row['name']] = $row['id']; - } - - function setAlias ($alias = '') { - $iso = array("Р°"=>"a", "Р±"=>"b", "РІ"=>"v", "Рі"=>"g", "Рґ"=>"d", "Рµ"=>"e", - "С‘"=>"jo", "Р¶"=>"zh", "Р·"=>"z", "Рё"=>"i", "Р№"=>"jj", "Рє"=>"k", "Р»"=>"l", - "Рј"=>"m", "РЅ"=>"n", "Рѕ"=>"o", "Рї"=>"p", "СЂ"=>"r", "СЃ"=>"s", "С‚"=>"t", "Сѓ"=>"u", - "С„"=>"f", "С…"=>"kh", "С†"=>"c", "С‡"=>"ch", "С€"=>"sh", "С‰"=>"shh", "С‹"=>"y", - "СЌ"=>"eh", "СЋ"=>"yu", "СЏ"=>"ya", "Рђ"=>"a", "Р‘"=>"b", "Р’"=>"v", "Р“"=>"g", - "Р”"=>"d", "Р•"=>"e", "РЃ"=>"jo", "Р–"=>"zh", "Р—"=>"z", "И"=>"i", "Р™"=>"jj", - "Рљ"=>"k", "Р›"=>"l", "Рњ"=>"m", "Рќ"=>"n", "Рћ"=>"o", "Рџ"=>"p", "Р "=>"r", "РЎ"=>"s", - "Рў"=>"t", "РЈ"=>"u", "Р¤"=>"f", "РҐ"=>"kh", "Р¦"=>"c", "Р§"=>"ch", "РЁ"=>"sh", - "Р©"=>"shh", "Р«"=>"y", "Р­"=>"eh", "Р®"=>"yu", "РЇ"=>"ya", " "=>"-", "."=>"-", - ","=>"-", "_"=>"-", "+"=>"", ":"=>"", ";"=>"", "!"=>"", "?"=>"", "/"=>"", "\\"=>""); - - if ($alias == '') { - if (!isset($this->fields['id']) - || $this->fields['id'] == 0 - || !isset($this->fields['pagetitle']) - || $this->fields['pagetitle'] == '') { - return; - } else { - - $title = mb_convert_encoding($this->fields['pagetitle'], 'cp-1251', 'UTF-8'); - $alias = strtr($title, $iso); - $alias2 = $this->fields['id'];// .'-'. $alias; - } - } else { - $alias = strtr($alias, $iso); - - } - - $this->Set('alias', $alias2); - $this->Save(); - return $alias; -} - -} -?> \ No newline at end of file diff --git a/assets/lib/resourse.php b/assets/lib/resourse.php deleted file mode 100644 index 985118f328..0000000000 --- a/assets/lib/resourse.php +++ /dev/null @@ -1,493 +0,0 @@ - - -USE: -require_once('assets/libs/resourse.php'); -$resourse=resourse::Instance($modx); - -#------------------------------------------------------ -* Add new document without invoke event and clear cache -$resourse->document()->set('titl','Пропаганда')->set('pagetitle',$i)->save(null,false); - -* Add new document without invoke event and call clear cache -$resourse->document()->set('titl','Пропаганда')->set('pagetitle',$i)->save(null,true); - -* Add new document call event and without clear cache -$resourse->document()->set('titl','Пропаганда')->set('pagetitle',$i)->save(true,false); - -#------------------------------------------------------- -#Edit resourse #13 -$resourse->edit(13)->set('pagetitle','new pagetitle')->save(null,false); - -#------------------------------------------------------- -$resourse->delete(8); - - -//JSON && PHP < 5.3 -$t = test::Instance(); -function asd($json){ - $t = test::Instance(); - foreach($json as $key=>$val){ - $t->set($key,$val); - } -} -$t->fromJson($json,'asd'); - -//JSON && PHP >= 5.3 -$t = test::Instance(); -$t->fromJson($json, function($json) use ($t){ - foreach($json as $key=>$val){ - $t->set($key,$val); - } -}); -*/ - - -if(!defined('MODX_BASE_PATH')) {die('What are you doing? Get out of here!');} - - -class resourse { - static $_instance = null; - private $_modx = null; - private $id = 0; - private $field = array(); - private $tv = array(); - private $tvid = array(); - private $log = array(); - private $edit = 0; - private $default_field ; - private $table=array('"'=>'_',"'"=>'_',' '=>'_','.'=>'_',','=>'_','а'=>'a','б'=>'b','в'=>'v', - 'г'=>'g','д'=>'d','е'=>'e','ё'=>'e','ж'=>'zh','з'=>'z','и'=>'i','й'=>'y','к'=>'k', - 'л'=>'l','м'=>'m','н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u', - 'ф'=>'f','х'=>'h','ц'=>'c','ч'=>'ch','ш'=>'sh','щ'=>'sch','ь'=>'','ы'=>'y','ъ'=>'', - 'э'=>'e','ю'=>'yu','я'=>'ya','А'=>'A','Б'=>'B','В'=>'V','Г'=>'G','Д'=>'D','Е'=>'E', - 'Ё'=>'E','Ж'=>'Zh','З'=>'Z','И'=>'I','Й'=>'Y','К'=>'K','Л'=>'L','М'=>'M','Н'=>'N', - 'О'=>'O','П'=>'P','Р'=>'R','С'=>'S','Т'=>'T','У'=>'U','Ф'=>'F','Х'=>'H','Ц'=>'C', - 'Ч'=>'Ch','Ш'=>'Sh','Щ'=>'Sch','Ь'=>'','Ы'=>'Y','Ъ'=>'','Э'=>'E','Ю'=>'Yu','Я'=>'Ya','/'=>'-', - ); - - private $set; - private $flag = false; - private $_table = array('site_content','site_tmplvar_contentvalues','site_tmplvars','site_templates','web_user_settings'); - - private function __construct($modx){ - try{ - if($modx instanceof DocumentParser){ - $this->modx = $modx; - } else throw new Exception('MODX should be instance of DocumentParser'); - - if(!$this->makeTable()) throw new Exception('Not exists table'); - - }catch(Exception $e){ die($e->getMessage()); } - - $this->get_TV(); - } - - private final function __clone(){throw new Exception('Clone is not allowed');} - - static public function Instance($modx){ - if (self::$_instance == NULL){self::$_instance = new self($modx);} - return self::$_instance; - } - - public function document($id=0){ - $this->newDoc = $id == 0; - $this->id = $id; - $this->field=array(); - $this->set=array(); - $this->default_field = array( - 'type'=>'document', - 'contentType'=>'text/html', - 'pagetitle'=>'New document', - 'longtitle'=>'', - 'description'=>'', - 'alias'=>'', - 'link_attributes'=>'', - 'published'=>'1', - 'pub_date'=>'0', - 'unpub_date'=>'0', - 'parent'=>'0', - 'isfolder'=>'0', - 'introtext'=>'', - 'content'=>'', - 'richtext'=>'1', - 'template'=>'0', - 'menuindex'=>'0', - 'searchable'=>'1', - 'cacheable'=>'1', - 'createdon'=>time(), - 'createdby'=>'0', - 'editedon'=>'0', - 'editedby'=>'0', - 'deleted'=>'0', - 'deletedon'=>'0', - 'deletedby'=>'0', - 'publishedon'=>'0', - 'publishedby'=>'0', - 'menutitle'=>'', - 'donthit'=>'0', - 'haskeywords'=>'0', - 'hasmetatags'=>'0', - 'privateweb'=>'0', - 'privatemgr'=>'0', - 'content_dispo'=>'0', - 'hidemenu'=>'1', - 'alias_visible'=>'1' - ); - $this->flag = true; - return $this; - } - - private function makeTable(){ - //@TODO: check exists table - $flag = true; - foreach($this->_table as $item){ - $this->_table[$item] = $this->modx->getFullTableName($item); - } - return $flag; - } - - private function Uset($key){ - if(!isset($this->field[$key])){ - $this->set[$key]= ""; - $this->log[] = "{$key} is empty"; - } else { - try{ - if(is_scalar($this->field[$key])){ - $this->set[$key]= $this->field[$key]; - } else throw new Exception("{$key} is not scalar
".print_r($this->field[$key],true)."
"); - }catch(Exception $e){ die($e->getMessage()); } - } - return $this; - } - - private function invokeEvent($name,$data=array(),$flag=false){ - $flag = (isset($flag) && $flag!='') ? (bool)$flag : false; - if($flag){ - $this->modx->invokeEvent($name,$data); - } - return $this; - } - - public function clearCache($fire_events = null){ - $this->modx->clearCache('full'); - $this->invokeEvent('OnSiteRefresh',array(),$fire_events); - } - - public function list_log($flush = false){ - echo '
'.print_r($this->log,true).'
'; - if($flush) $this->clearLog(); - return $this; - } - - public function clearLog(){ - $this->log = array(); - return $this; - } - - public function set($key,$value){ - $value = str_replace("'", "\'", $value ); - if(is_scalar($value) && is_scalar($key) && !empty($key)){ - switch($key){ - case 'template': { - $value = trim($value); - $value = $this->setTemplate($value); - break; - } - } - $this->field[$key] = $value; - } - return $this; - } - - private function setTemplate($tpl) { - if(!is_numeric($tpl) || $tpl != (int) $tpl) { - try{ - if(is_scalar($tpl)){ - $rs = $this->modx->db->select('id', $this->_table['site_templates'], "templatename = '{$tpl}'"); - if($this->modx->db->getRecordCount($rs) <= 0) throw new Exception("Template {$tpl} is not exists"); - $tpl = $this->modx->db->getValue($rs); - } else throw new Exception("Invalid template name: ".print_r($tpl,1)); - }catch(Exception $e){ - $tpl = 0; - die($e->getMessage()); - } - } - return (int)$tpl; - } - - public function get($key){ - return isset($this->field[$key]) ? $this->field[$key] : null; - } - - private function getAlias(){ - if ($this->modx->config['friendly_urls'] && $this->modx->config['automatic_alias'] && $this->get('alias') == ''){ - $alias = mb_strtolower(strtr($this->get('pagetitle'), $this->table)); - }else{ - if($this->get('alias')!=''){ - $alias = $this->get('alias'); - }else{ - $alias = ''; - } - } - return $this->checkAlias($alias); - } - - public function get_TV(){ - $result = $this->modx->db->select('id,name', $this->_table['site_tmplvars']); - while($row = $this->modx->db->getRow($result)) { - $this->tv[$row['name']] = $row['id']; - $this->tvid[$row['id']] = $row['name']; - } - } - - public function fromArray($data){ - foreach($data as $key=>$value) $this->set($key,$value); - return $this; - } - - public function edit($id){ - if(!$this->flag) $this->document($id); - - $result = $this->modx->db->select('*', $this->_table['site_content'], "id=".(int)$id); - $this->fromArray($this->modx->db->getRow($result)); - - $result = $this->modx->db->select('*', $this->_table['site_tmplvar_contentvalues'], "contentid=".(int)$id); - while ($row = $this->modx->db->getRow($result)){ - $this->set($this->tvid[$row['tmplvarid']], $row['value']); - } - unset($this->field['id']); - return $this; - } - - private function systemID(){ - $ignore = array( - 0, //empty document - (int)$this->modx->config['site_start'], - (int)$this->modx->config['error_page'], - (int)$this->modx->config['unauthorized_page'], - (int)$this->modx->config['site_unavailable_page'] - ); - $data = $this->modx->db->select('DISTINCT setting_value', $this->_table['web_user_settings'], "setting_name='login_home' AND setting_value!=''"); - $data = $this->modx->db->makeArray($data); - foreach($data as $item){ - $ignore[]=(int)$item['setting_value']; - } - return array_unique($ignore); - - } - - public function delete($ids,$fire_events = null){ - //@TODO: delete with SET deleted=1 - $ignore = $this->systemID(); - $_ids = $this->cleanIDs($ids, ',', $ignore); - try{ - if(is_array($_ids) && $_ids!=array()){ - $this->invokeEvent('OnBeforeEmptyTrash',array( - "ids"=>$_ids - ),$fire_events); - - $id = $this->sanitarIn($_ids); - $this->modx->db->delete($this->_table['site_content'], "id IN ({$id})"); - $this->modx->db->delete($this->_table['site_tmplvar_contentvalues'], "contentid IN ({$id})"); - - $this->invokeEvent('OnEmptyTrash',array( - "ids"=>$_ids - ),$fire_events); - } else throw new Exception('Invalid IDs list for delete:
'.print_r($ids,1).'
please, check ignore list:
'.print_r($ignore,1).'
'); - }catch(Exception $e){ die($e->getMessage()); } - - return $this; - } - - final private function cleanIDs($IDs,$sep=',',$ignore = array()) { - $out=array(); - if(!is_array($IDs)){ - try{ - if(is_scalar($IDs)){ - $IDs=explode($sep, $IDs); - } else { - $IDs = array(); - throw new Exception('Invalid IDs list
'.print_r($IDs,1).'
'); - } - } catch(Exception $e){ die($e->getMessage()); } - } - foreach($IDs as $item){ - $item = trim($item); - if(is_numeric($item) && (int)$item>=0){ //Fix 0xfffffffff - if(!empty($ignore) && in_array((int)$item, $ignore, true)){ - $this->log[] = 'Ignore id '.(int)$item; - }else{ - $out[]=(int)$item; - } - } - } - print_r($ignore); - $out = array_unique($out); - return $out; - } - - final protected function check($id){ - return (is_array($id) && $id!=array()) ? true : false; - } - - final protected function sanitarIn($data,$sep=','){ - if(!is_array($data)){ - $data=explode($sep,$data); - } - $out = $this->modx->db->escape($data); - $out="'".implode("','",$out)."'"; - return $out; - } - - public function fromJson($data,$callback=null){ - try{ - if(is_scalar($data) && !empty($data)){ - $json = json_decode($data); - }else throw new Exception("json is not string with json data"); - if ($this->jsonError($json)) { - if(isset($callback) && is_callable($callback)){ - call_user_func_array($callback,array($json)); - }else{ - if(isset($callback)) throw new Exception("Can't call callback JSON unpack
".print_r($callback,1)."
"); - foreach($json as $key=>$val){ - $this->set($key,$val); - } - } - } else throw new Exception('Error from JSON decode:
'.print_r($data,1).'
'); - }catch(Exception $e){ die($e->getMessage()); } - return $this; - } - - public function toJson($callback=null){ - try{ - $data = $this->toArray(); - $json = json_encode($data); - if(!$this->jsonError($data,$json)) { - $json = false; - throw new Exception('Error from JSON decode:
'.print_r($data,1).'
'); - } - }catch(Exception $e){ die($e->getMessage()); } - return $json; - } - - private function jsonError($data){ - $flag = false; - if(!function_exists('json_last_error')){ - function json_last_error(){ - return JSON_ERROR_NONE; - } - } - if(json_last_error() === JSON_ERROR_NONE && is_object($data) && $data instanceof stdClass){ - $flag = true; - } - return $flag; - } - - public function toArray(){ - return $this->field; - } - - private function checkAlias($alias, $i=1){ - if($this->modx->config['friendly_urls']){ - $flag = false; - $_alias = $this->modx->db->escape($alias); - if(!$this->modx->config['allow_duplicate_alias'] || ($this->modx->config['allow_duplicate_alias'] && $this->modx->conifg['use_alias_path'])){ - $flag = $this->modx->db->getValue($this->modx->db->select('id', $this->_table['site_content'], "alias='{$_alias}' AND parent={$this->get('parent')}", '', 1)); - } else { - $flag = $this->modx->db->getValue($this->modx->db->select('id', $this->_table['site_content'], "alias='{$_alias}'", '', 1)); - } - if(($flag && $this->newDoc) || (!$this->newDoc && $flag && $this->id != $flag)){ - /*$suffix = substr($alias, -2); - if(preg_match('/-(\d+)/',$suffix,$tmp) && isset($tmp[1]) && (int)$tmp[1]>1){ - $suffix = (int)$tmp[1] + 1; - $alias = substr($alias, 0, -2) . '-'. $suffix; - }else{ - $alias .= '-2'; - }*/ - $alias = $this->checkAlias($alias.'-'.$i,$i+1); - } - } - return $alias; - } - - public function save($fire_events = null,$clearCache = false){ - try{ - if(!$this->flag){ - throw new Exception('You need flush document field before set and save resource'); - } - }catch(Exception $e){ die($e->getMessage()); } - - if ($this->field['pagetitle'] == '') { - $this->log[] = 'Pagetitle is empty in
'.print_r($this->field,true).'
'; - return false; - } - $this->set('alias',$this->getAlias()); - - $this->invokeEvent('OnBeforeDocFormSave',array ( - "mode" => $this->newDoc ? "new" : "upd", - "id" => $this->id ? $this->id : '' - ),$fire_events); - - $fld = $this->toArray(); - foreach($this->default_field as $key=>$value){ - if ($this->newDoc && $this->get($key) == '' && $this->get($key)!==$value){ - $this->set($key,$value); - } - $this->Uset($key,$value); - unset($fld[$key]); - } - if (!empty($this->set)){ - if($this->newDoc){ - $this->modx->db->insert($this->set, $this->_table['site_content']); - }else{ - $this->modx->db->update($this->set, $this->_table['site_content'], "id = '{$this->id}'"); - } - } - - if($this->newDoc) $this->id = $this->modx->db->getInsertId(); - - foreach($fld as $key=>$value){ - #if ($value=='') continue; - if ($this->tv[$key]!=''){ - $fields = array( - 'tmplvarid' => $this->tv[$key], - 'contentid' => $this->id, - 'value' => $this->modx->db->escape($value), - ); - - $rs = $this->modx->db->select('value', $this->_table['site_tmplvar_contentvalues'], "contentid = '{$fields['contentid']}' AND tmplvarid = '{$fields['tmplvarid']}'"); - - if ( $this->modx->db->getRecordCount($rs) > 0 ) { - $row = $this->modx->db->getRow($rs); - if ($row['value'] != $value) { - $this->modx->db->update($fields, $this->_table['site_tmplvar_contentvalues'], "contentid = '{$fields['contentid']}' AND tmplvarid = '{$fields['tmplvarid']}'"); - } - }else{ - $this->modx->db->insert($fields, $this->_table['site_tmplvar_contentvalues']); - } - - } - } - $this->invokeEvent('OnDocFormSave',array ( - "mode" => $this->newDoc ? "new" : "upd", - "id" => $this->id - ),$fire_events); - - if($clearCache){ - $this->clearCache($fire_events); - } - $this->flag = false; - return $this->id; - } -} \ No newline at end of file diff --git a/assets/modules/docmanager/classes/dm_frontend.class.php b/assets/modules/docmanager/classes/dm_frontend.class.php index f676917b01..88a619e83d 100644 --- a/assets/modules/docmanager/classes/dm_frontend.class.php +++ b/assets/modules/docmanager/classes/dm_frontend.class.php @@ -81,7 +81,6 @@ function renderDocumentSelect() { function renderMisc() { $this->dm->ph['view.misc'] = $this->dm->parseTemplate('misc.tpl', $this->dm->ph); $this->dm->ph['view.tab'] = (is_numeric($_GET['tab'])) ? '' : ''; - } function renderChangeAuthors() { diff --git a/assets/modules/docmanager/js/docmanager.js b/assets/modules/docmanager/js/docmanager.js index fb866c3c46..bbfbc1f6cc 100644 --- a/assets/modules/docmanager/js/docmanager.js +++ b/assets/modules/docmanager/js/docmanager.js @@ -1,130 +1,138 @@ -function getCookie(name) { - var dc = document.cookie; - var prefix = name + "="; - var begin = dc.indexOf("; " + prefix); - if (begin == -1) { - begin = dc.indexOf(prefix); - if (begin != 0) return null; - } else { - begin += 2; - } - var end = document.cookie.indexOf(";", begin); - if (end == -1) { - end = dc.length; +function getCookie(name) +{ + var dc = document.cookie; + var prefix = name + '='; + var begin = dc.indexOf('; ' + prefix); + if (begin == -1) { + begin = dc.indexOf(prefix); + if (begin != 0) { + return null; } - return unescape(dc.substring(begin + prefix.length, end)); + } else { + begin += 2; + } + var end = document.cookie.indexOf(';', begin); + if (end == -1) { + end = dc.length; + } + return decodeURIComponent(dc.substring(begin + prefix.length, end)); } -function getSelectedRadio(buttonGroup) { - if (buttonGroup[0]) { - for (var i=0; i

[+lang.DM_adjust_authors_header+]


-

[+lang.DM_adjust_authors_desc+]


+
+
+

[+lang.DM_adjust_authors_header+]

+

[+lang.DM_adjust_authors_desc+]

- [+changeauthors.options+]

- - +
\ No newline at end of file diff --git a/assets/modules/docmanager/templates/documentgroups.tpl b/assets/modules/docmanager/templates/documentgroups.tpl index e58851b129..105a343e09 100644 --- a/assets/modules/docmanager/templates/documentgroups.tpl +++ b/assets/modules/docmanager/templates/documentgroups.tpl @@ -1,8 +1,8 @@

[+lang.DM_doc_desc+]


-[+documentgroups.grid+] -

- [+lang.DM_doc_radio_add+]   - [+lang.DM_doc_radio_remove+] -

+ [+documentgroups.grid+] +

+  [+lang.DM_doc_radio_add+]   +  [+lang.DM_doc_radio_remove+] +

\ No newline at end of file diff --git a/assets/modules/docmanager/templates/documents.tpl b/assets/modules/docmanager/templates/documents.tpl index 1b821c6a8a..979e469bb1 100644 --- a/assets/modules/docmanager/templates/documents.tpl +++ b/assets/modules/docmanager/templates/documents.tpl @@ -1,23 +1,29 @@ -
-
-
[+lang.DM_range_title+]
-
-
- - - - - - - - - - - - -
-
- [+lang.DM_select_range_text+] -
+
+
+
+
[+lang.DM_range_title+]
+
+
+ + + + + + + + + + +
+ + + + +
+
+
+ [+lang.DM_select_range_text+] +
+
\ No newline at end of file diff --git a/assets/modules/docmanager/templates/main.tpl b/assets/modules/docmanager/templates/main.tpl index 5354c52dfe..81d9b610cc 100644 --- a/assets/modules/docmanager/templates/main.tpl +++ b/assets/modules/docmanager/templates/main.tpl @@ -1,103 +1,132 @@ - [+lang.DM_module_title+] - - - - - - + + + + - [+onManagerMainFrameHeaderHTMLBlock+] + return true; + } + + [+onManagerMainFrameHeaderHTMLBlock+]

- [+lang.DM_module_title+] + [+lang.DM_module_title+]

-
-
- +
+ -
-

[+lang.DM_change_template+]

- - [+view.templates+] -
+
+

[+lang.DM_change_template+]

+ +
+ [+view.templates+] +
+
-
-

[+lang.DM_template_variables+]

- - [+view.templatevars+] -
+
+

[+lang.DM_template_variables+]

+ +
+ [+view.templatevars+] +
+
-
-

[+lang.DM_doc_permissions+]

- - [+view.documentgroups+] -
+
+

[+lang.DM_doc_permissions+]

+ +
+ [+view.documentgroups+] +
+
-
-

[+lang.DM_other+]

- - [+view.misc+] - [+view.changeauthors+] -
-
+
+

[+lang.DM_other+]

+ +
+ [+view.misc+] + [+view.changeauthors+] +
+
+ [+view.documents+] [+view.tab+] diff --git a/assets/modules/docmanager/templates/misc.tpl b/assets/modules/docmanager/templates/misc.tpl index 0bc98caef0..3e4574b03b 100644 --- a/assets/modules/docmanager/templates/misc.tpl +++ b/assets/modules/docmanager/templates/misc.tpl @@ -1,67 +1,67 @@ -

[+lang.DM_adjust_dates_header+]


-

[+lang.DM_adjust_dates_desc+]


+
+

[+lang.DM_adjust_dates_header+]

+

[+lang.DM_adjust_dates_desc+]

- - - - - - - - - - - - - - - - - -
- - -
- - -
- - -
- - -
+ + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+ + +
-
-

[+lang.DM_other_header+]


-

[+lang.DM_misc_desc+]


+

[+lang.DM_other_header+]

+

[+lang.DM_misc_desc+]

- - - - - - - - - - - - - - -

-   -   + + + + + + + + + + + + + + +

+   +  
\ No newline at end of file diff --git a/assets/modules/docmanager/templates/templates.tpl b/assets/modules/docmanager/templates/templates.tpl index 7511b332cd..9026b84379 100644 --- a/assets/modules/docmanager/templates/templates.tpl +++ b/assets/modules/docmanager/templates/templates.tpl @@ -1,13 +1,16 @@ -

[+lang.DM_tpl_desc+]


+

[+lang.DM_tpl_desc+]

+
- [+templates.grid+] -
- - - - - - - -
0[+lang.DM_tpl_blank_template+]
+ [+templates.grid+] +
+ + + + + + + + + +
0[+lang.DM_tpl_blank_template+]
\ No newline at end of file diff --git a/assets/modules/docmanager/templates/templatevars.tpl b/assets/modules/docmanager/templates/templatevars.tpl index 7578c391ac..947122aa8e 100644 --- a/assets/modules/docmanager/templates/templatevars.tpl +++ b/assets/modules/docmanager/templates/templatevars.tpl @@ -2,11 +2,12 @@
[+templatevars.grid+] -
+ +

[+lang.DM_tv_no_template_selected+]
- + - - + +
\ No newline at end of file diff --git a/assets/modules/docmanager/templates/update.tpl b/assets/modules/docmanager/templates/update.tpl index 9d3216dae6..14f0688cdb 100644 --- a/assets/modules/docmanager/templates/update.tpl +++ b/assets/modules/docmanager/templates/update.tpl @@ -1,46 +1,48 @@ - [+lang.DM_update_title+] - - - - - + [+lang.DM_update_title+] + + + + +

[+lang.DM_module_title+]

-
-
[+lang.DM_update_title+]
-
-

[+update.message+]

- -
+
+
+ [+lang.DM_update_title+] +

[+update.message+]

+ +
+ \ No newline at end of file diff --git a/assets/modules/docmanager/tv.ajax.php b/assets/modules/docmanager/tv.ajax.php index a67d6e491c..35ea6dd2ba 100644 --- a/assets/modules/docmanager/tv.ajax.php +++ b/assets/modules/docmanager/tv.ajax.php @@ -5,164 +5,172 @@ include_once("../../cache/siteManager.php"); -require_once '../../../'.MGR_DIR.'/includes/protect.inc.php'; -include_once ('../../../'.MGR_DIR.'/includes/config.inc.php'); -include_once (MODX_MANAGER_PATH.'includes/document.parser.class.inc.php'); -include_once (MODX_BASE_PATH.'assets/modules/docmanager/classes/docmanager.class.php'); +require_once '../../../' . MGR_DIR . '/includes/protect.inc.php'; +include_once('../../../' . MGR_DIR . '/includes/config.inc.php'); +include_once(MODX_MANAGER_PATH . 'includes/document.parser.class.inc.php'); +include_once(MODX_BASE_PATH . 'assets/modules/docmanager/classes/docmanager.class.php'); $modx = new DocumentParser; $modx->getSettings(); $dm = new DocManager($modx); $dm->getLang(); $dm->getTheme(); - - $output = ''; - - if(isset($_POST['tplID']) && is_numeric($_POST['tplID'])) { - $rs = $modx->db->select( - '*', - $modx->getFullTableName('site_tmplvars')." tv - LEFT JOIN ".$modx->getFullTableName('site_tmplvar_templates')." AS tvt ON tv.id = tvt.tmplvarid", - "tvt.templateid ='{$_POST['tplID']}'" - ); - $limit = $modx->db->getRecordCount($rs); - - if ($limit > 0) { - require (MODX_MANAGER_PATH.'includes/tmplvars.commands.inc.php'); - $output.= ""; - $i = 0; - while ($row = $modx->db->getRow($rs)) { +$output = ''; - if($i++>0) $output .= ''; - - $output.=' +$which_browser = $modx->configGlobal['which_browser'] ? $modx->configGlobal['which_browser'] : $modx->config['which_browser']; + +if (isset($_POST['tplID']) && is_numeric($_POST['tplID'])) { + $rs = $modx->db->select('*', $modx->getFullTableName('site_tmplvars') . " tv + LEFT JOIN " . $modx->getFullTableName('site_tmplvar_templates') . " AS tvt ON tv.id = tvt.tmplvarid", "tvt.templateid ='{$_POST['tplID']}'"); + $limit = $modx->db->getRecordCount($rs); + + if ($limit > 0) { + require(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); + $output .= "
"; + + $i = 0; + while ($row = $modx->db->getRow($rs)) { + + if ($i++ > 0) { + $output .= ''; + } + + $output .= ''; - } - $output.='
-  '.$row['caption'].'
'.$row['description'].' +  ' . $row['caption'] . '
' . $row['description'] . '
'; - $base_url = str_replace("assets/modules/docmanager/", "", MODX_BASE_URL); - $output.= renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $row['value'], ' style="width:300px;"'); - $output.= '
'; - //$output.= '
'.$dm->lang['DM_tv_ignore_tv'].' '; - } else { - print $dm->lang['DM_tv_no_tv']; - } - - print $output; - } else { - print ''; - } - + $base_url = str_replace("assets/modules/docmanager/", "", MODX_BASE_URL); + $output .= renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $row['value'], ' style="width:300px;"'); + $output .= ''; + } + $output .= ''; + //$output.= '
'.$dm->lang['DM_tv_ignore_tv'].' '; + } else { + print $dm->lang['DM_tv_no_tv']; + } + + print $output; +} else { + print ''; +} -function renderFormElement($field_type, $field_id, $default_text, $field_elements, $field_value, $field_style='') { - global $modx; - global $dm; - global $base_url; - global $rb_base_url; +function renderFormElement($field_type, $field_id, $default_text, $field_elements, $field_value, $field_style = '') +{ + global $modx; + global $dm; + global $base_url; + global $rb_base_url; - $field_html =''; - $field_value = ($field_value!="" ? $field_value : $default_text); + $field_html = ''; + $field_value = ($field_value != "" ? $field_value : $default_text); - switch ($field_type) { - case "text": // handler for regular text boxes - case "rawtext"; // non-htmlentity converted text boxes - case "email": // handles email input fields - case "number": // handles the input of numbers - $field_html .= ''; - break; - case "textareamini": // handler for textarea mini boxes - $field_html .= ''; - break; - case "textarea": // handler for textarea boxes - case "rawtextarea": // non-htmlentity convertex textarea boxes - case "htmlarea": // handler for textarea boxes (deprecated) - case "richtext": // handler for textarea boxes - $field_html .= ''; - break; - case "date": - $field_id = str_replace(array('-', '.'),'_', urldecode($field_id)); - if($field_value=='') $field_value=0; - $field_html .= ''; - $field_html .= ' No date'; + switch ($field_type) { + case "text": // handler for regular text boxes + case "rawtext"; // non-htmlentity converted text boxes + case "email": // handles email input fields + case "number": // handles the input of numbers + $field_html .= ''; + break; + case "textareamini": // handler for textarea mini boxes + $field_html .= ''; + break; + case "textarea": // handler for textarea boxes + case "rawtextarea": // non-htmlentity convertex textarea boxes + case "htmlarea": // handler for textarea boxes (deprecated) + case "richtext": // handler for textarea boxes + $field_html .= ''; + break; + case "date": + $field_id = str_replace(array('-', '.'), '_', urldecode($field_id)); + if ($field_value == '') { + $field_value = 0; + } + $field_html .= ''; + $field_html .= ' No date'; - break; - case "dropdown": // handler for select boxes - $field_html .= '"; - break; - case "listbox": // handler for select boxes - $field_html .= '"; - break; - case "listbox-multiple": // handler for select boxes where you can choose multiple items - $field_value = explode("||",$field_value); - $field_html .= '"; - break; - case "url": // handles url input fields - $urls= array(''=>'--', 'http://'=>'http://', 'https://'=>'https://', 'ftp://'=>'ftp://', 'mailto:'=>'mailto:'); - $field_html ='
'; - $field_html .= '
'; - break; - case "checkbox": // handles check boxes - $field_value = !is_array($field_value) ? explode("||",$field_value) : $field_value; - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id)); - static $i=0; - while (list($item, $itemvalue) = each ($index_list)) - { - list($item,$itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue); - if (strlen($itemvalue)==0) $itemvalue = $item; - $field_html .= '
'; - $i++; - } - break; - case "option": // handles radio buttons - $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id)); - while (list($item, $itemvalue) = each ($index_list)) - { - list($item,$itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue); - if (strlen($itemvalue)==0) $itemvalue = $item; - $field_html .= ''.$item.'
'; - } - break; - case "image": // handles image fields using htmlarea image manager - global $ResourceManagerLoaded; - global $content,$use_editor,$which_editor,$which_browser; - if (!$ResourceManagerLoaded && !(($content['richtext']==1 || $_GET['a']==4) && $use_editor==1 && $which_editor==3)){ - $field_html .=" + break; + case "dropdown": // handler for select boxes + $field_html .= '"; + break; + case "listbox": // handler for select boxes + $field_html .= '"; + break; + case "listbox-multiple": // handler for select boxes where you can choose multiple items + $field_value = explode("||", $field_value); + $field_html .= '"; + break; + case "url": // handles url input fields + $urls = array('' => '--', 'http://' => 'http://', 'https://' => 'https://', 'ftp://' => 'ftp://', 'mailto:' => 'mailto:'); + $field_html = '
'; + $field_html .= '
'; + break; + case "checkbox": // handles check boxes + $field_value = !is_array($field_value) ? explode("||", $field_value) : $field_value; + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id)); + static $i = 0; + while (list($item, $itemvalue) = each($index_list)) { + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); + if (strlen($itemvalue) == 0) { + $itemvalue = $item; + } + $field_html .= '
'; + $i++; + } + break; + case "option": // handles radio buttons + $index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_id)); + while (list($item, $itemvalue) = each($index_list)) { + list($item, $itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==", $itemvalue); + if (strlen($itemvalue) == 0) { + $itemvalue = $item; + } + $field_html .= '' . $item . '
'; + } + break; + case "image": // handles image fields using htmlarea image manager + global $ResourceManagerLoaded; + global $content, $use_editor, $which_editor, $which_browser; + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $_GET['a'] == 4) && $use_editor == 1 && $which_editor == 3)) { + $field_html .= " "; - $ResourceManagerLoaded = true; - } - $field_html .=' '; - break; - case "file": // handles the input of file uploads - /* Modified by Timon for use with resource browser */ - global $ResourceManagerLoaded; - global $content,$use_editor,$which_editor; - if (!$ResourceManagerLoaded && !(($content['richtext']==1 || $_GET['a']==4) && $use_editor==1 && $which_editor==3)){ - /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ - $field_html .=" + $ResourceManagerLoaded = true; + } + $field_html .= ' '; + break; + case "file": // handles the input of file uploads + /* Modified by Timon for use with resource browser */ + global $ResourceManagerLoaded; + global $content, $use_editor, $which_editor, $which_browser; + if (!$ResourceManagerLoaded && !(($content['richtext'] == 1 || $_GET['a'] == 4) && $use_editor == 1 && $which_editor == 3)) { + /* I didn't understand the meaning of the condition above, so I left it untouched ;-) */ + $field_html .= " "; - $ResourceManagerLoaded = true; - } - $field_html .=' '; - - break; - default: // the default handler -- for errors, mostly - $field_html .= ''; - } // end switch statement - return $field_html; + $ResourceManagerLoaded = true; + } + $field_html .= ' '; + + break; + default: // the default handler -- for errors, mostly + $field_html .= ''; + } // end switch statement + return $field_html; } // end renderFormElement function -function ParseIntputOptions($v) { - global $modx; - $a = array(); - if(is_array($v)) return $v; - else if($modx->db->isResult($v)) { - $a = $modx->db->makeArray($v); - } - else $a = explode("||", $v); - return $a; +function ParseIntputOptions($v) +{ + global $modx; + $a = array(); + if (is_array($v)) { + return $v; + } else if ($modx->db->isResult($v)) { + $a = $modx->db->makeArray($v); + } else { + $a = explode("||", $v); + } + return $a; } diff --git a/assets/modules/store/core.php b/assets/modules/store/core.php index 215b44f50a..d5aec6269a 100644 --- a/assets/modules/store/core.php +++ b/assets/modules/store/core.php @@ -208,6 +208,7 @@ public static function copyFolder($src, $dest) { $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach($objects as $name => $object) { + if (!$objects->getDepth() && $object->isFile()) continue; $startsAt = substr(dirname($name), strlen($path)); self::mkDir($dest.$startsAt); if ( $object->isDir() ) { diff --git a/assets/modules/store/installer/index.php b/assets/modules/store/installer/index.php index f3c59924e0..5ea0c64115 100755 --- a/assets/modules/store/installer/index.php +++ b/assets/modules/store/installer/index.php @@ -4,8 +4,10 @@ define('MODX_BASE_PATH',realpath('../../../../').'/'); include_once(MODX_BASE_PATH."assets/cache/siteManager.php"); define('MGR',MODX_BASE_PATH.MGR_DIR); - - +$autoloader = realpath(MODX_BASE_PATH . 'vendor/autoload.php'); +if (file_exists($autoloader) && is_readable($autoloader)) { + include_once($autoloader); +} define('MODX_API_MODE', true); include_once MGR.'/includes/config.inc.php'; @@ -15,16 +17,9 @@ $modx->getSettings(); startCMSSession(); $modx->minParserPasses=2; - +$modx->invokeEvent('OnManagerPageInit'); if(IN_MANAGER_MODE!='true' && !$modx->hasPermission('exec_module')) die('INCLUDE_ORDERING_ERROR

Please use the MODX Content Manager instead of accessing this file directly.'); - - - -if (version_compare(phpversion(), "5.3") < 0) { - @ ini_set('magic_quotes_runtime', 0); - @ ini_set('magic_quotes_sybase', 0); -} $moduleurl = $modx->config['site_url'].'assets/modules/store/installer/index.php'; $modulePath = MODX_BASE_PATH.'assets/modules/store/installer/'; $self = $modulePath.'/index.php'; diff --git a/assets/modules/store/installer/instprocessor-fast.php b/assets/modules/store/installer/instprocessor-fast.php index 812862345e..c81180fdee 100644 --- a/assets/modules/store/installer/instprocessor-fast.php +++ b/assets/modules/store/installer/instprocessor-fast.php @@ -5,10 +5,9 @@ define('MODX_BASE_PATH',realpath('../../../../').'/'); include_once(MODX_BASE_PATH."assets/cache/siteManager.php"); define('MGR',MODX_BASE_PATH.MGR_DIR); - -if (version_compare(phpversion(), "5.3") < 0) { - @ ini_set('magic_quotes_runtime', 0); - @ ini_set('magic_quotes_sybase', 0); +$autoloader = realpath(MODX_BASE_PATH .'vendor/autoload.php'); +if (file_exists($autoloader) && is_readable($autoloader)) { + include_once($autoloader); } $moduleurl = 'assets/modules/store/installer/index.php'; $modulePath = dirname(__FILE__); @@ -61,7 +60,7 @@ $modx->getSettings(); startCMSSession(); $modx->minParserPasses=2; - +$modx->invokeEvent('OnManagerPageInit'); global $moduleName; global $moduleVersion; global $moduleSQLBaseFile; diff --git a/assets/modules/store/installer/instprocessor.php b/assets/modules/store/installer/instprocessor.php index 64a84d3a30..5aea76e05e 100644 --- a/assets/modules/store/installer/instprocessor.php +++ b/assets/modules/store/installer/instprocessor.php @@ -6,6 +6,10 @@ $sqlParser = ''; define('MODX_API_MODE', true); +$autoloader = realpath(MODX_BASE_PATH .'vendor/autoload.php'); +if (file_exists($autoloader) && is_readable($autoloader)) { + include_once($autoloader); +} include_once MGR.'/includes/protect.inc.php'; include_once MGR.'/includes/config.inc.php'; include_once MGR.'/includes/document.parser.class.inc.php'; @@ -14,7 +18,7 @@ $modx->getSettings(); startCMSSession(); $modx->minParserPasses=2; - +$modx->invokeEvent('OnManagerPageInit'); global $moduleName; global $moduleVersion; global $moduleSQLBaseFile; diff --git a/assets/modules/store/installer/sqlParser.class.php b/assets/modules/store/installer/sqlParser.class.php index 6d80fc4438..6395b140e9 100755 --- a/assets/modules/store/installer/sqlParser.class.php +++ b/assets/modules/store/installer/sqlParser.class.php @@ -8,7 +8,7 @@ class SqlParser { var $mode, $fileManagerPath, $imgPath, $imgUrl; var $connection_charset, $connection_method; - function SqlParser( ) { + public function __construct() { $adminname=''; $adminemail=''; $adminpass=''; diff --git a/assets/modules/store/update.php b/assets/modules/store/update.php deleted file mode 100755 index 8aad258729..0000000000 --- a/assets/modules/store/update.php +++ /dev/null @@ -1,40 +0,0 @@ -open(dirname(__FILE__).'/update.zip'); -$zip->extractTo( dirname(__FILE__) ); -$zip->close(); -echo dirname(__FILE__).'/update.zip'; -unlink('update.zip'); -?> \ No newline at end of file diff --git a/assets/plugins/codemirror/cm/theme/one-dark.css b/assets/plugins/codemirror/cm/theme/one-dark.css index d521d0f682..d7aa0a3d56 100644 --- a/assets/plugins/codemirror/cm/theme/one-dark.css +++ b/assets/plugins/codemirror/cm/theme/one-dark.css @@ -7,7 +7,7 @@ /* UI Theme /----------------------------------------------------------------------------------- */ .cm-s-one-dark.CodeMirror { -border: none; +border-color: transparent; font-size: 1em; } .cm-s-one-dark.CodeMirror pre { diff --git a/assets/plugins/codemirror/codemirror.plugin.php b/assets/plugins/codemirror/codemirror.plugin.php index 78b0d0d16b..10c962348e 100644 --- a/assets/plugins/codemirror/codemirror.plugin.php +++ b/assets/plugins/codemirror/codemirror.plugin.php @@ -19,7 +19,7 @@ $textarea_name = 'post'; $mode = 'htmlmixed'; $lang = 'htmlmixed'; -$readOnly = isset( $readOnly ) && $readOnly === true ? 'true' : 'false'; +$readOnly = isset($readOnly) && $readOnly === true ? 'true' : 'false'; /* * Default Plugin configuration */ @@ -51,96 +51,103 @@ /* * Switch event */ -switch ($modx->Event->name) { - case 'OnTempFormRender' : - $object_name = $content['templatename']; - $rte = ($prte ? $prte : 'none'); - break; - case 'OnChunkFormRender' : - $rte = isset($which_editor) ? $which_editor : 'none'; - break; +switch($modx->Event->name) { + case 'OnTempFormRender' : + $object_name = $content['templatename']; + $rte = ($prte ? $prte : 'none'); + break; + case 'OnChunkFormRender' : + $rte = isset($which_editor) ? $which_editor : 'none'; + break; - case 'OnRichTextEditorInit': - if ($editor !== 'Codemirror') return; - $textarea_name = $modx->event->params['elements']; - $object_name = $content['pagetitle']; - $rte = 'none'; - $tvMode = true; - $contentType = $content['contentType'] ? $content['contentType'] : $modx->event->params['contentType']; + case 'OnRichTextEditorInit': + if($editor !== 'Codemirror') { + return; + } + $textarea_name = $modx->event->params['elements']; + $object_name = $content['pagetitle']; + $rte = 'none'; + $tvMode = true; + $contentType = $content['contentType'] ? $content['contentType'] : $modx->event->params['contentType']; - /* - * Switch contentType for doc - */ - switch ($contentType) { - case "text/css": - $mode = "text/css"; - $lang = "css"; - break; - case "text/javascript": - $mode = "text/javascript"; - $lang = "javascript"; - break; - case "application/json": - $mode = "application/json"; - $lang = "javascript"; - break; - case "application/x-httpd-php": - $mode = "application/x-httpd-php"; - $lang = "php"; - break; - } - break; - case 'OnDocFormRender' : - if($content['type'] == 'reference') return; - $textarea_name = 'ta'; - $object_name = $content['pagetitle']; - $xrte = (('htmlmixed' == $mode) ? $xrte : 0); - $rte = ($prte ? $prte : ($content['id'] ? ($xrte ? $srte : 'none') : $srte)); - $contentType = $content['contentType']; - /* - * Switch contentType for doc - */ - switch ($contentType) { - case "text/css": - $mode = "text/css"; - $lang = "css"; - break; - case "text/javascript": - $mode = "text/javascript"; - $lang = "javascript"; - break; - case "application/json": - $mode = "application/json"; - $lang = "javascript"; - break; - } - break; + /* + * Switch contentType for doc + */ + switch($contentType) { + case "text/css": + $mode = "text/css"; + $lang = "css"; + break; + case "text/javascript": + $mode = "text/javascript"; + $lang = "javascript"; + break; + case "application/json": + $mode = "application/json"; + $lang = "javascript"; + break; + case "application/x-httpd-php": + $mode = "application/x-httpd-php"; + $lang = "php"; + break; + } + break; + case 'OnDocFormRender' : + if($content['type'] == 'reference') { + return; + } + $textarea_name = 'ta'; + $object_name = $content['pagetitle']; + $xrte = (('htmlmixed' == $mode) ? $xrte : 0); + $rte = ($prte ? $prte : ($content['id'] ? ($xrte ? $srte : 'none') : $srte)); + $contentType = $content['contentType']; + /* + * Switch contentType for doc + */ + switch($contentType) { + case "text/css": + $mode = "text/css"; + $lang = "css"; + break; + case "text/javascript": + $mode = "text/javascript"; + $lang = "javascript"; + break; + case "application/json": + $mode = "application/json"; + $lang = "javascript"; + break; + } + break; - case 'OnSnipFormRender' : - case 'OnPluginFormRender' : - case 'OnModFormRender' : - $tvMode = true; - // $limitedHeight = true; // No limited height since MODX 1.2 - $elements = array($textarea_name,'properties'); - $mode = 'application/x-httpd-php-open'; - $rte = ($prte ? $prte : 'none'); - $lang = "php"; - break; + case 'OnSnipFormRender' : + case 'OnPluginFormRender' : + case 'OnModFormRender' : + $tvMode = true; + // $limitedHeight = true; // No limited height since MODX 1.2 + $elements = array( + $textarea_name, + 'properties' + ); + $mode = 'application/x-httpd-php-open'; + $rte = ($prte ? $prte : 'none'); + $lang = "php"; + break; - case 'OnManagerPageRender': - if ((31 == $action) && (('view' == $_REQUEST['mode']) || ('edit' == $_REQUEST['mode']))) { - $textarea_name = 'content'; - $rte = 'none'; - } - break; + case 'OnManagerPageRender': + if((31 == $action) && (('view' == $_REQUEST['mode']) || ('edit' == $_REQUEST['mode']))) { + $textarea_name = 'content'; + $rte = 'none'; + } + break; - default: - $this->logEvent(1, 2, 'Undefined event : ' . $modx->Event->name . ' in ' . $this->Event->activePlugin . ' Plugin', 'CodeMirror Plugin : ' . $modx->Event->name); + default: + $this->logEvent(1, 2, 'Undefined event : ' . $modx->Event->name . ' in ' . $this->Event->activePlugin . ' Plugin', 'CodeMirror Plugin : ' . $modx->Event->name); } $output = ''; -if (('none' == $rte) && $mode && !defined('INIT_CODEMIRROR')) { - define('INIT_CODEMIRROR', 1); - $output = <<< HEREDOC +if(('none' == $rte) && $mode && !defined('INIT_CODEMIRROR')) { + define('INIT_CODEMIRROR', 1); + $output = <<< HEREDOC @@ -264,26 +271,44 @@ function makeMarker(symbol) { undoDepth: {$undoDepth}, historyEventDelay: {$historyEventDelay}, extraKeys:{ + // add marker "Ctrl-Space": function(cm){ var n = cm.getCursor().line; var info = cm.lineInfo(n); foldFunc(cm, n); cm.setGutterMarker(n, "breakpoints", info.gutterMarkers ? null : makeMarker("+")); }, + // save "Ctrl-S": function(cm) { - document.getElementById('Button1').getElementsByTagName('a')[0].onclick(); + var el = document.querySelector('a#Button1') || document.querySelector('#Button1 > a'); + if(el) el.onclick(); }, + // save and continue "Ctrl-E": function(cm) { - document.getElementById('Button1').getElementsByTagName('select')[0].options[1].selected = true; - document.getElementById('Button1').getElementsByTagName('a')[0].onclick(); + var el = document.querySelector('a#Button1') || document.querySelector('#Button1 > a'); + var el2 = document.querySelector('#stay'); + if(el && el2) { + el2.options[1].selected = true; + el.onclick(); + } }, + // save and new "Ctrl-B": function(cm) { - document.getElementById('Button1').getElementsByTagName('select')[0].options[0].selected = true; - document.getElementById('Button1').getElementsByTagName('a')[0].onclick(); + var el = document.querySelector('a#Button1') || document.querySelector('#Button1 > a'); + var el2 = document.querySelector('#stay'); + if(el && el2) { + el2.options[0].selected = true; + el.onclick(); + } }, + // save and quit "Ctrl-Q": function(cm) { - document.getElementById('Button1').getElementsByTagName('select')[0].options[2].selected = true; - document.getElementById('Button1').getElementsByTagName('a')[0].onclick(); + var el = document.querySelector('a#Button1') || document.querySelector('#Button1 > a'); + var el2 = document.querySelector('#stay'); + if(el && el2) { + el2.options[2].selected = true; + el.onclick(); + } } } }; @@ -292,81 +317,81 @@ function makeMarker(symbol) { HEREDOC; } -if (!$tvMode) { - $elements = array($textarea_name); +if(!$tvMode) { + $elements = array($textarea_name); } -if (('none' == $rte) && $mode && $elements !== NULL) { - foreach ($elements as $el) { +if(('none' == $rte) && $mode && $elements !== NULL) { + foreach($elements as $el) { - if($el != $textarea_name && $limitedHeight) { - $setHeight = "myCodeMirrors['{$el}'].setSize('98%', 260);"; - } else { - $setHeight = ''; - }; - - $object_id = md5($evt->name . '-' . $content['id'] . '-' . $el); - - $output .= " - \n"; - }; + $object_id = md5($evt->name . '-' . $content['id'] . '-' . $el); + + $output .= " + \n"; + }; }; -$modx->Event->output($output); \ No newline at end of file +$modx->Event->output($output); 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 274e6aa9e8..ae538aa72c 100644 --- a/assets/plugins/elementsintree/assets/txt_content.tpl +++ b/assets/plugins/elementsintree/assets/txt_content.tpl @@ -1,198 +1,356 @@ @@ -286,22 +444,22 @@ } // Issue #20 - Keep HTTP_REFERER - function reloadElementsInTree() { - // http://stackoverflow.com/a/7917528/2354531 - var url = "index.php?a=1&f=tree"; - var a = document.createElement("a"); - if (a.click) - { - // HTML5 browsers and IE support click() on , early FF does not. - a.setAttribute("href", url); - a.style.display = "none"; - document.body.appendChild(a); - a.click(); - } else { - // Early FF can, however, use this usual method where IE cannot with secure links. - window.location = url; - } - } +// function reloadElementsInTree() { +// // http://stackoverflow.com/a/7917528/2354531 +// var url = "index.php?a=1&f=tree"; +// var a = document.createElement("a"); +// if (a.click) +// { +// // HTML5 browsers and IE support click() on , early FF does not. +// a.setAttribute("href", url); +// a.style.display = "none"; +// document.body.appendChild(a); +// a.click(); +// } else { +// // Early FF can, however, use this usual method where IE cannot with secure links. +// window.location = url; +// } +// } ///////////////////////////////////////////////////////////// // Prepare "remember scroll-position" functions 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/managermanager/widgets/showimagetvs/jquery.ddMM.mm_widget_showimagetvs.js b/assets/plugins/managermanager/widgets/showimagetvs/jquery.ddMM.mm_widget_showimagetvs.js index 691a15fbf6..b8332bb63e 100755 --- a/assets/plugins/managermanager/widgets/showimagetvs/jquery.ddMM.mm_widget_showimagetvs.js +++ b/assets/plugins/managermanager/widgets/showimagetvs/jquery.ddMM.mm_widget_showimagetvs.js @@ -67,7 +67,7 @@ $.fn.mm_widget_showimagetvs = function(params){ $this.data('lastvalue', url); - if (url.length > 0 && url.search(/http:\/\//i) == -1 && url.search(/\//) != 0){ + if (url.length > 0 && url.search(/https?:\/\//i) == -1 && url.search(/\//) != 0){ url = $.ddMM.config.site_url + url; } // If we have a PHPThumb URL diff --git a/assets/plugins/qm/qm.inc.php b/assets/plugins/qm/qm.inc.php index 846205b4c6..dd276f9a46 100755 --- a/assets/plugins/qm/qm.inc.php +++ b/assets/plugins/qm/qm.inc.php @@ -4,7 +4,7 @@ * * @author Mikko Lammi, www.maagit.fi, updated by Dmi3yy and Nicola1971 * @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html - * @version 1.5.7 updated 21/01/2017 + * @version 1.5.8 updated 21/08/2017 */ if(!class_exists('Qm')) { @@ -13,7 +13,7 @@ class Qm { var $modx; //_______________________________________________________ - function __construct(&$modx, $jqpath='', $loadmanagerjq='', $loadfrontendjq='', $noconflictjq='', $loadtb='', $tbwidth='', $tbheight='', $hidefields='', $hidetabs='', $hidesections='', $addbutton='', $tpltype='', $tplid='', $custombutton='', $managerbutton='', $logout='', $autohide='', $position='', $editbuttons='', $editbclass='', $newbuttons='', $newbclass='', $tvbuttons='', $tvbclass='', $buttonStyle='', $removeBg='') { + function __construct(&$modx, $jqpath='', $loadmanagerjq='', $loadfrontendjq='', $noconflictjq='', $loadfa='', $loadtb='', $tbwidth='', $tbheight='', $hidefields='', $hidetabs='', $hidesections='', $addbutton='', $tpltype='', $tplid='', $custombutton='', $managerbutton='', $logout='', $autohide='', $position='', $editbuttons='', $editbclass='', $newbuttons='', $newbclass='', $tvbuttons='', $tvbclass='', $buttonStyle='', $removeBg='') { $this->modx = $modx; // Get plugin parameters @@ -21,6 +21,7 @@ function __construct(&$modx, $jqpath='', $loadmanagerjq='', $loadfrontendjq='', $this->loadmanagerjq = $loadmanagerjq; $this->loadfrontendjq = $loadfrontendjq; $this->noconflictjq = $noconflictjq; + $this->loadfa = $loadfa; $this->loadtb = $loadtb; $this->tbwidth = $tbwidth; $this->tbheight = $tbheight; @@ -481,11 +482,17 @@ function Run() { $MGR_DIR = $this->modx->getManagerPath( ); $css = ' '; - + $css .= ' - '; + + // font-awesome + if ($this->loadfa == 'true') { + $css .= ' + + '; + } // Buttons Styles if ($this->buttonStyle == 'actionButtons') { $css .= ' 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/plugins/updater/lang/russian-UTF8.php b/assets/plugins/updater/lang/russian-UTF8.php index ca9511d57a..eb901c467a 100644 --- a/assets/plugins/updater/lang/russian-UTF8.php +++ b/assets/plugins/updater/lang/russian-UTF8.php @@ -15,7 +15,7 @@ $_lang['pluginname'] = 'Updater'; $_lang['system_update'] = 'Обновление системы'; $_lang["cms_outdated_msg"] = 'Система управления сайтом устарела. Для обновления обратитесь к разработчикам сайта. Актуальная версия'; -$_lang['bkp_before_msg'] = 'Настоятельно рекомендую сделать бекап перед обновлением системы, обновление выполняете на свой страх и риск!!'; +$_lang['bkp_before_msg'] = 'Настоятельно рекомендуется сделать бекап перед обновлением системы, обновление выполняется на свой страх и риск!'; $_lang['updateButton_txt'] = 'Обновить до версии'; //Error Messages $_lang['error_curl'] = 'Необходимо включить функцию CURL в PHP'; diff --git a/assets/plugins/updater/lang/russian.php b/assets/plugins/updater/lang/russian.php index ca9511d57a..eb901c467a 100644 --- a/assets/plugins/updater/lang/russian.php +++ b/assets/plugins/updater/lang/russian.php @@ -15,7 +15,7 @@ $_lang['pluginname'] = 'Updater'; $_lang['system_update'] = 'Обновление системы'; $_lang["cms_outdated_msg"] = 'Система управления сайтом устарела. Для обновления обратитесь к разработчикам сайта. Актуальная версия'; -$_lang['bkp_before_msg'] = 'Настоятельно рекомендую сделать бекап перед обновлением системы, обновление выполняете на свой страх и риск!!'; +$_lang['bkp_before_msg'] = 'Настоятельно рекомендуется сделать бекап перед обновлением системы, обновление выполняется на свой страх и риск!'; $_lang['updateButton_txt'] = 'Обновить до версии'; //Error Messages $_lang['error_curl'] = 'Необходимо включить функцию CURL в PHP'; diff --git a/assets/plugins/updater/plugin.updater.php b/assets/plugins/updater/plugin.updater.php index b0a0b3c907..aa9d3020ea 100644 --- a/assets/plugins/updater/plugin.updater.php +++ b/assets/plugins/updater/plugin.updater.php @@ -7,6 +7,7 @@ */ if(!defined('MODX_BASE_PATH')){die('What are you doing? Get out of here!');} +if (empty($_SESSION['mgrInternalKey'])) return; $version = 'evolution-cms/evolution'; $type = isset($type) ? $type: 'tags'; @@ -32,6 +33,7 @@ if (!extension_loaded('curl')){ $errorsMessage .= '-'.$_lang['error_curl'].'
'; $errors += 1; + $curlNotReady = true; } if (!extension_loaded('zip')){ $errorsMessage .= '-'.$_lang['error_zip'].'
'; @@ -46,6 +48,23 @@ $errors += 1; } + // Avoid "Fatal error: Call to undefined function curl_init()" + if(isset($curlNotReady)) { + $output = '
+ '.$errorsMessage.'
'; + + $widgets['updater'] = array( + 'menuindex' =>'1', + 'id' => 'updater', + 'cols' => 'col-sm-12', + 'icon' => 'fa-exclamation-triangle', + 'title' => $_lang['system_update'], + 'body' => $output + ); + $e->output(serialize($widgets)); + return; + } + $output = ''; if(!file_exists(MODX_BASE_PATH . 'assets/cache/updater/check_'.date("d").'.json')){ $ch = curl_init(); @@ -73,7 +92,7 @@ $_SESSION['updatelink'] = md5(time()); $_SESSION['updateversion'] = $git['version']; - if ($git['version'] != $currentVersion['version'] && $git['version'] != '') { + if (version_compare($git['version'], $currentVersion['version'],'>') && $git['version'] != '') { // get manager role $role = $_SESSION['mgrRole']; if(($role!=1) AND ($showButton == 'AdminOnly') OR ($showButton == 'hide') OR ($errors > 0)) { @@ -190,11 +209,11 @@ function mmkDir($folder, $perm = 0777) downloadFile("https://github.com/".$version."/archive/" . $_GET["version"] . ".zip", "evo.zip"); $zip = new ZipArchive; -$res = $zip->open(dirname(__FILE__) . "/evo.zip"); -$zip->extractTo(dirname(__FILE__) . "/temp"); +$res = $zip->open(__DIR__ . "/evo.zip"); +$zip->extractTo(__DIR__ . "/temp"); $zip->close(); -if ($handle = opendir(dirname(__FILE__) . "/temp")) { +if ($handle = opendir(__DIR__ . "/temp")) { while (false !== ($name = readdir($handle))) { if ($name != "." && $name != "..") { $dir = $name; @@ -202,29 +221,30 @@ function mmkDir($folder, $perm = 0777) } closedir($handle); } -removeFolder(dirname(__FILE__) . "/temp/" . $dir . "/install/assets/chunks"); -removeFolder(dirname(__FILE__) . "/temp/" . $dir . "/install/assets/tvs"); -removeFolder(dirname(__FILE__) . "/temp/" . $dir . "/install/assets/templates"); -unlink(dirname(__FILE__) . "/temp/" . $dir . "/.htaccess"); -unlink(dirname(__FILE__) . "/temp/" . $dir . "/ht.access"); -unlink(dirname(__FILE__) . "/temp/" . $dir . "/robots.txt"); +removeFolder(__DIR__ . "/temp/" . $dir . "/install/assets/chunks"); +removeFolder(__DIR__ . "/temp/" . $dir . "/install/assets/tvs"); +removeFolder(__DIR__ . "/temp/" . $dir . "/install/assets/templates"); +unlink(__DIR__ . "/temp/" . $dir . "/ht.access"); +unlink(__DIR__ . "/temp/" . $dir . "/README.md"); +unlink(__DIR__ . "/temp/" . $dir . "/sample-robots.txt"); + -if(is_file(dirname(__FILE__) . "/assets/cache/siteManager.php")){ +if(is_file(__DIR__ . "/assets/cache/siteManager.php")){ - unlink(dirname(__FILE__) . "/temp/" . $dir . "/assets/cache/siteManager.php"); - include_once(dirname(__FILE__) . "/assets/cache/siteManager.php"); + unlink(__DIR__ . "/temp/" . $dir . "/assets/cache/siteManager.php"); + include_once(__DIR__ . "/assets/cache/siteManager.php"); if(!defined("MGR_DIR")){ define("MGR_DIR","manager"); } if(MGR_DIR != "manager"){ - mmkDir(dirname(__FILE__)."/temp/".$dir."/".MGR_DIR); - copyFolder(dirname(__FILE__)."/temp/".$dir."/manager", dirname(__FILE__)."/temp/".$dir."/".MGR_DIR); - removeFolder(dirname(__FILE__)."/temp/".$dir."/manager"); + mmkDir(__DIR__."/temp/".$dir."/".MGR_DIR); + copyFolder(__DIR__."/temp/".$dir."/manager", __DIR__."/temp/".$dir."/".MGR_DIR); + removeFolder(__DIR__."/temp/".$dir."/manager"); } - echo dirname(__FILE__)."/temp/".$dir."/".MGR_DIR; + echo __DIR__."/temp/".$dir."/".MGR_DIR; } -copyFolder(dirname(__FILE__)."/temp/".$dir, dirname(__FILE__)."/"); -removeFolder(dirname(__FILE__)."/temp"); -unlink(dirname(__FILE__)."/evo.zip"); -unlink(dirname(__FILE__)."/update.php"); +copyFolder(__DIR__."/temp/".$dir, __DIR__."/"); +removeFolder(__DIR__."/temp"); +unlink(__DIR__."/evo.zip"); +unlink(__DIR__."/update.php"); header("Location: /install/index.php?action=mode");'); diff --git a/assets/snippets/DLUsers/lang/russian-UTF8.php b/assets/snippets/DLUsers/lang/russian-UTF8.php deleted file mode 100755 index 658e6c9e64..0000000000 --- a/assets/snippets/DLUsers/lang/russian-UTF8.php +++ /dev/null @@ -1,14 +0,0 @@ - array( - 'incorrect_mail' => 'Указан (если вообще указан) не корректный email', - 'no_user' => 'Пользователь не обнаружен или заблокирован', - 'incorrect_password' => 'Не удалось авторизоваться. Пароль указан не верно или в плагине отказали в авторизации' - ) -); - -return $_lang; diff --git a/assets/snippets/DLUsers/plugin.DLLogout.php b/assets/snippets/DLUsers/plugin.DLLogout.php deleted file mode 100755 index 7be5bb9bae..0000000000 --- a/assets/snippets/DLUsers/plugin.DLLogout.php +++ /dev/null @@ -1,10 +0,0 @@ -event->name == 'OnWebPagePrerender' && $modx->getLoginUserID('web')) { - $snippetName = (isset($snippetName) && is_string($snippetName)) ? $snippetName : 'DLUsers'; - $modx->runSnippet($snippetName, array( - 'action' => 'logout' - )); -} diff --git a/assets/snippets/DLUsers/snippet.DLUsers.php b/assets/snippets/DLUsers/snippet.DLUsers.php deleted file mode 100755 index c56b1f329c..0000000000 --- a/assets/snippets/DLUsers/snippet.DLUsers.php +++ /dev/null @@ -1,14 +0,0 @@ -event->params) ? $modx->event->params : array(); -$action = APIHelpers::getkey($params, 'action', ''); -$lang = APIHelpers::getkey($params, 'lang', $modx->getConfig('manager_language')); -$userClass = APIHelpers::getkey($params, 'userClass', 'modUsers'); -$DLUsers = \DLUsers\Actions::getInstance($modx, $lang, $userClass); -$out = ''; -if ( ! empty($action) && method_exists($DLUsers, $action)) { - $out = call_user_func_array(array($DLUsers, $action), array($params)); -} - -return $out; diff --git a/assets/snippets/DLUsers/src/Actions.php b/assets/snippets/DLUsers/src/Actions.php deleted file mode 100755 index c67a2c3e43..0000000000 --- a/assets/snippets/DLUsers/src/Actions.php +++ /dev/null @@ -1,578 +0,0 @@ -modx = $modx; - $this->userObj = new $userClass($this->modx, $debug); - $this->url = new DLCollection($this->modx); - - $site_url = $this->modx->getConfig('site_url'); - $site_start = $this->modx->getConfig('site_start', 1); - $error_page = $this->modx->getConfig('error_page', $site_start); - $unauthorized_page = $this->modx->getConfig('unauthorized_page', $error_page); - - $this->config = compact('site_url', 'site_start', 'error_page', 'unauthorized_page'); - } - - /** - * prevent the instance from being cloned - * - * @return void - */ - private function __clone() - { - - } - - /** - * prevent from being unserialized - * - * @return void - */ - private function __wakeup() - { - - } - - /** - * Сброс авторизации и обновление страницы - */ - public function logout($params) - { - $LogoutName = APIHelpers::getkey($params, 'LogoutName', 'logout'); - if (is_scalar($LogoutName) && !empty($LogoutName) && isset($_GET[$LogoutName])) { - $userID = $this->UserID('web'); - if ($userID) { - $this->userObj->edit($userID); - $params = array(); - if ($this->userObj->getID()) { - $params = array( - "userid" => $this->userObj->getID(), - "username" => $this->userObj->get('username') - ); - $this->modx->invokeEvent("OnBeforeWebLogout", $params); - } - $this->userObj->logOut(); - if ($this->userObj->getID()) { - $this->modx->invokeEvent("OnWebLogout", $params); - } - - $go = APIHelpers::getkey($params, 'url', ''); - if (empty($go)) { - $go = str_replace( - array("?" . $LogoutName, "&" . $LogoutName), - array("", ""), - $_SERVER['REQUEST_URI'] - ); - } - - $start = $this->makeUrl($this->config['site_start']); - if ($start == $go) { - $go = $this->config['site_url']; - } else { - $go = $this->config['site_url'] . ltrim($go, '/'); - } - $this->moveTo(array('url' => $go)); - } else { - //Если юзер не авторизован, то показываем ему 404 ошибку - $this->modx->sendErrorPage(); - } - } - - return true; - } - - /** - * Генерация ссылки под кнопку выход - * @return string - */ - public function logoutUrl($params) - { - $LogoutName = APIHelpers::getkey($params, 'LogoutName', 'logout'); - $request = parse_url($_SERVER['REQUEST_URI']); - - //Во избежании XSS мы не сохраняем весь REQUEST_URI, а берем только path - $query = '?' . $LogoutName; - - return $request['path'] . $query; - } - - /** - * Авторизация из блока - * если указан параметр authId, то данные из формы перекидываются в метод AuthPage - * В противном случае вся работа происходит внутри самого блока - */ - public function AuthBlock($params) - { - $POST = array('backUrl' => $_SERVER['REQUEST_URI']); - - $error = $errorCode = ''; - - $pwdField = APIHelpers::getkey($params, 'pwdField', 'password'); - $emailField = APIHelpers::getkey($params, 'emailField', 'email'); - $rememberField = APIHelpers::getkey($params, 'rememberField', 'remember'); - - if ($this->UserID('web')) { - $tpl = APIHelpers::getkey($params, 'tplProfile', ''); - if (empty($tpl)) { - $tpl = $this->getTemplate('tplProfile'); - } - $dataTPL = $this->userObj->toArray(); - $dataTPL['url.logout'] = $this->logoutUrl($params); - $homeID = APIHelpers::getkey($params, 'homeID'); - if (!empty($homeID)) { - $dataTPL['url.profile'] = $this->makeUrl($homeID); - } - } else { - $tpl = APIHelpers::getkey($params, 'tplForm', ''); - if (empty($tpl)) { - $tpl = $this->getTemplate('authForm'); - } - $POST = $this->Auth($pwdField, $emailField, $rememberField, $POST['backUrl'], __METHOD__, $error, - $errorCode, $params); - $dataTPL = array( - 'backUrl' => APIHelpers::getkey($POST, 'backUrl', ''), - 'emailValue' => APIHelpers::getkey($POST, 'email', ''), - 'emailField' => $emailField, - 'pwdField' => $pwdField, - 'method' => strtolower(__METHOD__), - 'error' => $error, - 'errorCode' => $errorCode - ); - $authId = APIHelpers::getkey($params, 'authId'); - if (!empty($authId)) { - $dataTPL['authPage'] = $this->makeUrl($authId); - $dataTPL['method'] = strtolower(__CLASS__ . '::' . 'authpage'); - } - } - - return DLTemplate::getInstance($this->modx)->parseChunk($tpl, $dataTPL); - } - - /** - * Авторизация на сайте со страницы авторизации - * [!Auth? &login=`password` &pwdField=`password` &homeID=`72`!] - */ - public function AuthPage($params) - { - $homeID = APIHelpers::getkey($params, 'homeID'); - $this->isAuthGoHome(array('id' => $homeID)); - - $error = $errorCode = ''; - $POST = array('backUrl' => ''); - - $pwdField = APIHelpers::getkey($params, 'pwdField', 'password'); - $emailField = APIHelpers::getkey($params, 'emailField', 'email'); - $rememberField = APIHelpers::getkey($params, 'rememberField', 'remember'); - - $tpl = APIHelpers::getkey($params, 'tpl', ''); - if (empty($tpl)) { - $tpl = $this->getTemplate('authForm'); - } - - $request = parse_url($_SERVER['REQUEST_URI']); - if ($request === false) { - $request = array(); - } - if (!empty($_SERVER['HTTP_REFERER'])) { - /** - * Thank you for super protection against hacking in protect.inc.php:-) - */ - $refer = htmlspecialchars_decode($_SERVER['HTTP_REFERER'], ENT_QUOTES); - } else { - $refer = $this->getBackUrl($request); - } - - if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $backUrl = APIHelpers::getkey($_POST, 'backUrl', $POST['backUrl']); - if (!is_scalar($backUrl)) { - $backUrl = $refer; - } else { - $backUrl = urldecode($backUrl); - } - } else { - $backUrl = $refer; - } - $backUrl = parse_url($backUrl); - if ($backUrl === false) { - $backUrl = array(); - } - if (!empty($backUrl['path']) && $request['path'] != $backUrl['path']) { - $POST['backUrl'] = $backUrl['path']; - } else { - $POST['backUrl'] = $this->getBackUrl($backUrl); - } - if (!empty($POST['backUrl'])) { - $idURL = $this->moveTo(array( - 'url' => '/' . ltrim($POST['backUrl'], '/'), - 'validate' => true - )); - } else { - $idURL = 0; - } - if (empty($idURL)) { - if (empty($homeID)) { - $homeID = $this->config['site_start']; - } - $POST['backUrl'] = $this->makeUrl($homeID); - } - $POST = $this->Auth($pwdField, $emailField, $rememberField, $POST['backUrl'], __METHOD__, $error, $errorCode, - $params); - - return DLTemplate::getInstance($this->modx)->parseChunk($tpl, array( - 'backUrl' => APIHelpers::getkey($POST, 'backUrl', ''), - 'emailValue' => APIHelpers::getkey($POST, 'email', ''), - 'emailField' => $emailField, - 'pwdField' => $pwdField, - 'method' => strtolower(__METHOD__), - 'error' => $error, - 'errorCode' => $errorCode - )); - } - - /** - * @param array $request - * @return string - */ - protected function getBackUrl(array $request = array()) - { - $selfHost = rtrim(str_replace("http://", "", $this->config['site_url']), '/'); - if (empty($request['host']) || $request['host'] == $selfHost) { - $query = !empty($request['query']) ? '?' . $request['query'] : ''; - $out = !empty($request['path']) ? $request['path'] . $query : ''; - } else { - $out = ''; - } - - return $out; - } - - /** - * @param $pwdField - * @param $emailField - * @param $rememberField - * @param $backUrl - * @param $method - * @param $error - * @param $errorCode - * @param array $params - * @return array - */ - protected function Auth( - $pwdField, - $emailField, - $rememberField, - $backUrl, - $method, - &$error, - &$errorCode, - $params = array() - ) { - $POST = array( - 'backUrl' => urlencode($backUrl) - ); - $userObj = &$this->userObj; - if ($_SERVER['REQUEST_METHOD'] == 'POST' && APIHelpers::getkey($_POST, 'method', '') == strtolower($method)) { - $POST = array_merge($POST, array( - 'password' => APIHelpers::getkey($_POST, $pwdField, ''), - 'email' => APIHelpers::getkey($_POST, $emailField, ''), - 'remember' => (bool)((int)APIHelpers::getkey($_POST, $rememberField, 0)) - )); - if (!empty($POST['email']) && is_scalar($POST['email']) && !$userObj->emailValidate($POST['email'], - false) - ) { - $userObj->edit($POST['email']); - - $this->modx->invokeEvent("OnBeforeWebLogin", array( - "username" => $POST['email'], - "userpassword" => $POST['password'], - "rememberme" => $POST['remember'], - 'userObj' => $userObj - )); - if ($userObj->getID() && !$userObj->checkBlock($userObj->getID())) { - $pluginFlag = $this->modx->invokeEvent("OnWebAuthentication", array( - "userid" => $userObj->getID(), - "username" => $userObj->get('username'), - "userpassword" => $POST['password'], - "savedpassword" => $userObj->get('password'), - "rememberme" => $POST['remember'], - )); - if ( - ($pluginFlag === true || $userObj->testAuth($userObj->getID(), $POST['password'], 0)) - && - $userObj->authUser($userObj->getID(), $POST['remember']) - ) { - $userObj->set('logincount', (int)$userObj->get('logincount') + 1); - $userObj->set('lastlogin', time()); - $userObj->set('failedlogincount', 0); - $userObj->save(false, false); - - $this->modx->invokeEvent("OnWebLogin", array( - "userid" => $userObj->getID(), - "username" => $userObj->get('username'), - "userpassword" => $POST['password'], - "rememberme" => $POST['remember'], - )); - $this->moveTo(array('url' => urldecode($POST['backUrl']))); - } else { - $userObj->set('failedlogincount', (int)$userObj->get('failedlogincount') + 1); - $userObj->save(false, false); - - $error = 'error.incorrect_password'; - } - } else { - $error = 'error.no_user'; - } - } else { - $error = 'error.incorrect_mail'; - $POST['email'] = ''; - } - } - if (!empty($error)) { - $errorCode = $error; - $error = APIHelpers::getkey($params, $error, ''); - $error = static::getLangMsg($error, $error); - } - - return $POST; - } - - /** - * Информация о пользователе - * [!DLUsers? &action=`UserInfo` &field=`fullname` &id=`2`!] - */ - public function UserInfo($params) - { - $out = ''; - $userID = APIHelpers::getkey($params, 'id', 0); - if (empty($userID)) { - $userID = $this->UserID('web'); - } - $field = APIHelpers::getkey($params, 'field', 'username'); - if ($userID > 0) { - $this->userObj->edit($userID); - switch (true) { - case ($field == $this->userObj->fieldPKName()): - $out = $this->userObj->getID(); - break; - case ($this->userObj->issetField($field)): - $out = $this->userObj->get($field); - break; - } - } - - return $out; - } - - /** - * ID пользователя - */ - public function UserID($type = 'web') - { - return $this->modx->getLoginUserID($type); - } - - /** - * Если не авторизован - то отправить на страницу - */ - public function isGuestGoHome($params) - { - if (!$this->UserID('web')) { - /** - * @see : http://modx.im/blog/triks/105.html - */ - $this->modx->invokeEvent('OnPageUnauthorized'); - $id = APIHelpers::getkey($params, 'id', $this->config['unauthorized_page']); - $this->moveTo(compact('id')); - } - - return; - } - - /** - * Если авторизован - то открыть личный кабинет - */ - public function isAuthGoHome($params) - { - $userID = $this->UserID('web'); - if ($userID > 0) { - $id = APIHelpers::getkey($params, 'homeID'); - if (empty($id)) { - $id = $this->modx->getConfig('login_home', $this->config['site_start']); - } - $this->moveTo(compact('id')); - } - - return; - } - - /** - * Редирект - */ - public function moveTo($params) - { - $id = (int)APIHelpers::getkey($params, 'id', 0); - $uri = APIHelpers::getkey($params, 'url', ''); - if ((empty($uri) && !empty($id)) || !is_string($uri)) { - $uri = $this->makeUrl($id); - } - $code = (int)APIHelpers::getkey($params, 'code', 0); - $addUrl = APIHelpers::getkey($params, 'addUrl', ''); - if (is_scalar($addUrl) && $addUrl != '') { - $uri .= "?" . $addUrl; - } - if (APIHelpers::getkey($params, 'validate', false)) { - if (isset($this->modx->snippetCache['getPageID'])) { - $out = $this->modx->runSnippet('getPageID', compact('uri')); - if (empty($out)) { - $uri = ''; - } - } else { - $uri = APIhelpers::sanitarTag($uri); - } - } else { - header("Location: " . $uri, true, ($code > 0 ? $code : 307)); - } - - return $uri; - } - - /** - * Создание ссылки на страницу - * - * @param int $id ID документа - * @return string - */ - protected function makeUrl($id = null) - { - $id = (int)$id; - if ($id <= 0) { - $id = $this->modx->documentObject['id']; - } - if ($this->url->containsKey($id)) { - $url = $this->url->get($id); - } else { - $url = $this->modx->makeUrl($id); - $this->url->set($id, $url); - } - - return $url; - } - - /** - * @param $name - * @return string - */ - protected function getTemplate($name) - { - $out = ''; - $file = dirname(dirname(__FILE__)) . '/tpl/' . $name . '.html'; - if (FS::getInstance()->checkFile($file)) { - $out = '@CODE: ' . file_get_contents($file); - } - - return $out; - } - - /** - * @param $lang - * @return bool - */ - protected static function loadLang($lang) - { - $file = dirname(dirname(__FILE__)) . '/lang/' . $lang . '.php'; - if (!FS::getInstance()->checkFile($file)) { - $file = false; - } - if (!empty($lang) && !isset(static::$langDic[$lang]) && !empty($file)) { - static::$langDic[$lang] = include_once($file); - if (is_array(static::$langDic[$lang])) { - static::$langDic[$lang] = APIHelpers::renameKeyArr(static::$langDic[$lang], $lang); - } else { - static::$langDic[$lang] = array(); - } - } - - return !(empty($lang) || empty(static::$langDic[$lang])); - } - - /** - * @param $key - * @param $default - * @return string - */ - protected static function getLangMsg($key, $default) - { - $out = $default; - $lng = static::$lang; - $dic = static::$langDic; - if (isset($dic[$lng], $dic[$lng][$lng . '.' . $key])) { - $out = $dic[$lng][$lng . '.' . $key]; - } - if (class_exists('evoBabel', false) && isset(self::$instance->modx->snippetCache['lang'])) { - $msg = self::$instance->modx->runSnippet('lang', array('a' => 'DLUsers.' . $key)); - if (!empty($msg)) { - $out = $msg; - } - } - - return $out; - } -} diff --git a/assets/snippets/DLUsers/tpl/authForm.html b/assets/snippets/DLUsers/tpl/authForm.html deleted file mode 100755 index bc4ac5e802..0000000000 --- a/assets/snippets/DLUsers/tpl/authForm.html +++ /dev/null @@ -1,9 +0,0 @@ -[+error:isnotempty=` -
[+error+]
`+] -
- - - Email:
- Password:
- -
\ No newline at end of file diff --git a/assets/snippets/DLUsers/tpl/tplProfile.html b/assets/snippets/DLUsers/tpl/tplProfile.html deleted file mode 100755 index 543bf5c2db..0000000000 --- a/assets/snippets/DLUsers/tpl/tplProfile.html +++ /dev/null @@ -1,3 +0,0 @@ -[+fullname+] -[+url.profile:isnotempty=`
Личный кабинет`+] -Выход \ No newline at end of file diff --git a/assets/snippets/DocLister/config/core/sitemap.json b/assets/snippets/DocLister/config/core/sitemap.json new file mode 100644 index 0000000000..0ab1abe337 --- /dev/null +++ b/assets/snippets/DocLister/config/core/sitemap.json @@ -0,0 +1,12 @@ +{ + "idType": "documents", + "ignoreEmpty": 1, + "addWhereList": "c.published = 1 AND c.deleted=0 AND c.searchable=1 AND c.type='document'", + "selectFields": "id,editedon,createdon,type", + "dateSource":"", + "tpl": "@CODE:\n\n\t[+e.url+]\n\t[+date+]\n\t[+update+]\n\t[+priority+]\n", + "tvList": "sitemap_changefreq,sitemap_priority", + "ownerTPL": "@CODE:[+dl.wrap+]", + "urlScheme": "full", + "e":"url" +} diff --git a/assets/snippets/DocLister/core/DocLister.abstract.php b/assets/snippets/DocLister/core/DocLister.abstract.php index 0376a40b46..ae939f9672 100644 --- a/assets/snippets/DocLister/core/DocLister.abstract.php +++ b/assets/snippets/DocLister/core/DocLister.abstract.php @@ -167,11 +167,13 @@ abstract class DocLister /** @var string Имя таблицы */ protected $table = ''; + /** @var string alias таблицы */ + protected $alias = ''; /** @var null|paginate_DL_Extender */ protected $extPaginate = null; - /** @var null|Helpers\Config */ + /** @var null|Helpers\Config */ public $config = null; /** @@ -237,8 +239,11 @@ public function __construct($modx, $cfg = array(), $startTime = null) break; } $this->config->setConfig($cfg); + $this->alias = empty($this->alias) ? $this->getCFGDef('tableAlias', + 'c') : $this->alias; + $this->table = $this->getTable(empty($this->table) ? $this->getCFGDef('table', + 'site_content') : $this->table, $this->alias); - $this->table = $this->getTable(empty($this->table) ? $this->getCFGDef('table', 'site_content') : $this->table); $this->idField = $this->getCFGDef('idField', 'id'); $this->parentField = $this->getCFGDef('parentField', 'parent'); @@ -581,7 +586,9 @@ public function render($tpl = '') $out = $this->_render($tpl); } - if ($out) $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out); + if ($out) { + $this->outData = DLTemplate::getInstance($this->modx)->parseDocumentSource($out); + } $this->debug->debugEnd('render'); return $this->outData; @@ -919,9 +926,13 @@ public function parseChunk($name, $data, $parseDocumentSource = false) 2, array('html', null) ); $DLTemplate = DLTemplate::getInstance($this->getMODX()); - if ($path = $this->getCFGDef('templatePath')) $DLTemplate->setTemplatePath($path); - if ($ext = $this->getCFGDef('templateExtension')) $DLTemplate->setTemplateExtension($ext); - $DLTemplate->setTwigTemplateVars(array('DocLister'=>$this)); + if ($path = $this->getCFGDef('templatePath')) { + $DLTemplate->setTemplatePath($path); + } + if ($ext = $this->getCFGDef('templateExtension')) { + $DLTemplate->setTemplateExtension($ext); + } + $DLTemplate->setTwigTemplateVars(array('DocLister' => $this)); $out = $DLTemplate->parseChunk($name, $data, $parseDocumentSource); $out = $this->parseLang($out); if (empty($out)) { @@ -1015,10 +1026,23 @@ protected function uniformPrepare(&$data, $i = 0) $this->renderTPL = $this->getCFGDef('tplId' . $i, $this->renderTPL); $this->renderTPL = $this->getCFGDef('tpl' . $iterationName, $this->renderTPL); + $iteration = $i; + + if ($this->extPaginate) { + $offset = $this->getCFGDef('reversePagination', + 0) && $this->extPaginate->currentPage() > 1 ? $this->extPaginate->totalPage() * $this->getCFGDef('display', + 0) - $this->extPaginate->totalDocs() : 0; + if ($this->getCFGDef('maxDocs', 0) && !$this->getCFGDef('reversePagination', + 0) && $this->extPaginate->currentPage() == $this->extPaginate->totalPage() + ) { + $iteration += $this->getCFGDef('display', 0); + } + $iteration += $this->getCFGDef('display', + 0) * ($this->extPaginate->currentPage() - 1) - $offset; + } $data[$this->getCFGDef("sysKey", - "dl") . '.full_iteration'] = ($this->extPaginate) ? ($i + $this->getCFGDef('display', - 0) * ($this->extPaginate->currentPage() - 1)) : $i; + "dl") . '.full_iteration'] = $iteration; if ($i == 1) { $this->renderTPL = $this->getCFGDef('tplFirst', $this->renderTPL); @@ -1088,13 +1112,13 @@ public function getJSON($data, $fields, $array = array()) $return['rows'] = array(); foreach ($out as $key => $item) { - $return['rows'][] = APIHelpers::getkey($item, $key, $item); + $return['rows'][] = $item; } $return['total'] = $this->getChildrenCount(); - }elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) { + } elseif ('simple' == $this->getCFGDef('JSONformat', 'old')) { $return = array(); foreach ($out as $key => $item) { - $return[] = APIHelpers::getkey($item, $key, $item); + $return[] = $item; } } else { $return = $out; @@ -1418,6 +1442,10 @@ protected function LimitSQL($limit = 0, $offset = 0) if ($limit == 0) { $limit = $this->getCFGDef('display', 0); } + $maxDocs = $this->getCFGDef('maxDocs', 0); + if ($maxDocs > 0 && $limit > $maxDocs) { + $limit = $maxDocs; + } if ($offset == 0) { $offset = $this->getCFGDef('offset', 0); } @@ -1506,22 +1534,39 @@ private function _treeBuild($data, $idName, $pidName) /** * Получение PrimaryKey основной таблицы. * По умолчанию это id. Переопределить можно в контроллере присвоив другое значение переменной idField - * + * @param bool $full если true то возвращается значение для подстановки в запрос * @return string PrimaryKey основной таблицы */ - public function getPK() + public function getPK($full = true) { - return isset($this->idField) ? $this->idField : 'id'; + $idField = isset($this->idField) ? $this->idField: 'id'; + if ($full) { + $idField = '`' . $idField . '`'; + if (!empty($this->alias)) { + $idField = '`' . $this->alias . '`.' . $idField; + } + } + + return $idField; } /** * Получение Parent key * По умолчанию это parent. Переопределить можно в контроллере присвоив другое значение переменной parentField + * @param bool $full если true то возвращается значение для подстановки в запрос * @return string Parent Key основной таблицы */ - public function getParentField() + public function getParentField($full = true) { - return isset($this->parentField) ? $this->parentField : ''; + $parentField = isset($this->parentField) ? $this->parentField : ''; + if ($full && !empty($parentField)) { + $parentField = '`' . $parentField . '`'; + if (!empty($this->alias)) { + $parentField = '`' . $this->alias . '`.' . $parentField; + } + } + + return $parentField; } /** @@ -1595,6 +1640,22 @@ public function filtersJoin() return APIHelpers::getkey($this->_filters, 'join', ''); } + /** + * @param string $join + * @return $this + */ + public function setFiltersJoin($join = '') { + if (!empty($join)) { + if (!empty($this->_filters['join'])) { + $this->_filters['join'] .= ' ' . $join; + } else { + $this->_filters['join'] = $join; + } + } + + return $this; + } + /** * Приведение типа поля * diff --git a/assets/snippets/DocLister/core/controller/onetable.php b/assets/snippets/DocLister/core/controller/onetable.php index e25e0b1900..c4f8f16cb3 100644 --- a/assets/snippets/DocLister/core/controller/onetable.php +++ b/assets/snippets/DocLister/core/controller/onetable.php @@ -20,7 +20,6 @@ class onetableDocLister extends DocLister * @var string */ protected $table = ''; - /** * @var string */ @@ -167,7 +166,6 @@ public function getJSON($data, $fields, $array = array()) * @var $extE e_DL_Extender */ $extE = $this->getExtender('e', true, true); - foreach ($data as $num => $row) { switch (true) { @@ -219,7 +217,7 @@ protected function getDocList() $where = array($where); } if ($sanitarInIDs != "''") { - $where[] = "`{$this->getPK()}` IN ({$sanitarInIDs})"; + $where[] = "{$this->getPK()} IN ({$sanitarInIDs})"; } if (!empty($where)) { @@ -230,10 +228,9 @@ protected function getDocList() $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); $rs = $this->dbQuery("SELECT {$fields} FROM {$this->table} {$where} {$group} {$this->SortOrderSQL($this->getPK())} {$limit}"); - $rows = $this->modx->db->makeArray($rs); - $out = array(); - foreach ($rows as $item) { - $out[$item[$this->getPK()]] = $item; + $pk = $this->getPK(false); + while ($item = $this->modx->db->getRow($rs)) { + $out[$item[$pk]] = $item; } } @@ -257,17 +254,17 @@ protected function getChildrenList() $tmpWhere = null; if ($sanitarInIDs != "''") { - $tmpWhere = "(`{$this->getParentField()}` IN (" . $sanitarInIDs . ")"; + $tmpWhere = "({$this->getParentField()} IN (" . $sanitarInIDs . ")"; switch ($this->getCFGDef('showParent', '0')) { case -1: $tmpWhere .= ")"; break; case 0: - $tmpWhere .= " AND `{$this->getPK()}` NOT IN(" . $sanitarInIDs . "))"; + $tmpWhere .= " AND {$this->getPK()} NOT IN(" . $sanitarInIDs . "))"; break; case 1: default: - $tmpWhere .= " OR `{$this->getPK()}` IN({$sanitarInIDs}))"; + $tmpWhere .= " OR {$this->getPK()} IN({$sanitarInIDs}))"; break; } } @@ -288,17 +285,20 @@ protected function getChildrenList() $where = ''; } $fields = $this->getCFGDef('selectFields', '*'); - $group = $this->getGroupSQL($this->getCFGDef('groupBy', "`{$this->getPK()}`")); + $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { - $sql = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " . + $rs = $this->dbQuery("SELECT {$fields} FROM " . $this->table . " " . $where . " " . $group . " " . $this->SortOrderSQL($this->getPK()) . " " . $this->LimitSQL($this->getCFGDef('queryLimit', 0)) ); - $rows = $this->modx->db->makeArray($sql); - foreach ($rows as $item) { - $out[$item[$this->getPK()]] = $item; + + $pk = $this->getPK(false); + + while ($item = $this->modx->db->getRow($rs)) { + $out[$item[$pk]] = $item; } + } return $out; @@ -324,25 +324,25 @@ public function getChildrenCount() case 'parents': switch ($this->getCFGDef('showParent', '0')) { case '-1': - $tmpWhere = "`{$this->getParentField()}` IN ({$sanitarInIDs})"; + $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs})"; break; case 0: - $tmpWhere = "`{$this->getParentField()}` IN ({$sanitarInIDs}) AND `{$this->getPK()}` NOT IN({$sanitarInIDs})"; + $tmpWhere = "{$this->getParentField()} IN ({$sanitarInIDs}) AND {$this->getPK()} NOT IN({$sanitarInIDs})"; break; case 1: default: - $tmpWhere = "(`{$this->getParentField()}` IN ({$sanitarInIDs}) OR `{$this->getPK()}` IN({$sanitarInIDs}))"; + $tmpWhere = "({$this->getParentField()} IN ({$sanitarInIDs}) OR {$this->getPK()} IN({$sanitarInIDs}))"; break; } if (($addDocs = $this->getCFGDef('documents', '')) != '') { $addDocs = $this->sanitarIn($this->cleanIDs($addDocs)); - $where[] = "((" . $tmpWhere . ") OR `{$this->getPK()}` IN({$addDocs}))"; + $where[] = "((" . $tmpWhere . ") OR {$this->getPK()} IN({$addDocs}))"; } else { $where[] = $tmpWhere; } break; case 'documents': - $where[] = "`{$this->getPK()}` IN({$sanitarInIDs})"; + $where[] = "{$this->getPK()} IN({$sanitarInIDs})"; break; } } @@ -353,9 +353,10 @@ public function getChildrenCount() $where = ''; } - $group = $this->getGroupSQL($this->getCFGDef('groupBy', "`{$this->getPK()}`")); - $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$this->table} {$where} {$group}) as `tmp`"); - + $group = $this->getGroupSQL($this->getCFGDef('groupBy', $this->getPK())); + $maxDocs = $this->getCFGDef('maxDocs', 0); + $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : ''; + $rs = ("SELECT count(*) FROM (SELECT count(*) FROM {$this->table} {$where} {$group} {$limit}) as `tmp`"); $out = $this->modx->db->getValue($rs); } @@ -368,20 +369,19 @@ public function getChildrenCount() */ public function getChildrenFolder($id) { + $out = array(); $sanitarInIDs = $this->sanitarIn($id); $tmp = $this->getCFGDef('addWhereFolder', ''); - $where = "`{$this->getParentField()}` IN ({$sanitarInIDs})"; + $where = "{$this->getParentField()} IN ({$sanitarInIDs})"; if (!empty($tmp)) { $where .= " AND " . $tmp; } - $rs = $this->dbQuery("SELECT `{$this->getPK()}` FROM {$this->table} WHERE {$where}"); - - $rows = $this->modx->db->makeArray($rs); - $out = array(); - foreach ($rows as $item) { - $out[] = $item[$this->getPK()]; + $rs = $this->dbQuery("SELECT {$this->getPK()} FROM {$this->table} WHERE {$where}"); + $pk = $this->getPK(false); + while ($item = $this->modx->db->getRow($rs)) { + $out[] = $item[$pk]; } return $out; diff --git a/assets/snippets/DocLister/core/controller/shopkeeper.php b/assets/snippets/DocLister/core/controller/shopkeeper.php index 5b1d984426..7719eca58b 100644 --- a/assets/snippets/DocLister/core/controller/shopkeeper.php +++ b/assets/snippets/DocLister/core/controller/shopkeeper.php @@ -203,11 +203,11 @@ public function getChildrenCount() if (trim($where) == 'WHERE') { $where = ''; } - $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); - $sort = $this->SortOrderSQL("c.createdon"); - list($from) = $this->injectSortByTV($from, $sort); + $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); + $maxDocs = $this->getCFGDef('maxDocs', 0); + $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : ''; - $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); + $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`"); $out = $this->modx->db->getValue($rs); } @@ -260,9 +260,7 @@ protected function getDocList() $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}"); - $rows = $this->modx->db->makeArray($rs); - - foreach ($rows as $item) { + while ($item = $this->modx->db->getRow($rs)) { $out[$item['id']] = $item; } } @@ -276,6 +274,7 @@ protected function getDocList() */ public function getChildrenFolder($id) { + $out = array(); $where = $this->getCFGDef('addWhereFolder', ''); $where = sqlHelper::trimLogicalOp($where); if ($where != '') { @@ -293,9 +292,7 @@ public function getChildrenFolder($id) $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where} AND c.id IN(SELECT DISTINCT s.parent FROM " . $this->getTable('catalog', 's') . ")"); - $rows = $this->modx->db->makeArray($rs); - $out = array(); - foreach ($rows as $item) { + while ($item = $this->modx->db->getRow($rs)) { $out[] = $item['id']; } @@ -365,14 +362,13 @@ protected function getChildrenList() $fields = $this->getCFGDef('selectFields', 'c.*'); $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { - $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . + $rs = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . $group . " " . $sort . " " . $this->LimitSQL($this->getCFGDef('queryLimit', 0)) ); - $rows = $this->modx->db->makeArray($sql); - foreach ($rows as $item) { + while ($item = $this->modx->db->getRow($rs)) { $out[$item['id']] = $item; } } diff --git a/assets/snippets/DocLister/core/controller/site_content.php b/assets/snippets/DocLister/core/controller/site_content.php index e90a288a22..48f4db9f88 100644 --- a/assets/snippets/DocLister/core/controller/site_content.php +++ b/assets/snippets/DocLister/core/controller/site_content.php @@ -49,6 +49,15 @@ public function getDocs($tvlist = '') $this->extTV->getAllTV_Name(); + /** + * @var $extJotCount jotcount_DL_Extender + */ + $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null; + + if ($extJotCount) { + $extJotCount->init($this); + } + if ($this->extPaginate = $this->getExtender('paginate')) { $this->extPaginate->init($this); } else { @@ -87,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; @@ -111,15 +118,6 @@ public function _render($tpl = '') */ $extPrepare = $this->getExtender('prepare'); - /** - * @var $extJotCount jotcount_DL_Extender - */ - $extJotCount = $this->getCFGdef('jotcount', 0) ? $this->getExtender('jotcount', true) : null; - - if ($extJotCount) { - $comments = $extJotCount->countComments(array_keys($this->_docs)); - } - $this->skippedDocs = 0; foreach ($this->_docs as $item) { $this->renderTPL = $tpl; @@ -129,10 +127,6 @@ public function _render($tpl = '') $item['summary'] = $extSummary ? $this->getSummary($item, $extSummary, 'introtext', 'content') : ''; - if ($extJotCount) { - $item['jotcount'] = APIHelpers::getkey($comments, $item['id'], 0); - } - $item = array_merge($item, $sysPlh); //inside the chunks available all placeholders set via $modx->toPlaceholders with prefix id, and with prefix sysKey $item['iteration'] = $i; //[+iteration+] - Number element. Starting from zero @@ -147,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'; @@ -245,16 +239,17 @@ public function getJSON($data, $fields, $array = array()) } } - if (array('1') == $fields || in_array(array('menutitle', 'pagetitle'), $fields)) { - $row['title'] = ($row['menutitle'] == '' ? $row['pagetitle'] : $row['menutitle']); + if (array('1') == $fields || in_array('title', $fields)) { + if (isset($row['pagetitle'])) { + $row['title'] = empty($row['menutitle']) ? $row['pagetitle'] : $row['menutitle']; + } } - if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array(array('content', 'type'), - $fields)) + if ((bool)$this->getCFGDef('makeUrl', 1) && (array('1') == $fields || in_array('url',$fields)) ) { - if ($row['type'] == 'reference') { + if (isset($row['type']) && $row['type'] == 'reference' && isset($row['content'])) { $row['url'] = is_numeric($row['content']) ? $this->modx->makeUrl($row['content'], '', '', $this->getCFGDef('urlScheme', '')) : $row['content']; - } else { + } elseif (isset($row['id'])) { $row['url'] = $this->modx->makeUrl($row['id'], '', '', $this->getCFGDef('urlScheme', '')); } } @@ -348,14 +343,13 @@ public function getChildrenCount() if (trim($where) == 'WHERE') { $where = ''; } - $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); - $sort = $this->SortOrderSQL("if(c.pub_date=0,c.createdon,c.pub_date)"); - list($from) = $this->injectSortByTV($from, $sort); + $group = $this->getGroupSQL($this->getCFGDef('groupBy', 'c.id')); $q_true = $q_true ? $q_true : $group != ''; - if ( $q_true ){ - $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group}) as `tmp`"); + $maxDocs = $this->getCFGDef('maxDocs', 0); + $limit = $maxDocs > 0 ? $this->LimitSQL($this->getCFGDef('maxDocs', 0)) : ''; + $rs = $this->dbQuery("SELECT count(*) FROM (SELECT count(*) FROM {$from} {$where} {$group} {$limit}) as `tmp`"); $out = $this->modx->db->getValue($rs); } else { @@ -412,11 +406,9 @@ protected function getDocList() $rs = $this->dbQuery("SELECT {$fields} FROM {$tbl_site_content} {$where} {$group} {$sort} {$limit}"); - $rows = $this->modx->db->makeArray($rs); - - foreach ($rows as $item) { + while ($item = $this->modx->db->getRow($rs)) { $out[$item['id']] = $item; - } + }; } return $out; @@ -428,6 +420,7 @@ protected function getDocList() */ public function getChildrenFolder($id) { + $out = array(); $where = $this->getCFGDef('addWhereFolder', ''); $where = sqlHelper::trimLogicalOp($where); if ($where != '') { @@ -444,9 +437,7 @@ public function getChildrenFolder($id) $rs = $this->dbQuery("SELECT id FROM {$tbl_site_content} {$where}"); - $rows = $this->modx->db->makeArray($rs); - $out = array(); - foreach ($rows as $item) { + while ($item = $this->modx->db->getRow($rs)) { $out[] = $item['id']; } @@ -531,15 +522,13 @@ protected function getChildrenList() $group = $this->getGroupSQL($this->getCFGDef('groupBy', '')); if ($sanitarInIDs != "''" || $this->getCFGDef('ignoreEmpty', '0')) { - $sql = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . + $rs = $this->dbQuery("SELECT {$fields} FROM " . $from . " " . $where . " " . $group . " " . $sort . " " . $this->LimitSQL($this->getCFGDef('queryLimit', 0)) ); - $rows = $this->modx->db->makeArray($sql); - - foreach ($rows as $item) { + while ($item = $this->modx->db->getRow($rs)) { $out[$item['id']] = $item; } } diff --git a/assets/snippets/DocLister/core/controller/site_content_menu.php b/assets/snippets/DocLister/core/controller/site_content_menu.php index 507d4c5ef2..ee2cd1d4ba 100644 --- a/assets/snippets/DocLister/core/controller/site_content_menu.php +++ b/assets/snippets/DocLister/core/controller/site_content_menu.php @@ -17,6 +17,7 @@ class site_content_menuDocLister extends site_contentDocLister protected $IDs = array(); protected $activeBranch = array(); protected $countChildren = array(); + protected $display = array(); /** * Очистка массива $IDs по которому потом будет производиться выборка документов @@ -40,9 +41,14 @@ public function setIDs($IDs) public function getDocs($tvlist = '') { $maxDepth = $this->getCFGDef('maxDepth', 10); + $this->extTV->getAllTV_Name(); //TODO кэширование if ($this->getCFGDef('hideSubMenus', 0) && empty($this->getCFGDef('openIds'))) { - $maxDepth = $this->setActiveBranch($this->getHereId()); + $maxDepth = min($maxDepth, $this->setActiveBranch($this->getHereId())); + if (empty(array_intersect($this->IDs, $this->activeBranch))) { + $maxDepth = 1; + $this->config->setConfig(array('hideSubMenus' => 0)); + }; } else { $this->setActiveBranch($this->getHereId()); } @@ -62,23 +68,46 @@ public function getDocs($tvlist = '') if ($this->getCFGDef('showParent', 0) && in_array(0, $this->IDs)) { $this->config->setConfig(array('showParent' => 0)); } - if ($this->getCFGDef('showParent', 0)) { - $orderBy = $this->getCFGDef('orderBy'); - $docs = $this->getDocList(); - $this->config->setConfig(array('orderBy' => $orderBy)); - $this->levels[$currentLevel++] = $docs; - $this->IDs = $ids = array_keys($docs); - $this->config->setConfig(array('showParent' => 0)); - } + $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); while ($currentLevel <= $maxDepth) { $orderBy = $this->getCFGDef('orderBy'); - $docs = $this->getChildrenList(); + if ($this->getCFGDef('showParent', 0) && $currentLevel == 1) { + $docs = $this->getDocList(); + $this->config->setConfig(array('showParent' => 0)); + } else { + $docs = $this->getChildrenList(); + } + if ($currentLevel == 1 && $joinMenus) { + $tmp = array(); + $display = 0; + $iteration = 1; + foreach ($docs as $id => $item) { + $tmp[$item['parent']][] = $item['id']; + $display++; + } + foreach ($tmp as $id => $item) { + foreach ($item as $_id) { + $docs[$_id]['_display'] = $display; + $docs[$_id]['iteration'] = $iteration++; + } + } + unset($tmp); + } else { + foreach ($docs as $id => &$item) { + $parent = $item['parent']; + if (!isset($this->display[$parent])) { + $this->display[$parent] = 1; + } + $item['iteration'] = $this->display[$parent]++; + } + } $this->config->setConfig(array('orderBy' => $orderBy)); if (empty($docs)) { break; } $this->levels[$currentLevel++] = $docs; $this->IDs = array_keys($docs); + $this->AddTable = array(); } if ($tvlist == '') { @@ -86,7 +115,6 @@ public function getDocs($tvlist = '') } if ($tvlist != '') { - $this->extTV->getAllTV_Name(); $ids = array(); foreach ($this->levels as $level => $docs) { $ids = array_merge($ids, array_keys($docs)); @@ -205,7 +233,6 @@ public function _render($tpl = '') $docs = $this->levels; /** @var prepare_DL_Extender_ $extPrepare */ $extPrepare = $this->getExtender('prepare'); - while ($currentLevel > 0) { foreach ($docs[$currentLevel] as $id => &$data) { if ($out = $this->prepareData($data)) { @@ -213,14 +240,9 @@ public function _render($tpl = '') $data = $out; } }; - if (!isset($data['maxLevel'])) { $data['maxLevel'] = 1; - $docs[$currentLevel - 1][$data[$this->parentField]]['maxLevel'] = 0; - } - - if (isset($data['here']) || isset($data['active'])) { - $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1; + $docs[$currentLevel - 1][$data['parent']]['maxLevel'] = 0; } if ($extPrepare) { @@ -238,18 +260,19 @@ public function _render($tpl = '') $data['wrap'] = $this->parseOuter($data); } $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], + $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'], $this->activeBranch)); if ($hideSubMenus) { - $docs[$currentLevel - 1][$data[$this->parentField]]['wrap'][] = $data; + $docs[$currentLevel - 1][$data['parent']]['wrap'][] = $data; } } unset($docs[$currentLevel]); $currentLevel--; } unset($data); + $out = ''; - $joinMenus = $this->getCFGDef('joinMenus',0) && !$this->getCFGDef('showParents',0); + $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); foreach ($docs[0] as $id => $data) { if (isset($data['wrap'])) { if ($joinMenus) { @@ -260,7 +283,9 @@ public function _render($tpl = '') } } } - if ($joinMenus) $out = $this->parseOuter(array('wrap'=>$out)); + if ($joinMenus) { + $out = $this->parseOuter(array('wrap' => $out)); + } return $out; } @@ -283,18 +308,28 @@ public function prepareData($data) if ($id == $this->getHereId()) { $data['here'] = 1; } - if (in_array($id,$this->activeBranch)) { + if (!isset($data['here']) && in_array($id, $this->activeBranch)) { $data['active'] = 1; } if ($this->getCFGDef('hideSubMenus') && isset($data['isfolder']) && $data['isfolder']) { $data['state'] = in_array($data['id'], $this->activeBranch) ? 'open' : 'closed'; } + if (!isset($data['_display'])) { + $data['_display'] = $this->display[$data['parent']] - 1; + } + if ($data['iteration'] == 1) { + $data['first'] = 1; + } + if ($data['iteration'] == $data['_display']) { + $data['last'] = 1; + } + $titleField = $this->getCFGDef('titleField', 'title'); $data[$titleField] = isset($data['menutitle']) && !empty($data['menutitle']) ? $data['menutitle'] : $data['pagetitle']; $data['level'] = $this->currentLevel; $data['url'] = $this->makeUrl($data); - if ($this->getCFGDef('countChildren', 1)) { + if ($this->getCFGDef('countChildren', 0)) { $data['count'] = isset($this->countChildren[$data['id']]) ? $this->countChildren[$data['id']] : 0; } @@ -340,15 +375,7 @@ public function parseOuter($data = array()) public function parseRow($data = array()) { $out = ''; - $maxIteration = count($data) - 1; foreach ($data as $iteration => $item) { - $item['iteration'] = $iteration + 1; - if ($iteration == 0) { - $item['first'] = 1; - } - if ($iteration == $maxIteration) { - $item['last'] = 1; - } $tpl = isset($item['_renderRowTpl']) ? $item['_renderRowTpl'] : $this->getRowTemplate($item); $item = array_merge($item, $this->getClasses($item)); $out .= $this->parseChunk($tpl, $item); @@ -504,7 +531,7 @@ public function getJSON($data, $fields, $array = array()) }; if (isset($data['here']) || isset($data['active'])) { - $docs[$currentLevel - 1][$data[$this->parentField]]['active'] = 1; + $docs[$currentLevel - 1][$data['parent']]['active'] = 1; } if ($extPrepare) { @@ -518,18 +545,27 @@ public function getJSON($data, $fields, $array = array()) } $hideSubMenus = $this->getCFGDef('hideSubMenus', 0); - $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data[$this->parentField], + $hideSubMenus = !$hideSubMenus || ($hideSubMenus && in_array((int)$data['parent'], $this->activeBranch)); if ($hideSubMenus) { - $docs[$currentLevel - 1][$data[$this->parentField]]['children'][] = $data; + $docs[$currentLevel - 1][$data['parent']]['children'][] = $data; } } unset($docs[$currentLevel]); $currentLevel--; } unset($data); - - $out = $docs[0][0]['children']; + $out = array(); + $joinMenus = $this->getCFGDef('joinMenus', 0) && !$this->getCFGDef('showParents', 0); + foreach ($docs[0] as $id => $data) { + if (isset($data['children'])) { + if ($joinMenus) { + $out = array_merge($out, $data['children']); + } else { + $out[] = $data['children']; + } + } + } unset($docs); return json_encode($out, JSON_UNESCAPED_UNICODE); diff --git a/assets/snippets/DocLister/core/extender/jotcount.extender.inc b/assets/snippets/DocLister/core/extender/jotcount.extender.inc old mode 100755 new mode 100644 index 7fc620d24c..cc2a3a6b95 --- a/assets/snippets/DocLister/core/extender/jotcount.extender.inc +++ b/assets/snippets/DocLister/core/extender/jotcount.extender.inc @@ -17,26 +17,13 @@ class jotcount_DL_Extender extends extDocLister */ protected function run() { - return true; - } - - /** - * @param $docs - * @return array - */ - public function countComments($docs) - { - $comments = array(); - if (count($docs)) { - $from = $this->DocLister->getTable('jot_content'); - $rs = $this->DocLister->dbQuery("SELECT uparent, COUNT(*) as total FROM {$from} WHERE uparent IN (" . implode(',', - $docs) . ") AND published=1 AND deleted=0 GROUP BY uparent"); - $counts = $this->modx->db->makeArray($rs); - foreach ($counts as $v) { - $comments[$v['uparent']] = $v['total']; - } - } + $join = "LEFT JOIN (SELECT `uparent`, COUNT(`id`) AS `jotcount` FROM {$this->DocLister->getTable('jot_content')} WHERE `published`=1 AND `deleted`=0 GROUP BY `uparent`) `jc` ON `jc`.`uparent` = {$this->DocLister->getPK()}"; + $this->DocLister->setFiltersJoin($join); + $fields = $this->DocLister->getCFGDef('selectFields', 'c.*'); + $this->DocLister->config->setConfig(array( + "selectFields" => $fields . ",IFNULL(`jc`.`jotcount`,0) AS `jotcount`" + )); - return $comments; + return true; } -} \ No newline at end of file +} diff --git a/assets/snippets/DocLister/core/extender/paginate.extender.inc b/assets/snippets/DocLister/core/extender/paginate.extender.inc index 17dde0e9ae..dda09f088b 100644 --- a/assets/snippets/DocLister/core/extender/paginate.extender.inc +++ b/assets/snippets/DocLister/core/extender/paginate.extender.inc @@ -12,6 +12,7 @@ if (!defined('MODX_BASE_PATH')) { * @see http://mis-algoritmos.com/2007/05/27/digg-style-pagination-class */ include_once(MODX_BASE_PATH . "assets/snippets/DocLister/lib/DLpaginate.class.php"); +include_once(MODX_BASE_PATH . "assets/snippets/DocLister/lib/DLpaginateReversed.class.php"); /** * Class paginate_DL_Extender @@ -22,7 +23,8 @@ class paginate_DL_Extender extends extDocLister * @var bool */ protected $lang = true; - + protected $reverse = false; + protected $count = 0; /** * @var array */ @@ -38,40 +40,77 @@ class paginate_DL_Extender extends extDocLister if (($paginate = $this->DocLister->getCFGDef('paginate', '')) == '') { $this->DocLister->config->setConfig(array('start' => 0)); } - $pages = 0; + $this->reverse = $this->DocLister->getCFGDef('reversePagination', 0); + $pages = $this->getListPages($paginate, 'total'); $display = $this->DocLister->getCFGDef('display', 0); switch ($paginate) { case 'offset': $requestName = $this->getRequestName('start'); $start = (isset($_GET[$requestName]) && intval($_GET[$requestName]) > 1) ? intval($_GET[$requestName]) : 0; $this->_pages['current'] = ceil($start / $display) + 1; + if ($this->reverse && $this->_pages['current'] > 1) { + $offset = $pages * $display - $this->count; + $start -= $offset; + } $this->DocLister->config->setConfig(array('start' => $start)); break; case 'pages': default: $paginate = 'pages'; $requestName = $this->getRequestName('page'); - if ( + if ( isset($_GET[$requestName]) - && intval($_GET[$requestName]) <= 1 - && !$this->DocLister->getCFGDef('noRedirect',0) + && !$this->DocLister->getCFGDef('noRedirect', 0) ) { - $this->modx->sendRedirect($this->getUrl()); + if ((!$this->reverse && (intval($_GET[$requestName]) <= 1 || intval($_GET[$requestName]) > $pages)) || ($this->reverse && (intval($_GET[$requestName]) >= $pages || intval($_GET[$requestName]) < 1))) { + $this->modx->sendRedirect($this->getUrl()); + } } - $start = (isset($_GET[$requestName]) && intval($_GET[$requestName]) > 1) ? (intval($_GET[$requestName]) - 1) : 0; - $this->_pages['current'] = $start + 1; - $this->DocLister->config->setConfig(array('start' => $start * $display)); + if ($this->reverse) { + $start = (isset($_GET[$requestName]) && intval($_GET[$requestName]) <= $pages) ? ($pages - intval($_GET[$requestName])) : 0; + $this->_pages['current'] = $start + 1; + $offset = $pages * $display - $this->count; + if ($this->_pages['current'] > 1) { + $this->DocLister->config->setConfig(array('start' => $start * $display - $offset)); + } else { + $display = $display - $offset; + $this->DocLister->config->setConfig(array('display' => $display)); + } + } else { + $start = (isset($_GET[$requestName]) && intval($_GET[$requestName]) > 1) ? (intval($_GET[$requestName]) - 1) : 0; + $this->_pages['current'] = $start + 1; + $this->DocLister->config->setConfig(array('start' => $start * $display)); + } + + break; } - $pages = $this->getListPages($paginate, 'total'); - $this->DocLister->toPlaceholders($this->currentPage(), 1, "current"); + + $this->DocLister->toPlaceholders($pages + 1 - $this->currentPage(), 1, "current"); $this->DocLister->toPlaceholders($this->renderPages($paginate), 1, "pages"); $this->DocLister->toPlaceholders(($this->currentPage() == 1 ? 1 : 0), 1, "isstart"); //[+isstart+] – is start page $this->DocLister->toPlaceholders(($this->currentPage() == $pages ? 1 : 0), 1, "isstop"); //[+isstop+] – is end page $this->DocLister->toPlaceholders($pages, 1, "totalPages"); // [+totalPages+] - total page. + + $limit = $this->DocLister->getCFGDef('maxDocs', 0); + if ($limit > 0 && !$this->reverse) { + switch ($paginate) { + case 'offset': + $offset = $start; + break; + case 'pages': + default: + $offset = $start * $display; + break; + } + if (($offset + $display) > $limit) { + $this->DocLister->config->setConfig(array('display' => $limit - $offset)); + } + } + return $pages; } @@ -90,7 +129,7 @@ class paginate_DL_Extender extends extDocLister $this->_pages['total'] = 1; } else { $addTables = $this->DocLister->AddTable; - $tmp = $this->DocLister->getChildrenCount(); + $tmp = $this->count = $this->DocLister->getChildrenCount(); $this->DocLister->AddTable = $addTables; $display = $this->DocLister->getCFGDef('display', 0); @@ -129,14 +168,22 @@ class paginate_DL_Extender extends extDocLister return (int)APIHelpers::getkey($this->_pages, 'total', 1); } + /** + * Общее число документов + * @return int + */ + public function totalDocs() + { + return $this->count; + } + /** * @param string $mode * @return string */ private function renderPages($mode = '') { - $out = ''; - $p = new DLpaginate; + $p = $this->reverse ? new DLpaginateReversed : new DLpaginate; $p->nextT = $this->DocLister->getChunkByParam('TplNextP', '@CODE:[%paginate.next%] >'); $p->prevT = $this->DocLister->getChunkByParam('TplPrevP', '@CODE:< [%paginate.prev%]'); $p->firstT = $this->DocLister->getChunkByParam('TplFirstP'); @@ -166,8 +213,13 @@ class paginate_DL_Extender extends extDocLister switch (true) { case ($mode == 'offset' && $this->totalPage() > 1): + $display = $this->DocLister->getCFGDef('display', 0); + $offset = $this->reverse ? $this->totalPage() * $display - $this->count : 0; + if ($this->currentPage() == 1) { + $this->DocLister->config->setConfig(array('display'=>$display - $offset)); + } $p->setMode('offset', array( - 'display' => $this->DocLister->getCFGDef('display', 0) + 'display' => $display ))->parameterName($this->getRequestName('start')); break; case ($mode == 'pages' && $this->totalPage() > 1): @@ -196,21 +248,28 @@ class paginate_DL_Extender extends extDocLister case 'pages': default: $requestName = 'page'; - $call = $this->DocLister->getCFGDef('makePaginateUrl', ''); - if((is_object($call) && ($call instanceof Closure)) || is_callable($call)){ + $call = $this->DocLister->getCFGDef('makePaginateUrl', ''); + if ((is_object($call) && ($call instanceof Closure)) || is_callable($call)) { $url = call_user_func($call, compact('url', 'params'), $this->modx, $this->DocLister, $this); - }else{ + } else { $url = $this->buildUrl($url, $requestName, $params); } break; } } - + return $url; } - public function buildUrl($url, $requestName, $params){ + /** + * @param $url + * @param $requestName + * @param $params + * @return array|string + */ + public function buildUrl($url, $requestName, $params) + { if ($requestName != '' && is_array($params)) { $q = http_build_query(array_merge($params, array($this->getRequestName($requestName) => null))); $url = explode("?", $url, 2); @@ -219,9 +278,10 @@ class paginate_DL_Extender extends extDocLister $url .= "?" . $q; } } + return $url; } - + /** * Имя REQUEST переменной в пагинаторе * diff --git a/assets/snippets/DocLister/lib/DLTemplate.class.php b/assets/snippets/DocLister/lib/DLTemplate.class.php old mode 100755 new mode 100644 diff --git a/assets/snippets/DocLister/lib/DLpaginateReversed.class.php b/assets/snippets/DocLister/lib/DLpaginateReversed.class.php new file mode 100644 index 0000000000..7c78d1e1ca --- /dev/null +++ b/assets/snippets/DocLister/lib/DLpaginateReversed.class.php @@ -0,0 +1,59 @@ +mode) { + case 'offset': + $display = isset($this->modeConfig['display']) ? $this->modeConfig['display'] : 0; + $out = $display * ($this->total_pages - $page); + break; + case 'back': + case 'pages': + default: + $out = $page; + break; + } + + return $out; + } + + /** + * @param $tpl + * @param $num + * @return mixed + */ + protected function renderItemTPL($tpl, $num) + { + $_num = $this->total_pages + 1 - $num; + return str_replace(array('[+num+]', '[+link+]'), array($_num, $this->get_pagenum_link($_num)), $tpl); + } + + /** + * @param $id + * @return mixed|string + */ + public function get_pagenum_link($id) + { + $flag = (strpos($this->target, '?') === false); + $value = $this->getPageQuery($id); + if ($flag && !empty($this->urlF)) { + $out = str_replace($this->urlF, $value, $this->target); + } else { + $out = $this->target; + if ($id > 0 && $id < $this->total_pages) { + $out .= ($flag ? "?" : "&") . $this->parameterName . "=" . $value; + } + } + + return $out; + } +} diff --git a/assets/snippets/DocLister/snippet.DLSitemap.php b/assets/snippets/DocLister/snippet.DLSitemap.php new file mode 100644 index 0000000000..1962dc82bb --- /dev/null +++ b/assets/snippets/DocLister/snippet.DLSitemap.php @@ -0,0 +1,49 @@ +event->params, 'BeforePrepare', ''); +$prepare[] = 'DLSitemap::prepare'; +$prepare[] = \APIhelpers::getkey($modx->event->params, 'AfterPrepare', ''); +$params['prepare'] = trim(implode(",", $prepare), ','); +if(!class_exists("DLSitemap")){ + class DLSitemap{ + public static function prepare(array $data = array(), DocumentParser $modx, $_DocLister) + { + $data['date'] = !empty($data['editedon']) ? $data['editedon'] : $data['createdon']; + $datediff = floor((time() - $data['date']) / 86400); + if ($datediff <= 1) { + $data['priority'] = '1.0'; + $data['update'] = 'daily'; + } elseif (($datediff > 1) && ($datediff <= 7)) { + $data['priority'] = '0.75'; + $data['update'] = 'weekly'; + } elseif (($datediff > 7) && ($datediff <= 30)) { + $data['priority'] = '0.50'; + $data['update'] = 'weekly'; + } else { + $data['priority'] = '0.25'; + $data['update'] = 'monthly'; + } + $data['date'] = date('c', $data['date']); + $priorityField = $_DocLister->getCFGDef('priority', 'tv.sitemap_priority'); + $changefreqField = $_DocLister->getCFGDef('changefreq', 'tv.sitemap_changefreq'); + if (!empty($data[$priorityField])) { + $data['priority'] = $data[$priorityField]; + } + if (!empty($data[$changefreqField])) { + $data['update'] = $data[$changefreqField]; + } + + return $data; + } + } +} + +$out = $modx->runSnippet('DocLister',$params); +if (!empty($out)) { + $out = "config['modx_charset']}\"?>\n{$out}\n"; +} + +return $out; diff --git a/assets/snippets/FormLister/core/FormLister.abstract.php b/assets/snippets/FormLister/core/FormLister.abstract.php index 96d7c872ff..7479555045 100644 --- a/assets/snippets/FormLister/core/FormLister.abstract.php +++ b/assets/snippets/FormLister/core/FormLister.abstract.php @@ -118,7 +118,8 @@ public function __construct(\DocumentParser $modx, $cfg = array()) )); } $this->lexicon = new Lexicon($modx, array( - 'langDir' => 'assets/snippets/FormLister/core/lang/' + 'langDir' => 'assets/snippets/FormLister/core/lang/', + 'lang' => $this->getCFGDef('lang', $this->modx->config['manager_language']) )); $this->formid = $this->getCFGDef('formid'); switch (strtolower($this->getCFGDef('formMethod', 'post'))) { @@ -146,14 +147,15 @@ public function initForm() $lexicon = $this->getCFGDef('lexicon'); if ($lexicon) { $_lexicon = $this->config->loadArray($lexicon); - if (is_array($_lexicon)) { - $lang = $this->lexicon->fromArray($_lexicon); + if (isset($_lexicon[0])) { + $lang = $this->lexicon->loadLang($_lexicon); } else { - $lang = $this->lexicon->loadLang($lexicon, $this->getCFGDef('lang'), - $this->getCFGDef('langDir')); + $lang = $this->lexicon->fromArray($_lexicon); } - if ($lang) { + if (!empty($lang)) { $this->log('Custom lexicon loaded', array('lexicon' => $lang)); + } else { + $this->log('Failed to load lexicon', array('lexicon' => $_lexicon)); } } $this->allowedFields = array_merge($this->allowedFields, @@ -290,7 +292,7 @@ public function setExternalFields($sources = 'array', $arrayParam = 'defaults') $classname = $_source[0]; if (!is_null($model = $this->loadModel($classname)) && isset($_source[1])) { /** @var \autoTable $data */ - if ($data = $model->edit($_source[1])->getID()) { + if ($model->edit($_source[1])->getID()) { $fields = $model->toArray(); if (isset($_source[2])) { $prefix = $_source[2]; @@ -478,7 +480,7 @@ public function setFields($fields = array(), $prefix = '') public function validateForm() { $validator = $this->getCFGDef('validator', '\FormLister\Validator'); - $validator = $this->loadModel($validator , '', array()); + $validator = $this->loadModel($validator, '', array()); $fields = $this->getFormData('fields'); $rules = $this->getValidationRules(); $this->rules = array_merge($this->rules, $rules); @@ -738,10 +740,14 @@ public function errorsToPlaceholders() foreach ($this->getFormData('errors') as $field => $error) { foreach ($error as $type => $message) { $classType = ($type == 'required') ? 'required' : 'error'; - $plh[$field . '.error'] = $this->parseChunk($this->getCFGDef('errorTpl', - '@CODE:
[+message+]
'), array('message' => $message)); + if (!empty($message)) { + $plh[$field . '.error'] = $this->parseChunk($this->getCFGDef('errorTpl', + '@CODE:
[+message+]
'), array('message' => $message)); + } $plh[$field . '.' . $classType . 'Class'] = $this->getCFGDef($field . '.' . $classType . 'Class', $this->getCFGDef($classType . 'Class', $classType)); + $plh[$field . '.class'] = "class=\"{$plh[$field . '.' . $classType . 'Class']}\""; + $plh[$field . '.classname'] = "{$plh[$field . '.' . $classType . 'Class']}"; } } @@ -859,7 +865,7 @@ public function renderMessagesGroup($messages, $wrapper, $splitter) public function parseChunk($name, $data, $parseDocumentSource = false) { $parseDocumentSource = $parseDocumentSource || $this->getCFGDef('parseDocumentSource', 0); - $rewriteUrls = $this->getCFGDef('rewriteUrls', 0); + $rewriteUrls = $this->getCFGDef('rewriteUrls', 1); $DLTemplate = \DLTemplate::getInstance($this->modx) ->setTemplatePath($this->getCFGDef('templatePath')) ->setTemplateExtension($this->getCFGDef('templateExtension')) @@ -877,7 +883,7 @@ public function parseChunk($name, $data, $parseDocumentSource = false) if (!$parseDocumentSource && $rewriteUrls) { $out = $this->modx->rewriteUrls($out); } - if ($this->getCFGDef('removeEmptyPlaceholders', 0)) { + if ($this->getCFGDef('removeEmptyPlaceholders', 1)) { preg_match_all('~\[(\+|\*|\(|%)([^:\+\[\]]+)([^\[\]]*?)(\1|\)|%)\]~s', $out, $matches); if ($matches[0]) { $out = str_replace($matches[0], '', $out); @@ -897,7 +903,9 @@ public function initCaptcha() $className = ucfirst($captcha . 'Wrapper'); $cfg = $this->config->loadArray($this->getCFGDef('captchaParams', array())); $cfg['id'] = $this->getFormId(); - $captcha = $this->loadModel($className, MODX_BASE_PATH . "assets/snippets/FormLister/lib/captcha/{$captcha}/wrapper.php",array($this->modx, $cfg)); + $captcha = $this->loadModel($className, + MODX_BASE_PATH . "assets/snippets/FormLister/lib/captcha/{$captcha}/wrapper.php", + array($this->modx, $cfg)); if (!is_null($captcha) && $captcha instanceof CaptchaInterface) { $captcha->init(); @@ -1023,7 +1031,8 @@ public function redirect($param = 'redirectTo', $_query = array()) * @param $url * @param $header */ - public function sendRedirect($url, $header = 'HTTP/1.1 307 Temporary Redirect') { + public function sendRedirect($url, $header = 'HTTP/1.1 307 Temporary Redirect') + { if (!$this->getCFGDef('api', 0)) { $header = $header ? $header : 'HTTP/1.1 307 Temporary Redirect'; $this->modx->sendRedirect($url, 0, 'REDIRECT_HEADER', $header); @@ -1176,8 +1185,7 @@ protected function removeGpc(&$target, $count = 0) if (is_array($value)) { $count++; if (10 < $count) { - echo 'GPC Array nested too deep!'; - exit; + break; } $this->removeGpc($value, $count); $count--; diff --git a/assets/snippets/FormLister/core/controller/DeleteUser.php b/assets/snippets/FormLister/core/controller/DeleteUser.php index 72224c4221..8eb26e2e57 100644 --- a/assets/snippets/FormLister/core/controller/DeleteUser.php +++ b/assets/snippets/FormLister/core/controller/DeleteUser.php @@ -52,13 +52,13 @@ public function __construct(\DocumentParser $modx, array $cfg = array()) */ public function render() { - if (!$uid = $this->modx->getLoginUserID('web')) { + if (!$this->modx->getLoginUserID('web')) { $this->redirect('exitTo'); $this->renderTpl = $this->getCFGDef('skipTpl', $this->lexicon->getMsg('deleteUser.default_skipTpl')); $this->setValid(false); }; - return parent::render(); // TODO: Change the autogenerated stub + return parent::render(); } diff --git a/assets/snippets/FormLister/core/controller/Form.php b/assets/snippets/FormLister/core/controller/Form.php index d1ca1b3db2..1ba3f450f5 100644 --- a/assets/snippets/FormLister/core/controller/Form.php +++ b/assets/snippets/FormLister/core/controller/Form.php @@ -188,15 +188,16 @@ public function renderReport($tplParam = 'reportTpl') /** * Получает тему письма из шаблона или строки + * @param string $param * @return mixed|null|string */ - public function renderSubject() + public function renderSubject($param = 'subject') { - $subject = $this->getCFGDef('subjectTpl'); + $subject = $this->getCFGDef($param . 'Tpl'); if (!empty($subject)) { $subject = $this->parseChunk($subject, $this->prerenderForm(true)); } else { - $subject = $this->getCFGDef('subject'); + $subject = $this->getCFGDef($param); } return $subject; @@ -310,7 +311,7 @@ public function sendAutosender() if (empty($to)) { $out = true; } else { - $mailer = new Mailer($this->modx, $this->getMailSendConfig($to, 'autosenderFromName')); + $mailer = new Mailer($this->modx, $this->getMailSendConfig($to, 'autosenderFromName', 'autoSubject')); $report = $this->renderReport('automessageTpl'); $out = $mailer->send($report); $this->log('Mail autosender report', array( @@ -335,7 +336,7 @@ public function sendCCSender() $out = true; } else { if ($this->getCFGDef('ccSender', 0)) { - $mailer = new Mailer($this->modx, $this->getMailSendConfig($to, 'ccSenderFromName')); + $mailer = new Mailer($this->modx, $this->getMailSendConfig($to, 'ccSenderFromName', 'ccSubject')); $report = $this->renderReport('ccSenderTpl'); $out = $mailer->send($report); $this->log('Mail CC report', @@ -376,7 +377,7 @@ public function process() $this->sendAutosender(); $this->setSubmitProtection()->postProcess(); } else { - $this->addMessage($this->lexicon->getMsg('form.formFailed')); + $this->addMessage($this->lexicon->getMsg('form.form_failed')); } } @@ -397,14 +398,17 @@ public function postProcess() /** * @param string $to * @param string $fromParam + * @param string $subjectParam * @return array */ - public function getMailSendConfig($to, $fromParam) + public function getMailSendConfig($to, $fromParam, $subjectParam = 'subject') { + $subject = empty($this->getCFGDef($subjectParam)) ? $this->renderSubject() : $this->renderSubject($subjectParam); + return array_merge( $this->mailConfig, array( - 'subject' => $this->renderSubject(), + 'subject' => $subject, 'to' => $to, 'fromName' => $this->getCFGDef($fromParam, $this->modx->config['site_name']) ) diff --git a/assets/snippets/FormLister/core/controller/Profile.php b/assets/snippets/FormLister/core/controller/Profile.php index 395d9e17f2..be226e4cd6 100644 --- a/assets/snippets/FormLister/core/controller/Profile.php +++ b/assets/snippets/FormLister/core/controller/Profile.php @@ -66,7 +66,6 @@ public function getValidationRules($param = 'rules') { $rules = parent::getValidationRules($param); $password = $this->getField('password'); - var_dump($rules); if (empty($password)) { $this->forbiddenFields[] = 'password'; if (isset($rules['password'])) { diff --git a/assets/snippets/FormLister/docs/history.md b/assets/snippets/FormLister/docs/history.md index c2b10f7a60..a11937a365 100644 --- a/assets/snippets/FormLister/docs/history.md +++ b/assets/snippets/FormLister/docs/history.md @@ -1,4 +1,25 @@ ## History +### 1.7.8 +* [Refactor] Переименованы файлы документации. +* [Refactor] Параметр removeEmptyPlaceholders по умолчанию включен (Core). +* [Refactor] Параметр rewriteUrls по умолчанию включен (Core). +* [Refactor] Плейсхолдеры ошибок [+field.error+] не устанавливаются, если нет сообщения об ошибке (Core). +* [Enhancement] Плейсхолдеры [+field.class+] (включает class="") и [+field.classname+] (не включает class="") (Core). +* [Refactor] Параметр lexicon может содержать или имена файлов (без расширения) через запятую или массив с языковыми строками (Lexicon). + +### 1.7.7 +* [Enhancement] Возможность указывать разный subject для разных типов писем (Form). + +### 1.7.6 +* [Fix] Исправления ошибок. + +### 1.7.5 +* [Fix] $this->modx вместо $modx в сниппете. + +### 1.7.4 +* [Fix] Ошибка в лексиконе (Form). +* [Refactor] Версии PHP ниже 5.6 не поддерживаются (Core). + ### 1.7.3 * [Refactor] Подключать __autoload.php, если не задан другой загрузчик. * [Fix] Ошибка в обработке параметра редиректа (Core). diff --git "a/assets/snippets/FormLister/docs/ru/010_\320\232\320\276\320\275\321\202\321\200\320\276\320\273\320\273\320\265\321\200\321\213.md" "b/assets/snippets/FormLister/docs/ru/010_\320\232\320\276\320\275\321\202\321\200\320\276\320\273\320\273\320\265\321\200\321\213.md" old mode 100644 new mode 100755 diff --git "a/assets/snippets/FormLister/docs/ru/020_\320\237\320\260\321\200\320\260\320\274\320\265\321\202\321\200\321\213.md" "b/assets/snippets/FormLister/docs/ru/020_\320\237\320\260\321\200\320\260\320\274\320\265\321\202\321\200\321\213.md" index e0046780fa..1cb9acd0bd 100644 --- "a/assets/snippets/FormLister/docs/ru/020_\320\237\320\260\321\200\320\260\320\274\320\265\321\202\321\200\321\213.md" +++ "b/assets/snippets/FormLister/docs/ru/020_\320\237\320\260\321\200\320\260\320\274\320\265\321\202\321\200\321\213.md" @@ -242,7 +242,7 @@ myparams:core - загрузить параметры из файла assets/sni Возможные значения - 0 или 1. -Значение по умолчанию - 0. +Значение по умолчанию - 1. ### parseDocumentSource Обрабатывает чанки MODX-парсером. diff --git "a/assets/snippets/FormLister/docs/ru/030_\320\222\320\260\320\273\320\270\320\264\320\260\321\206\320\270\321\217 \320\264\320\260\320\275\320\275\321\213\321\205.md" "b/assets/snippets/FormLister/docs/ru/030_\320\222\320\260\320\273\320\270\320\264\320\260\321\206\320\270\321\217_\320\264\320\260\320\275\320\275\321\213\321\205.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/030_\320\222\320\260\320\273\320\270\320\264\320\260\321\206\320\270\321\217 \320\264\320\260\320\275\320\275\321\213\321\205.md" rename to "assets/snippets/FormLister/docs/ru/030_\320\222\320\260\320\273\320\270\320\264\320\260\321\206\320\270\321\217_\320\264\320\260\320\275\320\275\321\213\321\205.md" diff --git "a/assets/snippets/FormLister/docs/ru/035_\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265 \320\272\320\260\320\277\321\207\320\270.md" "b/assets/snippets/FormLister/docs/ru/035_\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265_\320\272\320\260\320\277\321\207\320\270.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/035_\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265 \320\272\320\260\320\277\321\207\320\270.md" rename to "assets/snippets/FormLister/docs/ru/035_\320\230\321\201\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\320\275\320\270\320\265_\320\272\320\260\320\277\321\207\320\270.md" diff --git "a/assets/snippets/FormLister/docs/ru/040_\320\222\321\213\320\262\320\276\320\264 \320\264\320\260\320\275\320\275\321\213\321\205.md" "b/assets/snippets/FormLister/docs/ru/040_\320\222\321\213\320\262\320\276\320\264_\320\264\320\260\320\275\320\275\321\213\321\205.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/040_\320\222\321\213\320\262\320\276\320\264 \320\264\320\260\320\275\320\275\321\213\321\205.md" rename to "assets/snippets/FormLister/docs/ru/040_\320\222\321\213\320\262\320\276\320\264_\320\264\320\260\320\275\320\275\321\213\321\205.md" diff --git "a/assets/snippets/FormLister/docs/ru/050_\320\236\321\202\320\277\321\200\320\260\320\262\320\272\320\260 \320\277\320\270\321\201\320\265\320\274.md" "b/assets/snippets/FormLister/docs/ru/050_\320\236\321\202\320\277\321\200\320\260\320\262\320\272\320\260_\320\277\320\270\321\201\320\265\320\274.md" old mode 100644 new mode 100755 similarity index 98% rename from "assets/snippets/FormLister/docs/ru/050_\320\236\321\202\320\277\321\200\320\260\320\262\320\272\320\260 \320\277\320\270\321\201\320\265\320\274.md" rename to "assets/snippets/FormLister/docs/ru/050_\320\236\321\202\320\277\321\200\320\260\320\262\320\272\320\260_\320\277\320\270\321\201\320\265\320\274.md" index 49b1b8e7a2..f501b7d5d8 --- "a/assets/snippets/FormLister/docs/ru/050_\320\236\321\202\320\277\321\200\320\260\320\262\320\272\320\260 \320\277\320\270\321\201\320\265\320\274.md" +++ "b/assets/snippets/FormLister/docs/ru/050_\320\236\321\202\320\277\321\200\320\260\320\262\320\272\320\260_\320\277\320\270\321\201\320\265\320\274.md" @@ -64,19 +64,19 @@ Значение по умолчанию - 0. -### subject +### subject, ccSubject, autoSubject Тема письма. Возможные значения - строка. Значение по умолчанию - пусто. -### subjectTpl +### subjectTpl, ccSubjectTpl, autoSubjectTpl Шаблон темы письма. Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. -Значение по умолчанию - значение параметра subject. +Значение по умолчанию - значение параметра subject (ccSubject, autoSubject). ### autosender Адрес на который отправляется дополнительное письмо. diff --git "a/assets/snippets/FormLister/docs/ru/060_\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" "b/assets/snippets/FormLister/docs/ru/060_\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" similarity index 54% rename from "assets/snippets/FormLister/docs/ru/060_\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" rename to "assets/snippets/FormLister/docs/ru/060_\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" index 841e652207..8a1203405e 100644 --- "a/assets/snippets/FormLister/docs/ru/060_\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" +++ "b/assets/snippets/FormLister/docs/ru/060_\320\220\320\262\321\202\320\276\321\200\320\270\320\267\320\260\321\206\320\270\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" @@ -1,6 +1,78 @@ ## Авторизация пользователей -Контроллер Login позволяет авторизировать пользователей как по имени, так и по email. Кроме этого, можно дополнительно использовать плагин userHelper, который ведет учет количества логинов и времени последнего логина, а также реализует автологин и выход из учетной записи. +Авторизация пользователей в `FormLister` осуществляется с использованием контроллера `Login`. + +### Выбор поля для авторизации + +Поле для авторизации задается в параметре `loginField` и должно быть **уникальным** для каждого веб-пользователя. + +Авторизация может осуществляться: +* по **базовым** полям средствами класса `modUsers`: `id`, `username` и `email` +* по любому **другому полю** из учетной записи (с помощью плагина для события `OnWebAuthentication`) + + +Дополнительное использование плагина [userHelper](https://github.com/evolution-cms/evolution/blob/develop/assets/snippets/FormLister/plugin.userHelper.php) позволяет: + +* вести учет количества логинов +* определить время последней авторизации +* реализовать автологин и выход из учетной записи +* блокировать пользователей после определенного количества неудачных попыток авторизации + +Перед использованием плагина `userHelper` убедитесь что он включен: + +![Не забудьте включить userHelper](https://habrastorage.org/web/dbc/1e2/abd/dbc1e2abd8664a548f4eca254187fb60.png) + +## Пример вызова FormLister для авторизации веб-пользователей + +```javascript +[!FormLister? +&formid=`login` +&controller=`Login` +&loginField=`email` +&passwordField=`password` +&rules=`{ + "email":{ + "required":"Обязательно введите email" + } + }, + "password":{ + "required":"Обязательно введите пароль", + "minLength":{ + "params":6, + "message":"В пароле должно быть больше 6 символов" + } + }, +}` +&allowedFields=`email,password` +&formTpl=`@CODE: +
+
+ +
+ + + [+email.error+] +
+
+ + + [+password.error+] +
+ [+form.messages+] +
+ +
+
+
+` +&messagesOuterTpl=`@CODE:` +&successTpl=`@CODE:
Поздравляем с успешной авторизацией, [+fullname.value+]!
` +&errorTpl=`@CODE:
[+message+]
` +&requiredClass=` has-error` +&errorClass=` has-error` +&requiredClass=` has-error` +!] +``` ## Параметры контроллера @@ -115,3 +187,18 @@ Возможные значения - число секунд с момента последнего логина. Значение по умолчанию - 157680000 (5 лет). + +### maxFails +Количество попыток для ввода учетных данных. + +Возможные значения - число больше 0. + +Значение по умолчанию - 3. + +### blockTime +Время блокировки пользователя. + +Возможные значения - число секунд с момента последнего логина. + +Значение по умолчанию - 3600 (1 час). + diff --git "a/assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" "b/assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" deleted file mode 100644 index 58843c8e7a..0000000000 --- "a/assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" +++ /dev/null @@ -1,137 +0,0 @@ -## Регистрация пользователей - -Контроллер Register позволяет регистрировать пользователей в заданные группы и отправлять уведомления о регистрации. Контроллер является расширением контроллера Form, соответственно можно использовать соответствующие параметры для отправки писем при регистрации. - -Имена полей в форме должны соответствовать полям модели [modUsers](http://docs.evolution-cms.com/Extras/Snippets/DocLister/MODxAPI). - -Если в форме не задано поле username, то ему присваивается значение поля email. Таким образом можно регистрировать пользователей только по email. - -Если в форме не задано поле password, то значение поля генерируется автоматически. То есть регистрацию пользователя можно свести к указанию email. - -При регистрации с паролем, в форме может присутствовать поле repeatPassword. Если заданы правила валидации для полей password и repeatPassword, то при наличии для поля repeatPassword правила equals, оно будет автоматически скорректировано для проверки равенства значений полей password и repeatPassword: -``` -"repeatPassword":{ - "required":"Введите пароль еще раз", - "equals":{ - "params" : "Этот ключ в описании правила можно не задавать, он будет сформирован контроллером автоматически", - "message":"Пароли не совпадают" - } -} -``` - -При регистрации следует проверять уникальность имени пользователя и email. В контроллере предусмотрены соответствующие правила: -``` -&rules=`{ - "username":{ - "required":"Введите имя пользователя", - "alphaNumeric":"Только буквы и цифры", - "custom":{ - "function":"\\FormLister\\Register::uniqueUsername", - "message":"Имя уже занято" - } - }, - "email":{ - "required":"Введите email", - "email":"Неверный email", - "custom":{ - "function":"\\FormLister\\Register::uniqueEmail", - "message":"Этот email уже использует другой пользователь" - } - } -}` -``` -В шаблонах доступны все поля модели для созданной записи. Дополнительно задается поле user.password с незашифрованным паролем. - -## Параметры -### model -Класс для работы с пользователями. - -Возможные значения - имя класса. - -Значение по умолчанию - \modUsers - -### modelPath -Путь к файлу класса для работы с пользователями. - -Возможные значения - относительный путь к файлу. - -Значение по умолчанию - assets/lib/MODxAPI/modUsers.php - -### allowedFields -Разрешенные для обработки поля. Поля, не указанные в списке, игнорируются. Поля username, email и password всегда разрешены. - -Если не задано, то разрешены все поля. - -Возможные значения - имена полей формы, разделенные запятой. - -Значение по умолчанию - пусто. - -### forbiddenFields -Запрещенные для обработки поля. Поля, указанные в списке, игнорируются. Поля username, email и password удаляются из списка запрещенных. - -Возможные значения - имена полей формы, разделенные запятой. - -Значение по умолчанию - пусто. - -### userGroups -Добавляет зарегистрированного пользователя в указанные группы. - -Возможные значения - имена групп, разделенные запятой (если имена содержат запятую в названии, то можно задать значение параметра массивом). - -Значение по умолчанию - пусто. - -### checkActivation -Включает проверку активации учетной записи пользователя (см. "Активация учетных записей"). При этом после сохранения записи будет установлено поле activate.url, содержащее ссылку на страницу с вызовом сниппета для активации учетной записи. - -Возможные значения - 1 или 0. - -Значение по умолчанию - 0. - -### activateTo -Если включена проверка активации, то в этом параметре необходимо указать id страницы, на которой вызывается сниппет для активации. - -Возможные значения - id страницы. - -Значение по умолчанию - значение $modx->config['site_start']. - -### preparePostProcess -Позволяет выполнить обработку данных после сохранения. - -Возможные значения - имена сниппетов, анонимные функции, статические методы загруженных классов. - -Значение по умолчанию - пусто. - -### redirectTo -Перенаправляет пользователя на указанную страницу после регистрации. - -Возможные значения - id целевой страницы или массив. - -Значение по умолчанию - пусто. - -### exitTo -Перенаправляет уже авторизованного пользователя на указанную страницу. - -Возможные значения - id целевой страницы. - -Значение по умолчанию - пусто. - -### skipTpl -Шаблон сообщения для уже авторизованного пользователя. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Register с ключом [+register.default_skipTpl+] - -### successTpl -Шаблон сообщения об успешной регистрации. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Register с ключом [+register.default_successTpl+] - -### passwordLength -Длина пароля (если создается автоматически). - -Возможные значения - число символов больше 6. - -Значение по умолчанию - 6. diff --git "a/assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\270\314\206.md" "b/assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\270\314\206.md" rename to "assets/snippets/FormLister/docs/ru/070_\320\240\320\265\320\263\320\270\321\201\321\202\321\200\320\260\321\206\320\270\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\320\265\320\271.md" diff --git "a/assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217 \321\203\321\207\320\265\321\202\320\275\321\213\321\205 \320\267\320\260\320\277\320\270\321\201\320\265\320\271.md" "b/assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217 \321\203\321\207\320\265\321\202\320\275\321\213\321\205 \320\267\320\260\320\277\320\270\321\201\320\265\320\271.md" deleted file mode 100644 index ce0f37925c..0000000000 --- "a/assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217 \321\203\321\207\320\265\321\202\320\275\321\213\321\205 \320\267\320\260\320\277\320\270\321\201\320\265\320\271.md" +++ /dev/null @@ -1,84 +0,0 @@ -## Активация учетных записей - -Контроллер Activate реализует активацию учетных записей. Таким образом появляется возможность требовать у пользователя подтверждение учетной записи путем перехода по специальной ссылке из письма, отправленного при регистрации. - -Если по какой-то причине пользователь не получил письмо, то c помощью контроллера Activate он может запросить его повторную отправку. - -Учетная запись пользователя считается неактивированной если в поле logincount записано -1. - -В вызовах сниппета для регистрации и авторизации пользователей должен присутствовать параметр &checkActivation=`1`. - -Поэтому если при регистрации пользователь указывал пароль самостоятельно, то нужно запрашивать пароль для отправки письма со ссылкой для активации. Иначе будет генерироваться новый пароль, потому что раз пользователь запрашивает письмо для активации вручную, значит письмо после регистрации он не получил и не знает созданный при регистрации пароль. - -В шаблонах доступны все поля модели для обрабатываемой записи. В шаблоне reportTpl задается поле user.password с незашифрованным паролем и поле activate.url со ссылкой для активации. - -## Параметры -### model -Класс для работы с пользователями. - -Возможные значения - имя класса. - -Значение по умолчанию - \modUsers - -### modelPath -Путь к файлу класса для работы с пользователями. - -Возможные значения - относительный путь к файлу. - -Значение по умолчанию - assets/lib/MODxAPI/modUsers.php - -### redirectTo -Перенаправляет пользователя на указанную страницу после активации. - -Возможные значения - id целевой страницы или массив. - -Значение по умолчанию - пусто. - -### exitTo -Перенаправляет авторизованного пользователя на указанную страницу. - -Возможные значения - id целевой страницы или массив. - -Значение по умолчанию - пусто. - -### skipTpl -Шаблон сообщения для авторизованного пользователя. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Register с ключом [+register.default_skipTpl+] - -### reportTpl -Шаблон письма с информацией для активации учетной записи. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - пусто. - -### reportTpl -Шаблон письма с информацией для активации учетной записи. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - пусто. - -### successTpl -Шаблон сообщения об успешной отправке письма с данными для активации. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Activate с ключом [+activate.default_successTpl+] - -### activateSuccessTpl -Шаблон сообщения об успешной активации. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Activate с ключом [+activate.default_activateSuccessTpl+] - -### passwordLength -Длина создаваемого пароля. - -Возможные значения - число символов больше 6. - -Значение по умолчанию - 6. diff --git "a/assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217 \321\203\321\207\320\265\321\202\320\275\321\213\321\205 \320\267\320\260\320\277\320\270\321\201\320\265\320\270\314\206.md" "b/assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217_\321\203\321\207\320\265\321\202\320\275\321\213\321\205_\320\267\320\260\320\277\320\270\321\201\320\265\320\271.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217 \321\203\321\207\320\265\321\202\320\275\321\213\321\205 \320\267\320\260\320\277\320\270\321\201\320\265\320\270\314\206.md" rename to "assets/snippets/FormLister/docs/ru/075_\320\220\320\272\321\202\320\270\320\262\320\260\321\206\320\270\321\217_\321\203\321\207\320\265\321\202\320\275\321\213\321\205_\320\267\320\260\320\277\320\270\321\201\320\265\320\271.md" diff --git "a/assets/snippets/FormLister/docs/ru/080_\320\240\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265 \320\277\321\200\320\276\321\204\320\270\320\273\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" "b/assets/snippets/FormLister/docs/ru/080_\320\240\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265_\320\277\321\200\320\276\321\204\320\270\320\273\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/080_\320\240\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265 \320\277\321\200\320\276\321\204\320\270\320\273\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" rename to "assets/snippets/FormLister/docs/ru/080_\320\240\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265_\320\277\321\200\320\276\321\204\320\270\320\273\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" diff --git "a/assets/snippets/FormLister/docs/ru/085_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265 \320\277\321\200\320\276\321\204\320\270\320\273\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" "b/assets/snippets/FormLister/docs/ru/085_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265_\320\277\321\200\320\276\321\204\320\270\320\273\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/085_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265 \320\277\321\200\320\276\321\204\320\270\320\273\321\217 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" rename to "assets/snippets/FormLister/docs/ru/085_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265_\320\277\321\200\320\276\321\204\320\270\320\273\321\217_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217.md" diff --git "a/assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265 \320\277\320\260\321\200\320\276\320\273\320\265\320\271 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" "b/assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265 \320\277\320\260\321\200\320\276\320\273\320\265\320\271 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" deleted file mode 100644 index e9b507dd4f..0000000000 --- "a/assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265 \320\277\320\260\321\200\320\276\320\273\320\265\320\271 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" +++ /dev/null @@ -1,143 +0,0 @@ -## Восстановление паролей пользователями - -Контроллер Reminder позволяет web-пользователям восстанавливать забытые пароли. Расширяет контроллер Form. - -Восстановление паролей происходит по следующей схеме: - -- пользователь вводит в форме свой идентификатор (им может быть имя пользователя или email); -- пользователь получает письмо, в котором содержится ссылка для восстановления; -- при переходе по ссылке пользователь получает возможность ввести новый пароль либо пароль будет сгенерирован автоматически; -- пользователю отправляется письмо с новым паролем и показыается сообщение (в сообщении можно также вывести новый пароль). - -Параметр to перезаписывается значением email пользователя. Обязательно должен быть задан параметр resetTo. - -## Параметры -### model -Класс для работы с пользователями. - -Возможные значения - имя класса. - -Значение по умолчанию - \modUsers - -### modelPath -Путь к файлу класса для работы с пользователями. - -Возможные значения - относительный путь к файлу. - -Значение по умолчанию - assets/lib/MODxAPI/modUsers.php - -### hashField -Имя поля для хранения хэша данных пользователя. - -Значение по умолчанию - hash. - -### userField -Имя поля для хранения идентификатора пользователя (имя пользователя или email). - -Значение по умолчанию - email. - -### uidField -Имя поля, которое используется для идентификации пользователя при переходе по ссылке. - -Значение по умолчанию - id. - -### exitTo -Перенаправляет авторизованного пользователя на указанную страницу. - -Возможные значения - id целевой страницы. - -Значение по умолчанию - пусто. - -### resetTo -Страница, на которую будет указывать ссылка для восстановления паролей. Обязательный параметр. - -Возможные значения - id целевой страницы. - -Значение по умолчанию - id документа, в котором вызван контроллер. - -### redirectTo -Перенаправляет на указанную страницу после успешного восстановления пароля. - -Возможные значения - id целевой страницы. - -Значение по умолчанию - пусто. - -### skipTpl -Шаблон сообщения для авторизованного пользователя. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Reminder с ключом [+reminder.default_skipTpl+]. - -### formTpl -Шаблон формы для ввода идентификатора пользователя. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - пусто. - -### resetTpl -Шаблон формы для ввода нового пароля. Если параметр не задан, то пароль будет сгенерирован автоматически. - -Поля для ввода паролей должны называться password и repeatPassword. В форме должны также присутствовать скрытые поля с именами из параметров uidField и hashField. Значение для поля hashField задается через плейсхолдер [+user.hash+]. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - пусто. - -### successTpl -Шаблон сообщения об успешной отправке письма со ссылкой для восстановления пароля. В шаблоне можно выводить плейсхолдеры с данными пользователя (username, email и т.д.). - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Reminder с ключом [+reminder.default_successTpl+]. - -### resetSuccessTpl -Шаблон сообщения об успешном восстановлении пароля. В шаблоне можно выводить плейсхолдеры с данными пользователя (username, email и т.д.), а также новый пароль (newpassword). - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Reminder с ключом [+reminder.default_resetSuccessTpl+]. - -### reportTpl -Шаблон письма со ссылкой для восстановления пароля. В шаблоне можно выводить плейсхолдеры с данными пользователя (username, email и т.д.), а также новый пароль (newpassword). Ссылка для восстановлени пароля в письме задается через плейсхолдер [+reset.url+] - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - запись из лексикона Reminder с ключом [+reminder.default_reportTpl+].. - -### resetReportTpl -Шаблон письма об успешном восстановлении пароля. В шаблоне можно выводить плейсхолдеры с данными пользователя (username, email и т.д.), а также новый пароль (newpassword). Если не задан, то письмо пользователю отправляться не будет. - -Возможные значения - имя шаблона, указанное по правилам задания шаблонов в DocLister. - -Значение по умолчанию - пусто. - -### rules -Правила валидации для формы идентификации пользователя. - -Возможные значения - см. раздел "Валидация данных". - -Значение по умолчанию - пусто. - -### resetRules -Правила валидации для формы установки нового пароля. Если заданы правила валидации для полей password и repeatPassword, то при наличии для поля repeatPassword правила equals, оно будет автоматически скорректировано для проверки равенства значений полей password и repeatPassword: -``` -"repeatPassword":{ - "required":"Введите пароль еще раз", - "equals":{ - "params" : "Этот ключ в описании правила можно не задавать, он будет сформирован контроллером автоматически", - "message":"Пароли не совпадают" - } -} -``` -Возможные значения - см. раздел "Валидация данных". - -Значение по умолчанию - пусто. - -### passwordLength -Длина пароля (если создается автоматически). - -Возможные значения - число символов больше 6. - -Значение по умолчанию - 6. diff --git "a/assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265 \320\277\320\260\321\200\320\276\320\273\320\265\320\270\314\206 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" "b/assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265_\320\277\320\260\321\200\320\276\320\273\320\265\320\271_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265 \320\277\320\260\321\200\320\276\320\273\320\265\320\270\314\206 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" rename to "assets/snippets/FormLister/docs/ru/090_\320\222\320\276\321\201\321\201\321\202\320\260\320\275\320\276\320\262\320\273\320\265\320\275\320\270\320\265_\320\277\320\260\321\200\320\276\320\273\320\265\320\271_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" diff --git "a/assets/snippets/FormLister/docs/ru/100_\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265 \320\270 \321\200\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" "b/assets/snippets/FormLister/docs/ru/100_\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265_\320\270_\321\200\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265_\320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/100_\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265 \320\270 \321\200\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" rename to "assets/snippets/FormLister/docs/ru/100_\320\241\320\276\320\267\320\264\320\260\320\275\320\270\320\265_\320\270_\321\200\320\265\320\264\320\260\320\272\321\202\320\270\321\200\320\276\320\262\320\260\320\275\320\270\320\265_\320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" diff --git "a/assets/snippets/FormLister/docs/ru/105_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" "b/assets/snippets/FormLister/docs/ru/105_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265_\320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" old mode 100644 new mode 100755 similarity index 100% rename from "assets/snippets/FormLister/docs/ru/105_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265 \320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262 \320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" rename to "assets/snippets/FormLister/docs/ru/105_\320\243\320\264\320\260\320\273\320\265\320\275\320\270\320\265_\320\264\320\276\320\272\321\203\320\274\320\265\320\275\321\202\320\276\320\262_\320\277\320\276\320\273\321\214\320\267\320\276\320\262\320\260\321\202\320\265\320\273\321\217\320\274\320\270.md" diff --git "a/assets/snippets/FormLister/docs/ru/110_\320\233\320\265\320\272\321\201\320\270\320\272\320\276\320\275\321\213.md" "b/assets/snippets/FormLister/docs/ru/110_\320\233\320\265\320\272\321\201\320\270\320\272\320\276\320\275\321\213.md" index dd64c0974b..c9edeba8bc 100644 --- "a/assets/snippets/FormLister/docs/ru/110_\320\233\320\265\320\272\321\201\320\270\320\272\320\276\320\275\321\213.md" +++ "b/assets/snippets/FormLister/docs/ru/110_\320\233\320\265\320\272\321\201\320\270\320\272\320\276\320\275\321\213.md" @@ -13,6 +13,20 @@ return $lang; * langDir - путь к папке с лексиконами; * lang - язык лексикона (если не указано, то используется параметр конфигурации manager_language); -* lexicon - название лексикона, можно указать несколько названий через запятую. +* lexicon - название лексикона, можно указать несколько названий через запятую. Также можно задать значения непосредственно в параметре: +``` +&lexicon=`{ + "english":{ + "test":"Test lexicon value", + "foo":"Another lexicon value", + "bar":"And one more value" + }, + "russian-UTF8":{ + "test":"Проверка", + "foo":"Еще проверка", + "bar":"И еще" + } +}` +``` После этого в шаблонах можно использовать плейсхолдеры [%ключ%] для подстановки значений из загруженных языковых файлов. Кроме того поддерживаются лексиконы компонента EvoBabel. \ No newline at end of file diff --git a/assets/snippets/FormLister/lib/Lexicon.php b/assets/snippets/FormLister/lib/Lexicon.php index a855a01c82..b6c1ad383a 100644 --- a/assets/snippets/FormLister/lib/Lexicon.php +++ b/assets/snippets/FormLister/lib/Lexicon.php @@ -39,9 +39,8 @@ public function loadLang($name = 'core', $lang = '', $langDir = '') if (is_scalar($name) && !empty($name)) { $name = array($name); - } else { - return $this->_lang; } + foreach ($name as $n) { if ($lang != 'english') { $this->loadLangFile($n, 'english', $langDir); @@ -71,8 +70,9 @@ private function loadLangFile($name = 'core', $lang = '', $langDir = '') */ public function fromArray($lang) { - if (is_array($lang) && $lang) { - $this->_lang = array_merge($this->_lang, $lang); + $language = \APIhelpers::getkey($this->cfg, 'lang', $this->modx->config['manager_language']); + if (is_array($lang) && isset($lang[$language])) { + $this->_lang = array_merge($this->_lang, $lang[$language]); } return $this->_lang; diff --git a/assets/snippets/FormLister/lib/captcha/modxCaptcha/modxCaptcha.php b/assets/snippets/FormLister/lib/captcha/modxCaptcha/modxCaptcha.php index 8b84a6f172..186529883a 100644 --- a/assets/snippets/FormLister/lib/captcha/modxCaptcha/modxCaptcha.php +++ b/assets/snippets/FormLister/lib/captcha/modxCaptcha/modxCaptcha.php @@ -19,6 +19,12 @@ class ModxCaptcha protected $im_width = 0; protected $im_height = 0; + /** + * ModxCaptcha constructor. + * @param DocumentParser $modx + * @param int $width + * @param int $height + */ public function __construct(DocumentParser $modx, $width = 200, $height = 160) { $this->modx = $modx; @@ -82,45 +88,61 @@ private function drawText() $dir->close(); $text_font = (string)$fontstmp[array_rand($fontstmp)]; $chars = str_split($this->word); - /* angle for text inclination */ - /* initial text size */ + $_chars = array(); + $maxWidth = $this->im_width / count($chars); + $text_size = round(max($maxWidth, $this->im_height) * 3 /4.5 ); + $maxHeight = 0; + $totalWidth = 0; + foreach ($chars as $index => $value) { + $text_angle = rand(-20, 20); + $size = $text_size; + $box = imagettfbbox($size, $text_angle, $text_font, $value); + $charWidth = $box[2] - $box[0]; + $charHeight = abs($box[5] - $box[3]); + $_chars[] = array( + 'angle' => $text_angle, + 'size' => $size, + 'width' => $charWidth, + 'height' => $charHeight + ); + if ($charHeight > $maxHeight) $maxHeight = $charHeight; + $totalWidth += $charWidth; + } + + $minRatio = min(1, $this->im_width / $totalWidth, $this->im_height / $maxHeight); + $size = round($text_size * $minRatio * 0.9); + + $totalWidth = 0; + foreach ($_chars as $index => &$data) { + $data['size'] = $size; + $box = imagettfbbox($data['size'], $data['angle'], $text_font, $chars[$index]); + $charWidth = $box[2] - $box[0]; + $charHeight = abs($box[5] - $box[3]); + $data['width'] = $charWidth; + $data['height'] = $charHeight; + $totalWidth += $charWidth; + } /* create canvas for text drawing */ $im_text = imagecreate($this->im_width, $this->im_height); $bg_color = imagecolorallocate($im_text, 255, 255, 255); - - $len = count($chars); - foreach ($chars as $index => $value) { - $text_angle = rand(-30, 30); - /* initial text size */ - $text_size = 30; - /* calculate text width and height */ - $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); - $text_width = $box[2] - $box[0]; //text width - /* adjust text size */ - $text_size = round((30 * $this->im_width) / $text_width); - /* recalculate text width and height */ - $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); - $text_width = ($box[2] - $box[0]) / $len; //text width - $text_height = $box[5] - $box[3]; //text height - + $text_x = ($this->im_width - $totalWidth) / 2; + foreach ($_chars as $index => $data) { /* calculate center position of text */ - $text_x = ($this->im_width - $len * $text_width) / 2 + $index * $text_width; - $text_y = ($this->im_height - $text_height) / 2; - - + $text_y = ($this->im_height + $data['height'])/2; /* pick color for text */ $text_color = imagecolorallocate($im_text, rand(10, 200), rand(10, 200), rand(10, 200)); /* draw text into canvas */ imagettftext( $im_text, - $text_size, - $text_angle, + $data['size'], + $data['angle'], $text_x, $text_y, $text_color, $text_font, - $value); + $chars[$index]); + $text_x += $data['width']; } /* remove background color */ imagecolortransparent($im_text, $bg_color); diff --git a/assets/snippets/FormLister/lib/captcha/modxCaptcha/wrapper.php b/assets/snippets/FormLister/lib/captcha/modxCaptcha/wrapper.php index 613e50cb3d..14fab1f791 100644 --- a/assets/snippets/FormLister/lib/captcha/modxCaptcha/wrapper.php +++ b/assets/snippets/FormLister/lib/captcha/modxCaptcha/wrapper.php @@ -82,7 +82,7 @@ public static function validate(Core $FormLister, $value, CaptchaInterface $capt if (empty($value)) { $out = \APIhelpers::getkey($captcha->cfg, 'errorEmptyCode', 'Введите проверочный код'); } else { - $out = $value == $captcha->lastValue ? true : \APIhelpers::getkey($captcha->cfg, + $out = strtolower($value) == strtolower($captcha->lastValue) ? true : \APIhelpers::getkey($captcha->cfg, 'errorCodeFailed', 'Неверный проверочный код'); } $FormLister->log('Validate captcha value '.$value.' against '.$captcha->lastValue); diff --git a/assets/snippets/FormLister/snippet.FormLister.php b/assets/snippets/FormLister/snippet.FormLister.php index 622d2b0b5d..fb1cde70b4 100644 --- a/assets/snippets/FormLister/snippet.FormLister.php +++ b/assets/snippets/FormLister/snippet.FormLister.php @@ -9,7 +9,7 @@ * @var array $params */ if (!isset($formid)) { - $this->modx->logEvent(0, 1, "Parameter &formid is not set", 'FormLister'); + $modx->logEvent(0, 1, "Parameter &formid is not set", 'FormLister'); return; } if (!class_exists('\FormLister\Core')) { @@ -49,7 +49,7 @@ $FormLister->debug->saveLog(); } } else { - $this->modx->logEvent(0, 1, "Controller {$classname} is missing", 'FormLister'); + $modx->logEvent(0, 1, "Controller {$classname} is missing", 'FormLister'); } return $out; diff --git a/assets/snippets/ajaxSearch/classes/ajaxSearchLog.class.inc.php b/assets/snippets/ajaxSearch/classes/ajaxSearchLog.class.inc.php index 7c098ce66b..f2a54ef053 100644 --- a/assets/snippets/ajaxSearch/classes/ajaxSearchLog.class.inc.php +++ b/assets/snippets/ajaxSearch/classes/ajaxSearchLog.class.inc.php @@ -147,7 +147,7 @@ function updateComment($logid, $ascmt) { //============================================================================== /* The code below handles comment sent if the $_POST variables are set. Used when the user post comment from the ajaxSearch results window */ -if ($_POST['logid'] && $_POST['ascmt']) { +if (!empty($_POST['logid']) && !empty($_POST['ascmt'])) { $ascmt = strip_tags($_POST['ascmt']); $logid = intval($_POST['logid']); $safeCmt = (strlen($ascmt) < CMT_MAX_LENGTH) && (substr_count($ascmt, 'http') < CMT_MAX_LINKS); diff --git a/assets/snippets/ajaxSearch/classes/ajaxSearchUtil.class.inc.php b/assets/snippets/ajaxSearch/classes/ajaxSearchUtil.class.inc.php index 2b27c47e6e..1c0e8c9ddf 100644 --- a/assets/snippets/ajaxSearch/classes/ajaxSearchUtil.class.inc.php +++ b/assets/snippets/ajaxSearch/classes/ajaxSearchUtil.class.inc.php @@ -102,7 +102,7 @@ function getElapsedTime($start=0) { */ function setBacktrackLimit($backtrackLimit) { $this->_current_pcre_backtrack = ini_get('pcre.backtrack_limit'); - if ($dbg) $this->dbgRecord($current_pcre_backtrack, "AjaxSearch - pcre.backtrack_limit"); + if (isset($dbg)) $this->dbgRecord($current_pcre_backtrack, "AjaxSearch - pcre.backtrack_limit"); ini_set( 'pcre.backtrack_limit', $backtrackLimit); } /* diff --git a/assets/snippets/ajaxSearch/classes/asPhxParser.class.inc.php b/assets/snippets/ajaxSearch/classes/asPhxParser.class.inc.php index 02842e18a1..a3f587b65e 100644 --- a/assets/snippets/ajaxSearch/classes/asPhxParser.class.inc.php +++ b/assets/snippets/ajaxSearch/classes/asPhxParser.class.inc.php @@ -21,8 +21,8 @@ function __construct($template='',$maxpass=500) { $this->name = "PHx"; $this->version = "2.1.3"; $this->template = $this->getTemplate($template); - $this->user["mgrid"] = intval($_SESSION['mgrInternalKey']); - $this->user["usrid"] = intval($_SESSION['webInternalKey']); + $this->user["mgrid"] = !empty($_SESSION['mgrInternalKey']) ? intval($_SESSION['mgrInternalKey']) : ''; + $this->user["usrid"] = !empty($_SESSION['webInternalKey']) ? intval($_SESSION['webInternalKey']) : ''; $this->user["id"] = ($this->user["usrid"] > 0 ) ? (-$this->user["usrid"]) : $this->user["mgrid"]; $this->cache["cm"] = array(); $this->cache["ui"] = array(); diff --git a/assets/snippets/ajaxSearch/plugin.advSearchHighlight.tpl b/assets/snippets/ajaxSearch/plugin.advSearchHighlight.tpl index 9a9b1c42cd..aaed4650bf 100644 --- a/assets/snippets/ajaxSearch/plugin.advSearchHighlight.tpl +++ b/assets/snippets/ajaxSearch/plugin.advSearchHighlight.tpl @@ -86,17 +86,9 @@ if (isset($_REQUEST['searched']) && isset($_REQUEST['highlight'])) { $dbCharset = $database_connection_charset; $pgCharset = array_key_exists($dbCharset,$pageCharset) ? $pageCharset[$dbCharset] : $dbCharset; - // magic quotes check - if (get_magic_quotes_gpc()){ - $searched = strip_tags(stripslashes($_REQUEST['searched'])); - $highlight = strip_tags(stripslashes($_REQUEST['highlight'])); - if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags(stripslashes($_REQUEST['advsearch'])); - } - else { - $searched = strip_tags($_REQUEST['searched']); - $highlight = strip_tags($_REQUEST['highlight']); - if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags($_REQUEST['advsearch']); - } + $searched = strip_tags($_REQUEST['searched']); + $highlight = strip_tags($_REQUEST['highlight']); + if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags($_REQUEST['advsearch']); if ($advsearch != 'nowords') { diff --git a/assets/snippets/ajaxSearch/plugin.searchHighlight.tpl b/assets/snippets/ajaxSearch/plugin.searchHighlight.tpl index a00f897e36..8aaaac077d 100644 --- a/assets/snippets/ajaxSearch/plugin.searchHighlight.tpl +++ b/assets/snippets/ajaxSearch/plugin.searchHighlight.tpl @@ -81,17 +81,9 @@ if (isset($_REQUEST['searched']) && isset($_REQUEST['highlight'])) { $dbCharset = $database_connection_charset; $pgCharset = array_key_exists($dbCharset,$pageCharset) ? $pageCharset[$dbCharset] : $dbCharset; - // magic quotes check - if (get_magic_quotes_gpc()){ - $searched = strip_tags(stripslashes($_REQUEST['searched'])); - $highlight = strip_tags(stripslashes($_REQUEST['highlight'])); - if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags(stripslashes($_REQUEST['advsearch'])); - } - else { - $searched = strip_tags($_REQUEST['searched']); - $highlight = strip_tags($_REQUEST['highlight']); - if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags($_REQUEST['advsearch']); - } + $searched = strip_tags($_REQUEST['searched']); + $highlight = strip_tags($_REQUEST['highlight']); + if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags($_REQUEST['advsearch']); if ($advsearch != 'nowords') { 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 bda152c4ea..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","haskeywords","hasmetatags","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 = $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; } @@ -590,31 +514,31 @@ function multiSort($resource,$orderBy) { // Get Document IDs for future use // --------------------------------------------------- - function determineIDs($IDs, $IDType, $TVs, $orderBy, $depth, $showPublishedOnly, $seeThruUnpub, $hideFolders, $hidePrivate, $showInMenuOnly, $myWhere, $keywords, $dateSource, $limit, $summarize, $filter, $paginate, $randomize) { + 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 && $keywords==0) { + 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,30 +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 ($keywords) {$this->addField("haskeywords","*","db");$this->addField("hasmetatags","*","db");} - if ($this->debug) {$this->addField("pagetitle","backend","db");} -// intersel edit -// Bug when we use a date field ("pub_date","unpub_date","editedon","deletedon","publishedon") -// used to order the results' array in descending order: -// the result of getDocuments is not correct because the result is limited to $limit -// but the array of results was not sorted (see SQL Query in getDocuments) -// (see checkAdvSort function) -// my choice to fix this bug was to set limit to 0 in the getDocuments call when we order with a date field (see customReset), -// then to limit the size of the array after all sorting functions were done (see hereafter) -// I did not get side effects on my modx installs... - -/* - if (count($customReset) > 0) {$this->addField("createdon","backend","db");} - $resource = $this->getDocuments($documentIDs,$this->fields["backend"]["db"],$TVs,$orderBy,$showPublishedOnly,0,$hidePrivate,$where,$limit,$keywords,$randomize,$dateSource); -*/ - $limitSearch=$limit; - if (count($customReset) > 0) {$this->addField("createdon","backend","db"); $limitSearch=0;} - $resource = $this->getDocuments($documentIDs,$this->fields["backend"]["db"],$TVs,$orderBy,$showPublishedOnly,0,$hidePrivate,$where,$limitSearch,$keywords,$randomize,$dateSource); + 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); // EPO - End of change (then see line 692 - if ($limit) array_slice($resource, 0, $limit); ) @@ -672,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']; } } } @@ -701,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); @@ -717,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; } @@ -725,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);} @@ -750,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 } @@ -781,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; } @@ -795,82 +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("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 { + $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; - } - - // --------------------------------------------------- - // Function: appendKeywords - // Append keywords's to the resource array - // --------------------------------------------------- - - function appendKeywords($resource) { - $keys = $this->fetchKeywords($resource); - $resource["keywords"] = "$keys"; - return $resource; - } - - // --------------------------------------------------- - // Function: fetchKeywords - // Helper function to - // --------------------------------------------------- - - function fetchKeywords($resource) { - global $modx; - if($resource['haskeywords']==1) { - // insert keywords - $metas = implode(",",$modx->getKeywords($resource["id"])); - } - if($resource['hasmetatags']==1){ - // insert meta tags - $tags = $modx->getMETATags($resource["id"]); - foreach ($tags as $n=>$col) { - $tag = strtolower($col['tag']); - $metas.= ",".$col['tagvalue']; - } - } - return $metas; + return $docs; } // --------------------------------------------------- @@ -897,90 +771,89 @@ 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= "",$keywords=0,$randomize=0,$dateSource=false) { - global $modx; - - if (count($ids) == 0) { - return false; - } else { + 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; sort($ids); - $tblsc= $modx->getFullTableName("site_content"); - $tbldg= $modx->getFullTableName("document_groups"); - $tbltvc = $modx->getFullTableName("site_tmplvar_contentvalues"); // modify field names to use sc. table reference - $fields= "sc.".implode(",sc.",$fields); - if ($randomize != 0) { - $sort = "RAND()"; - } else { - $sort= $orderBy['sql']; + $fields= 'sc.'.join(',sc.',$fields); + + if ($randomize != 0) $sort = 'RAND()'; + else $sort= $orderBy['sql']; + + //Added by Andchir (http://modx-shopkeeper.ru/) + if(substr($where, 0, 5)=='@SQL:'){ + if($where) $where = substr(str_replace('@eq','=',$where), 5); + $left_join_tvc = 'LEFT JOIN [+prefx+]site_tmplvar_contentvalues AS tvc ON sc.id = tvc.contentid'; + } else { + if($where) $where = 'AND sc.' . join(' AND sc.', array_filter(array_map('trim', explode('AND', $where)))); + $left_join_tvc = ''; } - - //Added by Andchir (http://modx-shopkeeper.ru/) - if(substr($where, 0, 5)=="@SQL:"){ - $where = ($where == "") ? "" : substr(str_replace('@eq','=',$where), 5); - $left_join_tvc = "LEFT JOIN $tbltvc AS tvc ON sc.id = tvc.contentid"; - }else{ - $where= ($where == "") ? "" : 'AND sc.' . implode(' AND sc.', array_filter(array_map('trim', explode('AND', $where)))); - $left_join_tvc = ''; - } - - if ($public) { - // get document groups for current user - 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)"); + + if ($pubOnly) { + 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})"; + } + } } - $published = ($published) ? "AND sc.published=1" : ""; + $published = ($published) ? 'AND sc.published=1' : ''; - $result= $modx->db->select( - "DISTINCT {$fields}", - "{$tblsc} AS sc {$left_join_tvc} LEFT JOIN {$tbldg} dg on dg.document = sc.id", - "sc.id IN (" . implode(',', $ids) . ") {$published} AND sc.deleted='{$deleted}' {$where} ".($public ? 'AND ('.$access.')' : '')." GROUP BY sc.id", - $sort, - $limit - ); - $resourceArray= array (); - $cnt = $modx->db->getRecordCount($result); + $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[] = sprintf('sc.id IN (%s)', join(',', $ids)); + $sqlWhere[] = $published; + $sqlWhere[] = "AND sc.deleted='{$deleted}'"; + $sqlWhere[] = $where; + 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; + + $docs = array(); $TVData = array(); - $TVIDs = array(); - if ($cnt) { - while ($resource = $modx->db->getRow($result)) { - if ($modx->config["server_offset_time"] != 0 && $dateSource !== false) { - $dateValue = (is_int($resource[$dateSource]) !== true) ? $resource[$dateSource] : strtotime($resource[$dateSource]); - $resource[$dateSource] = $dateValue + $modx->config["server_offset_time"]; - } - if($keywords) { - $resource = $this->appendKeywords($resource); - } - if ($this->prefetch == true && $this->sortOrder !== false) $resource["ditto_sort"] = $this->sortOrder[$resource["id"]]; - $TVIDs[] = $resource["id"]; - $resourceArray["#".$resource["id"]] = $resource; - if (count($this->prefetch["resource"]) > 0) { - $x = "#".$resource["id"]; - $resourceArray[$x] = array_merge($resource,$this->prefetch["resource"][$x]); - // merge the prefetch array and the normal array - } - } - - $TVs = array_unique($TVs); - if (count($TVs) > 0) { - foreach($TVs as $tv){ - $TVData = array_merge_recursive($this->appendTV($tv,$TVIDs),$TVData); - } - } + $TVIDs = array(); + while ($doc = $modx->db->getRow($rs)) { + if ($dateSource !== false) { + if(!$this->isNum($doc[$dateSource])) $doc[$dateSource] = strtotime($doc[$dateSource]); + if($modx->config['server_offset_time'] != 0) + $doc[$dateSource] += $modx->config['server_offset_time']; + } + + if ($this->prefetch && $this->sortOrder!==false) $doc['ditto_sort'] = $this->sortOrder[$doc['id']]; + + $k = '#'.$doc['id']; + if (count($this->prefetch['resource']) > 0) { + $docs[$k] = array_merge($doc,$this->prefetch['resource'][$k]); + // merge the prefetch array and the normal array + } + else $docs[$k] = $doc; + + $TVIDs[] = $doc['id']; + } - $resourceArray = array_merge_recursive($resourceArray,$TVData); - if ($this->prefetch == true && $this->sortOrder !== false) { - $resourceArray = $this->customSort($resourceArray,"ditto_sort","ASC"); - } - - return $resourceArray; - } else { - return false; + $TVs = array_unique($TVs); + if (count($TVs) > 0) { + foreach($TVs as $tv){ + $TVData = array_merge_recursive($this->appendTV($tv,$TVIDs),$TVData); } } + + $docs = array_merge_recursive($docs,$TVData); + if ($this->prefetch == true && $this->sortOrder !== false) + $docs = $this->customSort($docs,'ditto_sort','ASC'); + + return $docs; } // --------------------------------------------------- @@ -993,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; } } @@ -1043,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 { @@ -1053,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) { @@ -1068,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); } // --------------------------------------------------- @@ -1079,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]; @@ -1111,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) @@ -1141,7 +1027,8 @@ 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; $display = $x +1; @@ -1151,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); } // --------------------------------------------------- @@ -1180,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 @@ -1206,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 2499b7b284..e71a5fe7b4 100644 --- a/assets/snippets/ditto/classes/template.class.inc.php +++ b/assets/snippets/ditto/classes/template.class.inc.php @@ -3,233 +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 ($modx->getChunk($tpl) != "") { - $template = $modx->getChunk($tpl); - } else if(substr($tpl, 0, 6) == "@FILE:") { - $template = $this->get_file_contents(MODX_BASE_PATH.substr($tpl, 6)); - } else if(substr($tpl, 0, 6) == "@CODE:") { - $template = substr($tpl, 6); - } else if(substr($tpl, 0, 5) == "@FILE") { - $template = $this->get_file_contents(trim(substr($tpl, 5))); - } else if(substr($tpl, 0, 5) == "@CODE") { - $template = trim(substr($tpl, 5)); - } else { - $template = $this->language['missing_placeholders_tpl']; - } - if(strpos($template,'[!')!==false) $template = str_replace(array('[!','!]'),array('[[',']]'),$template); - 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) ? '' : $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 '
  • Bad list
'; + } + 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) ? '' : $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 "
  • Bad list
"; - } - 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 fe7e7f3b8a..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,10 +22,11 @@ //---Core Settings---------------------------------------------------- // -$ditto_version = "2.1.2"; +$ditto_version = '2.1.2'; // Ditto version being executed -$ditto_base = isset($ditto_base) ? $modx->config['base_path'].$ditto_base : $modx->config['base_path']."assets/snippets/ditto/"; +if(isset($ditto_base)) $ditto_base = $modx->config['base_path'].ltrim($ditto_base,'/'); +else $ditto_base = str_replace('\\','/',__DIR__) . '/'; /* Param: ditto_base @@ -38,8 +39,8 @@ Default: [(base_path)]assets/snippets/ditto/ */ -$dittoID = (!isset($id)) ? "" : $id."_"; -$GLOBALS["dittoID"] = $dittoID; +$dittoID = (isset($id)) ? $id.'_' : ''; +$GLOBALS['dittoID'] = $dittoID; /* Param: id @@ -53,11 +54,11 @@ This is case sensitive Default: - "" - blank -*/ -$language = (isset($language))? $language : $modx->config['manager_language']; -if (!file_exists($ditto_base."lang/".$language.".inc.php")) { - $language ="english"; + '' - blank +*/ +if(!isset($language)) $language = $modx->config['manager_language']; +if (!is_file("{$ditto_base}lang/{$language}.inc.php")) { + $language ='english'; } /* Param: language @@ -69,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 @@ -79,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 @@ -96,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: - @@ -136,7 +137,7 @@ Default: 1 - on */ -$extenders = isset($extenders) ? explode(",",$extenders) : array(); +$extenders = isset($extenders) ? explode(',',$extenders) : array(); /* Param: extenders @@ -159,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'=>$orderBy); +$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)); } @@ -241,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']; } } } @@ -253,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 @@ -297,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 @@ -338,7 +339,7 @@ - - */ -$dateSource = isset($dateSource) ? $dateSource : "createdon"; +$dateSource = isset($dateSource) ? $dateSource : 'createdon'; /* Param: dateSource @@ -349,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 @@ -370,7 +371,7 @@ Related: - */ -$display = isset($display) ? $display : "all"; +$display = isset($display) ? $display : 'all'; /* Param: display @@ -379,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 @@ -397,10 +398,10 @@ Options: # - Any number - "all" - All documents found + 'all' - All documents found Default: - "all" - All documents found + 'all' - All documents found Related: - @@ -503,7 +504,7 @@ - - */ -$queryLimit = (isset($queryLimit))? $queryLimit : 0; +$queryLimit = (isset($queryLimit))? $queryLimit : ''; /* Param: queryLimit @@ -520,7 +521,7 @@ Related: - */ -$where = (isset($where))? $where : ""; +$where = (isset($where))? $where : ''; /* Param: where @@ -536,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 @@ -549,7 +550,7 @@ Default: [LANG] */ -$removeChunk = isset($removeChunk) ? explode(",",$removeChunk) : false; +$removeChunk = isset($removeChunk) ? explode(',',$removeChunk) : false; /* Param: removeChunk @@ -563,7 +564,7 @@ Default: [NULL] */ -$hiddenFields = isset($hiddenFields) ? explode(",",$hiddenFields) : false; +$hiddenFields = isset($hiddenFields) ? explode(',',$hiddenFields) : false; /* Param: hiddenFields @@ -590,7 +591,7 @@ Default: 0 */ -$globalFilterDelimiter = isset($globalFilterDelimiter) ? $globalFilterDelimiter : "|"; +$globalFilterDelimiter = isset($globalFilterDelimiter) ? $globalFilterDelimiter : '|'; /* Param: globalFilterDelimiter @@ -601,7 +602,7 @@ Any character not used in the filters Default: - "|" + '|' Related: - @@ -609,7 +610,7 @@ - */ -$localFilterDelimiter = isset($localFilterDelimiter) ? $localFilterDelimiter : ","; +$localFilterDelimiter = isset($localFilterDelimiter) ? $localFilterDelimiter : ','; /* Param: localFilterDelimiter @@ -620,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 @@ -665,21 +666,6 @@ - - */ -$keywords = (isset($keywords))? $keywords : 0; -/* - Param: keywords - - Purpose: - Enable fetching of associated keywords for each document - Can be used as [+keywords+] or as a tagData source - - Options: - 0 - off - 1 - on - - Default: - 0 - off -*/ $randomize = (isset($randomize))? $randomize : 0; /* @@ -714,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 @@ -814,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, $keywords, $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 @@ -824,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) { @@ -871,7 +857,7 @@ - - */ - $tplPaginatePrevious = isset($tplPaginatePrevious)? $ditto->template->fetch($tplPaginatePrevious) : "[+lang:previous+]"; + $tplPaginatePrevious = isset($tplPaginatePrevious)? $ditto->template->fetch($tplPaginatePrevious) : '[+lang:previous+]'; /* Param: tplPaginatePrevious @@ -891,7 +877,7 @@ - - */ - $tplPaginateNext = isset($tplPaginateNext)? $ditto->template->fetch($tplPaginateNext) : "[+lang:next+]"; + $tplPaginateNext = isset($tplPaginateNext)? $ditto->template->fetch($tplPaginateNext) : '[+lang:next+]'; /* Param: tplPaginateNext @@ -911,7 +897,7 @@ - - */ - $tplPaginateNextOff = isset($tplPaginateNextOff)? $ditto->template->fetch($tplPaginateNextOff) : "[+lang:next+]"; + $tplPaginateNextOff = isset($tplPaginateNextOff)? $ditto->template->fetch($tplPaginateNextOff) : '[+lang:next+]'; /* Param: tplPaginateNextOff @@ -930,7 +916,7 @@ - - */ - $tplPaginatePreviousOff = isset($tplPaginatePreviousOff)? $ditto->template->fetch($tplPaginatePreviousOff) : "[+lang:previous+]"; + $tplPaginatePreviousOff = isset($tplPaginatePreviousOff)? $ditto->template->fetch($tplPaginatePreviousOff) : '[+lang:previous+]'; /* Param: tplPaginatePreviousOff @@ -993,44 +979,45 @@ // 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 - - switch($orderBy['parsed'][0][1]) { - case "DESC": - $stop = ($ditto->prefetch === false) ? $stop + $start + $offset : $stop + $offset; - $start += $offset; - break; - case "ASC": - $start += $offset; - $stop += $start; - break; + if(isset($orderBy['parsed'][0][1])) { + switch($orderBy['parsed'][0][1]) { + case 'DESC': + $stop = ($ditto->prefetch === false) ? $stop + $start + $offset : $stop + $offset; + $start += $offset; + break; + case 'ASC': + $start += $offset; + $stop += $start; + break; + } } 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, $keywords, $randomize, $dateSource); + $resource = $ditto->getDocuments($documentIDs, $dbFields, $TVs, $orderBy, $showPublishedOnly, 0, $hidePrivate, $where, $queryLimit, $randomize, $dateSource); // retrieves documents $output = $header; // 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 } @@ -1038,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] @@ -1064,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; @@ -1076,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 { @@ -1094,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/assets/snippets/docinfo/snippet.docinfo.php b/assets/snippets/docinfo/snippet.docinfo.php index e97b7914de..d843a3ed16 100644 --- a/assets/snippets/docinfo/snippet.docinfo.php +++ b/assets/snippets/docinfo/snippet.docinfo.php @@ -20,7 +20,7 @@ * [[DocInfo? &docid=`3` &field=`tvname` &render=`1`]] */ if(!defined('MODX_BASE_PATH')){die('What are you doing? Get out of here!');} -$default_field = array('type','contentType','pagetitle','longtitle','description','alias','link_attributes','published','pub_date','unpub_date','parent','isfolder','introtext','content','richtext','template','menuindex','searchable','cacheable','createdon','createdby','editedon','editedby','deleted','deletedon','deletedby','publishedon','publishedby','menutitle','donthit','haskeywords','hasmetatags','privateweb','privatemgr','content_dispo','hidemenu','alias_visible'); +$default_field = array('type','contentType','pagetitle','longtitle','description','alias','link_attributes','published','pub_date','unpub_date','parent','isfolder','introtext','content','richtext','template','menuindex','searchable','cacheable','createdon','createdby','editedon','editedby','deleted','deletedon','deletedby','publishedon','publishedby','menutitle','donthit','privateweb','privatemgr','content_dispo','hidemenu','alias_visible'); $docid = (isset($docid) && (int)$docid>0) ? (int)$docid : $modx->documentIdentifier; $field = (isset($field)) ? $field : 'pagetitle'; $render = (isset($render)) ? $render : 0; diff --git a/assets/snippets/eform/eform.inc.php b/assets/snippets/eform/eform.inc.php index c92aac5312..ff983cc130 100644 --- a/assets/snippets/eform/eform.inc.php +++ b/assets/snippets/eform/eform.inc.php @@ -169,7 +169,6 @@ function eForm($modx,$params) { if(is_array($value)){ // type="checkbox" etc. remove empty values $value = array_filter($value,create_function('$v','return (!empty($v));')); } else { - if(get_magic_quotes_gpc()) $value = stripslashes($value); // For before PHP 5.3 if(!$allowhtml || $formats[$name][2]!='html') $value = strip_tags($value); } $fields[$name] = $value; diff --git a/assets/snippets/if/snippet.if.php b/assets/snippets/if/snippet.if.php index 6ca29594b3..1942789286 100644 --- a/assets/snippets/if/snippet.if.php +++ b/assets/snippets/if/snippet.if.php @@ -54,7 +54,7 @@ if ($and) {$subject=$opers[$i];$and=false;continue;} $operator = $opers[$i]; - $operand = $opers[$i+1]; + $operand = isset($opers[$i+1]) ? $opers[$i+1] : ''; if (isset($subject)) { if (!empty($operator)) { diff --git a/assets/snippets/jot/jot.class.inc.php b/assets/snippets/jot/jot.class.inc.php index 07c308066b..58c1d00b2b 100644 --- a/assets/snippets/jot/jot.class.inc.php +++ b/assets/snippets/jot/jot.class.inc.php @@ -487,9 +487,6 @@ function processForm($id=0) { // For every field posted loop foreach($_POST as $n=>$v) { - // Stripslashes if needed - if (get_magic_quotes_gpc()) { $v = stripslashes($v); } - // Avoid XSS $v = $modx->htmlspecialchars($v, ENT_QUOTES); diff --git a/assets/snippets/reflect/snippet.reflect.php b/assets/snippets/reflect/snippet.reflect.php index 9be8b4b2de..068489f19c 100644 --- a/assets/snippets/reflect/snippet.reflect.php +++ b/assets/snippets/reflect/snippet.reflect.php @@ -236,8 +236,8 @@ "tpl" => $itemTemplate, ); - $source = $dittoSnippetName; - $params = $dittoSnippetParameters; + $source = isset($dittoSnippetName) ? $dittoSnippetName : ''; + $params = isset($dittoSnippetParameters) ? $dittoSnippetParameters : ''; // TODO: Remove after 3.0 if (isset($params)) { @@ -407,6 +407,7 @@ function reflect($templatesDocumentID, $showItems, $groupByYears, $resource, $te $cal = array(); $output = ''; $ph = array('year'=>'','month'=>'','item'=>'','out'=>''); + $phx = isset($phx) ? $phx : ''; $build = array(); $stop = count($resource); diff --git a/assets/snippets/wayfinder/wayfinder.inc.php b/assets/snippets/wayfinder/wayfinder.inc.php index 1d80b866a3..3e4967ef4b 100644 --- a/assets/snippets/wayfinder/wayfinder.inc.php +++ b/assets/snippets/wayfinder/wayfinder.inc.php @@ -83,7 +83,7 @@ function buildSubMenu($subDocs,$level) { //Loop through each document to render output foreach ($subDocs as $docId => $docInfo) { - $docInfo['level'] = $level; + $docInfo['level'] = $docInfo['wf.level'] = $level; $docInfo['first'] = $counter==1 ? 1 : 0; //Determine if last item in group diff --git a/assets/snippets/weblogin/weblogin.inc.php b/assets/snippets/weblogin/weblogin.inc.php index 3181e8ee0f..e2cc81dbf4 100755 --- a/assets/snippets/weblogin/weblogin.inc.php +++ b/assets/snippets/weblogin/weblogin.inc.php @@ -83,9 +83,9 @@ function webLoginEnter(nextfield,event) { $tpl = "
".$tpls[0]."
"; $tpl.= ""; $tpl = str_replace("[+action+]",preserveUrl($modx->documentIdentifier,"",$ref),$tpl); - $tpl = str_replace("[+rememberme+]",($_POST['rememberme'] ? 1 : 0),$tpl); + $tpl = str_replace("[+rememberme+]",(!empty($_POST['rememberme']) ? 1 : 0),$tpl); $tpl = str_replace("[+username+]",$uid,$tpl); - $tpl = str_replace("[+checkbox+]",($_POST['rememberme'] ? "checked='checked'" : ""),$tpl); + $tpl = str_replace("[+checkbox+]",(!empty($_POST['rememberme']) ? "checked='checked'" : ""),$tpl); $tpl = str_replace("[+logintext+]",$loginText,$tpl); echo $tpl; @@ -97,7 +97,7 @@ function webLoginEnter(nextfield,event) { INCLUDE_ORDERING_ERROR

Please use the MODX Content Manager instead of accessing this file directly."); - -$downloadLinks = array( - 0=>array('title'=>$_lang["information"],'link'=>'https://modx.com/community/modx-evolution'), - 1=>array('title'=>$_lang["download"],'link'=>'https://modx.com/download/evolution/'), - 2=>array('title'=>$_lang["previous_releases"],'link'=>'https://modx.com/download/evolution/previous-releases.html'), - 3=>array('title'=>$_lang["extras"],'link'=>array( - 'https://modx.com/extras/?product=evolution', - 'http://extras.evolution-cms.com/', - 'https://github.com/extras-evolution' - )), -); - -$translationLinks = array( - 0=>array('title'=>'MODX Evolution','link'=>'https://www.transifex.com/modx/modx-evolution/'), - 1=>array('title'=>$_lang["extras"],'link'=>'https://www.transifex.com/modx/modx-evolution-extras/'), -); - -function createList($sectionHeader, $linkArr) { - $output = '
'.$sectionHeader.'
'."\n"; - $output .= ''."\n"; - $links = ''; - foreach($linkArr as $row) { - if (!is_array($row['link'])) $row['link'] = array($row['link']); - foreach ($row['link'] as $link) { - $links .= $links != '' ? '
' : ''; - $links .= '' . $link . ''; - } - $output .= ' - - - - '; - $links = ''; - } - $output .= '
' . $row["title"] . '' . $links . '
'."\n"; - return $output; -} - -echo createList($_lang['evo_downloads_title'], $downloadLinks); -echo createList($_lang['help_translating_title'], $translationLinks); - -?> - -
- -
- -
- -
- -
- - - - - - - -
-
- diff --git a/index.php b/index.php index bbdc63e953..f55531a249 100644 --- a/index.php +++ b/index.php @@ -82,7 +82,6 @@ * Function: This file loads and executes the parser. * */ -define("IN_ETOMITE_PARSER", "true"); // provides compatibility with etomite 0.6 and maybe later versions define("IN_PARSER_MODE", "true"); if (!defined('IN_MANAGER_MODE')) { define("IN_MANAGER_MODE", "false"); @@ -107,7 +106,6 @@ // initiate a new document parser include_once(MODX_MANAGER_PATH.'includes/document.parser.class.inc.php'); $modx = new DocumentParser; -$etomite = &$modx; // for backward compatibility // set some parser options $modx->minParserPasses = 1; // min number of parser recursive loops or passes diff --git a/install/actions/action_summary.php b/install/actions/action_summary.php index 6d3de9a77b..973b2d1b49 100644 --- a/install/actions/action_summary.php +++ b/install/actions/action_summary.php @@ -14,15 +14,6 @@ } else { echo "" . $_lang['ok'] . "

"; } -// check php register globals off -echo "

" . $_lang['checking_registerglobals']; -$register_globals = (int) ini_get('register_globals'); -if ($register_globals == '1'){ - echo "" . $_lang['failed']. "

".$_lang['checking_registerglobals_note']."

"; - // $errors += 1; // comment out for now so we still allow installs if folks are simply stubborn -} else { - echo "" . $_lang['ok'] . "

"; -} // check if iconv is available echo "

" . $_lang['checking_iconv']; $iconv = (int) function_exists('iconv'); 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/plugins/qm.tpl b/install/assets/plugins/qm.tpl index 2ec520d45c..546e08963d 100644 --- a/install/assets/plugins/qm.tpl +++ b/install/assets/plugins/qm.tpl @@ -5,9 +5,9 @@ * Enables QuickManager+ front end content editing support * * @category plugin - * @version 1.5.7 + * @version 1.5.8 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL v3) - * @internal @properties &jqpath=Path to jQuery;text;assets/js/jquery.min.js &loadmanagerjq=Load jQuery in manager;list;true,false;false &loadfrontendjq=Load jQuery in front-end;list;true,false;true &noconflictjq=jQuery noConflict mode in front-end;list;true,false;true &loadtb=Load modal box in front-end;list;true,false;true &tbwidth=Modal box window width;text;80% &tbheight=Modal box window height;text;90% &hidefields=Hide document fields from front-end editors;text;parent &hidetabs=Hide document tabs from front-end editors;text; &hidesections=Hide document sections from front-end editors;text; &addbutton=Show add document here button;list;true,false;true &tpltype=New document template type;list;parent,id,selected;parent &tplid=New document template id;int;3 &custombutton=Custom buttons;textarea; &managerbutton=Show go to manager button;list;true,false;true &logout=Logout to;list;manager,front-end;manager &disabled=Plugin disabled on documents;text; &autohide=Autohide toolbar;list;true,false;true &position= Toolbar position;list;top,right,bottom,left,before;top &editbuttons=Inline edit buttons;list;true,false;false &editbclass=Edit button CSS class;text;qm-edit &newbuttons=Inline new resource buttons;list;true,false;false &newbclass=New resource button CSS class;text;qm-new &tvbuttons=Inline template variable buttons;list;true,false;false &tvbclass=Template variable button CSS class;text;qm-tv &removeBg=Remove toolbar background;list;yes,no;no &buttonStyle=QuickManager buttons CSS stylesheet;list;actionButtons,navButtons;actionButtons + * @internal @properties &jqpath=Path to jQuery;text;assets/js/jquery.min.js &loadmanagerjq=Load jQuery in manager;list;true,false;false &loadfrontendjq=Load jQuery in front-end;list;true,false;true &noconflictjq=jQuery noConflict mode in front-end;list;true,false;true &loadfa=Load Font Awesome css in front-end;list;true,false;true &loadtb=Load modal box in front-end;list;true,false;true &tbwidth=Modal box window width;text;80% &tbheight=Modal box window height;text;90% &hidefields=Hide document fields from front-end editors;text;parent &hidetabs=Hide document tabs from front-end editors;text; &hidesections=Hide document sections from front-end editors;text; &addbutton=Show add document here button;list;true,false;true &tpltype=New document template type;list;parent,id,selected;parent &tplid=New document template id;int;3 &custombutton=Custom buttons;textarea; &managerbutton=Show go to manager button;list;true,false;true &logout=Logout to;list;manager,front-end;manager &disabled=Plugin disabled on documents;text; &autohide=Autohide toolbar;list;true,false;true &position= Toolbar position;list;top,right,bottom,left,before;top &editbuttons=Inline edit buttons;list;true,false;false &editbclass=Edit button CSS class;text;qm-edit &newbuttons=Inline new resource buttons;list;true,false;false &newbclass=New resource button CSS class;text;qm-new &tvbuttons=Inline template variable buttons;list;true,false;false &tvbclass=Template variable button CSS class;text;qm-tv &removeBg=Remove toolbar background;list;yes,no;no &buttonStyle=QuickManager buttons CSS stylesheet;list;actionButtons,navButtons;actionButtons * @internal @events OnParseDocument,OnWebPagePrerender,OnDocFormPrerender,OnDocFormSave,OnManagerLogout * @internal @modx_category Manager and Admin * @internal @legacy_names QM+,QuickEdit @@ -18,7 +18,7 @@ * @link http://www.maagit.fi/modx/quickmanager-plus * @author Mikko Lammi * @author Since 2011: yama, dmi3yy, segr, Nicola1971. - * @lastupdate 23/01/2017 + * @lastupdate 21/08/2017 */ // In manager @@ -43,5 +43,5 @@ if ($show) { } } include_once($modx->config['base_path'].'assets/plugins/qm/qm.inc.php'); - $qm = new Qm($modx, $jqpath, $loadmanagerjq, $loadfrontendjq, $noconflictjq, $loadtb, $tbwidth, $tbheight, $hidefields, $hidetabs, $hidesections, $addbutton, $tpltype, $tplid, $custombutton, $managerbutton, $logout, $autohide, $position, $editbuttons, $editbclass, $newbuttons, $newbclass, $tvbuttons, $tvbclass, $buttonStyle, $removeBg); + $qm = new Qm($modx, $jqpath, $loadmanagerjq, $loadfrontendjq, $noconflictjq, $loadfa, $loadtb, $tbwidth, $tbheight, $hidefields, $hidetabs, $hidesections, $addbutton, $tpltype, $tplid, $custombutton, $managerbutton, $logout, $autohide, $position, $editbuttons, $editbclass, $newbuttons, $newbclass, $tvbuttons, $tvbclass, $buttonStyle, $removeBg); } diff --git a/install/assets/plugins/searchhighlight.tpl b/install/assets/plugins/searchhighlight.tpl index 932062c411..5099f73a60 100644 --- a/install/assets/plugins/searchhighlight.tpl +++ b/install/assets/plugins/searchhighlight.tpl @@ -83,17 +83,10 @@ if (isset($_REQUEST['searched']) && isset($_REQUEST['highlight'])) { $dbCharset = $database_connection_charset; $pgCharset = array_key_exists($dbCharset,$pageCharset) ? $pageCharset[$dbCharset] : $dbCharset; - // magic quotes check - if (get_magic_quotes_gpc()){ - $searched = strip_tags(stripslashes($_REQUEST['searched'])); - $highlight = strip_tags(stripslashes($_REQUEST['highlight'])); - if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags(stripslashes($_REQUEST['advsearch'])); - } - else { - $searched = strip_tags($_REQUEST['searched']); - $highlight = strip_tags($_REQUEST['highlight']); - if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags($_REQUEST['advsearch']); - } + $searched = strip_tags($_REQUEST['searched']); + $highlight = strip_tags($_REQUEST['highlight']); + if (isset($_REQUEST['advsearch'])) $advsearch = strip_tags($_REQUEST['advsearch']); + if ($advsearch != 'nowords') { diff --git a/install/assets/plugins/userHelper.tpl b/install/assets/plugins/userHelper.tpl index ffc96893a7..527dbcd9a1 100644 --- a/install/assets/plugins/userHelper.tpl +++ b/install/assets/plugins/userHelper.tpl @@ -5,7 +5,7 @@ * addition to FormLister * * @category plugin - * @version 1.7.3 + * @version 1.7.8 * @internal @properties &logoutKey=Request key;text;logout &cookieName=Cookie Name;text;WebLoginPE &cookieLifetime=Cookie Lifetime, seconds;text;157680000 &maxFails=Max failed logins;text;3 &blockTime=Block for, seconds;text;3600 * @internal @events OnWebPageInit,OnPageNotFound,OnWebLogin * @internal @disabled 1 diff --git a/install/assets/snippets/DLMenu.tpl b/install/assets/snippets/DLMenu.tpl index 511c8132ce..0cd138feb9 100644 --- a/install/assets/snippets/DLMenu.tpl +++ b/install/assets/snippets/DLMenu.tpl @@ -5,7 +5,7 @@ * Snippet to build menu with DocLister * * @category snippet - * @version 1.1.1 + * @version 1.2.0 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL) * @internal @properties * @internal @modx_category Content diff --git a/install/assets/snippets/DLBuildMenu.tpl b/install/assets/snippets/DLSitemap.tpl similarity index 77% rename from install/assets/snippets/DLBuildMenu.tpl rename to install/assets/snippets/DLSitemap.tpl index 333f13606d..469142e56d 100644 --- a/install/assets/snippets/DLBuildMenu.tpl +++ b/install/assets/snippets/DLSitemap.tpl @@ -1,15 +1,15 @@ //=')) { - return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; - } else { - return session_id() === '' ? FALSE : TRUE; - } - } - return FALSE; - } function startCMSSession(){ - - if ( is_session_started() !== FALSE ) return; global $site_sessionname, $https_port; diff --git a/install/connection.collation.php b/install/connection.collation.php index 4d80000ddd..a91eac19df 100644 --- a/install/connection.collation.php +++ b/install/connection.collation.php @@ -14,41 +14,46 @@ } require_once('lang.php'); -if ($conn = mysqli_connect($host, $uid, $pwd)) { - // get collation - $rs = mysqli_query($conn, "SHOW COLLATION"); - if (mysqli_num_rows($rs) > 0) { - $output = ''; +$conn = mysqli_connect($host, $uid, $pwd); +if(!$conn) exit('can not connect'); + +// get collation +$rs = mysqli_query($conn, "SHOW COLLATION"); +if (mysqli_num_rows($rs) > 0) { + $output = ''; } + echo $output; +exit; + + function sortItem($array=array(),$order='utf8mb4,utf8') { $rs = array('recommend'=>''); diff --git a/install/connection.databasetest.php b/install/connection.databasetest.php index e5403a700e..f11b1d0fca 100644 --- a/install/connection.databasetest.php +++ b/install/connection.databasetest.php @@ -20,14 +20,6 @@ $output .= ''.$_lang['status_failed'].''; } else { - if (version_compare(phpversion(), "5.3") < 0) { - if(get_magic_quotes_gpc()) { - $_POST['database_name'] = stripslashes($_POST['database_name']); - $_POST['tableprefix'] = stripslashes($_POST['tableprefix']); - $_POST['database_collation'] = stripslashes($_POST['database_collation']); - $_POST['database_connection_method'] = stripslashes($_POST['database_connection_method']); - } - } $database_name = mysqli_real_escape_string($conn, $_POST['database_name']); $database_name = str_replace("`", "", $database_name); $tableprefix = mysqli_real_escape_string($conn, $_POST['tableprefix']); diff --git a/install/functions.php b/install/functions.php index 47fb063253..1f39dc99d3 100644 --- a/install/functions.php +++ b/install/functions.php @@ -52,7 +52,7 @@ function ph() $ph['pagetitle'] = $_lang['modx_install']; $ph['textdir'] = $modx_textdir ? ' id="rtl"':''; $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; - $ph['version'] = $moduleName.' '.$moduleVersion; + $ph['version'] = $moduleVersion; $ph['release_date'] = ($modx_textdir ? '‏':'') . $modx_release_date; $ph['footer1'] = $_lang['modx_footer1']; $ph['footer2'] = $_lang['modx_footer2']; diff --git a/install/index.php b/install/index.php index 4f4f4cdf18..dbdb283f0f 100644 --- a/install/index.php +++ b/install/index.php @@ -1,12 +1,7 @@ ". $_lang['setup_database_create_connection']; if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { - echo "".$_lang["setup_database_create_connection_failed"]."

".$_lang['setup_database_create_connection_failed_note']."

"; + echo ''.$_lang["setup_database_create_connection_failed"]."

".$_lang['setup_database_create_connection_failed_note']."

"; return; } else { - echo "".$_lang['ok']."

"; + echo ''.$_lang['ok']."

"; } // select database @@ -87,7 +87,7 @@ } else { if (function_exists('mysqli_set_charset')) mysqli_set_charset($conn, $database_charset); mysqli_query($conn, "{$database_connection_method} {$database_connection_charset}"); - echo "".$_lang['ok']."

"; + echo ''.$_lang['ok']."

"; } // try to create the database @@ -95,7 +95,7 @@ echo "

".$_lang['setup_database_creation']. str_replace("`", "", $dbase) . "`: "; // if(!@mysqli_create_db(str_replace("`","",$dbase), $conn)) { if (! mysqli_query($conn, "CREATE DATABASE $dbase DEFAULT CHARACTER SET $database_charset COLLATE $database_collation")) { - echo "".$_lang['setup_database_creation_failed']."".$_lang['setup_database_creation_failed_note']."

"; + echo ''.$_lang['setup_database_creation_failed']."".$_lang['setup_database_creation_failed_note']."

"; $errors += 1; ?>
@@ -107,7 +107,7 @@
 
         return;
     } else {
-        echo "".$_lang['ok']."

"; + echo ''.$_lang['ok']."

"; } } @@ -115,12 +115,12 @@ if ($installMode == 0) { echo "

" . $_lang['checking_table_prefix'] . $table_prefix . "`: "; if (@ $rs = mysqli_query($conn, "SELECT COUNT(*) FROM $dbase.`" . $table_prefix . "site_content`")) { - echo "" . $_lang['failed'] . "" . $_lang['table_prefix_already_inuse'] . "

"; + echo '' . $_lang['failed'] . "" . $_lang['table_prefix_already_inuse'] . "

"; $errors += 1; echo "

" . $_lang['table_prefix_already_inuse_note'] . "

"; return; } else { - echo "" . $_lang['ok'] . "

"; + echo ''.$_lang['ok']."

"; } } @@ -203,7 +203,7 @@ function parseProperties($propertyString) { echo "

" . $_lang['some_tables_not_updated'] . "

"; return; } else { - echo "".$_lang['ok']."

"; + echo ''.$_lang['ok']."

"; } } @@ -247,7 +247,7 @@ function parseProperties($propertyString) { $chmodSuccess = @chmod($filename, 0404); if ($configFileFailed == true) { - echo "" . $_lang['failed'] . "

"; + echo '' . $_lang['failed'] . "

"; $errors += 1; ?>

/includes/config.inc.php

@@ -258,7 +258,7 @@ function parseProperties($propertyString) { " . $_lang['ok'] . "

"; + echo ''.$_lang['ok']."

"; } // generate new site_id and set manager theme to default @@ -295,7 +295,7 @@ function parseProperties($propertyString) { echo "

" . $_lang['some_tables_not_updated'] . "

"; return; } else { - echo "".$_lang['ok']."

"; + echo ''.$_lang['ok']."

"; } } @@ -581,7 +581,7 @@ function parseProperties($propertyString) { } } if($insert === true) { - $properties = mysqli_real_escape_string($conn, parseProperties($properties, true)); + $properties = mysqli_real_escape_string($conn, propUpdate($properties,$row['properties'])); if(!mysqli_query($sqlParser->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; @@ -681,7 +681,7 @@ function parseProperties($propertyString) { $sql = sprintf('UPDATE `%ssite_content` SET template=%s WHERE template=4', $sqlParser->prefix, $row['id']); mysqli_query($sqlParser->conn, $sql); } - echo "".$_lang['ok']."

"; + echo ''.$_lang['ok']."

"; } } diff --git a/install/lang/italian.inc.php b/install/lang/italian.inc.php index 72d51a91c9..5ebe19acb8 100644 --- a/install/lang/italian.inc.php +++ b/install/lang/italian.inc.php @@ -31,10 +31,12 @@ $_lang["btnback_value"] = 'Indietro'; $_lang["btnclose_value"] = 'Chiudi'; $_lang["btnnext_value"] = 'Avanti'; -$_lang["cant_write_config_file"] = 'MODX non è riuscito a salvare il file di configurazione. Vi preghiamo di copiare il seguente testo nel file '; -$_lang["cant_write_config_file_note"] = 'Una volta completata l\'operazione potrete accedere a MODX inserendo nel browser l\'indirizzo vostrosito.it/[+MGR_DIR+]/.'; +$_lang["cant_write_config_file"] = 'EVO non é riuscito a salvare il file di configurazione. Vi preghiamo di copiare il seguente testo nel file '; +$_lang["cant_write_config_file_note"] = 'Una volta completata l\'operazione potrete accedere a EVO inserendo nel browser l\'indirizzo vostrosito.it/[+MGR_DIR+]/.'; $_lang["checkbox_select_options"] = 'Opzioni Checkbox:'; $_lang["checking_if_cache_exist"] = 'Verifico se esistono le directories /assets/cache e /assets/cache/rss : '; +$_lang["checking_iconv"] = 'Controllo se l\'estensione iconv é disponibile: '; +$_lang["checking_iconv_note"] = 'E\' importante installare/abilitare l\'estensione iconv. Contattate il vostro hosting provider se non sapete come fare.'; $_lang["checking_if_cache_file_writable"] = 'Controllo i permessi di scrittura sul file /assets/cache/siteCache.idx.php : '; $_lang["checking_if_cache_file2_writable"] = 'Controllo i permessi di scrittura sul file /assets/cache/sitePublishing.idx.php : '; $_lang["checking_if_cache_writable"] = 'Controllo i permessi di scrittura sulle directories /assets/cache e /assets/cache/rss : '; @@ -43,11 +45,11 @@ $_lang["checking_if_export_writable"] = 'Controllo i permessi di scrittura della directory /assets/export : '; $_lang["checking_if_images_exist"] = 'Controllo se esistono le directories /assets/images, /assets/files, /assets/flash, /assets/media, /assets/backup e /assets/.thumbs : '; $_lang["checking_if_images_writable"] = 'Controllo i permessi di scrittura delle directories /assets/images, /assets/files, /assets/flash, /assets/media, /assets/backup e /assets/.thumbs : '; -$_lang["checking_mysql_strict_mode"] = 'Controllo la modalità strict sql_mode di MySQL: '; +$_lang["checking_mysql_strict_mode"] = 'Controllo la modalità strict sql_mode di MySQL: '; $_lang["checking_mysql_version"] = 'Controllo la versione di MySQL: '; $_lang["checking_php_version"] = 'Controllo la versione di PHP: '; -$_lang["checking_registerglobals"] = 'Controllo se Register_Globals è disattivato: '; -$_lang["checking_registerglobals_note"] = 'Con questa configurazione il vostro sito potrebbe essere vittima di attacchi Cross Site Scripting (XSS). Per disabilitare Register_Globals ci sono diverse alternative: modificare il file php.ini globale, modificare il file .htaccess nella root della vostra installazione MODX, oppure aggiungere dei files php.ini in ogni directory della vostra installazione MODX (ma ci sono molte directories). Potete continuare con l\'installazione, ma non dite che non vi abbiamo avvertito.'; +$_lang["checking_registerglobals"] = 'Controllo se Register_Globals é disattivato: '; +$_lang["checking_registerglobals_note"] = 'Con questa configurazione il vostro sito potrebbe essere vittima di attacchi Cross Site Scripting (XSS). Per disabilitare Register_Globals ci sono diverse alternative: modificare il file php.ini globale, modificare il file .htaccess nella root della vostra installazione EVO, oppure aggiungere dei files php.ini in ogni directory della vostra installazione EVO (ma ci sono molte directories). Potete continuare con l\'installazione, ma non dite che non vi abbiamo avvertito.'; $_lang["checking_sessions"] = 'Controllo se le sessioni sono configurate correttamente: '; $_lang["checking_table_prefix"] = 'Controllo il prefisso per le tabelle `'; $_lang["choose_language"] = 'Scegli la lingua'; @@ -56,7 +58,7 @@ $_lang["connection_screen_collation"] = 'Collation:'; $_lang["connection_screen_connection_method"] = 'Tipo di connessione:'; $_lang["connection_screen_database_connection_information"] = 'Informazioni sul Database'; -$_lang["connection_screen_database_connection_note"] = 'Inserite il nome del database da usare o che volete creare per questa installazione MODX. Se il database non esiste, il programma di installazione proverà a crearlo. Questa operazione potrebbe non riuscire in funzione della vostra configurazione di MySQL.'; +$_lang["connection_screen_database_connection_note"] = 'Inserite il nome del database da usare o che volete creare per questa installazione EVO. Se il database non esiste, il programma di installazione proverà a crearlo. Questa operazione potrebbe non riuscire in funzione della vostra configurazione di MySQL.'; $_lang["connection_screen_database_host"] = 'Server del Database:'; $_lang["connection_screen_database_info"] = 'Informazioni sul Database'; $_lang["connection_screen_database_login"] = 'Nome utente del Database:'; @@ -76,12 +78,12 @@ $_lang["connection_screen_table_prefix"] = 'Prefisso per la Tabella:'; $_lang["creating_database_connection"] = 'Creo la connessione al database: '; $_lang["database_alerts"] = 'Avvisi e Errori del Database!'; -$_lang["database_connection_failed"] = 'La connessione al Database è fallita!'; +$_lang["database_connection_failed"] = 'La connessione al Database é fallita!'; $_lang["database_connection_failed_note"] = 'Vi preghiamo di controllare i dettagli della connessione al database e riprovare.'; $_lang["database_use_failed"] = 'Impossibile selezionare il Database!'; $_lang["database_use_failed_note"] = 'Vi preghiamo di controllare i permessi dell\'utente specificato e riprovare.'; $_lang["default_language"] = 'Lingua di default per il Manager'; -$_lang["default_language_description"] = 'Questa è la lingua che verrà usata nel Manager di MODX.'; +$_lang["default_language_description"] = 'Questa é la lingua che verrà usata nel Manager di EVO.'; $_lang["depedency_create"] = 'Dipendenza creata'; $_lang["depedency_update"] = 'Dipendenza aggiornata'; $_lang["during_execution_of_sql"] = ' durante l\'esecuzione del comando SQL '; @@ -92,8 +94,8 @@ $_lang["guid_set"] = 'GUID impostata'; $_lang["help"] = 'Aiuto!'; $_lang["help_link"] = 'http://forums.modx.com/'; -$_lang["help_title"] = 'Assistenza per l\'installazione nei forums MODX'; -$_lang["iagree_box"] = 'Accetto i termini della licenza MODX. Per una traduzione della licenza GPL versione 2, vi preghiamo di visitare il sito GNU.'; +$_lang["help_title"] = 'Assistenza per l\'installazione nei forums EVO'; +$_lang["iagree_box"] = 'Accetto i termini della licenza EVO. Per una traduzione della licenza GPL versione 2, vi preghiamo di visitare il sito GNU.'; $_lang["install"] = 'Installazione'; $_lang["install_overwrite"] = 'Installazione/Ripristino'; $_lang["install_results"] = 'Risultato dell\'Installazione'; @@ -101,12 +103,12 @@ $_lang["installation_error_occured"] = 'Si sono verificati i seguenti errori durante l\'installazione'; $_lang["installation_install_new_copy"] = 'Installare una nuova copia di '; $_lang["installation_install_new_note"] = 'Vi preghiamo di notare che questa opzione può sovrascrivere i dati preesistenti nel vostro database.'; -$_lang["installation_mode"] = 'Modalità di Installazione'; +$_lang["installation_mode"] = 'Modalità di Installazione'; $_lang["installation_new_installation"] = 'Nuova Installazione'; -$_lang["installation_note"] = 'Nota: Dopo l\'accesso al Manager dovete modificare e salvare la Configurazione di Sistema selezionando Strumenti -> Configurazione di Sistema nel Manager MODX.'; -$_lang["installation_successful"] = 'L\'Installazione è terminata con successo!'; +$_lang["installation_note"] = 'Nota: Dopo l\'accesso al Manager dovete modificare e salvare la Configurazione di Sistema selezionando Strumenti -> Configurazione di Sistema nel Manager EVO.'; +$_lang["installation_successful"] = 'L\'Installazione é terminata con successo!'; $_lang["installation_upgrade_advanced"] = 'Aggiornamento Avanzato'; -$_lang["installation_upgrade_advanced_note"] = 'Per amministratori di database esperti oppure quando è necessario migrare a database con un diverso set di caratteri.
Vi occorre conoscere il nome del database, utente, password e i dettagli della connessione e collation utilizzate.'; +$_lang["installation_upgrade_advanced_note"] = 'Per amministratori di database esperti oppure quando é necessario migrare a database con un diverso set di caratteri.
Vi occorre conoscere il nome del database, utente, password e i dettagli della connessione e collation utilizzate.'; $_lang["installation_upgrade_existing"] = 'Aggiornamento di una installazione esistente'; $_lang["installation_upgrade_existing_note"] = 'Aggiornamento dei files esistenti e del database.'; $_lang["installed"] = 'Installato'; @@ -114,20 +116,20 @@ $_lang["language_code"] = 'en'; $_lang["loading"] = 'Sto caricando...'; $_lang["modules"] = 'Moduli'; -$_lang["modx_footer1"] = '© 2005-[+current_year+] MODX Content Management Framework (CMF) project. Tutti i diritti riservati. MODX è sotto la licenza GNU GPL.'; -$_lang["modx_footer2"] = 'MODX è un software libero. Vi incoraggiamo ad essere creativi e usare MODX come vi pare. Se fate delle modifiche al codice e decidete di ridistribuire il vostro MODX modificato, dovrete distribuire gratuitamente il codice sorgente!'; -$_lang["modx_install"] = 'MODX » Installazione'; -$_lang["modx_requires_php"] = ', e MODx richiede PHP [+min_version+] o successivo'; -$_lang["mysql_5051"] = ' la versione di MySQL è 5.0.51!'; +$_lang["modx_footer1"] = '© 2005-[+current_year+] EVO Content Management Framework (CMF) project. Tutti i diritti riservati. EVO é sotto la licenza GNU GPL.'; +$_lang["modx_footer2"] = 'EVO é un software libero. Vi incoraggiamo ad essere creativi e usare EVO come vi pare. Se fate delle modifiche al codice e decidete di ridistribuire il vostro EVO modificato, dovrete distribuire gratuitamente il codice sorgente!'; +$_lang["modx_install"] = 'EVO » Installazione'; +$_lang["modx_requires_php"] = ', e EVO richiede PHP [+min_version+] o successivo'; +$_lang["mysql_5051"] = ' la versione di MySQL é 5.0.51!'; $_lang["mysql_5051_warning"] = 'Ci sono dei problemi noti con MySQL 5.0.51. Vi consigliamo di aggiornarlo prima di continuare.'; -$_lang["mysql_version_is"] = ' La vostra versione di MySQL è: '; +$_lang["mysql_version_is"] = ' La vostra versione di MySQL é: '; $_lang["no"] = 'No'; $_lang["none"] = 'Nessuno'; $_lang["not_found"] = 'non trovato'; $_lang["ok"] = 'OK!'; $_lang["optional_items"] = 'Componenti Opzionali'; $_lang["optional_items_note"] = 'Vi preghiamo di scegliere le opzioni di installazione e fare click su Installazione:'; -$_lang["php_security_notice"] = 'Avviso di Sicurezza

Anche se MODX funziona con la vostra versione di PHP, vi suggeriamo di non farlo. La vostra versione di PHP ha numerosi problemi di sicurezza. Un aggiornamento a PHP versione 4.3.8 o successiva correggerà questi problemi. Vi raccomandiamo di farlo per garantire la sicurezza del vostro sito web.

'; +$_lang["php_security_notice"] = 'Avviso di Sicurezza

Anche se EVO funziona con la vostra versione di EVO, vi suggeriamo di non farlo. La vostra versione di EVO ha numerosi problemi di sicurezza. Un aggiornamento a PHP versione 4.3.8 o successiva correggerà questi problemi. Vi raccomandiamo di farlo per garantire la sicurezza del vostro sito web.

'; $_lang["please_correct_error"] = '. Vi preghiamo di correggere l\'errore'; $_lang["please_correct_errors"] = '. Vi preghiamo di correggere gli errori'; $_lang["plugins"] = 'Plugins'; @@ -136,30 +138,30 @@ $_lang["recommend_collations_order"] = 'utf8mb4_unicode_ci,utf8mb4_general_ci,utf8_unicode_ci,utf8_general_ci,utf8mb4_bin,utf8_bin,utf8mb4_unicode_520_ci,utf8_unicode_520_ci,utf8_general_mysql500_ci'; $_lang["recommend_setting_change_title"] = 'Modifiche consigliate alla Configurazione'; $_lang["recommend_setting_change_validate_referer_confirmation"] = 'Modifica: Validazione degli headers HTTP_REFERER?'; -$_lang["recommend_setting_change_validate_referer_description"] = 'Il vostro sito non è stato configurato per validare gli headers HTTP_REFERER degli accessi al Manager. Vi raccomandiamo di abilitare questa impostazione per ridurre il rischio di attacchi CSRF (Cross Site Request Forgery).'; +$_lang["recommend_setting_change_validate_referer_description"] = 'Il vostro sito non é stato configurato per validare gli headers HTTP_REFERER degli accessi al Manager. Vi raccomandiamo di abilitare questa impostazione per ridurre il rischio di attacchi CSRF (Cross Site Request Forgery).'; $_lang["remove_install_folder_auto"] = 'Rimuovere la cartella install e i files in essa contenuti
 (Questa operazione richiede i permessi di scrittura nella cartella di installazione).'; -$_lang["remove_install_folder_manual"] = 'Ricordatevi di cancellare la cartella "install" prima di accedere a MODX.'; +$_lang["remove_install_folder_manual"] = 'Ricordatevi di cancellare la cartella "install" prima di accedere a EVO.'; $_lang["resetting_database"] = 'Reset del database per il sito-demo:'; $_lang["retry"] = 'Riprova'; $_lang["running_database_updates"] = 'Esecuzione degli aggiornamenti del database: '; $_lang["sample_web_site"] = 'Sito Web di Esempio'; -$_lang["sample_web_site_note"] = 'Vi preghiamo di notare che questo cancellerà i documenti e le risorse esistenti.'; +$_lang["sample_web_site_note"] = 'Vi preghiamo di notare che questo cancellerà i documenti e le risorse esistenti.'; $_lang["session_problem"] = 'E\' stato riscontrato un problema cone le sessioni del vostro server. Contattare un amministratore di sistema per risolvere il problema.'; $_lang["session_problem_try_again"] = 'Riprovare?'; -$_lang["setup_cannot_continue"] = 'Sfortunatamente il programma di Installazione non può continuare, perchè; '; -$_lang["setup_couldnt_install"] = 'MODX non è riuscito ad installare/modificare alcune tabelle del database selezionato.'; -$_lang["setup_database"] = 'MODX tenterà ora di configurare il database:
'; +$_lang["setup_cannot_continue"] = 'Sfortunatamente il programma di Installazione non può continuare, perché; '; +$_lang["setup_couldnt_install"] = 'EVO non é riuscito ad installare/modificare alcune tabelle del database selezionato.'; +$_lang["setup_database"] = 'EVO tenterà ora di configurare il database:
'; $_lang["setup_database_create_connection"] = 'Creazione della connessione con il database: '; $_lang["setup_database_create_connection_failed"] = 'Impossibile connettersi con il Database!'; $_lang["setup_database_create_connection_failed_note"] = 'Vi preghiamo di controllare i dettagli della connessione al database e riprovare.'; $_lang["setup_database_creating_tables"] = 'Creazione delle tabelle del database: '; $_lang["setup_database_creation"] = 'Creazione del database `'; $_lang["setup_database_creation_failed"] = 'Impossibile creare il Database!'; -$_lang["setup_database_creation_failed_note"] = ' - MODX non è riuscito a creare il database!'; -$_lang["setup_database_creation_failed_note2"] = 'MODX non è riuscito a creare il database e non è stato trovato un database con il nome specificato. Probabilmente il vostro hosting provider non consente a degli script esterni di creare un database. Vi preghiamo di creare manualmente un database ed eseguire nuovamente il programma di installazione.'; +$_lang["setup_database_creation_failed_note"] = ' - EVO non é riuscito a creare il database!'; +$_lang["setup_database_creation_failed_note2"] = 'EVO non é riuscito a creare il database e non é stato trovato un database con il nome specificato. Probabilmente il vostro hosting provider non consente a degli script esterni di creare un database. Vi preghiamo di creare manualmente un database ed eseguire nuovamente il programma di installazione.'; $_lang["setup_database_selection"] = 'Selezione del database `'; $_lang["setup_database_selection_failed"] = 'Impossibile selezionare il Database...'; -$_lang["setup_database_selection_failed_note"] = 'Il database specificato non esiste. MODX proverà a crearlo.'; +$_lang["setup_database_selection_failed_note"] = 'Il database specificato non esiste. EVO proverà a crearlo.'; $_lang["snippets"] = 'Snippets'; $_lang["some_tables_not_updated"] = 'Alcune tabelle non sono state aggiornate, probabilmente a causa di precedenti modifiche.'; $_lang["status_checking_database"] = 'Verifica del database: '; @@ -167,19 +169,19 @@ $_lang["status_failed"] = 'fallita!'; $_lang["status_failed_could_not_create_database"] = 'fallita - impossibile creare il database'; $_lang["status_failed_database_collation_does_not_match"] = 'fallita - problemi con la collation del database; usate SET NAMES o scegliete %s'; -$_lang["status_failed_table_prefix_already_in_use"] = 'fallita - il prefisso scelto per le tabelle è già in uso!'; -$_lang["status_passed"] = 'successo - il database è stato selezionato'; -$_lang["status_passed_database_created"] = 'successo - il database è stato creato'; -$_lang["status_passed_server"] = 'successo - la collation del database è disponibile'; +$_lang["status_failed_table_prefix_already_in_use"] = 'fallita - il prefisso scelto per le tabelle é già in uso!'; +$_lang["status_passed"] = 'successo - il database é stato selezionato'; +$_lang["status_passed_database_created"] = 'successo - il database é stato creato'; +$_lang["status_passed_server"] = 'successo - la collation del database é disponibile'; $_lang["strict_mode"] = ' Il server MySQL ha lo strict sql_mode abilitato!'; -$_lang["strict_mode_error"] = 'Alcune funzionalità di MODX potrebbero non funzionare se STRICT_TRANS_TABLES sql_mode è abilitato. Potete configurare MySQL dal file my.cnf o contattando un amministratore di sistema.'; -$_lang["summary_setup_check"] = 'MODX ha effettuato dei controlli per verificare che tutto sia pronto per l\'installazione.'; +$_lang["strict_mode_error"] = 'Alcune funzionalità di EVO potrebbero non funzionare se STRICT_TRANS_TABLES sql_mode é abilitato. Potete configurare MySQL dal file my.cnf o contattando un amministratore di sistema.'; +$_lang["summary_setup_check"] = 'EVO ha effettuato dei controlli per verificare che tutto sia pronto per l\'installazione.'; $_lang["system_configuration"] = 'Configurazione di Sistema'; -$_lang["system_configuration_validate_referer_description"] = 'L\'opzione di Validazione degli headers HTTP_REFERER è consigliata e vi può proteggere da attacchi CSRF, ma in qualche caso può impedire l\'accesso al Manager.'; -$_lang["table_prefix_already_inuse"] = ' - Il prefisso selezionato per le Tabelle è già in uso in questo database!'; -$_lang["table_prefix_already_inuse_note"] = 'MODX non ha potuto proseguire con l\'installazione nel database selezionato poichè contiene già delle tabelle con il prefisso indicato. Vi preghiamo di scegliere un nuovo prefisso per le tabelle ed eseguire nuovamente il programma di installazione.'; +$_lang["system_configuration_validate_referer_description"] = 'L\'opzione di Validazione degli headers HTTP_REFERER é consigliata e vi può proteggere da attacchi CSRF, ma in qualche caso può impedire l\'accesso al Manager.'; +$_lang["table_prefix_already_inuse"] = ' - Il prefisso selezionato per le Tabelle é già in uso in questo database!'; +$_lang["table_prefix_already_inuse_note"] = 'EVO non ha potuto proseguire con l\'installazione nel database selezionato poiché contiene già delle tabelle con il prefisso indicato. Vi preghiamo di scegliere un nuovo prefisso per le tabelle ed eseguire nuovamente il programma di installazione.'; $_lang["table_prefix_not_exist"] = ' - Il prefisso selezionato per le tabelle non esiste in questo database!'; -$_lang["table_prefix_not_exist_note"] = 'MODX non ha potuto proseguire con l\'installazione nel database selezionato poichè non contiene tabelle da aggiornare con il prefisso indicato. Vi preghiamo di scegliere un prefisso già esistente per le tabelle ed eseguire nuovamente il programma di installazione.'; +$_lang["table_prefix_not_exist_note"] = 'EVO non ha potuto proseguire con l\'installazione nel database selezionato poiché non contiene tabelle da aggiornare con il prefisso indicato. Vi preghiamo di scegliere un prefisso già esistente per le tabelle ed eseguire nuovamente il programma di installazione.'; $_lang["templates"] = 'Templates'; $_lang["to_log_into_content_manager"] = 'Per accedere al Manager ([+MGR_DIR+]/index.php) fate click sul bottone `Chiudi`.'; $_lang["toggle"] = 'Inverti'; @@ -192,11 +194,11 @@ $_lang["upgrade_note"] = 'Nota: Vi preghiamo di accedere al Manager come Amministratore e verificare la Configurazione di Sistema.'; $_lang["upgraded"] = 'Aggiornato'; $_lang["validate_referer_title"] = 'Validazione degli headers HTTP_REFERER?'; -$_lang["visit_forum"] = ', consultate i Forums MODX.'; +$_lang["visit_forum"] = ', consultate i Forums EVO.'; $_lang["warning"] = 'ATTENZIONE!'; -$_lang["welcome_message_start"] = 'Selezionate la modalità di installazione:'; -$_lang["welcome_message_text"] = 'Questo programma vi guiderà attraverso il processo di Installazione.'; -$_lang["welcome_message_welcome"] = 'Benvenuti nel programma di Installazione di MODX.'; +$_lang["welcome_message_start"] = 'Selezionate la modalità di installazione:'; +$_lang["welcome_message_text"] = 'Questo programma vi guiderà attraverso il processo di Installazione.'; +$_lang["welcome_message_welcome"] = 'Benvenuti nel programma di Installazione di EVO.'; $_lang["writing_config_file"] = 'Scrittura del file di configurazione: '; $_lang["yes"] = 'Si'; $_lang["you_running_php"] = ' - State eseguendo PHP '; diff --git a/install/setup.data.reset.sql b/install/setup.data.reset.sql index a52556d71d..7916371d73 100644 --- a/install/setup.data.reset.sql +++ b/install/setup.data.reset.sql @@ -7,19 +7,12 @@ # Empty tables first # - -TRUNCATE TABLE `{PREFIX}site_keywords`; - -TRUNCATE TABLE `{PREFIX}keyword_xref`; - TRUNCATE TABLE `{PREFIX}documentgroup_names`; TRUNCATE TABLE `{PREFIX}site_content`; TRUNCATE TABLE `{PREFIX}site_htmlsnippets`; -TRUNCATE TABLE `{PREFIX}site_keywords`; - TRUNCATE TABLE `{PREFIX}site_plugins`; TRUNCATE TABLE `{PREFIX}site_snippets`; diff --git a/install/setup.data.sql b/install/setup.data.sql index eaac800fff..74f7a25edd 100644 --- a/install/setup.data.sql +++ b/install/setup.data.sql @@ -2,18 +2,6 @@ # # Each sql command is separated by double lines - -# -# Dumping data for table `keyword_xref` -# - - -REPLACE INTO `{PREFIX}keyword_xref` VALUES ('3','1'); - - -REPLACE INTO `{PREFIX}keyword_xref` VALUES ('4','1'); - - # # Dumping data for table `documentgroup_names` # @@ -29,43 +17,43 @@ REPLACE INTO `{PREFIX}documentgroup_names` VALUES ('1','Site Admin Pages','0','0 # Dumping data for table `site_content` # -REPLACE INTO `{PREFIX}site_content` VALUES ('1','document','text/html','Home','Welcome to MODX','Introduction to MODX','index','','1','0','0','0','0','Create and do amazing things with MODX','

Install successful!

\n

You have successfully installed and configured MODX. We hope you find this site an adequate starting configuration for many small business, organization or personal websites; just change the template and content, and you\'ll be good to go! This site is preconfigured with a variety of options we hope are helpful, relevant and just plain cool for many marketing or personal sites:

\n
    \n
  • Simple Blog. When logged into your site, you\'ll be able to create new entries from the front end. This can also be turned into a News publishing or PR publishing system. View example blog
  • \n
  • Easy Comments. When logged into your site, your registered site users can comment on your posts. View example
  • \n
  • RSS Feeds. Your site visitors can stay up to date using your site feeds. View RSS feed
  • \n
  • Automatic User Registration. Those that wish to comment on blogs must first create an account. This comes pre-configured with a \"Captcha\" anti-robot registration feature. View registration form
  • \n
  • QuickEdit. When you\'re logged into the manager, you can edit a page directly from the front end! More about CMS features
  • \n
  • Integrated Site Search. Allows visitors to search only the pages you wish them to search. Uses Ajax to display results without loading a new page.
  • \n
  • Powerful Navigation Builder. Duplicate or build virtually any navigation system with our dynamic menu builder code. The menu above, for example. More about menu features
  • \n
  • Ajax ready. You\'re on your way to Web 2.0 and AJAX goodness. More about Ajax features
  • \n
  • Custom \"page not found (404)\" page. Help visitors who go astray to find what they\'re looking for. View 404 page
  • \n
  • Contact Us form. A highly configurable contact form you should customize to point to the right email address. Comes pre-configured to prevent mail-form-injection so your site does not become a source for spam. View form
  • \n
  • Newest documents list. Shows your visitor the most recently added pages (configurable).
  • \n
  • Customizable Content Manager. Preview uploaded images, hide or rename fields and lots more. See ManagerManager\'s documentation for details and instructions. Quick start: ManagerManager by default will look for \"rules\" in a Chunk named \"mm_rules\". Simply copy or rename the Chunk named \"mm_demo_rules\" to \"mm_rules\" and try it out!
  • \n
  • phpThumb. Examples to use phpThumb to crop images.
  • \n
\n

Full documentation can be found on the official documentation site.

\n

To log into the MODX Control Panel and start customizing this site, point your browser to /manager/.

','1','{BOOTSTRAP_SQL_ID}','0','1','1','1','1144904400','1','1378084284','0','0','0','0','0','Home','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('1','document','text/html','Home','Welcome to MODX','Introduction to MODX','index','','1','0','0','0','0','Create and do amazing things with MODX','

Install successful!

\n

You have successfully installed and configured MODX. We hope you find this site an adequate starting configuration for many small business, organization or personal websites; just change the template and content, and you\'ll be good to go! This site is preconfigured with a variety of options we hope are helpful, relevant and just plain cool for many marketing or personal sites:

\n
    \n
  • Simple Blog. When logged into your site, you\'ll be able to create new entries from the front end. This can also be turned into a News publishing or PR publishing system. View example blog
  • \n
  • Easy Comments. When logged into your site, your registered site users can comment on your posts. View example
  • \n
  • RSS Feeds. Your site visitors can stay up to date using your site feeds. View RSS feed
  • \n
  • Automatic User Registration. Those that wish to comment on blogs must first create an account. This comes pre-configured with a \"Captcha\" anti-robot registration feature. View registration form
  • \n
  • QuickEdit. When you\'re logged into the manager, you can edit a page directly from the front end! More about CMS features
  • \n
  • Integrated Site Search. Allows visitors to search only the pages you wish them to search. Uses Ajax to display results without loading a new page.
  • \n
  • Powerful Navigation Builder. Duplicate or build virtually any navigation system with our dynamic menu builder code. The menu above, for example. More about menu features
  • \n
  • Ajax ready. You\'re on your way to Web 2.0 and AJAX goodness. More about Ajax features
  • \n
  • Custom \"page not found (404)\" page. Help visitors who go astray to find what they\'re looking for. View 404 page
  • \n
  • Contact Us form. A highly configurable contact form you should customize to point to the right email address. Comes pre-configured to prevent mail-form-injection so your site does not become a source for spam. View form
  • \n
  • Newest documents list. Shows your visitor the most recently added pages (configurable).
  • \n
  • Customizable Content Manager. Preview uploaded images, hide or rename fields and lots more. See ManagerManager\'s documentation for details and instructions. Quick start: ManagerManager by default will look for \"rules\" in a Chunk named \"mm_rules\". Simply copy or rename the Chunk named \"mm_demo_rules\" to \"mm_rules\" and try it out!
  • \n
  • phpThumb. Examples to use phpThumb to crop images.
  • \n
\n

Full documentation can be found on the official documentation site.

\n

To log into the MODX Control Panel and start customizing this site, point your browser to /manager/.

','1','{BOOTSTRAP_SQL_ID}','0','1','1','1','1144904400','1','1378084284','0','0','0','0','0','Home','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('2','document','text/html','Blog','My Blog','','blog','','1','0','0','0','1','','[[Ditto? &parents=`2` &display=`2` &removeChunk=`Comments` &tpl=`ditto_blog` &paginate=`1` &extenders=`summary,dateFilter` &paginateAlwaysShowLinks=`1` &tagData=`documentTags`]]\n\n

Showing [+start+] - [+stop+] of [+total+] Articles

\n\n
[+previous+] [+pages+] [+next+]
\n\n
 
\n\n[[Reflect? &config=`wordpress` &dittoSnippetParameters=`parents:2` &id=`wp` &getDocuments=`1`]]','1','{BOOTSTRAP_SQL_ID}','1','0','0','1','1144904400','1','1159818696','0','0','0','0','0','Blog','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('2','document','text/html','Blog','My Blog','','blog','','1','0','0','0','1','','[[Ditto? &parents=`2` &display=`2` &removeChunk=`Comments` &tpl=`ditto_blog` &paginate=`1` &extenders=`summary,dateFilter` &paginateAlwaysShowLinks=`1` &tagData=`documentTags`]]\n\n

Showing [+start+] - [+stop+] of [+total+] Articles

\n\n
[+previous+] [+pages+] [+next+]
\n\n
 
\n\n[[Reflect? &config=`wordpress` &dittoSnippetParameters=`parents:2` &id=`wp` &getDocuments=`1`]]','1','{BOOTSTRAP_SQL_ID}','1','0','0','1','1144904400','1','1159818696','0','0','0','0','0','Blog','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('4','document','text/html','[*loginName*]','Login to Enable to Comments','','login','','1','0','0','0','0','','

In order to comment on blog entries, you must be a registered user of [(site_name)]. If you haven\'t already registered, you can request an account.

\n
[!WebLogin? &tpl=`WebLogin_tplForm` &loginhomeid=`2`!]
','1','{BOOTSTRAP_SQL_ID}','9','0','0','1','1144904400','1','1144904400','0','0','0','0','0','[*loginName*]','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('4','document','text/html','[*loginName*]','Login to Enable to Comments','','login','','1','0','0','0','0','','

In order to comment on blog entries, you must be a registered user of [(site_name)]. If you haven\'t already registered, you can request an account.

\n
[!WebLogin? &tpl=`WebLogin_tplForm` &loginhomeid=`2`!]
','1','{BOOTSTRAP_SQL_ID}','9','0','0','1','1144904400','1','1144904400','0','0','0','0','0','[*loginName*]','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('5','document','text/html','Request an Account','Sign Up for Full Site Privileges','','request-an-account','','1','0','0','0','0','','[[WebSignup? &tpl=`FormSignup` &groups=`Registered Users`]]','1','{BOOTSTRAP_SQL_ID}','7','0','0','1','1144904400','1','1158320704','0','0','0','0','0','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('5','document','text/html','Request an Account','Sign Up for Full Site Privileges','','request-an-account','','1','0','0','0','0','','[[WebSignup? &tpl=`FormSignup` &groups=`Registered Users`]]','1','{BOOTSTRAP_SQL_ID}','7','0','0','1','1144904400','1','1158320704','0','0','0','0','0','','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('6','document','text/html','Contact Us','Contact [(site_name)]','','contact-us','','1','0','0','0','0','','\n\n[!eForm? \n &formid=`ContactForm`\n &vericode=`1`\n &subject=`[+subject+]`\n &to=`[(emailsender)]` \n &ccsender=`1`\n &tpl=`ContactForm`\n &report=`ContactFormReport`\n &invalidClass=`invalidValue`\n &requiredClass=`requiredValue`\n &gotoid=`46`\n!]\n','0','{BOOTSTRAP_SQL_ID}','5','1','0','1','1144904400','1','1159303922','0','0','0','0','0','Contact us','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('6','document','text/html','Contact Us','Contact [(site_name)]','','contact-us','','1','0','0','0','0','','\n\n[!eForm? \n &formid=`ContactForm`\n &vericode=`1`\n &subject=`[+subject+]`\n &to=`[(emailsender)]` \n &ccsender=`1`\n &tpl=`ContactForm`\n &report=`ContactFormReport`\n &invalidClass=`invalidValue`\n &requiredClass=`requiredValue`\n &gotoid=`46`\n!]\n','0','{BOOTSTRAP_SQL_ID}','5','1','0','1','1144904400','1','1159303922','0','0','0','0','0','Contact us','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('7','document','text/html','404 - Document Not Found','Uh oh ... it\'s a 404! (Page Not Found)','','doc-not-found','','1','0','0','0','0','','

Looks like you tried to go somewhere that does not exist... perhaps you need to login or you\'d like one of the following pages instead:

\n\n[[Wayfinder? &startId=`0` &showDescription=`1`]]\n\n

Want to find it the old fashioned way? Use the site search at the top of this site to find what you seek.

\n\n','1','{BOOTSTRAP_SQL_ID}','12','0','1','1','1144904400','1','1159301173','0','0','0','0','0','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('7','document','text/html','404 - Document Not Found','Uh oh ... it\'s a 404! (Page Not Found)','','doc-not-found','','1','0','0','0','0','','

Looks like you tried to go somewhere that does not exist... perhaps you need to login or you\'d like one of the following pages instead:

\n\n[[Wayfinder? &startId=`0` &showDescription=`1`]]\n\n

Want to find it the old fashioned way? Use the site search at the top of this site to find what you seek.

\n\n','1','{BOOTSTRAP_SQL_ID}','12','0','1','1','1144904400','1','1159301173','0','0','0','0','0','','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('8','document','text/html','Search Results','Your Search Results','','search-results','','1','0','0','0','0','','[!AjaxSearch? &showInputForm=`0` &ajaxSearch=`0`!]','0','{BOOTSTRAP_SQL_ID}','10','0','0','1','1144904400','1','1158613055','0','0','0','0','0','','1','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('8','document','text/html','Search Results','Your Search Results','','search-results','','1','0','0','0','0','','[!AjaxSearch? &showInputForm=`0` &ajaxSearch=`0`!]','0','{BOOTSTRAP_SQL_ID}','10','0','0','1','1144904400','1','1158613055','0','0','0','0','0','','1','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('9','document','text/html','Mini-Blog HOWTO','How to Start Posting with MODX Mini-Blogs','','article-1126081344','','1','0','0','2','0','','

Setting up a mini-blog is relatively simple. Here\'s what you need to do to get started with making new posts:

\n
    \n
  1. Login to the MODX Control Panel.
  2. \n
  3. Press the plus-sign next to the Blog(2) container resource to see the blog entries posted there.
  4. \n
  5. To make a new Blog entry, simply right-click the Blog container document and choose the \"Create Resource here\" menu option. To edit an existing blog article, right click the entry and choose the \"Edit Resource\" menu option.
  6. \n\n
  7. Write or edit the content and press save, making sure the document is published.
  8. \n
  9. Everything else is automatic; you\'re done!
  10. \n
\n{{Comments}}','1','{BOOTSTRAP_SQL_ID}','0','1','1','-1','1144904400','1','1378084370','0','0','0','0','0','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('9','document','text/html','Mini-Blog HOWTO','How to Start Posting with MODX Mini-Blogs','','article-1126081344','','1','0','0','2','0','','

Setting up a mini-blog is relatively simple. Here\'s what you need to do to get started with making new posts:

\n
    \n
  1. Login to the MODX Control Panel.
  2. \n
  3. Press the plus-sign next to the Blog(2) container resource to see the blog entries posted there.
  4. \n
  5. To make a new Blog entry, simply right-click the Blog container document and choose the \"Create Resource here\" menu option. To edit an existing blog article, right click the entry and choose the \"Edit Resource\" menu option.
  6. \n\n
  7. Write or edit the content and press save, making sure the document is published.
  8. \n
  9. Everything else is automatic; you\'re done!
  10. \n
\n{{Comments}}','1','{BOOTSTRAP_SQL_ID}','0','1','1','-1','1144904400','1','1378084370','0','0','0','0','0','','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('11','document','text/xml','RSS Feed','[(site_name)] RSS Feed','','feed.rss','','1','0','0','0','0','','[[Ditto? &parents=`2` &format=`rss` &display=`20` &total=`20` &removeChunk=`Comments`]]','0','0','11','0','0','1','1144904400','1','1160062859','0','0','0','0','0','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('11','document','text/xml','RSS Feed','[(site_name)] RSS Feed','','feed.rss','','1','0','0','0','0','','[[Ditto? &parents=`2` &format=`rss` &display=`20` &total=`20` &removeChunk=`Comments`]]','0','0','11','0','0','1','1144904400','1','1160062859','0','0','0','0','0','','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('14','document','text/html','Content Management','Ways to manage content','','cms','','1','0','0','15','0','','

Manage your content in the backend

\n

The Manager is a skinnable feature-packed tool for admin users. You can add extra users and limit what functions they can access. MODX\'s Manager makes creating content and managing templates and reusable elements easy. Modules can be added to work with other datasets or make management tasks easier.

\n

Manage your content in the frontend

\n

The QuickEdit bar lets manager users edit content whilst browsing the site. Most content fields and template variables can be edited quickly and easily.

\n

Enable web users to add content

\n

Custom data entry is easy to code using the MODX API - so you can design forms and collect whatever information you need.

','1','{BOOTSTRAP_SQL_ID}','3','1','1','1','1144904400','1','1378086298','0','0','0','1378086298','1','Manage Content','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('14','document','text/html','Content Management','Ways to manage content','','cms','','1','0','0','15','0','','

Manage your content in the backend

\n

The Manager is a skinnable feature-packed tool for admin users. You can add extra users and limit what functions they can access. MODX\'s Manager makes creating content and managing templates and reusable elements easy. Modules can be added to work with other datasets or make management tasks easier.

\n

Manage your content in the frontend

\n

The QuickEdit bar lets manager users edit content whilst browsing the site. Most content fields and template variables can be edited quickly and easily.

\n

Enable web users to add content

\n

Custom data entry is easy to code using the MODX API - so you can design forms and collect whatever information you need.

','1','{BOOTSTRAP_SQL_ID}','3','1','1','1','1144904400','1','1378086298','0','0','0','1378086298','1','Manage Content','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('15','document','text/html','MODX Features','MODX Features','','features','','1','0','0','0','1','','[[Wayfinder?startId=`[*id*]` &outerClass=`topnav`]]','1','{BOOTSTRAP_SQL_ID}','2','1','1','1','1144904400','1','1158452722','0','0','0','1144777367','1','Features','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('15','document','text/html','MODX Features','MODX Features','','features','','1','0','0','0','1','','[[Wayfinder?startId=`[*id*]` &outerClass=`topnav`]]','1','{BOOTSTRAP_SQL_ID}','2','1','1','1','1144904400','1','1158452722','0','0','0','1144777367','1','Features','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('16','document','text/html','Ajax','Ajax and Web 2.0 ready','','ajax','','1','1159264800','0','15','0','','Ajax ready out-of-the-box\n

MODX empowers users to build engaging sites today, with its pre-integrated Mootools javascript library.

\n\n

Check out the Ajax-powered search in this example site. The libraries are also used with QuickEdit, our front-end editing tool.

\n\n

Smart integration means the scripts are only included in the document head when needed - no unnecessary bloat on simple pages!

\n\nWeb 2.0 today\n

MODX makes child\'s play of building content managed sites with validating, accessible CSS layouts - so web standards compliance is easy. (You can create a site with excessively nested tables too, if you really want to).

\n','1','{BOOTSTRAP_SQL_ID}','1','1','1','1','1144904400','1','1159307504','0','0','0','0','0','Ajax','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('16','document','text/html','Ajax','Ajax and Web 2.0 ready','','ajax','','1','1159264800','0','15','0','','Ajax ready out-of-the-box\n

MODX empowers users to build engaging sites today, with its pre-integrated Mootools javascript library.

\n\n

Check out the Ajax-powered search in this example site. The libraries are also used with QuickEdit, our front-end editing tool.

\n\n

Smart integration means the scripts are only included in the document head when needed - no unnecessary bloat on simple pages!

\n\nWeb 2.0 today\n

MODX makes child\'s play of building content managed sites with validating, accessible CSS layouts - so web standards compliance is easy. (You can create a site with excessively nested tables too, if you really want to).

\n','1','{BOOTSTRAP_SQL_ID}','1','1','1','1','1144904400','1','1159307504','0','0','0','0','0','Ajax','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('18','document','text/html','Just a pretend, older post','This post should in fact be archived','','article-1128398162','','1','0','0','2','0','','

Not so exciting, after all, eh?

\n','1','{BOOTSTRAP_SQL_ID}','2','1','1','-1','1144904400','1','1159306886','0','0','0','0','0','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('18','document','text/html','Just a pretend, older post','This post should in fact be archived','','article-1128398162','','1','0','0','2','0','','

Not so exciting, after all, eh?

\n','1','{BOOTSTRAP_SQL_ID}','2','1','1','-1','1144904400','1','1159306886','0','0','0','0','0','','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('22','document','text/html','Menus and Lists','Flexible Menus and Lists','','menus','','1','1159178400','0','15','0','','

Your documents - listed how you want them

\n

MODX\'s document data structure has been designed to allow many different routines to redisplay the information in ways that suit your needs, such as a dynamic menu in your template.

\n

Since the last release of MODX, the community has produced many great snippets - reusable functions that you can call in your content or template. Two of the most widely useful are Ditto and Wayfinder.

\n

Wayfinder - the menu builder

\n

Allows you to template every part of the menu. On this site, Wayfinder is being used to generate the drop-down menus, but many types of menus and sitemaps are possible.

\n

Ditto - the document lister

\n

Uses include listing the most recent blog posts, producing a site map, listing related documents (using a TV filter) and generating an RSS feed. You could even write a menu with it. On this site, Ditto is being used for the blog posts list on the Blog page, and the list on the right of some templates.

\n

Unlimited Customization

\n

If you can\'t quite get your desired effect using templating and the many options of Ditto and Wayfinder, you can write your own routine, or look for other snippets in the MODX repository. MODX\'s fields for Menu Title, summaries, menu position etc can be used via the API to produce anything you can imagine.

','1','{BOOTSTRAP_SQL_ID}','2','1','1','1','1144904400','1','1160148522','0','0','0','0','0','Menus and Lists','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('22','document','text/html','Menus and Lists','Flexible Menus and Lists','','menus','','1','1159178400','0','15','0','','

Your documents - listed how you want them

\n

MODX\'s document data structure has been designed to allow many different routines to redisplay the information in ways that suit your needs, such as a dynamic menu in your template.

\n

Since the last release of MODX, the community has produced many great snippets - reusable functions that you can call in your content or template. Two of the most widely useful are Ditto and Wayfinder.

\n

Wayfinder - the menu builder

\n

Allows you to template every part of the menu. On this site, Wayfinder is being used to generate the drop-down menus, but many types of menus and sitemaps are possible.

\n

Ditto - the document lister

\n

Uses include listing the most recent blog posts, producing a site map, listing related documents (using a TV filter) and generating an RSS feed. You could even write a menu with it. On this site, Ditto is being used for the blog posts list on the Blog page, and the list on the right of some templates.

\n

Unlimited Customization

\n

If you can\'t quite get your desired effect using templating and the many options of Ditto and Wayfinder, you can write your own routine, or look for other snippets in the MODX repository. MODX\'s fields for Menu Title, summaries, menu position etc can be used via the API to produce anything you can imagine.

','1','{BOOTSTRAP_SQL_ID}','2','1','1','1','1144904400','1','1160148522','0','0','0','0','0','Menus and Lists','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('24','document','text/html','Extendable by design','Extendable by design','','extendable','','1','1159092732','0','15','0','','

The MODX community has created many add-ons which can be found in the Repository, from image galleries and e-commerce to smaller utilities.

\n

Template Variables with Bindings

\n

TVs - Template Variables - are powerful extra fields that you can use with your documents. As an example of an advanced template element that returns a different thing dependent on code or data, we created an @BINDING for the name of the Login menu item. This changes the menu name from Login to Logout based on your logged in state. The @BINDING as follows was placed in the default value as: @EVAL if ($modx->getLoginUserID()) return \'Logout\'; else return \'Login\';

\n

Using jQuery-effects

\n

We used some simple effects to highlight various things on the front/home page to demonstrate how easy it is to create a useful way to draw attention to things. To see them in action on the home page, click the Integrated Site Search, Related Links or Newest Documents headers.

\n

Custom Forms

\n

To demonstrate how to link to custom forms, we customized the calls to the Webuser Registration system and the Login system.

\n

And more

\n

Rich Text Editor for blog entries. To make it easier to format blog posts with simple text formatting, we modified the blog to use a custom RTE-enabled Template Variable (TV).

\n

Smart-Summary logic. When splitting the full blog/news posts you simply insert a \"<!-- splitter -->\" where you want the break to occur. In addition, if that leaves any important tags open, it will try to match them and close them so it doesn\'t mess up your site layout with unclosed OL, UL or DIV tags.

','1','{BOOTSTRAP_SQL_ID}','4','1','1','2','1144904400','1','1159309971','0','0','0','0','0','Extendability','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('24','document','text/html','Extendable by design','Extendable by design','','extendable','','1','1159092732','0','15','0','','

The MODX community has created many add-ons which can be found in the Repository, from image galleries and e-commerce to smaller utilities.

\n

Template Variables with Bindings

\n

TVs - Template Variables - are powerful extra fields that you can use with your documents. As an example of an advanced template element that returns a different thing dependent on code or data, we created an @BINDING for the name of the Login menu item. This changes the menu name from Login to Logout based on your logged in state. The @BINDING as follows was placed in the default value as: @EVAL if ($modx->getLoginUserID()) return \'Logout\'; else return \'Login\';

\n

Using jQuery-effects

\n

We used some simple effects to highlight various things on the front/home page to demonstrate how easy it is to create a useful way to draw attention to things. To see them in action on the home page, click the Integrated Site Search, Related Links or Newest Documents headers.

\n

Custom Forms

\n

To demonstrate how to link to custom forms, we customized the calls to the Webuser Registration system and the Login system.

\n

And more

\n

Rich Text Editor for blog entries. To make it easier to format blog posts with simple text formatting, we modified the blog to use a custom RTE-enabled Template Variable (TV).

\n

Smart-Summary logic. When splitting the full blog/news posts you simply insert a \"<!-- splitter -->\" where you want the break to occur. In addition, if that leaves any important tags open, it will try to match them and close them so it doesn\'t mess up your site layout with unclosed OL, UL or DIV tags.

','1','{BOOTSTRAP_SQL_ID}','4','1','1','2','1144904400','1','1159309971','0','0','0','0','0','Extendability','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('32','document','text/html','Design','Site Design','','design','','1','0','0','0','0','','

Credits

\n

The MODX Starter-theme is based on Bootstrap 3.3.6 and made by graffx.nl and fuseit.de.

','1','{BOOTSTRAP_SQL_ID}','4','1','1','2','1144904400','1','1160112322','0','0','0','1144912754','1','Design','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('32','document','text/html','Design','Site Design','','design','','1','0','0','0','0','','

Credits

\n

The MODX Starter-theme is based on Bootstrap 3.3.6 and made by graffx.nl and fuseit.de.

','1','{BOOTSTRAP_SQL_ID}','4','1','1','2','1144904400','1','1160112322','0','0','0','1144912754','1','Design','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('33','document','text/html','Getting Help','Getting Help with MODX','','getting-help','','1','0','0','0','0','','

The team behind MODX strives to constantly add to and refine the documentation to help you get up to speed with MODX:

\n
    \n
  • For basic instructions on integrating custom templates into MODX, please see the Designer\'s Guide.
  • \n
  • For an introduction to working in MODX from the content editors perspectve, see the Content Editor\'s Guide.
  • \n
  • For a detailed overview of the backend "manager" and setting up Users and Groups, please peruse the Administration Guide.
  • \n
  • For developers, architecture and API documentation can be found in the Developer\'s Guide.
  • \n
  • And if someone has installed this site for you, but you\'re curious as to the steps they went through, please see the Getting Started Guide.
  • \n
\n\n

And don\'t forget, you can always learn and ask questions at the MODX forums. \n','1','{BOOTSTRAP_SQL_ID}','3','1','1','2','1144904400','2','1144904400','0','0','0','0','0','Getting Help','0','0','0','0','0','0','0','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('33','document','text/html','Getting Help','Getting Help with MODX','','getting-help','','1','0','0','0','0','','

The team behind MODX strives to constantly add to and refine the documentation to help you get up to speed with MODX:

\n
    \n
  • For basic instructions on integrating custom templates into MODX, please see the Designer\'s Guide.
  • \n
  • For an introduction to working in MODX from the content editors perspectve, see the Content Editor\'s Guide.
  • \n
  • For a detailed overview of the backend "manager" and setting up Users and Groups, please peruse the Administration Guide.
  • \n
  • For developers, architecture and API documentation can be found in the Developer\'s Guide.
  • \n
  • And if someone has installed this site for you, but you\'re curious as to the steps they went through, please see the Getting Started Guide.
  • \n
\n\n

And don\'t forget, you can always learn and ask questions at the MODX forums. \n','1','{BOOTSTRAP_SQL_ID}','3','1','1','2','1144904400','2','1144904400','0','0','0','0','0','Getting Help','0','0','0','0','0','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('37','document','text/html','[*loginName*]','The page you\'re trying to reach requires a login','','blog-login','','1','0','0','0','0','','

In order to add a blog entry, you must be logged in as a Site Admin webuser. Also, commenting on posts requires a login. Contact the site owner for permissions to create new post, or create a web user account to automatically receive commenting privileges. If you already have an account, please login below.

\n\n[!WebLogin? &tpl=`WebLogin_tplForm` &loginhomeid=`3`!]','1','{BOOTSTRAP_SQL_ID}','8','0','0','1','1144904400','1','1158599931','0','0','0','0','0','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('37','document','text/html','[*loginName*]','The page you\'re trying to reach requires a login','','blog-login','','1','0','0','0','0','','

In order to add a blog entry, you must be logged in as a Site Admin webuser. Also, commenting on posts requires a login. Contact the site owner for permissions to create new post, or create a web user account to automatically receive commenting privileges. If you already have an account, please login below.

\n\n[!WebLogin? &tpl=`WebLogin_tplForm` &loginhomeid=`3`!]','1','{BOOTSTRAP_SQL_ID}','8','0','0','1','1144904400','1','1158599931','0','0','0','0','0','','0','0','0','0','1','1'); -REPLACE INTO `{PREFIX}site_content` VALUES ('46','document','text/html','Thank You','','','thank-you','','1','0','0','0','0','','

Thank You!

\n

We do appreciate your feedback. Your comments have been submitted to our office and hopefully someone will bother to actually read it. You should also receive a copy of the message in your inbox.

\n

Please be assured that we will do our best not to ignore you, but if today is a Monday please try again in a few days.

\n','1','{BOOTSTRAP_SQL_ID}','6','1','1','1','1159302141','1','1159302892','0','0','0','1159302182','1','','0','0','0','0','0','0','1','1'); +REPLACE INTO `{PREFIX}site_content` VALUES ('46','document','text/html','Thank You','','','thank-you','','1','0','0','0','0','','

Thank You!

\n

We do appreciate your feedback. Your comments have been submitted to our office and hopefully someone will bother to actually read it. You should also receive a copy of the message in your inbox.

\n

Please be assured that we will do our best not to ignore you, but if today is a Monday please try again in a few days.

\n','1','{BOOTSTRAP_SQL_ID}','6','1','1','1','1159302141','1','1159302892','0','0','0','1159302182','1','','0','0','0','0','1','1'); # @@ -73,47 +61,28 @@ REPLACE INTO `{PREFIX}site_content` VALUES ('46','document','text/html','Thank Y # -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'FormSignup', 'For the weblogin signup', 0, 'none', 2, 0, ' \n\n
\n\n

User Details

\n
\n \n Items marked by * are required
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n\n
\n

Password

\n \n \n
\n
\n \n \n
\n \n
\n

Optional Account Profile Info

\n \n \n
\n \n
\n

Bot-Patrol

\n

Enter the word/number combination shown in the image below.

\n

If you have trouble reading the code, click on the code itself to generate a new random code.

\n \n
\n \n
\n \n
\n\n
\n\n\n
\n\n

Signup completed successfully!
\nYour account was created. A copy of your signup information was sent to your email address.

\n', 0); - - -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'nl_sidebar', 'Default Template TPL for Ditto', 0, 'none', 1, 0, '[+title+]
\n[+longtitle+]

', 0); - +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'FormSignup', 'For the weblogin signup', 0, 'none', 2, 0, ' \n\n
\n\n

User Details

\n
\n \n Items marked by * are required
\n
\n \n \n
\n
\n \n \n
\n
\n \n \n
\n\n
\n

Password

\n \n \n
\n
\n \n \n
\n \n
\n

Optional Account Profile Info

\n \n \n
\n \n
\n

Bot-Patrol

\n

Enter the word/number combination shown in the image below.

\n

If you have trouble reading the code, click on the code itself to generate a new random code.

\n \n
\n \n
\n \n
\n\n
\n\n\n
\n\n

Signup completed successfully!
\nYour account was created. A copy of your signup information was sent to your email address.

\n', 0, UNIX_TIMESTAMP(), 0, 0); -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ditto_blog', 'Blog Template', 0, 'none', 1, 0, '
\n \n \n \n \n

[+title+]

\n \n \n [+summary+]\n \n
','0'); +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'nl_sidebar', 'Default Template TPL for Ditto', 0, 'none', 1, 0, '[+title+]
\n[+longtitle+]

', 0, UNIX_TIMESTAMP(), 0, 0); -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'Comments', 'Comments (Jot) showing beneath a blog entry.', 0, 'none', 1, 0, '
\r\n[!Jot? &customfields=`name,email` &subscribe=`1` &pagination=`4` &badwords=`dotNet` &canmoderate=`Site Admins` &tplForm=`Comments_tplForm` &tplComments=`Comments_tplComments`!]\r\n
', 0); +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ditto_blog', 'Blog Template', 0, 'none', 1, 0, '
\n \n \n \n \n

[+title+]

\n \n \n [+summary+]\n \n
','0', UNIX_TIMESTAMP(), 0, 0); -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ContactForm', 'eForm-template for showing contact-form', 0, 'none', 1, 0, '
\n \n \n \n \n \n
\n \n \n
\n
\n \n \n
\n \n
\n \n \n
\n \n
\n \n \n
\n \n \n
\n
\n
\n verification code\n
\n
\n \n
\n
\n
\n \n
\n \n
\n\n
\n\n\n', 0); - - -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ContactFormReport', 'eForm-template for sending form-data by mail', 0, 'none', 1, 0, '

This is a response sent by [+name+] using the feedback form on the website. The details of the message follow below:

\r\n\r\n\r\n

Name: [+name+]

\r\n

Email: [+email+]

\r\n

Regarding: [+subject+]

\r\n

comments:
[+message+]

\r\n\r\n

You can use this link to reply: [+email+]

\r\n', 0); - - -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'reflect_month_tpl', 'For the yearly archive. Use with Ditto.', 0, 'none', 1, 0, '[+month+] [+year+]', 0); - - -INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ContactStyles', 'Styles for form validation', 0, 'none', 1, 0, '', 0); - - - -# -# Dumping data for table `site_keywords` -# +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'Comments', 'Comments (Jot) showing beneath a blog entry.', 0, 'none', 1, 0, '
\r\n[!Jot? &customfields=`name,email` &subscribe=`1` &pagination=`4` &badwords=`dotNet` &canmoderate=`Site Admins` &tplForm=`Comments_tplForm` &tplComments=`Comments_tplComments`!]\r\n
', 0, UNIX_TIMESTAMP(), 0, 0); -REPLACE INTO `{PREFIX}site_keywords` VALUES ('1','MODX'); +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ContactForm', 'eForm-template for showing contact-form', 0, 'none', 1, 0, '
\n \n \n \n \n \n
\n \n \n
\n
\n \n \n
\n \n
\n \n \n
\n \n
\n \n \n
\n \n \n
\n
\n
\n verification code\n
\n
\n \n
\n
\n
\n \n
\n \n
\n\n
\n\n\n', 0, UNIX_TIMESTAMP(), 0, 0); -REPLACE INTO `{PREFIX}site_keywords` VALUES ('2','content management system'); +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ContactFormReport', 'eForm-template for sending form-data by mail', 0, 'none', 1, 0, '

This is a response sent by [+name+] using the feedback form on the website. The details of the message follow below:

\r\n\r\n\r\n

Name: [+name+]

\r\n

Email: [+email+]

\r\n

Regarding: [+subject+]

\r\n

comments:
[+message+]

\r\n\r\n

You can use this link to reply: [+email+]

\r\n', 0, UNIX_TIMESTAMP(), 0, 0); -REPLACE INTO `{PREFIX}site_keywords` VALUES ('3','Front End Editing'); +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'reflect_month_tpl', 'For the yearly archive. Use with Ditto.', 0, 'none', 1, 0, '[+month+] [+year+]', 0, UNIX_TIMESTAMP(), 0, 0); -REPLACE INTO `{PREFIX}site_keywords` VALUES ('4','login'); +INSERT INTO `{PREFIX}site_htmlsnippets` VALUES (NULL, 'ContactStyles', 'Styles for form validation', 0, 'none', 1, 0, '', 0, UNIX_TIMESTAMP(), 0, 0); # # Dumping data for table `site_tmplvar_contentvalues` @@ -150,7 +119,7 @@ REPLACE INTO `{PREFIX}web_groups` VALUES ('1','1','1'); # -REPLACE INTO `{PREFIX}web_user_attributes` VALUES ('1','1','Site Admin','0','you@example.com','','','0','0','0','25','1129049624','1129063123','0','f426f3209310abfddf2ee00e929774b4','0','0','','','','','','','',''); +REPLACE INTO `{PREFIX}web_user_attributes` VALUES ('1','1','Site Admin','0','you@example.com','','','0','0','0','25','1129049624','1129063123','0','f426f3209310abfddf2ee00e929774b4','0','0','','','','','','','','', UNIX_TIMESTAMP(), 0); # diff --git a/install/setup.sql b/install/setup.sql index 7ab59d7645..2616ef5074 100755 --- a/install/setup.sql +++ b/install/setup.sql @@ -52,7 +52,8 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}document_groups` ( `document` int(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `document` (`document`), - KEY `document_group` (`document_group`) + KEY `document_group` (`document_group`), + UNIQUE INDEX `ix_dg_id` (`document_group`,`document`) ) ENGINE=MyISAM COMMENT='Contains data used for access permissions.'; CREATE TABLE IF NOT EXISTS `{PREFIX}documentgroup_names` ( @@ -77,15 +78,6 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}event_log` ( KEY `user`(`user`) ) ENGINE=MyISAM COMMENT='Stores event and error logs'; - -CREATE TABLE IF NOT EXISTS `{PREFIX}keyword_xref` ( - `content_id` int(11) NOT NULL default '0', - `keyword_id` int(11) NOT NULL default '0', - KEY `content_id` (`content_id`), - KEY `keyword_id` (`keyword_id`) -) ENGINE=MyISAM COMMENT='Cross reference bewteen keywords and content'; - - CREATE TABLE IF NOT EXISTS `{PREFIX}manager_log` ( `id` int(10) NOT NULL auto_increment, `timestamp` int(20) NOT NULL default '0', @@ -160,8 +152,6 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_content` ( `publishedby` int(10) NOT NULL default '0' COMMENT 'ID of user who published the document', `menutitle` varchar(255) NOT NULL DEFAULT '' COMMENT 'Menu title', `donthit` tinyint(1) NOT NULL default '0' COMMENT 'Disable page hit count', - `haskeywords` tinyint(1) NOT NULL default '0' COMMENT 'has links to keywords', - `hasmetatags` tinyint(1) NOT NULL default '0' COMMENT 'has links to meta tags', `privateweb` tinyint(1) NOT NULL default '0' COMMENT 'Private web document', `privatemgr` tinyint(1) NOT NULL default '0' COMMENT 'Private manager document', `content_dispo` tinyint(1) NOT NULL default '0' COMMENT '0-inline, 1-attachment', @@ -176,14 +166,6 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_content` ( ) ENGINE=MyISAM COMMENT='Contains the site document tree.'; -CREATE TABLE IF NOT EXISTS `{PREFIX}site_content_metatags` ( - `content_id` int(11) NOT NULL default '0', - `metatag_id` int(11) NOT NULL default '0', - KEY `content_id` (`content_id`), - KEY `metatag_id` (`metatag_id`) -) ENGINE=MyISAM COMMENT='Reference table between meta tags and content'; - - CREATE TABLE IF NOT EXISTS `{PREFIX}site_htmlsnippets` ( `id` int(10) NOT NULL auto_increment, `name` varchar(100) NOT NULL default '', @@ -194,28 +176,12 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_htmlsnippets` ( `cache_type` tinyint(1) NOT NULL default '0' COMMENT 'Cache option', `snippet` mediumtext, `locked` tinyint(4) NOT NULL default '0', + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', + `disabled` tinyint NOT NULL DEFAULT '0' COMMENT 'Disables the snippet', PRIMARY KEY (`id`) ) ENGINE=MyISAM COMMENT='Contains the site chunks.'; - -CREATE TABLE IF NOT EXISTS `{PREFIX}site_keywords` ( - `id` int(11) NOT NULL auto_increment, - `keyword` varchar(40) NOT NULL default '', - PRIMARY KEY (`id`), - UNIQUE KEY `keyword` (`keyword`) -) ENGINE=MyISAM COMMENT='Site keyword list'; - - -CREATE TABLE IF NOT EXISTS `{PREFIX}site_metatags` ( - `id` integer NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL DEFAULT '', - `tag` varchar(50) NOT NULL DEFAULT '' COMMENT 'tag name', - `tagvalue` varchar(255) NOT NULL DEFAULT '', - `http_equiv` tinyint NOT NULL DEFAULT 0 COMMENT '1 - use http_equiv tag style, 0 - use name', - PRIMARY KEY(`id`) -) ENGINE=MyISAM COMMENT='Site meta tags'; - - CREATE TABLE IF NOT EXISTS `{PREFIX}site_modules` ( `id` integer NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL DEFAULT '', @@ -264,6 +230,8 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_plugins` ( `properties` text COMMENT 'Default Properties', `disabled` tinyint NOT NULL DEFAULT '0' COMMENT 'Disables the plugin', `moduleguid` varchar(32) NOT NULL default '' COMMENT 'GUID of module from which to import shared parameters', + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM COMMENT='Contains the site plugins.'; @@ -285,6 +253,9 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_snippets` ( `locked` tinyint(4) NOT NULL default '0', `properties` text COMMENT 'Default Properties', `moduleguid` varchar(32) NOT NULL default '' COMMENT 'GUID of module from which to import shared parameters', + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', + `disabled` tinyint NOT NULL DEFAULT '0' COMMENT 'Disables the snippet', PRIMARY KEY (`id`) ) ENGINE=MyISAM COMMENT='Contains the site snippets.'; @@ -299,6 +270,8 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_templates` ( `content` mediumtext, `locked` tinyint(4) NOT NULL default '0', `selectable` tinyint(4) NOT NULL default '1', + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM COMMENT='Contains the site templates.'; @@ -331,7 +304,8 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_tmplvar_contentvalues` ( PRIMARY KEY (id), KEY idx_tmplvarid (tmplvarid), KEY idx_id (contentid), - FULLTEXT KEY `value_ft_idx` (`value`) + FULLTEXT KEY `value_ft_idx` (`value`), + UNIQUE INDEX `ix_tvid_contentid` (`tmplvarid`,`contentid`) ) ENGINE=MyISAM COMMENT='Site Template Variables Content Values Link Table'; CREATE TABLE IF NOT EXISTS `{PREFIX}site_tmplvar_templates` ( @@ -355,6 +329,8 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}site_tmplvars` ( `display` varchar(20) NOT NULL default '' COMMENT 'Display Control', `display_params` text COMMENT 'Display Control Properties', `default_text` text, + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', PRIMARY KEY (id), KEY `indx_rank`(`rank`) ) ENGINE=MyISAM COMMENT='Site Template Variables'; @@ -384,7 +360,9 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}user_attributes` ( `zip` varchar(25) NOT NULL default '', `fax` varchar(100) NOT NULL default '', `photo` varchar(255) NOT NULL default '' COMMENT 'link to photo', - `comment` text, + `comment` text, + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `userid` (`internalKey`) ) ENGINE=MyISAM COMMENT='Contains information about the backend users.'; @@ -466,8 +444,6 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}user_roles` ( `exec_module` int(1) NOT NULL DEFAULT 0, `view_eventlog` int(1) NOT NULL DEFAULT 0, `delete_eventlog` int(1) NOT NULL DEFAULT 0, - `manage_metatags` int(1) NOT NULL DEFAULT 0 COMMENT 'manage site meta tags and keywords', - `edit_doc_metatags` int(1) NOT NULL DEFAULT 0 COMMENT 'edit document meta tags and keywords' , `new_web_user` int(1) NOT NULL default '0', `edit_web_user` int(1) NOT NULL default '0', `save_web_user` int(1) NOT NULL default '0', @@ -538,7 +514,9 @@ CREATE TABLE IF NOT EXISTS `{PREFIX}web_user_attributes` ( `zip` varchar(25) NOT NULL default '', `fax` varchar(100) NOT NULL default '', `photo` varchar(255) NOT NULL default '' COMMENT 'link to photo', - `comment` text, + `comment` text, + `createdon` integer NOT NULL DEFAULT '0', + `editedon` integer NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `userid` (`internalKey`) ) ENGINE=MyISAM COMMENT='Contains information for web users.'; @@ -582,21 +560,48 @@ ALTER TABLE `{PREFIX}site_content` ALTER TABLE `{PREFIX}site_htmlsnippets` ADD COLUMN `editor_name` VARCHAR(50) NOT NULL DEFAULT 'none' AFTER `editor_type`; +ALTER TABLE `{PREFIX}site_htmlsnippets` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_htmlsnippets` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_htmlsnippets` + ADD COLUMN `disabled` tinyint NOT NULL DEFAULT '0'; + ALTER TABLE `{PREFIX}site_plugin_events` ADD COLUMN `priority` INT(10) NOT NULL default '0' COMMENT 'determines the run order of the plugin' AFTER `evtid`; ALTER TABLE `{PREFIX}site_templates` ADD COLUMN `selectable` TINYINT(4) NOT NULL DEFAULT '1' AFTER `locked`; +ALTER TABLE `{PREFIX}site_templates` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_templates` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + ALTER TABLE `{PREFIX}site_tmplvar_templates` ADD COLUMN `rank` integer(11) NOT NULL DEFAULT '0' AFTER `templateid`; +ALTER TABLE `{PREFIX}site_tmplvars` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_tmplvars` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + ALTER TABLE `{PREFIX}user_attributes` ADD COLUMN `street` varchar(255) NOT NULL DEFAULT '' AFTER `country`; ALTER TABLE `{PREFIX}user_attributes` ADD COLUMN `city` varchar(255) NOT NULL DEFAULT '' AFTER `street`; +ALTER TABLE `{PREFIX}user_attributes` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}user_attributes` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + ALTER TABLE `{PREFIX}user_roles` ADD COLUMN `edit_chunk` INT(1) NOT NULL DEFAULT '0' AFTER `delete_snippet`; @@ -651,6 +656,33 @@ ALTER TABLE `{PREFIX}web_user_attributes` ALTER TABLE `{PREFIX}web_user_attributes` ADD COLUMN `city` varchar(255) NOT NULL DEFAULT '' AFTER `street`; +ALTER TABLE `{PREFIX}web_user_attributes` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}web_user_attributes` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_snippets` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_snippets` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_snippets` + ADD COLUMN `disabled` tinyint NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_plugins` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_plugins` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_templates` + ADD COLUMN `createdon` integer NOT NULL DEFAULT '0'; + +ALTER TABLE `{PREFIX}site_templates` + ADD COLUMN `editedon` integer NOT NULL DEFAULT '0'; + # Set the private manager group flag UPDATE {PREFIX}documentgroup_names AS dgn @@ -826,6 +858,8 @@ ALTER TABLE `{PREFIX}member_groups` ADD UNIQUE INDEX `ix_group_member` (`user_gr ALTER TABLE `{PREFIX}web_groups` ADD UNIQUE INDEX `ix_group_user` (`webgroup`,`webuser`); +ALTER TABLE `{PREFIX}document_groups` ADD UNIQUE INDEX `ix_dg_id` (`document_group`,`document`); + # ]]upgrade-able @@ -846,7 +880,7 @@ REPLACE INTO `{PREFIX}site_templates` # Default Site Documents -REPLACE INTO `{PREFIX}site_content` VALUES (1,'document','text/html','Evolution CMS Install Success','Welcome to the EVO Content Management System','','minimal-base','',1,0,0,0,0,'','

Install Successful!

\r\n

You have successfully installed Evolution CMS.

\r\n\r\n

Getting Help

\r\n

The EVO Community provides a great starting point to learn all things Evolution CMS, or you can also see some great learning resources (books, tutorials, blogs and screencasts).

\r\n

Welcome to EVO!

\r\n',1,3,0,1,1,1,1130304721,1,1130304927,0,0,0,1130304721,1,'Base Install',0,0,0,0,0,0,0,1); +REPLACE INTO `{PREFIX}site_content` VALUES (1,'document','text/html','Evolution CMS Install Success','Welcome to the EVO Content Management System','','minimal-base','',1,0,0,0,0,'','

Install Successful!

\r\n

You have successfully installed Evolution CMS.

\r\n\r\n

Getting Help

\r\n

The EVO Community provides a great starting point to learn all things Evolution CMS, or you can also see some great learning resources (books, tutorials, blogs and screencasts).

\r\n

Welcome to EVO!

\r\n',1,3,0,1,1,1,1130304721,1,1130304927,0,0,0,1130304721,1,'Base Install',0,0,0,0,0,1); REPLACE INTO `{PREFIX}manager_users` @@ -859,9 +893,9 @@ REPLACE INTO `{PREFIX}user_attributes` REPLACE INTO `{PREFIX}user_roles` -(id,name,description,frames,home,view_document,new_document,save_document,publish_document,delete_document,empty_trash,action_ok,logout,help,messages,new_user,edit_user,logs,edit_parser,save_parser,edit_template,settings,credits,new_template,save_template,delete_template,edit_snippet,new_snippet,save_snippet,delete_snippet,edit_chunk,new_chunk,save_chunk,delete_chunk,empty_cache,edit_document,change_password,error_dialog,about,file_manager,save_user,delete_user,save_password,edit_role,save_role,delete_role,new_role,access_permissions,bk_manager,new_plugin,edit_plugin,save_plugin,delete_plugin,new_module,edit_module,save_module,exec_module,delete_module,view_eventlog,delete_eventlog,manage_metatags,edit_doc_metatags,new_web_user,edit_web_user,save_web_user,delete_web_user,web_access_permissions,view_unpublished,import_static,export_static,remove_locks,assets_images,assets_files,change_resourcetype,display_locks,category_manager) VALUES -(2,'Editor','Limited to managing content',1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0), -(3,'Publisher','Editor with expanded permissions including manage users\, update Elements and site settings',1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,1,0,1,0,0,1,1,1,1,1,0); +(id,name,description,frames,home,view_document,new_document,save_document,publish_document,delete_document,empty_trash,action_ok,logout,help,messages,new_user,edit_user,logs,edit_parser,save_parser,edit_template,settings,credits,new_template,save_template,delete_template,edit_snippet,new_snippet,save_snippet,delete_snippet,edit_chunk,new_chunk,save_chunk,delete_chunk,empty_cache,edit_document,change_password,error_dialog,about,file_manager,save_user,delete_user,save_password,edit_role,save_role,delete_role,new_role,access_permissions,bk_manager,new_plugin,edit_plugin,save_plugin,delete_plugin,new_module,edit_module,save_module,exec_module,delete_module,view_eventlog,delete_eventlog,new_web_user,edit_web_user,save_web_user,delete_web_user,web_access_permissions,view_unpublished,import_static,export_static,remove_locks,assets_images,assets_files,change_resourcetype,display_locks,category_manager) VALUES +(2,'Editor','Limited to managing content',1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0), +(3,'Publisher','Editor with expanded permissions including manage users\, update Elements and site settings',1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,1,0,0,1,1,1,1,1,0); # ]]non-upgrade-able @@ -918,8 +952,8 @@ INSERT IGNORE INTO `{PREFIX}system_settings` ('theme_refresher',''); REPLACE INTO `{PREFIX}user_roles` -(id,name,description,frames,home,view_document,new_document,save_document,publish_document,delete_document,empty_trash,action_ok,logout,help,messages,new_user,edit_user,logs,edit_parser,save_parser,edit_template,settings,credits,new_template,save_template,delete_template,edit_snippet,new_snippet,save_snippet,delete_snippet,edit_chunk,new_chunk,save_chunk,delete_chunk,empty_cache,edit_document,change_password,error_dialog,about,file_manager,save_user,delete_user,save_password,edit_role,save_role,delete_role,new_role,access_permissions,bk_manager,new_plugin,edit_plugin,save_plugin,delete_plugin,new_module,edit_module,save_module,exec_module,delete_module,view_eventlog,delete_eventlog,manage_metatags,edit_doc_metatags,new_web_user,edit_web_user,save_web_user,delete_web_user,web_access_permissions,view_unpublished,import_static,export_static,remove_locks,assets_images,assets_files,change_resourcetype,display_locks,category_manager) VALUES -(1, 'Administrator', 'Site administrators have full access to all functions',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); +(id,name,description,frames,home,view_document,new_document,save_document,publish_document,delete_document,empty_trash,action_ok,logout,help,messages,new_user,edit_user,logs,edit_parser,save_parser,edit_template,settings,credits,new_template,save_template,delete_template,edit_snippet,new_snippet,save_snippet,delete_snippet,edit_chunk,new_chunk,save_chunk,delete_chunk,empty_cache,edit_document,change_password,error_dialog,about,file_manager,save_user,delete_user,save_password,edit_role,save_role,delete_role,new_role,access_permissions,bk_manager,new_plugin,edit_plugin,save_plugin,delete_plugin,new_module,edit_module,save_module,exec_module,delete_module,view_eventlog,delete_eventlog,new_web_user,edit_web_user,save_web_user,delete_web_user,web_access_permissions,view_unpublished,import_static,export_static,remove_locks,assets_images,assets_files,change_resourcetype,display_locks,category_manager) VALUES +(1, 'Administrator', 'Site administrators have full access to all functions',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1); # 1 - "Parser Service Events", 2 - "Manager Access Events", 3 - "Web Access Service Events", 4 - "Cache Service Events", 5 - "Template Service Events", 6 - Custom Events @@ -1080,8 +1114,6 @@ UPDATE `{PREFIX}user_roles` SET exec_module=1, view_eventlog = 1, delete_eventlog = 1, - manage_metatags = 1, - edit_doc_metatags = 1, new_web_user = 1, edit_web_user = 1, save_web_user = 1, diff --git a/manager/actions/access_permissions.dynamic.php b/manager/actions/access_permissions.dynamic.php index bb3d717022..14908782ad 100644 --- a/manager/actions/access_permissions.dynamic.php +++ b/manager/actions/access_permissions.dynamic.php @@ -39,226 +39,250 @@ } ?> +

- +

-
-

' . $_lang['access_permissions_off'] . '

' : '' ?> - -
- +
' . $_lang['access_permissions_off'] . '
' : '') ?>
-
-

- - + - echo '

' . $_lang['access_permissions_users_tab'] . '

'; +
+

+ - ?> - - - - - - - - - -
-
- - -   - -
-
-
+
+

+
+ +
+ + +
+ +
+ +
+
+
+
db->select('groupnames.*, users.id AS user_id, users.username user_name', "{$tbl_membergroup_names} AS groupnames - LEFT JOIN {$tbl_member_groups} AS groups ON groups.user_group = groupnames.id - LEFT JOIN {$tbl_manager_users} AS users ON users.id = groups.member", '', 'groupnames.name, user_name'); + $rs = $modx->db->select('groupnames.*, users.id AS user_id, users.username user_name', $tbl_membergroup_names . ' AS groupnames + LEFT JOIN ' . $tbl_member_groups . ' AS groups ON groups.user_group = groupnames.id + LEFT JOIN ' . $tbl_manager_users . ' AS users ON users.id = groups.member', '', 'groupnames.name, user_name'); if($modx->db->getRecordCount($rs) < 1) { - echo '' . $_lang['no_groups_found'] . ''; + ?> +
+ \n"; + ?> +
+ db->getRow($rs)) { - if($row['id'] !== $pid) { + if($pid != $row['id']) { if($pid != '') { - echo "\n"; - } // close previous one - - // display the current user group with a rename/delete form - echo '
  • ' . "\n" . "\t" . '' . "\n" . "\t" . '' . "\n" . "\t" . '' . "\n" . "\t" . ' ' . "\n" . "\t" . ' ' . "\n" . "\t" . '' . "\n" . '
    '; - - echo "
      \n"; - echo "\t
    • " . $_lang['access_permissions_users_in_group'] . ' '; + echo '
  • '; + } + ?> +
    + + + +
    + +
    + + +
    +
    +
    + + ' . $_lang['access_permissions_no_users_in_group'] . ''; + ?> + + ' . $row['user_name'] . ''; + ?> + + \n"; - echo "\n"; - } - ?> + } + ?> +
    +
    -
    -

    - - +

    + - echo '

    ' . $_lang['access_permissions_resources_tab'] . '

    '; - ?> - - - - - - - - - -
    -
    - - -   - -
    -
    -
    +
    +

    +
    + +
    + + +
    + +
    + +
    +
    +
    +
    db->select('dgnames.id, dgnames.name, sc.id AS doc_id, sc.pagetitle AS doc_title', "{$tbl_documentgroup_names} AS dgnames - LEFT JOIN {$tbl_document_groups} AS dg ON dg.document_group = dgnames.id - LEFT JOIN {$tbl_site_content} AS sc ON sc.id = dg.document", "", "dgnames.name, sc.id"); + $rs = $modx->db->select('dgnames.id, dgnames.name, sc.id AS doc_id, sc.pagetitle AS doc_title', $tbl_documentgroup_names . ' AS dgnames + LEFT JOIN ' . $tbl_document_groups . ' AS dg ON dg.document_group = dgnames.id + LEFT JOIN ' . $tbl_site_content . ' AS sc ON sc.id = dg.document', '', 'dgnames.name, sc.id'); if($modx->db->getRecordCount($rs) < 1) { - echo '' . $_lang['no_groups_found'] . ''; + ?> +
    + ' . "\n" . "\t" . '' . "\n" . "\t" . '' . $_lang['access_permissions_resource_groups'] . '' . "\n" . "\t" . '' . "\n"; + ?> +
    + db->getRow($rs)) { - if($row['id'] !== $pid) { + if($pid != $row['id']) { if($pid != '') { - echo "\n"; - } // close previous one - - echo '
    ' . "\n" . "\t" . '' . "\n" . "\t" . '' . "\n" . "\t" . '' . "\n" . "\t" . ' ' . "\n" . "\t" . '' . "\n" . "\t" . '' . "\n" . '
    '; - - echo '' . $_lang['access_permissions_resources_in_group'] . ' '; + echo '
    '; + } + ?> +
    + + + +
    + +
    + + +
    +
    +
    + + + + htmlspecialchars($row['doc_title']) . '">' . $row['doc_id'] . ''; + ?> + + '; - } - ?> + } + ?> +
    +
    + +
    +

    + -
    -

    - +
    +

    ' . $_lang['access_permissions_links_tab'] . '

    '; - - $rs = $modx->db->select("groupnames.*, groupacc.id AS link_id, dgnames.id AS dg_id, dgnames.name AS dg_name", "{$tbl_membergroup_names} AS groupnames - LEFT JOIN {$tbl_membergroup_access} AS groupacc ON groupacc.membergroup = groupnames.id - LEFT JOIN {$tbl_documentgroup_names} AS dgnames ON dgnames.id = groupacc.documentgroup", '', 'name, dg_name'); + $rs = $modx->db->select('groupnames.*, groupacc.id AS link_id, dgnames.id AS dg_id, dgnames.name AS dg_name', $tbl_membergroup_names . ' AS groupnames + LEFT JOIN ' . $tbl_membergroup_access . ' AS groupacc ON groupacc.membergroup = groupnames.id + LEFT JOIN ' . $tbl_documentgroup_names . ' AS dgnames ON dgnames.id = groupacc.documentgroup', '', 'name, dg_name'); if($modx->db->getRecordCount($rs) < 1) { - echo '' . $_lang['no_groups_found'] . '
    '; - } else { ?> - - - - - - - - - -
    -
    - - - - - - - -
    -
    -
    +
    \n"; - $pid = ''; - while($row = $modx->db->getRow($rs)) { - if($row['id'] != $pid) { - if($pid != '') { - echo "\n"; - } // close previous one - echo '
  • ' . $row['name'] . ''; - + } else { + ?> +
    + +
    + + + + + + + +
    +
    +
    +
      + db->getRow($rs)) { + if($row['id'] != $pid) { + if($pid != '') { + echo '
  • '; + } // close previous one + ?> +
  • + ' . $_lang['no_groups_found'] . ''; + $pid = ''; + continue; + } else { + echo '
      '; + } + } if(!$row['dg_id']) { - echo ' » ' . $_lang['no_groups_found'] . "\n"; - $pid = ''; continue; - } else { - echo "'; + ?> +
    +
    -
    +
    diff --git a/manager/actions/bkmanager.static.php b/manager/actions/bkmanager.static.php index 028a369f6b..7993a119f6 100644 --- a/manager/actions/bkmanager.static.php +++ b/manager/actions/bkmanager.static.php @@ -1,465 +1,491 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('bk_manager')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('bk_manager')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $dbase = trim($dbase, '`'); -if(!isset($modx->config['snapshot_path'])) { - if(is_dir(MODX_BASE_PATH . 'temp/backup/')) { - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'temp/backup/'; - } else { - $modx->config['snapshot_path'] = MODX_BASE_PATH . 'assets/backup/'; - } +if (!isset($modx->config['snapshot_path'])) { + if (is_dir(MODX_BASE_PATH . 'temp/backup/')) { + $modx->config['snapshot_path'] = MODX_BASE_PATH . 'temp/backup/'; + } else { + $modx->config['snapshot_path'] = MODX_BASE_PATH . 'assets/backup/'; + } } // Backup Manager by Raymond: $mode = isset($_POST['mode']) ? $_POST['mode'] : ''; -if($mode == 'restore1') { - if(isset($_POST['textarea']) && !empty($_POST['textarea'])) { - $source = trim($_POST['textarea']); - $_SESSION['textarea'] = $source . "\n"; - } else { - $source = file_get_contents($_FILES['sqlfile']['tmp_name']); - } - import_sql($source); - header('Location: index.php?r=9&a=93'); - exit; -} elseif($mode == 'restore2') { - $path = $modx->config['snapshot_path'] . $_POST['filename']; - if(file_exists($path)) { - $source = file_get_contents($path); - import_sql($source); - if(headers_sent()) { - echo "\n"; - } else { - header("Location: index.php?r=9&a=93"); - } - } - exit; -} elseif($mode == 'backup') { - $tables = isset($_POST['chk']) ? $_POST['chk'] : ''; - if(!is_array($tables)) { - $modx->webAlertAndQuit("Please select a valid table from the list below."); - } - - /* - * Code taken from Ralph A. Dahlgren MySQLdumper Snippet - Etomite 0.6 - 2004-09-27 - * Modified by Raymond 3-Jan-2005 - * Perform MySQLdumper data dump - */ - @set_time_limit(120); // set timeout limit to 2 minutes - $dumper = new Mysqldumper($database_server, $database_user, $database_password, $dbase); - $dumper->setDBtables($tables); - $dumper->setDroptables((isset($_POST['droptables']) ? true : false)); - $dumpfinished = $dumper->createDump('dumpSql'); - if($dumpfinished) { - exit; - } else { - $modx->webAlertAndQuit('Unable to Backup Database'); - } - - // MySQLdumper class can be found below -} elseif($mode == 'snapshot') { - if(!is_dir(rtrim($modx->config['snapshot_path'], '/'))) { - mkdir(rtrim($modx->config['snapshot_path'], '/')); - @chmod(rtrim($modx->config['snapshot_path'], '/'), 0777); - } - if(!is_file("{$modx->config['snapshot_path']}.htaccess")) { - $htaccess = "order deny,allow\ndeny from all\n"; - file_put_contents("{$modx->config['snapshot_path']}.htaccess", $htaccess); - } - if(!is_writable(rtrim($modx->config['snapshot_path'], '/'))) { - $modx->webAlertAndQuit(parsePlaceholder($_lang["bkmgr_alert_mkdir"], array('snapshot_path' => $modx->config['snapshot_path']))); - } - $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; - $rs = $modx->db->query($sql); - $tables = $modx->db->getColumn('Name', $rs); - //$today = $modx->toDateFormat(time()); - //$today = str_replace(array('/',' '), '-', $today); - //$today = str_replace(':', '', $today); - //$today = strtolower($today); - $today = date('Y-m-d_H-i-s'); - global $path; - $path = "{$modx->config['snapshot_path']}{$today}.sql"; - - @set_time_limit(120); // set timeout limit to 2 minutes - $dumper = new Mysqldumper($database_server, $database_user, $database_password, $dbase); - $dumper->setDBtables($tables); - $dumper->setDroptables(true); - $dumpfinished = $dumper->createDump('snapshot'); - - $pattern = "{$modx->config['snapshot_path']}*.sql"; - $files = glob($pattern, GLOB_NOCHECK); - $total = ($files[0] !== $pattern) ? count($files) : 0; - arsort($files); - while(10 < $total && $limit < 50) { - $del_file = array_pop($files); - unlink($del_file); - $total = count($files); - $limit++; - } - - if($dumpfinished) { - $_SESSION['result_msg'] = 'snapshot_ok'; - header("Location: index.php?a=93"); - exit; - } else { - $modx->webAlertAndQuit('Unable to Backup Database'); - } +if ($mode == 'restore1') { + if (isset($_POST['textarea']) && !empty($_POST['textarea'])) { + $source = trim($_POST['textarea']); + $_SESSION['textarea'] = $source . "\n"; + } else { + $source = file_get_contents($_FILES['sqlfile']['tmp_name']); + } + import_sql($source); + header('Location: index.php?r=9&a=93'); + exit; +} elseif ($mode == 'restore2') { + $path = $modx->config['snapshot_path'] . $_POST['filename']; + if (file_exists($path)) { + $source = file_get_contents($path); + import_sql($source); + if (headers_sent()) { + echo "\n"; + } else { + header("Location: index.php?r=9&a=93"); + } + } + exit; +} elseif ($mode == 'backup') { + $tables = isset($_POST['chk']) ? $_POST['chk'] : ''; + if (!is_array($tables)) { + $modx->webAlertAndQuit("Please select a valid table from the list below."); + } + + /* + * Code taken from Ralph A. Dahlgren MySQLdumper Snippet - Etomite 0.6 - 2004-09-27 + * Modified by Raymond 3-Jan-2005 + * Perform MySQLdumper data dump + */ + @set_time_limit(120); // set timeout limit to 2 minutes + $dumper = new Mysqldumper($database_server, $database_user, $database_password, $dbase); + $dumper->setDBtables($tables); + $dumper->setDroptables((isset($_POST['droptables']) ? true : false)); + $dumpfinished = $dumper->createDump('dumpSql'); + if ($dumpfinished) { + exit; + } else { + $modx->webAlertAndQuit('Unable to Backup Database'); + } + + // MySQLdumper class can be found below +} elseif ($mode == 'snapshot') { + if (!is_dir(rtrim($modx->config['snapshot_path'], '/'))) { + mkdir(rtrim($modx->config['snapshot_path'], '/')); + @chmod(rtrim($modx->config['snapshot_path'], '/'), 0777); + } + if (!is_file("{$modx->config['snapshot_path']}.htaccess")) { + $htaccess = "order deny,allow\ndeny from all\n"; + file_put_contents("{$modx->config['snapshot_path']}.htaccess", $htaccess); + } + if (!is_writable(rtrim($modx->config['snapshot_path'], '/'))) { + $modx->webAlertAndQuit(parsePlaceholder($_lang["bkmgr_alert_mkdir"], array('snapshot_path' => $modx->config['snapshot_path']))); + } + $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; + $rs = $modx->db->query($sql); + $tables = $modx->db->getColumn('Name', $rs); + //$today = $modx->toDateFormat(time()); + //$today = str_replace(array('/',' '), '-', $today); + //$today = str_replace(':', '', $today); + //$today = strtolower($today); + $today = date('Y-m-d_H-i-s'); + global $path; + $path = "{$modx->config['snapshot_path']}{$today}.sql"; + + @set_time_limit(120); // set timeout limit to 2 minutes + $dumper = new Mysqldumper($database_server, $database_user, $database_password, $dbase); + $dumper->setDBtables($tables); + $dumper->setDroptables(true); + $dumpfinished = $dumper->createDump('snapshot'); + + $pattern = "{$modx->config['snapshot_path']}*.sql"; + $files = glob($pattern, GLOB_NOCHECK); + $total = ($files[0] !== $pattern) ? count($files) : 0; + arsort($files); + while (10 < $total && $limit < 50) { + $del_file = array_pop($files); + unlink($del_file); + $total = count($files); + $limit++; + } + + if ($dumpfinished) { + $_SESSION['result_msg'] = 'snapshot_ok'; + header("Location: index.php?a=93"); + exit; + } else { + $modx->webAlertAndQuit('Unable to Backup Database'); + } } else { - include_once MODX_MANAGER_PATH . "includes/header.inc.php"; // start normal header + include_once MODX_MANAGER_PATH . "includes/header.inc.php"; // start normal header } -if(isset($_SESSION['result_msg']) && $_SESSION['result_msg'] != '') { - switch($_SESSION['result_msg']) { - case 'import_ok': - $ph['result_msg_import'] = '
    ' . $_lang["bkmgr_import_ok"] . '
    '; - $ph['result_msg_snapshot'] = '
    ' . $_lang["bkmgr_import_ok"] . '
    '; - break; - case 'snapshot_ok': - $ph['result_msg_import'] = ''; - $ph['result_msg_snapshot'] = '
    ' . $_lang["bkmgr_snapshot_ok"] . '
    '; - break; - } - $_SESSION['result_msg'] = ''; +if (isset($_SESSION['result_msg']) && $_SESSION['result_msg'] != '') { + switch ($_SESSION['result_msg']) { + case 'import_ok': + $ph['result_msg_import'] = '
    ' . $_lang["bkmgr_import_ok"] . '
    '; + $ph['result_msg_snapshot'] = '
    ' . $_lang["bkmgr_import_ok"] . '
    '; + break; + case 'snapshot_ok': + $ph['result_msg_import'] = ''; + $ph['result_msg_snapshot'] = '
    ' . $_lang["bkmgr_snapshot_ok"] . '
    '; + break; + } + $_SESSION['result_msg'] = ''; } else { - $ph['result_msg_import'] = ''; - $ph['result_msg_snapshot'] = ''; + $ph['result_msg_import'] = ''; + $ph['result_msg_snapshot'] = ''; } ?> - - -

    - -

    - - - -
    -
    - - -
    -

    - -
    - -

    -

    - - -

    - - - - - - - - - - - - - - - db->escape($modx->db->config['table_prefix']) . "%'"; - $rs = $modx->db->query($sql); - $i = 0; - while($db_status = $modx->db->getRow($rs)) { - //$bgcolor = ($i++ % 2) ? '#EEEEEE' : '#FFFFFF'; - - if(isset($tables)) { - $table_string = implode(',', $table); - } else { - $table_string = ''; - } - - echo '' . "\n" . '' . "\n" . '' . "\n"; - echo '' . "\n"; - - // Enable record deletion for certain tables (TRUNCATE TABLE) if they're not already empty - $truncateable = array( - $modx->db->config['table_prefix'] . 'event_log', - $modx->db->config['table_prefix'] . 'manager_log', - ); - if($modx->hasPermission('settings') && in_array($db_status['Name'], $truncateable) && $db_status['Rows'] > 0) { - echo '' . "\n"; - } else { - echo '' . "\n"; - } - - if($modx->hasPermission('settings')) { - echo '' . "\n"; - } else { - echo '' . "\n"; - } - - echo '' . "\n" . '' . "\n" . '' . "\n" . ""; - - $total = $total + $db_status['Index_length'] + $db_status['Data_length']; - $totaloverhead = $totaloverhead + $db_status['Data_free']; - } - ?> - - - - - - - - - - -
    ' . $db_status['Rows'] . '' . $db_status['Collation'] . '' . '' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '' . '' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '' . ($db_status['Data_free'] > 0 ? '' . $modx->nicesize($db_status['Data_free']) . '' : '-') . '' . ($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-') . '' . $modx->nicesize($db_status['Data_length'] - $db_status['Data_free']) . '' . $modx->nicesize($db_status['Index_length']) . '' . $modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '
      0 ? '' . $modx->nicesize($totaloverhead) . '
    (' . number_format($totaloverhead) . ' B)' : '-' ?>
     " . $modx->nicesize($total) . "
    (" . number_format($total) . " B)" ?>
    - 0) { - echo '

    ' . $_lang['database_overhead'] . '

    '; - } - ?> -
    -
    - - -
    -

    - - -
    - -
    -
    - - - - $v) { - $title[] = $k; - } - $result = '' . implode('', $title) . ''; - foreach($last_result as $row) { - $result_value = array(); - if($row) { - foreach($row as $k => $v) { - $result_value[] = $v; - } - $result .= '' . implode('', $result_value) . ''; - } - } - $style = ''; - $result = $style . '' . $result . '
    '; - } - } - - function checked($cond) { - if($cond) { - return ' checked'; - } - } - - ?> -

    - - -

    -
    -
    - -
    - - -
    -

    ' . $_lang["bkmgr_run_sql_result"] . '

    ' . $result . '
    '; - } - ?> -
    - -
    -

    - - -
    - "snapshot_path={$modx->config['snapshot_path']}")) ?> -
    -
    - - - - - -
    - -
    -
    -
    - - - - config['snapshot_path']}*.sql"; - $files = glob($pattern, GLOB_NOCHECK); - $total = ($files[0] !== $pattern) ? count($files) : 0; - $detailFields = array( - 'MODX Version', - 'Host', - 'Generation Time', - 'Server version', - 'PHP Version', - 'Database', - 'Description' - ); - if(is_array($files) && 0 < $total) { - echo ''; - echo "\n"; - arsort($files); - $tpl = '' . "\n"; - while($file = array_shift($files)) { - $filename = substr($file, strrpos($file, '/') + 1); - $filesize = $modx->nicesize(filesize($file)); - - $file = fopen($file, "r"); - $count = 0; - $details = array(); - while($count < 11) { - $line = fgets($file); - foreach($detailFields as $label) { - $fileLabel = '# ' . $label; - if(strpos($line, $fileLabel) !== false) { - $details[$label] = htmlentities(trim(str_replace(array( - $fileLabel, - ':', - '`' - ), '', $line)), ENT_QUOTES, $modx_manager_charset); - } - } - $count++; - }; - fclose($file); - - $tooltip = "Generation Time: " . $details["Generation Time"] . "\n"; - $tooltip .= "Server version: " . $details["Server version"] . "\n"; - $tooltip .= "PHP Version: " . $details["PHP Version"] . "\n"; - $tooltip .= "Host: " . $details["Host"] . "\n"; - - echo str_replace(array( - '[+filename+]', - '[+filesize+]', - '[+filedesc+]', - '[+modx_version+]', - '[+database_name+]', - '[+tooltip+]' - ), array( - $filename, - $filesize, - $details['Description'], - $details['MODX Version'], - $details['Database'], - $tooltip - ), $tpl); - } - echo '
    {$_lang["files_filename"]}{$_lang["files_filesize"]}{$_lang["description"]}{$_lang["modx_version"]}{$_lang["database_name"]}{$_lang["onlineusers_action"]}
    [+filename+][+filesize+][+filedesc+][+modx_version+][+database_name+]' . $_lang["bkmgr_restore_submit"] . '
    '; - } else { - echo $_lang["bkmgr_snapshot_nothing"]; - } - ?> - -
    -
    -
    - -
    - -
    - + + +

    + +

    + + + +
    + + +
    +

    + + +
    +
    + +

    + + +

    +
    +
    + + + + + + + + + + + + + + + + db->escape($modx->db->config['table_prefix']) . "%'"; + $rs = $modx->db->query($sql); + $i = 0; + while ($db_status = $modx->db->getRow($rs)) { + if (isset($tables)) { + $table_string = implode(',', $table); + } else { + $table_string = ''; + } + + echo '' . "\n" . '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + echo '' . "\n"; + + // Enable record deletion for certain tables (TRUNCATE TABLE) if they're not already empty + $truncateable = array( + $modx->db->config['table_prefix'] . 'event_log', + $modx->db->config['table_prefix'] . 'manager_log', + ); + if ($modx->hasPermission('settings') && in_array($db_status['Name'], $truncateable) && $db_status['Rows'] > 0) { + echo '' . "\n"; + } else { + echo '' . "\n"; + } + + if ($modx->hasPermission('settings')) { + echo '' . "\n"; + } else { + echo '' . "\n"; + } + + echo '' . "\n" . '' . "\n" . '' . "\n" . ""; + + $total = $total + $db_status['Index_length'] + $db_status['Data_length']; + $totaloverhead = $totaloverhead + $db_status['Data_free']; + } + ?> + + + + + + + + + + +
    ' . (!empty($db_status['Comment']) ? '' : '') . '' . $db_status['Rows'] . '' . $db_status['Collation'] . '' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '' . '' . $modx->nicesize($db_status['Data_length'] + $db_status['Data_free']) . '' . ($db_status['Data_free'] > 0 ? '' . $modx->nicesize($db_status['Data_free']) . '' : '-') . '' . ($db_status['Data_free'] > 0 ? $modx->nicesize($db_status['Data_free']) : '-') . '' . $modx->nicesize($db_status['Data_length'] - $db_status['Data_free']) . '' . $modx->nicesize($db_status['Index_length']) . '' . $modx->nicesize($db_status['Index_length'] + $db_status['Data_length'] + $db_status['Data_free']) . '
      0 ? '' . $modx->nicesize($totaloverhead) . '
    (' . number_format($totaloverhead) . ' B)' : '-' ?>
     " . $modx->nicesize($total) . "
    (" . number_format($total) . " B)" ?>
    +
    +
    + 0) { ?> +
    +

    + +
    +
    +
    + + +
    +

    + + +
    + +
    + +
    +
    + + + $v) { + $title[] = $k; + } + $result = '' . implode('', $title) . ''; + $result .= ''; + foreach ($last_result as $row) { + $result_value = array(); + if ($row) { + foreach ($row as $k => $v) { + $result_value[] = $v; + } + $result .= '' . implode('', $result_value) . ''; + } + } + $result .= ''; + $result = '' . $result . '
    '; + } + } + + function checked($cond) + { + if ($cond) { + return ' checked'; + } + } + + ?> +

    + + +

    +
    +
    + +
    + + +
    + + +
    +
    +
    + +
    +
    + +
    +

    + + +
    + +
    + "snapshot_path={$modx->config['snapshot_path']}")) ?> +
    +
    + + + +
    + +
    + +
    +
    + +
    +
    + +
    +
    + + + + config['snapshot_path']}*.sql"; + $files = glob($pattern, GLOB_NOCHECK); + $total = ($files[0] !== $pattern) ? count($files) : 0; + $detailFields = array( + 'MODX Version', + 'Host', + 'Generation Time', + 'Server version', + 'PHP Version', + 'Database', + 'Description' + ); + if (is_array($files) && 0 < $total) { + ?> +
    +
    + + + + + + + + + + + + + + nicesize(filesize($file)); + + $file = fopen($file, "r"); + $count = 0; + $details = array(); + while ($count < 11) { + $line = fgets($file); + foreach ($detailFields as $label) { + $fileLabel = '# ' . $label; + if (strpos($line, $fileLabel) !== false) { + $details[$label] = htmlentities(trim(str_replace(array( + $fileLabel, + ':', + '`' + ), '', $line)), ENT_QUOTES, $modx_manager_charset); + } + } + $count++; + }; + fclose($file); + + $tooltip = "Generation Time: " . $details["Generation Time"] . "\n"; + $tooltip .= "Server version: " . $details["Server version"] . "\n"; + $tooltip .= "PHP Version: " . $details["PHP Version"] . "\n"; + $tooltip .= "Host: " . $details["Host"] . "\n"; + ?> + + + + + + + + + + + +
    +
    +
    + + +
    +
    +
    + +
    tpDBM.setSelectedIndex( ' . $_GET['tab'] . ' );'; +if (is_numeric($_GET['tab'])) { + echo ''; } include_once "footer.inc.php"; // send footer @@ -480,285 +506,300 @@ function checked($cond) { * **/ -class Mysqldumper { - var $_dbtables; - var $_isDroptables; - var $database_server; - var $dbname; - - function __construct($database_server, $database_user, $database_password, $dbname) { - // Don't drop tables by default. - $this->dbname = $dbname; - $this->setDroptables(false); - } - - function setDroptables($state) { - $this->_isDroptables = $state; - } - - // If set to true, it will generate 'DROP TABLE IF EXISTS'-statements for each table. - - function setDBtables($dbtables) { - $this->_dbtables = $dbtables; - } - - function createDump($callBack) { - global $modx; - - // Set line feed - $lf = "\n"; - $tempfile_path = $modx->config['base_path'] . 'assets/backup/temp.php'; - - $result = $modx->db->query('SHOW TABLES'); - $tables = $this->result2Array(0, $result); - foreach($tables as $tblval) { - $result = $modx->db->query("SHOW CREATE TABLE `{$tblval}`"); - $createtable[$tblval] = $this->result2Array(1, $result); - } - - $version = $modx->getVersionData(); - - // Set header - $output = "#{$lf}"; - $output .= "# " . addslashes($modx->config['site_name']) . " Database Dump{$lf}"; - $output .= "# MODX Version:{$version['version']}{$lf}"; - $output .= "# {$lf}"; - $output .= "# Host: {$this->database_server}{$lf}"; - $output .= "# Generation Time: " . $modx->toDateFormat(time()) . $lf; - $output .= "# Server version: " . $modx->db->getVersion() . $lf; - $output .= "# PHP Version: " . phpversion() . $lf; - $output .= "# Database: `{$this->dbname}`{$lf}"; - $output .= "# Description: " . trim($_REQUEST['backup_title']) . "{$lf}"; - $output .= "#"; - file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); - $output = ''; - - // Generate dumptext for the tables. - if(isset($this->_dbtables) && count($this->_dbtables)) { - $this->_dbtables = implode(',', $this->_dbtables); - } else { - unset($this->_dbtables); - } - foreach($tables as $tblval) { - // check for selected table - if(isset($this->_dbtables)) { - if(strstr(",{$this->_dbtables},", ",{$tblval},") === false) { - continue; - } - } - if($callBack === 'snapshot') { - /* - switch($tblval) - { - case $modx->db->config['table_prefix'].'event_log': - case $modx->db->config['table_prefix'].'manager_log': - continue 2; - }*/ - if(!preg_match('@^' . $modx->db->config['table_prefix'] . '@', $tblval)) { - continue; - } - } - $output .= "{$lf}{$lf}# --------------------------------------------------------{$lf}{$lf}"; - $output .= "#{$lf}# Table structure for table `{$tblval}`{$lf}"; - $output .= "#{$lf}{$lf}"; - // Generate DROP TABLE statement when client wants it to. - if($this->isDroptables()) { - $output .= "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;{$lf}"; - $output .= "DROP TABLE IF EXISTS `{$tblval}`;{$lf}"; - $output .= "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;{$lf}{$lf}"; - } - $output .= "{$createtable[$tblval][0]};{$lf}"; - $output .= $lf; - $output .= "#{$lf}# Dumping data for table `{$tblval}`{$lf}#{$lf}"; - $result = $modx->db->select('*', $tblval); - $rows = $this->loadObjectList('', $result); - foreach($rows as $row) { - $insertdump = $lf; - $insertdump .= "INSERT INTO `{$tblval}` VALUES ("; - $arr = $this->object2Array($row); - foreach($arr as $key => $value) { - if(is_null($value)) { - $value = 'NULL'; - } else { - $value = addslashes($value); - $value = str_replace(array( - "\r\n", - "\r", - "\n" - ), '\\n', $value); - $value = "'{$value}'"; - } - $insertdump .= $value . ','; - } - $output .= rtrim($insertdump, ',') . ");\n"; - if(1048576 < strlen($output)) { - file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); - $output = ''; - } - } - file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); - $output = ''; - } - $output = file_get_contents($tempfile_path); - if(!empty($output)) { - unlink($tempfile_path); - } - - switch($callBack) { - case 'dumpSql': - dumpSql($output); - break; - case 'snapshot': - snapshot($output); - break; - } - return true; - } - - function result2Array($numinarray = 0, $resource) { - global $modx; - $array = array(); - while($row = $modx->db->getRow($resource, 'num')) { - $array[] = $row[$numinarray]; - } - $modx->db->freeResult($resource); - return $array; - } - - // Private function object2Array. - - function isDroptables() { - return $this->_isDroptables; - } - - // Private function loadObjectList. - - function loadObjectList($key = '', $resource) { - global $modx; - $array = array(); - while($row = $modx->db->getRow($resource, 'object')) { - if($key) { - $array[$row->$key] = $row; - } else { - $array[] = $row; - } - } - $modx->db->freeResult($resource); - return $array; - } - - // Private function result2Array. - - function object2Array($obj) { - $array = null; - if(is_object($obj)) { - $array = array(); - foreach(get_object_vars($obj) as $key => $value) { - if(is_object($value)) { - $array[$key] = $this->object2Array($value); - } else { - $array[$key] = $value; - } - } - } - return $array; - } +class Mysqldumper +{ + var $_dbtables; + var $_isDroptables; + var $database_server; + var $dbname; + + function __construct($database_server, $database_user, $database_password, $dbname) + { + // Don't drop tables by default. + $this->dbname = $dbname; + $this->setDroptables(false); + } + + function setDroptables($state) + { + $this->_isDroptables = $state; + } + + // If set to true, it will generate 'DROP TABLE IF EXISTS'-statements for each table. + + function setDBtables($dbtables) + { + $this->_dbtables = $dbtables; + } + + function createDump($callBack) + { + global $modx; + + // Set line feed + $lf = "\n"; + $tempfile_path = $modx->config['base_path'] . 'assets/backup/temp.php'; + + $result = $modx->db->query('SHOW TABLES'); + $tables = $this->result2Array(0, $result); + foreach ($tables as $tblval) { + $result = $modx->db->query("SHOW CREATE TABLE `{$tblval}`"); + $createtable[$tblval] = $this->result2Array(1, $result); + } + + $version = $modx->getVersionData(); + + // Set header + $output = "#{$lf}"; + $output .= "# " . addslashes($modx->config['site_name']) . " Database Dump{$lf}"; + $output .= "# MODX Version:{$version['version']}{$lf}"; + $output .= "# {$lf}"; + $output .= "# Host: {$this->database_server}{$lf}"; + $output .= "# Generation Time: " . $modx->toDateFormat(time()) . $lf; + $output .= "# Server version: " . $modx->db->getVersion() . $lf; + $output .= "# PHP Version: " . phpversion() . $lf; + $output .= "# Database: `{$this->dbname}`{$lf}"; + $output .= "# Description: " . trim($_REQUEST['backup_title']) . "{$lf}"; + $output .= "#"; + file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); + $output = ''; + + // Generate dumptext for the tables. + if (isset($this->_dbtables) && count($this->_dbtables)) { + $this->_dbtables = implode(',', $this->_dbtables); + } else { + unset($this->_dbtables); + } + foreach ($tables as $tblval) { + // check for selected table + if (isset($this->_dbtables)) { + if (strstr(",{$this->_dbtables},", ",{$tblval},") === false) { + continue; + } + } + if ($callBack === 'snapshot') { + /* + switch($tblval) + { + case $modx->db->config['table_prefix'].'event_log': + case $modx->db->config['table_prefix'].'manager_log': + continue 2; + }*/ + if (!preg_match('@^' . $modx->db->config['table_prefix'] . '@', $tblval)) { + continue; + } + } + $output .= "{$lf}{$lf}# --------------------------------------------------------{$lf}{$lf}"; + $output .= "#{$lf}# Table structure for table `{$tblval}`{$lf}"; + $output .= "#{$lf}{$lf}"; + // Generate DROP TABLE statement when client wants it to. + if ($this->isDroptables()) { + $output .= "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;{$lf}"; + $output .= "DROP TABLE IF EXISTS `{$tblval}`;{$lf}"; + $output .= "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;{$lf}{$lf}"; + } + $output .= "{$createtable[$tblval][0]};{$lf}"; + $output .= $lf; + $output .= "#{$lf}# Dumping data for table `{$tblval}`{$lf}#{$lf}"; + $result = $modx->db->select('*', $tblval); + $rows = $this->loadObjectList('', $result); + foreach ($rows as $row) { + $insertdump = $lf; + $insertdump .= "INSERT INTO `{$tblval}` VALUES ("; + $arr = $this->object2Array($row); + foreach ($arr as $key => $value) { + if (is_null($value)) { + $value = 'NULL'; + } else { + $value = addslashes($value); + $value = str_replace(array( + "\r\n", + "\r", + "\n" + ), '\\n', $value); + $value = "'{$value}'"; + } + $insertdump .= $value . ','; + } + $output .= rtrim($insertdump, ',') . ");\n"; + if (1048576 < strlen($output)) { + file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); + $output = ''; + } + } + file_put_contents($tempfile_path, $output, FILE_APPEND | LOCK_EX); + $output = ''; + } + $output = file_get_contents($tempfile_path); + if (!empty($output)) { + unlink($tempfile_path); + } + + switch ($callBack) { + case 'dumpSql': + dumpSql($output); + break; + case 'snapshot': + snapshot($output); + break; + } + return true; + } + + function result2Array($numinarray = 0, $resource) + { + global $modx; + $array = array(); + while ($row = $modx->db->getRow($resource, 'num')) { + $array[] = $row[$numinarray]; + } + $modx->db->freeResult($resource); + return $array; + } + + // Private function object2Array. + + function isDroptables() + { + return $this->_isDroptables; + } + + // Private function loadObjectList. + + function loadObjectList($key = '', $resource) + { + global $modx; + $array = array(); + while ($row = $modx->db->getRow($resource, 'object')) { + if ($key) { + $array[$row->$key] = $row; + } else { + $array[] = $row; + } + } + $modx->db->freeResult($resource); + return $array; + } + + // Private function result2Array. + + function object2Array($obj) + { + $array = null; + if (is_object($obj)) { + $array = array(); + foreach (get_object_vars($obj) as $key => $value) { + if (is_object($value)) { + $array[$key] = $this->object2Array($value); + } else { + $array[$key] = $value; + } + } + } + return $array; + } } -function import_sql($source, $result_code = 'import_ok') { - global $modx, $e; - - if($modx->getLockedElements() !== array()) { - $modx->webAlertAndQuit("At least one Resource is still locked or edited right now by any user. Remove locks or ask users to log out before proceeding."); - } - - $settings = getSettings(); - - if(strpos($source, "\r") !== false) { - $source = str_replace(array( - "\r\n", - "\n", - "\r" - ), "\n", $source); - } - $sql_array = preg_split('@;[ \t]*\n@', $source); - foreach($sql_array as $sql_entry) { - $sql_entry = trim($sql_entry, "\r\n; "); - if(empty($sql_entry)) { - continue; - } - $rs = $modx->db->query($sql_entry); - } - restoreSettings($settings); - - $modx->clearCache(); - - $_SESSION['last_result'] = $modx->db->makeArray($rs); - - $_SESSION['result_msg'] = $result_code; +function import_sql($source, $result_code = 'import_ok') +{ + global $modx, $e; + + if ($modx->getLockedElements() !== array()) { + $modx->webAlertAndQuit("At least one Resource is still locked or edited right now by any user. Remove locks or ask users to log out before proceeding."); + } + + $settings = getSettings(); + + if (strpos($source, "\r") !== false) { + $source = str_replace(array( + "\r\n", + "\n", + "\r" + ), "\n", $source); + } + $sql_array = preg_split('@;[ \t]*\n@', $source); + foreach ($sql_array as $sql_entry) { + $sql_entry = trim($sql_entry, "\r\n; "); + if (empty($sql_entry)) { + continue; + } + $rs = $modx->db->query($sql_entry); + } + restoreSettings($settings); + + $modx->clearCache(); + + $_SESSION['last_result'] = $modx->db->makeArray($rs); + + $_SESSION['result_msg'] = $result_code; } -function dumpSql(&$dumpstring) { - global $modx; - $today = $modx->toDateFormat(time(), 'dateOnly'); - $today = str_replace('/', '-', $today); - $today = strtolower($today); - $size = strlen($dumpstring); - if(!headers_sent()) { - header('Expires: 0'); - header('Cache-Control: private'); - header('Pragma: cache'); - header('Content-type: application/download'); - header("Content-Length: {$size}"); - header("Content-Disposition: attachment; filename={$today}_database_backup.sql"); - } - echo $dumpstring; - return true; +function dumpSql(&$dumpstring) +{ + global $modx; + $today = $modx->toDateFormat(time(), 'dateOnly'); + $today = str_replace('/', '-', $today); + $today = strtolower($today); + $size = strlen($dumpstring); + if (!headers_sent()) { + header('Expires: 0'); + header('Cache-Control: private'); + header('Pragma: cache'); + header('Content-type: application/download'); + header("Content-Length: {$size}"); + header("Content-Disposition: attachment; filename={$today}_database_backup.sql"); + } + echo $dumpstring; + return true; } -function snapshot(&$dumpstring) { - global $path; - file_put_contents($path, $dumpstring, FILE_APPEND); - return true; +function snapshot(&$dumpstring) +{ + global $path; + file_put_contents($path, $dumpstring, FILE_APPEND); + return true; } -function getSettings() { - global $modx; - $tbl_system_settings = $modx->getFullTableName('system_settings'); - - $rs = $modx->db->select('setting_name, setting_value', $tbl_system_settings); - - $settings = array(); - while($row = $modx->db->getRow($rs)) { - switch($row['setting_name']) { - case 'rb_base_dir': - case 'filemanager_path': - case 'site_url': - case 'base_url': - $settings[$row['setting_name']] = $row['setting_value']; - break; - } - } - return $settings; +function getSettings() +{ + global $modx; + $tbl_system_settings = $modx->getFullTableName('system_settings'); + + $rs = $modx->db->select('setting_name, setting_value', $tbl_system_settings); + + $settings = array(); + while ($row = $modx->db->getRow($rs)) { + switch ($row['setting_name']) { + case 'rb_base_dir': + case 'filemanager_path': + case 'site_url': + case 'base_url': + $settings[$row['setting_name']] = $row['setting_value']; + break; + } + } + return $settings; } -function restoreSettings($settings) { - global $modx; - $tbl_system_settings = $modx->getFullTableName('system_settings'); +function restoreSettings($settings) +{ + global $modx; + $tbl_system_settings = $modx->getFullTableName('system_settings'); - foreach($settings as $k => $v) { - $modx->db->update(array('setting_value' => $v), $tbl_system_settings, "setting_name='{$k}'"); - } + foreach ($settings as $k => $v) { + $modx->db->update(array('setting_value' => $v), $tbl_system_settings, "setting_name='{$k}'"); + } } -function parsePlaceholder($tpl = '', $ph = array()) { - if(empty($ph) || empty($tpl)) { - return $tpl; - } - - foreach($ph as $k => $v) { - $k = "[+{$k}+]"; - $tpl = str_replace($k, $v, $tpl); - } - return $tpl; +function parsePlaceholder($tpl = '', $ph = array()) +{ + if (empty($ph) || empty($tpl)) { + return $tpl; + } + + foreach ($ph as $k => $v) { + $k = "[+{$k}+]"; + $tpl = str_replace($k, $v, $tpl); + } + return $tpl; } diff --git a/manager/actions/category_mgr/skin/add.tpl.phtml b/manager/actions/category_mgr/skin/add.tpl.phtml index 7a857666e3..c5b0e49afb 100644 --- a/manager/actions/category_mgr/skin/add.tpl.phtml +++ b/manager/actions/category_mgr/skin/add.tpl.phtml @@ -1,29 +1,20 @@
    - - - - - - - - - - - - - - - - - -
    txt('cm_category_name'); ?>txt('cm_category_position'); ?>
    -
    \ No newline at end of file + + +

    + Add a new category to the Manager. +

    +
    +
    + + +
    +
    + + +
    +
    + diff --git a/manager/actions/category_mgr/skin/categorize.tpl.phtml b/manager/actions/category_mgr/skin/categorize.tpl.phtml index 2ffc6585a2..5a0522a0e1 100644 --- a/manager/actions/category_mgr/skin/categorize.tpl.phtml +++ b/manager/actions/category_mgr/skin/categorize.tpl.phtml @@ -1,30 +1,20 @@
    - - - - -
    - renderView('chunks/categorize/elements_select'); ?> -
    - - - - - -
    \ No newline at end of file + + +

    + Categorize elements easily by dragging them into categories. +

    +
    + renderView('chunks/categorize/elements_select'); ?> +
    + + + diff --git a/manager/actions/category_mgr/skin/chunks/categorize/drag_element.tpl.phtml b/manager/actions/category_mgr/skin/chunks/categorize/drag_element.tpl.phtml index 64d1fd0c7c..c8ad6c1eb0 100644 --- a/manager/actions/category_mgr/skin/chunks/categorize/drag_element.tpl.phtml +++ b/manager/actions/category_mgr/skin/chunks/categorize/drag_element.tpl.phtml @@ -1,6 +1,6 @@ -
    -

    - -

    - -
    \ No newline at end of file +
    > +

    + +

    + +
    diff --git a/manager/actions/category_mgr/skin/chunks/edit/assigned_elements_collapse.tpl.phtml b/manager/actions/category_mgr/skin/chunks/edit/assigned_elements_collapse.tpl.phtml index b1c9fc8deb..58eba8adc5 100644 --- a/manager/actions/category_mgr/skin/chunks/edit/assigned_elements_collapse.tpl.phtml +++ b/manager/actions/category_mgr/skin/chunks/edit/assigned_elements_collapse.tpl.phtml @@ -1,8 +1,8 @@ - +
    $items ) : ?> - + @@ -10,9 +10,9 @@ $items ) : ?> - + - - config['show_meta'] === '1'): - $tbl_keyword_xref = $modx->getFullTableName('keyword_xref'); - $tbl_site_keywords = $modx->getFullTableName('site_keywords'); - $tbl_site_content_metatags = $modx->getFullTableName('site_content_metatags'); - $tbl_site_metatags = $modx->getFullTableName('site_metatags'); - // Get list of current keywords for this document - $keywords = array(); - $rs = $modx->db->select('k.keyword', "{$tbl_site_keywords} AS k, {$tbl_keyword_xref} AS x ", "k.id = x.keyword_id AND x.content_id='{$id}'", 'k.keyword ASC'); - $keywords = $modx->db->getColumn('keyword', $rs); - - // Get list of selected site META tags for this document - $metatags_selected = array(); - $rs = $modx->db->select('meta.id, meta.name, meta.tagvalue', "{$tbl_site_metatags} AS meta LEFT JOIN {$tbl_site_content_metatags} AS sc ON sc.metatag_id = meta.id", "sc.content_id='{$content['id']}'"); - while($row = $modx->db->getRow($rs)) { - $metatags_selected[] = $row['name'] . ': ' . $row['tagvalue'] . ''; - } - ?> - - - - - - - - - diff --git a/manager/actions/eventlog.dynamic.php b/manager/actions/eventlog.dynamic.php index eefda4967d..6a24f321a8 100644 --- a/manager/actions/eventlog.dynamic.php +++ b/manager/actions/eventlog.dynamic.php @@ -33,9 +33,9 @@ // context menu include_once MODX_MANAGER_PATH . "includes/controls/contextmenu.php"; $cm = new ContextMenu("cntxm", 150); -$cm->addItem($_lang['view_log'], "js:menuAction(1)", ''); +$cm->addItem($_lang['view_log'], "js:menuAction(1)", $_style['actions_preview']); $cm->addSeparator(); -$cm->addItem($_lang['delete'], "js:menuAction(2)", '', (!$modx->hasPermission('delete_eventlog') ? 1 : 0)); +$cm->addItem($_lang['delete'], "js:menuAction(2)", $_style['actions_delete'], (!$modx->hasPermission('delete_eventlog') ? 1 : 0)); echo $cm->render(); ?> @@ -82,7 +82,7 @@ function menuAction(a) { } } - document.addEvent('click', function() { + document.addEventListener('click', function() { contextm.style.visibility = "hidden"; }); @@ -109,45 +109,51 @@ function menuAction(a) {
    -
    - db->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el + +
    +
    + db->select("el.id, ELT(el.type , 'text-info {$_style['actions_info']}' , 'text-warning {$_style['actions_triangle']}' , 'text-danger {$_style['actions_error']}' ) as icon, el.createdon, el.source, el.eventid,IFNULL(wu.username,mu.username) as username", "{$tbl_event_log} AS el LEFT JOIN {$tbl_manager_users} AS mu ON mu.id=el.user AND el.usertype=0 LEFT JOIN {$tbl_web_users} AS wu ON wu.id=el.user AND el.usertype=1", ($sqlQuery ? "" . (is_numeric($sqlQuery) ? "(eventid='{$sqlQuery}') OR " : '') . "(source LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "createdon DESC"); - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; - $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items - $grd->pagerClass = ''; - $grd->pageClass = 'page-item'; - $grd->selPageClass = 'page-item active'; - $grd->noRecordMsg = $_lang['no_records_found']; - $grd->cssClass = "table data"; - $grd->columnHeaderClass = "tableHeader"; - $grd->itemClass = "tableItem"; - $grd->altItemClass = "tableAltItem"; - $grd->fields = "type,source,createdon,eventid,username"; - $grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid']; - $grd->colWidths = "1%,,150,1%,1%"; - $grd->colAligns = "center,,,center,center"; - $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p'; - if($listmode == '1') { - $grd->pageSize = 0; - } - if($_REQUEST['op'] == 'reset') { - $grd->pageNumber = 1; - } - // render grid - echo $grd->render(); - ?> + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; + $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items + $grd->pagerClass = ''; + $grd->pageClass = 'page-item'; + $grd->selPageClass = 'page-item active'; + $grd->noRecordMsg = $_lang['no_records_found']; + $grd->cssClass = "table data nowrap"; + $grd->columnHeaderClass = "tableHeader"; + $grd->itemClass = "tableItem"; + $grd->altItemClass = "tableAltItem"; + $grd->fields = "type,source,createdon,eventid,username"; + $grd->columns = $_lang['type'] . " ," . $_lang['source'] . " ," . $_lang['date'] . " ," . $_lang['event_id'] . " ," . $_lang['sysinfo_userid']; + $grd->colWidths = "1%,,1%,1%,1%"; + $grd->colAligns = "center,,,center,center"; + $grd->colTypes = "template:||template:[+source+]||date: " . $modx->toDateFormat(null, 'formatOnly') . ' %I:%M %p'; + if($listmode == '1') { + $grd->pageSize = 0; + } + if($_REQUEST['op'] == 'reset') { + $grd->pageNumber = 1; + } + // render grid + echo $grd->render(); + ?> +
    +
    diff --git a/manager/actions/files.dynamic.php b/manager/actions/files.dynamic.php index 08da47ecdf..37beab4aa8 100644 --- a/manager/actions/files.dynamic.php +++ b/manager/actions/files.dynamic.php @@ -1,9 +1,9 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('file_manager')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('file_manager')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $token_check = checkToken(); $newToken = makeToken(); @@ -11,9 +11,9 @@ // settings $theme_image_path = $modx->config['site_manager_url'] . 'media/style/' . $modx->config['manager_theme'] . '/images/'; $excludes = array( - '.', - '..', - '.svn' + '.', + '..', + '.svn' ); $alias_suffix = (!empty($friendly_url_suffix)) ? ',' . ltrim($friendly_url_suffix, '.') : ''; $editablefiles = explode(',', 'txt,php,tpl,less,sass,shtml,html,htm,xml,js,css,pageCache,htaccess' . $alias_suffix); @@ -33,28 +33,28 @@ $protected_path[] = $modx->config['base_path'] . 'temp/backup'; $protected_path[] = $modx->config['base_path'] . 'assets/backup'; -if(!$modx->hasPermission('save_plugin')) { - $protected_path[] = $modx->config['base_path'] . 'assets/plugins'; +if (!$modx->hasPermission('save_plugin')) { + $protected_path[] = $modx->config['base_path'] . 'assets/plugins'; } -if(!$modx->hasPermission('save_snippet')) { - $protected_path[] = $modx->config['base_path'] . 'assets/snippets'; +if (!$modx->hasPermission('save_snippet')) { + $protected_path[] = $modx->config['base_path'] . 'assets/snippets'; } -if(!$modx->hasPermission('save_template')) { - $protected_path[] = $modx->config['base_path'] . 'assets/templates'; +if (!$modx->hasPermission('save_template')) { + $protected_path[] = $modx->config['base_path'] . 'assets/templates'; } -if(!$modx->hasPermission('save_module')) { - $protected_path[] = $modx->config['base_path'] . 'assets/modules'; +if (!$modx->hasPermission('save_module')) { + $protected_path[] = $modx->config['base_path'] . 'assets/modules'; } -if(!$modx->hasPermission('empty_cache')) { - $protected_path[] = $modx->config['base_path'] . 'assets/cache'; +if (!$modx->hasPermission('empty_cache')) { + $protected_path[] = $modx->config['base_path'] . 'assets/cache'; } -if(!$modx->hasPermission('import_static')) { - $protected_path[] = $modx->config['base_path'] . 'temp/import'; - $protected_path[] = $modx->config['base_path'] . 'assets/import'; +if (!$modx->hasPermission('import_static')) { + $protected_path[] = $modx->config['base_path'] . 'temp/import'; + $protected_path[] = $modx->config['base_path'] . 'assets/import'; } -if(!$modx->hasPermission('export_static')) { - $protected_path[] = $modx->config['base_path'] . 'temp/export'; - $protected_path[] = $modx->config['base_path'] . 'assets/export'; +if (!$modx->hasPermission('export_static')) { + $protected_path[] = $modx->config['base_path'] . 'temp/export'; + $protected_path[] = $modx->config['base_path'] . 'assets/export'; } /* } @@ -75,890 +75,919 @@ $uploadablefiles = array(); $uploadablefiles = array_merge($upload_files, $upload_images, $upload_media, $upload_flash); $uploadablefiles = add_dot($uploadablefiles); -function add_dot($array) { - $count = count($array); - for($i = 0; $i < $count; $i++) { - $array[$i] = '.' . strtolower(trim($array[$i])); // add a dot :) - } - return $array; +function add_dot($array) +{ + $count = count($array); + for ($i = 0; $i < $count; $i++) { + $array[$i] = '.' . strtolower(trim($array[$i])); // add a dot :) + } + return $array; } // end settings // get the current work directory -if(isset($_REQUEST['path']) && !empty($_REQUEST['path'])) { - $_REQUEST['path'] = str_replace('..', '', $_REQUEST['path']); - $startpath = is_dir($_REQUEST['path']) ? $_REQUEST['path'] : removeLastPath($_REQUEST['path']); +if (isset($_REQUEST['path']) && !empty($_REQUEST['path'])) { + $_REQUEST['path'] = str_replace('..', '', $_REQUEST['path']); + $startpath = is_dir($_REQUEST['path']) ? $_REQUEST['path'] : removeLastPath($_REQUEST['path']); } else { - $startpath = $filemanager_path; + $startpath = $filemanager_path; } $startpath = rtrim($startpath, '/'); -if(!is_readable($startpath)) { - $modx->webAlertAndQuit($_lang["not_readable_dir"]); +if (!is_readable($startpath)) { + $modx->webAlertAndQuit($_lang["not_readable_dir"]); } // Raymond: get web start path for showing pictures $rf = realpath($filemanager_path); $rw = realpath('../'); $webstart_path = str_replace('\\', '/', str_replace($rw, '', $rf)); -if(substr($webstart_path, 0, 1) == '/') { - $webstart_path = '..' . $webstart_path; +if (substr($webstart_path, 0, 1) == '/') { + $webstart_path = '..' . $webstart_path; } else { - $webstart_path = '../' . $webstart_path; + $webstart_path = '../' . $webstart_path; } ?> - - -

    - -

    - -
    -
    - - - "> - - - [+subject+]'; - $ph['image'] = $_style['files_folder-open']; - $ph['subject'] = $_lang['add_folder']; - $ph['href'] = 'index.php?a=31&mode=newfolder&path=' . urlencode($startpath) . '&name='; - $_ = parsePlaceholder($tpl, $ph); - - $tpl = '' . $_lang['files.dynamic.php1'] . ''; - $ph['image'] = $_style['files_page_html']; - $ph['href'] = 'index.php?a=31&mode=newfile&path=' . urlencode($startpath) . '&name='; - $_ .= parsePlaceholder($tpl, $ph); - echo $_; - } - ?> - - "> - -
    -
    - -
    - - webAlertAndQuit($_lang["files_access_denied"]); - } - - // Unzip .zip files - by Raymond - if($enablefileunzip && $_REQUEST['mode'] == 'unzip' && is_writable($startpath)) { - if(!$err = unzip(realpath("{$startpath}/" . $_REQUEST['file']), realpath($startpath))) { - echo '' . $_lang['file_unzip_fail'] . ($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '') . '

    '; - } else { - echo '' . $_lang['file_unzip'] . '

    '; - } - } - // End Unzip - Raymond - - - // New Folder & Delete Folder option - Raymond - if(is_writable($startpath)) { - // Delete Folder - if($_REQUEST['mode'] == 'deletefolder') { - $folder = $_REQUEST['folderpath']; - if(!$token_check || !@rrmdir($folder)) { - echo '' . $_lang['file_folder_not_deleted'] . '

    '; - } else { - echo '' . $_lang['file_folder_deleted'] . '

    '; - } - } - - // Create folder here - if($_REQUEST['mode'] == 'newfolder') { - $old_umask = umask(0); - $foldername = str_replace('..\\', '', str_replace('../', '', $_REQUEST['name'])); - if(!mkdirs("{$startpath}/{$foldername}", 0777)) { - echo '', $_lang['file_folder_not_created'], '

    '; - } else { - if(!@chmod($startpath . '/' . $foldername, $newfolderaccessmode)) { - echo '' . $_lang['file_folder_chmod_error'] . '

    '; - } else { - echo '' . $_lang['file_folder_created'] . '

    '; - } - } - umask($old_umask); - } - // Create file here - if($_REQUEST['mode'] == 'newfile') { - $old_umask = umask(0); - $filename = str_replace('..\\', '', str_replace('../', '', $_REQUEST['name'])); - $filename = $modx->db->escape($filename); - - if(!checkExtension($filename)) { - echo '' . $_lang['files_filetype_notok'] . '

    '; - } elseif(preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $filename) !== 0) { - echo $_lang['files.dynamic.php3']; - } else { - $rs = file_put_contents("{$startpath}/{$filename}", ''); - if($rs === false) { - echo '', $_lang['file_folder_not_created'], '

    '; - } else { - echo $_lang['files.dynamic.php4']; - } - umask($old_umask); - } - } - // Duplicate file here - if($_REQUEST['mode'] == 'duplicate') { - $old_umask = umask(0); - $filename = $_REQUEST['path']; - $filename = $modx->db->escape($filename); - $newFilename = str_replace('..\\', '', str_replace('../', '', $_REQUEST['newFilename'])); - $newFilename = $modx->db->escape($newFilename); - - if(!checkExtension($newFilename)) { - echo '' . $_lang['files_filetype_notok'] . '

    '; - } elseif(preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { - echo $_lang['files.dynamic.php3']; - } else { - if(!copy($filename, MODX_BASE_PATH . $newFilename)) { - echo $_lang['files.dynamic.php5']; - } - umask($old_umask); - } - } - // Rename folder here - if($_REQUEST['mode'] == 'renameFolder') { - $old_umask = umask(0); - $dirname = $_REQUEST['path'] . '/' . $_REQUEST['dirname']; - $dirname = $modx->db->escape($dirname); - $newDirname = str_replace(array( - '..\\', - '../', - '\\', - '/' - ), '', $_REQUEST['newDirname']); - $newDirname = $modx->db->escape($newDirname); - - if(preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newDirname) !== 0) { - echo $_lang['files.dynamic.php3']; - } else if(!rename($dirname, $_REQUEST['path'] . '/' . $newDirname)) { - echo '', $_lang['file_folder_not_created'], '

    '; - } - umask($old_umask); - } - // Rename file here - if($_REQUEST['mode'] == 'renameFile') { - $old_umask = umask(0); - $path = dirname($_REQUEST['path']); - $filename = $_REQUEST['path']; - $filename = $modx->db->escape($filename); - $newFilename = str_replace(array( - '..\\', - '../', - '\\', - '/' - ), '', $_REQUEST['newFilename']); - $newFilename = $modx->db->escape($newFilename); - - if(!checkExtension($newFilename)) { - echo '' . $_lang['files_filetype_notok'] . '

    '; - } elseif(preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { - echo $_lang['files.dynamic.php3']; - } else { - if(!rename($filename, $path . '/' . $newFilename)) { - echo $_lang['files.dynamic.php5']; - } - umask($old_umask); - } - } - } - // End New Folder - Raymond - - $filesize = 0; - $files = 0; - $folders = 0; - $dirs_array = array(); - $files_array = array(); - if(strlen(MODX_BASE_PATH) < strlen($filemanager_path)) { - $len--; - } - - ?> -
    -
    txt( $element ); ?>txt( $element ); ?>

    txt( 'none' ); ?>

    txt( 'none' ); ?>

    +
    • diff --git a/manager/actions/category_mgr/skin/css/module.css b/manager/actions/category_mgr/skin/css/module.css index a041c4b340..ef06ef65eb 100644 --- a/manager/actions/category_mgr/skin/css/module.css +++ b/manager/actions/category_mgr/skin/css/module.css @@ -205,7 +205,7 @@ div#section-body-categories div.drag p { } div#section-body-categories div.drag:hover p { - display: block; + /*display: block;*/ } div#section-body-categories div.uncategorized_elements, @@ -277,4 +277,4 @@ td.assigned > button.btn:hover { background-color:#37bdf4; } margin: 15px 15px 10px 15px; }*/ -#category-edit table.grid .gridAltItem { background-color:#fff; } \ No newline at end of file +#category-edit table.grid .gridAltItem { background-color:#fff; } diff --git a/manager/actions/category_mgr/skin/edit.tpl.phtml b/manager/actions/category_mgr/skin/edit.tpl.phtml index 110c22afab..7be26e7d9b 100644 --- a/manager/actions/category_mgr/skin/edit.tpl.phtml +++ b/manager/actions/category_mgr/skin/edit.tpl.phtml @@ -1,54 +1,53 @@
      - - - - - - - - - - - - - - - - - - - - - - - - - - -
      txt('cm_assigned_elements'); ?>txt('cm_edit_name'); ?>txt('cm_mark_for_deletion'); ?>txt('cm_delete_now'); ?>
      - -
      renderView('chunks/edit/assigned_elements', $view->getAllAssignedElements($category['id'])); ?>
      -
      - - - - - - - txt('delete'); ?> -
      - renderView('chunks/edit/assigned_elements_collapse', $view->getAllAssignedElements($category['id'])); ?> -
      -
      \ No newline at end of file + + +

      + Change category name or delete category from the Manager. +

      +
      +
      + + + + + + + + + + + + + + + + + + + + + + +
      txt('cm_assigned_elements'); ?>txt('cm_edit_name'); ?>txt('cm_mark_for_deletion'); ?>txt('cm_delete_now'); ?>
      + +
      renderView('chunks/edit/assigned_elements', $view->getAllAssignedElements($category['id'])); ?>
      +
      + + + + + + + txt('delete'); ?> +
      + renderView('chunks/edit/assigned_elements_collapse', $view->getAllAssignedElements($category['id'])); ?> +
      +
      +
      + diff --git a/manager/actions/category_mgr/skin/js/categories.js b/manager/actions/category_mgr/skin/js/categories.js index 6c4010ce84..b433546973 100644 --- a/manager/actions/category_mgr/skin/js/categories.js +++ b/manager/actions/category_mgr/skin/js/categories.js @@ -1,157 +1,109 @@ - -//window.addEvent('domready',function(){ - /** - * Tips + * + * Select Categories */ -new Tips($$('.mootooltip'),{className:'custom'} ); -new MooTips($$('.mootooltip_dom'), { - className :'assigned', - showOnClick: true, - showOnMouseEnter: true, - showDelay: 200, - hideDelay: 200, - offsets: {'x': 20, 'y': 20}, - fixed: true -}); +let ajax_url = 'index.php?a=121'; +let categorizeWorkbench = document.getElementById('categorize-workbench'); +document.getElementById('elements-select').onchange = function(e) { + categorizeWorkbench.innerHTML = ''; + categorizeWorkbench.classList.add('ajax_loading'); + document.getElementById('categorize-elements').classList.remove('hidden'); + document.getElementById('categorize-formfields').innerHTML = ''; + let xhr = new XMLHttpRequest(); + xhr.open('POST', ajax_url, true); + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;'); + xhr.onload = function() { + if (this.readyState === 4) { + categorizeWorkbench.classList.remove('ajax_loading'); + categorizeWorkbench.innerHTML = this.responseText; + evo.tooltips('#categorize-elements [data-tooltip]'); + evo.draggable('.drag', { + handle: { + start: function() { + this.style.opacity = '.5'; + this.style.zIndex = 10000; + }, end: function() { + this.style.opacity = 1; + this.style.zIndex = 1000; + }, + }, container: { + className: 'drop', classOver: 'over', over: function() { + this.classList.add('over'); + }, leave: function() { + this.classList.remove('over'); + }, drop: function(drag) { + this.classList.remove('over'); + drag.classList.add('ok'); + }, + }, + }); + } + }; + xhr.send(request_key + '[ajax]=1&' + request_key + '[task]=categorize_load_elements&' + request_key + '[elements]=' + e.target.value); +}; /** * Sort Categories */ -new Sortables($('categories-sort'), { - //handles:'span.handle', - onStart: function(element){ - element.toggleClass('move'); - }, - onComplete: function(element){ - element.toggleClass('move'); - // reorder the indexes - this.list.getChildren().each(function(element, i){ - element.getElement('input.sort').setProperty( 'value', (i+1) ); - element.getElement('span.sort').setHTML( (i+1) ); - element.getElements('td').each(function(td){ - td.removeClass('gridItem').removeClass('gridAltItem'); - td.addClass( ( i%2===0 ) ? 'gridItem' : 'gridAltItem' ); - }); - }); +evo.sortable('.table-sortable tbody > tr', { + complete: function() { + let els = document.querySelectorAll('.table-sortable tbody > tr'); + for (let i = 0; i < els.length; i++) { + els[i].querySelector('input.sort').value = i + 1; + els[i].querySelector('span.sort').innerHTML = i + 1; } + }, }); -/** - * Categorization - */ -var reset_position = function( drag ) { - drag.setStyles({ left:0+"px", top:0+"px" }); -} - -var optDrop = { - over: function(drag) { - this.addClass('over'); - drag.addClass('ok'); - }, - leave: function(drag) { - this.removeClass('over'); - drag.removeClass('ok'); - }, - drop: function(drag) { - this.removeClass('over'); - drag.injectInside(this); - reset_position(drag); - } -} - -var optDrag = { - onStart: function(drag) { - drag.setOpacity(.5).setStyle('z-index', 10000); - }, - onComplete: function(drag) { - drag.setOpacity(1).setStyle('z-index', 1000); - reset_position(drag); - } -} - -var init_drag = function() { - - optDrag.droppables = $$('div.drop').addEvents( optDrop ); - $$('div#categorize-workbench div.drag').makeDraggable( optDrag ); - $$('div#categorize-workbench div.drag').each(function(element){ reset_position(element) }); - - /** - * Make container uncategorized elements movable.... but for what - - if( $('categorize-category-0') !== null ){ - var first_click = true; - var container_uncategorized = $('categorize-category-0'); - container_uncategorized.getElement('h2').addEvent('click',function(){ - if( first_click === true ) { - this.getParent().setStyles({ - 'top' : '-50px', - 'left': '0' - }); - new Drag.Move(container_uncategorized, { - handle: container_uncategorized.getElement('h2') - }); - first_click = false; - } - }); - } - - */ -} - /** * collect the categorization in formfields - * + * * @TODO collect them within a object and send by jason-request. - */ -$('categorize-submit').addEvent('mouseenter',function() { - - this.setProperty('disabled','disabled'); - this.setProperty('value','wait...'); - - $('categorize-formfields').empty(); - - $$('div.categorize_category').each(function(drop) { - - category_id = drop.getProperty('id').split('-')[2]; - category_name = drop.getElement('h2').getText().trim(); - elements = drop.getElements('div.drag'); - - if( elements.length > 0 ) { - elements.each(function(element,index) { - var element_id = element.getProperty('id').split('-')[2]; - var element_name = element.getElement('h4').getText(); - var id_input_element = 'input-element-'+element_id; - var id_input_element_name = 'input-element-name-'+element_id; - var id_input_category_name = 'input-category-name-'+element_id; - - new Element( 'input', { - 'type' : 'text', - 'id' : id_input_element_name, - 'name' : request_key + '[categorize][elements]['+element_id+'][element_name]', - 'value': element_name.trim() - }).injectInside( $('categorize-formfields') ); - - new Element( 'input', { - 'type' : 'text', - 'id' : id_input_element, - 'name' : request_key + '[categorize][elements]['+element_id+'][category_id]', - 'value': category_id - }).injectInside( $('categorize-formfields') ); - - new Element( 'input', { - 'type' : 'text', - 'id' : id_input_category_name, - 'name' : request_key + '[categorize][elements]['+element_id+'][category_name]', - 'value': category_name.trim() - }).injectInside( $('categorize-formfields') ); + */ +document.getElementById('categorize-submit').addEventListener('mouseenter', function() { + this.disabled = 'disabled'; + this.value = 'wait...'; + let categorizeFormfields = document.getElementById('categorize-formfields'); + categorizeFormfields.innerHTML = ''; + + [].slice.call(document.querySelectorAll('div.categorize_category')).forEach(function(a) { + let category_id = a.id.split('-')[2]; + let category_name = a.querySelector('h2').innerText.replace(/^\s+|\s+$/g, ''); + let elements = a.querySelectorAll('div.drag'); + + if (elements.length > 0) { + elements.forEach(function(element) { + let element_id = element.id.split('-')[2]; + let element_name = element.querySelector('h4').innerText.replace(/^\s+|\s+$/g, ''); + let id_input_element = 'input-element-' + element_id; + let id_input_element_name = 'input-element-name-' + element_id; + let id_input_category_name = 'input-category-name-' + element_id; + + let input = document.createElement('input'); + input.type = 'text'; + input.id = id_input_element_name; + input.name = request_key + '[categorize][elements][' + element_id + '][element_name]'; + input.value = element_name; + categorizeFormfields.appendChild(input); + + input = document.createElement('input'); + input.type = 'text'; + input.id = id_input_element; + input.name = request_key + '[categorize][elements][' + element_id + '][category_id]'; + input.value = category_id; + categorizeFormfields.appendChild(input); + + input = document.createElement('input'); + input.type = 'text'; + input.id = id_input_category_name; + input.name = request_key + '[categorize][elements][' + element_id + '][category_name]'; + input.value = category_name; + categorizeFormfields.appendChild(input); + }); + } + }); - }); - } - }); + this.disabled = ''; + this.value = 'Save categorization'; - this.removeProperty('disabled'); - this.setProperty('value','Save categorization'); }); - -//}); diff --git a/manager/actions/category_mgr/skin/main.tpl.phtml b/manager/actions/category_mgr/skin/main.tpl.phtml index f89f2e7e14..28fb9a8fb5 100644 --- a/manager/actions/category_mgr/skin/main.tpl.phtml +++ b/manager/actions/category_mgr/skin/main.tpl.phtml @@ -1,102 +1,89 @@ - - -js_output)) : ?> - - + +js_output)) : ?> + +

      - get('name') ?> + get('name') ?>

      -
      - - - renderView('chunks/db_setup'); ?> - - - renderView('chunks/messages', $view->getMessages('global')); ?> - -
      - - -
      -

      txt('cm_add_new_category'); ?>

      - - renderView('chunks/messages', $view->getMessages('add')); ?> - renderView('add'); ?> -
      - - - -
      -

      txt('cm_edit_categories'); ?>

      - - renderView('chunks/messages', $view->getMessages('edit')); ?> - renderView('edit', $data); ?> -
      - -
      -

      txt('cm_sort_categories'); ?>

      - - renderView('chunks/messages', $view->getMessages('sort')); ?> - renderView('sort', $data); ?> -
      - -
      -

      txt('cm_categorize_elements'); ?>

      - - renderView('chunks/messages', $view->getMessages('categorize')); ?> - renderView('categorize', $data); ?> -
      - - - - new_translations[$view->get('manager_language')] && !empty($view->new_translations[$view->get('manager_language')])) : ?> - -
      -

      txt('Translations'); ?>

      - - renderView('chunks/messages', $view->getMessages('translate')); ?> - renderView('translate', $view->new_translations[$view->get('manager_language')]); ?> -
      - - - -
      - - - -
      + + renderView('chunks/db_setup') ?> + + +
      + +
      renderView('chunks/messages', $view->getMessages('global')) ?>
      + +
      + + +
      +

      txt('cm_add_new_category') ?>

      + +
      + renderView('chunks/messages', $view->getMessages('add')) ?> + renderView('add') ?> +
      +
      + + + +
      +

      txt('cm_edit_categories') ?>

      + +
      + renderView('chunks/messages', $view->getMessages('edit')) ?> + renderView('edit', $data) ?> +
      +
      + +
      +

      txt('cm_sort_categories') ?>

      + +
      + renderView('chunks/messages', $view->getMessages('sort')) ?> + renderView('sort', $data) ?> +
      +
      + +
      +

      txt('cm_categorize_elements') ?>

      + +
      + renderView('chunks/messages', $view->getMessages('categorize')) ?> + renderView('categorize', $data) ?> +
      +
      + + + + new_translations[$view->get('manager_language')] && !empty($view->new_translations[$view->get('manager_language')])) : ?> + +
      +

      txt('Translations') ?>

      + +
      + renderView('chunks/messages', $view->getMessages('translate')) ?> + renderView('translate', $view->new_translations[$view->get('manager_language')]) ?> +
      +
      + + + +
      + +
      + + - \ No newline at end of file + diff --git a/manager/actions/category_mgr/skin/sort.tpl.phtml b/manager/actions/category_mgr/skin/sort.tpl.phtml index be4fd6bffa..0552acf2cb 100644 --- a/manager/actions/category_mgr/skin/sort.tpl.phtml +++ b/manager/actions/category_mgr/skin/sort.tpl.phtml @@ -1,41 +1,39 @@ -
      - - - - - - - - - - - - - - - - - - - -
      txt('category_heading') ?>txt('position') ?>
      - - - - - - - - -
      + + + +

      + Drag category up or down to change its rank. Can be very useful when used with CategorizedTabs plugin to change tabs order. +

      +
      +
      + + + + + + + + + + + + + + + +
      txt('category_heading') ?>txt('position') ?>
      + + + + +
      +
      +
      diff --git a/manager/actions/document_data.static.php b/manager/actions/document_data.static.php index 7173f44f66..130c968dd8 100644 --- a/manager/actions/document_data.static.php +++ b/manager/actions/document_data.static.php @@ -96,7 +96,7 @@ // $rowHeaderClass = 'gridHeader'; // $rowRegularClass = 'gridItem'; // $rowAlternateClass = 'gridAltItem'; - $tableClass = 'table data'; + $tableClass = 'table data nowrap'; $columnHeaderClass = array( 'text-center', 'text-left', @@ -170,16 +170,9 @@ break; default: if($children['isfolder']) { - $isPrivate = ($children['privateweb'] || $children['privatemgr']) ? '1' : '0'; - $icon = $isPrivate ? $_style['tree_folder_secure'] : $_style['tree_folder_new']; + $icon = $_style['tree_folder_new']; } else { - if($children['privateweb'] || $children['privatemgr']) { - if(isset($icons[$children['contentType']])) { - $icon = $icons[$children['contentType']]; - } else { - $icon = $_style['tree_page_secure']; - } - } elseif(isset($icons[$children['contentType']])) { + if(isset($icons[$children['contentType']])) { $icon = $icons[$children['contentType']]; } else { $icon = $_style['tree_page']; @@ -187,15 +180,17 @@ } } + $private = ($children['privateweb'] || $children['privatemgr'] ? ' private' : ''); + // дописываем в заголовок класс для неопубликованных плюс по всем ссылкам обратный путь // для сохранения сортировки $class = ($children['deleted'] ? 'text-danger text-decoration-through' : (!$children['published'] ? ' font-italic text-muted' : ' publish')); //$class .= ($children['hidemenu'] ? ' text-muted' : ' text-primary'); //$class .= ($children['isfolder'] ? ' font-weight-bold' : ''); if($modx->hasPermission('edit_document')) { - $title = '' . $icon . '' . $children['pagetitle'] . ''; + $title = '' . $icon . '' . '' . $children['pagetitle'] . ''; } else { - $title = '' . $icon . '' . $children['pagetitle'] . ''; + $title = '' . $icon . '' . $children['pagetitle'] . ''; } $icon_pub_unpub = (!$children['published']) ? '' : ''; @@ -308,47 +303,6 @@ class="' . $_style["icons_move_document"] . '">' . $icon_pub_unpub : '')
    : " . $_lang['not_set'] . ")" ?>
    :" . $_lang['not_set'] . ")"; - } - ?>
    :', $metatags_selected); - } else { - echo "(" . $_lang['not_set'] . ")"; - } - ?>
     
    - - - - - - - - - '; - } - ?> -
    ' . $_lang['files_directory_is_empty'] . '
    -
    - -
    -

    - ' . $folders . ' '; - echo $_lang['files_files'] . ': ' . $files . ' '; - echo $_lang['files_data'] . ': ' . $modx->nicesize($filesizes) . ' '; - echo $_lang['files_dirwritable'] . ' ' . (is_writable($startpath) == 1 ? $_lang['yes'] . '.' : $_lang['no']) . '.' - ?> -

    - - - -
    - - - - - - -
    - - -
    -
    - " . $_lang['files_upload_inhibited_msg'] . "

    "; - } - ?> -
    -
    - -
    + + +

    + +

    + +
    +
    + + + "> + + + [+subject+]'; + $ph['image'] = $_style['files_folder-open']; + $ph['subject'] = $_lang['add_folder']; + $ph['href'] = 'index.php?a=31&mode=newfolder&path=' . urlencode($startpath) . '&name='; + $_ = parsePlaceholder($tpl, $ph); + + $tpl = '' . $_lang['files.dynamic.php1'] . ''; + $ph['image'] = $_style['files_page_html']; + $ph['href'] = 'index.php?a=31&mode=newfile&path=' . urlencode($startpath) . '&name='; + $_ .= parsePlaceholder($tpl, $ph); + echo $_; + } + ?> + + "> + +
    +
    + +
    + + webAlertAndQuit($_lang["files_access_denied"]); + } + + // Unzip .zip files - by Raymond + if ($enablefileunzip && $_REQUEST['mode'] == 'unzip' && is_writable($startpath)) { + if (!$err = unzip(realpath("{$startpath}/" . $_REQUEST['file']), realpath($startpath))) { + echo '' . $_lang['file_unzip_fail'] . ($err === 0 ? 'Missing zip library (php_zip.dll / zip.so)' : '') . '

    '; + } else { + echo '' . $_lang['file_unzip'] . '

    '; + } + } + // End Unzip - Raymond + + + // New Folder & Delete Folder option - Raymond + if (is_writable($startpath)) { + // Delete Folder + if ($_REQUEST['mode'] == 'deletefolder') { + $folder = $_REQUEST['folderpath']; + if (!$token_check || !@rrmdir($folder)) { + echo '' . $_lang['file_folder_not_deleted'] . '

    '; + } else { + echo '' . $_lang['file_folder_deleted'] . '

    '; + } + } + + // Create folder here + if ($_REQUEST['mode'] == 'newfolder') { + $old_umask = umask(0); + $foldername = str_replace('..\\', '', str_replace('../', '', $_REQUEST['name'])); + if (!mkdirs("{$startpath}/{$foldername}", 0777)) { + echo '', $_lang['file_folder_not_created'], '

    '; + } else { + if (!@chmod($startpath . '/' . $foldername, $newfolderaccessmode)) { + echo '' . $_lang['file_folder_chmod_error'] . '

    '; + } else { + echo '' . $_lang['file_folder_created'] . '

    '; + } + } + umask($old_umask); + } + // Create file here + if ($_REQUEST['mode'] == 'newfile') { + $old_umask = umask(0); + $filename = str_replace('..\\', '', str_replace('../', '', $_REQUEST['name'])); + $filename = $modx->db->escape($filename); + + if (!checkExtension($filename)) { + echo '' . $_lang['files_filetype_notok'] . '

    '; + } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $filename) !== 0) { + echo $_lang['files.dynamic.php3']; + } else { + $rs = file_put_contents("{$startpath}/{$filename}", ''); + if ($rs === false) { + echo '', $_lang['file_folder_not_created'], '

    '; + } else { + echo $_lang['files.dynamic.php4']; + } + umask($old_umask); + } + } + // Duplicate file here + if ($_REQUEST['mode'] == 'duplicate') { + $old_umask = umask(0); + $filename = $_REQUEST['path']; + $filename = $modx->db->escape($filename); + $newFilename = str_replace('..\\', '', str_replace('../', '', $_REQUEST['newFilename'])); + $newFilename = $modx->db->escape($newFilename); + + if (!checkExtension($newFilename)) { + echo '' . $_lang['files_filetype_notok'] . '

    '; + } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { + echo $_lang['files.dynamic.php3']; + } else { + if (!copy($filename, MODX_BASE_PATH . $newFilename)) { + echo $_lang['files.dynamic.php5']; + } + umask($old_umask); + } + } + // Rename folder here + if ($_REQUEST['mode'] == 'renameFolder') { + $old_umask = umask(0); + $dirname = $_REQUEST['path'] . '/' . $_REQUEST['dirname']; + $dirname = $modx->db->escape($dirname); + $newDirname = str_replace(array( + '..\\', + '../', + '\\', + '/' + ), '', $_REQUEST['newDirname']); + $newDirname = $modx->db->escape($newDirname); + + if (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newDirname) !== 0) { + echo $_lang['files.dynamic.php3']; + } else if (!rename($dirname, $_REQUEST['path'] . '/' . $newDirname)) { + echo '', $_lang['file_folder_not_created'], '

    '; + } + umask($old_umask); + } + // Rename file here + if ($_REQUEST['mode'] == 'renameFile') { + $old_umask = umask(0); + $path = dirname($_REQUEST['path']); + $filename = $_REQUEST['path']; + $filename = $modx->db->escape($filename); + $newFilename = str_replace(array( + '..\\', + '../', + '\\', + '/' + ), '', $_REQUEST['newFilename']); + $newFilename = $modx->db->escape($newFilename); + + if (!checkExtension($newFilename)) { + echo '' . $_lang['files_filetype_notok'] . '

    '; + } elseif (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newFilename) !== 0) { + echo $_lang['files.dynamic.php3']; + } else { + if (!rename($filename, $path . '/' . $newFilename)) { + echo $_lang['files.dynamic.php5']; + } + umask($old_umask); + } + } + } + // End New Folder - Raymond + + $filesize = 0; + $files = 0; + $folders = 0; + $dirs_array = array(); + $files_array = array(); + if (strlen(MODX_BASE_PATH) < strlen($filemanager_path)) { + $len--; + } + + ?> +
    + + + + + + + + + + '; + } + ?> +
    ' . $_lang['files_directory_is_empty'] . '
    +
    + +
    +

    + ' . $folders . ' '; + echo $_lang['files_files'] . ': ' . $files . ' '; + echo $_lang['files_data'] . ': ' . $modx->nicesize($filesizes) . ' '; + echo $_lang['files_dirwritable'] . ' ' . (is_writable($startpath) == 1 ? $_lang['yes'] . '.' : $_lang['no']) . '.' + ?> +

    + + + +
    + + + + + + +
    + + +
    +
    + " . $_lang['files_upload_inhibited_msg'] . "

    "; + } + ?> +
    +
    + +
    - -
    - - webAlertAndQuit("Error opening file for reading."); - } - ?> -
    - - - - - - - -
    - -
    -
    -
    - invokeEvent('OnRichTextEditorInit', array( - 'editor' => 'Codemirror', - 'elements' => array( - 'content', - ), - 'contentType' => $contentType, - 'readOnly' => $_REQUEST['mode'] == 'edit' ? false : true - )); - if(is_array($evtOut)) { - echo implode('', $evtOut); - } - -} - -function determineIcon($file, $selFile, $mode) { - $icons = array( - 'default' => 'fa fa-file-o', - 'edit' => 'fa fa-pencil-square-o', - 'view' => 'fa fa-eye' - ); - $icon = $icons['default']; - if($file == $selFile) { - $icon = isset($icons[$mode]) ? $icons[$mode] : $icons['default']; - } - return ''; -} - -function markRow($file, $selFile, $mode) { - $classNames = array( - 'default' => '', - 'edit' => 'editRow', - 'view' => 'viewRow' - ); - if($file == $selFile) { - $class = isset($classNames[$mode]) ? $classNames[$mode] : $classNames['default']; - return ' class="' . $class . '"'; - } - return ''; -} - -function ls($curpath) { - global $_lang, $theme_image_path, $_style; - global $excludes, $protected_path, $editablefiles, $inlineviewablefiles, $viewablefiles, $enablefileunzip, $enablefiledownload, $uploadablefiles, $folders, $files, $filesizes, $len, $dirs_array, $files_array, $webstart_path, $modx; - $dircounter = 0; - $filecounter = 0; - $curpath = str_replace('//', '/', $curpath . '/'); - - if(!is_dir($curpath)) { - echo 'Invalid path "', $curpath, '"
    '; - return; - } - $dir = scandir($curpath); - - // first, get info - foreach($dir as $file) { - $newpath = $curpath . $file; - if($file === '..' || $file === '.') { - continue; - } - if(is_dir($newpath)) { - $dirs_array[$dircounter]['dir'] = $newpath; - $dirs_array[$dircounter]['stats'] = lstat($newpath); - if($file === '..' || $file === '.') { - continue; - } elseif(!in_array($file, $excludes) && !in_array($newpath, $protected_path)) { - $dirs_array[$dircounter]['text'] = ' ' . $file . ''; - - $dfiles = scandir($newpath); - foreach($dfiles as $i => $infile) { - switch($infile) { - case '..': - case '.': - unset($dfiles[$i]); - break; - } - } - $file_exists = (0 < count($dfiles)) ? 'file_exists' : ''; - - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '' : ''; - } else { - $dirs_array[$dircounter]['text'] = ' ' . $file . ''; - $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '' : ''; - } - - $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? ' ' : ''; - - // increment the counter - $dircounter++; - } else { - $type = getExtension($newpath); - $files_array[$filecounter]['file'] = $newpath; - $files_array[$filecounter]['stats'] = lstat($newpath); - $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']) . ' '. $file; - $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '' : ''); - $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '' : $files_array[$filecounter]['view']; - $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '' : ''; - $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '' : ''; - $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '' : ''; - $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '' : ''; - $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '' : ''; - - // increment the counter - $filecounter++; - } - } - - // dump array entries for directories - $folders = count($dirs_array); - sort($dirs_array); // sorting the array alphabetically (Thanks pxl8r!) - for($i = 0; $i < $folders; $i++) { - $filesizes += $dirs_array[$i]['stats']['7']; - echo ''; - echo '' . $dirs_array[$i]['text'] . ''; - echo '' . $modx->toDateFormat($dirs_array[$i]['stats']['9']) . ''; - echo '' . $modx->nicesize($dirs_array[$i]['stats']['7']) . ''; - echo ''; - echo $dirs_array[$i]['rename']; - echo $dirs_array[$i]['delete']; - echo ''; - echo ''; - } - - // dump array entries for files - $files = count($files_array); - sort($files_array); // sorting the array alphabetically (Thanks pxl8r!) - for($i = 0; $i < $files; $i++) { - $filesizes += $files_array[$i]['stats']['7']; - echo ''; - echo '' . $files_array[$i]['text'] . ''; - echo '' . $modx->toDateFormat($files_array[$i]['stats']['9']) . ''; - echo '' . $modx->nicesize($files_array[$i]['stats']['7']) . ''; - echo ''; - echo $files_array[$i]['unzip']; - echo $files_array[$i]['view']; - echo $files_array[$i]['edit']; - echo $files_array[$i]['duplicate']; - echo $files_array[$i]['rename']; - echo $files_array[$i]['delete']; - echo ''; - echo ''; - } - return; -} - -function removeLastPath($string) { - $pos = strrpos($string, '/'); - if($pos !== false) { - $path = substr($string, 0, $pos); - } else { - $path = false; - } - return $path; -} - -function getExtension($string) { - $pos = strrpos($string, '.'); - if($pos !== false) { - $ext = substr($string, $pos); - $ext = strtolower($ext); - } else { - $ext = false; - } - return $ext; -} - -function checkExtension($path = '') { - global $uploadablefiles; - - if(in_array(getExtension($path), $uploadablefiles)) { - return true; - } else { - return false; - } -} - -function mkdirs($strPath, $mode) { // recursive mkdir function - if(is_dir($strPath)) { - return true; - } - $pStrPath = dirname($strPath); - if(!mkdirs($pStrPath, $mode)) { - return false; - } - return @mkdir($strPath); -} - -function logFileChange($type, $filename) { - //global $_lang; - - include_once('log.class.inc.php'); - $log = new logHandler(); - - switch($type) { - case 'upload': - $string = 'Uploaded File'; - break; - case 'delete': - $string = 'Deleted File'; - break; - case 'modify': - $string = 'Modified File'; - break; - default: - $string = 'Viewing File'; - break; - } - - $string = sprintf($string, $filename); - $log->initAndWriteLog($string, '', '', '', $type, $filename); - - // HACK: change the global action to prevent double logging - // @see index.php @ 915 - global $action; - $action = 1; +if ($_REQUEST['mode'] == "edit" || $_REQUEST['mode'] == "view") { + ?> + +
    + + webAlertAndQuit("Error opening file for reading."); + } + ?> +
    + + + + + + + +
    + +
    +
    +
    + invokeEvent('OnRichTextEditorInit', array( + 'editor' => 'Codemirror', + 'elements' => array( + 'content', + ), + 'contentType' => $contentType, + 'readOnly' => $_REQUEST['mode'] == 'edit' ? false : true + )); + if (is_array($evtOut)) { + echo implode('', $evtOut); + } + +} + +function determineIcon($file, $selFile, $mode) +{ + $icons = array( + 'default' => 'fa fa-file-o', + 'edit' => 'fa fa-pencil-square-o', + 'view' => 'fa fa-eye' + ); + $icon = $icons['default']; + if ($file == $selFile) { + $icon = isset($icons[$mode]) ? $icons[$mode] : $icons['default']; + } + return ''; +} + +function markRow($file, $selFile, $mode) +{ + $classNames = array( + 'default' => '', + 'edit' => 'editRow', + 'view' => 'viewRow' + ); + if ($file == $selFile) { + $class = isset($classNames[$mode]) ? $classNames[$mode] : $classNames['default']; + return ' class="' . $class . '"'; + } + return ''; +} + +function ls($curpath) +{ + global $_lang, $theme_image_path, $_style; + global $excludes, $protected_path, $editablefiles, $inlineviewablefiles, $viewablefiles, $enablefileunzip, $enablefiledownload, $uploadablefiles, $folders, $files, $filesizes, $len, $dirs_array, $files_array, $webstart_path, $modx; + $dircounter = 0; + $filecounter = 0; + $curpath = str_replace('//', '/', $curpath . '/'); + + if (!is_dir($curpath)) { + echo 'Invalid path "', $curpath, '"
    '; + return; + } + $dir = scandir($curpath); + + // first, get info + foreach ($dir as $file) { + $newpath = $curpath . $file; + if ($file === '..' || $file === '.') { + continue; + } + if (is_dir($newpath)) { + $dirs_array[$dircounter]['dir'] = $newpath; + $dirs_array[$dircounter]['stats'] = lstat($newpath); + if ($file === '..' || $file === '.') { + continue; + } elseif (!in_array($file, $excludes) && !in_array($newpath, $protected_path)) { + $dirs_array[$dircounter]['text'] = ' ' . $file . ''; + + $dfiles = scandir($newpath); + foreach ($dfiles as $i => $infile) { + switch ($infile) { + case '..': + case '.': + unset($dfiles[$i]); + break; + } + } + $file_exists = (0 < count($dfiles)) ? 'file_exists' : ''; + + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '' : ''; + } else { + $dirs_array[$dircounter]['text'] = ' ' . $file . ''; + $dirs_array[$dircounter]['delete'] = is_writable($curpath) ? '' : ''; + } + + $dirs_array[$dircounter]['rename'] = is_writable($curpath) ? ' ' : ''; + + // increment the counter + $dircounter++; + } else { + $type = getExtension($newpath); + $files_array[$filecounter]['file'] = $newpath; + $files_array[$filecounter]['stats'] = lstat($newpath); + $files_array[$filecounter]['text'] = determineIcon($newpath, $_REQUEST['path'], $_REQUEST['mode']) . ' ' . $file; + $files_array[$filecounter]['view'] = (in_array($type, $viewablefiles)) ? '' : (($enablefiledownload && in_array($type, $uploadablefiles)) ? '' : ''); + $files_array[$filecounter]['view'] = (in_array($type, $inlineviewablefiles)) ? '' : $files_array[$filecounter]['view']; + $files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '' : ''; + $files_array[$filecounter]['edit'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '' : ''; + $files_array[$filecounter]['duplicate'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '' : ''; + $files_array[$filecounter]['rename'] = (in_array($type, $editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '' : ''; + $files_array[$filecounter]['delete'] = is_writable($curpath) && is_writable($newpath) ? '' : ''; + + // increment the counter + $filecounter++; + } + } + + // dump array entries for directories + $folders = count($dirs_array); + sort($dirs_array); // sorting the array alphabetically (Thanks pxl8r!) + for ($i = 0; $i < $folders; $i++) { + $filesizes += $dirs_array[$i]['stats']['7']; + echo ''; + echo '' . $dirs_array[$i]['text'] . ''; + echo '' . $modx->toDateFormat($dirs_array[$i]['stats']['9']) . ''; + echo '' . $modx->nicesize($dirs_array[$i]['stats']['7']) . ''; + echo ''; + echo $dirs_array[$i]['rename']; + echo $dirs_array[$i]['delete']; + echo ''; + echo ''; + } + + // dump array entries for files + $files = count($files_array); + sort($files_array); // sorting the array alphabetically (Thanks pxl8r!) + for ($i = 0; $i < $files; $i++) { + $filesizes += $files_array[$i]['stats']['7']; + echo ''; + echo '' . $files_array[$i]['text'] . ''; + echo '' . $modx->toDateFormat($files_array[$i]['stats']['9']) . ''; + echo '' . $modx->nicesize($files_array[$i]['stats']['7']) . ''; + echo ''; + echo $files_array[$i]['unzip']; + echo $files_array[$i]['view']; + echo $files_array[$i]['edit']; + echo $files_array[$i]['duplicate']; + echo $files_array[$i]['rename']; + echo $files_array[$i]['delete']; + echo ''; + echo ''; + } + return; +} + +function removeLastPath($string) +{ + $pos = strrpos($string, '/'); + if ($pos !== false) { + $path = substr($string, 0, $pos); + } else { + $path = false; + } + return $path; +} + +function getExtension($string) +{ + $pos = strrpos($string, '.'); + if ($pos !== false) { + $ext = substr($string, $pos); + $ext = strtolower($ext); + } else { + $ext = false; + } + return $ext; +} + +function checkExtension($path = '') +{ + global $uploadablefiles; + + if (in_array(getExtension($path), $uploadablefiles)) { + return true; + } else { + return false; + } +} + +function mkdirs($strPath, $mode) +{ // recursive mkdir function + if (is_dir($strPath)) { + return true; + } + $pStrPath = dirname($strPath); + if (!mkdirs($pStrPath, $mode)) { + return false; + } + return @mkdir($strPath); +} + +function logFileChange($type, $filename) +{ + //global $_lang; + + include_once('log.class.inc.php'); + $log = new logHandler(); + + switch ($type) { + case 'upload': + $string = 'Uploaded File'; + break; + case 'delete': + $string = 'Deleted File'; + break; + case 'modify': + $string = 'Modified File'; + break; + default: + $string = 'Viewing File'; + break; + } + + $string = sprintf($string, $filename); + $log->initAndWriteLog($string, '', '', '', $type, $filename); + + // HACK: change the global action to prevent double logging + // @see index.php @ 915 + global $action; + $action = 1; } // by patrick_allaert - php user notes -function unzip($file, $path) { - global $newfolderaccessmode, $token_check; - - if(!$token_check) { - return false; - } - - // added by Raymond - if(!extension_loaded('zip')) { - return 0; - } - // end mod - $zip = zip_open($file); - if($zip) { - $old_umask = umask(0); - $path = rtrim($path, '/') . '/'; - while($zip_entry = zip_read($zip)) { - if(zip_entry_filesize($zip_entry) > 0) { - // str_replace must be used under windows to convert "/" into "\" - $zip_entry_name = zip_entry_name($zip_entry); - $complete_path = $path . str_replace('\\', '/', dirname($zip_entry_name)); - $complete_name = $path . str_replace('\\', '/', $zip_entry_name); - if(!file_exists($complete_path)) { - $tmp = ''; - foreach(explode('/', $complete_path) AS $k) { - $tmp .= $k . '/'; - if(!is_dir($tmp)) { - mkdir($tmp, 0777); - } - } - } - if(zip_entry_open($zip, $zip_entry, 'r')) { - file_put_contents($complete_name, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry))); - zip_entry_close($zip_entry); - } - } - } - umask($old_umask); - zip_close($zip); - return true; - } - zip_close($zip); -} - -function rrmdir($dir) { - foreach(glob($dir . '/*') as $file) { - if(is_dir($file)) { - rrmdir($file); - } else { - unlink($file); - } - } - return rmdir($dir); -} - -function fileupload() { - global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; - $msg = ''; - - foreach($_FILES['userfile']['name'] as $i => $name) { - if(!empty($_FILES['userfile']['tmp_name'][$i])) { - $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; - $userfile['error'] = $_FILES['userfile']['error'][$i]; - $name = $_FILES['userfile']['name'][$i]; - if($modx->config['clean_uploaded_filename'] == 1) { - $nameparts = explode('.', $name); - $nameparts = array_map(array( - $modx, - 'stripAlias' - ), $nameparts, array('file_manager')); - $name = implode('.', $nameparts); - } - $userfile['name'] = $name; - $userfile['type'] = $_FILES['userfile']['type'][$i]; - - // this seems to be an upload action. - $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath)); - $path = rtrim($path, '/') . '/' . $userfile['name']; - $msg .= $path; - if($userfile['error'] == 0) { - $img = (strpos($userfile['type'], 'image') !== false) ? '
    ' : ''; - $msg .= "

    " . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '

    '; - } - - $userfilename = $userfile['tmp_name']; - - if(is_uploaded_file($userfilename)) { - // file is uploaded file, process it! - if(!checkExtension($userfile['name'])) { - $msg .= '

    ' . $_lang['files_filetype_notok'] . '

    '; - } else { - if(@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) { - // Ryan: Repair broken permissions issue with file manager - if(strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { - @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions); - } - // Ryan: End - $msg .= '

    ' . $_lang['files_upload_ok'] . '


    '; - - // invoke OnFileManagerUpload event - $modx->invokeEvent('OnFileManagerUpload', array( - 'filepath' => $_POST['path'], - 'filename' => $userfile['name'] - )); - // Log the change - logFileChange('upload', $_POST['path'] . '/' . $userfile['name']); - } else { - $msg .= '

    ' . $_lang['files_upload_copyfailed'] . ' ' . $_lang["files_upload_permissions_error"] . '

    '; - } - } - } else { - $msg .= '
    ' . $_lang['files_upload_error'] . ':'; - switch($userfile['error']) { - case 0: //no error; possible file attack! - $msg .= $_lang['files_upload_error0']; - break; - case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini - $msg .= $_lang['files_upload_error1']; - break; - case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form - $msg .= $_lang['files_upload_error2']; - break; - case 3: //uploaded file was only partially uploaded - $msg .= $_lang['files_upload_error3']; - break; - case 4: //no file was uploaded - $msg .= $_lang['files_upload_error4']; - break; - default: //a default error, just in case! :) - $msg .= $_lang['files_upload_error5']; - break; - } - $msg .= '
    '; - } - } - } - return $msg . '
    '; -} - -function textsave() { - global $_lang; - - $msg = $_lang['editing_file']; - $filename = $_POST['path']; - $content = $_POST['content']; - - // Write $content to our opened file. - if(file_put_contents($filename, $content) === FALSE) { - $msg .= '' . $_lang['file_not_saved'] . '

    '; - } else { - $msg .= '' . $_lang['file_saved'] . '

    '; - $_REQUEST['mode'] = 'edit'; - } - // Log the change - logFileChange('modify', $filename); - return $msg; -} - -function delete_file() { - global $_lang, $token_check; - - $msg = sprintf($_lang['deleting_file'], str_replace('\\', '/', $_REQUEST['path'])); - - $file = $_REQUEST['path']; - if(!$token_check || !@unlink($file)) { - $msg .= '' . $_lang['file_not_deleted'] . '

    '; - } else { - $msg .= '' . $_lang['file_deleted'] . '

    '; - } - - // Log the change - logFileChange('delete', $file); - - return $msg; -} - -function parsePlaceholder($tpl, $ph) { - foreach($ph as $k => $v) { - $k = "[+{$k}+]"; - $tpl = str_replace($k, $v, $tpl); - } - return $tpl; -} - -function checkToken() { - if(isset($_POST['token']) && !empty($_POST['token'])) { - $token = $_POST['token']; - } elseif(isset($_GET['token']) && !empty($_GET['token'])) { - $token = $_GET['token']; - } else { - $token = false; - } - - if(isset($_SESSION['token']) && !empty($_SESSION['token']) && $_SESSION['token'] === $token) { - $rs = true; - } else { - $rs = false; - } - $_SESSION['token'] = ''; - return $rs; -} - -function makeToken() { - $newToken = uniqid(''); - $_SESSION['token'] = $newToken; - return $newToken; +function unzip($file, $path) +{ + global $newfolderaccessmode, $token_check; + + if (!$token_check) { + return false; + } + + // added by Raymond + if (!extension_loaded('zip')) { + return 0; + } + // end mod + $zip = zip_open($file); + if ($zip) { + $old_umask = umask(0); + $path = rtrim($path, '/') . '/'; + while ($zip_entry = zip_read($zip)) { + if (zip_entry_filesize($zip_entry) > 0) { + // str_replace must be used under windows to convert "/" into "\" + $zip_entry_name = zip_entry_name($zip_entry); + $complete_path = $path . str_replace('\\', '/', dirname($zip_entry_name)); + $complete_name = $path . str_replace('\\', '/', $zip_entry_name); + if (!file_exists($complete_path)) { + $tmp = ''; + foreach (explode('/', $complete_path) AS $k) { + $tmp .= $k . '/'; + if (!is_dir($tmp)) { + mkdir($tmp, 0777); + } + } + } + if (zip_entry_open($zip, $zip_entry, 'r')) { + file_put_contents($complete_name, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry))); + zip_entry_close($zip_entry); + } + } + } + umask($old_umask); + zip_close($zip); + return true; + } + zip_close($zip); +} + +function rrmdir($dir) +{ + foreach (glob($dir . '/*') as $file) { + if (is_dir($file)) { + rrmdir($file); + } else { + unlink($file); + } + } + return rmdir($dir); +} + +function fileupload() +{ + global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions; + $msg = ''; + + foreach ($_FILES['userfile']['name'] as $i => $name) { + if (!empty($_FILES['userfile']['tmp_name'][$i])) { + $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'][$i]; + $userfile['error'] = $_FILES['userfile']['error'][$i]; + $name = $_FILES['userfile']['name'][$i]; + if ($modx->config['clean_uploaded_filename'] == 1) { + $nameparts = explode('.', $name); + $nameparts = array_map(array( + $modx, + 'stripAlias' + ), $nameparts, array('file_manager')); + $name = implode('.', $nameparts); + } + $userfile['name'] = $name; + $userfile['type'] = $_FILES['userfile']['type'][$i]; + + // this seems to be an upload action. + $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath)); + $path = rtrim($path, '/') . '/' . $userfile['name']; + $msg .= $path; + if ($userfile['error'] == 0) { + $img = (strpos($userfile['type'], 'image') !== false) ? '
    ' : ''; + $msg .= "

    " . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '

    '; + } + + $userfilename = $userfile['tmp_name']; + + if (is_uploaded_file($userfilename)) { + // file is uploaded file, process it! + if (!checkExtension($userfile['name'])) { + $msg .= '

    ' . $_lang['files_filetype_notok'] . '

    '; + } else { + if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) { + // Ryan: Repair broken permissions issue with file manager + if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') { + @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions); + } + // Ryan: End + $msg .= '

    ' . $_lang['files_upload_ok'] . '


    '; + + // invoke OnFileManagerUpload event + $modx->invokeEvent('OnFileManagerUpload', array( + 'filepath' => $_POST['path'], + 'filename' => $userfile['name'] + )); + // Log the change + logFileChange('upload', $_POST['path'] . '/' . $userfile['name']); + } else { + $msg .= '

    ' . $_lang['files_upload_copyfailed'] . ' ' . $_lang["files_upload_permissions_error"] . '

    '; + } + } + } else { + $msg .= '
    ' . $_lang['files_upload_error'] . ':'; + switch ($userfile['error']) { + case 0: //no error; possible file attack! + $msg .= $_lang['files_upload_error0']; + break; + case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini + $msg .= $_lang['files_upload_error1']; + break; + case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form + $msg .= $_lang['files_upload_error2']; + break; + case 3: //uploaded file was only partially uploaded + $msg .= $_lang['files_upload_error3']; + break; + case 4: //no file was uploaded + $msg .= $_lang['files_upload_error4']; + break; + default: //a default error, just in case! :) + $msg .= $_lang['files_upload_error5']; + break; + } + $msg .= '
    '; + } + } + } + return $msg . '
    '; +} + +function textsave() +{ + global $_lang; + + $msg = $_lang['editing_file']; + $filename = $_POST['path']; + $content = $_POST['content']; + + // Write $content to our opened file. + if (file_put_contents($filename, $content) === false) { + $msg .= '' . $_lang['file_not_saved'] . '

    '; + } else { + $msg .= '' . $_lang['file_saved'] . '

    '; + $_REQUEST['mode'] = 'edit'; + } + // Log the change + logFileChange('modify', $filename); + return $msg; +} + +function delete_file() +{ + global $_lang, $token_check; + + $msg = sprintf($_lang['deleting_file'], str_replace('\\', '/', $_REQUEST['path'])); + + $file = $_REQUEST['path']; + if (!$token_check || !@unlink($file)) { + $msg .= '' . $_lang['file_not_deleted'] . '

    '; + } else { + $msg .= '' . $_lang['file_deleted'] . '

    '; + } + + // Log the change + logFileChange('delete', $file); + + return $msg; +} + +function parsePlaceholder($tpl, $ph) +{ + foreach ($ph as $k => $v) { + $k = "[+{$k}+]"; + $tpl = str_replace($k, $v, $tpl); + } + return $tpl; +} + +function checkToken() +{ + if (isset($_POST['token']) && !empty($_POST['token'])) { + $token = $_POST['token']; + } elseif (isset($_GET['token']) && !empty($_GET['token'])) { + $token = $_GET['token']; + } else { + $token = false; + } + + if (isset($_SESSION['token']) && !empty($_SESSION['token']) && $_SESSION['token'] === $token) { + $rs = true; + } else { + $rs = false; + } + $_SESSION['token'] = ''; + return $rs; +} + +function makeToken() +{ + $newToken = uniqid(''); + $_SESSION['token'] = $newToken; + return $newToken; } diff --git a/manager/actions/help.static.php b/manager/actions/help.static.php index 48b1df1ca4..36ffc4100f 100644 --- a/manager/actions/help.static.php +++ b/manager/actions/help.static.php @@ -2,7 +2,7 @@ if(IN_MANAGER_MODE != "true") { die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -$helpBasePath = MODX_BASE_PATH . "assets/templates/help/"; +$helpBasePath = "actions/help/"; ?>

    @@ -16,7 +16,7 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +$logo= ''; +$downloadLinks = array( + 0=>array('title'=>$_lang["information"],'link'=>'https://evo.im/'), + 1=>array('title'=>$_lang["download"],'link'=>'https://github.com/evolution-cms/evolution/releases'), + 2=>array('title'=>$_lang["previous_releases"],'link'=>'https://modx.com/download/evolution/previous-releases.html'), + 3=>array('title'=>$_lang["extras"],'link'=>array( + 'http://extras.evolution-cms.com/', + 'https://github.com/extras-evolution' + )), +); + +$translationLinks = array( + 0=>array('title'=>'Evolution CMS','link'=>'https://www.transifex.com/evolutioncms/evolution/'), + 1=>array('title'=>$_lang["extras"],'link'=>'https://www.transifex.com/evolutioncms/extras/'), +); + +function createList($sectionHeader, $linkArr) { + $output = '
    '.$sectionHeader.'
    '."\n"; + $output .= ''."\n"; + $links = ''; + foreach($linkArr as $row) { + if (!is_array($row['link'])) $row['link'] = array($row['link']); + foreach ($row['link'] as $link) { + $links .= $links != '' ? '
    ' : ''; + $links .= '' . $link . ''; + } + $output .= ' + + + + '; + $links = ''; + } + $output .= '
    ' . $row["title"] . '' . $links . '
    '."\n"; + return $output; +} +echo $logo; +echo createList($_lang['evo_downloads_title'], $downloadLinks); +echo createList($_lang['help_translating_title'], $translationLinks); + +?> + +
    + +
    + + + + diff --git a/assets/templates/help/01Documentation.php b/manager/actions/help/02Documentation.php similarity index 59% rename from assets/templates/help/01Documentation.php rename to manager/actions/help/02Documentation.php index 1e2bc8be04..365faec89f 100644 --- a/assets/templates/help/01Documentation.php +++ b/manager/actions/help/02Documentation.php @@ -4,13 +4,12 @@
    - - - + + + - - +
    What is MODX?Official 1.0 documentation
    MODX.comHome of MODX
    MODX ForumsGeneral support & discussions
    What is EVO?Official EVO documentation
    evo.imHome of EVO
    EVO ForumsGeneral support & discussions
    docs.evolution-cms.comGoogle TranslateFurther documentation
    API ReferenceGoogle TranslateFurther documentation
    MODX.imGoogle TranslateMODX by community
    MODX.com.uaGoogle TranslateFurther documentation
    MODX.imGoogle TranslateRussian community
    diff --git a/assets/templates/help/02Version_Notices.php b/manager/actions/help/03Version_Notices.php similarity index 58% rename from assets/templates/help/02Version_Notices.php rename to manager/actions/help/03Version_Notices.php index b5ed1d9433..07dc4f1576 100644 --- a/assets/templates/help/02Version_Notices.php +++ b/manager/actions/help/03Version_Notices.php @@ -1,9 +1,9 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); - if ($handle = opendir(MODX_BASE_PATH . 'assets/templates/help/version_notices')) { + if ($handle = opendir('actions/help/version_notices')) { while (false !== ($file = readdir($handle))) { - if ($file != "." && $file != ".." && $file != ".svn" && is_readable(MODX_BASE_PATH . "assets/templates/help/version_notices/{$file}")) { + if ($file != "." && $file != ".." && $file != ".svn" && is_readable("actions/help/version_notices/{$file}")) { $notices[] = str_replace('.php', '', $file); } } @@ -14,8 +14,15 @@ $notices = array_reverse($notices); foreach($notices as $v) { - echo '
    MODX v'.$v.'
    '; - include(MODX_BASE_PATH . "assets/templates/help/version_notices/{$v}.php"); + if ($v >= '1.3.0') { + $cms = 'EVO'; + } + else { + $cms = 'MODX EVO'; + } + echo '
    '.$cms.' '.$v.'
    '; + include("actions/help/version_notices/{$v}.php"); echo '

    '; + } ?> \ No newline at end of file diff --git a/assets/templates/help/03Changelog.php b/manager/actions/help/04Changelog.php similarity index 100% rename from assets/templates/help/03Changelog.php rename to manager/actions/help/04Changelog.php diff --git a/manager/actions/help/version_notices/1.1.1.php b/manager/actions/help/version_notices/1.1.1.php new file mode 100644 index 0000000000..aa9868f421 --- /dev/null +++ b/manager/actions/help/version_notices/1.1.1.php @@ -0,0 +1,89 @@ +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +?> +

    +

    Resource-Tree

    +
      +
    • Moved "Sort menuindex" from DocManager to Resource-tree (#618, #636) +

      Sort Resources in Root: Click Button "Sort menu index" on top of resource-tree
      + Sort Resources of Parent Resource: Right mouse-click on parent, then choose "Sort menu index" +

      +
    • +
    • New "Manage Elements" Buttons (#669) +

      You can quick-access elements, files and images now directly from ressource-tree. Use Shift-Mouseclick to open multiple windows/elements.

      +
    • +
    • Remember last sort-options (#618, #636) +

      The ressource-tree stores now the last set sort-options per user to database (Sort by, Asc/Desc, Display-Name). At manager log-in, last settings of each user get restored.

      +
    • +
    + +

    MODX Tags

    +
      +
    • New Modifiers/Filters in Core (PHx) +

      Can be disabled in MODX-configuration. More infos at #623

      +
    • +
    • Snippet - Shortcut param = true +

      [[snippetName?param1&param2]] will automatically be handled as [[snippetName?param1=`1`&param2=`1`]] while param=`` will still be handled as empty value.

      +
    • +
    • New Conditional Tags / Modifiers +

      Can be enabled/disabled via Configuration -> "Enable Filters". More examples at #622 and #623. Example:

      +
      [*longtitle:ifempty=[*pagetitle*]*]
      +
      <!--@IF:[*id:is('[(site_start)]')*]>
      +Top page
      +<@ELSE>
      +Sub page
      +<@ENDIF-->
      +
    • + +
    • New Comment Tag +

      Comment-Tags will be completely removed from output. More infos at #680. Example:

      +
      <!--@- This is a comment -@-->
      +
      <!--@- Or HTML-Code / Snippets etc you want to disable temporarily -@-->
      +
    • + +
    • New Chunk Parameters +

      It is possible to pass properties/values to a chunk. More infos at #625. Example:

      + Chunk: +
      +<h1>[+title+]</h1>
      +<p>[+body+]</p>
      + Call: +
      {{chunkName? &title='First post' &body='Hello World!'}}
      +
    • + +
    • File-binded Templates via @INCLUDE +

      Templates can be included via @INCLUDE using external PHP- & HTML-files. More infos at #627. Example:

      +

      MODX-Template:

      +
      @INCLUDE:assets/templates/mydesign/template.inc.php
      +

      template.inc.php :

      +
      switch($modx->documentIdentifier) {
      +    case $modx->config['site_start']:
      +        return file_get_contents('assets/templates/mydesign/top.html');
      +    default:
      +        return file_get_contents('assets/templates/mydesign/page.html');
      +}
      +
    • +
    + +

    New Manager Roles

    +
      +
    • change_resourcetype +

      A user with this permission can change resource-type (webpage/weblink). More infos at #531

      +
    • +
    • assets_images, assets_files +

      Controls the display of 2 new buttons in resource-tree and grants/blocks access to KCFinder. More infos at #681

      +
    • +
    + +

    Template-Variables

    +
      +
    • @BINDINGS providing TV-values +

      [*tv_name*] will be replaced by its value taken from actual resource. Beware of SQL-Errors in case no or wrong value is given (set a reasonable default-value to avoid errors). More infos at #699. Example:

      +
      @SELECT name,value FROM xxx WHERE yyy = [*tv_name*]
      +
    • +
    + +

    Important Details for Developers

    +
      +
    • jQuery updated to v3.1 and loaded into manager by default.
      Known issues: MultiTV 2.0.8 has problems with row-reordering and requires an update.
    • +
    \ No newline at end of file diff --git a/assets/templates/help/version_notices/1.1.php b/manager/actions/help/version_notices/1.1.php similarity index 100% rename from assets/templates/help/version_notices/1.1.php rename to manager/actions/help/version_notices/1.1.php diff --git a/assets/templates/help/version_notices/1.2.1.php b/manager/actions/help/version_notices/1.2.1.php similarity index 100% rename from assets/templates/help/version_notices/1.2.1.php rename to manager/actions/help/version_notices/1.2.1.php diff --git a/assets/templates/help/version_notices/1.2.2.php b/manager/actions/help/version_notices/1.2.2.php similarity index 100% rename from assets/templates/help/version_notices/1.2.2.php rename to manager/actions/help/version_notices/1.2.2.php diff --git a/assets/templates/help/version_notices/1.2.php b/manager/actions/help/version_notices/1.2.php similarity index 100% rename from assets/templates/help/version_notices/1.2.php rename to manager/actions/help/version_notices/1.2.php diff --git a/manager/actions/help/version_notices/1.3.0.php b/manager/actions/help/version_notices/1.3.0.php new file mode 100644 index 0000000000..feb4066f3a --- /dev/null +++ b/manager/actions/help/version_notices/1.3.0.php @@ -0,0 +1,45 @@ +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +?> +

    +

    EVOLUTION CMS 1.3.0

    +
      +
    • The new release of EVO 1.3.0 runs under the name EVOLUTION CMS +

      Now updates will be released more often. About once a month there will be a fresh release instead of 1 release at half a year..

      +
    • +
    + +

    What's new in 1.3.0:

    +
      +
    • New name and logo +
    • +
    • New admin panel theme with a lot of innovations +
    • +
    • Correction of errors and stability +
    • +
    • Widgets for the main page (OnManagerWelcomeHome) +
    • +
    • Change the top menu (OnManagerMenuPrerender) +
    • +
    • Document tree changes (OnManagerNodePrerender) +
    • +
    +

    The New admin panel theme

    +
      +
    • Drag & drop in the document tree +
    • +
    • Dark style, quickly switching the appearance of the admin system +
    • +
    • Easier and faster +
    • +
    • Context menu for elements +
    • +
    • Ajax search in the admin area +
    • +
    • Remembering paths in admin panel +
    • +
    • 3 Level menu items with search and the ability to create a new item +
    • +
    • Support for mobile devices, although there is still some work in progress +
    • +
    \ No newline at end of file diff --git a/manager/actions/help/version_notices/1.3.1.php b/manager/actions/help/version_notices/1.3.1.php new file mode 100644 index 0000000000..cb5767676a --- /dev/null +++ b/manager/actions/help/version_notices/1.3.1.php @@ -0,0 +1,8 @@ +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +?> +

    +
      +
    • fix minor issues +
    • +
    diff --git a/manager/actions/help/version_notices/1.3.2.php b/manager/actions/help/version_notices/1.3.2.php new file mode 100644 index 0000000000..cb5767676a --- /dev/null +++ b/manager/actions/help/version_notices/1.3.2.php @@ -0,0 +1,8 @@ +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +?> +

    +
      +
    • fix minor issues +
    • +
    diff --git a/manager/actions/help/version_notices/1.3.3.php b/manager/actions/help/version_notices/1.3.3.php new file mode 100644 index 0000000000..cb5767676a --- /dev/null +++ b/manager/actions/help/version_notices/1.3.3.php @@ -0,0 +1,8 @@ +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +?> +

    +
      +
    • fix minor issues +
    • +
    diff --git a/manager/actions/help/version_notices/1.3.4.php b/manager/actions/help/version_notices/1.3.4.php new file mode 100644 index 0000000000..b1e44713ac --- /dev/null +++ b/manager/actions/help/version_notices/1.3.4.php @@ -0,0 +1,20 @@ +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +?> +

    +
      +
    • update FormLister to 1.7.8 (dmi3yy)
    • +
    • update DocLister to 1.3.11 (dmi3yy)
    • +
    • @FILE for chunks - {{@FILE:assets/chunks/header.html}}
    • +
    • remove mootols from manage category
    • +
    • added disable/enable snippets and chuncks #126
    • +
    • Depricated keywords and metatags (not used by default from 1.0.8 version) use TV for this.
    • +
    • new settings for group TVs (http://take.ms/OmFYb)
    • +
    • add header("X-XSS-Protection: 0"); for correct work filamanager.
    • +
    • Add DLSitemap and DLMenu snippets
    • +
    • Remove DLBuildMenu
    • +
    • Refactor manager search and fix permision for this
    • +
    • remove etomite "compatibility"
    • +
    • New - $modx->config['enable_cache']
    • +
    • New - [*value:makeUrl*] modifier
    • +
    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/logging.static.php b/manager/actions/logging.static.php index 3cdd927afa..44f1a871b7 100644 --- a/manager/actions/logging.static.php +++ b/manager/actions/logging.static.php @@ -1,309 +1,327 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('logs')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('logs')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } -function array_unique_multi($array, $checkKey) { - // Use the builtin if we're not a multi-dimensional array - if(!is_array(current($array)) || empty($checkKey)) { - return array_unique($array); - } +function array_unique_multi($array, $checkKey) +{ + // Use the builtin if we're not a multi-dimensional array + if (!is_array(current($array)) || empty($checkKey)) { + return array_unique($array); + } - $ret = array(); - $checkValues = array(); // contains the unique key Values - foreach($array as $key => $current) { - if(in_array($current[$checkKey], $checkValues)) { - continue; - } // duplicate + $ret = array(); + $checkValues = array(); // contains the unique key Values + foreach ($array as $key => $current) { + if (in_array($current[$checkKey], $checkValues)) { + continue; + } // duplicate - $checkValues[] = $current[$checkKey]; - $ret[$key] = $current; - } - return $ret; + $checkValues[] = $current[$checkKey]; + $ret[$key] = $current; + } + return $ret; } -function record_sort($array, $key) { - $hash = array(); - foreach($array as $k => $v) $hash[$k] = $v[$key]; +function record_sort($array, $key) +{ + $hash = array(); + foreach ($array as $k => $v) { + $hash[$k] = $v[$key]; + } - natsort($hash); + natsort($hash); - $records = array(); - foreach($hash as $k => $row) $records[$k] = $array[$k]; + $records = array(); + foreach ($hash as $k => $row) { + $records[$k] = $array[$k]; + } - return $records; + return $records; } $rs = $modx->db->select('DISTINCT internalKey, username, action, itemid, itemname', $modx->getFullTableName('manager_log')); $logs = $modx->db->makeArray($rs); - ?> -

    - -

    +

    + +

    + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + " /> + + "> + +
    +
    +
    +
    +
    +
    +
    + " /> + + "> + +
    +
    +
    +
    +
    +
    + +
    +
    + + "> + "> + + " style="display:none;" /> +
    + +
    +
    -
    -
    -
    -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - -
    - -
    - -
    - -
    - " /> - "> -
    - " /> - "> -
    - -
    - - " style="display:none;" /> -
    -
    -
    + + +
    +
    -
    -
    db->escape($_REQUEST['itemname']) . "'"; - } - if($_REQUEST['message'] != "") { - $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'"; - } - // date stuff - if($_REQUEST['datefrom'] != "") { - $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']); - } - if($_REQUEST['dateto'] != "") { - $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']); - } +if (isset($_REQUEST['log_submit'])) { + // get the selections the user made. + $sqladd = array(); + if ($_REQUEST['searchuser'] != 0) { + $sqladd[] = "internalKey='" . intval($_REQUEST['searchuser']) . "'"; + } + if ($_REQUEST['action'] != 0) { + $sqladd[] = "action=" . intval($_REQUEST['action']); + } + if ($_REQUEST['itemid'] != 0 || $_REQUEST['itemid'] == "-") { + $sqladd[] = "itemid='" . $_REQUEST['itemid'] . "'"; + } + if ($_REQUEST['itemname'] != '0') { + $sqladd[] = "itemname='" . $modx->db->escape($_REQUEST['itemname']) . "'"; + } + if ($_REQUEST['message'] != "") { + $sqladd[] = "message LIKE '%" . $modx->db->escape($_REQUEST['message']) . "%'"; + } + // date stuff + if ($_REQUEST['datefrom'] != "") { + $sqladd[] = "timestamp>" . $modx->toTimeStamp($_REQUEST['datefrom']); + } + if ($_REQUEST['dateto'] != "") { + $sqladd[] = "timestamp<" . $modx->toTimeStamp($_REQUEST['dateto']); + } + + // If current position is not set, set it to zero + if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { + $int_cur_position = 0; + } else { + $int_cur_position = $_REQUEST['int_cur_position']; + } - // If current position is not set, set it to zero - if(!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { - $int_cur_position = 0; - } else { - $int_cur_position = $_REQUEST['int_cur_position']; - } + // Number of result to display on the page, will be in the LIMIT of the sql query also + $int_num_result = is_numeric($_REQUEST['nrresults']) ? $_REQUEST['nrresults'] : $number_of_logs; - // Number of result to display on the page, will be in the LIMIT of the sql query also - $int_num_result = is_numeric($_REQUEST['nrresults']) ? $_REQUEST['nrresults'] : $number_of_logs; + $extargv = "&a=13&searchuser=" . $_REQUEST['searchuser'] . "&action=" . $_REQUEST['action'] . "&itemid=" . $_REQUEST['itemid'] . "&itemname=" . $_REQUEST['itemname'] . "&message=" . $_REQUEST['message'] . "&dateto=" . $_REQUEST['dateto'] . "&datefrom=" . $_REQUEST['datefrom'] . "&nrresults=" . $int_num_result . "&log_submit=" . $_REQUEST['log_submit']; // extra argv here (could be anything depending on your page) - $extargv = "&a=13&searchuser=" . $_REQUEST['searchuser'] . "&action=" . $_REQUEST['action'] . "&itemid=" . $_REQUEST['itemid'] . "&itemname=" . $_REQUEST['itemname'] . "&message=" . $_REQUEST['message'] . "&dateto=" . $_REQUEST['dateto'] . "&datefrom=" . $_REQUEST['datefrom'] . "&nrresults=" . $int_num_result . "&log_submit=" . $_REQUEST['log_submit']; // extra argv here (could be anything depending on your page) + // build the sql + $limit = $num_rows = $modx->db->getValue($modx->db->select('COUNT(*)', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''))); - // build the sql - $limit = $num_rows = $modx->db->getValue($modx->db->select('COUNT(*)', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''))); + $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}"); - $rs = $modx->db->select('*', $modx->getFullTableName('manager_log'), (!empty($sqladd) ? implode(' AND ', $sqladd) : ''), 'timestamp DESC, id DESC', "{$int_cur_position}, {$int_num_result}"); -if($limit < 1) { - echo '

    ' . $_lang["mgrlog_emptysrch"] . '

    '; +if ($limit < 1) { + echo '

    ' . $_lang["mgrlog_emptysrch"] . '

    '; } else { - echo '

    ' . $_lang["mgrlog_sortinst"] . '

    '; + echo '

    ' . $_lang["mgrlog_sortinst"] . '

    '; + + include_once "paginate.inc.php"; + // New instance of the Paging class, you can modify the color and the width of the html table + $p = new Paging($num_rows, $int_cur_position, $int_num_result, $extargv); + + // Load up the 2 array in order to display result + $array_paging = $p->getPagingArray(); + $array_row_paging = $p->getPagingRowArray(); + $current_row = $int_cur_position / $int_num_result; + + // Display the result as you like... + print "

    " . $_lang["paging_showing"] . " " . $array_paging['lower']; + print " " . $_lang["paging_to"] . " " . $array_paging['upper']; + print " (" . $array_paging['total'] . " " . $_lang["paging_total"] . ")
    "; + $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? " " : " "); + $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? " " : " "); + $pagesfound = sizeof($array_row_paging); + if ($pagesfound > 6) { + $paging .= $array_row_paging[$current_row - 2]; // ." "; + $paging .= $array_row_paging[$current_row - 1]; // ." "; + $paging .= $array_row_paging[$current_row]; // ." "; + $paging .= $array_row_paging[$current_row + 1]; // ." "; + $paging .= $array_row_paging[$current_row + 2]; // ." "; + } else { + for ($i = 0; $i < $pagesfound; $i++) { + $paging .= $array_row_paging[$i] . " "; + } + } + $paging .= $array_paging['next_link'] . $_lang["paging_next"] . (isset($array_paging['next_link']) ? " " : " ") . " "; + $paging .= $array_paging['last_link'] . $_lang["paging_last"] . (isset($array_paging['last_link']) ? " " : " ") . " "; + // The above exemple print somethings like: + // Results 1 to 20 of 597 <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>> + // Of course you can now play with array_row_paging in order to print + // only the results you would like... + ?> + + - include_once "paginate.inc.php"; - // New instance of the Paging class, you can modify the color and the width of the html table - $p = new Paging($num_rows, $int_cur_position, $int_num_result, $extargv); +

    - // Load up the 2 array in order to display result - $array_paging = $p->getPagingArray(); - $array_row_paging = $p->getPagingRowArray(); - $current_row = $int_cur_position / $int_num_result; +
    +
    + + + + + + + + + + + + db->getRow($rs)) { + if (!preg_match("/^[0-9]+$/", $logentry['itemid'])) { + $item = '
    -
    '; + } elseif ($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) { + $item = '' . $logentry['itemname'] . ''; + } else { + $item = $logentry['itemname']; + } + //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true' + $user_drill = 'index.php?a=13&searchuser=' . $logentry['internalKey'] . '&itemname=0&log_submit=true'; + ?> + + + + + + + + + +
    ' . $logentry['username'] . '' ?>toDateFormat($logentry['timestamp'] + $server_offset_time) ?>
    +
    +
    - // Display the result as you like... - print "

    " . $_lang["paging_showing"] . " " . $array_paging['lower']; - print " " . $_lang["paging_to"] . " " . $array_paging['upper']; - print " (" . $array_paging['total'] . " " . $_lang["paging_total"] . ")
    "; - $paging = $array_paging['first_link'] . $_lang["paging_first"] . (isset($array_paging['first_link']) ? " " : " "); - $paging .= $array_paging['previous_link'] . $_lang["paging_prev"] . (isset($array_paging['previous_link']) ? " " : " "); - $pagesfound = sizeof($array_row_paging); - if($pagesfound > 6) { - $paging .= $array_row_paging[$current_row - 2]; // ." "; - $paging .= $array_row_paging[$current_row - 1]; // ." "; - $paging .= $array_row_paging[$current_row]; // ." "; - $paging .= $array_row_paging[$current_row + 1]; // ." "; - $paging .= $array_row_paging[$current_row + 2]; // ." "; - } else { - for($i = 0; $i < $pagesfound; $i++) { - $paging .= $array_row_paging[$i] . " "; - } - } - $paging .= $array_paging['next_link'] . $_lang["paging_next"] . (isset($array_paging['next_link']) ? " " : " ") . " "; - $paging .= $array_paging['last_link'] . $_lang["paging_last"] . (isset($array_paging['last_link']) ? " " : " ") . "

    "; - echo $paging; - // The above exemple print somethings like: - // Results 1 to 20 of 597 <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>> - // Of course you can now play with array_row_paging in order to print - // only the results you would like... - ?> - - - - - - - - - - - - db->getRow($rs)) { - if(!preg_match("/^[0-9]+$/", $logentry['itemid'])) { - $item = '
    -
    '; - } elseif($logentry['action'] == 3 || $logentry['action'] == 27 || $logentry['action'] == 5) { - $item = '' . '[' . $logentry['itemid'] . '] ' . $logentry['itemname'] . ''; - } else { - $item = '[' . $logentry['itemid'] . '] ' . $logentry['itemname']; - } - //index.php?a=13&searchuser=' . $logentry['internalKey'] . '&action=' . $logentry['action'] . '&itemname=' . $logentry['itemname'] . '&log_submit=true' - $user_drill = 'index.php?a=13&searchuser=' . $logentry['internalKey'] . '&itemname=0&log_submit=true'; - ?> - - - - - - - - -
    ' . $logentry['username'] . ''; ?>toDateFormat($logentry['timestamp'] + $server_offset_time); ?>
    + -
    - +
    + INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); -if(!$modx->hasPermission('manage_metatags')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); -} - -// initialize page view state - the $_PAGE object -$modx->manager->initPageViewState(); - -?> - - -
    - - - -
    - -
    -
    -

    -
    - - - - -
    - - - - - - - - - - -

    -

    -

    -

    - " name="cmdsavetag" onclick="addTag()" /> " name="cmdcanceltag" onclick="cancelTag()" />

    -
    -
    -
    - db->select('*', $modx->getFullTableName("site_metatags"), '', 'name'); - include_once MODX_MANAGER_PATH."includes/controls/datagrid.class.php"; - $grd = new DataGrid('',$ds,$number_of_results); // set page size to 0 t show all items - $grd->noRecordMsg = $_lang["no_records_found"]; - $grd->cssClass="grid"; - $grd->columnHeaderClass="gridHeader"; - $grd->itemClass="gridItem"; - $grd->altItemClass="gridAltItem"; - $grd->fields="id,name,tag,tagvalue"; - $grd->columns=$_lang["delete"]." ,".$_lang["name"]." ,".$_lang["tag"]." ,".$_lang["value"]; - $grd->colWidths="40"; - $grd->colAligns="center"; - $grd->colTypes="template:||". - "template:[+value+]"; - echo $grd->render(); - ?> -
    - - - - - -
     
    - " onclick="deleteTag();" /> -
    -
    -
    - - -
    -
    -

    -db->select('*', $modx->getFullTableName('site_keywords'), '', 'keyword ASC'); - $grd = new DataGrid('',$ds,$number_of_results); // set page size to 0 t show all items - $grd->noRecordMsg = $_lang["no_keywords_found"]; - $grd->cssClass="grid"; - $grd->columnHeaderClass="gridHeader"; - $grd->itemClass="gridItem"; - $grd->altItemClass="gridAltItem"; - $grd->fields="id,keyword,keyword"; - $grd->columns=$_lang["delete"]." ,".$_lang["keyword"]." ,".$_lang["rename"]; - $grd->colWidths="40"; - $grd->colAligns="center"; - $grd->colTypes="template:||". - "template:[+keyword+]||". - "template:"; - echo $grd->render(); -?> - - - - - - - -
     
    -   -   - -
    -
    -
    -
    - diff --git a/manager/actions/messages.static.php b/manager/actions/messages.static.php index 768efa5caf..19b077c501 100644 --- a/manager/actions/messages.static.php +++ b/manager/actions/messages.static.php @@ -1,324 +1,296 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('messages')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('messages')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } ?>

    - +

    - -
    -
    -
    - db->select('*', $modx->getFullTableName('user_messages'), "id='" . (int) $_REQUEST['id'] . "'"); - $message = $modx->db->getRow($rs); - if(!$message) { - echo "Wrong number of messages returned!"; - } else { - if($message['recipient'] != $modx->getLoginUserID()) { - echo $_lang['messages_not_allowed_to_read']; - } else { - // output message! - // get the name of the sender - $sender = $message['sender']; - if($sender == 0) { - $sendername = $_lang['messages_system_user']; - } else { - $rs2 = $modx->db->select('username', $modx->getFullTableName('manager_users'), "id='{$sender}'"); - $sendername = $modx->db->getValue($rs2); - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
      -
    • - " /> -
    • -
    • - - " />
    • -
    • ">
    • - - - -
    -
     
    :
    :toDateFormat($message['postdate'] + $server_offset_time); ?>
    :
     
    - ", $message['message']); - $dashcount = substr_count($message, "-----"); - $message = str_replace("-----", "", $message); - for($i = 0; $i < $dashcount; $i++) { - $message .= ""; - } - - echo $message; - ?> - -
    - db->update(array('messageread' => 1), $modx->getFullTableName('user_messages'), "id='{$_REQUEST['id']}'"); - } - } - ?> -
    -
    + +
    +
    + + db->select('*', $modx->getFullTableName('user_messages'), "id='" . (int)$_REQUEST['id'] . "'"); + $message = $modx->db->getRow($rs); + if (!$message) { + echo "Wrong number of messages returned!"; + } else { + if ($message['recipient'] != $modx->getLoginUserID()) { + echo $_lang['messages_not_allowed_to_read']; + } else { + // output message! + // get the name of the sender + $sender = $message['sender']; + if ($sender == 0) { + $sendername = $_lang['messages_system_user']; + } else { + $rs2 = $modx->db->select('username', $modx->getFullTableName('manager_users'), "id='{$sender}'"); + $sendername = $modx->db->getValue($rs2); + } + ?> +
    + + + "> +
    +

    +
    +
    + + + + + + + + + + + + + + + + +
    : 
    : toDateFormat($message['postdate'] + $server_offset_time) ?>
    : 
    +
    + ', $message['message']); + $dashcount = substr_count($message, '-----'); + $message = str_replace('-----', '', $message); + for ($i = 0; $i < $dashcount; $i++) { + $message .= ''; + } + ?> +
    +
    + db->update(array('messageread' => 1), $modx->getFullTableName('user_messages'), "id='{$_REQUEST['id']}'"); + } + } + ?> +
    +
    +

    -
    -
    -
    - db->select('count(id)', $modx->getFullTableName('user_messages'), "recipient=" . $modx->getLoginUserID() . ""); - $num_rows = $modx->db->getValue($rs); - - // ============================================================== - // Exemple Usage - // Note: I make 2 query to the database for this exemple, it - // could (and should) be made with only one query... - // ============================================================== - - // If current position is not set, set it to zero - if(!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { - $int_cur_position = 0; - } else { - $int_cur_position = (int) $_REQUEST['int_cur_position']; - } +
    +
    +

    + db->select('count(id)', $modx->getFullTableName('user_messages'), "recipient=" . $modx->getLoginUserID() . ""); + $num_rows = $modx->db->getValue($rs); - // Number of result to display on the page, will be in the LIMIT of the sql query also - $int_num_result = $number_of_messages; + // ============================================================== + // Exemple Usage + // Note: I make 2 query to the database for this exemple, it + // could (and should) be made with only one query... + // ============================================================== + // If current position is not set, set it to zero + if (!isset($_REQUEST['int_cur_position']) || $_REQUEST['int_cur_position'] == 0) { + $int_cur_position = 0; + } else { + $int_cur_position = (int)$_REQUEST['int_cur_position']; + } - $extargv = "&a=10"; // extra argv here (could be anything depending on your page) + // Number of result to display on the page, will be in the LIMIT of the sql query also + $int_num_result = $number_of_messages; - include_once "paginate.inc.php"; - // New instance of the Paging class, you can modify the color and the width of the html table - $p = new Paging($num_rows, $int_cur_position, $int_num_result, $extargv); + $extargv = "&a=10"; // extra argv here (could be anything depending on your page) - // Load up the 2 array in order to display result - $array_paging = $p->getPagingArray(); - $array_row_paging = $p->getPagingRowArray(); + include_once "paginate.inc.php"; + // New instance of the Paging class, you can modify the color and the width of the html table + $p = new Paging($num_rows, $int_cur_position, $int_num_result, $extargv); - // Display the result as you like... - $pager .= $_lang['showing'] . " " . $array_paging['lower']; - $pager .= " " . $_lang['to'] . " " . $array_paging['upper']; - $pager .= " (" . $array_paging['total'] . " " . $_lang['total'] . ")"; - $pager .= "
    " . $array_paging['previous_link'] . "<<" . (isset($array_paging['previous_link']) ? " " : " "); - for($i = 0; $i < sizeof($array_row_paging); $i++) { - $pager .= $array_row_paging[$i] . " "; - } - $pager .= $array_paging['next_link'] . ">>" . (isset($array_paging['next_link']) ? "" : ""); + // Load up the 2 array in order to display result + $array_paging = $p->getPagingArray(); + $array_row_paging = $p->getPagingRowArray(); - // The above exemple print somethings like: - // Results 1 to 20 of 597 <<< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 >>> - // Of course you can now play with array_row_paging in order to print - // only the results you would like... + // Display the result as you like... + $pager .= $_lang['showing'] . " " . $array_paging['lower']; + $pager .= " " . $_lang['to'] . " " . $array_paging['upper']; + $pager .= " (" . $array_paging['total'] . " " . $_lang['total'] . ")"; + $pager .= "
    " . $array_paging['previous_link'] . "<<" . (isset($array_paging['previous_link']) ? " " : " "); + for ($i = 0; $i < sizeof($array_row_paging); $i++) { + $pager .= $array_row_paging[$i] . " "; + } + $pager .= $array_paging['next_link'] . ">>" . (isset($array_paging['next_link']) ? "" : ""); - $rs = $modx->db->select('*', $modx->getFullTableName('user_messages'), "recipient=" . $modx->getLoginUserID() . "", 'postdate DESC', "{$int_cur_position}, {$int_num_result}"); - $limit = $modx->db->getRecordCount($rs); - if($limit < 1) { - echo $_lang['messages_no_messages']; - } else { - echo $pager; - $dotablestuff = 1; - ?> - - - - - - - - - - - - - db->getRow($rs)) { - $sender = $message['sender']; - if($sender == 0) { - $sendername = "[System]"; - } else { - $rs2 = $modx->db->select('username', $modx->getFullTableName('manager_users'), "id='{$sender}'"); - $sendername = $modx->db->getValue($rs2); - } - $messagestyle = $message['messageread'] == 0 ? "messageUnread" : "messageRead"; - ?> - - - - - - - - >> + // Of course you can now play with array_row_paging in order to print + // only the results you would like... - if($dotablestuff == 1) { ?> - -
    " : ""; ?>toDateFormat($message['postdate'] + $server_offset_time); ?>
    - -
    + $rs = $modx->db->select('*', $modx->getFullTableName('user_messages'), "recipient=" . $modx->getLoginUserID() . "", 'postdate DESC', "{$int_cur_position}, {$int_num_result}"); + $limit = $modx->db->getRecordCount($rs); + if ($limit < 1) { + echo $_lang['messages_no_messages']; + } else { + $dotablestuff = 1; + ?> + + +
    +
    + + + + + + + + + + + + db->getRow($rs)) { + $sender = $message['sender']; + if ($sender == 0) { + $sendername = "[System]"; + } else { + $rs2 = $modx->db->select('username', $modx->getFullTableName('manager_users'), "id='{$sender}'"); + $sendername = $modx->db->getValue($rs2); + } + $messagestyle = $message['messageread'] == 0 ? "text-primary" : ""; + ?> + + + + + + + + + +
    ' : "" ?>toDateFormat($message['postdate'] + $server_offset_time) ?>
    +
    +
    + +
    -
    -
    -
    - db->select('*', $modx->getFullTableName('user_messages'), "id='" . $_REQUEST['id'] . "'"); - $message = $modx->db->getRow($rs); - if(!$message) { - echo "Wrong number of messages returned!"; - } else { - if($message['recipient'] != $modx->getLoginUserID()) { - echo $_lang['messages_not_allowed_to_read']; - } else { - // output message! - // get the name of the sender - $sender = $message['sender']; - if($sender == 0) { - $sendername = "[System]"; - } else { - $rs2 = $modx->db->select('username', $modx->getFullTableName('manager_users'), "id='{$sender}'"); - $sendername = $modx->db->getValue($rs2); - } - $subjecttext = $_REQUEST['m'] == 'rp' ? "Re: " : "Fwd: "; - $subjecttext .= $message['subject']; - $messagetext = "\n\n\n-----\n" . $_lang['messages_from'] . ": $sendername\n" . $_lang['messages_sent'] . ": " . $modx->toDateFormat($message['postdate'] + $server_offset_time) . "\n" . $_lang['messages_subject'] . ": " . $message['subject'] . "\n\n" . $message['message']; - if($_REQUEST['m'] == 'rp') { - $recipientindex = $message['sender']; - } - } - } - } - ?> - -
    -
    - : - - - - -
    -     -     - -
    :  - db->select('username, id', $modx->getFullTableName('manager_users')); - ?> - -
    - - -
    -
    +

    -

    +
    +
    +

    + db->select('*', $modx->getFullTableName('user_messages'), "id='" . $_REQUEST['id'] . "'"); + $message = $modx->db->getRow($rs); + if (!$message) { + echo "Wrong number of messages returned!"; + } else { + if ($message['recipient'] != $modx->getLoginUserID()) { + echo $_lang['messages_not_allowed_to_read']; + } else { + // output message! + // get the name of the sender + $sender = $message['sender']; + if ($sender == 0) { + $sendername = "[System]"; + } else { + $rs2 = $modx->db->select('username', $modx->getFullTableName('manager_users'), "id='{$sender}'"); + $sendername = $modx->db->getValue($rs2); + } + $subjecttext = $_REQUEST['m'] == 'rp' ? "Re: " : "Fwd: "; + $subjecttext .= $message['subject']; + $messagetext = "\n\n\n-----\n" . $_lang['messages_from'] . ": $sendername\n" . $_lang['messages_sent'] . ": " . $modx->toDateFormat($message['postdate'] + $server_offset_time) . "\n" . $_lang['messages_subject'] . ": " . $message['subject'] . "\n\n" . $message['message']; + if ($_REQUEST['m'] == 'rp') { + $recipientindex = $message['sender']; + } + } + } + } + ?> -
    - : - - - - - - - - - - - - - -
    :
    :
    - - - -
    - -
    + +
    + : +
    +
    +
    + + + +
    +
    +
    :  + db->select('username, id', $modx->getFullTableName('manager_users')); + ?> + +
    + + +
    +
    + : +
    +
    :
    +
    +
    +
    +
    :
    +
    +
    +
    + "> + "> +
    +
    hasPermission('messages'); ?> diff --git a/manager/actions/modules.static.php b/manager/actions/modules.static.php index a3f02bca51..de8980ba0a 100644 --- a/manager/actions/modules.static.php +++ b/manager/actions/modules.static.php @@ -1,22 +1,22 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('exec_module'))) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!($modx->hasPermission('new_module') || $modx->hasPermission('edit_module') || $modx->hasPermission('exec_module'))) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } // initialize page view state - the $_PAGE object $modx->manager->initPageViewState(); // get and save search string -if($_REQUEST['op'] == 'reset') { - $query = ''; - $_PAGE['vs']['search'] = ''; +if ($_REQUEST['op'] == 'reset') { + $query = ''; + $_PAGE['vs']['search'] = ''; } else { - $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search']; - $sqlQuery = $modx->db->escape($query); - $_PAGE['vs']['search'] = $query; + $query = isset($_REQUEST['search']) ? $_REQUEST['search'] : $_PAGE['vs']['search']; + $sqlQuery = $modx->db->escape($query); + $_PAGE['vs']['search'] = $query; } // get & save listmode @@ -28,7 +28,9 @@ include_once MODX_MANAGER_PATH . "includes/controls/contextmenu.php"; $cm = new ContextMenu("cntxm", 150); $cm->addItem($_lang["run_module"], "js:menuAction(1)", $_style['actions_run'], (!$modx->hasPermission('exec_module') ? 1 : 0)); -$cm->addSeparator(); +if ($modx->hasPermission('edit_module') || $modx->hasPermission('new_module') || $modx->hasPermission('delete_module')) { + $cm->addSeparator(); +} $cm->addItem($_lang["edit"], "js:menuAction(2)", $_style['actions_edit'], (!$modx->hasPermission('edit_module') ? 1 : 0)); $cm->addItem($_lang["duplicate"], "js:menuAction(3)", $_style['actions_duplicate'], (!$modx->hasPermission('new_module') ? 1 : 0)); $cm->addItem($_lang["delete"], "js:menuAction(4)", $_style['actions_delete'], (!$modx->hasPermission('delete_module') ? 1 : 0)); @@ -36,94 +38,113 @@ ?>

    - +

    -
    +
    -
    - db->select("id,name,description,IF(locked,'{$_lang['yes']}','-') as locked,IF(disabled,'{$_lang['yes']}','-') as disabled,IF(icon<>'',icon,'{$_style['icons_modules']}') as icon", $modx->getFullTableName("site_modules"), (!empty($sqlQuery) ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "name"); - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; - $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items - $grd->noRecordMsg = $_lang["no_records_found"]; - $grd->cssClass = "table data"; - $grd->columnHeaderClass = "tableHeader"; - $grd->itemClass = "tableItem"; - $grd->altItemClass = "tableAltItem"; - $grd->fields = "icon,name,description,locked,disabled"; - $grd->columns = $_lang["icon"] . " ," . $_lang["name"] . " ," . $_lang["description"] . " ," . $_lang["locked"] . " ," . $_lang["disabled"]; - $grd->colWidths = "34,,,60,60"; - $grd->colAligns = "center,,,center,center"; - $grd->colTypes = "template:||template:[+value+]"; - if($listmode == '1') { - $grd->pageSize = 0; - } - if($_REQUEST['op'] == 'reset') { - $grd->pageNumber = 1; - } - // render grid - echo $grd->render(); - ?> -
    +
    + config['use_udperms'])) { + $rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, sm.description, mg.member, IF(disabled,"' . $_lang['yes'] . '","-") as disabled, IF(sm.icon<>"",sm.icon,"' . $_style['icons_modules'] . '") as icon + FROM ' . $modx->getFullTableName('site_modules') . ' AS sm + LEFT JOIN ' . $modx->getFullTableName('site_module_access') . ' AS sma ON sma.module = sm.id + LEFT JOIN ' . $modx->getFullTableName('member_groups') . ' AS mg ON sma.usergroup = mg.user_group + WHERE (mg.member IS NULL OR mg.member = ' . $modx->getLoginUserID() . ') AND sm.disabled != 1 AND sm.locked != 1 + ORDER BY sm.name'); + if ($modx->hasPermission('edit_module')) { + $title = "[+value+]"; + } else if ($modx->hasPermission('exec_module')) { + $title = "[+value+]"; + } else { + $title = '[+value+]'; + } + } else { + $rs = $modx->db->select("id, name, description, IF(locked,'{$_lang['yes']}','-') as locked, IF(disabled,'{$_lang['yes']}','-') as disabled, IF(icon<>'',icon,'{$_style['icons_modules']}') as icon", $modx->getFullTableName("site_modules"), (!empty($sqlQuery) ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), "name"); + $title = "[+value+]"; + } + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; + $grd = new DataGrid('', $rs, $number_of_results); // set page size to 0 t show all items + $grd->noRecordMsg = $_lang["no_records_found"]; + $grd->cssClass = "table data"; + $grd->columnHeaderClass = "tableHeader"; + $grd->itemClass = "tableItem"; + $grd->altItemClass = "tableAltItem"; + $grd->fields = "icon,name,description,locked,disabled"; + $grd->columns = $_lang["icon"] . " ," . $_lang["name"] . " ," . $_lang["description"] . " ," . $_lang["locked"] . " ," . $_lang["disabled"]; + $grd->colWidths = "34,,,60,60"; + $grd->colAligns = "center,,,center,center"; + $grd->colTypes = "template:||template:" . $title; + if ($listmode == '1') { + $grd->pageSize = 0; + } + if ($_REQUEST['op'] == 'reset') { + $grd->pageNumber = 1; + } + // render grid + echo $grd->render(); + ?> +
    diff --git a/manager/actions/move_document.dynamic.php b/manager/actions/move_document.dynamic.php index bd4e66aaff..1caf165976 100644 --- a/manager/actions/move_document.dynamic.php +++ b/manager/actions/move_document.dynamic.php @@ -1,15 +1,15 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('save_document')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('save_document')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } -if(isset($_REQUEST['id'])) { - $id = intval($_REQUEST['id']); +if (isset($_REQUEST['id'])) { + $id = intval($_REQUEST['id']); } else { - $modx->webAlertAndQuit($_lang["error_no_id"]); + $modx->webAlertAndQuit($_lang["error_no_id"]); } // check permissions on the document @@ -19,8 +19,8 @@ $udperms->document = $id; $udperms->role = $_SESSION['mgrRole']; -if(!$udperms->checkPermissions()) { - $modx->webAlertAndQuit($_lang["access_permission_denied"]); +if (!$udperms->checkPermissions()) { + $modx->webAlertAndQuit($_lang["access_permission_denied"]); } // Set the item name for logger @@ -28,65 +28,71 @@ $_SESSION['itemname'] = $pagetitle; ?> -

    - +

    -
    - -
    + -
    -
    -
    -

    -

    - - - :
    -
    - -
    - -
    -
    +
    +
    +

    +
    + + + + +

    :

    + + +
    +
    diff --git a/manager/actions/mutate_content.dynamic.php b/manager/actions/mutate_content.dynamic.php index 9544f1ed42..2bb87ebcfe 100644 --- a/manager/actions/mutate_content.dynamic.php +++ b/manager/actions/mutate_content.dynamic.php @@ -46,11 +46,7 @@ $tbl_member_groups = $modx->getFullTableName('member_groups'); $tbl_membergroup_access = $modx->getFullTableName('membergroup_access'); $tbl_document_groups = $modx->getFullTableName('document_groups'); -$tbl_keyword_xref = $modx->getFullTableName('keyword_xref'); $tbl_site_content = $modx->getFullTableName('site_content'); -$tbl_site_content_metatags = $modx->getFullTableName('site_content_metatags'); -$tbl_site_keywords = $modx->getFullTableName('site_keywords'); -$tbl_site_metatags = $modx->getFullTableName('site_metatags'); $tbl_site_templates = $modx->getFullTableName('site_templates'); $tbl_site_tmplvar_access = $modx->getFullTableName('site_tmplvar_access'); $tbl_site_tmplvar_contentvalues = $modx->getFullTableName('site_tmplvar_contentvalues'); @@ -276,20 +272,6 @@ function checkParentChildRelation(pId, pName) { return true; } - function clearKeywordSelection() { - var opt = document.mutate.elements["keywords[]"].options; - for(var i = 0; i < opt.length; i++) { - opt[i].selected = false; - } - } - - function clearMetatagSelection() { - var opt = document.mutate.elements["metatags[]"].options; - for(var i = 0; i < opt.length; i++) { - opt[i].selected = false; - } - } - var curTemplate = -1; var curTemplateIndex = 0; @@ -925,96 +907,226 @@ function SetUrl(url, width, height, alt) { - manager->action == '4') || ($content['type'] == 'reference' || $modx->manager->action == 72)) { ?> - db->select($field, $from, $where, 'tvtpl.rank,tv.rank, tv.id'); - $limit = $modx->db->getRecordCount($rs); - if($limit > 0) { - ?> - -
    -
    - db->makeArray($rs, 'name'); - echo "\t" . '' . "\n"; - require_once(MODX_MANAGER_PATH . 'includes/tmplvars.inc.php'); - require_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); - $i = 0; - foreach($tvsArray as $row) { - // Go through and display all Template Variables - if($row['type'] == 'richtext' || $row['type'] == 'htmlarea') { - // determine TV-options - $tvOptions = $modx->parseProperties($row['elements']); - if(!empty($tvOptions)) { - // Allow different Editor with TV-option {"editor":"CKEditor4"} or &editor=Editor;text;CKEditor4 - $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor']; - }; - // Add richtext editor to the list - $richtexteditorIds[$editor][] = "tv" . $row['id']; - $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions; - } - // splitter - if($i++ > 0) { - echo "\t\t", '', "\n"; - } - - // post back value - if(array_key_exists('tv' . $row['id'], $_POST)) { - if(is_array($_POST['tv' . $row['id']])) { - $tvPBV = implode('||', $_POST['tv' . $row['id']]); - } else { - $tvPBV = $_POST['tv' . $row['id']]; - } - } else { - $tvPBV = $row['value']; - } - - $tvDescription = (!empty($row['description'])) ? '
    ' . $row['description'] . '' : ''; - $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '
    (' . $_lang['tmplvars_inherited'] . ')' : ''; - $tvName = $modx->hasPermission('edit_template') ? '
    [*' . $row['name'] . '*]' : ''; - - echo "\t\t", '\n", "\t\t\t", '\n"; - } - echo "\t
    ', $row['caption'] . $tvName, "\n", "\t\t\t", $tvDescription, $tvInherited, "
    ' . "\n", "\t\t\t" . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . "\n" . "\t\t
    \n"; - ?> -
    - - - " . $_lang['tmplvars_novars'] . "

    \n"; - } - ?> - + manager->action == '4') || ($content['type'] == 'reference' || $modx->manager->action == 72)) { + $template = $default_template; + $group_tvs = empty($modx->config['group_tvs']) ? 0 : (int)$modx->config['group_tvs']; + if (isset ($_REQUEST['newtemplate'])) { + $template = $_REQUEST['newtemplate']; + } else { + if (isset ($content['template'])) { + $template = $content['template']; + } + } + + $field = "DISTINCT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value, tvtpl.rank as tvrank"; + $vs = array( + $tbl_site_tmplvars, + $tbl_site_tmplvar_templates, + $tbl_site_tmplvar_contentvalues, + $id, + $tbl_site_tmplvar_access + ); + $from = vsprintf("%s AS tv INNER JOIN %s AS tvtpl ON tvtpl.tmplvarid = tv.id + LEFT JOIN %s AS tvc ON tvc.tmplvarid=tv.id AND tvc.contentid='%s' + LEFT JOIN %s AS tva ON tva.tmplvarid=tv.id", $vs); + $dgs = $docgrp ? " OR tva.documentgroup IN ({$docgrp})" : ''; + $vs = array( + $template, + $_SESSION['mgrRole'], + $dgs + ); + $sort = 'tvtpl.rank,tv.rank, tv.id'; + if ($group_tvs) { + $field .= ', IFNULL(tv.category,0) as category_id, IFNULL(cat.category,"' . $_lang['no_category'] . '") AS category, IFNULL(cat.rank,0) AS category_rank'; + $from .= ' + LEFT JOIN ' . $tbl_categories . ' AS cat ON cat.id=tv.category'; + $sort = 'cat.rank,cat.id,' . $sort; + } + $where = vsprintf("tvtpl.templateid='%s' AND (1='%s' OR ISNULL(tva.documentgroup) %s)", $vs); + $rs = $modx->db->select($field, $from, $where, $sort); + if ($modx->db->getRecordCount($rs)) { + $templateVariables .= ' + ' . "\n"; + if (!$group_tvs) { + $templateVariables .= ' +
    ' . $_lang['settings_templvars'] . '
    +
    + '; + } else if ($group_tvs == 2) { + $templateVariables .= ' +
    +
    ' . $_lang['settings_templvars'] . '
    +
    + '; + } else if ($group_tvs == 3) { + $templateVariables .= ' +
    +

    ' . $_lang['settings_templvars'] . '

    + '; + } else if ($group_tvs == 4) { + $templateVariables .= ' +
    +

    ' . $_lang['settings_templvars'] . '

    + + +
    + '; + } + + $tvsArray = $modx->db->makeArray($rs, 'name'); + require_once(MODX_MANAGER_PATH . 'includes/tmplvars.inc.php'); + require_once(MODX_MANAGER_PATH . 'includes/tmplvars.commands.inc.php'); + $i = 0; + $tab = ''; + foreach ($tvsArray as $row) { + if ($tab !== $row['category_id']) { + if ($group_tvs == 1 || $group_tvs == 3) { + if ($i === 0) { + $templateVariables .= ' +
    +
    ' . $row['category'] . '
    +
    +
    ' . "\n"; + } else { + $templateVariables .= ' +
    +
    +
    + +
    +
    ' . $row['category'] . '
    +
    + '; + } + } else if ($group_tvs == 2 || $group_tvs == 4) { + if ($i === 0) { + $templateVariables .= ' +
    +

    ' . $row['category'] . '

    + + +
    +
    '; + } else { + $templateVariables .= ' +
    +
    +
    + +
    +

    ' . $row['category'] . '

    + + +
    + '; + } + } else if ($group_tvs == 5) { + if ($i === 0) { + $templateVariables .= ' +
    +

    ' . $row['category'] . '

    + +
    '; + } else { + $templateVariables .= ' +
    +
    + +
    +

    ' . $row['category'] . '

    + + + '; + } + } + $split = 0; + } else { + $split = 1; + } + // Go through and display all Template Variables + if ($row['type'] == 'richtext' || $row['type'] == 'htmlarea') { + // determine TV-options + $tvOptions = $modx->parseProperties($row['elements']); + if (!empty($tvOptions)) { + // Allow different Editor with TV-option {"editor":"CKEditor4"} or &editor=Editor;text;CKEditor4 + $editor = isset($tvOptions['editor']) ? $tvOptions['editor'] : $modx->config['which_editor']; + }; + // Add richtext editor to the list + $richtexteditorIds[$editor][] = "tv" . $row['id']; + $richtexteditorOptions[$editor]["tv" . $row['id']] = $tvOptions; + } + // splitter + if ($group_tvs) { + if ($split && $i) { + $templateVariables .= ' + ' . "\n"; + } + } else if ($i) { + $templateVariables .= ' + ' . "\n"; + } + + // post back value + if (array_key_exists('tv' . $row['id'], $_POST)) { + if (is_array($_POST['tv' . $row['id']])) { + $tvPBV = implode('||', $_POST['tv' . $row['id']]); + } else { + $tvPBV = $_POST['tv' . $row['id']]; + } + } else { + $tvPBV = $row['value']; + } + + $tvDescription = (!empty($row['description'])) ? '
    ' . $row['description'] . '' : ''; + $tvInherited = (substr($tvPBV, 0, 8) == '@INHERIT') ? '
    (' . $_lang['tmplvars_inherited'] . ')' : ''; + $tvName = $modx->hasPermission('edit_template') ? '
    [*' . $row['name'] . '*]' : ''; + + $templateVariables .= ' + + + + '; + + $tab = $row['category_id']; + $i++; + } + $templateVariables .= ' +
    ' . $row['caption'] . $tvName . '' . $tvDescription . $tvInherited . '
    ' . renderFormElement($row['type'], $row['id'], $row['default_text'], $row['elements'], $tvPBV, '', $row, $tvsArray) . '
    +
    ' . "\n"; + if ($group_tvs == 1) { + $templateVariables .= ' +
    ' . "\n"; + } else if ($group_tvs == 2 || $group_tvs == 4) { + $templateVariables .= ' +
    +
    +
    ' . "\n"; + } else if ($group_tvs == 3) { + $templateVariables .= ' +
    + ' . "\n"; + } + $templateVariables .= ' + ' . "\n"; + } else { + // There aren't any Template Variables + //$templateVariables .= "\t

    " . $_lang['tmplvars_novars'] . "

    \n"; + } + } + + // Template Variables + if ($modx->config['group_tvs'] < 3) { + echo $templateVariables; + } + ?> @@ -1222,82 +1334,14 @@ function SetUrl(url, width, height, alt) { - - - hasPermission('edit_doc_metatags') && $modx->config['show_meta']) { - // get list of site keywords - $keywords = array(); - $ds = $modx->db->select('id, keyword', $tbl_site_keywords, '', 'keyword ASC'); - while($row = $modx->db->getRow($ds)) { - $keywords[$row['id']] = $row['keyword']; - } - // get selected keywords using document's id - if(isset ($content['id']) && count($keywords) > 0) { - $keywords_selected = array(); - $ds = $modx->db->select('keyword_id', $tbl_keyword_xref, "content_id='{$content['id']}'"); - while($row = $modx->db->getRow($ds)) { - $keywords_selected[$row['keyword_id']] = ' selected="selected"'; - } - } - - // get list of site META tags - $metatags = array(); - $ds = $modx->db->select('id, name', $tbl_site_metatags); - while($row = $modx->db->getRow($ds)) { - $metatags[$row['id']] = $row['name']; - } - // get selected META tags using document's id - if(isset ($content['id']) && count($metatags) > 0) { - $metatags_selected = array(); - $ds = $modx->db->select('metatag_id', $tbl_site_content_metatags, "content_id='{$content['id']}'"); - while($row = $modx->db->getRow($ds)) { - $metatags_selected[$row['metatag_id']] = ' selected="selected"'; - } - } - ?> - -
    -

    - - - - - - -


    - - - - -

    - -
    - -

    - -
    - -
    -
    -
    + config['group_tvs'] > 2) { + echo $templateVariables; + } + ?> INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -switch($modx->manager->action) { - case 78: - if(!$modx->hasPermission('edit_chunk')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - break; - case 77: - if(!$modx->hasPermission('new_chunk')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - break; - default: - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +switch ($modx->manager->action) { + case 78: + if (!$modx->hasPermission('edit_chunk')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + break; + case 77: + if (!$modx->hasPermission('new_chunk')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + break; + default: + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; @@ -24,8 +24,8 @@ $tbl_site_htmlsnippets = $modx->getFullTableName('site_htmlsnippets'); // check to see the snippet editor isn't locked -if($lockedEl = $modx->elementIsLocked(3, $id)) { - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['chunk'])); +if ($lockedEl = $modx->elementIsLocked(3, $id)) { + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['chunk'])); } // end check for lock @@ -33,31 +33,31 @@ $modx->lockElement(3, $id); $content = array(); -if(isset($_REQUEST['id']) && $_REQUEST['id'] != '' && is_numeric($_REQUEST['id'])) { - $rs = $modx->db->select('*', $tbl_site_htmlsnippets, "id='{$id}'"); - $content = $modx->db->getRow($rs); - if(!$content) { - $modx->webAlertAndQuit("Chunk not found for id '{$id}'."); - } - $_SESSION['itemname'] = $content['name']; - if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } -} else if(isset($_REQUEST['itemname'])) { - $content['name'] = $_REQUEST['itemname']; +if (isset($_REQUEST['id']) && $_REQUEST['id'] != '' && is_numeric($_REQUEST['id'])) { + $rs = $modx->db->select('*', $tbl_site_htmlsnippets, "id='{$id}'"); + $content = $modx->db->getRow($rs); + if (!$content) { + $modx->webAlertAndQuit("Chunk not found for id '{$id}'."); + } + $_SESSION['itemname'] = $content['name']; + if ($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } +} else if (isset($_REQUEST['itemname'])) { + $content['name'] = $_REQUEST['itemname']; } else { - $_SESSION['itemname'] = $_lang["new_htmlsnippet"]; - $content['category'] = intval($_REQUEST['catid']); + $_SESSION['itemname'] = $_lang["new_htmlsnippet"]; + $content['category'] = intval($_REQUEST['catid']); } -if($modx->manager->hasFormValues()) { - $modx->manager->loadFormValues(); +if ($modx->manager->hasFormValues()) { + $modx->manager->loadFormValues(); } -if(isset($_POST['which_editor'])) { - $which_editor = $_POST['which_editor']; +if (isset($_POST['which_editor'])) { + $which_editor = $_POST['which_editor']; } else { - $which_editor = $content['editor_name'] != 'none' ? $content['editor_name'] : 'none'; + $which_editor = $content['editor_name'] != 'none' ? $content['editor_name'] : 'none'; } $content = array_merge($content, $_POST); @@ -69,183 +69,189 @@ // Print RTE Javascript function ?> - - -
    - invokeEvent('OnChunkFormPrerender', array( - 'id' => $id, - )); - if(is_array($evtOut)) { - echo implode('', $evtOut); - } - - ?> - - - - -

    - -

    - - - -
    -
    -
    - -
    - - -
    -

    - -
    -
    - -
    -
    - - hasPermission('save_role')): ?> - - -
    - - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - - - +
    + +
    + +
    + + invokeEvent('OnChunkFormRender', array( + 'id' => $id, + )); + if (is_array($evtOut)) { + echo implode('', $evtOut); + } + ?> +
    + + invokeEvent('OnRichTextEditorInit', array( - 'editor' => $which_editor, - 'elements' => array( - 'post', - ), - )); - if(is_array($evtOut)) { - echo implode('', $evtOut); - } +if ($use_editor == 1) { + $evtOut = $modx->invokeEvent('OnRichTextEditorInit', array( + 'editor' => $which_editor, + 'elements' => array( + 'post', + ), + )); + if (is_array($evtOut)) { + echo implode('', $evtOut); + } } -?> diff --git a/manager/actions/mutate_menuindex_sort.dynamic.php b/manager/actions/mutate_menuindex_sort.dynamic.php index 019ef032a0..fed6a80053 100644 --- a/manager/actions/mutate_menuindex_sort.dynamic.php +++ b/manager/actions/mutate_menuindex_sort.dynamic.php @@ -1,12 +1,12 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('edit_document')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('edit_document')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } -$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : NULL; +$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : null; $reset = isset($_POST['reset']) && $_POST['reset'] == 'true' ? 1 : 0; $items = isset($_POST['list']) ? $_POST['list'] : ''; $ressourcelist = ''; @@ -19,212 +19,165 @@ $udperms->document = $id; $udperms->role = $_SESSION['mgrRole']; -if(!$udperms->checkPermissions()) { - $modx->webAlertAndQuit($_lang["access_permission_denied"]); +if (!$udperms->checkPermissions()) { + $modx->webAlertAndQuit($_lang["access_permission_denied"]); } -if(isset($_POST['listSubmitted'])) { - $updateMsg .= '
    ' . $_lang['sort_updated'] . '
    '; - if(strlen($items) > 0) { - $items = explode(';', $items); - foreach($items as $key => $value) { - $docid = ltrim($value, 'item_'); - $key = $reset ? 0 : $key; - if(is_numeric($docid)) { - $modx->db->update(array('menuindex' => $key), $modx->getFullTableName('site_content'), "id='{$docid}'"); - } - } - } +if (isset($_POST['listSubmitted'])) { + $updateMsg .= '
    ' . $_lang['sort_updated'] . '
    '; + if (strlen($items) > 0) { + $items = explode(';', $items); + foreach ($items as $key => $value) { + $docid = ltrim($value, 'item_'); + $key = $reset ? 0 : $key; + if (is_numeric($docid)) { + $modx->db->update(array('menuindex' => $key), $modx->getFullTableName('site_content'), "id='{$docid}'"); + } + } + } } -$limit = 0; $disabled = 'true'; $pagetitle = ''; -if($id !== NULL) { - $rs = $modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"); - $pagetitle = $modx->db->getValue($rs); - - $rs = $modx->db->select('id, pagetitle, parent, menuindex, published, hidemenu, deleted', $modx->getFullTableName('site_content'), "parent='{$id}'", 'menuindex ASC'); - $resource = $modx->db->makeArray($rs); - $limit = count($resource); - if($limit < 1) { - $updateMsg = $_lang['sort_nochildren']; - } else { - $disabled = 0; - foreach($resource as $item) { - // Add classes to determine whether it's published, deleted, not in the menu - // or has children. - // Use class names which match the classes in the document tree - $classes = ''; - $classes .= ($item['hidemenu']) ? ' notInMenuNode ' : ' inMenuNode'; - $classes .= ($item['published']) ? ' publishedNode ' : ' unpublishedNode '; - $classes = ($item['deleted']) ? ' deletedNode ' : $classes; - $hasChildren = (count($modx->getChildIds($item['id'], 1)) > 0) ? ' ' : ' '; - $ressourcelist .= '
  • ' . $hasChildren . $item['pagetitle'] . ' (' . $item['id'] . ')
  • '; - } - } +$ressourcelist = ''; +if ($id !== null) { + $rs = $modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$id}'"); + $pagetitle = $modx->db->getValue($rs); + + $rs = $modx->db->select('id, pagetitle, parent, menuindex, published, hidemenu, deleted, isfolder', $modx->getFullTableName('site_content'), "parent='{$id}'", 'menuindex ASC'); + if ($modx->db->getRecordCount($rs)) { + $ressourcelist .= '
      '; + while ($row = $modx->db->getRow($rs)) { + $classes = ''; + $classes .= ($row['hidemenu']) ? ' notInMenuNode ' : ' inMenuNode'; + $classes .= ($row['published']) ? ' publishedNode ' : ' unpublishedNode '; + $classes = ($row['deleted']) ? ' deletedNode ' : $classes; + $icon = $row['isfolder'] ? ' ' : ' '; + $ressourcelist .= '
    • ' . $icon . $row['pagetitle'] . ' (' . $row['id'] . ')
    • '; + } + $ressourcelist .= '
    '; + } else { + $updateMsg = '

    ' . $_lang['sort_nochildren'] . '

    '; + } } $pagetitle = $id == 0 ? $site_name : $pagetitle; ?> - -

    - +

    -
    - () -

    -

    - - -

    - - -
      - -
    - -
    - - -
    -
    +
    + () + +

    +

    + + +

    + + + + +
    +
    + + +
    + diff --git a/manager/actions/mutate_password.dynamic.php b/manager/actions/mutate_password.dynamic.php index 3f09fd6d2c..a33bd92acb 100644 --- a/manager/actions/mutate_password.dynamic.php +++ b/manager/actions/mutate_password.dynamic.php @@ -24,24 +24,19 @@ -
    -
    -
    +
    +

    - - - - - - - - - - - -
    : 
    : 
    +
    +
    :
    +
    +
    +
    +
    :
    +
    +
    diff --git a/manager/actions/mutate_plugin.dynamic.php b/manager/actions/mutate_plugin.dynamic.php index 716ba3b275..7f984c609e 100644 --- a/manager/actions/mutate_plugin.dynamic.php +++ b/manager/actions/mutate_plugin.dynamic.php @@ -1,21 +1,21 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -switch($modx->manager->action) { - case 102: - if(!$modx->hasPermission('edit_plugin')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - break; - case 101: - if(!$modx->hasPermission('new_plugin')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - break; - default: - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +switch ($modx->manager->action) { + case 102: + if (!$modx->hasPermission('edit_plugin')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + break; + case 101: + if (!$modx->hasPermission('new_plugin')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + break; + default: + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; @@ -25,32 +25,32 @@ $tbl_system_eventnames = $modx->getFullTableName('system_eventnames'); // check to see the plugin isn't locked -if($lockedEl = $modx->elementIsLocked(5, $id)) { - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['plugin'])); +if ($lockedEl = $modx->elementIsLocked(5, $id)) { + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['plugin'])); } // end check for lock // Lock plugin for other users to edit $modx->lockElement(5, $id); -if(isset($_GET['id'])) { - $rs = $modx->db->select('*', $tbl_site_plugins, "id='{$id}'"); - $content = $modx->db->getRow($rs); - if(!$content) { - header("Location: {$modx->config['site_url']}"); - } - $_SESSION['itemname'] = $content['name']; - if($content['locked'] == 1 && $modx->hasPermission('save_role') != 1) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - $content['properties'] = str_replace("&", "&", $content['properties']); +if (isset($_GET['id'])) { + $rs = $modx->db->select('*', $tbl_site_plugins, "id='{$id}'"); + $content = $modx->db->getRow($rs); + if (!$content) { + header("Location: {$modx->config['site_url']}"); + } + $_SESSION['itemname'] = $content['name']; + if ($content['locked'] == 1 && $modx->hasPermission('save_role') != 1) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + $content['properties'] = str_replace("&", "&", $content['properties']); } else { - $_SESSION['itemname'] = $_lang["new_plugin"]; - $content['category'] = intval($_REQUEST['catid']); + $_SESSION['itemname'] = $_lang["new_plugin"]; + $content['category'] = intval($_REQUEST['catid']); } -if($modx->manager->hasFormValues()) { - $modx->manager->loadFormValues(); +if ($modx->manager->hasFormValues()) { + $modx->manager->loadFormValues(); } // Add lock-element JS-Script @@ -58,623 +58,657 @@ $lockElementType = 5; require_once(MODX_MANAGER_PATH . 'includes/active_user_locks.inc.php'); -function bold($cond = false) { - if($cond !== false) { - return ' style="background-color:#777;color:#fff;"'; - } else { - return; - } +function bold($cond = false) +{ + if ($cond !== false) { + return ' style="background-color:#777;color:#fff;"'; + } else { + return; + } } ?>
    - - - -

    - -

    - - - -
    -
    -
    - -
    - - - -
    -

    - -
    -
    -
    - -
    -
    - - hasPermission('save_role')): ?> - - -
    - - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    - -
    - hasPermission('save_role')): ?> -
    - - -
    - -
    -
    - - -
    - -
    - -
    - - -
    -

    - -
    -
    - -
    -
    -
    -
    -
    -
    - - -
    -

    - -
    -
    -
    - -
    - + + +

    + +

    + + + +
    +
    +
    + +
    + + + +
    +

    + +
    +
    +
    + +
    +
    + + hasPermission('save_role')): ?> + + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + hasPermission('save_role')): ?> +
    +
    + +
    +
    + + +
    +
    + +
    + + + +
    + +
    + +
    + + +
    +

    + +
    +
    + +
    +
    +
    +
    +
    +
    + + +
    +

    + +
    +
    +
    + +
    + - -
    -
    -
    -
    - -
    -
    - -
    - -
    - -
    - - -
    -

    - -
    -

    - 0) { - $rs = $modx->db->select('evtid', $tbl_site_plugin_events, "pluginid='{$id}'"); - $evts = $modx->db->getColumn('evtid', $rs); - } else { - if(isset($content['sysevents']) && is_array($content['sysevents'])) { - $evts = $content['sysevents']; - } else { - $evts = array(); - } - } - - // display system events - $evtnames = array(); - $services = array( - "Parser Service Events", - "Manager Access Events", - "Web Access Service Events", - "Cache Service Events", - "Template Service Events", - "User Defined Events" - ); - $rs = $modx->db->select('*', $tbl_system_eventnames, '', 'service DESC, groupname, name'); - $limit = $modx->db->getRecordCount($rs); - if($limit == 0) { - echo ""; - } else { - while($row = $modx->db->getRow($rs)) { - // display records - if($srv != $row['service']) { - $srv = $row['service']; - if(count($evtnames) > 0) { - echoEventRows($evtnames); - } - echo '
    '; - echo '
    ' . $services[$srv - 1] . '
    '; - } - // display group name - if($grp != $row['groupname']) { - $grp = $row['groupname']; - if(count($evtnames) > 0) { - echoEventRows($evtnames); - } - echo '
    '; - echo '
    ' . $row['groupname'] . '
    '; - } - $evtnames[] = ' ' . "\n"; - if(count($evtnames) == 2) { - echoEventRows($evtnames); - } - } - } - if(count($evtnames) > 0) { - echoEventRows($evtnames); - } - - function echoEventRows(&$evtnames) { - echo '
    ' . implode('
    ', $evtnames) . '
    '; - $evtnames = array(); - } - - ?> -
    -
    - - -
    -

    - -
    - -
    -
    - -
    - - - invokeEvent("OnPluginFormRender", array("id" => $id)); - if(is_array($evtOut)) { - echo implode("", $evtOut); - } - ?> + while ($row = $modx->db->getRow($ds)) { + echo ""; + } + ?> + + +
    +
    +
    +
    + +
    +
    + +
    + +
    + +
    + + +
    +

    + +
    +

    + 0) { + $rs = $modx->db->select('evtid', $tbl_site_plugin_events, "pluginid='{$id}'"); + $evts = $modx->db->getColumn('evtid', $rs); + } else { + if (isset($content['sysevents']) && is_array($content['sysevents'])) { + $evts = $content['sysevents']; + } else { + $evts = array(); + } + } + + // display system events + $evtnames = array(); + $services = array( + "Parser Service Events", + "Manager Access Events", + "Web Access Service Events", + "Cache Service Events", + "Template Service Events", + "User Defined Events" + ); + $rs = $modx->db->select('*', $tbl_system_eventnames, '', 'service DESC, groupname, name'); + $limit = $modx->db->getRecordCount($rs); + if ($limit == 0) { + echo ""; + } else { + while ($row = $modx->db->getRow($rs)) { + // display records + if ($srv != $row['service']) { + $srv = $row['service']; + if (count($evtnames) > 0) { + echoEventRows($evtnames); + } + echo '
    '; + echo '
    ' . $services[$srv - 1] . '
    '; + } + // display group name + if ($grp != $row['groupname']) { + $grp = $row['groupname']; + if (count($evtnames) > 0) { + echoEventRows($evtnames); + } + echo '
    '; + echo '
    ' . $row['groupname'] . '
    '; + } + $evtnames[] = ' ' . "\n"; + if (count($evtnames) == 2) { + echoEventRows($evtnames); + } + } + } + if (count($evtnames) > 0) { + echoEventRows($evtnames); + } + + function echoEventRows(&$evtnames) + { + echo '
    ' . implode('
    ', $evtnames) . '
    '; + $evtnames = array(); + } + + ?> +
    +
    + + +
    +

    + +
    + +
    +
    + +
    + + + invokeEvent("OnPluginFormRender", array("id" => $id)); + if (is_array($evtOut)) { + echo implode("", $evtOut); + } + ?>
    diff --git a/manager/actions/mutate_plugin_priority.dynamic.php b/manager/actions/mutate_plugin_priority.dynamic.php index a627e5e72e..97adb32cd3 100644 --- a/manager/actions/mutate_plugin_priority.dynamic.php +++ b/manager/actions/mutate_plugin_priority.dynamic.php @@ -1,37 +1,37 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('save_plugin')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('save_plugin')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $siteURL = $modx->config['site_url']; $updateMsg = ''; -if(isset($_POST['listSubmitted'])) { - $updateMsg .= '' . $_lang['sort_updated'] . '

    '; - $tbl = $modx->getFullTableName('site_plugin_events'); - - foreach($_POST as $listName => $listValue) { - if($listName == 'listSubmitted') { - continue; - } - $orderArray = explode(',', $listValue); - $listName = ltrim($listName, 'list_'); - if(count($orderArray) > 0) { - foreach($orderArray as $key => $item) { - if($item == '') { - continue; - } - $pluginId = ltrim($item, 'item_'); - $modx->db->update(array('priority' => $key), $tbl, "pluginid='{$pluginId}' AND evtid='{$listName}'"); - } - } - } - // empty cache - $modx->clearCache('full'); +if (isset($_POST['listSubmitted'])) { + $updateMsg .= '' . $_lang['sort_updated'] . ''; + $tbl = $modx->getFullTableName('site_plugin_events'); + + foreach ($_POST as $listName => $listValue) { + if ($listName == 'listSubmitted') { + continue; + } + $orderArray = explode(',', $listValue); + $listName = ltrim($listName, 'list_'); + if (count($orderArray) > 0) { + foreach ($orderArray as $key => $item) { + if ($item == '') { + continue; + } + $pluginId = ltrim($item, 'item_'); + $modx->db->update(array('priority' => $key), $tbl, "pluginid='{$pluginId}' AND evtid='{$listName}'"); + } + } + } + // empty cache + $modx->clearCache('full'); } $rs = $modx->db->select("sysevt.name as evtname, sysevt.id as evtid, pe.pluginid, plugs.name, pe.priority, plugs.disabled", $modx->getFullTableName('system_eventnames') . " sysevt @@ -40,131 +40,86 @@ $insideUl = 0; $preEvt = ''; -$evtLists = ''; +$sortableList = ''; $sortables = array(); -while($plugins = $modx->db->getRow($rs)) { - if($preEvt !== $plugins['evtid']) { - $sortables[] = $plugins['evtid']; - $evtLists .= $insideUl ? '
    ' : ''; - $evtLists .= '' . $plugins['evtname'] . '
      '; - $insideUl = 1; - } - $evtLists .= '
    • ' . $plugins['name'] . ($plugins['disabled'] ? ' (hide)' : '') . '
    • '; - $preEvt = $plugins['evtid']; +while ($plugins = $modx->db->getRow($rs)) { + if ($preEvt !== $plugins['evtid']) { + $sortables[] = $plugins['evtid']; + $sortableList .= $insideUl ? '
    ' : ''; + $sortableList .= '
    ' . $plugins['evtname'] . '
      '; + $insideUl = 1; + } + $sortableList .= '
    • ' . $plugins['name'] . ($plugins['disabled'] ? ' (hide)' : '') . '
    • '; + $preEvt = $plugins['evtid']; } -if($insideUl) { - $evtLists .= '
    '; +if ($insideUl) { + $sortableList .= '
    '; } require_once(MODX_MANAGER_PATH . 'includes/header.inc.php'); ?> - - -

    +

    + +

    -
    - -
    -

    - - - - - -
    - - - - -
    -
    -
    +
    + +

    + + + + + + +
    +
    + + + + +
    + 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/actions/mutate_settings.dynamic.php b/manager/actions/mutate_settings.dynamic.php index 63e6e88218..624546f422 100644 --- a/manager/actions/mutate_settings.dynamic.php +++ b/manager/actions/mutate_settings.dynamic.php @@ -23,8 +23,8 @@ while($row = $modx->db->getRow($rs)) { $settings[$row['setting_name']] = $row['setting_value']; } -$settings['filemanager_path'] = preg_replace('@^' . MODX_BASE_PATH . '@', '[(base_path)]', $settings['filemanager_path']); -$settings['rb_base_dir'] = preg_replace('@^' . MODX_BASE_PATH . '@', '[(base_path)]', $settings['rb_base_dir']); +$settings['filemanager_path'] = preg_replace('@^' . preg_quote(MODX_BASE_PATH) . '@', '[(base_path)]', $settings['filemanager_path']); +$settings['rb_base_dir'] = preg_replace('@^' . preg_quote(MODX_BASE_PATH) . '@', '[(base_path)]', $settings['rb_base_dir']); extract($settings, EXTR_OVERWRITE); diff --git a/manager/actions/mutate_settings/tab1_site_settings.inc.php b/manager/actions/mutate_settings/tab1_site_settings.inc.php index e9153d3cbf..5ade04b0f6 100644 --- a/manager/actions/mutate_settings/tab1_site_settings.inc.php +++ b/manager/actions/mutate_settings/tab1_site_settings.inc.php @@ -11,50 +11,50 @@ - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + + + + + + - + - + - + - + - + - + diff --git a/manager/actions/mutate_settings/tab2_furl_settings.inc.php b/manager/actions/mutate_settings/tab2_furl_settings.inc.php index 5a8ac2cf10..2269244e37 100644 --- a/manager/actions/mutate_settings/tab2_furl_settings.inc.php +++ b/manager/actions/mutate_settings/tab2_furl_settings.inc.php @@ -4,7 +4,7 @@

    [(site_status)]

    htmlspecialchars($_lang['sitename_title']) ?>htmlspecialchars($_lang['sitename_title']) ?>
    [(site_name)]

    [(emailsender)]

    [(site_start)]

    [(error_page)]

    [(unauthorized_page)]

    [(site_unavailable_page)]
    +
    [(site_unavailable_message)]


    [(default_template)]
    db->select( @@ -121,7 +121,7 @@

    [(auto_template_logic)]


    @@ -130,7 +130,7 @@

    [(enable_filter)]

    [(publish_default)]

    @@ -159,7 +159,7 @@

    [(cache_default)]

    @@ -167,7 +167,7 @@

    [(search_default)]

    @@ -175,7 +175,7 @@

    [(auto_menuindex)]

    @@ -200,7 +200,7 @@

    [(docid_incrmnt_method)]

    [(enable_cache)]
    +
    +
    + +

    [(cache_type)]


    [(minifyphp_incache)]

    @@ -232,7 +241,7 @@

    [(server_offset_time)]

    [(server_protocol)]

    @@ -256,13 +265,13 @@

    [(rss_url_news)]

    [(track_visitors)]

    @@ -270,7 +279,7 @@

    [(top_howmany)]
    - + - + > - +> @@ -43,7 +43,7 @@ > - +> @@ -54,7 +54,7 @@ > - +> - +> - + > - +> - +> - +> - +

    [(friendly_urls)]

    @@ -18,7 +18,7 @@

    [(xhtml_urls)]

    @@ -32,7 +32,7 @@

    [(friendly_url_prefix)]

    [(friendly_url_suffix)]

    [(make_folders)]

    @@ -69,7 +69,7 @@

    [(seostrict)]

    @@ -84,7 +84,7 @@

    [(aliaslistingfolder)]

    @@ -99,7 +99,7 @@

    [(friendly_alias_urls)]

    @@ -113,7 +113,7 @@

    [(use_alias_path)]

    @@ -127,7 +127,7 @@

    [(allow_duplicate_alias)]

    @@ -141,7 +141,7 @@

    [(automatic_alias)]

    diff --git a/manager/actions/mutate_settings/tab3_user_settings.inc.php b/manager/actions/mutate_settings/tab3_user_settings.inc.php index 83e5b93135..31320489eb 100644 --- a/manager/actions/mutate_settings/tab3_user_settings.inc.php +++ b/manager/actions/mutate_settings/tab3_user_settings.inc.php @@ -4,7 +4,7 @@ - + > - + - + - - - -

    [(use_udperms)]

    @@ -18,7 +18,7 @@

    [(udperms_allowroot)]

    @@ -37,7 +37,7 @@

    [(email_method)]

    @@ -50,7 +50,7 @@
    +
    [(emailsubject)]

    +
    [(signupemail_message)]

    +
    [(websignupemail_message)]

    +
    [(webpwdreminder_message)]

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -> + + + + > + + + + > + + + > + + + + > + + + + > + + + > + + + + > + + + + > + + + > + + + + > + + + + > + + + + + +
     
     
     

    -
     
    -
    -
     
    -
    -
     
    -
    -
     
    -
    +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -invokeEvent('OnRichTextEditorRegister'); - if(!is_array($evtOut)) { - $evtOut = array(); - $use_editor = 0; - } -?> - > - - - - > - - - - > - - - - - > - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - > - - - - > - - - > - - - - > - - - - > - - - > - - - - > - - - - > - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + invokeEvent('OnInterfaceSettingsRender'); - if(is_array($evtOut)) echo implode("",$evtOut); + // invoke OnRichTextEditorRegister event + $evtOut = $modx->invokeEvent('OnRichTextEditorRegister'); + if (!is_array($evtOut)) { + $evtOut = array(); + $use_editor = 0; + } ?> - - -

    + [(manager_language)] +
    + +
     
    +
    +

    + [(modx_charset)] +
    + +
     
    +
    +

    + [(manager_theme)] +
    + +
     
     
     
    -
    -
     
    -
    -
     
     
     
     
     
     
     
    -
    - -
     
    -
    +
    +

    + [(warning_visibility)] +
    + +
    + +
     
    +
    +

    + [(tree_page_click)] +
    + +
    + +
     
    +
    +

    + [(use_breadcrumbs)] +
    + +
    + +
     
    +
    +

    + [(remember_last_tab)] +
    + +
    + +
     
    +
    +
    +
    + [(group_tvs)] +
    + -
     
     
    -
     
    + echo implode("\n", $output) + ?> + +
     
    +
    +

    + [(resource_tree_node_name)] +
    + +
    +
     
    +
    +

    + [(session_timeout)] +
     
    +
    +

    + [(tree_show_protected)] +
    + +
    + +
     
    +
    +

    + [(datepicker_offset)] +
     
    +
    +

    + [(datetime_format)] +
    + +
     
    +
    +

    + [(number_of_logs)] +
     
    +
    +

    + [(mail_check_timeperiod)] +
     
    +
    +

    + [(number_of_messages)] +
     
    +
    +

    + [(number_of_results)] +
     
    +
    +
    +

    + [(use_editor)] +
    +
    + +
     
    +
    +

    + [(which_editor)] +
    + +
     
    +
    +

    + [(fe_editor_lang)] +
    + +
     
    +
    +

    + [(editor_css_path)] +
     
    +
    +
    + invokeEvent('OnInterfaceSettingsRender'); + if (is_array($evtOut)) { + echo implode("", $evtOut); + } + ?> +
    diff --git a/manager/actions/mutate_settings/tab5_security_settings.inc.php b/manager/actions/mutate_settings/tab5_security_settings.inc.php index 3d87f7e186..bebb006549 100644 --- a/manager/actions/mutate_settings/tab5_security_settings.inc.php +++ b/manager/actions/mutate_settings/tab5_security_settings.inc.php @@ -9,7 +9,7 @@ - + - + - + - + - + @@ -72,7 +72,7 @@ - + @@ -83,7 +83,7 @@ - + - + - + - + @@ -139,7 +139,7 @@ - + @@ -150,7 +150,7 @@ - + - + > - ' . "\n" . ' ' . "\n" . ' ' . "\n"; + ?> +
    + db->getRow($rs)) { - if($row['id'] !== $pid) { + if($pid != $row['id']) { if($pid != '') { - echo "\n"; - } // close previous one - - echo '

    [(allow_eval)]


    @@ -24,7 +24,7 @@

    [(safe_functions_at_eval)]
    @@ -37,7 +37,7 @@

    [(check_files_onlogin)]

    @@ -47,7 +47,7 @@

    [(validate_referer)]

    @@ -61,7 +61,7 @@

    [(valid_hostnames)]

    [(rss_url_security)]

    [(error_reporting)]


    @@ -97,7 +97,7 @@

    [(send_errormail)]


    @@ -109,7 +109,7 @@

    [(enable_bindings)]

    @@ -128,7 +128,7 @@

    [(failed_login_attempts)]

    [(blocked_minutes)]

    [(pwd_hash_algo)]

    [(use_captcha)]

    +
    [(captcha_words)]

    - + - + @@ -31,7 +31,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -57,7 +57,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -83,7 +83,7 @@ - + @@ -96,7 +96,7 @@ - + diff --git a/manager/actions/mutate_settings/tab7_filebrowser_settings.inc.php b/manager/actions/mutate_settings/tab7_filebrowser_settings.inc.php index 01ab003ba6..2534a2de5d 100644 --- a/manager/actions/mutate_settings/tab7_filebrowser_settings.inc.php +++ b/manager/actions/mutate_settings/tab7_filebrowser_settings.inc.php @@ -4,7 +4,7 @@

    [(filemanager_path)]
    [(base_path)]
    @@ -18,7 +18,7 @@

    [(upload_files)]

    [(upload_images)]

    [(upload_media)]

    [(upload_flash)]

    [(upload_maxsize)]

    [(new_file_permissions)]

    [(new_folder_permissions)]
    - + > - + > - + > - + > - + @@ -84,7 +84,7 @@ > - + > - + > - + @@ -129,7 +129,7 @@ > - + @@ -142,7 +142,7 @@ > - + @@ -155,7 +155,7 @@ > - + @@ -168,7 +168,7 @@ > - + @@ -181,7 +181,7 @@ > - + @@ -194,7 +194,7 @@ > - + > - + > - + "; + } else { + echo ""; + } + ?> + + + + + + + + + + + + + +

    [(use_browser)]

    @@ -19,7 +19,7 @@

    [(which_browser)]

    [(rb_webuser)]

    @@ -57,7 +57,7 @@

    [(rb_base_dir)]
    [(base_path)]assets/
    @@ -71,7 +71,7 @@

    [(rb_base_url)]

    [(clean_uploaded_filename)]

    @@ -100,7 +100,7 @@

    [(strip_image_paths)]

    @@ -116,7 +116,7 @@

    [(maxImageWidth)]

    [(maxImageHeight)]

    [(thumbWidth)]

    [(thumbHeight)]

    [(thumbsDir)]

    [(jpegQuality)]

    [(denyZipDownload)]

    @@ -206,7 +206,7 @@

    [(denyExtensionRename)]

    @@ -218,7 +218,7 @@

    [(showHiddenFiles)]

    diff --git a/manager/actions/mutate_snippet.dynamic.php b/manager/actions/mutate_snippet.dynamic.php index ae33bb708b..a2a216a150 100644 --- a/manager/actions/mutate_snippet.dynamic.php +++ b/manager/actions/mutate_snippet.dynamic.php @@ -1,21 +1,21 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -switch($modx->manager->action) { - case 22: - if(!$modx->hasPermission('edit_snippet')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - break; - case 23: - if(!$modx->hasPermission('new_snippet')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - break; - default: - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +switch ($modx->manager->action) { + case 22: + if (!$modx->hasPermission('edit_snippet')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + break; + case 23: + if (!$modx->hasPermission('new_snippet')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + break; + default: + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; @@ -26,8 +26,8 @@ $tbl_site_snippets = $modx->getFullTableName('site_snippets'); // check to see the snippet editor isn't locked -if($lockedEl = $modx->elementIsLocked(4, $id)) { - $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['snippet'])); +if ($lockedEl = $modx->elementIsLocked(4, $id)) { + $modx->webAlertAndQuit(sprintf($_lang['lock_msg'], $lockedEl['username'], $_lang['snippet'])); } // end check for lock @@ -35,26 +35,26 @@ $modx->lockElement(4, $id); $content = array(); -if(isset($_GET['id'])) { - $rs = $modx->db->select('*', $tbl_site_snippets, "id='{$id}'"); - $content = $modx->db->getRow($rs); - if(!$content) { - header("Location: " . MODX_SITE_URL . "index.php?id=" . $site_start); - } - $_SESSION['itemname'] = $content['name']; - if($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); - } - $content['properties'] = str_replace("&", "&", $content['properties']); -} else if(isset($_REQUEST['itemname'])) { - $content['name'] = $_REQUEST['itemname']; +if (isset($_GET['id'])) { + $rs = $modx->db->select('*', $tbl_site_snippets, "id='{$id}'"); + $content = $modx->db->getRow($rs); + if (!$content) { + header("Location: " . MODX_SITE_URL . "index.php?id=" . $site_start); + } + $_SESSION['itemname'] = $content['name']; + if ($content['locked'] == 1 && $_SESSION['mgrRole'] != 1) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); + } + $content['properties'] = str_replace("&", "&", $content['properties']); +} else if (isset($_REQUEST['itemname'])) { + $content['name'] = $_REQUEST['itemname']; } else { - $_SESSION['itemname'] = $_lang["new_snippet"]; - $content['category'] = intval($_REQUEST['catid']); + $_SESSION['itemname'] = $_lang["new_snippet"]; + $content['category'] = intval($_REQUEST['catid']); } -if($modx->manager->hasFormValues()) { - $modx->manager->loadFormValues(); +if ($modx->manager->hasFormValues()) { + $modx->manager->loadFormValues(); } $content = array_merge($content, $_POST); @@ -66,498 +66,530 @@ ?>
    - invokeEvent("OnSnipFormPrerender", array("id" => $id)); - if(is_array($evtOut)) { - echo implode("", $evtOut); - } - - // Prepare info-tab via parseDocBlock - $snippetcode = isset($content['snippet']) ? $modx->db->escape($content['snippet']) : ''; - $parsed = $modx->parseDocBlockFromString($snippetcode); - $docBlockList = $modx->convertDocBlockIntoList($parsed); - ?> - - - -

    - -

    - - - -
    -
    -
    - -
    - - - -
    -

    - -
    -
    -
    - -
    -
    - - hasPermission('save_role')): ?> - - -
    - - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - hasPermission('save_role')): ?> -
    - - -
    - -
    - - - -
    - -
    - -
    - - -
    -

    - -
    -
    - -
    -
    -
    -
    -
    -
    - - -
    -

    - -
    -
    -
    - -
    - + + +

    + +

    + + + +
    +
    +
    + +
    + + + +
    +

    + +
    +
    +
    + +
    +
    + + hasPermission('save_role')): ?> + + +
    + + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + hasPermission('save_role')): ?> +
    + +
    + +
    + +
    + + +
    +
    + +
    + + + +
    + +
    + +
    + + +
    +

    + +
    +
    + +
    +
    +
    +
    +
    +
    + + +
    +

    + +
    +
    +
    + +
    + - -
    -
    -
    -
    - -
    -
    - -
    - -
    - -
    - - -
    -

    - -
    - -
    -
    - - - invokeEvent("OnSnipFormRender", array("id" => $id)); - if(is_array($evtOut)) { - echo implode("", $evtOut); - } - ?> + while ($row = $modx->db->getRow($ds)) { + echo ""; + } + ?> + + +
    +
    +
    +
    + +
    +
    + +
    + +
    + +
    + + +
    +

    + +
    + +
    +
    + + + invokeEvent("OnSnipFormRender", array("id" => $id)); + if (is_array($evtOut)) { + echo implode("", $evtOut); + } + ?> diff --git a/manager/actions/mutate_template_tv_rank.dynamic.php b/manager/actions/mutate_template_tv_rank.dynamic.php index cf22b6df6d..78a80dd768 100644 --- a/manager/actions/mutate_template_tv_rank.dynamic.php +++ b/manager/actions/mutate_template_tv_rank.dynamic.php @@ -1,9 +1,9 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('save_template')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('save_template')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; @@ -17,202 +17,153 @@ $updateMsg = ''; -if(isset($_POST['listSubmitted'])) { - $updateMsg .= '
    ' . $_lang['sort_updated'] . '
    '; - foreach($_POST as $listName => $listValue) { - if($listName == 'listSubmitted' || $listName == 'reset') { - continue; - } - $orderArray = explode(';', rtrim($listValue, ';')); - foreach($orderArray as $key => $item) { - if(strlen($item) == 0) { - continue; - } - $key = $reset ? 0 : $key; - $tmplvar = ltrim($item, 'item_'); - $modx->db->update(array('rank' => $key), $tbl_site_tmplvar_templates, "tmplvarid='{$tmplvar}' AND templateid='{$id}'"); - } - } - // empty cache - $modx->clearCache('full'); +if (isset($_POST['listSubmitted'])) { + $updateMsg .= '
    ' . $_lang['sort_updated'] . '
    '; + foreach ($_POST as $listName => $listValue) { + if ($listName == 'listSubmitted' || $listName == 'reset') { + continue; + } + $orderArray = explode(';', rtrim($listValue, ';')); + foreach ($orderArray as $key => $item) { + if (strlen($item) == 0) { + continue; + } + $key = $reset ? 0 : $key; + $tmplvar = ltrim($item, 'item_'); + $modx->db->update(array('rank' => $key), $tbl_site_tmplvar_templates, "tmplvarid='{$tmplvar}' AND templateid='{$id}'"); + } + } + // empty cache + $modx->clearCache('full'); } $rs = $modx->db->select("tv.name AS name, tv.caption AS caption, tv.id AS id, tr.templateid, tr.rank, tm.templatename", "{$tbl_site_tmplvar_templates} AS tr INNER JOIN {$tbl_site_tmplvars} AS tv ON tv.id = tr.tmplvarid - INNER JOIN {$tbl_site_templates} AS tm ON tr.templateid = tm.id", "tr.templateid='{$id}'", "tr.rank DESC, tv.rank DESC, tv.id DESC" // workaround for correct sort of none-existing ranks -); -$limit = $modx->db->getRecordCount($rs); - -if($limit > 1) { - $tvsArr = array(); - while($row = $modx->db->getRow($rs)) { - $tvsArr[] = $row; - } - $tvsArr = array_reverse($tvsArr, true); // reverse ORDERBY DESC - - $i = 0; - foreach($tvsArr as $row) { - if($i++ == 0) { - $evtLists .= '' . $row['templatename'] . '
      '; - } - $caption = $row['caption'] != '' ? $row['caption'] : $row['name']; - $evtLists .= '
    • ' . $caption . ' [*' . $row['name'] . '*]
    • '; - } - $evtLists .= '
    '; + INNER JOIN {$tbl_site_templates} AS tm ON tr.templateid = tm.id", "tr.templateid='{$id}'", "tr.rank ASC, tv.rank ASC, tv.id ASC"); + +if ($modx->db->getRecordCount($rs)) { + $sortableList = '
    ' . $row['templatename'] . '
      '; + while ($row = $modx->db->getRow($rs)) { + $caption = $row['caption'] != '' ? $row['caption'] : $row['name']; + $sortableList .= '
    • ' . $caption . ' [*' . $row['name'] . '*]
    • '; + } + $sortableList .= '
    '; +} else { + $updateMsg = '

    ' . $_lang['tmplvars_novars'] . '

    '; } ?> - - -

    +

    + +

    -
    - -

    -

    - - -

    - - - - -
    - - -
    -
    +
    + + +

    +

    + + +

    + + + + +
    +
    + + +
    + diff --git a/manager/actions/mutate_tv_rank.dynamic.php b/manager/actions/mutate_tv_rank.dynamic.php index f93b8e157e..9fcbcc79ba 100644 --- a/manager/actions/mutate_tv_rank.dynamic.php +++ b/manager/actions/mutate_tv_rank.dynamic.php @@ -1,9 +1,9 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('save_template')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('save_template')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $reset = isset($_POST['reset']) && $_POST['reset'] == 'true' ? 1 : 0; @@ -14,199 +14,151 @@ $updateMsg = ''; -if(isset($_POST['listSubmitted'])) { - $updateMsg .= '' . $_lang['sort_updated'] . ''; - foreach($_POST as $listName => $listValue) { - if($listName == 'listSubmitted' || $listName == 'reset') { - continue; - } - $orderArray = explode(';', rtrim($listValue, ';')); - foreach($orderArray as $key => $item) { - if(strlen($item) == 0) { - continue; - } - $key = $reset ? 0 : $key; - $id = ltrim($item, 'item_'); - $modx->db->update(array('rank' => $key), $tbl_site_tmplvars, "id='{$id}'"); - } - } - // empty cache - $modx->clearCache('full'); +if (isset($_POST['listSubmitted'])) { + $updateMsg .= '' . $_lang['sort_updated'] . ''; + foreach ($_POST as $listName => $listValue) { + if ($listName == 'listSubmitted' || $listName == 'reset') { + continue; + } + $orderArray = explode(';', rtrim($listValue, ';')); + foreach ($orderArray as $key => $item) { + if (strlen($item) == 0) { + continue; + } + $key = $reset ? 0 : $key; + $id = ltrim($item, 'item_'); + $modx->db->update(array('rank' => $key), $tbl_site_tmplvars, "id='{$id}'"); + } + } + // empty cache + $modx->clearCache('full'); } $rs = $modx->db->select("name, caption, id, rank", $tbl_site_tmplvars, "", "rank ASC, id ASC"); -$limit = $modx->db->getRecordCount($rs); - -if($limit > 1) { - $tvsArr = array(); - while($row = $modx->db->getRow($rs)) { - $tvsArr[] = $row; - } - - $i = 0; - foreach($tvsArr as $row) { - if($i++ == 0) { - $evtLists .= '' . $row['templatename'] . '
      '; - } - $caption = $row['caption'] != '' ? $row['caption'] : $row['name']; - $evtLists .= '
    • ' . $caption . ' [*' . $row['name'] . '*]
    • '; - } - $evtLists .= '
    '; -} +if ($modx->db->getRecordCount($rs)) { + $sortableList = '
    ' . $row['templatename'] . '
      '; + while ($row = $modx->db->getRow($rs)) { + $caption = $row['caption'] != '' ? $row['caption'] : $row['name']; + $sortableList .= '
    • ' . $caption . ' [*' . $row['name'] . '*]
    • '; + } + $sortableList .= '
    '; +} else { + $updateMsg = '

    ' . $_lang['tmplvars_novars'] . '

    '; +} ?> - - -

    +

    + +

    -
    - -

    -

    - - -

    - - - - -
    - - -
    -
    +
    + + +

    +

    + + +

    + + + + +
    +
    + + +
    + diff --git a/manager/actions/phpinfo.static.php b/manager/actions/phpinfo.static.php index db596947ab..290a60c67b 100644 --- a/manager/actions/phpinfo.static.php +++ b/manager/actions/phpinfo.static.php @@ -1,27 +1,34 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} ?> - ', '
    ', $pinfo); $pinfo = str_replace('width="600"', 'width="90%"', $pinfo); $pinfo = str_replace('src,input', 'src, input', $pinfo); -echo $pinfo; -?> \ No newline at end of file +?> + diff --git a/manager/actions/refresh_site.dynamic.php b/manager/actions/refresh_site.dynamic.php index c2394e8f6b..008de9590f 100644 --- a/manager/actions/refresh_site.dynamic.php +++ b/manager/actions/refresh_site.dynamic.php @@ -16,18 +16,24 @@ ?> -

    +

    + +
    +
    + + + +
    +
    -
    -
    +
    +
    " . $_lang["refresh_published"] . "

    ", $num_rows_pub) ?> " . $_lang["refresh_unpublished"] . "

    ", $num_rows_unpub) ?> clearCache('full', true); - // invoke OnSiteRefresh event $modx->invokeEvent("OnSiteRefresh"); - ?>
    diff --git a/manager/actions/resource_selector.static.php b/manager/actions/resource_selector.static.php index 8e581ea9b5..a83143eab2 100644 --- a/manager/actions/resource_selector.static.php +++ b/manager/actions/resource_selector.static.php @@ -1,37 +1,13 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(!$modx->hasPermission('edit_module')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +if (!$modx->hasPermission('edit_module')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en'; -?> - -> - - <?php echo $content["name"] . " " . $_lang['element_selector_title']; ?> - - - " /> - - - - - - -db->escape($query); // select SQL -switch($rt) { - case "snip": - $title = $_lang["snippet"]; - $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_snippets"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); - break; - - case "tpl": - $title = $_lang["template"]; - $ds = $modx->db->select('id,templatename as name,description', $modx->getFullTableName("site_templates"), ($sqlQuery ? "(templatename LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'templatename'); - break; - - case("tv"): - $title = $_lang["tv"]; - $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_tmplvars"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); - break; - - case("chunk"): - $title = $_lang["chunk"]; - $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_htmlsnippets"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); - break; - - case("plug"): - $title = $_lang["plugin"]; - $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_plugins"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); - break; - - case("doc"): - $title = $_lang["resource"]; - $ds = $modx->db->select('id,pagetitle as name,longtitle as description', $modx->getFullTableName("site_content"), ($sqlQuery ? "(pagetitle LIKE '%{$sqlQuery}%') OR (longtitle LIKE '%{$sqlQuery}%')" : ""), 'pagetitle'); - break; +switch ($rt) { + case "snip": + $title = $_lang["snippet"]; + $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_snippets"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); + break; + + case "tpl": + $title = $_lang["template"]; + $ds = $modx->db->select('id,templatename as name,description', $modx->getFullTableName("site_templates"), ($sqlQuery ? "(templatename LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'templatename'); + break; + + case("tv"): + $title = $_lang["tv"]; + $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_tmplvars"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); + break; + + case("chunk"): + $title = $_lang["chunk"]; + $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_htmlsnippets"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); + break; + + case("plug"): + $title = $_lang["plugin"]; + $ds = $modx->db->select('id,name,description', $modx->getFullTableName("site_plugins"), ($sqlQuery ? "(name LIKE '%{$sqlQuery}%') OR (description LIKE '%{$sqlQuery}%')" : ""), 'name'); + break; + + case("doc"): + $title = $_lang["resource"]; + $ds = $modx->db->select('id,pagetitle as name,longtitle as description', $modx->getFullTableName("site_content"), ($sqlQuery ? "(pagetitle LIKE '%{$sqlQuery}%') OR (longtitle LIKE '%{$sqlQuery}%')" : ""), 'pagetitle'); + break; } +include_once MODX_MANAGER_PATH . "includes/header.inc.php"; ?> + +

    + +

    + +
    +
    + + +
    +
    + +
    +
    +
    +
    - - - - - - - - -
    -
    -

    -
    - - - - - - - - -
    - -
    - noRecordMsg = $_lang["no_records_found"]; - $grd->cssClass = "grid"; - $grd->columnHeaderClass = "gridHeader"; - $grd->itemClass = "gridItem"; - $grd->altItemClass = "gridAltItem"; - $grd->columns = $_lang["name"] . " ," . $_lang["description"]; - $grd->colTypes = "template: [+value+]"; - $grd->colWidths = "45%"; - $grd->fields = "name,description"; - if($_REQUEST['listmode'] == '1') { - $grd->pageSize = 0; - } - echo $grd->render(); - ?> -
    -
    + + + + + + + + + +
    +
    + +
    +
    + noRecordMsg = $_lang["no_records_found"]; + $grd->cssClass = "table data nowrap"; + $grd->columnHeaderClass = "tableHeader"; + $grd->itemClass = "tableItem"; + $grd->altItemClass = "tableAltItem"; + $grd->columns = $_lang["name"] . " ," . $_lang["description"]; + $grd->colTypes = "template: [+value+]"; + $grd->colWidths = "45%"; + $grd->fields = "name,description"; + if ($_REQUEST['listmode'] == '1') { + $grd->pageSize = 0; + } + echo $grd->render(); + ?> +
    +
    +
    +
    \ No newline at end of file diff --git a/manager/actions/resources/functions.inc.php b/manager/actions/resources/functions.inc.php index e433ebc5b7..b98807c31c 100644 --- a/manager/actions/resources/functions.inc.php +++ b/manager/actions/resources/functions.inc.php @@ -132,23 +132,36 @@ function prepareElementRowPh($row, $resourceTable, $resources) { $types = isset($resources->types[$resourceTable]) ? $resources->types[$resourceTable] : false; $class = ''; + $_lang["confirm_delete"] = $_lang["delete"]; + if($resourceTable == 'site_templates') { $class = $row['selectable'] ? '' : 'disabledPlugin'; $lockElementType = 1; + $_lang["confirm_delete"] = $_lang["confirm_delete_template"]; } if($resourceTable == 'site_tmplvars') { $class = $row['reltpl'] ? '' : 'disabledPlugin'; $lockElementType = 2; + $_lang["confirm_delete"] = $_lang["confirm_delete_tmplvars"]; } if($resourceTable == 'site_htmlsnippets') { + $class = $row['disabled'] ? 'disabledPlugin' : ''; $lockElementType = 3; + $_lang["confirm_delete"] = $_lang["confirm_delete_htmlsnippet"]; } if($resourceTable == 'site_snippets') { + $class = $row['disabled'] ? 'disabledPlugin' : ''; $lockElementType = 4; + $_lang["confirm_delete"] = $_lang["confirm_delete_snippet"]; } if($resourceTable == 'site_plugins') { $class = $row['disabled'] ? 'disabledPlugin' : ''; $lockElementType = 5; + $_lang["confirm_delete"] = $_lang["confirm_delete_plugin"]; + } + if($resourceTable == 'site_modules') { + $class = $row['disabled'] ? '' : 'disabledPlugin'; + $_lang["confirm_delete"] = $_lang["confirm_delete_module"]; } // Prepare displaying user-locks @@ -198,13 +211,13 @@ function prepareElementRowPh($row, $resourceTable, $resources) { /* row buttons */ $buttons = ''; if($modx->hasPermission($types['actions']['edit'][1])) { - $buttons .= '
  • '; + $buttons .= '
  • '; } if($modx->hasPermission($types['actions']['duplicate'][1])) { - $buttons .= '
  • '; + $buttons .= '
  • '; } if($modx->hasPermission($types['actions']['remove'][1])) { - $buttons .= '
  • '; + $buttons .= '
  • '; } $buttons = $buttons ? '
      ' . $buttons . '
    ' : ''; @@ -225,4 +238,3 @@ function prepareElementRowPh($row, $resourceTable, $resources) { 'textdir' => $modx_textdir ? '‏' : '', ); } - diff --git a/manager/actions/resources/mgrResources.class.php b/manager/actions/resources/mgrResources.class.php index 500a0eaec9..bcaa4ba56f 100644 --- a/manager/actions/resources/mgrResources.class.php +++ b/manager/actions/resources/mgrResources.class.php @@ -69,7 +69,7 @@ function hasAnyPermissions($permissions) { function queryResources($resourceTable, $nameField = 'name') { global $modx, $_lang; - $pluginsql = $resourceTable == 'site_plugins' ? $resourceTable . '.disabled, ' : ''; + $pluginsql = ($resourceTable == 'site_htmlsnippets' || $resourceTable == 'site_snippets' || $resourceTable == 'site_plugins' || $resourceTable == 'site_modules') ? $resourceTable . '.disabled, ' : ''; $tvsql = ''; $tvjoin = ''; @@ -80,22 +80,6 @@ function queryResources($resourceTable, $nameField = 'name') { } else $sttfield = ''; - //$orderby = $resourceTable == 'site_plugins' ? '6,2' : '5,1'; - - switch ($resourceTable) { - case 'site_plugins': - $orderby = '6,2'; - break; - case 'site_tmplvars': - $orderby = '7,3'; - break; - case 'site_templates': - $orderby = '6,1'; - break; - default: - $orderby = '5,1'; - } - $selectableTemplates = $resourceTable == 'site_templates' ? "{$resourceTable}.selectable, " : ""; $rs = $modx->db->select( @@ -103,7 +87,7 @@ function queryResources($resourceTable, $nameField = 'name') { $modx->getFullTableName($resourceTable) . " AS {$resourceTable} LEFT JOIN " . $modx->getFullTableName('categories') . " AS categories ON {$resourceTable}.category = categories.id {$tvjoin}", "", - $orderby + "category,name" ); $limit = $modx->db->getRecordCount($rs); diff --git a/manager/actions/resources/tab1_templates.inc.php b/manager/actions/resources/tab1_templates.inc.php index 26cecc20d0..d33561a715 100644 --- a/manager/actions/resources/tab1_templates.inc.php +++ b/manager/actions/resources/tab1_templates.inc.php @@ -1,34 +1,38 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(isset($resources->items['site_templates'])) { ?> -
    -

    - - +if (isset($resources->items['site_templates'])) { ?> +
    +

    + + -
      -
    • -
      - -
      -
    • -
    • ">
    • -
    • ">
    • - -
    +
    +
    +
    + +
    + "> + "> + +
    +
    +
    +
    - + - -
    + + + +
    \ No newline at end of file diff --git a/manager/actions/resources/tab2_templatevars.inc.php b/manager/actions/resources/tab2_templatevars.inc.php index b889f6bddf..0af5a39c34 100644 --- a/manager/actions/resources/tab2_templatevars.inc.php +++ b/manager/actions/resources/tab2_templatevars.inc.php @@ -1,39 +1,43 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(isset($resources->items['site_tmplvars'])) { ?> -
    -

    - - - +if (isset($resources->items['site_tmplvars'])) { ?> +
    +

    + + + -
      -
    • -
      - -
      -
    • -
    • ">
    • -
    • ">
    • -
    • ">
    • - -
    +
    +
    +
    + +
    + "> + "> + "> + +
    +
    +
    +
    - + - -
    + + + +
    \ No newline at end of file diff --git a/manager/actions/resources/tab3_chunks.inc.php b/manager/actions/resources/tab3_chunks.inc.php index 5e103a8d79..c2aceaa276 100644 --- a/manager/actions/resources/tab3_chunks.inc.php +++ b/manager/actions/resources/tab3_chunks.inc.php @@ -1,34 +1,39 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(isset($resources->items['site_htmlsnippets'])) { ?> -
    -

    - - +if (isset($resources->items['site_htmlsnippets'])) { ?> +
    +

    + -
      -
    • -
      - -
      -
    • -
    • ">
    • -
    • ">
    • - -
    + - +
    +
    +
    + +
    + "> + "> + +
    +
    +
    +
    - -
    + + + + + +
    \ No newline at end of file diff --git a/manager/actions/resources/tab4_snippets.inc.php b/manager/actions/resources/tab4_snippets.inc.php index bd89babf85..afee07b694 100644 --- a/manager/actions/resources/tab4_snippets.inc.php +++ b/manager/actions/resources/tab4_snippets.inc.php @@ -1,34 +1,39 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(isset($resources->items['site_snippets'])) { ?> -
    -

    - - +if (isset($resources->items['site_snippets'])) { ?> +
    +

    + -
      -
    • -
      - -
      -
    • -
    • ">
    • -
    • ">
    • - -
    + - +
    +
    +
    + +
    + "> + "> + +
    +
    +
    +
    - -
    + + + + + +
    \ No newline at end of file diff --git a/manager/actions/resources/tab5_plugins.inc.php b/manager/actions/resources/tab5_plugins.inc.php index 300174e770..1cc600a879 100644 --- a/manager/actions/resources/tab5_plugins.inc.php +++ b/manager/actions/resources/tab5_plugins.inc.php @@ -1,43 +1,52 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } -if(isset($resources->items['site_plugins'])) { ?> -
    -

    - - +if (isset($resources->items['site_plugins'])) { ?> +
    +

    + -
      -
    • -
      - -
      -
    • - hasPermission('new_plugin')) { ?> -
    • ">
    • - hasPermission('save_plugin')) { ?> -
    • ">
    • - hasPermission('delete_plugin') && $_SESSION['mgrRole'] == 1) { - $tbl_site_plugins = $modx->getFullTableName('site_plugins'); - if($modx->db->getRecordCount($modx->db->query("SELECT id FROM {$tbl_site_plugins} t1 WHERE disabled = 1 AND name IN (SELECT name FROM {$tbl_site_plugins} t2 WHERE t1.name = t2.name AND t1.id != t2.id)"))) { ?> -
    • - -
    • ">
    • - -
    + - +
    +
    +
    + +
    + hasPermission('new_plugin')) { ?> + "> + + hasPermission('save_plugin')) { ?> + "> + + hasPermission('delete_plugin') && $_SESSION['mgrRole'] == 1) { + $tbl_site_plugins = $modx->getFullTableName('site_plugins'); + if ($modx->db->getRecordCount($modx->db->query("SELECT id FROM {$tbl_site_plugins} t1 WHERE disabled = 1 AND name IN (SELECT name FROM {$tbl_site_plugins} t2 WHERE t1.name = t2.name AND t1.id != t2.id)"))) { ?> + + + "> + +
    +
    +
    +
    - -
    + + + + + +
    \ No newline at end of file diff --git a/manager/actions/resources/tab6_categoryview.inc.php b/manager/actions/resources/tab6_categoryview.inc.php index 56f30dd689..94b0601ae1 100644 --- a/manager/actions/resources/tab6_categoryview.inc.php +++ b/manager/actions/resources/tab6_categoryview.inc.php @@ -1,31 +1,36 @@ -INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); } ?>
    -

    - +

    + - -
      -
    • -
      - -
      -
    • -
    • ">
    • -
    • ">
    • - -
    + - +
    +
    +
    + +
    + "> + "> + +
    +
    +
    +
    - + + + + +
    \ No newline at end of file diff --git a/manager/actions/resources/tpl_viewForm.tpl b/manager/actions/resources/tpl_viewForm.tpl index e8f5788b1c..c19177fb5b 100644 --- a/manager/actions/resources/tpl_viewForm.tpl +++ b/manager/actions/resources/tpl_viewForm.tpl @@ -1,26 +1,24 @@ -
  • [%btn_view_options%]
  • -
    " . ($log_status['Data_free'] > 0 ? "" . $modx->nicesize($log_status['Data_free']) . "" : "-") . "" . ($log_status['Data_free'] > 0 ? $modx->nicesize($log_status['Data_free']) : "-") . "nicesize($log_status['Data_length'] - $log_status['Data_free']) ?>nicesize($log_status['Index_length']) ?>nicesize($log_status['Index_length'] + $log_status['Data_length'] + $log_status['Data_free']) ?>
      0 ? "" . $modx->nicesize($totaloverhead) . "
    (" . number_format($totaloverhead) . " B)" : "-" ?>
     " . $modx->nicesize($total) . "
    (" . number_format($total) . " B)" ?>
    + + + 0) { ?> +
    +

    + + diff --git a/manager/actions/user_management.static.php b/manager/actions/user_management.static.php index 1c0750cb5c..e2cbcfdaf1 100644 --- a/manager/actions/user_management.static.php +++ b/manager/actions/user_management.static.php @@ -39,7 +39,7 @@ function searchResource() { }; function resetSearch() { - document.resource.search.value = '' + document.resource.search.value = ''; document.resource.op.value = "reset"; document.resource.submit(); }; @@ -52,7 +52,7 @@ function changeListMode() { }; var selectedItem; - var contextm = getClientScriptObject(); ?>; + var contextm = getClientScriptObject() ?>; function showContentMenu(id, e) { selectedItem = id; @@ -70,88 +70,106 @@ function menuAction(a) { window.location.href = 'index.php?a=12&id=' + id; break; case 2: // delete - if(confirm("") === true) { + if(confirm("") === true) { window.location.href = 'index.php?a=33&id=' + id; } break; } } - document.addEvent('click', function() { + document.addEventListener('click', function() { contextm.style.visibility = "hidden"; }); + + document.addEventListener('DOMContentLoaded', function() { + var h1help = document.querySelector('h1 > .help'); + h1help.onclick = function() { + document.querySelector('.element-edit-message').classList.toggle('show') + } + }); +
    - - + +

    - +

    -
    -
    -

    - -
    - hasPermission('save_role')) { - $where .= (empty($where) ? "" : " AND ") . "mua.role != 1"; - } - if(!empty($sqlQuery)) { - $where .= (empty($where) ? "" : " AND ") . "((mu.username LIKE '{$sqlQuery}%') OR (mua.fullname LIKE '%{$sqlQuery}%') OR (mua.email LIKE '{$sqlQuery}%'))"; - } - $ds = $modx->db->select("mu.id, mu.username, rname.name AS role, mua.fullname, mua.email, ELT(mua.gender, '{$_lang['user_male']}', '{$_lang['user_female']}', '{$_lang['user_other']}') AS gender, IF(mua.blocked,'{$_lang['yes']}','-') as blocked, mua.thislogin", $modx->getFullTableName('manager_users') . " AS mu +
    +
    +
    + +
    +
    + +
    +
    + hasPermission('save_role')) { + $where .= (empty($where) ? "" : " AND ") . "mua.role != 1"; + } + if(!empty($sqlQuery)) { + $where .= (empty($where) ? "" : " AND ") . "((mu.username LIKE '{$sqlQuery}%') OR (mua.fullname LIKE '%{$sqlQuery}%') OR (mua.email LIKE '{$sqlQuery}%'))"; + } + $ds = $modx->db->select("mu.id, mu.username, rname.name AS role, mua.fullname, mua.email, ELT(mua.gender, '{$_lang['user_male']}', '{$_lang['user_female']}', '{$_lang['user_other']}') AS gender, IF(mua.blocked,'{$_lang['yes']}','-') as blocked, mua.thislogin", $modx->getFullTableName('manager_users') . " AS mu INNER JOIN " . $modx->getFullTableName('user_attributes') . " AS mua ON mua.internalKey=mu.id LEFT JOIN " . $modx->getFullTableName('user_roles') . " AS rname ON mua.role=rname.id", $where, 'mua.blocked ASC, mua.thislogin DESC'); - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; - $grd = new DataGrid('', $ds, $modx->config['number_of_results']); // set page size to 0 t show all items - $grd->noRecordMsg = $_lang["no_records_found"]; - $grd->cssClass = "grid"; - $grd->columnHeaderClass = "gridHeader"; - $grd->itemClass = "gridItem"; - $grd->altItemClass = "gridAltItem"; - $grd->fields = "id,username,fullname,role,email,gender,blocked,thislogin"; - $grd->columns = implode(',', array( - $_lang["icon"], - $_lang["name"], - $_lang["user_full_name"], - $_lang['role'], - $_lang["email"], - $_lang["user_gender"], - $_lang["user_block"], - $_lang["login_button"] - )); - $grd->colAligns = "center,,,,,center,center"; - $grd->colTypes = implode('||', array( - 'template:', - 'template:[+value+]', - 'template:[+fullname+]', - 'template:[+role+]', - 'template:[+email+]', - 'template:[+gender+]', - 'template:[+blocked+]', - 'date: ' . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . ' %H:%M' - )); - if($listmode == '1') { - $grd->pageSize = 0; - } - if($_REQUEST['op'] == 'reset') { - $grd->pageNumber = 1; - } - // render grid - echo $grd->render(); - ?> + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; + $grd = new DataGrid('', $ds, $modx->config['number_of_results']); // set page size to 0 t show all items + $grd->noRecordMsg = $_lang["no_records_found"]; + $grd->cssClass = "table data"; + $grd->columnHeaderClass = "tableHeader"; + $grd->itemClass = "tableItem"; + $grd->altItemClass = "tableAltItem"; + $grd->fields = "id,username,fullname,role,email,gender,blocked,thislogin"; + $grd->columns = implode(',', array( + $_lang["icon"], + $_lang["name"], + $_lang["user_full_name"], + $_lang['role'], + $_lang["email"], + $_lang["user_gender"], + $_lang["user_block"], + $_lang["login_button"] + )); + $grd->colWidths = "1%,,,,,,1%,1%"; + $grd->colAligns = "center,,,,,center,center,right' nowrap='nowrap"; + $grd->colTypes = implode('||', array( + 'template:', + 'template:[+value+]', + 'template:[+fullname+]', + 'template:[+role+]', + 'template:[+email+]', + 'template:[+gender+]', + 'template:[+blocked+]', + 'date: ' . $modx->toDateFormat('[+thislogin+]', 'formatOnly') . ' %H:%M' + )); + if($listmode == '1') { + $grd->pageSize = 0; + } + if($_REQUEST['op'] == 'reset') { + $grd->pageNumber = 1; + } + // render grid + echo $grd->render(); + ?> +
    diff --git a/manager/actions/web_access_permissions.dynamic.php b/manager/actions/web_access_permissions.dynamic.php index 928de1000f..d6cee74370 100644 --- a/manager/actions/web_access_permissions.dynamic.php +++ b/manager/actions/web_access_permissions.dynamic.php @@ -30,229 +30,250 @@ } ?> +

    - +

    -
    -

    ' . $_lang['access_permissions_off'] . '

    ' : ''; ?> - -
    - +
    ' . $_lang['access_permissions_off'] . '
    ' : '') ?>
    -
    -

    - - + - echo '

    ' . $_lang['access_permissions_users_tab'] . '

    '; +
    +

    + - ?> - - - - - - - - - -
    - - - -   - - -
    -
    +
    +

    +
    + +
    + + +
    + +
    + +
    +
    +
    +
    db->select('groupnames.*, users.id AS user_id, users.username user_name ', $modx->getFullTableName('webgroup_names') . " AS groupnames LEFT JOIN " . $modx->getFullTableName('web_groups') . " AS groups ON groups.webgroup = groupnames.id LEFT JOIN " . $modx->getFullTableName('web_users') . " AS users ON users.id = groups.webuser", '', 'groupnames.name, user_name'); if($modx->db->getRecordCount($rs) < 1) { - echo '' . $_lang['no_groups_found'] . ''; + ?> +
    + \n"; + ?> +
    + db->getRow($rs)) { - if($row['id'] !== $pid) { + if($pid != $row['id']) { if($pid != '') { - echo "\n"; - } // close previous one - - // display the current user group with a rename/delete form - echo '
  • ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . '  ' . "\n" . '  ' . "\n" . ' ' . "\n" . '
    '; - - echo "
      \n"; - echo "\t
    • " . $_lang['web_access_permissions_users_in_group'] . ' '; + echo '
  • '; + } + ?> +
    + + + +
    + +
    + + +
    +
    +
    + + ' . $_lang['access_permissions_no_users_in_group'] . ''; + ?> + + ' . $row['user_name'] . ''; + ?> + + \n"; - echo "\n"; - } - ?> + } + ?> +
    +
    +
    +

    + -
    -

    - - ' . $_lang['access_permissions_resources_tab'] . '

    '; - - ?> - - - - - - - - - -
    -
    - - -   - -
    -
    -
    +
    +

    +
    + +
    + + +
    + +
    + +
    +
    +
    +
    db->select('dgnames.id, dgnames.name, sc.id AS doc_id, sc.pagetitle AS doc_title', $modx->getFullTableName('documentgroup_names') . " AS dgnames LEFT JOIN " . $modx->getFullTableName('document_groups') . " AS dg ON dg.document_group = dgnames.id LEFT JOIN " . $modx->getFullTableName('site_content') . " AS sc ON sc.id = dg.document", '', 'dgnames.name, sc.id'); if($modx->db->getRecordCount($rs) < 1) { - echo '' . $_lang['no_groups_found'] . ''; + ?> +
    + ' . "\n" . '
    ' . $_lang['access_permissions_resource_groups'] . '
    ' . "\n" . ' ' . "\n" . ' ' . "\n" . ' ' . "\n" . '  ' . "\n" . ' ' . "\n" . ' ' . "\n" . '
    '; - - echo '
    ' . $_lang['access_permissions_resources_in_group'] . ' '; + echo '
    '; + } + ?> +
    + + + +
    + +
    + + +
    +
    +
    + + + + htmlspecialchars($row['doc_title']) . '">' . $row['doc_id'] . ''; + ?> + + "; - } - ?> + } + ?> +
    + -
    -

    - - ' . $_lang['access_permissions_links_tab'] . '

    '; +
    +

    + +
    +

    + db->select('groupnames.*, groupacc.id AS link_id, dgnames.id AS dg_id, dgnames.name AS dg_name', $modx->getFullTableName('webgroup_names') . " AS groupnames LEFT JOIN " . $modx->getFullTableName('webgroup_access') . " AS groupacc ON groupacc.webgroup = groupnames.id LEFT JOIN " . $modx->getFullTableName('documentgroup_names') . " AS dgnames ON dgnames.id = groupacc.documentgroup", '', 'name, dg_name'); if($modx->db->getRecordCount($rs) < 1) { - echo '' . $_lang['no_groups_found'] . '
    '; - } else { ?> - - - - - - - - - -
    -
    - - - - - - - -
    -
    -
    +
    \n"; - $pid = ''; - while($row = $modx->db->getRow($rs)) { - if($row['id'] != $pid) { - if($pid != '') { - echo "\n"; - } // close previous one - echo '
  • ' . $row['name'] . ''; - + } else { + ?> +
    + +
    + + + + + + + +
    +
    +
    +
      + db->getRow($rs)) { + if($row['id'] != $pid) { + if($pid != '') { + echo '
  • '; + } // close previous one + ?> +
  • + ' . $_lang['no_groups_found'] . ''; + $pid = ''; + continue; + } else { + echo '
      '; + } + } if(!$row['dg_id']) { - echo ' » ' . $_lang['no_groups_found'] . "\n"; - $pid = ''; continue; - } else { - echo ""; + ?> +
    +
    -
    +
    diff --git a/manager/actions/web_user_management.static.php b/manager/actions/web_user_management.static.php index d514eccabe..43a55b2862 100644 --- a/manager/actions/web_user_management.static.php +++ b/manager/actions/web_user_management.static.php @@ -39,7 +39,7 @@ function searchResource() { }; function resetSearch() { - document.resource.search.value = '' + document.resource.search.value = ''; document.resource.op.value = "reset"; document.resource.submit(); }; @@ -52,7 +52,8 @@ function changeListMode() { }; var selectedItem; - var contextm = getClientScriptObject(); ?>; + var contextm = getClientScriptObject() ?>; + function showContentMenu(id, e) { selectedItem = id; contextm.style.left = (e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft))) + "px"; @@ -69,64 +70,80 @@ function menuAction(a) { window.location.href = 'index.php?a=88&id=' + id; break; case 2: // delete - if(confirm("") === true) { + if(confirm("") === true) { window.location.href = 'index.php?a=90&id=' + id; } break; } } - document.addEvent('click', function() { + document.addEventListener('click', function() { contextm.style.visibility = "hidden"; }); + + document.addEventListener('DOMContentLoaded', function() { + var h1help = document.querySelector('h1 > .help'); + h1help.onclick = function() { + document.querySelector('.element-edit-message').classList.toggle('show') + } + }); +
    - - + +

    - +

    -
    -
    -

    - -
    - +
    +
    - $ds = $modx->db->select("wu.id, wu.username, wua.fullname, wua.email, ELT(wua.gender, '{$_lang['user_male']}', '{$_lang['user_female']}', '{$_lang['user_other']}') AS gender, IF(wua.blocked,'{$_lang['yes']}','-') as 'blocked'", $modx->getFullTableName("web_users") . " wu +
    +
    + +
    +
    + db->select("wu.id, wu.username, wua.fullname, wua.email, ELT(wua.gender, '{$_lang['user_male']}', '{$_lang['user_female']}', '{$_lang['user_other']}') AS gender, IF(wua.blocked,'{$_lang['yes']}','-') as 'blocked'", $modx->getFullTableName("web_users") . " wu INNER JOIN " . $modx->getFullTableName("web_user_attributes") . " wua ON wua.internalKey=wu.id", ($sqlQuery ? "(wu.username LIKE '{$sqlQuery}%') OR (wua.fullname LIKE '%{$sqlQuery}%') OR (wua.email LIKE '%{$sqlQuery}%')" : ""), 'username'); - include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; - $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items - $grd->noRecordMsg = $_lang["no_records_found"]; - $grd->cssClass = "grid"; - $grd->columnHeaderClass = "gridHeader"; - $grd->itemClass = "gridItem"; - $grd->altItemClass = "gridAltItem"; - $grd->fields = "id,username,fullname,email,gender,blocked"; - $grd->columns = $_lang["icon"] . " ," . $_lang["name"] . " ," . $_lang["user_full_name"] . " ," . $_lang["email"] . " ," . $_lang["user_gender"] . " ," . $_lang["user_block"]; - $grd->colWidths = "34,,,,40,34"; - $grd->colAligns = "center,,,,center,center"; - $grd->colTypes = "template:||template:[+value+]"; - if($listmode == '1') { - $grd->pageSize = 0; - } - if($_REQUEST['op'] == 'reset') { - $grd->pageNumber = 1; - } - // render grid - echo $grd->render(); - ?> + include_once MODX_MANAGER_PATH . "includes/controls/datagrid.class.php"; + $grd = new DataGrid('', $ds, $number_of_results); // set page size to 0 t show all items + $grd->noRecordMsg = $_lang["no_records_found"]; + $grd->cssClass = "table data"; + $grd->columnHeaderClass = "tableHeader"; + $grd->itemClass = "tableItem"; + $grd->altItemClass = "tableAltItem"; + $grd->fields = "id,username,fullname,email,gender,blocked"; + $grd->columns = $_lang["icon"] . " ," . $_lang["name"] . " ," . $_lang["user_full_name"] . " ," . $_lang["email"] . " ," . $_lang["user_gender"] . " ," . $_lang["user_block"]; + $grd->colWidths = "1%,,,,1%,1%"; + $grd->colAligns = "center,,,,center,right' nowrap='nowrap"; + $grd->colTypes = "template:||template:[+value+]"; + if($listmode == '1') { + $grd->pageSize = 0; + } + if($_REQUEST['op'] == 'reset') { + $grd->pageNumber = 1; + } + // render grid + echo $grd->render(); + ?> +
    diff --git a/manager/actions/welcome.static.php b/manager/actions/welcome.static.php index 4e26eef3ae..24e0178616 100644 --- a/manager/actions/welcome.static.php +++ b/manager/actions/welcome.static.php @@ -315,7 +315,8 @@
    -' + ', + 'hide'=>'0' ); $widgets['onlineinfo'] = array( 'menuindex' => '20', @@ -323,7 +324,8 @@ 'cols' => 'col-sm-6', 'icon' => 'fa-user', 'title' => '[%onlineusers_title%]', - 'body' => '
    [+OnlineInfo+]
    ' + 'body' => '
    [+OnlineInfo+]
    ', + 'hide'=>'0' ); $widgets['recentinfo'] = array( 'menuindex' => '30', @@ -331,31 +333,40 @@ 'cols' => 'col-sm-12', 'icon' => 'fa-pencil-square-o', 'title' => '[%activity_title%]', - 'body' => '
    [+RecentInfo+]
    ' -); -$widgets['news'] = array( - 'menuindex' => '40', - 'id' => 'news', - 'cols' => 'col-sm-6', - 'icon' => 'fa-rss', - 'title' => '[%modx_news_title%]', - 'body' => '
    [+modx_news_content+]
    ' -); -$widgets['security'] = array( - 'menuindex' => '50', - 'id' => 'security', - 'cols' => 'col-sm-6', - 'icon' => 'fa-exclamation-triangle', - 'title' => '[%security_notices_title%]', - 'body' => '
    [+modx_security_notices_content+]
    ' + 'body' => '
    [+RecentInfo+]
    ', + 'hide'=>'0' ); +if ($modx->config['rss_url_news']) { + $widgets['news'] = array( + 'menuindex' => '40', + 'id' => 'news', + 'cols' => 'col-sm-6', + 'icon' => 'fa-rss', + 'title' => '[%modx_news_title%]', + 'body' => '
    [+modx_news_content+]
    ', + 'hide'=>'0' + ); +} +if ($modx->config['rss_url_security']) { + $widgets['security'] = array( + 'menuindex' => '50', + 'id' => 'security', + 'cols' => 'col-sm-6', + 'icon' => 'fa-exclamation-triangle', + 'title' => '[%security_notices_title%]', + 'body' => '
    [+modx_security_notices_content+]
    ', + 'hide'=>'0' + ); +} // invoke OnManagerWelcomeHome event $sitewidgets = $modx->invokeEvent("OnManagerWelcomeHome", array('widgets' => $widgets)); if(is_array($sitewidgets)) { + $newwidgets = array(); foreach($sitewidgets as $widget){ - $widgets = array_merge($widgets, unserialize($widget)); + $newwidgets = array_merge($newwidgets, unserialize($widget)); } + $widgets = (count($newwidgets) > 0) ? $newwidgets : $widgets; } usort($widgets, function ($a, $b) { @@ -365,7 +376,9 @@ $tpl = getTplWidget(); $output = ''; foreach($widgets as $widget) { - $output .= $modx->parseText($tpl, $widget); + if ($widget['hide'] != '1'){ + $output .= $modx->parseText($tpl, $widget); + } } $ph['widgets'] = $output; @@ -606,4 +619,4 @@ function hideConfigCheckWarning(key) { '; return $script; -} +} \ No newline at end of file diff --git a/manager/frames/1.php b/manager/frames/1.php index c8ce43d857..4c7712d241 100644 --- a/manager/frames/1.php +++ b/manager/frames/1.php @@ -1,7 +1,7 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); + die("INCLUDE_ORDERING_ERROR

    Please use the EVO Content Manager instead of accessing this file directly."); } header("X-XSS-Protection: 0"); @@ -80,10 +80,8 @@ <?= $site_name ?>- (EVO CMS Manager) - - - - + + - -
    - - [+OnManagerLoginFormPrerender+] -
    -
    + +
    +
    + + [+OnManagerLoginFormPrerender+] + - - - - -

    [+login_captcha_message+]

    -

    [+captcha_image+]

    - [+captcha_input+] -
    -
    - + +
    +
    +

    +
    © 2005-2017 by the EVO. EVO™ is licensed under the GPL.
    +
    -

    -
    © 2005-2017 by the EVO. EVO™ is licensed under the GPL.
    - +
    - + + \ No newline at end of file diff --git a/manager/media/style/default/style.css b/manager/media/style/default/style.css index 1e9eb8b5d4..a33f13d084 100644 --- a/manager/media/style/default/style.css +++ b/manager/media/style/default/style.css @@ -1,60 +1,31 @@ @import "../common/bootstrap/css/bootstrap.min.css?v=4.0.0-alpha.5"; @import "../common/font-awesome/css/font-awesome.min.css?v=4.7.0"; -@import "css/fonts.css?v=1.3.0"; -@import "css/custom.css?v=1.3.0"; +@import "css/fonts.css?v=1.3.3"; +@import "css/forms.css?v=1.3.3"; +@import "css/custom.css?v=1.3.3"; @import "css/tabpane.css"; @import "css/contextmenu.css"; /* -------------------------[ Misc stuff ]--- */ -.sectionBody fieldset { background: none repeat scroll 0 0 #FDFDFD; border: 1px solid #CCCCCC; padding: 1rem !important; } -.sectionBody legend { font-weight: 500; padding: 5px 1rem; background: #fff; border: 1px solid #ccc; -moz-box-shadow: 1px 1px 3px #ccc; -webkit-box-shadow: 1px 1px 3px #ccc; box-shadow: 1px 1px 3px #ccc; -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } -.sectionBody fieldset h3 { font-size: 14px; color: #789; font-weight: 500; padding-bottom: 0; margin-bottom: 0; } -.sectionHeader, .showHideVisible { color: #333; margin: 0 1rem; padding: 5px 3px 5px; zoom: 1; font-weight: 500; text-shadow: 0 1px 0 #FFF; } -.sectionHeader + .sectionBody, .showHideVisible + .sectionBody { margin-top: -1px !important } -.tab-page .sectionHeader { margin: 1rem 3px 0; } -.sectionBody, .layerVisible { position: relative; } -.tab-page .sectionBody, .tab-page .section .sectionBody, .sectionBody .sectionBody { border-top: 1px solid #CCCCCC; margin: 0 3px 1rem; padding: 7px; } -.section .sectionBody { margin: 0 1rem 1rem; padding: 1rem; background-color: #fff; border: 1px solid #CCCCCC; } -.sectionBody > p:first-child { margin-left: 1rem; margin-right: 1rem } -.showHideVisible, .layerVisible { margin: 0 10px 4px; } .comment { font-size: 11px; color: #999; padding: 4px 0; } -thead, .fancyrow { color: #333; height: 18px !important; background-color: #E4E4E4; } -thead td { color: #333; border-top: 1px solid #fff; } -.fancyrow2 { height: 18px !important; background: #F0A62F repeat-x top; border-bottom: 1px solid #fff; color: #fff; } .screen { border: 1px solid #ddd; text-align: center; } -.even { background: #D9E7C2; } +.even { background: #d9e7c2; } .odd { background: #fff; } /* -------------------------[ end sortable table ]--- */ .disabledImage { width: 20px; opacity: 0.3; filter: alpha(opacity=30); } .disabledImage img { border: 0; } .editorCell { border-top: 1px solid #808080; text-align: left; vertical-align: baseline; } /* */ -.unpublished a, .unpublish { color: #B68282; font-style: italic; } +.unpublished a, .unpublish { color: #b68282; font-style: italic; } .notInMenuNode { color: #39515d; text-decoration: none; } #treeSplitter { width: 10px; height: 100%; position: absolute; right: -10px; } -.deleted { color: #A52A2A; text-decoration: line-through; } +.deleted { color: #a52a2a; text-decoration: line-through; } label.disabled { color: #aaa; } -/* -------------------------[ search bar ]--- */ -.searchbar { width: 100%; } -.searchbar table { margin-top: -3px; } -/*.searchtext { margin-top: -5px !important; height: 18px; padding: 2px; }*/ -.searchbutton { width: 22px; padding: 5px; text-decoration: none; background: #fff; border: 1px solid #D1D8DF; } -.searchbutton:hover { text-decoration: none; background: #fff; border: 1px solid #88939E; } -.searchbutton img { vertical-align: middle; margin: 0; padding: 0 } -.searchtoolbarbtn { text-decoration: none; border: 1px solid #D1D8DF; text-decoration: none !important; background: #fff; padding: 5px 5px 5px 2px; } -.searchtoolbarbtn img { vertical-align: middle; padding: 3px; } -.searchtoolbarbtn:hover { text-decoration: none; border: 1px solid #88939E; background: #fff; } /* -------------------------[ home page main links ]--- */ /*a.hometblink, a.hometblink:active, .hometblink { text-decoration: underline; color: #333; font-weight: 500; font-size: 12px; } a.hometblink:hover { text-decoration: underline; color: Gray; }*/ .notice { width: 100%; padding: 5px; border: 1px solid #eee; background-color: #f5f5f5; color: #707070; } /* -------------------------[ Settings Table ]--- */ -.filelist td { border-bottom: 1px solid #C2C3CF; } -/* -------------------------[ Tabs ]--- */ -.tab-page { clear: both; width: 100%; background-color: #fff; padding: 0; border: 0; border-radius: 0; box-shadow: 0 0 0.3rem 0 rgba(0, 0, 0, .1) } -.sectionBody > .tab-pane > .tab-page { padding: 1.3rem; } -.sectionHeader { padding: 7px 0px; } -.tab-page .sectionBody { padding: 12px 0px; } -.tab-page > table { width: 100%; border-collapse: collapse } +.filelist td { border-bottom: 1px solid #c2c3cf; } /* -------------------------[ Welcome Page ]--- */ /*#mainActionPages { background: #f5f5f5; }*/ /* -------------------------[ New sortable table class ]--- */ @@ -62,33 +33,16 @@ a.hometblink:hover { text-decoration: underline; color: Gray; }*/ .sortabletable thead tr { color: #333; font-weight: 500; white-space: nowrap; background-color: #d2d2d2; text-align: left; } .sortabletable tr { background: #fff; } .sortabletable tr.even { background: #f7f7f7; } -.sortabletable tbody tr:hover { background: #E9F0F3; } +.sortabletable tbody tr:hover { background: #e9f0f3; } .sortabletable td, .sortabletable th { padding: 5px !important; border: 1px solid #ccc; } .sortabletable th { text-align: left; cursor: pointer; color: #333; } .sortabletable th a { text-decoration: none; color: #333; } .sortabletable th:active { background: #ccc; padding: 3px 4px 1px 6px; } /* -------------------------[ Pagination table ]--- */ #max-display-records { margin: 10px 0; } -#pagination { margin: 10px 0; } -#pagination ul { margin: 10px 0; display: inline; } -#pagination li { list-style: none; display: inline; width: 1rem; margin: 0 0 0 1px; } -#pagination li a { padding: 3px 8px; border: 1px solid #D9E7C2; text-decoration: none; color: #333; } -#pagination li.currentPage a, #pagination li a:hover { color: #060; border: 1px solid #060; } fieldset.tab-page { border: 1px solid #e4e4e4 !important; } h2#edit_document_title { font-size: 0.9rem; color: #f5f5f5; width: 100%; border-bottom: none; padding: 5px 10px; } fieldset#preview h2.tab { float: right; } -/* -------------------------[ Action Buttons ]--- */ -.actionButtons { margin: 0; padding: 0; background: none; width: auto; white-space: nowrap; } -.actionButtons li { float: left; margin: 0; padding: 0; list-style: none; } -.actionButtons li:before, .mmTagList li:before, .rTable li:before, .tab-pane ul li ul li:before, .dashboard li:before, div#idShowHideSocialBox.sectionBody > div.btn-group.ope > ul.dropdown-menu > li:before, .sectionBody .multitv .list li:before { display: none; content: ''; } -.actionButtons img { vertical-align: top; margin-top: 1px; filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3; } -.actionButtons:hover img { filter: alpha(opacity=100); -moz-opacity: 1; opacity: 1; } -.actionButtons a:hover { border-color: #999; -moz-box-shadow: 1px 1px 2px #aaa; -webkit-box-shadow: 1px 1px 2px #aaa; box-shadow: 1px 1px 2px #aaa; -webkit-transition: all .3s ease; -moz-transition: all .3s ease; -o-transition: all .3s ease; transition: .3s ease; background: -moz-linear-gradient(#FFFFFF, #F5F5F5); background: -webkit-gradient(linear, 0 0, 0 100%, from(#FFFFFF), to(#F5F5F5)); background: -o-linear-gradient(#FFFFFF, #F5F5F5); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#F5F5F5); -zoom: 1; text-decoration: none !important; } -.actionButtons a:active { background: #92aac4 bottom left; -webkit-box-shadow: 0 0 10px #b8c7d6; -moz-box-shadow: 0 0 10px #b8c7d6; box-shadow: 0 0 10px #b8c7d6; } -/*.actionButtons li.primary a, .actionButtons a.primary, .actionButtons a.default { color: #fff; border-color: #658f1a; text-shadow: 0 -1px 0 #2B5F0C; background: #66901b; background: -moz-linear-gradient(#8aae4b, #66901b); background: -webkit-gradient(linear, 0 0, 0 100%, from(#8aae4b), to(#66901b)); background: -o-linear-gradient(#8aae4b, #66901b); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#8aae4b, endColorstr=#66901b); } -.actionButtons li.disabled a { color: #777; border: 0 solid #657587; pointer-events: none; } -.actionButtons li.disabled a img { opacity: .3; filter: alpha(opacity=30); }*/ /* * Generic styles for all form elements */ @@ -101,8 +55,9 @@ form#mutate .multitv input[type="text"] { width: 300px; } form#mutate .imageField { width: 50%; min-width: 300px; } form#mutate input[name="menuindex"] { text-align: center; width: 80px; padding-left: 0; padding-right: 0; } form#mutate input[name="ta"].inputBox { padding-left: 30px } -form#mutate input[name="ta"].inputBox + input[type=button], form#mutate input[name="ta"].inputBox + .CodeMirror + input[type=button] { position: relative; float: right; margin: -2.385em 0px 0 0; z-index: 5; border-radius: 0 .1rem .1rem 0 !important; } form#mutate input[name="ta"].inputBox:focus + input[type=button], form#mutate input[name="ta"].inputBox:focus + .CodeMirror + input[type=button] { border-color: #1377c5 #1377c5 #1377c5 #bbb; } +input[name^=tv].DatePicker, input[name*=date].DatePicker, input[name=createdon].DatePicker, input[name=editedon].DatePicker { float: left; width: auto; padding-right: 2em } +input[name^=tv].DatePicker + a, input[name*=date].DatePicker + a { position: relative; z-index: 5; margin-top: 0.5em; margin-left: -1.5em; float: left; } form#mutate textarea.tv_textareamini { height: 100px; width: 300px; overflow-y: scroll; } form#mutate textarea.tv_textarea { height: 100px; width: 100%; overflow-y: scroll; } form#mutate #llock { position: relative; z-index: 5; float: left; width: 1.9rem; height: 1.9rem; margin: 0 -2rem 0 0; line-height: 2rem; cursor: pointer; text-align: center; } @@ -110,55 +65,16 @@ form#mutate #llock + #ta { display: block !important; padding-left: 2rem } form#mutate #llock + #ta + .CodeMirror { display: none !important; } form#mutate #plock { width: 1.4em; cursor: pointer; font-size: 14px } /* -* Styling for datepicker elements in settings and templavars -*/ -form#mutate input.date, form#mutate input.tvdate { margin-right: 10px; } -/* -* Individual Styles for fieldset#settings_page_settings -*/ -form#mutate fieldset#settings_page_settings input#pub_date, form#mutate fieldset#settings_page_settings input#unpub_date { width: 150px; } -form#mutate fieldset#settings_page_settings select { width: 155px; } -/* -* Individual Styles for fieldset#meta_keywords -*/ -form#mutate fieldset#meta_keywords select.inputBox { display: block; margin-bottom: 0; } -form#mutate fieldset#meta_keywords dl.keywords { float: left; margin-right: 30px; } -form#mutate fieldset#meta_keywords dl.metatags { float: left; } -form#mutate fieldset#meta_keywords dl dt label { width: 100px; } -form#mutate fieldset#meta_keywords dl dd { margin-left: 110px; } -/* * Individual Styles for fieldset#preview */ fieldset#preview iframe { width: 100%; margin: 0 auto; border: 1px solid #f5f5f5; } /* -* Individual Styles for fieldset#document_content -*/ -fieldset#document_content textarea#ta { width: 100%; height: 400px; font-size: 1em; } -/* * Individual Styles for fieldset#access_permissions */ fieldset#access_permissions dt label { width: 200px; } fieldset#access_permissions dd { margin-left: 210px; } fieldset#access_permissions dl dd ul li { list-style-type: none; } /* ppb: -* fieldset#settings_templvars -*/ -fieldset#settings_templvars .tv_url_select { width: 70px; margin-right: 10px; } -fieldset#settings_templvars .tv_url_input { width: 220px; } -fieldset#settings_templvars dd.tvCheckBox label input, fieldset#settings_templvars dd.tvRadioOptions label input { margin-right: 10px; } -fieldset#settings_templvars .tv_date { width: 150px; } -form#mutate select.tv_url_select { padding: 5px 3px; } -/* ppb: -* Style mootools tooltips -*/ -[data-tooltip] { cursor: help } -[data-tooltip]::after, .custom-tip { position: absolute; z-index: 13000; width: 13rem; margin-left: 1rem; padding: 0.9rem 1rem; font-size: 0.75rem; line-height: 1.5; font-family: sans-serif; text-align: left; color: #333; background-color: #fff; border: 1px solid #ccc; visibility: hidden; transition-duration: .3s; transform: translate3d(1rem, 0, 0); } -[data-tooltip]::after { opacity: 0; content: attr(data-tooltip); } -[data-tooltip]:hover::after { opacity: 1; visibility: visible; transform: translate3d(0, 0, 0); } -[data-tooltip].fa-question-circle { opacity: 0.15; } -[data-tooltip].fa-question-circle:hover { opacity: 1; } -th > [data-tooltip].fa-question-circle, td > [data-tooltip].fa-question-circle { float: right; } -/* ppb: * Some styling for legacy mode fieldsets */ fieldset.legacy { background: #fff; padding: 10px; margin: 10px 10px 35px; border: 1px solid #e4e4e4 !important; position: relative; } @@ -173,10 +89,6 @@ fieldset.legacy h2 { width: 100%; background: #f5f5f5; margin: -10px -10px 1rem .phptextarea { font-family: Consolas, 'Courier New', 'Courier', monospace; } /* Custom */ /* normalize some td paddings */ -#tabTemplate tbody td, .sectionBody td, .sectionBody th { padding: 1px 5px; text-align: left; vertical-align: top; } -.sectionBody .displayparams, .sectionBody .permissiongroup { margin-bottom: 0.15rem; background-color: #eee; border-collapse: separate; border-spacing: 1px; } -.sectionBody .displayparams th, .sectionBody .displayparams td { padding: 4px 4px; } -.sectionBody .displayparams thead td, .sectionBody .permissiongroup thead td { border-top: none; } #displayparams table { background: #fff; } #displayparams table tbody td { border-bottom: 1px dotted #d3d3d3; } .permissiongroups { margin: 0; } @@ -186,36 +98,25 @@ td#displayparams > table.displayparams { border: none; } /* replace warning red color in tabs */ strong[style*='color:#EF1D1D'] { color: yellow !important; } .selected strong[style*='color:#ffeb00'] { color: red !important; } -#tabEvents table, #tabEvents td { padding: 2px; } code { font-size: inherit; font-family: Consolas, 'Courier New', 'Courier', monospace; background-color: #eee; border: 1px solid #ccc; padding: 1px 2px; } #resourcesPane .disabledPlugin a:hover { color: #aaa; } -/* breadcrumbs */ -ul.breadcrumbs { margin: 0 1rem 12px 1rem; padding: 0 0 9px 0; line-height: normal; font-size: 0; border-bottom: 1px dotted #CECACA; } -li.breadcrumbs__li { list-style: none; display: inline-block; padding: 0; margin: 0; } -a.breadcrumbs__a { font-size: 12px; text-decoration: none; } -.breadcrumbs__sep { font-size: 13px; margin: 0 6px; color: #777; } -li.breadcrumbs__li_current { font-size: 12px; font-weight: 500; } -/* end breadcrumbs */ /* table styles*/ -.table, #documentPane #tv_body table, #documentPane [id*="table-"], #documentPane [id*="table-tv"] { width: 100%; } +.table, #documentPane #tv_body table, #documentPane .tmplvars table, #documentPane [id*="table-"], #documentPane [id*="table-tv"] { width: 100%; } #documentPane .tab-page > table > tr > td:first-child, #documentPane .tab-page > table > tbody > tr > td:first-child, #documentPane .tab-page .tmplvars > table > tbody > tr > td:first-child, #tmplvarsPane .tab-page > table > tbody > tr > td:first-child, #tmplvarsPane .tab-page > table > tbody > tr > th:first-child, #chunkPane .tab-page > table > tbody > tr > td:first-child, #chunkPane .tab-page > table > tbody > tr > th:first-child, #snipetPane .tab-page > table > tbody > tr > td:first-child, #snipetPane .tab-page > table > tbody > tr > th:first-child, #pluginPane .tab-page > table > tbody > tr > td:first-child, #pluginPane .tab-page > table > tbody > tr > th:first-child, #modulePane .tab-page > table > tbody > tr > td:first-child, #modulePane .tab-page > table > tbody > tr > th:first-child, #docManagerPane .tab-page #dates > table > tbody > tr > td:first-child { width: 200px } #documentPane .tab-page > table > tr > td:last-child, #documentPane .tab-page .tmplvars > table > tbody > tr > td:last-child { width: inherit !important } #documentPane .tab-page > table > tbody > tr > td:first-child > .warning { display: inline-block; width: calc(100% - 1rem); } -#documentPane .tab-page > table > tbody > tr > td:first-child > [data-tooltip].fa-question-circle { margin-top: 0.3rem; } +#documentPane .tab-page > table > tbody > tr > td:first-child > [data-tooltip] { margin-top: 0.3rem; vertical-align: top } .table--edit { margin-bottom: 1rem; } .table th, .table td { text-align: left; vertical-align: middle; } table th { font-weight: 500; } .table--edit th { width: 200px; color: #555; font-size: inherit; } .table--edit input[type="text"], .table--edit input[type="password"], .table--edit input[type="number"], .table--edit textarea, .table--edit select, .settings input[type="text"], .settings input[type="password"], .settings input[type="number"], .settings textarea, .settings select { width: 300px; } -.table th, .table td, .sectionBody td, .sectionBody th { padding: 0.15rem 0.25rem; } -.table tr:first-child > th, .table tr:first-child > td, .sectionBody tr:first-child > td, .sectionBody tr:first-child > th { /*border-top: none*/ } /* * MODxRE2 styles * css above is original MODxRE * css below is basicaly MODxRE overrides to get MODxRE2 look */ /* nav */ -.alert-warning { color: #1377c5; } .no-events { pointer-events: none; } /* Required for Bootstrap3 Collapse */ .panel-title > a::before { content: "\f107"; /* fa-angle-down */ font-family: "FontAwesome"; } @@ -248,15 +149,15 @@ div#tabCategory.tab-page ul li ul li { padding-top: 7px; padding-bottom: 7px; } .btnCell { width: 6em; text-align: right; padding-right: 1rem; } .mainCell > span { display: block } /* Manage elements general styles */ -a.man_el_name { display: block; padding: .1em 0 .1em 1.3rem; } +a.man_el_name { display: block; padding: .1em 0 .1em 1.25rem; } a.man_el_name:hover { text-decoration: none; } .lockCell + .mainCell a.man_el_name { padding-left: 0 !important; } .lockCell + .mainCell a.man_el_name:before { display: none; } .elements_descr { color: #222; margin-left: 1em; font-size: 0.88em; } -.resourceTable .panel-heading { margin: 0 -1.3rem !important; background-color: #f5f5f5; border-top: 1px dotted #dedede; border-bottom: 1px dotted #dedede; } -.resourceTable .panel-title > a { padding: 5px 1.3rem; text-decoration: none } -.resourceTable ul.elements { margin: 0 -1.3rem; padding: 0 0 10px 0; } -.resourceTable ul.elements > li { padding: 0 !important; border-bottom: 1px dotted #dedede; border-left: 3px solid #FFF; transition: all 0.1s ease; margin: 0 !important; } +.resourceTable .panel-heading { margin: 0 -1.25rem !important; background-color: #f5f5f5; border-top: 1px dotted #dedede; border-bottom: 1px dotted #dedede; } +.resourceTable .panel-title > a { padding: 5px 1.25rem; text-decoration: none } +.resourceTable ul.elements { margin: 0 -1.25rem; padding: 0 0 10px 0; } +.resourceTable ul.elements > li { padding: 0 !important; border-bottom: 1px dotted #dedede; border-left: 3px solid #fff; transition: all 0.1s ease; margin: 0 !important; } .resourceTable ul.elements > li:hover { background: #f9f9f9; border-left: 3px solid #1377c5; } .resourceTable ul.elements > li::before { display: none } #resourcesPane .panel-group ul { } @@ -266,22 +167,6 @@ ul.elements_buttonbar { list-style: none; margin: 0; padding: 0; display: table; ul.elements_buttonbar li { display: table-cell; padding: 0 !important; width: 2em; } ul.elements_buttonbar li a { display: block; width: 2em; padding: 4px 2px 2px 2px; margin: 1px; min-width: 22px; } ul.elements_buttonbar .fa { font-size: 0.875rem; padding: 1px 1px 0; } -/* Manage elements views-form */ -.switchForm { display: block; width: 100%; float: left; clear: left; margin: 7px 0 7px -4px; padding: 5px; background-color: #fff; border: 1px solid #E4E4E4; border-radius: 3px; } -.switchForm h3.optionsTitle { color: #1377c5; padding-left: 7px; font-size: 16px; } -.switchForm label { color: #1377c5; font-weight: 700; } -.switchForm input.columns { width: 3em; color: #444; font-weight: normal; } -.switchForm input.fontsize { width: 4em; color: #444; font-weight: normal; } -.switchForm .cb_all { float: left; } -.switchForm .btn_reset { float: right; } -.switchForm .optionsLeft { float: left; padding: 4px 8px 4px 4px; } -.switchForm .optionsFull { display: block; clear: both; padding: 4px 8px 4px 4px; } -.switchForm .optionsRadios { padding-top: 6px; } -.switchForm .optionsChecks { padding-top: 10px; } -.switchForm .optionsFontsSize { margin-left: 9px; padding-left: 8px; border-left: 1px solid #ededed; } -.switchForm .optionsReset { margin-left: 8px; border-left: 1px solid #ededed; padding-left: 8px; } -.switchForm .optionsAllTabs { clear: left; padding-top: 10px; } -.switchForm .optionsClear { display: block; clear: both; padding-top: 8px; margin-bottom: 4px; border-bottom: 1px solid #ededed; } /* Checkbox "Icons" */ .noicons.tab-page ul li ul li a:before, .noicons .elements_description a:before { display: none !important; } /* View-dependent styles */ @@ -299,67 +184,17 @@ ul.elements_buttonbar .fa { font-size: 0.875rem; padding: 1px 1px 0; } .resourceTable.flex ul.elements { } .resourceTable.flex ul.elements > li { overflow: hidden; /* fix for Firefox */ break-inside: avoid-column; -webkit-column-break-inside: avoid; -moz-column-break-inside: avoid; -o-column-break-inside: avoid; -ms-column-break-inside: avoid; column-break-inside: avoid; page-break-inside: avoid } .resourceTable.flex .elements_descr { display: block; margin-left: 1.5em; } -/* action buttons */ -.actionButtons a { float: left; padding: 5px 10px; height: 32px; font-size: 13px; font-weight: 500; } -.actionButtons a, .actionButtons li.primary a, .actionButtons a.primary, .actionButtons a.default { text-shadow: none; background: #fff; color: #555; border: 1px solid #E4E4E4; border-radius: 3px; /*box-shadow: 0 0 0 1px #E4E4E4;*/ box-shadow: none; transition: none; } -.actionButtons a:hover { background: #1377c5; box-shadow: none; border-color: #1377c5; color: #FFF !important; transition: none; } -.actionButtons a:active { background-color: #3189ba; border-color: #3189ba; } -.actionButtons li.primary a, .actionButtons a.primary { color: #fff; border-color: #32AB9A; background: #32AB9A linear-gradient(#32AB9A, #00948E); } -.actionButtons li.primary a:hover, .actionButtons a.primary:hover { background: #2b9385 linear-gradient(#2b9385, #007571); border-color: #2b9385; } -.actionButtons li.primary a:active, .actionButtons a.primary:active { background: #32AB9A; border-color: #32AB9A; } -.actionButtons img { display: none; } -#treePane .actionButtons img { display: inline; } -.actionButtons--tableheader .fa { font-size: 14px; } -.sectionBody .actionButtons { padding-top: 0; min-height: 40px; } -.sectionBody .actionButtons li { margin-right: 10px; } -.sectionBody .actionButtons a { display: inline-block; padding: 9px 10px; line-height: 1; } -#range input#pids { width: 100% !important; } -#range input#pids + input[name=fsubmit] { margin-top: 0.5rem; } -#range::after { content: ""; display: table; width: 100% } #content_body #which_editor { margin-top: 12px; } /* resource children list */ #tabChildren .grid th, #tabChildren .grid tr > td:nth-child(5), #tabChildren .grid tr > td:nth-child(6) { text-align: center; white-space: nowrap } #tabChildren .grid td { text-align: right; white-space: nowrap } #tabChildren .grid tr > th:nth-child(2), #tabChildren .grid tr > td:nth-child(2) { text-align: left; white-space: normal } #tabChildren .grid tr > td:nth-child(6) a { padding: 0 .2em; font-size: 0.9rem; color: #444; } -table.actionButtons { margin-top: 1rem; margin-bottom: 10px; } -table.actionButtons img { display: inline-block; } -table.actionButtons .searchtext { padding: 5px; height: 24px; width: 150px; } -/* backup */ -#tabBackup p.actionButtons { margin-top: 20px; margin-bottom: 1rem; } -/* filter elements */ -.filterElements-form { margin-bottom: 10px; margin-top: 5px; } -.actionButtons .filterElements-form { margin-top: 0; margin-bottom: 0; } -.filterElements-form .form-control { display: block; width: 100%; max-width: 500px; font-size: 13px; } -.actionButtons .filterElements-form .form-control { width: 200px; height: 33px; padding-left: 8px; box-sizing: border-box; } -/* pagetitle-icon */ -.pagetitle-icon { margin-right: 2px; color: #1377c5; } /* element-edit-message */ .msg-container { padding-bottom: 10px; border-bottom: 1px solid #ededed; margin-bottom: 1rem; color: #777; } .btn-small { padding: 2px 4px !important; font-size: 11px !important; } .relative { position: relative; } .modx-alert { display: block; margin: 60px 10px 10px 10px; padding: 1em; } -.modx-alert.alert-error { background-color: #ffd0d0; border: 1px solid #ff0000; color: #000; } +.modx-alert.alert-error { background-color: #ffd0d0; border: 1px solid #f00; color: #000; } tr.userIdle td { color: #aaa; } tr.userIdle td strong:before { font-family: "FontAwesome"; font-style: normal; font-weight: normal; color: #aaa; padding: 0 5px 0 0; content: '\f017'; } -#modxonline_widget td strong:before { font-family: "FontAwesome"; font-style: normal; font-weight: normal; color: #3d5764; padding: 0 5px 0 0; content: '\f2be'; } -#modxonline_widget td strong.userMultipleSessions:before { color: #bf4949; content: '\f2bd'; } -#modxonline_widget tr.userIdle td strong.userMultipleSessions:before { color: #bf4949; content: '\f017'; } -/* c-roleslist */ -.c-roleslist { margin-bottom: 10px; margin-left: 12px; } -.c-roleslist-name { display: block; font-size: 13px; font-weight: 500; } -.c-roleslist-hyphen { display: none; } -.c-roleslist-description { color: #666; } -.c-roleslist-item { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px dashed #ddd; } -.c-roleslist-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom-width: 0; } -.c-roleslist-item--admin { font-style: italic; } -/*responsive buttons*/ -.actionButtons .fa { display: none; text-align: center; font-size: 1em; line-height: 1em; width: 1.1em; vertical-align: initial } -.sectionBody .actionButtons .fa, .actionButtons--eit .fa { display: inline-block; } -.optionsTitle .fa { display: inline-block; } -@media (max-width: 900px) { -.actionButtons a { display: inline-block; padding: 6px 10px } -.tab-page .actionButtons a { margin-top: 0 !important } -.actionButtons a span { display: none; } -.actionButtons a .fa { display: inline-block; } -} \ No newline at end of file diff --git a/manager/media/style/default/style.php b/manager/media/style/default/style.php index 2d541dfc07..63dfd2ef13 100644 --- a/manager/media/style/default/style.php +++ b/manager/media/style/default/style.php @@ -20,7 +20,7 @@ } // Favicon -$_style['favicon'] = (file_exists(MODX_BASE_PATH . '/favicon.ico') ? MODX_SITE_URL . 'favicon.ico' : 'media/style/' . $modx->config['manager_theme'] . '/images/favicon.ico'); +$_style['favicon'] = (file_exists(MODX_BASE_PATH . 'favicon.ico') ? MODX_SITE_URL . 'favicon.ico' : 'media/style/' . $modx->config['manager_theme'] . '/images/favicon.ico'); // Tree Menu Toolbar $_style['add_doc_tree'] = ''; @@ -174,6 +174,7 @@ $_style['actions_error'] = 'fa fa-times-circle'; $_style['actions_info'] = 'fa fa-info-circle'; $_style['actions_triangle'] = 'fa fa-exclamation-triangle'; +$_style['actions_table'] = 'fa fa-table'; //for back compatibility @@ -389,15 +390,13 @@ ' : '') . ' ', - 'newmodule' => '
    + 'newmodule' => ($addnew ? '
    - ' . ($addnew ? ' ' . $_lang['new_module'] . ' - ' : '') . '
    -
    ', +
    ' : ''), 'close' => '
    diff --git a/manager/processors/cache_sync.class.processor.php b/manager/processors/cache_sync.class.processor.php index 17fa6e9c1c..0097ecd39e 100644 --- a/manager/processors/cache_sync.class.processor.php +++ b/manager/processors/cache_sync.class.processor.php @@ -9,9 +9,13 @@ class synccache var $aliases = array(); var $parents = array(); var $aliasVisible = array(); + var $request_time; function __construct() { + global $modx; + + $this->request_time = $_SERVER['REQUEST_TIME']+$modx->config['server_offset_time']; } function setCachepath($path) @@ -43,7 +47,7 @@ function getParents($id, $path = '') { // modx:returns child's parent global $modx; if (empty($this->aliases)) { - $qh = $modx->db->select('id, IF(alias=\'\', id, alias) AS alias, parent, alias_visible', $modx->getFullTableName('site_content')); + $qh = $modx->db->select('id, IF(alias=\'\', id, alias) AS alias, parent, alias_visible', '[+prefix+]site_content'); while ($row = $modx->db->getRow($qh)) { $this->aliases[$row['id']] = $row['alias']; $this->parents[$row['id']] = $row['parent']; @@ -103,7 +107,6 @@ function emptyCache($modx = null) public function publishTimeConfig($cacheRefreshTime='') { - $cacheRefreshTimeFromDB = $this->getCacheRefreshTime(); if(!preg_match('@^[0-9]+$]@',$cacheRefreshTime) || $cacheRefreshTimeFromDB < $cacheRefreshTime) $cacheRefreshTime = $cacheRefreshTimeFromDB; @@ -112,7 +115,7 @@ public function publishTimeConfig($cacheRefreshTime='') // write the file $content = array(); $content[] = 'request_time); $content[] = sprintf('$cacheRefreshTime = %s;', $cacheRefreshTime); $filename = $this->cachePath.'/sitePublishing.idx.php'; @@ -134,16 +137,15 @@ public function getCacheRefreshTime() // update publish time file $timesArr = array(); - $current_time = $_SERVER['REQUEST_TIME'] + $modx->config['server_offset_time']; - $result = $modx->db->select('MIN(pub_date) AS minpub', $modx->getFullTableName('site_content'), 'pub_date>'.$current_time); + $result = $modx->db->select('MIN(pub_date) AS minpub', '[+prefix+]site_content', 'pub_date>'.$this->request_time); if(!$result) echo "Couldn't determine next publish event!"; $minpub = $modx->db->getValue($result); if($minpub!=NULL) $timesArr[] = $minpub; - $result = $modx->db->select('MIN(unpub_date) AS minunpub', $modx->getFullTableName('site_content'), 'unpub_date>'.$current_time); + $result = $modx->db->select('MIN(unpub_date) AS minunpub', '[+prefix+]site_content', 'unpub_date>'.$this->request_time); if(!$result) echo "Couldn't determine next unpublish event!"; $minunpub = $modx->db->getValue($result); @@ -219,7 +221,7 @@ public function buildCache($modx) { $tmpPHP .= '$c = &$this->chunkCache;'; while ($tmp1 = $modx->db->getRow($rs)) { /** without trim */ - $tmpPHP .= '$c[\'' . $this->escapeSingleQuotes($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['snippet']) . "';"; + $tmpPHP .= '$c[\'' . $this->escapeSingleQuotes($tmp1['name']) . '\']' . " = '" . $this->escapeSingleQuotes($tmp1['disabled'] ? '' : $tmp1['snippet']) . "';"; } // WRITE snippets to cache file @@ -229,20 +231,25 @@ public function buildCache($modx) { ); $tmpPHP .= '$s=&$this->snippetCache;'; while ($row = $modx->db->getRow($rs)) { - $name = $this->escapeSingleQuotes($row['name']); - $code = trim($row['snippet']); - if($modx->config['minifyphp_incache']) - $code = $this->php_strip_whitespace($code); - $code = $this->escapeSingleQuotes($code); - $properties = $modx->parseProperties($row['properties']); - $sharedproperties = $modx->parseProperties($row['sharedproperties']); - $properties = array_merge($sharedproperties,$properties); - $tmpPHP .= sprintf("\$s['%s']='%s';", $name, $code); - if (0escapeSingleQuotes($properties); - $tmpPHP .= sprintf("\$s['%sProps']='%s';", $name, $properties); - } + $name = $this->escapeSingleQuotes($row['name']); + if($row['disabled']) { + $tmpPHP .= sprintf("\$s['%s']='%s';", $name, "return false;"); + $tmpPHP .= sprintf("\$s['%sProps']='%s';", $name, ''); + } else { + $code = trim($row['snippet']); + if($modx->config['minifyphp_incache']) + $code = $this->php_strip_whitespace($code); + $code = $this->escapeSingleQuotes($code); + $properties = $modx->parseProperties($row['properties']); + $sharedproperties = $modx->parseProperties($row['sharedproperties']); + $properties = array_merge($sharedproperties,$properties); + $tmpPHP .= sprintf("\$s['%s']='%s';", $name, $code); + if (0escapeSingleQuotes($properties); + $tmpPHP .= sprintf("\$s['%sProps']='%s';", $name, $properties); + } + } } // WRITE plugins to cache file diff --git a/manager/processors/duplicate_content.processor.php b/manager/processors/duplicate_content.processor.php index 5dc23f8ca4..718e06527c 100755 --- a/manager/processors/duplicate_content.processor.php +++ b/manager/processors/duplicate_content.processor.php @@ -54,12 +54,28 @@ function duplicateDocument($docid, $parent=null, $_toplevel=0) { $rs = $modx->db->select('*', $tblsc, "id='{$docid}'"); $content = $modx->db->getRow($rs); - unset($content['id']); // remove the current id. + // Handle incremental ID + switch($modx->config['docid_incrmnt_method']) + { + case '1': + $from = "{$tblsc} AS T0 LEFT JOIN {$tblsc} AS T1 ON T0.id + 1 = T1.id"; + $rs = $modx->db->select('MIN(T0.id)+1', $from, "T1.id IS NULL"); + $content['id'] = $modx->db->getValue($rs); + break; + case '2': + $rs = $modx->db->select('MAX(id)+1',$tblsc); + $content['id'] = $modx->db->getValue($rs); + break; + + default: + unset($content['id']); // remove the current id. + } // Once we've grabbed the document object, start doing some modifications if ($_toplevel == 0) { // count duplicates $pagetitle = $modx->db->getValue($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "id='{$docid}'")); + $pagetitle = $modx->db->escape($pagetitle); $count = $modx->db->getRecordCount($modx->db->select('pagetitle', $modx->getFullTableName('site_content'), "pagetitle LIKE '{$pagetitle} Duplicate%'")); if($count>=1) $count = ' '.($count+1); else $count = ''; @@ -98,8 +114,7 @@ function duplicateDocument($docid, $parent=null, $_toplevel=0) { // Duplicate the Document $newparent = $modx->db->insert($content, $tblsc); - // duplicate document's TVs & Keywords - duplicateKeywords($docid, $newparent); + // duplicate document's TVs duplicateTVs($docid, $newparent); duplicateAccess($docid, $newparent); @@ -119,18 +134,6 @@ function duplicateDocument($docid, $parent=null, $_toplevel=0) { return $newparent; } -// Duplicate Keywords -function duplicateKeywords($oldid,$newid){ - global $modx; - - $tblkw = $modx->getFullTableName('keyword_xref'); - - $modx->db->insert( - array('content_id'=>'', 'keyword_id'=>''), $tblkw, // Insert into - "{$newid}, keyword_id", $tblkw, "content_id='{$oldid}'" // Copy from - ); -} - // Duplicate Document TVs function duplicateTVs($oldid,$newid){ global $modx; diff --git a/manager/processors/execute_module.processor.php b/manager/processors/execute_module.processor.php index 79cf911237..248f6ec740 100644 --- a/manager/processors/execute_module.processor.php +++ b/manager/processors/execute_module.processor.php @@ -64,7 +64,6 @@ // evalModule function evalModule($moduleCode,$params){ global $modx; - $etomite = &$modx; $modx->event->params = &$params; // store params inside event object if(is_array($params)) { extract($params, EXTR_SKIP); diff --git a/manager/processors/login.processor.php b/manager/processors/login.processor.php index aa1106ea18..fc540c2dfa 100755 --- a/manager/processors/login.processor.php +++ b/manager/processors/login.processor.php @@ -1,17 +1,18 @@ loadExtension('ManagerAPI'); $modx->loadExtension('phpass'); $modx->getSettings(); -$etomite = &$modx; // include_once the language file $_lang = array(); include_once("{$core_path}lang/english.inc.php"); -if($manager_language!=='english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { - include_once("{$core_path}lang/{$manager_language}.inc.php"); +if($manager_language !== 'english' && is_file("{$core_path}lang/{$manager_language}.inc.php")) { + include_once("{$core_path}lang/{$manager_language}.inc.php"); } // include the logger include_once("{$core_path}log.class.inc.php"); // Initialize System Alert Message Queque -if (!isset($_SESSION['SystemAlertMsgQueque'])) $_SESSION['SystemAlertMsgQueque'] = array(); +if(!isset($_SESSION['SystemAlertMsgQueque'])) { + $_SESSION['SystemAlertMsgQueque'] = array(); +} $SystemAlertMsgQueque = &$_SESSION['SystemAlertMsgQueque']; // initiate the content manager class - // for backward compatibility +// for backward compatibility -$username = $modx->db->escape($modx->htmlspecialchars($_REQUEST['username'], ENT_NOQUOTES)); +$username = $modx->db->escape($modx->htmlspecialchars($_REQUEST['username'], ENT_NOQUOTES)); $givenPassword = $modx->htmlspecialchars($_REQUEST['password'], ENT_NOQUOTES); -$captcha_code = $_REQUEST['captcha_code']; -$rememberme = $_REQUEST['rememberme']; +$captcha_code = $_REQUEST['captcha_code']; +$rememberme = $_REQUEST['rememberme']; $failed_allowed = $modx->config['failed_login_attempts']; // invoke OnBeforeManagerLogin event -$modx->invokeEvent('OnBeforeManagerLogin', - array( - 'username' => $username, - 'userpassword' => $givenPassword, - 'rememberme' => $rememberme - )); +$modx->invokeEvent('OnBeforeManagerLogin', array( + 'username' => $username, + 'userpassword' => $givenPassword, + 'rememberme' => $rememberme + )); $fields = 'mu.*, ua.*'; -$from = '[+prefix+]manager_users AS mu, [+prefix+]user_attributes AS ua'; -$where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id"; -$rs = $modx->db->select($fields, $from,$where); +$from = '[+prefix+]manager_users AS mu, [+prefix+]user_attributes AS ua'; +$where = "BINARY mu.username='{$username}' and ua.internalKey=mu.id"; +$rs = $modx->db->select($fields, $from, $where); $limit = $modx->db->getRecordCount($rs); -if($limit==0 || $limit>1) { - jsAlert($_lang['login_processor_unknown_user']); - return; +if($limit == 0 || $limit > 1) { + jsAlert($_lang['login_processor_unknown_user']); + return; } $row = $modx->db->getRow($rs); -$internalKey = $row['internalKey']; -$dbasePassword = $row['password']; -$failedlogins = $row['failedlogincount']; -$blocked = $row['blocked']; -$blockeduntildate = $row['blockeduntil']; -$blockedafterdate = $row['blockedafter']; -$registeredsessionid = $row['sessionid']; -$role = $row['role']; -$lastlogin = $row['lastlogin']; -$nrlogins = $row['logincount']; -$fullname = $row['fullname']; -$email = $row['email']; +$internalKey = $row['internalKey']; +$dbasePassword = $row['password']; +$failedlogins = $row['failedlogincount']; +$blocked = $row['blocked']; +$blockeduntildate = $row['blockeduntil']; +$blockedafterdate = $row['blockedafter']; +$registeredsessionid = $row['sessionid']; +$role = $row['role']; +$lastlogin = $row['lastlogin']; +$nrlogins = $row['logincount']; +$fullname = $row['fullname']; +$email = $row['email']; // get the user settings from the database $rs = $modx->db->select('setting_name, setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_value!=''"); -while ($row = $modx->db->getRow($rs)) { - extract($row); - ${$setting_name} = $setting_value; +while($row = $modx->db->getRow($rs)) { + extract($row); + ${$setting_name} = $setting_value; } // blocked due to number of login errors. -if($failedlogins>=$failed_allowed && $blockeduntildate>time()) { - @session_destroy(); - session_unset(); - if ($cip = getenv("HTTP_CLIENT_IP")) - $ip = $cip; - elseif ($cip = getenv("HTTP_X_FORWARDED_FOR")) - $ip = $cip; - elseif ($cip = getenv("REMOTE_ADDR")) - $ip = $cip; - else $ip = "UNKNOWN"; - $log = new logHandler; - $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: ".$ip); - jsAlert($_lang['login_processor_many_failed_logins']); - return; +if($failedlogins >= $failed_allowed && $blockeduntildate > time()) { + @session_destroy(); + session_unset(); + if($cip = getenv("HTTP_CLIENT_IP")) { + $ip = $cip; + } elseif($cip = getenv("HTTP_X_FORWARDED_FOR")) { + $ip = $cip; + } elseif($cip = getenv("REMOTE_ADDR")) { + $ip = $cip; + } else { + $ip = "UNKNOWN"; + } + $log = new logHandler; + $log->initAndWriteLog("Login Fail (Temporary Block)", $internalKey, $username, "119", $internalKey, "IP: " . $ip); + jsAlert($_lang['login_processor_many_failed_logins']); + return; } // blocked due to number of login errors, but get to try again -if($failedlogins>=$failed_allowed && $blockeduntildate= $failed_allowed && $blockeduntildate < time()) { $fields = array(); $fields['failedlogincount'] = '0'; - $fields['blockeduntil'] = time()-1; - $modx->db->update($fields,'[+prefix+]user_attributes',"internalKey='{$internalKey}'"); + $fields['blockeduntil'] = time() - 1; + $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); } // this user has been blocked by an admin, so no way he's loggin in! -if($blocked=='1') { - @session_destroy(); - session_unset(); - jsAlert($_lang['login_processor_blocked1']); - return; +if($blocked == '1') { + @session_destroy(); + session_unset(); + jsAlert($_lang['login_processor_blocked1']); + return; } // blockuntil: this user has a block until date -if($blockeduntildate>time()) { - @session_destroy(); - session_unset(); - jsAlert($_lang['login_processor_blocked2']); - return; +if($blockeduntildate > time()) { + @session_destroy(); + session_unset(); + jsAlert($_lang['login_processor_blocked2']); + return; } // blockafter: this user has a block after date -if($blockedafterdate>0 && $blockedafterdate 0 && $blockedafterdate < time()) { + @session_destroy(); + session_unset(); + jsAlert($_lang['login_processor_blocked3']); + return; } // allowed ip -if ($allowed_ip) { - if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { - if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { - jsAlert($_lang['login_processor_remotehost_ip']); - return; - } - } - if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { - jsAlert($_lang['login_processor_remote_ip']); - return; - } +if($allowed_ip) { + if(($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])) && ($hostname != $_SERVER['REMOTE_ADDR'])) { + if(gethostbyname($hostname) != $_SERVER['REMOTE_ADDR']) { + jsAlert($_lang['login_processor_remotehost_ip']); + return; + } + } + if(!in_array($_SERVER['REMOTE_ADDR'], array_filter(array_map('trim', explode(',', $allowed_ip))))) { + jsAlert($_lang['login_processor_remote_ip']); + return; + } } // allowed days -if ($allowed_days) { - $date = getdate(); - $day = $date['wday']+1; - if (strpos($allowed_days, $day)===false) { - jsAlert($_lang['login_processor_date']); - return; - } +if($allowed_days) { + $date = getdate(); + $day = $date['wday'] + 1; + if(strpos($allowed_days, $day) === false) { + jsAlert($_lang['login_processor_date']); + return; + } } // invoke OnManagerAuthentication event -$rt = $modx->invokeEvent('OnManagerAuthentication', - array( - 'userid' => $internalKey, - 'username' => $username, - 'userpassword' => $givenPassword, - 'savedpassword' => $dbasePassword, - 'rememberme' => $rememberme - )); +$rt = $modx->invokeEvent('OnManagerAuthentication', array( + 'userid' => $internalKey, + 'username' => $username, + 'userpassword' => $givenPassword, + 'savedpassword' => $dbasePassword, + 'rememberme' => $rememberme + )); // check if plugin authenticated the user $matchPassword = false; -if (!isset($rt) || !$rt || (is_array($rt) && !in_array(true,$rt))) -{ +if(!isset($rt) || !$rt || (is_array($rt) && !in_array(true, $rt))) { // check user password - local authentication $hashType = $modx->manager->getHashType($dbasePassword); - if($hashType=='phpass') $matchPassword = login($username,$_REQUEST['password'],$dbasePassword); - elseif($hashType=='md5') $matchPassword = loginMD5($internalKey,$givenPassword,$dbasePassword,$username); - elseif($hashType=='v1') $matchPassword = loginV1($internalKey,$givenPassword,$dbasePassword,$username); - else $matchPassword = false; -} else if($rt === true || (is_array($rt) && in_array(true,$rt))) { + if($hashType == 'phpass') { + $matchPassword = login($username, $_REQUEST['password'], $dbasePassword); + } elseif($hashType == 'md5') { + $matchPassword = loginMD5($internalKey, $givenPassword, $dbasePassword, $username); + } elseif($hashType == 'v1') { + $matchPassword = loginV1($internalKey, $givenPassword, $dbasePassword, $username); + } else { + $matchPassword = false; + } +} else if($rt === true || (is_array($rt) && in_array(true, $rt))) { $matchPassword = true; } if(!$matchPassword) { jsAlert($_lang['login_processor_wrong_password']); - incrementFailedLoginCount($internalKey,$failedlogins,$failed_allowed,$blocked_minutes); + incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); return; } -if($use_captcha==1) { - if (!isset ($_SESSION['veriword'])) { - jsAlert($_lang['login_processor_captcha_config']); +if($modx->config['use_captcha'] == 1) { + if(!isset ($_SESSION['veriword'])) { + jsAlert($_lang['login_processor_captcha_config']); + return; + } elseif($_SESSION['veriword'] != $captcha_code) { + jsAlert($_lang['login_processor_bad_code']); + incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes); return; } - elseif ($_SESSION['veriword'] != $captcha_code) { - jsAlert($_lang['login_processor_bad_code']); - incrementFailedLoginCount($internalKey,$failedlogins,$failed_allowed,$blocked_minutes); - return; - } } $modx->cleanupExpiredLocks(); @@ -211,159 +216,168 @@ $_SESSION['usertype'] = 'manager'; // user is a backend user // get permissions -$_SESSION['mgrShortname']=$username; -$_SESSION['mgrFullname']=$fullname; -$_SESSION['mgrEmail']=$email; -$_SESSION['mgrValidated']=1; -$_SESSION['mgrInternalKey']=$internalKey; -$_SESSION['mgrFailedlogins']=$failedlogins; -$_SESSION['mgrLastlogin']=$lastlogin; -$_SESSION['mgrLogincount']=$nrlogins; // login count -$_SESSION['mgrRole']=$role; +$_SESSION['mgrShortname'] = $username; +$_SESSION['mgrFullname'] = $fullname; +$_SESSION['mgrEmail'] = $email; +$_SESSION['mgrValidated'] = 1; +$_SESSION['mgrInternalKey'] = $internalKey; +$_SESSION['mgrFailedlogins'] = $failedlogins; +$_SESSION['mgrLastlogin'] = $lastlogin; +$_SESSION['mgrLogincount'] = $nrlogins; // login count +$_SESSION['mgrRole'] = $role; $rs = $modx->db->select('*', $modx->getFullTableName('user_roles'), "id='{$role}'"); $_SESSION['mgrPermissions'] = $modx->db->getRow($rs); // successful login so reset fail count and update key values -$modx->db->update( - 'failedlogincount=0, ' - . 'logincount=logincount+1, ' - . 'lastlogin=thislogin, ' - . 'thislogin=' . time() . ', ' - . "sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'" -); +$modx->db->update('failedlogincount=0, ' . 'logincount=logincount+1, ' . 'lastlogin=thislogin, ' . 'thislogin=' . time() . ', ' . "sessionid='{$currentsessionid}'", '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); // get user's document groups -$i=0; -$rs = $modx->db->select( - 'uga.documentgroup', - $modx->getFullTableName('member_groups').' ug - INNER JOIN ' . $modx->getFullTableName('membergroup_access').' uga ON uga.membergroup=ug.user_group', - "ug.member='{$internalKey}'" - ); +$i = 0; +$rs = $modx->db->select('uga.documentgroup', $modx->getFullTableName('member_groups') . ' ug + INNER JOIN ' . $modx->getFullTableName('membergroup_access') . ' uga ON uga.membergroup=ug.user_group', "ug.member='{$internalKey}'"); $_SESSION['mgrDocgroups'] = $modx->db->getColumn('documentgroup', $rs); if($rememberme == '1') { - $_SESSION['modx.mgr.session.cookie.lifetime']= intval($modx->config['session.cookie.lifetime']); - + $_SESSION['modx.mgr.session.cookie.lifetime'] = intval($modx->config['session.cookie.lifetime']); + // Set a cookie separate from the session cookie with the username in it. // Are we using secure connection? If so, make sure the cookie is secure global $https_port; - - $secure = ( (isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); - if ( version_compare(PHP_VERSION, '5.2', '<') ) { - setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time()+60*60*24*365, MODX_BASE_URL, '; HttpOnly' , $secure ); + + $secure = ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port); + if(version_compare(PHP_VERSION, '5.2', '<')) { + setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, '; HttpOnly', $secure); } else { - setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time()+60*60*24*365, MODX_BASE_URL, NULL, $secure, true); + setcookie('modx_remember_manager', $_SESSION['mgrShortname'], time() + 60 * 60 * 24 * 365, MODX_BASE_URL, NULL, $secure, true); } } else { - $_SESSION['modx.mgr.session.cookie.lifetime']= 0; - + $_SESSION['modx.mgr.session.cookie.lifetime'] = 0; + // Remove the Remember Me cookie - setcookie ('modx_remember_manager', '', time() - 3600, MODX_BASE_URL); + setcookie('modx_remember_manager', '', time() - 3600, MODX_BASE_URL); } // Check if user already has an active session, if not check if user pressed logout end of last session $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_user_sessions'), "internalKey='{$internalKey}'"); $activeSession = $modx->db->getValue($rs); if(!$activeSession) { - $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8"); - if ($lastHit = $modx->db->getValue($rs)) $_SESSION['show_logout_reminder'] = array('type'=>'logout_reminder', 'lastHit'=>$lastHit); + $rs = $modx->db->select('lasthit', $modx->getFullTableName('active_users'), "internalKey='{$internalKey}' AND action != 8"); + if($lastHit = $modx->db->getValue($rs)) { + $_SESSION['show_logout_reminder'] = array( + 'type' => 'logout_reminder', + 'lastHit' => $lastHit + ); + } } $log = new logHandler; $log->initAndWriteLog('Logged in', $modx->getLoginUserID(), $_SESSION['mgrShortname'], '58', '-', 'MODX'); // invoke OnManagerLogin event -$modx->invokeEvent('OnManagerLogin', - array( - 'userid' => $internalKey, - 'username' => $username, - 'userpassword' => $givenPassword, - 'rememberme' => $rememberme - )); +$modx->invokeEvent('OnManagerLogin', array( + 'userid' => $internalKey, + 'username' => $username, + 'userpassword' => $givenPassword, + 'rememberme' => $rememberme + )); // check if we should redirect user to a web page $rs = $modx->db->select('setting_value', '[+prefix+]user_settings', "user='{$internalKey}' AND setting_name='manager_login_startup'"); $id = intval($modx->db->getValue($rs)); -if($id>0) { - $header = 'Location: '.$modx->makeUrl($id,'','','full'); - if($_POST['ajax']==1) echo $header; - else header($header); -} -else { - $header = 'Location: '.MODX_MANAGER_URL; - if($_POST['ajax']==1) echo $header; - else header($header); +if($id > 0) { + $header = 'Location: ' . $modx->makeUrl($id, '', '', 'full'); + if($_POST['ajax'] == 1) { + echo $header; + } else { + header($header); + } +} else { + $header = 'Location: ' . MODX_MANAGER_URL; + if($_POST['ajax'] == 1) { + echo $header; + } else { + header($header); + } } // show javascript alert -function jsAlert($msg){ +function jsAlert($msg) { global $modx; - if($_POST['ajax']!=1) echo ""; - else echo $msg."\n"; + if($_POST['ajax'] != 1) { + echo ""; + } else { + echo $msg . "\n"; + } } -function login($username,$givenPassword,$dbasePassword) { +function login($username, $givenPassword, $dbasePassword) { global $modx; return $modx->phpass->CheckPassword($givenPassword, $dbasePassword); } -function loginV1($internalKey,$givenPassword,$dbasePassword,$username) { +function loginV1($internalKey, $givenPassword, $dbasePassword, $username) { global $modx; - + $user_algo = $modx->manager->getV1UserHashAlgorithm($internalKey); - - if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) + + if(!isset($modx->config['pwd_hash_algo']) || empty($modx->config['pwd_hash_algo'])) { $modx->config['pwd_hash_algo'] = 'UNCRYPT'; - + } + if($user_algo !== $modx->config['pwd_hash_algo']) { $bk_pwd_hash_algo = $modx->config['pwd_hash_algo']; $modx->config['pwd_hash_algo'] = $user_algo; } - + if($dbasePassword != $modx->manager->genV1Hash($givenPassword, $internalKey)) { return false; } - - updateNewHash($username,$givenPassword); - + + updateNewHash($username, $givenPassword); + return true; } -function loginMD5($internalKey,$givenPassword,$dbasePassword,$username) { +function loginMD5($internalKey, $givenPassword, $dbasePassword, $username) { global $modx; - - if($dbasePassword != md5($givenPassword)) return false; - updateNewHash($username,$givenPassword); + + if($dbasePassword != md5($givenPassword)) { + return false; + } + updateNewHash($username, $givenPassword); return true; } -function updateNewHash($username,$password) { +function updateNewHash($username, $password) { global $modx; - + $field = array(); $field['password'] = $modx->phpass->HashPassword($password); $modx->db->update($field, '[+prefix+]manager_users', "username='{$username}'"); } -function incrementFailedLoginCount($internalKey,$failedlogins,$failed_allowed,$blocked_minutes) { +function incrementFailedLoginCount($internalKey, $failedlogins, $failed_allowed, $blocked_minutes) { global $modx; - - $failedlogins += 1; - $fields = array('failedlogincount' => $failedlogins); - if($failedlogins>=$failed_allowed) //block user for too many fail attempts - $fields['blockeduntil'] = time()+($blocked_minutes*60); + $failedlogins += 1; + + $fields = array('failedlogincount' => $failedlogins); + if($failedlogins >= $failed_allowed) //block user for too many fail attempts + { + $fields['blockeduntil'] = time() + ($blocked_minutes * 60); + } - $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); + $modx->db->update($fields, '[+prefix+]user_attributes', "internalKey='{$internalKey}'"); - if($failedlogins<$failed_allowed) { + if($failedlogins < $failed_allowed) { //sleep to help prevent brute force attacks - $sleep = (int)$failedlogins/2; - if($sleep>5) $sleep = 5; - sleep($sleep); - } + $sleep = (int) $failedlogins / 2; + if($sleep > 5) { + $sleep = 5; + } + sleep($sleep); + } @session_destroy(); session_unset(); - return; + return; } diff --git a/manager/processors/metatags.processor.php b/manager/processors/metatags.processor.php deleted file mode 100644 index e4f3cdee4b..0000000000 --- a/manager/processors/metatags.processor.php +++ /dev/null @@ -1,98 +0,0 @@ -INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); -if(!$modx->hasPermission('manage_metatags')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); -} - -// get op code -$opcode = isset($_POST['op']) ? $_POST['op'] : "keys" ; - -// add tag -if($opcode=="addtag") { - list($tag,$http_equiv) = explode(";",$_POST["tag"]); - $f = array( - 'name' => $modx->db->escape($_POST["tagname"]), - 'tag' => $modx->db->escape($tag), - 'tagvalue' => $modx->db->escape($_POST["tagvalue"]), - 'http_equiv' => intval($http_equiv) - ); - if($f["name"] && $f["tagvalue"]) { - $modx->db->insert($f,$modx->getFullTableName("site_metatags")); - } -} -// edit tag -else if($opcode=="edttag") { - $id = intval($_POST["id"]); - list($tag,$http_equiv) = explode(";",$_POST["tag"]); - $f = array( - 'name' => $modx->db->escape($_POST["tagname"]), - 'tag' => $modx->db->escape($tag), - 'tagvalue' => $modx->db->escape($_POST["tagvalue"]), - 'http_equiv' => intval($http_equiv) - ); - if($f["name"] && $f["tagvalue"]) { - $modx->db->update($f,$modx->getFullTableName("site_metatags"),"id='{$id}'"); - } -} -// delete -else if($opcode=="deltag") { - $f = $_POST["tag"]; - if(is_array($f) && count($f)>0) { - $f = $modx->db->escape($f); - $modx->db->delete($modx->getFullTableName("site_metatags"),"id IN('".implode("','",$f)."')"); - } -} -else { - $delete_keywords = isset($_POST['delete_keywords']) ? $_POST['delete_keywords'] : array() ; - $orig_keywords = isset($_POST['orig_keywords']) ? $_POST['orig_keywords'] : array() ; - $rename_keywords = isset($_POST['rename_keywords']) ? $_POST['rename_keywords'] : array() ; - - // do any renaming that has to be done - foreach($orig_keywords as $key => $value) { - if($rename_keywords[$key]!=$value) { - $rs = $modx->db->select('count(*)', $modx->getFullTableName('site_keywords'), "BINARY keyword='".$modx->db->escape($rename_keywords[$key])."'"); - $limit = $modx->db->getValue($rs); - if($limit > 0) { - $modx->webAlertAndQuit("Keyword '{$rename_keywords[$key]}' already been defined!"); - } else { - $modx->db->update( - array( - 'keyword' => $modx->db->escape($rename_keywords[$key]), - ), $modx->getFullTableName('site_keywords'), "keyword='".$modx->db->escape($value)."'"); - } - } - } - - // delete any keywords that need to be deleted - if(count($delete_keywords)>0) { - $keywords_array = array_keys($delete_keywords); - - $modx->db->delete($modx->getFullTableName('keyword_xref'), "keyword_id IN(".implode(",", $keywords_array).")"); - - $modx->db->delete($modx->getFullTableName('site_keywords'), "id IN(".implode(",", $keywords_array).")"); - - } - - // add new keyword - if(!empty($_POST['new_keyword'])) { - $nk = $_POST['new_keyword']; - - $rs = $modx->db->select('count(*)', $modx->getFullTableName('site_keywords'), "keyword='".$modx->db->escape($nk)."'"); - $limit = $modx->db->getValue($rs); - if($limit > 0) { - $modx->webAlertAndQuit("Keyword '{$nk}' already exists!"); - } else { - $modx->db->insert( - array( - 'keyword' => $modx->db->escape($nk), - ), $modx->getFullTableName('site_keywords')); - } - } -} - -// empty cache -$modx->clearCache('full'); - -$header="Location: index.php?a=81"; -header($header); -?> \ No newline at end of file diff --git a/manager/processors/move_document.processor.php b/manager/processors/move_document.processor.php index dae281b419..69da41e95a 100644 --- a/manager/processors/move_document.processor.php +++ b/manager/processors/move_document.processor.php @@ -14,6 +14,9 @@ if($documentID <= 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); if($newParentID < 0) $modx->webAlertAndQuit($_lang["error_movedocument2"]); +$parents = $modx->getParentIds($newParentID); +if (in_array($documentID, $parents)) $modx->webAlertAndQuit($_lang["error_movedocument2"]); + $rs = $modx->db->select('parent', $modx->getFullTableName('site_content'), "id='{$documentID}'"); $oldparent = $modx->db->getValue($rs); @@ -98,4 +101,4 @@ function allChildren($currDocID) { header($header); } else { $modx->webAlertAndQuit("You cannot move a document to a child document!"); -} \ No newline at end of file +} diff --git a/manager/processors/save_content.processor.php b/manager/processors/save_content.processor.php index d0e4e3dd24..5a8bfd48ea 100644 --- a/manager/processors/save_content.processor.php +++ b/manager/processors/save_content.processor.php @@ -25,8 +25,6 @@ $unpub_date = $_POST['unpub_date']; $document_groups = (isset($_POST['chkalldocs']) && $_POST['chkalldocs'] == 'on') ? array() : $_POST['docgroups']; $type = $_POST['type']; -$keywords = $_POST['keywords']; -$metatags = $_POST['metatags']; $contentType = $modx->db->escape($_POST['contentType']); $contentdispo = intval($_POST['content_dispo']); $longtitle = $modx->db->escape($_POST['longtitle']); @@ -57,9 +55,7 @@ $tbl_documentgroup_names = $modx->getFullTableName('documentgroup_names'); $tbl_member_groups = $modx->getFullTableName('member_groups'); $tbl_membergroup_access = $modx->getFullTableName('membergroup_access'); -$tbl_keyword_xref = $modx->getFullTableName('keyword_xref'); $tbl_site_content = $modx->getFullTableName('site_content'); -$tbl_site_content_metatags = $modx->getFullTableName('site_content_metatags'); $tbl_site_tmplvar_access = $modx->getFullTableName('site_tmplvar_access'); $tbl_site_tmplvar_contentvalues = $modx->getFullTableName('site_tmplvar_contentvalues'); $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates'); @@ -402,9 +398,6 @@ $modx->db->update($fields, $tbl_site_content, "id='{$_REQUEST['parent']}'"); } - // save META Keywords - saveMETAKeywords($key); - // invoke OnDocFormSave event $modx->invokeEvent("OnDocFormSave", array ( "mode" => "new", @@ -468,6 +461,12 @@ $modx->manager->saveFormValues(27); $modx->webAlertAndQuit("Document can not be it's own parent!"); } + + $parents = $modx->getParentIds($parent); + if (in_array($oldparent, $parents)) { + $modx->webAlertAndQuit("Document descendant can not be it's parent!"); + } + // check to see document is a folder $rs = $modx->db->select('count(id)', $tbl_site_content, "parent='{$id}'"); $count = $modx->db->getValue($rs); @@ -635,8 +634,6 @@ $modx->db->update($fields, $tbl_site_content, "id='{$oldparent}'"); } - // save META Keywords - saveMETAKeywords($id); // invoke OnDocFormSave event $modx->invokeEvent("OnDocFormSave", array ( @@ -691,40 +688,4 @@ $modx->webAlertAndQuit("No operation set in request."); } -// -- Save META Keywords -- -function saveMETAKeywords($id) { - global $modx, $keywords, $metatags, - $tbl_keyword_xref, - $tbl_site_content, - $tbl_site_content_metatags; - - if ($modx->hasPermission('edit_doc_metatags')) { - // keywords - remove old keywords first - $modx->db->delete($tbl_keyword_xref, "content_id=$id"); - for ($i = 0; $i < count($keywords); $i++) { - $kwid = $keywords[$i]; - $flds = array ( - 'content_id' => $id, - 'keyword_id' => $kwid - ); - $modx->db->insert($flds, $tbl_keyword_xref); - } - // meta tags - remove old tags first - $modx->db->delete($tbl_site_content_metatags, "content_id=$id"); - for ($i = 0; $i < count($metatags); $i++) { - $kwid = $metatags[$i]; - $flds = array ( - 'content_id' => $id, - 'metatag_id' => $kwid - ); - $modx->db->insert($flds, $tbl_site_content_metatags); - } - $flds = array ( - 'haskeywords' => (count($keywords) ? 1 : 0), - 'hasmetatags' => (count($metatags) ? 1 : 0) - ); - $modx->db->update($flds, $tbl_site_content, "id='{$id}'"); - } -} - -?> \ No newline at end of file +?> diff --git a/manager/processors/save_htmlsnippet.processor.php b/manager/processors/save_htmlsnippet.processor.php index ec5b881b4b..821ba10e61 100755 --- a/manager/processors/save_htmlsnippet.processor.php +++ b/manager/processors/save_htmlsnippet.processor.php @@ -1,14 +1,18 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} if (!$modx->hasPermission('save_chunk')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = intval($_POST['id']); $snippet = $modx->db->escape($_POST['post']); $name = $modx->db->escape(trim($_POST['name'])); $description = $modx->db->escape($_POST['description']); -$locked = $_POST['locked']=='on' ? 1 : 0 ; +$locked = $_POST['locked'] == 'on' ? 1 : 0; +$disabled = $_POST['disabled'] == "on" ? '1' : '0'; +$currentdate = time() + $modx->config['server_offset_time']; //Kyle Jaebker - added category support if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { @@ -16,14 +20,16 @@ } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { $categoryid = 0; } else { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = checkCategory($_POST['newcategory']); if (!$categoryid) { $categoryid = newCategory($_POST['newcategory']); } } -if($name=="") $name = "Untitled chunk"; +if ($name == "" || $name == 'null') { + $name = "Untitled chunk"; +} $editor_type = $_POST['which_editor'] != 'none' ? 1 : 2; $editor_name = $_POST['which_editor'] != 'none' ? $_POST['which_editor'] : 'none'; @@ -31,108 +37,106 @@ switch ($_POST['mode']) { case '77': - // invoke OnBeforeChunkFormSave event - $modx->invokeEvent("OnBeforeChunkFormSave", - array( - "mode" => "new", - "id" => $id - )); - - // disallow duplicate names for new chunks - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_htmlsnippets'), "name='{$name}'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(77); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['chunk'], $name), "index.php?a=77"); - } - - //do stuff to save the new doc - $newid = $modx->db->insert( - array( - 'name' => $name, - 'description' => $description, - 'snippet' => $snippet, - 'locked' => $locked, - 'category' => $categoryid, - 'editor_type' => $editor_type, - 'editor_name' => $editor_name - ), $modx->getFullTableName('site_htmlsnippets')); - - // invoke OnChunkFormSave event - $modx->invokeEvent("OnChunkFormSave", - array( - "mode" => "new", - "id" => $newid - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "78&id=$newid":"77"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $header="Location: index.php?a=76&r=2"; - header($header); - } + // invoke OnBeforeChunkFormSave event + $modx->invokeEvent("OnBeforeChunkFormSave", array( + "mode" => "new", + "id" => $id + )); + + // disallow duplicate names for new chunks + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_htmlsnippets'), "name='{$name}'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(77); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['chunk'], $name), "index.php?a=77"); + } + + //do stuff to save the new doc + $newid = $modx->db->insert(array( + 'name' => $name, + 'description' => $description, + 'snippet' => $snippet, + 'locked' => $locked, + 'category' => $categoryid, + 'editor_type' => $editor_type, + 'editor_name' => $editor_name, + 'disabled' => $disabled, + 'createdon' => $currentdate, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_htmlsnippets')); + + // invoke OnChunkFormSave event + $modx->invokeEvent("OnChunkFormSave", array( + "mode" => "new", + "id" => $newid + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "78&id=$newid" : "77"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; case '78': - // invoke OnBeforeChunkFormSave event - $modx->invokeEvent("OnBeforeChunkFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // disallow duplicate names for chunks - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_htmlsnippets'), "name='{$name}' AND id!='{$id}'"); - if($modx->db->getValue($rs) > 0) { - $modx->manager->saveFormValues(78); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['chunk'], $name), "index.php?a=78&id={$id}"); - } - - //do stuff to save the edited doc - $modx->db->update( - array( - 'name' => $name, - 'description' => $description, - 'snippet' => $snippet, - 'locked' => $locked, - 'category' => $categoryid, - 'editor_type' => $editor_type, - 'editor_name' => $editor_name - ), $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); - - // invoke OnChunkFormSave event - $modx->invokeEvent("OnChunkFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "78&id=$id":"77"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $modx->unlockElement(3, $id); - $header="Location: index.php?a=76&r=2"; - header($header); - } + // invoke OnBeforeChunkFormSave event + $modx->invokeEvent("OnBeforeChunkFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // disallow duplicate names for chunks + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_htmlsnippets'), "name='{$name}' AND id!='{$id}'"); + if ($modx->db->getValue($rs) > 0) { + $modx->manager->saveFormValues(78); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['chunk'], $name), "index.php?a=78&id={$id}"); + } + + //do stuff to save the edited doc + $modx->db->update(array( + 'name' => $name, + 'description' => $description, + 'snippet' => $snippet, + 'locked' => $locked, + 'category' => $categoryid, + 'editor_type' => $editor_type, + 'editor_name' => $editor_name, + 'disabled' => $disabled, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_htmlsnippets'), "id='{$id}'"); + + // invoke OnChunkFormSave event + $modx->invokeEvent("OnChunkFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "78&id=$id" : "77"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $modx->unlockElement(3, $id); + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; default: - $modx->webAlertAndQuit("No operation set in request."); + $modx->webAlertAndQuit("No operation set in request."); } -?> \ No newline at end of file diff --git a/manager/processors/save_module.processor.php b/manager/processors/save_module.processor.php index 3faa5eb2b0..b2391b22b5 100644 --- a/manager/processors/save_module.processor.php +++ b/manager/processors/save_module.processor.php @@ -1,24 +1,27 @@ -INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); -if(!$modx->hasPermission('save_module')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} +if (!$modx->hasPermission('save_module')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = intval($_POST['id']); $name = $modx->db->escape(trim($_POST['name'])); $description = $modx->db->escape($_POST['description']); $resourcefile = $modx->db->escape($_POST['resourcefile']); -$enable_resource = $_POST['enable_resource']=='on' ? 1 : 0 ; +$enable_resource = $_POST['enable_resource'] == 'on' ? 1 : 0; $icon = $modx->db->escape($_POST['icon']); //$category = intval($_POST['category']); -$disabled = $_POST['disabled']=='on' ? 1 : 0 ; -$wrap = $_POST['wrap']=='on' ? 1 : 0 ; -$locked = $_POST['locked']=='on' ? 1 : 0 ; +$disabled = $_POST['disabled'] == 'on' ? 1 : 0; +$wrap = $_POST['wrap'] == 'on' ? 1 : 0; +$locked = $_POST['locked'] == 'on' ? 1 : 0; $modulecode = $modx->db->escape($_POST['post']); $properties = $modx->db->escape($_POST['properties']); -$enable_sharedparams = $_POST['enable_sharedparams']=='on' ? 1 : 0 ; +$enable_sharedparams = $_POST['enable_sharedparams'] == 'on' ? 1 : 0; $guid = $modx->db->escape($_POST['guid']); -$parse_docblock = $_POST['parse_docblock']=="1" ? '1' : '0'; +$parse_docblock = $_POST['parse_docblock'] == "1" ? '1' : '0'; +$currentdate = time() + $modx->config['server_offset_time']; //Kyle Jaebker - added category support if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { @@ -26,180 +29,180 @@ } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { $categoryid = 0; } else { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = checkCategory($_POST['newcategory']); if (!$categoryid) { $categoryid = newCategory($_POST['newcategory']); } } -if($name=="") $name = "Untitled module"; +if ($name == "") { + $name = "Untitled module"; +} -if($parse_docblock) { - $parsed = $modx->parseDocBlockFromString($modulecode, true); - $name = isset($parsed['name']) ? $parsed['name'] : $name; - $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; - $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid; +if ($parse_docblock) { + $parsed = $modx->parseDocBlockFromString($modulecode, true); + $name = isset($parsed['name']) ? $parsed['name'] : $name; + $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; + $guid = isset($parsed['guid']) ? $parsed['guid'] : $guid; $enable_sharedparams = isset($parsed['shareparams']) ? intval($parsed['shareparams']) : $enable_sharedparams; - - $description = isset($parsed['description']) ? $parsed['description'] : $description; - $version = isset($parsed['version']) ? ''.$parsed['version'].' ' : ''; - if($version) { + + $description = isset($parsed['description']) ? $parsed['description'] : $description; + $version = isset($parsed['version']) ? '' . $parsed['version'] . ' ' : ''; + if ($version) { $description = $version . trim(preg_replace('/(.+?)+(<\/b>)/i', '', $description)); } - if(isset($parsed['modx_category'])) { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + if (isset($parsed['modx_category'])) { + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = getCategory($parsed['modx_category']); } } switch ($_POST['mode']) { case '107': - // invoke OnBeforeModFormSave event - $modx->invokeEvent("OnBeforeModFormSave", - array( - "mode" => "new", - "id" => $id - )); - - // disallow duplicate names for new modules - $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(107); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); - } - - // save the new module - $newid = $modx->db->insert( - array( - 'name' => $name, - 'description' => $description, - 'disabled' => $disabled, - 'wrap' => $wrap, - 'locked' => $locked, - 'icon' => $icon, - 'resourcefile' => $resourcefile, - 'enable_resource' => $enable_resource, - 'category' => $categoryid, - 'enable_sharedparams' => $enable_sharedparams, - 'guid' => $guid, - 'modulecode' => $modulecode, - 'properties' => $properties, - ), $modx->getFullTableName('site_modules')); - - // save user group access permissions - saveUserGroupAccessPermissons(); - - // invoke OnModFormSave event - $modx->invokeEvent("OnModFormSave", - array( - "mode" => "new", - "id" => $newid - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "108&id=$newid":"107"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $header="Location: index.php?a=106&r=2"; - header($header); - } + // invoke OnBeforeModFormSave event + $modx->invokeEvent("OnBeforeModFormSave", array( + "mode" => "new", + "id" => $id + )); + + // disallow duplicate names for new modules + $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(107); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=107"); + } + + // save the new module + $newid = $modx->db->insert(array( + 'name' => $name, + 'description' => $description, + 'disabled' => $disabled, + 'wrap' => $wrap, + 'locked' => $locked, + 'icon' => $icon, + 'resourcefile' => $resourcefile, + 'enable_resource' => $enable_resource, + 'category' => $categoryid, + 'enable_sharedparams' => $enable_sharedparams, + 'guid' => $guid, + 'modulecode' => $modulecode, + 'properties' => $properties, + 'createdon' => $currentdate, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_modules')); + + // save user group access permissions + saveUserGroupAccessPermissons(); + + // invoke OnModFormSave event + $modx->invokeEvent("OnModFormSave", array( + "mode" => "new", + "id" => $newid + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "108&id=$newid" : "107"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $header = "Location: index.php?a=106&r=2"; + header($header); + } break; case '108': - // invoke OnBeforeModFormSave event - $modx->invokeEvent("OnBeforeModFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // disallow duplicate names for new modules - $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); - if ($modx->db->getValue($rs) > 0) { - $modx->manager->saveFormValues(108); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); - } - - // save the edited module - $modx->db->update( - array( - 'name' => $name, - 'description' => $description, - 'icon' => $icon, - 'enable_resource' => $enable_resource, - 'resourcefile' => $resourcefile, - 'disabled' => $disabled, - 'wrap' => $wrap, - 'locked' => $locked, - 'category' => $categoryid, - 'enable_sharedparams' => $enable_sharedparams, - 'guid' => $guid, - 'modulecode' => $modulecode, - 'properties' => $properties, - ), $modx->getFullTableName('site_modules'), "id='{$id}'"); - - // save user group access permissions - saveUserGroupAccessPermissons(); - - // invoke OnModFormSave event - $modx->invokeEvent("OnModFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "108&id=$id":"107"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $modx->unlockElement(6, $id); - $header="Location: index.php?a=106&r=2"; - header($header); - } - break; + // invoke OnBeforeModFormSave event + $modx->invokeEvent("OnBeforeModFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // disallow duplicate names for new modules + $rs = $modx->db->select('count(id)', $modx->getFullTableName('site_modules'), "name='{$name}' AND id!='{$id}'"); + if ($modx->db->getValue($rs) > 0) { + $modx->manager->saveFormValues(108); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_module'], $name), "index.php?a=108&id={$id}"); + } + + // save the edited module + $modx->db->update(array( + 'name' => $name, + 'description' => $description, + 'icon' => $icon, + 'enable_resource' => $enable_resource, + 'resourcefile' => $resourcefile, + 'disabled' => $disabled, + 'wrap' => $wrap, + 'locked' => $locked, + 'category' => $categoryid, + 'enable_sharedparams' => $enable_sharedparams, + 'guid' => $guid, + 'modulecode' => $modulecode, + 'properties' => $properties, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_modules'), "id='{$id}'"); + + // save user group access permissions + saveUserGroupAccessPermissons(); + + // invoke OnModFormSave event + $modx->invokeEvent("OnModFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "108&id=$id" : "107"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $modx->unlockElement(6, $id); + $header = "Location: index.php?a=106&r=2"; + header($header); + } + break; default: - $modx->webAlertAndQuit("No operation set in request."); + $modx->webAlertAndQuit("No operation set in request."); } // saves module user group access -function saveUserGroupAccessPermissons(){ - global $modx; - global $id,$newid; - global $use_udperms; - - if($newid) $id = $newid; - $usrgroups = $_POST['usrgroups']; - - // check for permission update access - if($use_udperms==1) { - // delete old permissions on the module - $modx->db->delete($modx->getFullTableName("site_module_access"), "module='{$id}'"); - if(is_array($usrgroups)) { - foreach ($usrgroups as $value) { - $modx->db->insert( - array( - 'module' => $id, - 'usergroup' => stripslashes($value), - ), $modx->getFullTableName('site_module_access')); - } - } - } +function saveUserGroupAccessPermissons() +{ + global $modx; + global $id, $newid; + global $use_udperms; + + if ($newid) { + $id = $newid; + } + $usrgroups = $_POST['usrgroups']; + + // check for permission update access + if ($use_udperms == 1) { + // delete old permissions on the module + $modx->db->delete($modx->getFullTableName("site_module_access"), "module='{$id}'"); + if (is_array($usrgroups)) { + foreach ($usrgroups as $value) { + $modx->db->insert(array( + 'module' => $id, + 'usergroup' => stripslashes($value), + ), $modx->getFullTableName('site_module_access')); + } + } + } } -?> diff --git a/manager/processors/save_plugin.processor.php b/manager/processors/save_plugin.processor.php index 5fa2b18ff3..cb6ae43642 100755 --- a/manager/processors/save_plugin.processor.php +++ b/manager/processors/save_plugin.processor.php @@ -1,19 +1,22 @@ -INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); -if(!$modx->hasPermission('save_plugin')) { +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} +if (!$modx->hasPermission('save_plugin')) { $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = intval($_POST['id']); $name = $modx->db->escape(trim($_POST['name'])); $description = $modx->db->escape($_POST['description']); -$locked = $_POST['locked']=='on' ? '1' : '0' ; +$locked = $_POST['locked'] == 'on' ? '1' : '0'; $plugincode = $modx->db->escape($_POST['post']); $properties = $modx->db->escape($_POST['properties']); -$disabled = $_POST['disabled']=="on" ? '1' : '0'; +$disabled = $_POST['disabled'] == "on" ? '1' : '0'; $moduleguid = $modx->db->escape($_POST['moduleguid']); $sysevents = $_POST['sysevents']; -$parse_docblock = $_POST['parse_docblock']=="1" ? '1' : '0'; +$parse_docblock = $_POST['parse_docblock'] == "1" ? '1' : '0'; +$currentdate = time() + $modx->config['server_offset_time']; //Kyle Jaebker - added category support if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { @@ -21,26 +24,28 @@ } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { $categoryid = 0; } else { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); - $categoryid = getCategory($_POST['newcategory']); + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); + $categoryid = getCategory($_POST['newcategory']); +} + +if ($name == "") { + $name = "Untitled plugin"; } -if($name=="") $name = "Untitled plugin"; - -if($parse_docblock) { - $parsed = $modx->parseDocBlockFromString($plugincode, true); - $name = isset($parsed['name']) ? $parsed['name'] : $name; - $sysevents = isset($parsed['events']) ? explode(',', $parsed['events']) : $sysevents; - $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; - $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; - - $description = isset($parsed['description']) ? $parsed['description'] : $description; - $version = isset($parsed['version']) ? ''.$parsed['version'].' ' : ''; - if($version) { +if ($parse_docblock) { + $parsed = $modx->parseDocBlockFromString($plugincode, true); + $name = isset($parsed['name']) ? $parsed['name'] : $name; + $sysevents = isset($parsed['events']) ? explode(',', $parsed['events']) : $sysevents; + $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; + $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; + + $description = isset($parsed['description']) ? $parsed['description'] : $description; + $version = isset($parsed['version']) ? '' . $parsed['version'] . ' ' : ''; + if ($version) { $description = $version . trim(preg_replace('/(.+?)+(<\/b>)/i', '', $description)); } - if(isset($parsed['modx_category'])) { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + if (isset($parsed['modx_category'])) { + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = getCategory($parsed['modx_category']); } } @@ -49,133 +54,130 @@ $eventIds = array(); switch ($_POST['mode']) { case '101': - + // invoke OnBeforePluginFormSave event - $modx->invokeEvent("OnBeforePluginFormSave", - array( - "mode" => "new", - "id" => $id - )); - - // disallow duplicate names for active plugins - if ($disabled == '0') { - $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_plugins'), "name='{$name}' AND disabled='0'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(101); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['plugin'], $name), "index.php?a=101"); - } - } - - //do stuff to save the new plugin - $newid = $modx->db->insert( - array( - 'name' => $name, - 'description' => $description, - 'plugincode' => $plugincode, - 'disabled' => $disabled, - 'moduleguid' => $moduleguid, - 'locked' => $locked, - 'properties' => $properties, - 'category' => $categoryid, - ), $tblSitePlugins); - - // save event listeners - saveEventListeners($newid,$sysevents,$_POST['mode']); - - // invoke OnPluginFormSave event - $modx->invokeEvent("OnPluginFormSave", - array( - "mode" => "new", - "id" => $newid - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "102&id=$newid":"101"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $header="Location: index.php?a=76&r=2"; - header($header); + $modx->invokeEvent("OnBeforePluginFormSave", array( + "mode" => "new", + "id" => $id + )); + + // disallow duplicate names for active plugins + if ($disabled == '0') { + $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_plugins'), "name='{$name}' AND disabled='0'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(101); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['plugin'], $name), "index.php?a=101"); } + } + + //do stuff to save the new plugin + $newid = $modx->db->insert(array( + 'name' => $name, + 'description' => $description, + 'plugincode' => $plugincode, + 'disabled' => $disabled, + 'moduleguid' => $moduleguid, + 'locked' => $locked, + 'properties' => $properties, + 'category' => $categoryid, + 'createdon' => $currentdate, + 'editedon' => $currentdate + ), $tblSitePlugins); + + // save event listeners + saveEventListeners($newid, $sysevents, $_POST['mode']); + + // invoke OnPluginFormSave event + $modx->invokeEvent("OnPluginFormSave", array( + "mode" => "new", + "id" => $newid + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "102&id=$newid" : "101"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; case '102': // invoke OnBeforePluginFormSave event - $modx->invokeEvent("OnBeforePluginFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // disallow duplicate names for active plugins - if ($disabled == '0') { - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_plugins'), "name='{$name}' AND id!='{$id}' AND disabled='0'"); - if ($modx->db->getValue($rs) > 0) { - $modx->manager->saveFormValues(102); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['plugin'], $name), "index.php?a=102&id={$id}"); - } - } + $modx->invokeEvent("OnBeforePluginFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // disallow duplicate names for active plugins + if ($disabled == '0') { + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_plugins'), "name='{$name}' AND id!='{$id}' AND disabled='0'"); + if ($modx->db->getValue($rs) > 0) { + $modx->manager->saveFormValues(102); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['plugin'], $name), "index.php?a=102&id={$id}"); + } + } //do stuff to save the edited plugin - $modx->db->update( - array( - 'name' => $name, - 'description' => $description, - 'plugincode' => $plugincode, - 'disabled' => $disabled, - 'moduleguid' => $moduleguid, - 'locked' => $locked, - 'properties' => $properties, - 'category' => $categoryid, - ), $tblSitePlugins, "id='{$id}'"); - - // save event listeners - saveEventListeners($id,$sysevents,$_POST['mode']); - - // invoke OnPluginFormSave event - $modx->invokeEvent("OnPluginFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "102&id=$id":"101"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $modx->unlockElement(5, $id); - $header="Location: index.php?a=76&r=2"; - header($header); - } + $modx->db->update(array( + 'name' => $name, + 'description' => $description, + 'plugincode' => $plugincode, + 'disabled' => $disabled, + 'moduleguid' => $moduleguid, + 'locked' => $locked, + 'properties' => $properties, + 'category' => $categoryid, + 'editedon' => $currentdate + ), $tblSitePlugins, "id='{$id}'"); + + // save event listeners + saveEventListeners($id, $sysevents, $_POST['mode']); + + // invoke OnPluginFormSave event + $modx->invokeEvent("OnPluginFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "102&id=$id" : "101"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $modx->unlockElement(5, $id); + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; default: - $modx->webAlertAndQuit("No operation set in request."); + $modx->webAlertAndQuit("No operation set in request."); } - # Save Plugin Event Listeners -function saveEventListeners($id,$sysevents,$mode) { +function saveEventListeners($id, $sysevents, $mode) +{ global $modx; // save selected system events $tblSitePluginEvents = $modx->getFullTableName('site_plugin_events'); $insert_sysevents = array(); - for($i=0;$i$id,'evtid'=>$evtId,'priority'=>$priority); + $insert_sysevents[] = array('pluginid' => $id, 'evtid' => $evtId, 'priority' => $priority); } $modx->db->delete($tblSitePluginEvents, "pluginid='{$id}'"); foreach ($insert_sysevents as $insert_sysevent) { @@ -197,13 +199,14 @@ function saveEventListeners($id,$sysevents,$mode) { } } -function getEventIdByName($name) { +function getEventIdByName($name) +{ global $modx, $eventIds; - if(empty($eventIds)) { + if (empty($eventIds)) { $rs = $modx->db->select('id, name', $modx->getFullTableName('system_eventnames')); - while ($row = $modx->db->getRow($rs)) - $eventIds[$row['name']] = $row['id']; + while ($row = $modx->db->getRow($rs)) { + $eventIds[$row['name']] = $row['id']; + } } return $eventIds[$name]; } -?> \ 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, diff --git a/manager/processors/save_snippet.processor.php b/manager/processors/save_snippet.processor.php index 4357ac4424..d317e9ac98 100755 --- a/manager/processors/save_snippet.processor.php +++ b/manager/processors/save_snippet.processor.php @@ -1,25 +1,35 @@ INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +if (IN_MANAGER_MODE != "true") { + die("INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} if (!$modx->hasPermission('save_snippet')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = intval($_POST['id']); $snippet = trim($_POST['post']); $name = $modx->db->escape(trim($_POST['name'])); $description = $modx->db->escape($_POST['description']); -$locked = $_POST['locked']=='on' ? 1 : 0 ; +$locked = $_POST['locked'] == 'on' ? 1 : 0; +$disabled = $_POST['disabled'] == "on" ? '1' : '0'; +$currentdate = time() + $modx->config['server_offset_time']; + // strip out PHP tags from snippets -if ( strncmp($snippet, "' ) $snippet = substr($snippet, 0, -2); -$snippet = $modx->db->escape($snippet); +if (substr($snippet, -2) == '?>') { + $snippet = substr($snippet, 0, -2); +} + +$snippet = $modx->db->escape($snippet); $properties = $modx->db->escape($_POST['properties']); $moduleguid = $modx->db->escape($_POST['moduleguid']); -$parse_docblock = $_POST['parse_docblock']=="1" ? '1' : '0'; +$parse_docblock = $_POST['parse_docblock'] == "1" ? '1' : '0'; //Kyle Jaebker - added category support if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { @@ -27,28 +37,30 @@ } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { $categoryid = 0; } else { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = checkCategory($_POST['newcategory']); if (!$categoryid) { $categoryid = newCategory($_POST['newcategory']); } } -if($name=="") $name = "Untitled snippet"; +if ($name == "") { + $name = "Untitled snippet"; +} -if($parse_docblock) { - $parsed = $modx->parseDocBlockFromString($snippet, true); - $name = isset($parsed['name']) ? $parsed['name'] : $name; - $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; - $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; +if ($parse_docblock) { + $parsed = $modx->parseDocBlockFromString($snippet, true); + $name = isset($parsed['name']) ? $parsed['name'] : $name; + $properties = isset($parsed['properties']) ? $parsed['properties'] : $properties; + $moduleguid = isset($parsed['guid']) ? $parsed['guid'] : $moduleguid; - $description = isset($parsed['description']) ? $parsed['description'] : $description; - $version = isset($parsed['version']) ? ''.$parsed['version'].' ' : ''; - if($version) { + $description = isset($parsed['description']) ? $parsed['description'] : $description; + $version = isset($parsed['version']) ? '' . $parsed['version'] . ' ' : ''; + if ($version) { $description = $version . trim(preg_replace('/(.+?)+(<\/b>)/i', '', $description)); } - if(isset($parsed['modx_category'])) { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + if (isset($parsed['modx_category'])) { + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = getCategory($parsed['modx_category']); } } @@ -56,108 +68,109 @@ switch ($_POST['mode']) { case '23': // Save new snippet - // invoke OnBeforeSnipFormSave event - $modx->invokeEvent("OnBeforeSnipFormSave", - array( - "mode" => "new", - "id" => $id - )); - - // disallow duplicate names for new snippets - $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(23); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23"); - } - - //do stuff to save the new doc - $newid = $modx->db->insert( - array( - 'name' => $name, - 'description' => $description, - 'snippet' => $snippet, - 'moduleguid' => $moduleguid, - 'locked' => $locked, - 'properties' => $properties, - 'category' => $categoryid, - ), $modx->getFullTableName('site_snippets')); - - // invoke OnSnipFormSave event - $modx->invokeEvent("OnSnipFormSave", - array( - "mode" => "new", - "id" => $newid - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "22&id=$newid":"23"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $header="Location: index.php?a=76&r=2"; - header($header); - } + // invoke OnBeforeSnipFormSave event + $modx->invokeEvent("OnBeforeSnipFormSave", array( + "mode" => "new", + "id" => $id + )); + + // disallow duplicate names for new snippets + $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(23); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=23"); + } + + //do stuff to save the new doc + $newid = $modx->db->insert(array( + 'name' => $name, + 'description' => $description, + 'snippet' => $snippet, + 'moduleguid' => $moduleguid, + 'locked' => $locked, + 'properties' => $properties, + 'category' => $categoryid, + 'disabled' => $disabled, + 'createdon' => $currentdate, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_snippets')); + + // invoke OnSnipFormSave event + $modx->invokeEvent("OnSnipFormSave", array( + "mode" => "new", + "id" => $newid + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "22&id=$newid" : "23"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; case '22': // Save existing snippet - // invoke OnBeforeSnipFormSave event - $modx->invokeEvent("OnBeforeSnipFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // disallow duplicate names for snippets - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'"); - if ($modx->db->getValue($rs) > 0) { - $modx->manager->saveFormValues(22); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}"); - } - - //do stuff to save the edited doc - $modx->db->update( - array( - 'name' => $name, - 'description' => $description, - 'snippet' => $snippet, - 'moduleguid' => $moduleguid, - 'locked' => $locked, - 'properties' => $properties, - 'category' => $categoryid, - ), $modx->getFullTableName('site_snippets'), "id='{$id}'"); - - // invoke OnSnipFormSave event - $modx->invokeEvent("OnSnipFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // Set the item name for logger - $_SESSION['itemname'] = $name; - - // empty cache - $modx->clearCache('full'); - - if($_POST['runsnippet']) run_snippet($snippet); - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "22&id=$id":"23"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $modx->unlockElement(4, $id); - $header="Location: index.php?a=76&r=2"; - header($header); - } + // invoke OnBeforeSnipFormSave event + $modx->invokeEvent("OnBeforeSnipFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // disallow duplicate names for snippets + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_snippets'), "name='{$name}' AND id!='{$id}'"); + if ($modx->db->getValue($rs) > 0) { + $modx->manager->saveFormValues(22); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['snippet'], $name), "index.php?a=22&id={$id}"); + } + + //do stuff to save the edited doc + $modx->db->update(array( + 'name' => $name, + 'description' => $description, + 'snippet' => $snippet, + 'moduleguid' => $moduleguid, + 'locked' => $locked, + 'properties' => $properties, + 'category' => $categoryid, + 'disabled' => $disabled, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_snippets'), "id='{$id}'"); + + // invoke OnSnipFormSave event + $modx->invokeEvent("OnSnipFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // Set the item name for logger + $_SESSION['itemname'] = $name; + + // empty cache + $modx->clearCache('full'); + + if ($_POST['runsnippet']) { + run_snippet($snippet); + } + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "22&id=$id" : "23"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $modx->unlockElement(4, $id); + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; default: - $modx->webAlertAndQuit("No operation set in request."); + $modx->webAlertAndQuit("No operation set in request."); } diff --git a/manager/processors/save_template.processor.php b/manager/processors/save_template.processor.php index bc6c727542..2833116d88 100644 --- a/manager/processors/save_template.processor.php +++ b/manager/processors/save_template.processor.php @@ -1,16 +1,19 @@ -INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); -if(!$modx->hasPermission('save_template')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} +if (!$modx->hasPermission('save_template')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = intval($_POST['id']); $template = $modx->db->escape($_POST['post']); $templatename = $modx->db->escape(trim($_POST['templatename'])); $description = $modx->db->escape($_POST['description']); -$locked = $_POST['locked']=='on' ? 1 : 0 ; +$locked = $_POST['locked'] == 'on' ? 1 : 0; $selectable = $id == $modx->config['default_template'] ? 1 : // Force selectable - $_POST['selectable']=='on' ? 1 : 0; + $_POST['selectable'] == 'on' ? 1 : 0; +$currentdate = time() + $modx->config['server_offset_time']; //Kyle Jaebker - added category support if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { @@ -18,155 +21,158 @@ } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { $categoryid = 0; } else { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = checkCategory($_POST['newcategory']); if (!$categoryid) { $categoryid = newCategory($_POST['newcategory']); } } -if($templatename=="") $templatename = "Untitled template"; +if ($templatename == "") { + $templatename = "Untitled template"; +} switch ($_POST['mode']) { case '19': - - // invoke OnBeforeTempFormSave event - $modx->invokeEvent("OnBeforeTempFormSave", - array( - "mode" => "new", - "id" => $id - )); - - // disallow duplicate names for new templates - $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(19); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); - } - - //do stuff to save the new doc - $newid = $modx->db->insert( - array( - 'templatename' => $templatename, - 'description' => $description, - 'content' => $template, - 'locked' => $locked, - 'selectable' => $selectable, - 'category' => $categoryid, - ), $modx->getFullTableName('site_templates')); - - // invoke OnTempFormSave event - $modx->invokeEvent("OnTempFormSave", - array( - "mode" => "new", - "id" => $newid - )); - // Set new assigned Tvs - saveTemplateAccess($newid); - - // Set the item name for logger - $_SESSION['itemname'] = $templatename; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "16&id=$newid":"19"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $header="Location: index.php?a=76&r=2"; - header($header); - } + + // invoke OnBeforeTempFormSave event + $modx->invokeEvent("OnBeforeTempFormSave", array( + "mode" => "new", + "id" => $id + )); + + // disallow duplicate names for new templates + $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(19); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=19"); + } + + //do stuff to save the new doc + $newid = $modx->db->insert(array( + 'templatename' => $templatename, + 'description' => $description, + 'content' => $template, + 'locked' => $locked, + 'selectable' => $selectable, + 'category' => $categoryid, + 'createdon' => $currentdate, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_templates')); + + // invoke OnTempFormSave event + $modx->invokeEvent("OnTempFormSave", array( + "mode" => "new", + "id" => $newid + )); + // Set new assigned Tvs + saveTemplateAccess($newid); + + // Set the item name for logger + $_SESSION['itemname'] = $templatename; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "16&id=$newid" : "19"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; case '16': - // invoke OnBeforeTempFormSave event - $modx->invokeEvent("OnBeforeTempFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // disallow duplicate names for templates - $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(16); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); - } - - //do stuff to save the edited doc - $modx->db->update( - array( - 'templatename' => $templatename, - 'description' => $description, - 'content' => $template, - 'locked' => $locked, - 'selectable' => $selectable, - 'category' => $categoryid, - ), $modx->getFullTableName('site_templates'), "id='{$id}'"); - // Set new assigned Tvs - saveTemplateAccess($id); - - // invoke OnTempFormSave event - $modx->invokeEvent("OnTempFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // Set the item name for logger - $_SESSION['itemname'] = $templatename; - - // first empty the cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "16&id=$id":"19"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $modx->unlockElement(1, $id); - $header="Location: index.php?a=76&r=2"; - header($header); - } - - + // invoke OnBeforeTempFormSave event + $modx->invokeEvent("OnBeforeTempFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // disallow duplicate names for templates + $rs = $modx->db->select('COUNT(*)', $modx->getFullTableName('site_templates'), "templatename='{$templatename}' AND id!='{$id}'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(16); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['template'], $templatename), "index.php?a=16&id={$id}"); + } + + //do stuff to save the edited doc + $modx->db->update(array( + 'templatename' => $templatename, + 'description' => $description, + 'content' => $template, + 'locked' => $locked, + 'selectable' => $selectable, + 'category' => $categoryid, + 'editedon' => $currentdate + ), $modx->getFullTableName('site_templates'), "id='{$id}'"); + // Set new assigned Tvs + saveTemplateAccess($id); + + // invoke OnTempFormSave event + $modx->invokeEvent("OnTempFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // Set the item name for logger + $_SESSION['itemname'] = $templatename; + + // first empty the cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "16&id=$id" : "19"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $modx->unlockElement(1, $id); + $header = "Location: index.php?a=76&r=2"; + header($header); + } + + break; default: - $modx->webAlertAndQuit("No operation set in request."); + $modx->webAlertAndQuit("No operation set in request."); } -function saveTemplateAccess($id) { +function saveTemplateAccess($id) +{ global $modx; - if ($_POST['tvsDirty'] == 1) { - $newAssignedTvs = $_POST['assignedTv']; - - // Preserve rankings of already assigned TVs - $rs = $modx->db->select( "tmplvarid, rank", $modx->getFullTableName('site_tmplvar_templates'), "templateid='{$id}'", "" ); - - $ranksArr = array(); - $highest = 0; - while($row = $modx->db->getRow($rs)) { - $ranksArr[$row['tmplvarid']] = $row['rank']; - $highest = $highest < $row['rank'] ? $row['rank'] : $highest; - }; - - $modx->db->delete($modx->getFullTableName('site_tmplvar_templates'),"templateid='{$id}'"); - if(empty($newAssignedTvs)) return; - foreach($newAssignedTvs as $tvid){ - if(!$id || !$tvid) continue; // Dont link zeros - $modx->db->insert( - array( - 'templateid' => $id, - 'tmplvarid' => $tvid, - 'rank' => isset($ranksArr[$tvid]) ? $ranksArr[$tvid] : $highest += 1 // append TVs to rank - ), $modx->getFullTableName('site_tmplvar_templates')); - } - } + if ($_POST['tvsDirty'] == 1) { + $newAssignedTvs = $_POST['assignedTv']; + + // Preserve rankings of already assigned TVs + $rs = $modx->db->select("tmplvarid, rank", $modx->getFullTableName('site_tmplvar_templates'), "templateid='{$id}'", ""); + + $ranksArr = array(); + $highest = 0; + while ($row = $modx->db->getRow($rs)) { + $ranksArr[$row['tmplvarid']] = $row['rank']; + $highest = $highest < $row['rank'] ? $row['rank'] : $highest; + }; + + $modx->db->delete($modx->getFullTableName('site_tmplvar_templates'), "templateid='{$id}'"); + if (empty($newAssignedTvs)) { + return; + } + foreach ($newAssignedTvs as $tvid) { + if (!$id || !$tvid) { + continue; + } // Dont link zeros + $modx->db->insert(array( + 'templateid' => $id, + 'tmplvarid' => $tvid, + 'rank' => isset($ranksArr[$tvid]) ? $ranksArr[$tvid] : $highest += 1 // append TVs to rank + ), $modx->getFullTableName('site_tmplvar_templates')); + } + } } diff --git a/manager/processors/save_tmplvars.processor.php b/manager/processors/save_tmplvars.processor.php index e49a408b94..74983969c3 100755 --- a/manager/processors/save_tmplvars.processor.php +++ b/manager/processors/save_tmplvars.processor.php @@ -1,11 +1,13 @@ -INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); -if(!$modx->hasPermission('save_template')) { - $modx->webAlertAndQuit($_lang["error_no_privileges"]); +INCLUDE_ORDERING_ERROR

    Please use the MODX Content Manager instead of accessing this file directly."); +} +if (!$modx->hasPermission('save_template')) { + $modx->webAlertAndQuit($_lang["error_no_privileges"]); } $id = intval($_POST['id']); -$name = $modx->db->escape(trim($_POST['name'])); +$name = $modx->db->escape(trim($_POST['name'])); $description = $modx->db->escape($_POST['description']); $caption = $modx->db->escape($_POST['caption']); $type = $modx->db->escape($_POST['type']); @@ -14,9 +16,10 @@ $rank = isset ($_POST['rank']) ? $modx->db->escape($_POST['rank']) : 0; $display = $modx->db->escape($_POST['display']); $params = $modx->db->escape($_POST['params']); -$locked = $_POST['locked']=='on' ? 1 : 0 ; +$locked = $_POST['locked'] == 'on' ? 1 : 0; $origin = isset($_REQUEST['or']) ? intval($_REQUEST['or']) : 76; -$originId = isset($_REQUEST['oid']) ? intval($_REQUEST['oid']) : NULL; +$originId = isset($_REQUEST['oid']) ? intval($_REQUEST['oid']) : null; +$currentdate = time() + $modx->config['server_offset_time']; //Kyle Jaebker - added category support if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) { @@ -24,7 +27,7 @@ } elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) { $categoryid = 0; } else { - include_once(MODX_MANAGER_PATH.'includes/categories.inc.php'); + include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php'); $categoryid = checkCategory($_POST['newcategory']); if (!$categoryid) { $categoryid = newCategory($_POST['newcategory']); @@ -40,192 +43,192 @@ switch ($_POST['mode']) { case '300': - // invoke OnBeforeTVFormSave event - $modx->invokeEvent("OnBeforeTVFormSave", - array( - "mode" => "new", - "id" => $id - )); - - // disallow duplicate names for new tvs - $rs = $modx->db->select('COUNT(*)', $tbl_site_tmplvars, "name='{$name}'"); - $count = $modx->db->getValue($rs); - if($count > 0) { - $modx->manager->saveFormValues(300); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['tv'], $name), "index.php?a=300"); - } + // invoke OnBeforeTVFormSave event + $modx->invokeEvent("OnBeforeTVFormSave", array( + "mode" => "new", + "id" => $id + )); + + // disallow duplicate names for new tvs + $rs = $modx->db->select('COUNT(*)', $tbl_site_tmplvars, "name='{$name}'"); + $count = $modx->db->getValue($rs); + if ($count > 0) { + $modx->manager->saveFormValues(300); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['tv'], $name), "index.php?a=300"); + } // disallow reserved names - if(in_array($name, 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', 'haskeywords', 'hasmetatags', 'privateweb', 'privatemgr', 'content_dispo', 'hidemenu','alias_visible'))) { - $_POST['name'] = ''; - $modx->manager->saveFormValues(300); - $modx->webAlertAndQuit(sprintf($_lang['reserved_name_warning'], $_lang['tv'], $name), "index.php?a=300"); + if (in_array($name, 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', 'alias_visible'))) { + $_POST['name'] = ''; + $modx->manager->saveFormValues(300); + $modx->webAlertAndQuit(sprintf($_lang['reserved_name_warning'], $_lang['tv'], $name), "index.php?a=300"); } - // Add new TV - $newid = $modx->db->insert( - array( - 'name' => $name, - 'description' => $description, - 'caption' => $caption, - 'type' => $type, - 'elements' => $elements, - 'default_text' => $default_text, - 'display' => $display, - 'display_params' => $params, - 'rank' => $rank, - 'locked' => $locked, - 'category' => $categoryid, - ), $tbl_site_tmplvars); - - // save access permissions - saveTemplateAccess(); - saveDocumentAccessPermissons(); - - // invoke OnTVFormSave event - $modx->invokeEvent("OnTVFormSave", - array( - "mode" => "new", - "id" => $newid - )); - - // Set the item name for logger - $_SESSION['itemname'] = $caption; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "301&id=$newid":"300"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']; - header($header); - } else { - $header="Location: index.php?a=76&r=2"; - header($header); - } + // Add new TV + $newid = $modx->db->insert(array( + 'name' => $name, + 'description' => $description, + 'caption' => $caption, + 'type' => $type, + 'elements' => $elements, + 'default_text' => $default_text, + 'display' => $display, + 'display_params' => $params, + 'rank' => $rank, + 'locked' => $locked, + 'category' => $categoryid, + 'createdon' => $currentdate, + 'editedon' => $currentdate + ), $tbl_site_tmplvars); + + // save access permissions + saveTemplateAccess(); + saveDocumentAccessPermissons(); + + // invoke OnTVFormSave event + $modx->invokeEvent("OnTVFormSave", array( + "mode" => "new", + "id" => $newid + )); + + // Set the item name for logger + $_SESSION['itemname'] = $caption; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "301&id=$newid" : "300"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay']; + header($header); + } else { + $header = "Location: index.php?a=76&r=2"; + header($header); + } break; - case '301': - // invoke OnBeforeTVFormSave event - $modx->invokeEvent("OnBeforeTVFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // disallow duplicate names for tvs - $rs = $modx->db->select('COUNT(*)', $tbl_site_tmplvars, "name='{$name}' AND id!='{$id}'"); - if($modx->db->getValue($rs) > 0) { - $modx->manager->saveFormValues(300); - $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['tv'], $name), "index.php?a=301&id={$id}"); - } - // disallow reserved names - if(in_array($name, 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', 'haskeywords', 'hasmetatags', 'privateweb', 'privatemgr', 'content_dispo', 'hidemenu','alias_visible'))) { - $modx->manager->saveFormValues(300); - $modx->webAlertAndQuit(sprintf($_lang['reserved_name_warning'], $_lang['tv'], $name), "index.php?a=301&id={$id}"); - } - - // update TV - $modx->db->update( - array( - 'name' => $name, - 'description' => $description, - 'caption' => $caption, - 'type' => $type, - 'elements' => $elements, - 'default_text' => $default_text, - 'display' => $display, - 'display_params' => $params, - 'rank' => $rank, - 'locked' => $locked, - 'category' => $categoryid, - ), $tbl_site_tmplvars, "id='{$id}'"); - - // save access permissions - saveTemplateAccess(); - saveDocumentAccessPermissons(); - - // invoke OnTVFormSave event - $modx->invokeEvent("OnTVFormSave", - array( - "mode" => "upd", - "id" => $id - )); - - // Set the item name for logger - $_SESSION['itemname'] = $caption; - - // empty cache - $modx->clearCache('full'); - - // finished emptying cache - redirect - if($_POST['stay']!='') { - $a = ($_POST['stay']=='2') ? "301&id=$id":"300"; - $header="Location: index.php?a=".$a."&r=2&stay=".$_POST['stay']."&or=".$origin."&oid=".$originId; - header($header); - } else { - $modx->unlockElement(2, $id); - $header="Location: index.php?a=".$origin."&r=2".($originId!=NULL?'&id='.$originId:''); - header($header); - } - + case '301': + // invoke OnBeforeTVFormSave event + $modx->invokeEvent("OnBeforeTVFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // disallow duplicate names for tvs + $rs = $modx->db->select('COUNT(*)', $tbl_site_tmplvars, "name='{$name}' AND id!='{$id}'"); + if ($modx->db->getValue($rs) > 0) { + $modx->manager->saveFormValues(300); + $modx->webAlertAndQuit(sprintf($_lang['duplicate_name_found_general'], $_lang['tv'], $name), "index.php?a=301&id={$id}"); + } + // disallow reserved names + if (in_array($name, 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', 'alias_visible'))) { + $modx->manager->saveFormValues(300); + $modx->webAlertAndQuit(sprintf($_lang['reserved_name_warning'], $_lang['tv'], $name), "index.php?a=301&id={$id}"); + } + + // update TV + $modx->db->update(array( + 'name' => $name, + 'description' => $description, + 'caption' => $caption, + 'type' => $type, + 'elements' => $elements, + 'default_text' => $default_text, + 'display' => $display, + 'display_params' => $params, + 'rank' => $rank, + 'locked' => $locked, + 'category' => $categoryid, + 'editedon' => $currentdate + ), $tbl_site_tmplvars, "id='{$id}'"); + + // save access permissions + saveTemplateAccess(); + saveDocumentAccessPermissons(); + + // invoke OnTVFormSave event + $modx->invokeEvent("OnTVFormSave", array( + "mode" => "upd", + "id" => $id + )); + + // Set the item name for logger + $_SESSION['itemname'] = $caption; + + // empty cache + $modx->clearCache('full'); + + // finished emptying cache - redirect + if ($_POST['stay'] != '') { + $a = ($_POST['stay'] == '2') ? "301&id=$id" : "300"; + $header = "Location: index.php?a=" . $a . "&r=2&stay=" . $_POST['stay'] . "&or=" . $origin . "&oid=" . $originId; + header($header); + } else { + $modx->unlockElement(2, $id); + $header = "Location: index.php?a=" . $origin . "&r=2" . ($originId != null ? '&id=' . $originId : ''); + header($header); + } + break; default: - $modx->webAlertAndQuit("No operation set in request."); + $modx->webAlertAndQuit("No operation set in request."); } -function saveTemplateAccess() { - global $id,$newid; - global $modx; +function saveTemplateAccess() +{ + global $id, $newid; + global $modx; + + if ($newid) { + $id = $newid; + } + $templates = $_POST['template']; // get muli-templates based on S.BRENNAN mod + + // update template selections + $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates'); - if($newid) $id = $newid; - $templates = $_POST['template']; // get muli-templates based on S.BRENNAN mod - - // update template selections - $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_templates'); - $getRankArray = array(); $getRank = $modx->db->select("templateid, rank", $tbl_site_tmplvar_templates, "tmplvarid='{$id}'"); - while( $row = $modx->db->getRow( $getRank ) ) { - $getRankArray[$row['templateid']] = $row['rank']; + while ($row = $modx->db->getRow($getRank)) { + $getRankArray[$row['templateid']] = $row['rank']; + } + + + $modx->db->delete($tbl_site_tmplvar_templates, "tmplvarid = '{$id}'"); + for ($i = 0; $i < count($templates); $i++) { + $setRank = ($getRankArray[$templates[$i]]) ? $getRankArray[$templates[$i]] : 0; + $modx->db->insert(array( + 'tmplvarid' => $id, + 'templateid' => $templates[$i], + 'rank' => $setRank, + ), $tbl_site_tmplvar_templates); } - - - $modx->db->delete($tbl_site_tmplvar_templates, "tmplvarid = '{$id}'"); - for($i=0;$idb->insert( - array( - 'tmplvarid' => $id, - 'templateid' => $templates[$i], - 'rank' => $setRank, - ), $tbl_site_tmplvar_templates); - } } -function saveDocumentAccessPermissons(){ - global $id,$newid; - global $modx,$use_udperms; - - $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_access'); - - if($newid) $id = $newid; - $docgroups = $_POST['docgroups']; - - // check for permission update access - if($use_udperms==1) { - // delete old permissions on the tv - $modx->db->delete($tbl_site_tmplvar_templates, "tmplvarid='{$id}'"); - if(is_array($docgroups)) { - foreach ($docgroups as $value) { - $modx->db->insert( - array( - 'tmplvarid' => $id, - 'documentgroup' => stripslashes($value), - ), $tbl_site_tmplvar_templates); - } - } - } +function saveDocumentAccessPermissons() +{ + global $id, $newid; + global $modx, $use_udperms; + + $tbl_site_tmplvar_templates = $modx->getFullTableName('site_tmplvar_access'); + + if ($newid) { + $id = $newid; + } + $docgroups = $_POST['docgroups']; + + // check for permission update access + if ($use_udperms == 1) { + // delete old permissions on the tv + $modx->db->delete($tbl_site_tmplvar_templates, "tmplvarid='{$id}'"); + if (is_array($docgroups)) { + foreach ($docgroups as $value) { + $modx->db->insert(array( + 'tmplvarid' => $id, + 'documentgroup' => stripslashes($value), + ), $tbl_site_tmplvar_templates); + } + } + } } -?> \ No newline at end of file diff --git a/manager/processors/save_web_user.processor.php b/manager/processors/save_web_user.processor.php index b0712c90b1..c87034a0c1 100644 --- a/manager/processors/save_web_user.processor.php +++ b/manager/processors/save_web_user.processor.php @@ -108,22 +108,6 @@ // Save User Settings saveUserSettings($internalKey); - // invoke OnWebSaveUser event - $modx->invokeEvent("OnWebSaveUser", array( - "mode" => "new", - "userid" => $internalKey, - "username" => $newusername, - "userpassword" => $newpassword, - "useremail" => $email, - "userfullname" => $fullname - )); - - // invoke OnWUsrFormSave event - $modx->invokeEvent("OnWUsrFormSave", array( - "mode" => "new", - "id" => $internalKey - )); - // Set the item name for logger $_SESSION['itemname'] = $newusername; @@ -142,6 +126,22 @@ } // end of user_groups stuff! + // invoke OnWebSaveUser event + $modx->invokeEvent("OnWebSaveUser", array( + "mode" => "new", + "userid" => $internalKey, + "username" => $newusername, + "userpassword" => $newpassword, + "useremail" => $email, + "userfullname" => $fullname + )); + + // invoke OnWUsrFormSave event + $modx->invokeEvent("OnWUsrFormSave", array( + "mode" => "new", + "id" => $internalKey + )); + if($passwordnotifymethod == 'e') { sendMailMessage($email, $newusername, $newpassword, $fullname); if($input['stay'] != '') { @@ -244,33 +244,6 @@ // Set the item name for logger $_SESSION['itemname'] = $newusername; - // invoke OnWebSaveUser event - $modx->invokeEvent("OnWebSaveUser", array( - "mode" => "upd", - "userid" => $id, - "username" => $newusername, - "userpassword" => $newpassword, - "useremail" => $email, - "userfullname" => $fullname, - "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), - "olduseremail" => (($oldemail != $email) ? $oldemail : "") - )); - - // invoke OnWebChangePassword event - if($genpassword == 1) { - $modx->invokeEvent("OnWebChangePassword", array( - "userid" => $id, - "username" => $newusername, - "userpassword" => $newpassword - )); - } - - // invoke OnWUsrFormSave event - $modx->invokeEvent("OnWUsrFormSave", array( - "mode" => "upd", - "id" => $id - )); - /*******************************************************************************/ // put the user in the user_groups he/ she should be in // first, check that up_perms are switched on! @@ -289,6 +262,33 @@ // end of user_groups stuff! /*******************************************************************************/ + // invoke OnWebSaveUser event + $modx->invokeEvent("OnWebSaveUser", array( + "mode" => "upd", + "userid" => $id, + "username" => $newusername, + "userpassword" => $newpassword, + "useremail" => $email, + "userfullname" => $fullname, + "oldusername" => (($oldusername != $newusername) ? $oldusername : ""), + "olduseremail" => (($oldemail != $email) ? $oldemail : "") + )); + + // invoke OnWebChangePassword event + if($genpassword == 1) { + $modx->invokeEvent("OnWebChangePassword", array( + "userid" => $id, + "username" => $newusername, + "userpassword" => $newpassword + )); + } + + // invoke OnWUsrFormSave event + $modx->invokeEvent("OnWUsrFormSave", array( + "mode" => "upd", + "id" => $id + )); + if($genpassword == 1 && $passwordnotifymethod == 's') { if($input['stay'] != '') { $a = ($input['stay'] == '2') ? "88&id={$id}" : "87"; diff --git a/manager/processors/undelete_content.processor.php b/manager/processors/undelete_content.processor.php index 32b12e7dc0..c9d4adc725 100644 --- a/manager/processors/undelete_content.processor.php +++ b/manager/processors/undelete_content.processor.php @@ -75,13 +75,19 @@ function getChildren($parent) { 'deletedon' => 0, ), $modx->getFullTableName('site_content'), "id='{$id}'"); - // Set the item name for logger - $_SESSION['itemname'] = $content['pagetitle']; +$modx->invokeEvent("OnDocFormUnDelete", + array( + "id"=>$id, + "children"=>$children + )); - // empty cache - $modx->clearCache('full'); +// Set the item name for logger +$_SESSION['itemname'] = $content['pagetitle']; - // finished emptying cache - redirect - $header="Location: index.php?a=3&id=$pid&r=1".$add_path; - header($header); +// empty cache +$modx->clearCache('full'); + +// finished emptying cache - redirect +$header="Location: index.php?a=3&id=$pid&r=1".$add_path; +header($header); ?> \ No newline at end of file