function serendipity_plugin_api_core_event_hook($event, &$bag, &$eventData, &$addData) { global $serendipity; switch ($event) { case 'js_backend': case 'js': // Add a global available (index.tpl; admin/index.tpl; preview_iframe.tpl) redirect error string function used by errorToExceptionHandler() // hardened by admin only - better have that here, to be reachable everywhere if ($serendipity['production'] === true && $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) { echo "\nfunction errorHandlerCreateDOM(htmlStr) {\n var frag = document.createDocumentFragment(),\n temp = document.createElement('div');\n temp.innerHTML = htmlStr;\n while (temp.firstChild) {\n frag.appendChild(temp.firstChild);\n }\n return frag;\n} \n"; } break; case 'external_plugin': switch ($eventData) { case 'admin/serendipity_editor.js': header('Content-Type: application/javascript'); global $serendipity; echo serendipity_smarty_show('admin/serendipity_editor.js.tpl', null, 'JS', 'include/plugin_api.inc.php:external_plugin'); break; } break; case 'backend_save': case 'backend_publish': echo '<script>$(document).ready(function() { if(Modernizr.indexeddb) { serendipity.eraseEntryEditorCache(); } });</script>'; return true; break; } }
function serendipity_plugin_api_core_event_hook($event, &$bag, &$eventData, &$addData) { global $serendipity; switch ($event) { case 'js_backend': case 'js': // Add a global available (index.tpl; admin/index.tpl; preview_iframe.tpl) redirect error string function used by errorToExceptionHandler() // hardened by admin only - better have that here, to be reachable everywhere if ($serendipity['production'] === true && $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN) { echo "\nfunction errorHandlerCreateDOM(htmlStr) {\n var frag = document.createDocumentFragment(),\n temp = document.createElement('div');\n temp.innerHTML = htmlStr;\n while (temp.firstChild) {\n frag.appendChild(temp.firstChild);\n }\n return frag;\n} \n"; } break; case 'external_plugin': if ($eventData == 'admin/serendipity_editor.js') { header('Content-Type: application/javascript'); echo serendipity_smarty_show('admin/serendipity_editor.js.tpl', null, 'JS', 'include/plugin_api.inc.php:external_plugin'); } break; case 'backend_save': case 'backend_publish': // this is preview_iframe.tpl updertHooks [ NOT ONLY!! See freetags ] if ($_GET['serendipity']['is_iframe'] == 'true' && $_GET['serendipity']['iframe_mode'] == 'save') { echo "\n" . '<script>document.addEventListener("DOMContentLoaded", function() { if (window.parent.Modernizr.indexedDB) { window.parent.serendipity.eraseEntryEditorCache(); } });</script>' . "\n"; } break; } }
$data['rip_entry'] = array(); foreach ($serendipity['POST']['multiDelete'] as $idx => $id) { $ids .= (int) $id . ','; $entry = serendipity_fetchEntry('id', $id, 1, 1); $data['is_multidelete'] = true; $data['rip_entry'][] = sprintf(DELETE_SURE, $entry['id'] . ' - ' . serendipity_specialchars($entry['title'])); } $newLoc = '?' . serendipity_setFormToken('url') . '&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=doMultiDelete&serendipity[id]=' . $ids; $data['switched_output'] = true; $data['newLoc'] = $newLoc; break; case 'edit': $entry = serendipity_fetchEntry('id', $serendipity['GET']['id'], 1, 1); default: include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php'; // edit entry mode $entryForm = serendipity_printEntryForm('?', array('serendipity[action]' => 'admin', 'serendipity[adminModule]' => 'entries', 'serendipity[adminAction]' => 'save'), isset($entry) ? $entry : array()); } $data['entryForm'] = $entryForm; $data['errors'] = $errors; $data['get'] = $serendipity['GET']; // don't trust {$smarty.get.vars} if not proofed, as we often change GET vars via serendipty['GET'] by runtime // make sure we've got these if (!isset($data['urltoken'])) { $data['urltoken'] = serendipity_setFormToken('url'); } if (!isset($data['formtoken'])) { $data['formtoken'] = serendipity_setFormToken(); } echo serendipity_smarty_show('admin/entries.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
} if ($info['demoURL']) { $data['templates'][$theme]['demoURL'] = $info['demoURL']; } } $unmetRequirements = array(); if (isset($info['require serendipity']) && version_compare($info['require serendipity'], serendipity_getCoreVersion($serendipity['version']), '>')) { $unmetRequirements[] = 'Serendipity ' . $info['require serendipity']; $data['templates'][$theme]['unmetRequirements'] = sprintf(UNMET_REQUIREMENTS, implode(', ', $unmetRequirements)); } if ($info['recommended']) { $data['recommended_templates'][$theme] = $data['templates'][$theme]; if ($theme != $serendipity['template'] && $theme != $serendipity['template_backend']) { unset($data['templates'][$theme]); } } } uasort($data['templates'], function ($a, $b) { return strnatcasecmp($a['info']['name'], $b['info']['name']); }); $data['cur_tpl'] = $data['templates'][$serendipity['template']]; $data['cur_tpl_backend'] = $data['templates'][$serendipity['template_backend']]; unset($data['templates'][$serendipity['template']]); if ($serendipity['template'] != $serendipity['template_backend'] && isset($data['recommended_templates'][$serendipity['template_backend']]) && isset($data['templates'][$serendipity['template_backend']])) { // when we could not unset a template because it is a backend template, and when that template is also a recommended template, then it will now // be in recommended and in the normal tmeplate list. We just detected that and have to remove it unset($data['templates'][$serendipity['template_backend']]); } unset($data['recommended_templates'][$serendipity['template']]); echo serendipity_smarty_show('admin/templates.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
$data['cat'] = $this_cat; if (!is_array($this_cat) || isset($this_cat['authorid']) && $this_cat['authorid'] == '0' || isset($read_groups[0])) { $data['selectAllReadAuthors'] = true; } if (!is_array($this_cat) || isset($this_cat['authorid']) && $this_cat['authorid'] == '0' || isset($write_groups[0])) { $data['selectAllWriteAuthors'] = true; } $categories = serendipity_fetchCategories('all'); $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); $data['categories'] = $categories; // hook content as var to category.inc.tpl, to place inside the form ob_start(); serendipity_plugin_api::hook_event('backend_category_showForm', $cid, $this_cat); $data['category_showForm'] = ob_get_contents(); ob_end_clean(); } if ($serendipity['GET']['adminAction'] == 'view') { if (empty($admin_category)) { $cats = serendipity_fetchCategories('all'); } else { $cats = serendipity_fetchCategories(null, null, null, 'write'); } $data['view'] = true; $data['viewCats'] = $cats; if (is_array($cats)) { $categories = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED); $data['viewCategories'] = $categories; } } echo serendipity_smarty_show('admin/category.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
$from = array(); } elseif (serendipity_checkPermission('adminUsersMaintainOthers') || serendipity_checkPermission('adminUsersMaintainSame') && $group_intersect) { $data['create_permission'] = true; $from =& $user[0]; unset($from['password']); } else { $from = array(); } } else { $from = array(); } $data['from'] = $from; $config = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE); if (!empty($serendipity['GET']['userid'])) { $from['groups'] = serendipity_getGroups($serendipity['GET']['userid']); } else { $from['groups'] = array(); } $data['config'] = serendipity_printConfigTemplate($config, $from, true, false, true, true); } elseif ($serendipity['GET']['adminAction'] == 'delete' && serendipity_checkPermission('adminUsersDelete')) { $user = serendipity_fetchUsers($serendipity['GET']['userid']); $group_intersect = serendipity_intersectGroup($user[0]['authorid']); if (serendipity_checkPermission('adminUsersMaintainOthers') || serendipity_checkPermission('adminUsersMaintainSame') && $group_intersect) { $data['delete'] = true; $data['userid'] = (int) $serendipity['GET']['userid']; $data['realname'] = $user[0]['realname']; $data['formToken'] = serendipity_setFormToken(); } } echo serendipity_smarty_show('admin/users.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
global $serendipity; if (!serendipity_checkPermission('adminImagesView')) { return; } $output = ""; // After upload, do not show the list to be able to proceed to // media selection. if ($addvar_check && !empty($GLOBALS['image_selector_addvars'])) { return true; } if (!isset($serendipity['thumbPerPage'])) { $serendipity['thumbPerPage'] = 2; } $smarty_vars = array('textarea' => isset($serendipity['GET']['textarea']) ? $serendipity['GET']['textarea'] : false, 'htmltarget' => isset($serendipity['GET']['htmltarget']) ? $serendipity['GET']['htmltarget'] : '', 'filename_only' => isset($serendipity['GET']['filename_only']) ? $serendipity['GET']['filename_only'] : false); $show_upload = isset($serendipity['GET']['showUpload']) ? $serendipity['GET']['showUpload'] : false; $output .= serendipity_displayImageList(isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1, $serendipity['thumbPerPage'], isset($serendipity['GET']['showMediaToolbar']) ? serendipity_db_bool($serendipity['GET']['showMediaToolbar']) : true, NULL, $show_upload, NULL, $smarty_vars); return $output; } if (!isset($data['showML'])) { if (isset($_REQUEST['go_properties'])) { $data['showMLbutton'] = true; } else { // always having the ML available is useful when switching the filter after adding an image, thus being in the add-case $data['showML'] = showMediaLibrary(); } } $data['get']['fid'] = $serendipity['GET']['fid']; // don't trust {$smarty.get.vars} if not proofed, as we often change GET vars via serendipty['GET'] by runtime $data['get']['only_path'] = $serendipity['GET']['only_path']; echo serendipity_smarty_show('admin/images.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
/** * Prints the content of the iframe. * * Called by serendipity_is_iframe, when preview is requested. Fetches data from session. * An iframe is used so that a single s9y page must not timeout on intensive operations, * and so that the frontend stylesheet can be embedded without screwing up the backend. * * @access private * @see serendipity_is_iframe() * @param mixed The entry array (comes from session variable) * @param string Indicates whether an entry is previewed or saved. Save performs XML-RPC calls. * @param boolean Use smarty templating? * @return boolean Indicates whether iframe data was printed */ function serendipity_iframe(&$entry, $mode = null) { global $serendipity; if (empty($mode) || !is_array($entry)) { return false; } $data = array(); $data['is_preview'] = true; $data['mode'] = $mode; switch ($mode) { case 'save': ob_start(); $res = serendipity_updertEntry($entry); $data['updertHooks'] = ob_get_contents(); ob_end_clean(); if (is_string($res)) { $data['res'] = $res; } if (!empty($serendipity['lastSavedEntry'])) { $data['lastSavedEntry'] = $serendipity['lastSavedEntry']; } $data['entrylink'] = serendipity_archiveURL($res, $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); break; case 'preview': $serendipity['smarty_preview'] = true; $data['preview'] = serendipity_printEntries(array($entry), $entry['extended'] != '' ? 1 : 0, true); break; } return serendipity_smarty_show('preview_iframe.tpl', $data); }
$showWritableNote = true; } } $data['showWritableNote'] = $showWritableNote; $data['errorCount'] = $errorCount; if ($errorCount < 1) { if (sizeof($sqlfiles) > 0) { $data['database_update_types'] = sprintf(SERENDIPITY_UPGRADER_DATABASE_UPDATES, $serendipity['dbType']); $data['sqlfiles'] = $sqlfiles; } $taskCount = 0; $data['tasks'] = array(); foreach ($tasks as $task) { if (version_compare($serendipity['versionInstalled'], $task['version'], '<')) { $data['tasks'][] = $task; $taskCount++; } } $data['taskCount'] = $taskCount; } } $data['get']['action'] = $serendipity['GET']['action']; // don't trust {$smarty.get.vars} if not proofed, as we often change GET vars via serendipty['GET'] by runtime $data['templatePath'] = $serendipity['templatePath']; if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } /* see on top */ #$serendipity['smarty']->registerPlugin('function', 'serendipity_upgraderResultDiagnose', 'serendipity_smarty_backend_upgraderResultDiagnose'); echo serendipity_smarty_show('admin/upgrader.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers')) { serendipity_plugin_api::remove_plugin_instance($key); } } } } if (isset($_POST['SAVE'])) { $data['save'] = true; $data['timestamp'] = serendipity_strftime('%H:%M:%S'); } ob_start(); serendipity_plugin_api::hook_event('backend_pluginlisting_header', $null); $data['backend_pluginlisting_header'] = ob_get_contents(); ob_end_clean(); ob_start(); serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity); $data['backend_plugins_sidebar_header'] = ob_get_contents(); ob_end_clean(); $data['sidebar_plugins'] = show_plugins(false, $sidebars); ob_start(); serendipity_plugin_api::hook_event('backend_plugins_event_header', $serendipity); $data['backend_plugins_event_header'] = ob_get_contents(); ob_end_clean(); $data['event_plugins'] = show_plugins(true); if (count($serendipity['memSnaps']) > 0) { $data['$memsnaps'] = $serendipity['memSnaps']; } $data['updateAllMsg'] = isset($serendipity['GET']['updateAllMsg']); } echo serendipity_smarty_show('admin/plugins.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
$data['perms'][$perm]['permission'] = false; } else { $data['perms'][$perm]['permission'] = true; } } if ($serendipity['enablePluginACL']) { $data['enablePluginACL'] = true; $allplugins =& serendipity_plugin_api::get_event_plugins(); $allhooks = array(); $data['allplugins'] = $allplugins; foreach ($allplugins as $plugid => $currentplugin) { foreach ($currentplugin['b']->properties['event_hooks'] as $hook => $set) { $allhooks[$hook] = array(); } $data['allplugins'][$plugid]['has_permission'] = serendipity_hasPluginPermissions($plugid, $from['id']); } ksort($allhooks); $data['allhooks'] = $allhooks; foreach ($allhooks as $hook => $set) { $data['allhooks'][$hook]['has_permission'] = serendipity_hasPluginPermissions($hook, $from['id']); } } } elseif ($serendipity['GET']['adminAction'] == 'delete') { $data['delete'] = true; $group = serendipity_fetchGroup($serendipity['GET']['group']); $data['group_id'] = $serendipity['GET']['group']; $data['group'] = $group; $data['formToken'] = serendipity_setFormToken(); } echo serendipity_smarty_show('admin/groups.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
/** * Parses the configuration array and displays the configuration screen * * @access public * @param array Configuration superarray * @param array The previous values submitted by the user * @param boolean If true, no HTML FORM container will be emitted * @param boolean If true, the configuration sections will all be folded * @param boolean If true, the user can turn config sections on and off * @param boolean If true, the user can NOT display possibly dangerous options * @return null */ function serendipity_printConfigTemplate($config, $from = false, $noForm = false, $folded = true, $allowToggle = true, $showDangerous = false) { global $serendipity; $data = array(); $data['noForm'] = $noForm; $data['formToken'] = serendipity_setFormToken(); $data['allowToggle'] = $allowToggle; foreach ($config as &$category) { foreach ($category['items'] as &$item) { $value = $from[$item['var']]; /* Calculate value if we are not installed, how clever :) */ if ($from == false) { $value = serendipity_query_default($item['var'], $item['default']); } /* Check for installOnly flag */ if (in_array('installOnly', $item['flags']) && IS_installed === true) { continue; } if (in_array('hideValue', $item['flags'])) { $value = ''; } if (!$showDangerous && $item['view'] == 'dangerous') { continue; } if (in_array('config', $item['flags']) && isset($from['authorid'])) { $value = serendipity_get_user_config_var($item['var'], $from['authorid'], $item['default']); } if (in_array('parseDescription', $item['flags'])) { $item['description'] = serendipity_replaceEmbeddedConfigVars($item['description']); } if (in_array('probeDefault', $item['flags'])) { $item['default'] = serendipity_probeInstallation($item['var']); } if (in_array('ifEmpty', $item['flags']) && empty($value)) { $value = serendipity_query_default($item['var'], $item['default']); } $item['guessedInput'] = serendipity_guessInput($item['type'], $item['var'], $value, $item['default']); } } $data['config'] = $config; return serendipity_smarty_show('admin/config_template.tpl', $data); }
<?php $data = array(); // do not move to end of switch, since this will change smarty assignment scope ob_start(); include S9Y_INCLUDE_PATH . 'include/admin/import.inc.php'; $data['importMenu'] = ob_get_contents(); ob_end_clean(); switch ($serendipity['GET']['adminAction']) { case 'integrity': $data['action'] = "integrity"; if (!is_readable(S9Y_INCLUDE_PATH . 'checksums.inc.php') || 0 == filesize(S9Y_INCLUDE_PATH . 'checksums.inc.php')) { $data['noChecksum'] = true; break; } $data['badsums'] = serendipity_verifyFTPChecksums(); break; case 'runcleanup': // The smarty method clearCompiledTemplate() clears all compiled smarty template files in templates_c // Since there may be other compiled template files in templates_c too, we have to restrict this call() to clear the blogs template only, // to not have the following automated recompile, force the servers memory to get exhausted, // when using plugins like serendipity_event_gravatar plugin, which can eat up some MB... // Restriction to template means: leave the page we are on: ../admin/index.tpl and all others, which are set, included and compiled by runtime. (plugins, etc. this can be quite some..!) if (method_exists($serendipity['smarty'], 'clearCompiledTemplate')) { $data['cleanup_finish'] = (int) $serendipity['smarty']->clearCompiledTemplate(null, $serendipity['template']); $data['cleanup_template'] = $serendipity['template']; } break; } echo serendipity_smarty_show('admin/maintenance.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
} if (serendipity_checkConfigItemFlags($item, 'configuration')) { serendipity_set_config_var($item['var'], $_POST[$item['var']], $serendipity['authorid']); } } $pl_data = array('id' => $serendipity['POST']['authorid'], 'authorid' => $serendipity['POST']['authorid'], 'username' => $_POST['username'], 'realname' => $_POST['realname'], 'email' => $_POST['email']); serendipity_updatePermalink($pl_data, 'author'); serendipity_plugin_api::hook_event('backend_users_edit', $pl_data); } if ($serendipity['authorid'] === $_SESSION['serendipityAuthorid']) { if (is_null($serendipity['detected_lang'])) { $_SESSION['serendipityLanguage'] = $serendipity['lang']; } } $from = $_POST; } } $data['formToken'] = serendipity_setFormToken(); $template = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE); $user = serendipity_fetchUsers($serendipity['authorid']); $from = $user[0]; $from['groups'] = serendipity_getGroups($serendipity['authorid']); unset($from['password']); $data['config'] = serendipity_printConfigTemplate($template, $from, true, false); $add = array('internal' => true); serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_profiles', $from, $add); if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } echo serendipity_smarty_show('admin/personal.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
$class = 'serendipity_admin_list_item_' . ($i % 2 == 0 ? 'even' : 'uneven'); if ($comment['status'] == 'pending') { $class .= ' serendipity_admin_comment_pending'; $header_class = 'serendipityAdminMsgNote serendipity_admin_comment_pending_header'; } elseif (strstr($comment['status'], 'confirm')) { $class .= ' serendipity_admin_comment_pending serendipity_admin_comment_confirm'; $header_class = 'serendipityAdminMsgNote serendipity_admin_comment_pending_header serendipity_admin_comment_confirm_header'; } else { $header_class = ''; } $comment['class'] = $class; $comment['header_class'] = $header_class; if (!empty($comment['url']) && substr($comment['url'], 0, 7) != 'http://' && substr($comment['url'], 0, 8) != 'https://') { $comment['url'] = 'http://' . $comment['url']; } // include all comment vars back into upper array to assign to Smarty $comments[] = $comment; } } $data['comments'] = $comments; $data['errormsg'] = $errormsg; $data['msg'] = $msg; $data['urltoken'] = serendipity_setFormToken('url'); $data['formtoken'] = serendipity_setFormToken(); $data['get']['filter'] = $serendipity['GET']['filter']; // don't trust {$smarty.get.vars} if not proofed, as we often change GET vars via serendipty['GET'] by runtime if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } echo serendipity_smarty_show('admin/comments.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
/** * Prints a media item * * @param array Array of image metadata * @param string URL for maintenance tasks * @param boolean Whether to show maintenance task items * @param int how many media items to display per row * @param boolean Enclose within a table cell? * @param array Additional Smarty variables * @return string Generated HTML * */ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lineBreak = 3, $enclose = true, $smarty_vars = array()) { global $serendipity; $form_hidden = ''; // do not add, if not for the default media list form if (($serendipity['GET']['adminAction'] == 'default' || empty($serendipity['GET']['adminAction'])) && !$serendipity['GET']['fid']) { foreach ($serendipity['GET'] as $g_key => $g_val) { // do not add token, since this is assigned separately to properties and list forms if (!is_array($g_val) && $g_key != 'page' && $g_key != 'token') { $form_hidden .= ' <input type="hidden" name="serendipity[' . $g_key . ']" value="' . serendipity_specialchars($g_val) . '">' . "\n"; } } } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $order_fields = serendipity_getImageFields(); // reset filename for building template filters, since this is hardcoded as 'only_filename' unset($order_fields['i.name']); $media = array('manage' => $manage, 'multiperm' => serendipity_checkPermission('adminImagesDirectories'), 'lineBreak' => $lineBreak, 'lineBreakP' => round(1 / $lineBreak * 100), 'url' => $url, 'enclose' => $enclose, 'token' => serendipity_setFormToken(), 'form_hidden' => $form_hidden, 'blimit_path' => empty($smarty_vars['limit_path']) ? '' : basename($smarty_vars['limit_path']), 'only_path' => $serendipity['GET']['only_path'], 'only_filename' => $serendipity['GET']['only_filename'], 'sortorder' => $serendipity['GET']['sortorder'], 'keywords_selected' => $serendipity['GET']['keywords'], 'filter' => $serendipity['GET']['filter'], 'sort_order' => $order_fields, 'simpleFilters' => $serendipity['simpleFilters'], 'hideSubdirFiles' => $serendipity['GET']['hideSubdirFiles'], 'authors' => serendipity_fetchUsers(), 'sort_row_interval' => array(8, 16, 50, 100), 'nr_files' => count($file), 'keywords' => explode(';', $serendipity['mediaKeywords']), 'thumbSize' => $serendipity['thumbSize'], 'sortParams' => array('perpage', 'order', 'ordermode')); $media = array_merge($media, $smarty_vars); $media['files'] =& $file; if (count($paths) > 0) { $media['paths'] =& $paths; } else { $media['paths'] =& serendipity_getMediaPaths(); } $serendipity['smarty']->assignByRef('media', $media); if ($enclose) { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); return serendipity_smarty_show('admin/media_pane.tpl'); } else { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); return serendipity_smarty_show('admin/media_properties.tpl'); } }
serendipity_addDefaultGroup('USERLEVEL_EDITOR_DESC', USERLEVEL_EDITOR); serendipity_addDefaultGroup('USERLEVEL_CHIEF_DESC', USERLEVEL_CHIEF); serendipity_addDefaultGroup('USERLEVEL_ADMIN_DESC', USERLEVEL_ADMIN); $data['add_authors'] = true; serendipity_set_config_var('template', $serendipity['defaultTemplate']); $data['set_template_vars'] = true; include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php'; serendipity_plugin_api::register_default_plugins(); $data['register_default_plugins'] = true; } $errors = serendipity_installFiles($basedir); $data['errors_sif'] = $errors; if (serendipity_updateConfiguration()) { $data['s9y_installed'] = true; } echo serendipity_smarty_show("admin/installer.inc.tpl", $data); return; } include_once dirname(dirname(__FILE__)) . "/functions.inc.php"; if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $serendipity['smarty']->assign($data); $tfile = serendipity_getTemplateFile("admin/installer.inc.tpl"); ob_start(); include $tfile; $content = ob_get_contents(); ob_end_clean(); // eval a string template and do not store compiled code echo $serendipity['smarty']->display('eval:' . $content); /* vim: set sts=4 ts=4 expandtab : */
/** * Prints a media item * * @param array Array of image metadata * @param string URL for maintenance tasks * @param boolean Whether to show maintenance task items * @param int how many media items to display per row * @param boolean Enclose within a table cell? * @param array Additional Smarty variables * @return string Generated HTML * */ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lineBreak = 3, $enclose = true, $smarty_vars = array()) { global $serendipity; $form_hidden = ''; foreach ($serendipity['GET'] as $g_key => $g_val) { if (!is_array($g_val) && $g_key != 'page') { $form_hidden .= ' <input type="hidden" name="serendipity[' . $g_key . ']" value="' . serendipity_specialchars($g_val) . '">' . "\n"; } } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $media = array('manage' => $manage, 'lineBreak' => $lineBreak, 'lineBreakP' => round(1 / $lineBreak * 100), 'url' => $url, 'enclose' => $enclose, 'zoomIMG' => serendipity_getTemplateFile('admin/img/big_zoom.png'), 'renameIMG' => serendipity_getTemplateFile('admin/img/big_rename.png'), 'resizeIMG' => serendipity_getTemplateFile('admin/img/big_resize.png'), 'rotatecwIMG' => serendipity_getTemplateFile('admin/img/big_rotate_cw.png'), 'rotateccwIMG' => serendipity_getTemplateFile('admin/img/big_rotate_ccw.png'), 'configureIMG' => serendipity_getTemplateFile('admin/img/configure.png'), 'deleteIMG' => serendipity_getTemplateFile('admin/img/big_delete.png'), 'prevIMG' => serendipity_getTemplateFile('admin/img/previous.png'), 'nextIMG' => serendipity_getTemplateFile('admin/img/next.png'), 'token' => serendipity_setFormToken(), 'form_hidden' => $form_hidden, 'blimit_path' => empty($smarty_vars['limit_path']) ? '' : basename($smarty_vars['limit_path']), 'only_path' => $serendipity['GET']['only_path'], 'only_filename' => $serendipity['GET']['only_filename'], 'sortorder' => $serendipity['GET']['sortorder'], 'keywords_selected' => $serendipity['GET']['keywords'], 'filter' => $serendipity['GET']['filter'], 'sort_order' => serendipity_getImageFields(), 'authors' => serendipity_fetchUsers(), 'sort_row_interval' => array(8, 16, 50, 100), 'nr_files' => count($file), 'keywords' => explode(';', $serendipity['mediaKeywords']), 'thumbSize' => $serendipity['thumbSize'], 'sortParams' => array('perpage', 'order', 'ordermode'), 'filterParams' => array('only_path', 'only_filename')); foreach ($media['sortParams'] as $sortParam) { $serendipity['smarty']->assign(array("get_sortorder_{$sortParam}" => $serendipity['GET']['sortorder'][$sortParam])); } foreach ($media['filterParams'] as $filterParam) { $serendipity['smarty']->assign(array("{$filterParam}" => $serendipity['GET'][$filterParam])); } $media = array_merge($media, $smarty_vars); $media['files'] =& $file; if (count($paths) > 0) { $media['paths'] =& $paths; } else { $media['paths'] =& serendipity_getMediaPaths(); } $serendipity['smarty']->assignByRef('media', $media); if ($enclose) { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); return serendipity_smarty_show(serendipity_getTemplateFile('admin/media_pane.tpl', 'serendipityPath')); } else { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); return serendipity_smarty_show(serendipity_getTemplateFile('admin/media_properties.tpl', 'serendipityPath')); } }
function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) { # init == true when editor was already initialized static $init = false; global $serendipity; if ($init && $spawnMulti) { return; } if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg']) { $eventData = array('init' => &$init, 'item' => &$item, 'jsname' => &$jsname, 'skip' => false, 'buttons' => array()); serendipity_plugin_api::hook_event('backend_wysiwyg', $eventData); if ($eventData['skip']) { return; } $data = array('init' => $init, 'spawnMulti' => $spawnMulti, 'jsname' => $jsname, 'item' => $item, 'buttons' => $eventData['buttons']); echo serendipity_smarty_show('admin/wysiwyg_init.tpl', $data); } $init = true; }
/** * Show the plugin configuration * * @access public * @param object A plugin object * @param object The plugins property bag object * @param string The name of the plugin * @param string The description of the plugin * @param array The property bag 'configuration' array, holding the array of config items. * @param boolean Shows the surrounding HTML table? * @param boolean Shows the FORM submit button? * @param boolean Shows a plugin's "example" method output? * @param boolean Spawn a plugins' configuration WYSIWYG items? * @param string The array index name of POSTed values ($serendipity['POST'][xxx]) * @param array An array that groups certain config keys * @return string The configuration HTML */ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_names, $showTable = true, $showSubmit = true, $showExample = true, $spawnNuggets = true, $postKey = 'plugin', $config_groups = NULL) { global $serendipity; if (empty($config_names)) { return false; } $tfile = "/admin/plugin_config_item.tpl"; $data = array(); if ($showSubmit && $postKey != 'plugin') { $data['showSubmit_head'] = true; } if ($showTable) { $data['showTable'] = true; } $elcount = 0; $htmlnugget = array(); $plugin_options = array(); $data['config_names'] = $config_names; foreach ($config_names as $config_item) { $elcount++; $cbag = new serendipity_property_bag(); $plugin->introspect_config_item($config_item, $cbag); $data['cname'] = $cname = serendipity_specialchars($cbag->get('name')); $data['cdesc'] = $cdesc = serendipity_specialchars($cbag->get('description')); $value = $plugin->get_config($config_item, 'unset'); $lang_direction = serendipity_specialchars($cbag->get('lang_direction')); if (empty($lang_direction)) { $lang_direction = LANG_DIRECTION; } $data['lang_direction'] = $lang_direction; /* Apparently no value was set for this config item */ if ($value === 'unset') { /* Try and the default value for the config item */ $value = $cbag->get('default'); /* Still, we don't have a value, try and get (bool)false - from an old plugin */ if ($value === '') { $value = $plugin->get_config($config_item, false, true); } } if (isset($_POST['serendipity'][$postkey][$config_item])) { if (is_array($_POST['serendipity'][$postkey][$config_item])) { $hvalue = $_POST['serendipity'][$postkey][$config_item]; array_walk($hvalue, 'serendipity_specialchars'); } else { $hvalue = serendipity_specialchars($_POST['serendipity'][$postkey][$config_item]); } } else { $hvalue = serendipity_specialchars($value); } $radio = array(); $select = array(); $per_row = null; $text_rows = null; $input_type = null; $data['is_multi_select'] = $is_multi_select = false; $data['ctype'] = $ctype = $cbag->get('type'); $data['elcount'] = $elcount; $data['hvalue'] = $hvalue; $data['postKey'] = $postKey; $data['config_item'] = $config_item; $assign_plugin_config = function ($data) use(&$plugin_options, $tfile, $config_item) { $plugin_options[$config_item] = array('config' => serendipity_smarty_show($tfile, $data), 'ctype' => $data['ctype']); }; switch ($ctype) { case 'seperator': // compat, due being misspelled // compat, due being misspelled case 'separator': case 'suboption': $assign_plugin_config($data); break; case 'multiselect': $data['is_multi_select'] = $is_multi_select = true; case 'select': $data['ctype'] = 'select'; if (is_array($hvalue)) { $selected_options = $hvalue; } elseif ($is_multi_select) { $selected_options = explode('^', $hvalue); } else { $selected_options = array($hvalue => $hvalue); } $data['selected_options'] = $selected_options; $data['pre_selected'] = $pre_selected = (array) $cbag->get('select_preselected'); $data['select_size'] = $select_size = $cbag->get('select_size'); $data['select'] = $select = $cbag->get('select_values'); $assign_plugin_config($data); break; case 'tristate': $data['ctype'] = 'tristate'; $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $data['ctype'] = 'boolean'; $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case 'radio': $data['ctype'] = 'radio'; if (!count($radio) > 0) { $radio = $cbag->get('radio'); } if (empty($per_row)) { $per_row = $cbag->get('radio_per_row'); if (empty($per_row)) { $per_row = 2; } } $data['per_row'] = $per_row; $data['radio_button'] = array(); $counter = 0; foreach ($radio['value'] as $radio_index => $radio_value) { $id = serendipity_specialchars($config_item . $radio_value); $counter++; $checked = ""; if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) { $checked = " checked"; } elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue === 'false')) { $checked = " checked"; } elseif ($radio_value == $hvalue) { $checked = " checked"; } $data['radio_button'][$radio_index]['id'] = $id; $data['radio_button'][$radio_index]['checked'] = $checked; $data['radio_button'][$radio_index]['counter'] = $counter; $data['radio_button'][$radio_index]['value'] = $radio_value; $data['radio_button'][$radio_index]['index'] = serendipity_specialchars($radio['desc'][$radio_index]); } $assign_plugin_config($data); break; case 'string': $data['ctype'] = 'string'; if (empty($input_type)) { $input_type = $cbag->get('input_type'); if (empty($input_type)) { $input_type = "text"; } } $data['input_type'] = $input_type; $assign_plugin_config($data); break; case 'html': $data['ctype'] = 'html'; case 'text': $data['ctype'] = 'text'; if (empty($text_rows)) { $text_rows = $cbag->get('rows'); if (empty($text_rows)) { $text_rows = 20; } } $data['text_rows'] = $text_rows; if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; if (!function_exists('serendipity_emit_htmlarea_code')) { @(include_once dirname(__FILE__) . '/functions_entries_admin.inc.php'); } // use SpawnMulti false per default (for multi nugget textareas, eg linklist sidebar plugin) - but where do we use jsname though? serendipity_emit_htmlarea_code("nuggets{$elcount}", "nuggets{$elcount}"); } $assign_plugin_config($data); break; case 'content': $data['ctype'] = 'content'; $data['cbag_default'] = $cbag->get('default'); $assign_plugin_config($data); break; case 'custom': $data['ctype'] = 'custom'; $data['cbag_custom'] = $cbag->get('custom'); $assign_plugin_config($data); break; case 'hidden': $data['ctype'] = 'hidden'; $data['cbag_value'] = $cbag->get('value'); $assign_plugin_config($data); break; case 'media': $data['ctype'] = 'media'; // Print the HTML to display the popup media selector $preview_width = $cbag->get('preview_width'); if (!$preview_width || $preview_width == "") { $preview_width = '400px'; } $preview_height = $cbag->get('preview_height'); if (!$preview_height || $preview_height == "") { $preview_height = '100px'; } $data['preview_width'] = $preview_width; $data['preview_height'] = $preview_height; $data['value'] = $value; $assign_plugin_config($data); break; case 'sequence': $data['ctype'] = 'sequence'; // For the drag-n-drop to work, the list must be included in // a container (probably an <ol>) that JavaScript can access // (easiest by ID), with <li> children that have unique IDs, // and handles with ids of 'g'.$li_id. // I can't get it to work unless there's a class of // pluginmanager_container on the ol, either. // The drag-n-drop returns the list of IDs in order. $data['sequencejs_output'] = $sequencejs_output = $serendipity['sequencejs_output']; if (!$sequencejs_output) { $serendipity['sequencejs_output'] = true; } // I want this generic sequence widget to hide the ID, but // display a name or description with an optional picture. // (This would allow users to identify choices by thumbnail.) // Therefore, I need an array with keys 'id', 'display', and // 'imgurl' (or similar) to generate each list item. // Get the data we need to display the list if (!$value) { $value = $eventData['default']; } $data['value'] = $value; $data['cname'] = $cname = $cbag->get('name'); $data['cdesc'] = $cdesc = $cbag->get('description'); $data['checkable'] = $checkable = $cbag->get('checkable'); /** Unordered array of values */ $items = $cbag->get('values'); if (!is_array($items)) { $items = null; } /** Array specifying order to use values in $items */ $order = null; if ($value) { $data['store_order'] = $store_order = $order = explode(',', $value); } // $items is the list of things to sequence. It's not in // order, and reordering PHP arrays is problematic. So // we keep it unordered, and access its values according // to another array (appropriately named $order). if (is_array($items)) { // Allow simple value for any sequence item foreach ($items as $key => $item) { if (!is_array($item)) { // Replace this item with an empty array unset($items[$key]); $items[$item] = array(); } } // Make sure all the items are in the order list; new items // go on the end (new items could have been added without // this config item being updated) // Also fill out thumbnails and display names foreach ($items as $id => $junk) { if ($order == null) { $order = array($id); } else { if (!in_array($id, $order)) { $order[] = $id; } } // If there's no defined display name, default to the ID if (!isset($items[$id]['display'])) { $items[$id]['display'] = $id; } // If there's no image, we just won't display anything. } // Make sure all the items to be ordered exist! Otherwise // we could try to sequence nothing. $filtered = array(); foreach ($order as $id) { if (array_key_exists($id, $items)) { $filtered[] = $id; } } $order = $filtered; } else { // If there's nothing to sequence, make the order in // which to use them valid, but empty $order = array(); } // Start the row, add one cell for the name and description $data['items'] = $items; $sort_idx = 0; $data['last'] = $last = count($order) - 1; foreach ($order as $id) { // Create the variables required to print this item if ($sort_idx > 0) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx - 1)]; $swapping[(int) ($sort_idx - 1)] = $temp; $data['order_id'][$sort_idx]['oneup'] = $oneup = implode(',', $swapping); } if ($sort_idx < $last) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx + 1)]; $swapping[(int) ($sort_idx + 1)] = $temp; $data['order_id'][$sort_idx]['onedown'] = $onedown = implode(',', $swapping); } $data['order_id'][$sort_idx]['id'] = $id; $data['order_id'][$sort_idx]['sort_idx'] = $sort_idx; // Print the HTML // // Set the item and its ID // Make a handle with ID 'g$id' // Add the item contents // Luddite submit buttons (please, think of the scriptless!) // Next, please $sort_idx++; } // foreach end if (!is_array($items) or empty($order)) { // Print the empty message $data['no_sequence'] = sprint(NONE); } // Print the Javascript to drag-n-drop the list // Finish the row $assign_plugin_config($data); break; default: $data['ctype'] = 'default'; // Unknown configuration key. Let the plugin handle it. $addData = func_get_args(); $eventData = array('config_item' => $config_item, 'cbag' => $cbag, 'plugin' => $plugin, 'value' => $value, 'bag' => $bag, 'postKey' => $postKey); ob_start(); serendipity_plugin_api::hook_event('backend_pluginconfig_' . $ctype, $eventData, $addData); $plugin_options[$config_item]['config'] = ob_get_contents(); $plugin_options[$config_item]['ctype'] = 'default'; ob_end_clean(); break; } } $data['config_groups'] = $config_groups; $data['plugin_options'] = $plugin_options; if (is_array($config_groups)) { foreach ($config_groups as $config_header => $config_groupkeys) { foreach ($config_groupkeys as $config_groupkey) { unset($plugin_options[$config_groupkey]); } } } $data['plugin_options_ungrouped'] = $plugin_options; if ($showSubmit) { $data['showSubmit_foot'] = true; } if ($showExample && method_exists($plugin, 'example')) { $data['showExample'] = true; $data['plugin_example'] = $plugin->example(); } if ($spawnNuggets && isset($serendipity['wysiwyg']) && $serendipity['wysiwyg'] && count($htmlnugget) > 0) { $data['spawnNuggets'] = true; $ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false); serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev); $data['ev'] = $ev; } return serendipity_smarty_show('admin/plugin_config.tpl', $data); }
<?php # $Id$ if (IN_serendipity !== true) { die('Don\'t hack!'); } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } echo serendipity_smarty_show('admin/entries_overview.inc.tpl'); /* vim: set sts=4 ts=4 expandtab : */
$comment['fullBody'] = $comment['body']; $comment['summary'] = serendipity_mb('substr', $comment['body'], 0, 100); if (strlen($comment['fullBody']) > strlen($comment['summary'])) { $comment['excerpt'] = true; // When summary is not the full body, strip HTML tags from summary, as it might break and leave unclosed HTML. $comment['fullBody'] = nl2br(serendipity_specialchars($comment['fullBody'])); $comment['summary'] = nl2br(strip_tags($comment['summary'])); } } } $data['comments'] = $comments; $entries = serendipity_fetchEntries(false, false, (int) $serendipity['dashboardLimit'], true, false, 'timestamp DESC', 'e.timestamp >= ' . serendipity_serverOffsetHour()); $entriesAmount = count($entries); if ($entriesAmount < (int) $serendipity['dashboardDraftLimit']) { // there is still space for drafts $drafts = serendipity_fetchEntries(false, false, (int) $serendipity['dashboardDraftLimit'] - $entriesAmount, true, false, 'timestamp DESC', "isdraft = 'true' AND e.timestamp <= " . serendipity_serverOffsetHour()); if (is_array($entries) && is_array($drafts)) { $entries = array_merge($entries, $drafts); } else { if (is_array($drafts)) { // $entries is not an array, thus empty $entries = $drafts; } } } $data['entries'] = $entries; $data['urltoken'] = serendipity_setFormToken('url'); $data['token'] = serendipity_setFormToken(); $data['no_create'] = $serendipity['no_create']; echo serendipity_smarty_show('admin/overview.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
$data['res'] = $res; if (is_array($res)) { $data['diagnosticError'] = true; } else { /* If we have new rewrite rules, then install them */ $permalinkOld = array($oldConfig['serendipityHTTPPath'], $oldConfig['serendipityPath'], $oldConfig['defaultBaseURL'], $oldConfig['indexFile'], $oldConfig['rewrite']); $permalinkNew = array($serendipity['serendipityHTTPPath'], $serendipity['serendipityPath'], $serendipity['defaultBaseURL'], $serendipity['indexFile'], $serendipity['rewrite']); // Compare all old permalink section values against new one. A change in any of those // will force to update the .htaccess for rewrite rules. $permconf = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE); if (is_array($permconf) && is_array($permconf['permalinks']['items'])) { foreach ($permconf['permalinks']['items'] as $permitem) { $permalinkOld[] = $oldConfig[$permitem['var']]; $permalinkNew[] = $serendipity[$permitem['var']]; } } if (serendipity_checkPermission('siteConfiguration') && serialize($permalinkOld) != serialize($permalinkNew)) { $data['htaccessRewrite'] = true; $data['serendipityPath'] = $serendipity['serendipityPath']; $res = serendipity_installFiles($serendipity['serendipityPath']); $data['res'] = $res; serendipity_buildPermalinks(); } } } $data['config'] = serendipity_printConfigTemplate(serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE), $serendipity, false, true); if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } echo serendipity_smarty_show('admin/configuration.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */