Skip to content

Instantly share code, notes, and snippets.

@garvinhicking
Created February 25, 2014 11:17
Show Gist options
  • Save garvinhicking/9207103 to your computer and use it in GitHub Desktop.
Save garvinhicking/9207103 to your computer and use it in GitHub Desktop.
+4.10 Fixed (4.06) markup and sets (4.06 listentries) to be optional (selectbox default) due to errors
+ Added some css
+ Fixed some minor markup errors
+ Fixed backend_templates/default_staticpage_backend.tpl smarty markup (escape and cke-wysiwyg)
+ Changed Template names
+ Added 'publishstatus' and removed 'pass','is_startpage','is_404_page' in plugins config options,
+ since the latter were unused there and are too specific to be set global in plugin config.
+ Now 'publishstatus' will respect a global show as option rule (Draft is default)
+ Outsourced some heavy markup functions
+ Smartified the backend as much as possible (get ready to run smarty-only in future?)
+4.06 Bump version since merged entry list pull request by (ogerlach)
+@define('STATICPAGE_SHOWLIST_DEFAULT', 'Backend: Zeige als Eintragsliste');
+@define('STATICPAGE_SHOWLIST_DESC', 'Zeige Management Startseite als Eintrags Liste. Auswahlliste Standardeinstellung.');
+@define('STATICPAGE_SHOWLIST_DEFAULT', 'Backend: Zeige als Eintragsliste');
+@define('STATICPAGE_SHOWLIST_DESC', 'Zeige Management Startseite als Eintrags Liste. Auswahlliste Standardeinstellung.');
+@define('STATICPAGE_SHOWLIST_DEFAULT', 'Backend: Show as entry list');
+@define('STATICPAGE_SHOWLIST_DESC', 'Show backends staticpage startpage as entry list. Selectbox default.');
+ 'publishstatus',
- 'pass',
- 'is_startpage',
- 'is_404_page',
- 'use_quicksearch'
+ 'use_quicksearch',
+ 'showlist'
+ case 'showlist':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', STATICPAGE_SHOWLIST_DEFAULT);
+ $propbag->add('description', STATICPAGE_SHOWLIST_DESC);
+ $propbag->add('default', false);
+ break;
+ case 'publishstatus':
+ $propbag->add('type', 'select');
+ $propbag->add('name', STATICPAGE_PUBLISHSTATUS);
+ $propbag->add('description', STATICPAGE_DEFAULT_DESC);
+ $propbag->add('select_values', array(DRAFT, PUBLISH));
+ $propbag->add('default', '');
+ break;
- if (!isset($this->staticpage['publishstatus'])) {
- $this->staticpage['publishstatus'] = '1';
- }
+ if ($is_smarty) {
+ if (is_string($result)) $serendipity['smarty']->assign('sp_pagetype_update', true);
+ $serendipity['smarty']->assign('sp_pagetype_mixedresult', $result);
+ // moduled, since using lots of html/smarty output
+ include_once 'backend_show.php';
+ if ($is_smarty) {
+ $filename = 'backend_staticpage.tpl';
+ $content = $this->parseTemplate($filename);
+ echo $content;
+ /**
+ * Sequence Drag&Drop pageorder mover
+ *
+ * @param array new sorted id list
+ * @access private
+ * @return null
+ */
+ function move_sequence($order)
+ foreach ($order as $key => $id) {
+ serendipity_db_update('staticpages', array('id' => $id), array('pageorder' => $key));
+ @unlink($this->cachefile);
+ // else call moduled, since using lots of html/smarty output - needs to load multiple times! Dont use *_once!
+ include 'backend_inspectConfig.php';
+ // this brings pagetype into "scope". Without, value will not work, which is strange ...
+ if (!empty($this->pagetype) && $serendipity['POST']['pagetype'] != '__new') {
+ $this->fetchPageType($this->pagetype['id']);
+ }
+ // get global set show publishstatus for smartified showform and new
+ if (empty($this->pagetype) && $serendipity['POST']['pagetype'] == '__new') {
+ $this->staticpage['publishstatus'] = serendipity_db_bool($this->get_config('publishstatus'));
+ }
- $config_value = $this->staticpage[$config_item];
+ $config_value = empty($this->pagetype) ? $this->get_static($config_item, 'unset') : $this->pagetype[$config_item];
+ // $this->staticpage can be an empty or an fullfilled array - while pagetype is only empty, if the request fetches the default_staticpage_backend.tpl template.
+ if(empty($this->pagetype)) {
+ } else {
+ $this->introspect_item_type($config_item, $cbag);
+ }
- $value = $this->get_static($config_item, 'unset');
+ $value = empty($this->pagetype) ? $this->get_static($config_item, 'unset') : $this->get_type($config_item, 'unset');
- ?>
- <script type="text/javascript">
- function Spawnnugget() {
- <?php foreach($this->htmlnugget AS $htmlnuggetid) {
- if (version_compare(preg_replace('@[^0-9\.]@', '', $serendipity['version']), '0.9', '<')) { ?>
- if (window.Spawnnuggets) Spawnnuggets<?php echo $htmlnuggetid; ?>();
- <?php } else { ?>
-
- if (window.Spawnnuggets) Spawnnuggets('<?php echo $htmlnuggetid; ?>');
- <?php } ?>
- <?php } ?>
- }
- </script>
- <?php
+ // smarty only function
+ $serendipity['smarty']->assign( array(
+ 'sp_pagetype_showform_isnuggets' => true,
+ 'sp_pagetype_showform_htmlnuggets' => $this->htmlnugget
+ ));
- // Code copied from include/admin/plugins.inc.php. Sue me. ;-)
+ // get global set show publishstatus for non-smarty showform and new
+ if ($serendipity['POST']['backend_template'] == 'internal' && $serendipity['POST']['staticpage'] == '__new') {
+ $this->staticpage['publishstatus'] = serendipity_db_bool($this->get_config('publishstatus'));
+ }
- if ($value_func == 'get_static' && $serendipity['POST']['backend_template'] != 'internal') {
+ // Code copied from include/admin/plugins.inc.php. Sue me. ;-)
+ // now 'get_type' also needs to use a smartified file, therefore we check for 'is_smarty' instead
+ if (/*$value_func == 'get_static'*/$is_smarty && $serendipity['POST']['backend_template'] != 'internal') {
+ /* ToDo: Convert to Smarty3 register() in future! */
- if (isset($serendipity['wysiwyg'])) {
- $serendipity['smarty']->assign('is_wysiwyg', $serendipity['wysiwyg']);
+ if ($serendipity['wysiwyg'] && !class_exists('serendipity_event_ckeditor')) {
+ $serendipity['smarty']->assign('is_wysiwyg', true); // ckeditor has no need to disable 2cd collapsible box
+ // check for other templates, else set default
- 'form_container' => $this->staticpage,
+ 'form_container' => ($this->staticpage ? $this->staticpage : $this->pagetype),
+ if (!$is_smarty) {
+ }
+ if ($serendipity['POST']['backend_template'] == 'internal') $serendipity['smarty']->assign('sp_defpages_oldform', true); // in case cookie for internal template exist (POST = COOKIE newly added in listentries part of backend_show.php)
- $this->inspectConfig(false, 'input', $elcount, $config_item, $config_value, $type, $cname, $cdesc, $value, $default, $lang_direction, $hvalue, $radio, $radio2, $select, $per_row, $per_row2);
+ $this->inspectConfig(false, 'input', $elcount, $config_item, $config_value, $type, $cname, $cdesc, $value, $default, $lang_direction, $hvalue, $radio, $radio2, $select, $per_row, $per_row2); // was smarty false
+ if (!$is_smarty) {
- function Spawnnugget() {
- <?php foreach($this->htmlnugget AS $htmlnuggetid) {
- if (version_compare(preg_replace('@[^0-9\.]@', '', $serendipity['version']), '0.9', '<')) { ?>
- if (window.Spawnnuggets) Spawnnuggets<?php echo $htmlnuggetid; ?>();
- <?php } else { ?>
-
+ function Spawnnugget() { //no smarty
+ <?php foreach($this->htmlnugget AS $htmlnuggetid) { ?>
- <?php } ?>
+ } else {
+ $serendipity['smarty']->assign( array(
+ 'sp_pagetype_showform_isnuggets' => true,
+ 'sp_pagetype_showform_htmlnuggets' => $this->htmlnugget
+ ));
+ }
+ if (!$is_smarty) {
+ }
- $entry_pre = '';
+ $published = true;
- $entry_pre .= ' ' . DRAFT . ': ';
+ $published = false;
+ // this markup happens inside backend categories, which is non smartified
- $this->showBackend();
+ $this->showBackend(serendipity_smarty_init());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment