SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/views/admin/page_edit.php

  1. <?php
  2. /*
  3.  * kate: tab-width 4; indent-width 4; space-indent on; word-wrap off; word-wrap-column 120;
  4.  * :tabSize=4:indentSize=4:noTabs=true:wrap=false:maxLineLen=120:mode=php:
  5.  *
  6.  * Copyright (C) 2015 Karmabunny Pty Ltd.
  7.  *
  8.  * This file is a part of SproutCMS.
  9.  *
  10.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  11.  * of the GNU General Public License as published by the Free Software Foundation, either
  12.  * version 3 of the License, or (at your option) any later version.
  13.  *
  14.  * For more information, visit <http://getsproutcms.com>.
  15.  */
  16. use Sprout\Helpers\Admin;
  17. use Sprout\Helpers\Constants;
  18. use Sprout\Helpers\Enc;
  19. use Sprout\Helpers\Fb;
  20. use Sprout\Helpers\FileConstants;
  21. use Sprout\Helpers\Form;
  22. use Sprout\Helpers\Navigation;
  23. use Sprout\Helpers\NavigationGroups;
  24. use Sprout\Helpers\Needs;
  25. use Sprout\Helpers\Register;
  26. use Sprout\Helpers\Request;
  27. use Sprout\Helpers\Sprout;
  28. use Sprout\Helpers\Subsites;
  29. use Sprout\Helpers\Text;
  30. use Sprout\Helpers\WidgetArea;
  31.  
  32.  
  33. if ($data['type'] == 'tool' and empty($front_end_controllers)) {
  34. echo '<p><i>No tool page types have been defined. Unable to edit tool pages.</i></p>';
  35. return;
  36. }
  37.  
  38. Needs::fileGroup('sprout/page_edit');
  39. Needs::fileGroup('sprout/underscore');
  40. Needs::fileGroup('drag_drop_upload');
  41.  
  42. if ($show_tour) {
  43. Needs::fileGroup('sprout/backbone');
  44. Needs::fileGroup('sprout/tourist');
  45. Needs::fileGroup('sprout/tourist-page-edit');
  46. }
  47.  
  48.  
  49. if ($data['alt_template'] == '') $data['alt_template'] = 'skin/inner';
  50.  
  51. $subsite_absroot = Subsites::getAbsRoot($_SESSION['admin']['active_subsite'], Request::protocol());
  52.  
  53. $base = Subsites::getAbsRoot($_SESSION['admin']['active_subsite']);
  54. $root = Navigation::getRootNode();
  55. $node = $root->findNodeValue('id', $id);
  56.  
  57. if ($node) {
  58. $share_type = 'Public URL';
  59. $share_url = $base . $node->getFriendlyUrlNoprefix();
  60. } else {
  61. $share_type = 'Temporary URL';
  62. $share_url = $base . 'page/view_by_id/' . $id;
  63. }
  64. ?>
  65.  
  66. <?php
  67. Form::setData($data);
  68. Form::setErrors($errors);
  69. ?>
  70.  
  71.  
  72. <input type="hidden" name="rev_id" value="<?= $sel_rev_id; ?>">
  73. <input type="hidden" name="type" value="<?= Enc::html($data['type']); ?>">
  74.  
  75. <!-- Settings -->
  76. <div id="page-settings-wrapper" class="page-edit-tab">
  77. <div class="heading-with-buttons">
  78. <button class="button button-small button-grey icon-close icon-after page-edit-tab-close" type="button" data-target="page-settings-wrapper">Close</button>
  79. <h3 class="h2 icon-before icon-settings">Settings</h3>
  80. </div>
  81. <div class="white-box">
  82. <?php
  83. Form::nextFieldDetails('Template', true, 'Overrides the default page container template; e.g. utilise a wide page rather than a column view.');
  84. echo Form::dropdown('alt_template', [], $templates);
  85. ?>
  86.  
  87. <?php if (Subsites::getConfigAdmin('nav_groups') !== null): ?>
  88. <?php
  89. Form::nextFieldDetails('Menu group', false);
  90. echo Form::dropdown('menu_group', ['-dropdown-top' => 'None -- Don\'t show in menu'], NavigationGroups::getAllNamesAdmin());
  91. ?>
  92. <?php endif; ?>
  93.  
  94. <?php if (Kohana::config('page.enable_banners')): ?>
  95. <?php
  96. Form::nextFieldDetails('Banner', false, 'Overrides the default banner image when the page is viewed.');
  97. echo Form::fileSelector('banner', [], ['filter' => FileConstants::TYPE_IMAGE]);
  98. ?>
  99. <?php endif; ?>
  100.  
  101. <?php
  102. Form::nextFieldDetails('Gallery Thumbnail', false, 'A thumbnail for the page when seen in the page gallery.');
  103. echo Form::fileSelector('gallery_thumb', [], ['filter' => FileConstants::TYPE_IMAGE]);
  104. ?>
  105.  
  106.  
  107. <h3>Old content</h3>
  108.  
  109. <?php
  110. Form::nextFieldDetails('Auto deactivate', false, 'Automatically hide the page from users after this date.');
  111. echo Form::datepicker('date_expire', []);
  112. ?>
  113.  
  114. <?php
  115. if ($data['type'] == 'standard') {
  116. $help_text = "A warning about stale content is sent if this page hasn't been updated for this many days";
  117. $help_text .= " (enter 0 to disable such warnings)";
  118. Form::nextFieldDetails('Maximum days before content is stale', false, $help_text);
  119. echo Form::text(
  120. 'stale_age',
  121. [
  122. 'placeholder' => Kohana::config('sprout.stale_page_age'),
  123. ]
  124. );
  125. }
  126. ?>
  127.  
  128.  
  129. <h3>Metadata</h3>
  130.  
  131. <?php
  132. Form::nextFieldDetails('URL slug', true, 'The text used to generate a link for the page; e.g. "this-is-a-slug" would result in: ' . Sprout::absRoot() . 'this-is-a-slug');
  133. echo Form::text('slug', []);
  134. ?>
  135.  
  136. <?php
  137. Form::nextFieldDetails('Keywords', false, 'Terms that relate to the content on the page; these are important for search relevancy.');
  138. echo Form::text('meta_keywords', ['size' => 30]);
  139. ?>
  140.  
  141. <?php
  142. Form::nextFieldDetails('Description', false, 'A short (under 100 words) summary of the page content.');
  143. echo Form::text('meta_description', ['size' => 30]);
  144. ?>
  145.  
  146. <?php
  147. if (empty($page['alt_browser_title'])) {
  148. Form::nextFieldDetails('Web-browser title (defaults to: ' . Navigation::buildBrowserTitle($page['name']) . ')',
  149. false,
  150. 'Specify a custom browser title for the page; this will appear in the browser title bar/tab.'
  151. );
  152. } else {
  153. Form::nextFieldDetails('Web-browser title', false, 'A custom browser title for the page; this will appear in the browser title bar/tab.');
  154. }
  155. echo Form::text('alt_browser_title', ['size' => 30]);
  156. ?>
  157.  
  158. <?php
  159. Form::nextFieldDetails('Alternate navigation title', false, 'Override the default title that appears in links and navigation breadcrumbs for this page.');
  160. echo Form::text('alt_nav_title', ['size' => 30]);
  161. ?>
  162.  
  163. <?php echo Fb::heading('Custom attributes'); ?>
  164. <div class="info">You can use these to fulfill any operational need you may have.</div>
  165. <?php Admin::attrEditor($data['multiedit_attrs']); ?>
  166.  
  167.  
  168. <!-- Permissions -->
  169. <div>
  170. <?php if (Register::hasFeature('users')): ?>
  171. <h3>Who can view this page?</h3>
  172. <div class="info">You can restrict which user groups can access this page.</div>
  173. <?php
  174. echo Form::multiradio('user_perm_specific', [], [
  175. 0 => 'Anyone who can view the parent page',
  176. 1 => 'Choose specific user groups',
  177. ]);
  178. ?>
  179. <div class="user_perms">
  180. <?php
  181. echo Form::checkboxSet('user_permissions', [], $user_category_options);
  182. ?>
  183. </div>
  184. <?php endif; ?>
  185.  
  186.  
  187. <h3>Who can manage this page?</h3>
  188. <div class="info">You can restrict which operator groups can edit this page.</div>
  189. <?php
  190. echo Form::multiradio('admin_perm_specific', [], [
  191. 0 => 'Anyone who can manage the parent page',
  192. 1 => 'Choose specific operator groups',
  193. ]);
  194. ?>
  195. <div class="admin_perms">
  196. <?php
  197. echo Form::checkboxSet('admin_permissions', [], $admin_category_options);
  198. ?>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203.  
  204. <!-- Revisions tab -->
  205. <div id="page-revisions-wrapper" class="page-edit-tab">
  206. <div class="heading-with-buttons">
  207. <button class="button button-small button-grey icon-close icon-after page-edit-tab-close" type="button" data-target="page-revisions-wrapper">Close</button>
  208. <h3 class="h2 icon-before icon-history">Page Revisions</h3>
  209. </div>
  210. <div class="white-box">
  211. <div class="info">This is a list of all revisions which have been made to this page.</div>
  212. <table class="main-list main-list--small main-list-no-js" id="rev-list">
  213. <thead>
  214. <tr>
  215. <th style="width: 20px;">&nbsp;</th>
  216. <th style="width: 165px;">Date modified</th>
  217. <th>Changes</th>
  218. <th style="width: 200px">Editor</th>
  219. <th style="width: 200px">Status</th>
  220. <th style="width: 200px">Action</th>
  221. </tr>
  222. </thead>
  223. <tbody>
  224. <?php
  225. foreach ($revs as $rev) {
  226. $rev_edit_url = "admin/edit/page/{$id}?revision={$rev['id']}";
  227. $rev_view_url = "page/view_specific_rev/{$id}/{$rev['id']}";
  228.  
  229. if ($can_approve_revisions and $rev['status'] == 'need_approval') {
  230. $rev_view_url .= '/' . $rev['approval_code'];
  231. }
  232. ?>
  233.  
  234. <tr>
  235. <td>
  236. <?php if ($sel_rev_id == $rev['id']): ?>
  237. <span class="icon-before icon-edit" title="This revision is currently being edited"></span>
  238. <?php endif; ?>
  239. </td>
  240. <td><?php echo Enc::html($rev['date_modified']); ?></td>
  241. <td><?php echo Enc::html($rev['changes_made']); ?></td>
  242. <td><?php echo Enc::html($rev['modified_editor']); ?></td>
  243. <td>
  244. <?php
  245. echo Enc::html(Constants::$rev_statuses[$rev['status']]);
  246. if ($rev['status'] == 'auto_launch') {
  247. echo ' on ', date('d/m/Y', strtotime($rev['date_launch']));
  248. }
  249. ?>
  250. </td>
  251. <td style="white-space: nowrap;">
  252. <a href="<?= Enc::html($rev_edit_url); ?>" class="button button-small button-green icon-before icon-edit">Edit</a>
  253. <a href="<?= Enc::html($rev_view_url); ?>" class="button button-small button-blue icon-before icon-remove_red_eye">View</a>
  254. </td>
  255. </tr>
  256.  
  257. <?php
  258. }
  259. ?>
  260. </tbody>
  261. </table>
  262.  
  263.  
  264. <?php if (count($revs) != count($history)): ?>
  265. <?php echo Fb::heading('Page history'); ?>
  266. <div class="info">This is a history of changes to this page.</div>
  267. <table class="main-list main-list--small">
  268. <thead>
  269. <tr>
  270. <th style="width: 195px">Date</th>
  271. <th>Changes</th>
  272. <th style="width: 200px">Editor</th>
  273. </tr>
  274. </thead>
  275. <tbody>
  276. <?php foreach ($history as $item): ?>
  277. <tr>
  278. <td><?php echo Enc::html($item['date_added']); ?></td>
  279. <td><?php echo Enc::html($item['changes_made']); ?></td>
  280. <td><?php echo Enc::html($item['modified_editor']); ?></td>
  281. </tr>
  282. <?php endforeach; ?>
  283. </tbody>
  284. </table>
  285. <?php endif; ?>
  286. </div>
  287. </div>
  288.  
  289. <!-- Main content editing -->
  290. <div class="content-bar">
  291.  
  292. <?php
  293. if ($admin_notes) {
  294. echo '<ul class="messages all-type-neutral"><li class="neutral">', Text::richtext($admin_notes), '</li></ul>';
  295. }
  296. ?>
  297.  
  298. <?php if (!$has_live_rev and empty($_GET['suppress'])): ?>
  299. <ul class="messages all-type-neutral"><li class="neutral">NOTE: modify the 'Publish options' to put this page live.</li></ul>
  300. <?php elseif ($page['active'] != 1): ?>
  301. <ul class="messages all-type-neutral"><li class="neutral">This page is not currently active on the website.</li></ul>
  302. <?php endif; ?>
  303.  
  304. <div class="columns -clearfix">
  305. <div class="column column-7">
  306. <div id="tour-page-title">
  307. <?php Form::nextFieldDetails('Name', true); ?>
  308. <?= Form::text('name', ['spellcheck' => 'true', '-wrapper-class' => 'white']); ?>
  309. </div>
  310. </div>
  311.  
  312. <div class="column column-5">
  313. <div id="tour-page-parent">
  314. <?php
  315. Form::nextFieldDetails('Parent page', false);
  316. echo Form::pageDropdown('parent_id', ['-wrapper-class' => 'white']);
  317. ?>
  318. </div>
  319. </div>
  320. </div>
  321.  
  322. <?php if ($data['type'] == 'tool'): ?>
  323. <?php Form::nextFieldDetails('Module', true, 'The type of tool page to show'); ?>
  324. <?php echo Form::dropdown('controller_entrance', [], $front_end_controllers); ?>
  325.  
  326. <?php Form::nextFieldDetails('Feature', true, 'The specific feature of the module to show'); ?>
  327. <?php echo Form::dropdown('controller_argument', [], $controller_arguments); ?>
  328. <?php elseif ($data['type'] == 'redirect'): ?>
  329. <?php echo Fb::heading('Redirect'); ?>
  330. <div class="info">If this is set, users will be redirected to another page on the website or an external location.</div>
  331. <?php echo Fb::lnk('redirect', [], ['-wrapper-class' => 'white']); ?>
  332. <?php else: ?>
  333. <div id="tour-content-area">
  334. <div class="heading-with-buttons">
  335. <?php if (empty($page['redirect'])): ?>
  336. <button class="button button-small button-grey icon-keyboard_arrow_up icon-after content-block-collapse-button" type="button" data-target="wl-embedded">Collapse all</button>
  337. <?php endif; ?>
  338. <h3 class="h2 icon-before icon-content">Content</h3>
  339. </div>
  340.  
  341. <p>Content Blocks build the structure of your page. Add, remove, disable, or reorder them how you wish.</p>
  342.  
  343. <?php
  344. // Content blocks
  345. $areas = Kohana::config('sprout.widget_areas');
  346. foreach ($areas as $area_id => $area) {
  347. if ($area->getName() != 'embedded') continue;
  348. Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));
  349. break;
  350. }
  351. ?>
  352. </div>
  353. <?php endif; ?>
  354. </div>
  355.  
  356. <?php if ($data['type'] != 'redirect'): ?>
  357. <!-- Widgets-->
  358. <div class="sidebar-widgets">
  359. <?php
  360. $areas = Kohana::config('sprout.widget_areas');
  361. foreach ($areas as $area_id => $area) {
  362. if ($area->getName() == 'embedded') continue;
  363. if ($area->getOrientation() == WidgetArea::ORIENTATION_EMAIL) continue;
  364.  
  365. if ($area_id == 2) {
  366. $heading_class = 'h2 icon-before icon-sidebar';
  367. } else {
  368. $heading_class = 'h2';
  369. }
  370.  
  371. echo '<div class="heading-with-buttons">';
  372. if (empty($page['redirect'])) {
  373. echo '<button class="button button-small button-grey icon-keyboard_arrow_up icon-after content-block-collapse-button" type="button" data-target="wl-sidebar">Collapse all</button>';
  374. }
  375. echo '<h3 class="', $heading_class, '">', Enc::html($area->getNiceName()), '</h3>';
  376. echo '</div>';
  377.  
  378. if ($area_id == 2) {
  379. echo '<p>These content blocks will be displayed in the sidebar of the page.</p>';
  380. }
  381.  
  382. Admin::widgetList($area->getName(), $area, @$widgets[$area_id], empty($page['redirect']));
  383. }
  384. ?>
  385. </div>
  386. <?php endif; ?>
  387.  
  388. <?php Admin::clearFieldErrors(); ?>
  389.