preserved.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. <?php return array (
  2. 'cf1ffbc0d08d65667a1338cc666f85b9' =>
  3. array (
  4. 'criteria' =>
  5. array (
  6. 'name' => 'upgrademodx',
  7. ),
  8. 'object' =>
  9. array (
  10. 'name' => 'upgrademodx',
  11. 'path' => '{core_path}components/upgrademodx/',
  12. 'assets_path' => '{assets_path}components/upgrademodx/',
  13. ),
  14. ),
  15. 'fa5bf96394c881bfc1d16b348e9ff20d' =>
  16. array (
  17. 'criteria' =>
  18. array (
  19. 'key' => 'ugm_verbose',
  20. ),
  21. 'object' =>
  22. array (
  23. 'key' => 'ugm_verbose',
  24. 'value' => '1',
  25. 'xtype' => 'combo-boolean',
  26. 'namespace' => 'upgrademodx',
  27. 'area' => 'GitHub',
  28. 'editedon' => '2019-01-16 14:42:23',
  29. ),
  30. ),
  31. 'dd58afda7eaddb1778700fadf9ef2ab5' =>
  32. array (
  33. 'criteria' =>
  34. array (
  35. 'key' => 'ugm_versionlist_api_url',
  36. ),
  37. 'object' =>
  38. array (
  39. 'key' => 'ugm_versionlist_api_url',
  40. 'value' => '//api.github.com/repos/modxcms/revolution/tags',
  41. 'xtype' => 'textfield',
  42. 'namespace' => 'upgrademodx',
  43. 'area' => 'Widget',
  44. 'editedon' => NULL,
  45. ),
  46. ),
  47. '4796fe12c0192320d81fef3462ae0a8a' =>
  48. array (
  49. 'criteria' =>
  50. array (
  51. 'key' => 'ugm_temp_dir',
  52. ),
  53. 'object' =>
  54. array (
  55. 'key' => 'ugm_temp_dir',
  56. 'value' => '{base_path}ugmtemp/',
  57. 'xtype' => 'textfield',
  58. 'namespace' => 'upgrademodx',
  59. 'area' => 'Widget',
  60. 'editedon' => NULL,
  61. ),
  62. ),
  63. '6c48d2b4c21cb2e299dc13819cc62f54' =>
  64. array (
  65. 'criteria' =>
  66. array (
  67. 'key' => 'ugm_cert_path',
  68. ),
  69. 'object' =>
  70. array (
  71. 'key' => 'ugm_cert_path',
  72. 'value' => '',
  73. 'xtype' => 'textfield',
  74. 'namespace' => 'upgrademodx',
  75. 'area' => 'GitHub',
  76. 'editedon' => NULL,
  77. ),
  78. ),
  79. 'a6aa30ad1045aea4fc1881bf45e85019' =>
  80. array (
  81. 'criteria' =>
  82. array (
  83. 'key' => 'ugm_file_version',
  84. ),
  85. 'object' =>
  86. array (
  87. 'key' => 'ugm_file_version',
  88. 'value' => '',
  89. 'xtype' => 'textfield',
  90. 'namespace' => 'upgrademodx',
  91. 'area' => 'Widget',
  92. 'editedon' => NULL,
  93. ),
  94. ),
  95. 'ceba60a930ab9b8fa6005ae5080d23f3' =>
  96. array (
  97. 'criteria' =>
  98. array (
  99. 'key' => 'ugm_force_pcl_zip',
  100. ),
  101. 'object' =>
  102. array (
  103. 'key' => 'ugm_force_pcl_zip',
  104. 'value' => '0',
  105. 'xtype' => 'combo-boolean',
  106. 'namespace' => 'upgrademodx',
  107. 'area' => 'Download',
  108. 'editedon' => NULL,
  109. ),
  110. ),
  111. '67fbc94224b00bd3e30bed096e2e92dc' =>
  112. array (
  113. 'criteria' =>
  114. array (
  115. 'key' => 'ugm_modx_timeout',
  116. ),
  117. 'object' =>
  118. array (
  119. 'key' => 'ugm_modx_timeout',
  120. 'value' => '6',
  121. 'xtype' => 'textfield',
  122. 'namespace' => 'upgrademodx',
  123. 'area' => 'Download',
  124. 'editedon' => NULL,
  125. ),
  126. ),
  127. '5c186deeee7fb6957dd2f5dbb731b2f9' =>
  128. array (
  129. 'criteria' =>
  130. array (
  131. 'key' => 'ugm_ssl_verify_peer',
  132. ),
  133. 'object' =>
  134. array (
  135. 'key' => 'ugm_ssl_verify_peer',
  136. 'value' => '0',
  137. 'xtype' => 'combo-boolean',
  138. 'namespace' => 'upgrademodx',
  139. 'area' => 'Download',
  140. 'editedon' => '2019-01-09 12:19:58',
  141. ),
  142. ),
  143. 'fec373d24443729a5661471e57a58851' =>
  144. array (
  145. 'criteria' =>
  146. array (
  147. 'key' => 'ugm_language',
  148. ),
  149. 'object' =>
  150. array (
  151. 'key' => 'ugm_language',
  152. 'value' => 'en',
  153. 'xtype' => 'textfield',
  154. 'namespace' => 'upgrademodx',
  155. 'area' => 'Form',
  156. 'editedon' => NULL,
  157. ),
  158. ),
  159. '837b94550ee6fe63d5e38b0b2486f374' =>
  160. array (
  161. 'criteria' =>
  162. array (
  163. 'key' => 'ugm_pl_only',
  164. ),
  165. 'object' =>
  166. array (
  167. 'key' => 'ugm_pl_only',
  168. 'value' => '1',
  169. 'xtype' => 'combo-boolean',
  170. 'namespace' => 'upgrademodx',
  171. 'area' => 'Form',
  172. 'editedon' => NULL,
  173. ),
  174. ),
  175. '66d0c6907c42a6c3d400bd75017d2a35' =>
  176. array (
  177. 'criteria' =>
  178. array (
  179. 'key' => 'ugm_github_username',
  180. ),
  181. 'object' =>
  182. array (
  183. 'key' => 'ugm_github_username',
  184. 'value' => '',
  185. 'xtype' => 'textfield',
  186. 'namespace' => 'upgrademodx',
  187. 'area' => 'GitHub',
  188. 'editedon' => '2019-01-16 14:47:38',
  189. ),
  190. ),
  191. '873c90b97eec6840ba3bac13fced36fe' =>
  192. array (
  193. 'criteria' =>
  194. array (
  195. 'key' => 'ugm_github_token',
  196. ),
  197. 'object' =>
  198. array (
  199. 'key' => 'ugm_github_token',
  200. 'value' => '',
  201. 'xtype' => 'textfield',
  202. 'namespace' => 'upgrademodx',
  203. 'area' => 'GitHub',
  204. 'editedon' => '2019-01-16 14:47:35',
  205. ),
  206. ),
  207. 'ea24bb9594824c5dc0f2d2ec9d881f39' =>
  208. array (
  209. 'criteria' =>
  210. array (
  211. 'key' => 'ugm_github_timeout',
  212. ),
  213. 'object' =>
  214. array (
  215. 'key' => 'ugm_github_timeout',
  216. 'value' => '6',
  217. 'xtype' => 'textfield',
  218. 'namespace' => 'upgrademodx',
  219. 'area' => 'GitHub',
  220. 'editedon' => NULL,
  221. ),
  222. ),
  223. '7044de863da29f9c729548abaf70b3b6' =>
  224. array (
  225. 'criteria' =>
  226. array (
  227. 'key' => 'ugm_versions_to_show',
  228. ),
  229. 'object' =>
  230. array (
  231. 'key' => 'ugm_versions_to_show',
  232. 'value' => '5',
  233. 'xtype' => 'textfield',
  234. 'namespace' => 'upgrademodx',
  235. 'area' => 'Form',
  236. 'editedon' => NULL,
  237. ),
  238. ),
  239. '3c9479116c58e5aadcd4eca66259dbca' =>
  240. array (
  241. 'criteria' =>
  242. array (
  243. 'key' => 'ugm_groups',
  244. ),
  245. 'object' =>
  246. array (
  247. 'key' => 'ugm_groups',
  248. 'value' => 'Administrator',
  249. 'xtype' => 'textfield',
  250. 'namespace' => 'upgrademodx',
  251. 'area' => 'Security',
  252. 'editedon' => NULL,
  253. ),
  254. ),
  255. '375ee837f936b7b6a0792813ffcba157' =>
  256. array (
  257. 'criteria' =>
  258. array (
  259. 'key' => 'ugm_interval',
  260. ),
  261. 'object' =>
  262. array (
  263. 'key' => 'ugm_interval',
  264. 'value' => '1 hour',
  265. 'xtype' => 'textfield',
  266. 'namespace' => 'upgrademodx',
  267. 'area' => 'Widget',
  268. 'editedon' => '2019-01-16 14:35:22',
  269. ),
  270. ),
  271. '642c901f2aa3a6ee3ef914dbf78e4a63' =>
  272. array (
  273. 'criteria' =>
  274. array (
  275. 'key' => 'ugm_last_check',
  276. ),
  277. 'object' =>
  278. array (
  279. 'key' => 'ugm_last_check',
  280. 'value' => '2019-01-16 14:42:31',
  281. 'xtype' => 'textfield',
  282. 'namespace' => 'upgrademodx',
  283. 'area' => 'Widget',
  284. 'editedon' => '2019-01-16 14:42:31',
  285. ),
  286. ),
  287. 'ad783e06b01c5806537bcd56f4e58cb2' =>
  288. array (
  289. 'criteria' =>
  290. array (
  291. 'key' => 'ugm_latest_version',
  292. ),
  293. 'object' =>
  294. array (
  295. 'key' => 'ugm_latest_version',
  296. 'value' => '',
  297. 'xtype' => 'textfield',
  298. 'namespace' => 'upgrademodx',
  299. 'area' => 'Widget',
  300. 'editedon' => '2018-11-11 20:39:27',
  301. ),
  302. ),
  303. 'b3f83ba974e3e9fc265a41e6ca5f2171' =>
  304. array (
  305. 'criteria' =>
  306. array (
  307. 'key' => 'ugm_hide_when_no_upgrade',
  308. ),
  309. 'object' =>
  310. array (
  311. 'key' => 'ugm_hide_when_no_upgrade',
  312. 'value' => '0',
  313. 'xtype' => 'combo-boolean',
  314. 'namespace' => 'upgrademodx',
  315. 'area' => 'Widget',
  316. 'editedon' => '2019-01-09 12:22:52',
  317. ),
  318. ),
  319. 'e6511b2d991103ccd186bbb3f06b44f1' =>
  320. array (
  321. 'criteria' =>
  322. array (
  323. 'key' => 'ugm_version_list_path',
  324. ),
  325. 'object' =>
  326. array (
  327. 'key' => 'ugm_version_list_path',
  328. 'value' => '{core_path}cache/upgrademodx/',
  329. 'xtype' => 'textfield',
  330. 'namespace' => 'upgrademodx',
  331. 'area' => 'Widget',
  332. 'editedon' => NULL,
  333. ),
  334. ),
  335. '93d5c9e8b3de922ca1551fd849fd0546' =>
  336. array (
  337. 'criteria' =>
  338. array (
  339. 'name' => 'Upgrade MODX',
  340. ),
  341. 'object' =>
  342. array (
  343. 'id' => 7,
  344. 'name' => 'Upgrade MODX',
  345. 'description' => 'Upgrade MODX Widget',
  346. 'type' => 'snippet',
  347. 'content' => 'UpgradeMODXWidget',
  348. 'namespace' => 'upgrademodx',
  349. 'lexicon' => 'upgrademodx:default',
  350. 'size' => 'half',
  351. 'name_trans' => 'Upgrade MODX',
  352. 'description_trans' => 'Upgrade MODX Widget',
  353. ),
  354. ),
  355. 'be905b2e7814eb80b8bac56f674d1c97' =>
  356. array (
  357. 'criteria' =>
  358. array (
  359. 'category' => 'UpgradeMODX',
  360. ),
  361. 'object' =>
  362. array (
  363. 'id' => 17,
  364. 'parent' => 0,
  365. 'category' => 'UpgradeMODX',
  366. 'rank' => 0,
  367. ),
  368. ),
  369. 'e91af180a87f45e65e06191756cd359f' =>
  370. array (
  371. 'criteria' =>
  372. array (
  373. 'name' => 'UpgradeMODXTpl',
  374. ),
  375. 'object' =>
  376. array (
  377. 'id' => 55,
  378. 'source' => 0,
  379. 'property_preprocess' => 0,
  380. 'name' => 'UpgradeMODXTpl',
  381. 'description' => 'Tpl chunk for alert widget',
  382. 'editor_type' => 0,
  383. 'category' => 17,
  384. 'cache_type' => 0,
  385. 'snippet' => '<div id="Upgrade_modx">
  386. <h3 style="color:[[+ugm_notice_color]]">[[+ugm_notice]]</h3>
  387. <br/>[[+ugm_current_version_caption]]: [[+ugm_current_version]]
  388. <br/>[[+ugm_latest_version_caption]]: [[+ugm_latest_version]]
  389. [[+ugm_version_form]]
  390. <div id="ugm_errors">[[+ugm_errors]]</div>
  391. </div>
  392. <script src="[[+ugm_assets_url]]js/classie.js"></script>
  393. <script src="[[+ugm_assets_url]]js/progressButton.js"></script>
  394. <script src="[[+ugm_assets_url]]js/ugm-bottom.js"></script>
  395. <p>&nbsp;</p>
  396. ',
  397. 'locked' => 0,
  398. 'properties' => 'a:0:{}',
  399. 'static' => 0,
  400. 'static_file' => '',
  401. 'content' => '<div id="Upgrade_modx">
  402. <h3 style="color:[[+ugm_notice_color]]">[[+ugm_notice]]</h3>
  403. <br/>[[+ugm_current_version_caption]]: [[+ugm_current_version]]
  404. <br/>[[+ugm_latest_version_caption]]: [[+ugm_latest_version]]
  405. [[+ugm_version_form]]
  406. <div id="ugm_errors">[[+ugm_errors]]</div>
  407. </div>
  408. <script src="[[+ugm_assets_url]]js/classie.js"></script>
  409. <script src="[[+ugm_assets_url]]js/progressButton.js"></script>
  410. <script src="[[+ugm_assets_url]]js/ugm-bottom.js"></script>
  411. <p>&nbsp;</p>
  412. ',
  413. ),
  414. ),
  415. 'ed07d9bb8ee2fe68fff664cc91088ceb' =>
  416. array (
  417. 'criteria' =>
  418. array (
  419. 'name' => 'UpgradeMODXWidget',
  420. ),
  421. 'object' =>
  422. array (
  423. 'id' => 49,
  424. 'source' => 0,
  425. 'property_preprocess' => 0,
  426. 'name' => 'UpgradeMODXWidget',
  427. 'description' => 'Upgrade MODX Dashboard widget',
  428. 'editor_type' => 0,
  429. 'category' => 17,
  430. 'cache_type' => 0,
  431. 'snippet' => '/**
  432. * UpgradeMODXWidget snippet for UpgradeMODX extra
  433. *
  434. * Copyright 2015-2018 Bob Ray <https://bobsguides.com>
  435. * Created on 08-16-2015
  436. *
  437. * UpgradeMODX is free software; you can redistribute it and/or modify it under the
  438. * terms of the GNU General Public License as published by the Free Software
  439. * Foundation; either version 2 of the License, or (at your option) any later
  440. * version.
  441. *
  442. * UpgradeMODX is distributed in the hope that it will be useful, but WITHOUT ANY
  443. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  444. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  445. *
  446. * You should have received a copy of the GNU General Public License along with
  447. * UpgradeMODX; if not, write to the Free Software Foundation, Inc., 59 Temple
  448. * Place, Suite 330, Boston, MA 02111-1307 USA
  449. *
  450. * @package upgrademodx
  451. */
  452. /**
  453. * Description
  454. * -----------
  455. * UpgradeMODX Dashboard widget
  456. * This package was inspired by the work of a number of people and I have borrowed some of their code.
  457. * Dmytro Lukianenko (dmi3yy) is the original author of the MODX install script. Susan Sottwell, Sharapov,
  458. * Bumkaka, Inreti, Zaigham Rana, frischnetz, and AgelxNash, also contributed and I\'d like to thank all
  459. * of them for laying the groundwork.
  460. *
  461. * Variables
  462. * ---------
  463. * @var $modx modX
  464. * @var $scriptProperties array
  465. *
  466. * @package upgrademodx
  467. **/
  468. /* Properties
  469. * @property &groups textfield -- group, or comma-separated list of groups, who will see the widget; Default: (empty)..
  470. * @property &hideWhenNoUpgrade combo-boolean -- Hide widget when no upgrade is available; Default: No.
  471. * @property &interval textfield -- Interval between checks -- Examples: 1 week, 3 days, 6 hours; Default: 1 week.
  472. * @property &language textfield -- Two-letter code of language to user; Default: en.
  473. * @property &lastCheck textfield -- Date and time of last check -- set automatically; Default: (empty)..
  474. * @property &latestVersion textfield -- Latest version (at last check) -- set automatically; Default: (empty)..
  475. * @property &plOnly combo-boolean -- Show only pl (stable) versions; Default: yes.
  476. * @property &versionsToShow textfield -- Number of versions to show in upgrade form (not widget); Default: 5.
  477. */
  478. /* Initialize */
  479. /* This will execute when in MODX */
  480. $language = $modx->getOption(\'ugm_language\', null, $modx->getOption(\'manager_language\'), true);
  481. $language = empty($language) ? \'en\' : $language;
  482. $props = $scriptProperties;
  483. $modx->lexicon->load($language . \':upgrademodx:default\');
  484. $devMode = $modx->getOption(\'ugm.devMode\', null, false, true);
  485. $groups = $modx->getOption(\'ugm_groups\', null, \'Administrator\', true);
  486. /* Return empty string if user shouldn\'t see widget */
  487. if (strpos($groups, \',\') !== false) {
  488. $groups = explode(\',\', $groups);
  489. }
  490. if (! $modx->user->isMember($groups)) {
  491. return \'\';
  492. }
  493. $corePath = $modx->getOption(\'ugm.core_path\', null, $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/upgrademodx/\');
  494. $assetsUrl = $modx->getOption(\'ugm.assets_url\', null, $modx->getOption(\'assets_url\', null, MODX_ASSETS_URL) . \'components/upgrademodx/\');
  495. require_once($corePath . \'model/upgrademodx/upgrademodx.class.php\');
  496. $upgrade = new UpgradeMODX($modx);
  497. $upgrade->init();
  498. $props[\'ugm_setup_url\'] = MODX_SITE_URL . \'setup/index.php\';
  499. unset($props[\'controller\']); // remove trash from scriptProperties
  500. $modx->regClientStartupScript(\'<script>
  501. var ugmConnectorUrl = "\' . $assetsUrl . \'connector.php";
  502. var ugm_config = \' . $modx->toJSON($props) . \';
  503. var ugm_setup_url = "\' . MODX_SITE_URL . \'setup/index.php";
  504. </script>\'
  505. );
  506. $modx->regClientCSS($assetsUrl . \'css/progress.css\');
  507. $modx->regClientStartupScript("//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js");
  508. $modx->regClientStartupScript($assetsUrl . \'js/modernizr.custom.js\');
  509. $hideWhenNoUpgrade = $modx->getOption(\'ugm_hide_when_no_upgrade\', null, false, true);
  510. $settingsVersion = $modx->getOption(\'settings_version\');
  511. /* Set Placeholders */
  512. $placeholders = array();
  513. $placeholders[\'[[+ugm_assets_url]]\'] = $assetsUrl;
  514. $placeholders[\'[[+ugm_current_version]]\'] = $settingsVersion;
  515. $placeholders[\'[[+ugm_current_version_caption]]\'] = $modx->lexicon(\'ugm_current_version_caption\');
  516. $placeholders[\'[[+ugm_latest_version_caption]]\'] = $modx->lexicon(\'ugm_latest_version_caption\');
  517. $upgradeAvailable = $upgrade->upgradeAvailable($settingsVersion);
  518. $placeholders[\'[[+ugm_latest_version]]\'] = $upgrade->getLatestVersion();
  519. if ($devMode) {
  520. $upgradeAvailable = true;
  521. }
  522. if ($upgradeAvailable) {
  523. $versionForm = $upgrade->createVersionForm($modx);
  524. }
  525. $errors = $upgrade->getErrors();
  526. if (!empty($errors)) {
  527. $msg = \'\';
  528. foreach ($errors as $error) {
  529. $msg .= \'<br/><span style="color:red">\' . $modx->lexicon(\'ugm_error\') .
  530. \': \' . $error . \'</span>\';
  531. }
  532. return $msg;
  533. }
  534. /* Process */
  535. /* See if there\'s a new version */
  536. if ($upgradeAvailable) {
  537. $placeholders[\'[[+ugm_notice]]\'] = $modx->lexicon(\'ugm_upgrade_available\');
  538. $placeholders[\'[[+ugm_notice_color]]\'] = \'green\';
  539. $placeholders[\'[[+ugm_version_form]]\'] = $versionForm;
  540. } else {
  541. if ($hideWhenNoUpgrade) {
  542. return \'\';
  543. } else {
  544. $placeholders[\'[[+ugm_notice]]\'] = $modx->lexicon(\'ugm_modx_up_to_date\');
  545. $placeholders[\'[[+ugm_notice_color]]\'] = \'gray\';
  546. }
  547. }
  548. /* Get Tpl */
  549. $tpl = $modx->getChunk(\'UpgradeMODXTpl\');
  550. /* Do the replacements */
  551. $tpl = str_replace(array_keys($placeholders), array_values($placeholders), $tpl);
  552. /*if (php_sapi_name() === \'cli\') {
  553. echo $tpl;
  554. }*/
  555. return $tpl;',
  556. 'locked' => 0,
  557. 'properties' => 'a:0:{}',
  558. 'moduleguid' => '',
  559. 'static' => 0,
  560. 'static_file' => '',
  561. 'content' => '/**
  562. * UpgradeMODXWidget snippet for UpgradeMODX extra
  563. *
  564. * Copyright 2015-2018 Bob Ray <https://bobsguides.com>
  565. * Created on 08-16-2015
  566. *
  567. * UpgradeMODX is free software; you can redistribute it and/or modify it under the
  568. * terms of the GNU General Public License as published by the Free Software
  569. * Foundation; either version 2 of the License, or (at your option) any later
  570. * version.
  571. *
  572. * UpgradeMODX is distributed in the hope that it will be useful, but WITHOUT ANY
  573. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  574. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  575. *
  576. * You should have received a copy of the GNU General Public License along with
  577. * UpgradeMODX; if not, write to the Free Software Foundation, Inc., 59 Temple
  578. * Place, Suite 330, Boston, MA 02111-1307 USA
  579. *
  580. * @package upgrademodx
  581. */
  582. /**
  583. * Description
  584. * -----------
  585. * UpgradeMODX Dashboard widget
  586. * This package was inspired by the work of a number of people and I have borrowed some of their code.
  587. * Dmytro Lukianenko (dmi3yy) is the original author of the MODX install script. Susan Sottwell, Sharapov,
  588. * Bumkaka, Inreti, Zaigham Rana, frischnetz, and AgelxNash, also contributed and I\'d like to thank all
  589. * of them for laying the groundwork.
  590. *
  591. * Variables
  592. * ---------
  593. * @var $modx modX
  594. * @var $scriptProperties array
  595. *
  596. * @package upgrademodx
  597. **/
  598. /* Properties
  599. * @property &groups textfield -- group, or comma-separated list of groups, who will see the widget; Default: (empty)..
  600. * @property &hideWhenNoUpgrade combo-boolean -- Hide widget when no upgrade is available; Default: No.
  601. * @property &interval textfield -- Interval between checks -- Examples: 1 week, 3 days, 6 hours; Default: 1 week.
  602. * @property &language textfield -- Two-letter code of language to user; Default: en.
  603. * @property &lastCheck textfield -- Date and time of last check -- set automatically; Default: (empty)..
  604. * @property &latestVersion textfield -- Latest version (at last check) -- set automatically; Default: (empty)..
  605. * @property &plOnly combo-boolean -- Show only pl (stable) versions; Default: yes.
  606. * @property &versionsToShow textfield -- Number of versions to show in upgrade form (not widget); Default: 5.
  607. */
  608. /* Initialize */
  609. /* This will execute when in MODX */
  610. $language = $modx->getOption(\'ugm_language\', null, $modx->getOption(\'manager_language\'), true);
  611. $language = empty($language) ? \'en\' : $language;
  612. $props = $scriptProperties;
  613. $modx->lexicon->load($language . \':upgrademodx:default\');
  614. $devMode = $modx->getOption(\'ugm.devMode\', null, false, true);
  615. $groups = $modx->getOption(\'ugm_groups\', null, \'Administrator\', true);
  616. /* Return empty string if user shouldn\'t see widget */
  617. if (strpos($groups, \',\') !== false) {
  618. $groups = explode(\',\', $groups);
  619. }
  620. if (! $modx->user->isMember($groups)) {
  621. return \'\';
  622. }
  623. $corePath = $modx->getOption(\'ugm.core_path\', null, $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/upgrademodx/\');
  624. $assetsUrl = $modx->getOption(\'ugm.assets_url\', null, $modx->getOption(\'assets_url\', null, MODX_ASSETS_URL) . \'components/upgrademodx/\');
  625. require_once($corePath . \'model/upgrademodx/upgrademodx.class.php\');
  626. $upgrade = new UpgradeMODX($modx);
  627. $upgrade->init();
  628. $props[\'ugm_setup_url\'] = MODX_SITE_URL . \'setup/index.php\';
  629. unset($props[\'controller\']); // remove trash from scriptProperties
  630. $modx->regClientStartupScript(\'<script>
  631. var ugmConnectorUrl = "\' . $assetsUrl . \'connector.php";
  632. var ugm_config = \' . $modx->toJSON($props) . \';
  633. var ugm_setup_url = "\' . MODX_SITE_URL . \'setup/index.php";
  634. </script>\'
  635. );
  636. $modx->regClientCSS($assetsUrl . \'css/progress.css\');
  637. $modx->regClientStartupScript("//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js");
  638. $modx->regClientStartupScript($assetsUrl . \'js/modernizr.custom.js\');
  639. $hideWhenNoUpgrade = $modx->getOption(\'ugm_hide_when_no_upgrade\', null, false, true);
  640. $settingsVersion = $modx->getOption(\'settings_version\');
  641. /* Set Placeholders */
  642. $placeholders = array();
  643. $placeholders[\'[[+ugm_assets_url]]\'] = $assetsUrl;
  644. $placeholders[\'[[+ugm_current_version]]\'] = $settingsVersion;
  645. $placeholders[\'[[+ugm_current_version_caption]]\'] = $modx->lexicon(\'ugm_current_version_caption\');
  646. $placeholders[\'[[+ugm_latest_version_caption]]\'] = $modx->lexicon(\'ugm_latest_version_caption\');
  647. $upgradeAvailable = $upgrade->upgradeAvailable($settingsVersion);
  648. $placeholders[\'[[+ugm_latest_version]]\'] = $upgrade->getLatestVersion();
  649. if ($devMode) {
  650. $upgradeAvailable = true;
  651. }
  652. if ($upgradeAvailable) {
  653. $versionForm = $upgrade->createVersionForm($modx);
  654. }
  655. $errors = $upgrade->getErrors();
  656. if (!empty($errors)) {
  657. $msg = \'\';
  658. foreach ($errors as $error) {
  659. $msg .= \'<br/><span style="color:red">\' . $modx->lexicon(\'ugm_error\') .
  660. \': \' . $error . \'</span>\';
  661. }
  662. return $msg;
  663. }
  664. /* Process */
  665. /* See if there\'s a new version */
  666. if ($upgradeAvailable) {
  667. $placeholders[\'[[+ugm_notice]]\'] = $modx->lexicon(\'ugm_upgrade_available\');
  668. $placeholders[\'[[+ugm_notice_color]]\'] = \'green\';
  669. $placeholders[\'[[+ugm_version_form]]\'] = $versionForm;
  670. } else {
  671. if ($hideWhenNoUpgrade) {
  672. return \'\';
  673. } else {
  674. $placeholders[\'[[+ugm_notice]]\'] = $modx->lexicon(\'ugm_modx_up_to_date\');
  675. $placeholders[\'[[+ugm_notice_color]]\'] = \'gray\';
  676. }
  677. }
  678. /* Get Tpl */
  679. $tpl = $modx->getChunk(\'UpgradeMODXTpl\');
  680. /* Do the replacements */
  681. $tpl = str_replace(array_keys($placeholders), array_values($placeholders), $tpl);
  682. /*if (php_sapi_name() === \'cli\') {
  683. echo $tpl;
  684. }*/
  685. return $tpl;',
  686. ),
  687. ),
  688. );