Automad
 All Classes Functions Variables Pages
edit_page.php
1 <?php
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  * AUTOMAD
29  *
30  * Copyright (c) 2014 by Marc Anton Dahmen
31  * http://marcdahmen.de
32  *
33  * Licensed under the MIT license.
34  * http://automad.org/license
35  */
36 
37 
38 namespace Automad\Core;
39 
40 
41 defined('AUTOMAD') or die('Direct access not permitted!');
42 
43 
44 /*
45  * The GUI page to edit page content. As part of the GUI, this file is only to be included from the Gui class.
46  */
47 
48 
49 if (array_key_exists(Parse::queryKey('url'), $this->collection)) {
50 
51  $Page = $this->collection[Parse::queryKey('url')];
52  $data = Parse::textFile($this->pageFile($Page));
53 
54  if (!isset($data[AM_KEY_TITLE]) || !$data[AM_KEY_TITLE]) {
55  $data[AM_KEY_TITLE] = basename($Page->url);
56  }
57 
58  if (isset($data[AM_KEY_URL])) {
59  $url = $data[AM_KEY_URL];
60  } else {
61  $url = $Page->url;
62  }
63 
64  $this->guiTitle = $this->guiTitle . ' / ' . $data[AM_KEY_TITLE];
65 
66 } else {
67 
68  $Page = false;
69 
70 }
71 
72 
73 $this->element('header');
74 
75 
76 ?>
77 
78  <?php if ($Page) { ?>
79  <div class="column subnav">
80  <div class="scroll">
81  <div class="inner">
82  <ul class="nav nav-pills nav-stacked">
83  <li>
84  <a href="<?php echo Resolve::url($Page, $url); ?>" target="_blank">
85  <span class="glyphicon glyphicon-arrow-right"></span><span class="hidden-md"> <?php echo $this->tb['btn_visit_page']; ?></span>
86  </a>
87  </li>
88  <!-- Data -->
89  <li class="active">
90  <a href="#data" data-toggle="tab">
91  <span class="glyphicon glyphicon-align-left"></span><span class="hidden-md"> <?php echo $this->tb['btn_data']; ?></span>
92  </a>
93  </li>
94  <!-- Files -->
95  <li>
96  <a href="#files" data-toggle="tab">
97  <span class="glyphicon glyphicon-folder-open"></span><span class="hidden-md"> <?php echo $this->tb['btn_files']; ?></span>
98  </a>
99  </li>
100  <!-- Add Subpage Button -->
101  <li>
102  <a href="#" data-toggle="modal" data-target="#automad-add-subpage-modal">
103  <span class="glyphicon glyphicon-plus"></span><span class="hidden-md"> <?php echo $this->tb['btn_add_page']; ?></span>
104  </a>
105  </li>
106  <?php if ($Page->path != '/') { ?>
107  <!-- Move Page Button -->
108  <li>
109  <a href="#" data-toggle="modal" data-target="#automad-move-page-modal">
110  <span class="glyphicon glyphicon-move"></span><span class="hidden-md"> <?php echo $this->tb['btn_move_page']; ?></span>
111  </a>
112  </li>
113  <!-- Delete Page Button -->
114  <li>
115  <a href="#" data-toggle="modal" data-target="#automad-delete-page-modal">
116  <span class="glyphicon glyphicon-trash"></span><span class="hidden-md"> <?php echo $this->tb['btn_delete_page']; ?></span>
117  </a>
118  </li>
119  <?php } ?>
120  </ul>
121  </div>
122  </div>
123  </div>
124 
125  <div class="column content">
126  <div class="inner">
127  <div class="alert alert-info">
128  <a href="<?php echo Resolve::url($Page, $url); ?>" target="_blank"><span class="glyphicon glyphicon-link"></span> <?php echo $url; ?></a>
129  </div>
130  <!-- Tab panes -->
131  <div class="tab-content">
132  <div id="data" class="tab-pane fade in active">
133  <form class="automad-form automad-init" data-automad-handler="page_data" data-automad-url="<?php echo $Page->url; ?>" role="form">
134  <span class="glyphicon glyphicon-time"></span> <?php echo $this->tb['btn_loading']; ?>
135  </form>
136  </div>
137  <div id="files" class="tab-pane fade">
138  <script src="<?php echo AM_BASE_URL; ?>/automad/lib/jquery-file-upload/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
139  <script src="<?php echo AM_BASE_URL; ?>/automad/lib/jquery-file-upload/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
140  <script src="<?php echo AM_BASE_URL; ?>/automad/lib/jquery-file-upload/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
141  <form class="automad-form automad-init" data-automad-handler="files" data-automad-url="<?php echo $Page->url; ?>" role="form"></form>
142  </div>
143  </div>
144  </div>
145  </div>
146 
147  <!-- Add Subpage Modal -->
148  <div class="modal fade" id="automad-add-subpage-modal">
149  <div class="modal-dialog">
150  <div class="modal-content">
151  <div class="modal-header">
152  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
153  <h3 class="modal-title"><?php echo $this->tb['btn_add_page']; ?></h3>
154  </div>
155  <form class="automad-form" data-automad-handler="add_page" data-automad-url="<?php echo $Page->url; ?>" role="form">
156  <div class="modal-body">
157  <div class="alert alert-info"><span class="glyphicon glyphicon-arrow-right"></span> <b><?php echo rtrim($Page->url, '/'); ?>/</b></div>
158  <div class="form-group">
159  <label for="add-subpage-title">Title</label>
160  <input id="add-subpage-title" class="form-control" type="text" name="subpage[<?php echo AM_KEY_TITLE; ?>]" value="" onkeypress="return event.keyCode != 13;" required />
161  </div>
162  <?php echo $this->templateSelectBox('add-subpage-theme_template', 'subpage[theme_template]'); ?>
163  </div>
164  <div class="modal-footer">
165  <div class="btn-group btn-group-justified">
166  <div class="btn-group"><button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> <?php echo $this->tb['btn_close']; ?></button></div>
167  <div class="btn-group"><button type="submit" class="btn btn-primary" data-loading-text="<?php echo $this->tb['btn_loading']; ?>"><span class="glyphicon glyphicon-plus"></span> <?php echo $this->tb['btn_add_page']; ?></button></div>
168  </div>
169  </div>
170  </form>
171  </div>
172  </div>
173  </div>
174 
175  <!-- Move Page Modal -->
176  <div class="modal fade" id="automad-move-page-modal" data-automad-url="<?php echo $Page->url; ?>" data-automad-title="<?php echo $data[AM_KEY_TITLE]; ?>">
177  <div class="modal-dialog">
178  <div class="modal-content">
179  <div class="modal-header">
180  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
181  <h3 class="modal-title"><?php echo $this->tb['btn_move_page']; ?></h3>
182  </div>
183  <div class="modal-body">
184  <div class="alert alert-info"><span class="glyphicon glyphicon-move"></span> <b><?php echo $Page->url; ?></b></div>
185  <h4><?php echo $this->tb['page_move_destination']; ?></h4>
186  <?php echo $this->siteTree('', $this->collection, array(), true); ?>
187  </div>
188  <div class="modal-footer">
189  <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> <?php echo $this->tb['btn_close']; ?></button>
190  </div>
191  </div>
192  </div>
193  </div>
194 
195  <!-- Delete Page Confirm Modal -->
196  <div class="modal fade" id="automad-delete-page-modal">
197  <div class="modal-dialog">
198  <div class="modal-content">
199  <div class="modal-header">
200  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
201  <h3 class="modal-title"><?php echo $this->tb['btn_delete_page']; ?></h3>
202  </div>
203  <form class="automad-form" data-automad-handler="delete_page" data-automad-url="<?php echo $Page->url; ?>" role="form">
204  <input type="hidden" name="title" value="<?php echo $data[AM_KEY_TITLE]; ?>" />
205  <div class="modal-body">
206  <div class="alert alert-danger"><span class="glyphicon glyphicon-trash"></span> <b><?php echo $Page->url; ?></b></div>
207  <?php echo $this->tb['page_confirm_delete']; ?>
208  </div>
209  <div class="modal-footer">
210  <div class="btn-group btn-group-justified">
211  <div class="btn-group"><button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> <?php echo $this->tb['btn_close']; ?></button></div>
212  <div class="btn-group"><button type="submit" class="btn btn-danger" data-loading-text="<?php echo $this->tb['btn_loading']; ?>"><span class="glyphicon glyphicon-trash"></span> <?php echo $this->tb['btn_delete_page']; ?></button></div>
213  </div>
214  </div>
215  </form>
216  </div>
217  </div>
218  </div>
219  <?php } else { ?>
220  <div class="column content">
221  <div class="inner">
222  <div class="alert alert-danger"><h4><?php echo $this->tb['error_page_not_found']; ?><br /><br /><strong><?php echo Parse::queryKey('url');?></strong></h4></div>
223  </div>
224  </div>
225  <?php } ?>
226 
227 <?php
228 
229 
230 $this->element('footer');
231 
232 
233 ?>
static textFile($file)
Definition: parse.php:473
static queryKey($key)
Definition: parse.php:294