SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/sprout_load.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13. use Sprout\Helpers\I18n;
  14. use Sprout\Helpers\Pdb;
  15. use Sprout\Helpers\Register;
  16. use Sprout\Helpers\SessionStats;
  17. use Sprout\Helpers\WidgetArea;
  18.  
  19.  
  20. I18n::init();
  21. SessionStats::init();
  22.  
  23. Register::extraPage(1, '404 error');
  24. Register::extraPage(2, 'Admin login message');
  25.  
  26. Register::pageattr('sprout.notes', 'Notes', 'AttrEditorMultiline');
  27. Register::pageattr('sprout.admin_notes', 'Admin notes', 'AttrEditorMultiline');
  28. Register::pageattr('sprout.department', 'Department');
  29. Register::pageattr('sprout.document_no', 'Document No.');
  30. Register::pageattr('sprout.maintainer', 'Maintainer');
  31. Register::pageattr('sprout.orig_author', 'Orig. Author');
  32. Register::pageattr('sprout.lang', 'Language');
  33.  
  34. Register::linkspec('\\Sprout\\Helpers\\LinkSpecExternal', 'External URL');
  35. Register::linkspec('\\Sprout\\Helpers\\LinkSpecInternal', 'Internal URL');
  36. Register::linkspec('\\Sprout\\Helpers\\LinkSpecPage', 'Internal Page');
  37. Register::linkspec('\\Sprout\\Helpers\\LinkSpecDocument', 'Document');
  38.  
  39. Register::rteLibrary('\\Sprout\\Helpers\\RteLibraryPages');
  40. Register::rteLibrary('\\Sprout\\Helpers\\RteLibraryDocuments');
  41. Register::rteLibrary('\\Sprout\\Helpers\\RteLibrarySounds');
  42. Register::rteLibrary('\\Sprout\\Helpers\\RteLibraryImages');
  43.  
  44. Register::sitemapGen('\\Sprout\\Helpers\\SitemapGenPages');
  45.  
  46. Register::searchHandler('Sprout\\Controllers\\PageController', 'page_keywords', ['main.active = 1', 'main.show_in_nav = 1']);
  47.  
  48. Register::frontEndController('Sprout\\Controllers\\AdvancedSearchController', 'Advanced search');
  49.  
  50. Register::contentReplace('inner_html', ['Sprout\\Helpers\\ContentReplace', 'intlinks']);
  51. Register::contentReplace('inner_html', ['Sprout\\Helpers\\ContentReplace', 'localAnchor']);
  52.  
  53. Register::contentReplace('main_content', ['Sprout\\Widgets\\ImageGalleryWidget', 'contentReplace']);
  54.  
  55. Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\PageAdminController', 'cronPageActivate');
  56. Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\PageAdminController', 'cronPageDeactivate');
  57. Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\PageAdminController', 'cronCheckStale');
  58. Register::cronJob('daily', 'Sprout\\Controllers\\AdminController', 'cronGenericActivate');
  59. Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\FileAdminController', 'cronCleanupInvalid');
  60. Register::cronJob('daily', 'Sprout\\Controllers\\ContentSubscribeController', 'cronSendSubscriptions');
  61. Register::cronJob('daily', 'Sprout\\Controllers\\Admin\\ActionLogAdminController', 'cronCleanup');
  62.  
  63. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Platform\\DeviceCategory', 'Platform', 'Device category');
  64. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Platform\\BrowserName', 'Platform', 'Browser name');
  65. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Platform\\BrowserVersion', 'Platform', 'Browser version');
  66. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Session\\TimeOnSite', 'Session', 'Minutes on site');
  67. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Session\\ThisPageviews', 'Session', 'Pageviews');
  68. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Session\\TotalPageviews', 'Session', 'Pageviews (total)');
  69. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Session\\UniquePageviews', 'Session', 'Pageviews (unique)');
  70. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Acquisition\\UtmSource', 'Acquisition', 'Source');
  71. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Acquisition\\UtmMedium', 'Acquisition', 'Medium');
  72. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Acquisition\\UtmCampaign', 'Acquisition', 'Campaign');
  73. Register::displayCondition('Sprout\\Helpers\\DisplayConditions\\Acquisition\\Referrer', 'Acquisition', 'Full referrer');
  74.  
  75. Register::widgetTile(
  76. 'embedded',
  77. 'Text blocks',
  78. 'insert_drive_file',
  79. 'Formatted page content',
  80. [
  81. 'RichText' => 'Text block',
  82. ]
  83. );
  84.  
  85.  
  86. Register::widgetTile(
  87. 'embedded',
  88. 'Collections',
  89. 'description',
  90. 'Formatted page content',
  91. [
  92. 'ChildrenPages' => 'Page lists',
  93. 'ChildrenGallery' => 'Page gallery',
  94. 'ImageGallery' => 'Image gallery',
  95. 'FileList' => 'List of files',
  96. 'Sitemap' => 'Sitemap',
  97. 'VideoPlaylist' => 'Video play-list gallery'
  98. ]
  99. );
  100.  
  101. Register::widgetTile(
  102. 'embedded',
  103. 'Maps',
  104. 'map',
  105. 'Embed Google maps',
  106. [
  107. 'Map' => 'Google map',
  108. 'MapDirections' => 'Google map with directions',
  109. ]
  110. );
  111.  
  112. Register::widgetTile(
  113. 'embedded',
  114. 'Advanced',
  115. 'settings',
  116. 'Stuff most people won\'t touch',
  117. [
  118. 'HtmlCode' => 'HTML code',
  119. ]
  120. );
  121.  
  122. Register::widgetTile(
  123. 'embedded',
  124. 'Social Media',
  125. 'settings',
  126. 'Social',
  127. [
  128. 'RssFeedWidget' => 'RSS Feed',
  129. ]
  130. );
  131.  
  132. Register::widgetTile(
  133. 'sidebar',
  134. 'Text blocks',
  135. 'insert_drive_file',
  136. 'Page content',
  137. [
  138. 'RichText' => 'Rich text',
  139. 'HtmlCode' => 'HTML code',
  140. ]
  141. );
  142.  
  143. Register::widgetTile(
  144. 'sidebar',
  145. 'Collections',
  146. 'description',
  147. 'Formatted page content',
  148. [
  149. 'ChildrenPages' => 'Children pages',
  150. 'ImageGallery' => 'Image gallery',
  151. 'FileList' => 'List of files',
  152. ]
  153. );
  154.  
  155. $area = WidgetArea::findAreaByName('email');
  156. if ($area) {
  157. $area->addWidget('HtmlCode');
  158. }
  159.  
  160. Register::emailText(
  161. 'operator.welcome',
  162. 'name' => 'The real name of the new operator',
  163. 'username' => 'The username of the new operator',
  164. 'password' => 'The password for logging in',
  165. ),
  166. 'sprout/email/operator_welcome'
  167. );
  168.  
  169.  
  170. Pdb::setFormatter('DateTime', function($dt) {
  171. return $dt->format('Y-m-d H:i:s');
  172. });
  173.  
  174. Pdb::setFormatter('DateInterval', function($interval) {
  175. $dt = new \DateTime();
  176. $dt->add($interval);
  177. return $dt->format('Y-m-d H:i:s');
  178. });
  179.  
  180. Register::addDbtoolsApi([
  181. 'title' => 'QR Code',
  182. 'desc' => 'Renders QR code',
  183. 'class' => 'Sprout\\Controllers\\DbToolsController',
  184. 'method' => 'qrCodeForm',
  185. ]);
  186.