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: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40:
41: $plugin_is_filter = 9 | CLASS_PLUGIN;
42: $plugin_description = gettext("A CMS plugin that adds the capability to run an entire gallery focused website with zenphoto.");
43: $plugin_notice = gettext("<strong>Note:</strong> This feature must be integrated into your theme. It is not supported by either the <em>default</em> or the <em>stopdesign</em> theme.");
44: $plugin_author = "Malte Müller (acrylian), Stephen Billard (sbillard)";
45: $option_interface = 'zenpagecms';
46:
47: if (OFFSET_PATH == 2) {
48: setOptionDefault('zenpageNewsLink', array_key_exists('news', $_zp_conf_vars['special_pages']) ? $_zp_conf_vars['special_pages']['news']['rewrite'] : 'news');
49: setOptionDefault('zenpageCategoryLink', array_key_exists('category', $_zp_conf_vars['special_pages']) ? $_zp_conf_vars['special_pages']['category']['rewrite'] : '_NEWS_/category');
50: setOptionDefault('zenpageNewsArchiveLink', array_key_exists('news_archive', $_zp_conf_vars['special_pages']) ? $_zp_conf_vars['special_pages']['news_archive']['rewrite'] : '_NEWS_/archive');
51: setOptionDefault('zenpagePagesLink', array_key_exists('pages', $_zp_conf_vars['special_pages']) ? $_zp_conf_vars['special_pages']['pages']['rewrite'] : 'pages');
52: }
53:
54:
55: $_zp_conf_vars['special_pages']['news'] = array('define' => '_NEWS_', 'rewrite' => getOption('zenpageNewsLink'),
56: 'option' => 'zenpageNewsLink', 'default' => 'news');
57: $_zp_conf_vars['special_pages']['category'] = array('define' => '_CATEGORY_', 'rewrite' => getOption('zenpageCategoryLink'),
58: 'option' => 'zenpageCategoryLink', 'default' => '_NEWS_/category');
59: $_zp_conf_vars['special_pages']['news_archive'] = array('define' => '_NEWS_ARCHIVE_', 'rewrite' => getOption('zenpageNewsArchiveLink'),
60: 'option' => 'zenpageNewsArchiveLink', 'default' => '_NEWS_/archive');
61: $_zp_conf_vars['special_pages']['pages'] = array('define' => '_PAGES_', 'rewrite' => getOption('zenpagePagesLink'),
62: 'option' => 'zenpagePagesLink', 'default' => 'pages');
63:
64: $_zp_conf_vars['special_pages'][] = array('definition' => '%NEWS%', 'rewrite' => '_NEWS_');
65: $_zp_conf_vars['special_pages'][] = array('definition' => '%CATEGORY%', 'rewrite' => '_CATEGORY_');
66: $_zp_conf_vars['special_pages'][] = array('definition' => '%NEWS_ARCHIVE%', 'rewrite' => '_NEWS_ARCHIVE_');
67: $_zp_conf_vars['special_pages'][] = array('definition' => '%PAGES%', 'rewrite' => '_PAGES_');
68:
69: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%PAGES%/*$',
70: 'rule' => '%REWRITE% index.php?p=pages [L,QSA]');
71: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%PAGES%/(.*)/?$',
72: 'rule' => '%REWRITE% index.php?p=pages&title=$1 [L, QSA]');
73: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%CATEGORY%/(.*)/([0-9]+)/?$',
74: 'rule' => '%REWRITE% index.php?p=news&category=$1&page=$2 [L,QSA]');
75: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%CATEGORY%/(.*)/?$',
76: 'rule' => '%REWRITE% index.php?p=news&category=$1 [L,QSA]');
77: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%NEWS_ARCHIVE%/(.*)/([0-9]+)/?$',
78: 'rule' => '%REWRITE% index.php?p=news&date=$1&page=$2 [L,QSA]');
79: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%NEWS_ARCHIVE%/(.+)/?$',
80: 'rule' => '%REWRITE% index.php?p=news&date=$1 [L,QSA]');
81: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%NEWS%/([0-9]+)/?$',
82: 'rule' => '%REWRITE% index.php?p=news&page=$1 [L,QSA]');
83: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%NEWS%/(.+)/?$',
84: 'rule' => '%REWRITE% index.php?p=news&title=$1 [L,QSA]');
85: $_zp_conf_vars['special_pages'][] = array('define' => false, 'rewrite' => '^%NEWS%/*$',
86: 'rule' => '%REWRITE% index.php?p=news [L,QSA]');
87:
88: zp_register_filter('checkForGuest', 'zenpagecms::checkForGuest');
89: zp_register_filter('isMyItemToView', 'zenpagecms::isMyItemToView');
90: zp_register_filter('admin_toolbox_global', 'zenpagecms::admin_toolbox_global');
91: zp_register_filter('admin_toolbox_news', 'zenpagecms::admin_toolbox_news');
92: zp_register_filter('admin_toolbox_pages', 'zenpagecms::admin_toolbox_pages');
93: zp_register_filter('themeSwitcher_head', 'zenpagecms::switcher_head');
94: zp_register_filter('themeSwitcher_Controllink', 'zenpagecms::switcher_controllink', 0);
95: zp_register_filter('load_theme_script', 'zenpagecms::switcher_setup', 99);
96:
97: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-class.php');
98: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-class-news.php');
99: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-class-page.php');
100: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-class-category.php');
101:
102: $_zp_zenpage = new Zenpage();
103:
104: class zenpagecms {
105:
106: function __construct() {
107: if (OFFSET_PATH == 2) {
108:
109: setOptionDefault('zenpage_articles_per_page', '10');
110: setOptionDefault('zenpage_text_length', '500');
111: setOptionDefault('zenpage_textshorten_indicator', ' (...)');
112: gettext($str = 'Read more');
113: setOptionDefault('zenpage_read_more', getAllTranslations($str));
114: setOptionDefault('zenpage_indexhitcounter', false);
115: setOptionDefault('menu_truncate_string', 0);
116: setOptionDefault('menu_truncate_indicator', '');
117: setOptionDefault('enabled-zenpage-items', 'news-and-pages');
118: }
119: }
120:
121: function getOptionsSupported() {
122: global $_common_truncate_handler;
123:
124: $options = array(
125: gettext('Enabled Zenpage items') => array(
126: 'key' => 'enabled-zenpage-items',
127: 'type' => OPTION_TYPE_RADIO,
128: 'order' => 7,
129: 'buttons' => array(
130: gettext('Enable news articles and pages') => 'news-and-pages',
131: gettext('Enable news') => 'news',
132: gettext('Enable pages') => 'pages'
133: ),
134: 'desc' => gettext('This enables or disables the admin tabs for pages and/or news articles. To hide news and/or pages content on the front end as well, themes must be setup to use <br><code>if(extensionEnabled("zenpage") && ZP_NEWS_ENABLED) { … }</code> or <br><code>if(extensionEnabled("zenpage") && ZP_PAGES_ENABLED) { … }</code> in appropriate places. Same if disabled items should blocked as they otherwise still can be accessed via direct links. <p class="notebox"><strong>NOTE:</strong> This does not delete content and is not related to management rights.</p>')
135: ),
136: gettext('Articles per page (theme)') => array('key' => 'zenpage_articles_per_page', 'type' => OPTION_TYPE_TEXTBOX,
137: 'order' => 0,
138: 'desc' => gettext("How many news articles you want to show per page on the news or news category pages.")),
139: gettext('News article text length') => array('key' => 'zenpage_text_length', 'type' => OPTION_TYPE_TEXTBOX,
140: 'order' => 1,
141: 'desc' => gettext("The length of news article excerpts in news or news category pages. Leave empty for full text.")),
142: gettext('News article text shorten indicator') => array('key' => 'zenpage_textshorten_indicator', 'type' => OPTION_TYPE_TEXTBOX,
143: 'order' => 2,
144: 'desc' => gettext("Something that indicates that the article text is shortened, “ (...)” by default.")),
145: gettext('Read more') => array('key' => 'zenpage_read_more', 'type' => OPTION_TYPE_TEXTBOX, 'multilingual' => 1,
146: 'order' => 3,
147: 'desc' => gettext("The text for the link to the full article.")),
148: gettext('Truncate titles*') => array('key' => 'menu_truncate_string', 'type' => OPTION_TYPE_TEXTBOX,
149: 'disabled' => $_common_truncate_handler,
150: 'order' => 23,
151: 'desc' => gettext('Limit titles to this many characters. Zero means no limit.')),
152: gettext('Truncate indicator*') => array('key' => 'menu_truncate_indicator', 'type' => OPTION_TYPE_TEXTBOX,
153: 'disabled' => $_common_truncate_handler,
154: 'order' => 24,
155: 'desc' => gettext('Append this string to truncated titles.'))
156: );
157: if ($_common_truncate_handler) {
158: $options['note'] = array('key' => 'menu_truncate_note', 'type' => OPTION_TYPE_NOTE,
159: 'order' => 25,
160: 'desc' => '<p class="notebox">' . $_common_truncate_handler . '</p>');
161: } else {
162: $_common_truncate_handler = gettext('* These options may be set via the <a href="javascript:gotoName(\'zenpage\');"><em>Zenpage</em></a> plugin options.');
163: $options['note'] = array('key' => 'menu_truncate_note',
164: 'type' => OPTION_TYPE_NOTE,
165: 'order' => 25,
166: 'desc' => gettext('<p class="notebox">*<strong>Note:</strong> The setting of these options are shared with other plugins.</p>'));
167: }
168: return $options;
169: }
170:
171: function handleOption($option, $currentValue) {
172:
173: }
174:
175: static function switcher_head($list) {
176: ?>
177: <script type="text/javascript">
178:
179: function switchCMS(checked) {
180: window.location = '?cmsSwitch=' + checked;
181: }
182:
183: </script>
184: <?php
185: return $list;
186: }
187:
188: static function switcher_controllink($theme) {
189: global $_zp_gallery_page;
190: if ($_zp_gallery_page == 'pages.php' || $_zp_gallery_page == 'news.php') {
191: $disabled = ' disabled="disalbed"';
192: } else {
193: $disabled = '';
194: }
195: if (getPlugin('pages.php', $theme)) {
196: ?>
197: <span id="themeSwitcher_zenpage" title="<?php echo gettext("Enable Zenpage CMS plugin"); ?>">
198: <label>
199: Zenpage
200: <input type="checkbox" name="cmsSwitch" id="cmsSwitch" value="1"<?php if (extensionEnabled('zenpage')) echo $disabled . ' checked="checked"'; ?> onclick="switchCMS(this.checked);" />
201: </label>
202: </span>
203: <?php
204: }
205: return $theme;
206: }
207:
208: static function switcher_setup($ignore) {
209: global $_zp_zenpage;
210: if (class_exists('themeSwitcher') && themeSwitcher::active()) {
211: if (isset($_GET['cmsSwitch'])) {
212: setOption('themeSwitcher_zenpage_switch', $cmsSwitch = (int) ($_GET['cmsSwitch'] == 'true'));
213: if (!$cmsSwitch) {
214: enableExtension('zenpage', 0, false);
215: }
216: }
217: }
218: if (extensionEnabled('zenpage')) {
219: require_once(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-template-functions.php');
220: } else {
221: $_zp_zenpage = NULL;
222: }
223: return $ignore;
224: }
225:
226:
227:
228: 229: 230: 231:
232: static function checkForGuest($auth) {
233: global $_zp_current_zenpage_page, $_zp_current_category;
234: if (!is_null($_zp_current_zenpage_page)) {
235: $authType = $_zp_current_zenpage_page->checkforGuest();
236: return $authType;
237: } else if (!is_null($_zp_current_category)) {
238: $authType = $_zp_current_category->checkforGuest();
239: return $authType;
240: }
241: return $auth;
242: }
243:
244: 245: 246: 247: 248:
249: static function isMyItemToView($fail) {
250: global $_zp_gallery_page, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_current_category;
251: switch ($_zp_gallery_page) {
252: case 'pages.php':
253: if ($_zp_current_zenpage_page->isMyItem(LIST_RIGHTS)) {
254: return true;
255: }
256: break;
257: case 'news.php':
258: if (in_context(ZP_ZENPAGE_NEWS_ARTICLE)) {
259: if ($_zp_current_zenpage_news->isMyItem(LIST_RIGHTS)) {
260: return true;
261: }
262: } else {
263: if (zp_loggedin(ALL_NEWS_RIGHTS) || !is_object($_zp_current_category) || !$_zp_current_category->isProtected()) {
264: return true;
265: }
266: if (is_object($_zp_current_category)) {
267: if ($_zp_current_category->isMyItem(LIST_RIGHTS)) {
268: return true;
269: }
270: }
271: }
272: return false;
273: break;
274: }
275: return $fail;
276: }
277:
278: 279: 280: 281:
282: static function admin_toolbox_global($zf) {
283: global $_zp_zenpage;
284: if (zp_loggedin(ZENPAGE_NEWS_RIGHTS) && ZP_NEWS_ENABLED) {
285:
286: echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-news-articles.php\">" . gettext("News") . "</a></li>";
287: }
288: if (zp_loggedin(ZENPAGE_PAGES_RIGHTS) && ZP_PAGES_ENABLED) {
289: echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-pages.php\">" . gettext("Pages") . "</a></li>";
290: }
291: return $zf;
292: }
293:
294: static function admin_toolbox_pages($redirect, $zf) {
295: global $_zp_zenpage;
296: if (zp_loggedin(ZENPAGE_PAGES_RIGHTS) && ZP_PAGES_ENABLED) {
297:
298: echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&edit&titlelink=" . urlencode(getPageTitlelink()) . "\">" . gettext("Edit Page") . "</a></li>";
299: if (GALLERY_SESSION) {
300:
301: ?>
302: <li><a href="javascript:confirmDelete('<?php echo $zf . '/' . PLUGIN_FOLDER; ?>/zenpage/page-admin.php?del=<?php echo getPageID(); ?>&XSRFToken=<?php echo getXSRFToken('delete'); ?>',deletePage)"
303: title="<?php echo gettext("Delete page"); ?>"><?php echo gettext("Delete Page"); ?>
304: </a></li>
305: <?php
306: }
307: echo "<li><a href=\"" . FULLWEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&add\">" . gettext("Add Page") . "</a></li>";
308: }
309: return $redirect . '&title=' . urlencode(getPageTitlelink());
310: }
311:
312: static function admin_toolbox_news($redirect, $zf) {
313: global $_zp_zenpage, $_zp_current_category, $_zp_current_zenpage_news;
314: if (is_NewsArticle()) {
315: if (zp_loggedin(ZENPAGE_NEWS_RIGHTS) && ZP_NEWS_ENABLED) {
316:
317:
318:
319:
320: echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?newsarticle&edit&titlelink=" . html_encode($_zp_current_zenpage_news->getTitleLink()) . "\">" . gettext("Edit Article") . "</a></li>";
321: if (GALLERY_SESSION) {
322:
323: ?>
324: <li>
325: <a href="javascript:confirmDelete('<?php echo $zf . '/' . PLUGIN_FOLDER; ?>/zenpage/admin-news-articles.php?del=<?php echo getNewsID(); ?>&XSRFToken=<?php echo getXSRFToken('delete'); ?>',deleteArticle)"
326: title="<?php echo gettext("Delete article"); ?>"><?php echo gettext("Delete Article"); ?> </a>
327: </li>
328: <?php
329: }
330: echo "<li><a href=\"" . $zf . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?newsarticle&add\">" . gettext("Add Article") . "</a></li>";
331: }
332: $redirect .= '&title=' . urlencode($_zp_current_zenpage_news->getTitlelink());
333: } else {
334:
335: if (!empty($_zp_current_category)) {
336: $redirect .= '&category=' . $_zp_current_category->getTitlelink();
337: }
338: }
339: return $redirect;
340: }
341:
342: }
343:
344: 345: 346: 347: 348:
349: function getNewsIndexURL($page = '') {
350: $rewrite = _NEWS_ . '/';
351: $plain = '/index.php?p=news';
352: if ($page > 1) {
353: $rewrite .= $page . '/';
354: $plain .= '&page=' . $page;
355: }
356: return zp_apply_filter('getLink', rewrite_path($rewrite, $plain), 'news.php', $page);
357: }
358:
359: 360: 361: 362: 363: 364:
365: function getNewsArchiveURL($date) {
366: return zp_apply_filter('getLink', rewrite_path(_NEWS_ARCHIVE_ . '/' . $date . '/', "/index.php?p=news&date=$date"), 'news.php', NULL);
367: }
368: ?>
369: