[ Index ] |
|
Code source de Serendipity 1.2 |
1 <?php # $Id: templates.inc.php 1816 2007-08-06 10:18:39Z garvinhicking $ 2 # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) 3 # All rights reserved. See LICENSE file for licensing details 4 5 if (IN_serendipity !== true) { 6 die ("Don't hack!"); 7 } 8 9 if (!serendipity_checkPermission('adminTemplates')) { 10 return; 11 } 12 13 class template_option { 14 var $config = null; 15 var $values = null; 16 var $keys = null; 17 18 function introspect_config_item($item, &$bag) { 19 foreach($this->config[$item] AS $key => $val) { 20 $bag->add($key, $val); 21 } 22 } 23 24 function get_config($item) { 25 return $this->values[$item]; 26 } 27 28 function set_config($item, $value) { 29 global $serendipity; 30 serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options 31 WHERE okey = 't_" . serendipity_db_escape_string($serendipity['template']) . "' 32 AND name = '" . serendipity_db_escape_string($item) . "'"); 33 serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (okey, name, value) 34 VALUES ('t_" . serendipity_db_escape_string($serendipity['template']) . "', '" . serendipity_db_escape_string($item) . "', '" . serendipity_db_escape_string($value) . "')"); 35 return true; 36 } 37 38 function import(&$config) { 39 foreach($config AS $key => $item) { 40 $this->config[$item['var']] = $item; 41 $this->keys[$item['var']] = $item['var']; 42 } 43 } 44 } 45 46 if ($serendipity['GET']['adminAction'] == 'install' ) { 47 serendipity_plugin_api::hook_event('backend_templates_fetchtemplate', $serendipity); 48 49 $themeInfo = serendipity_fetchTemplateInfo(htmlspecialchars($serendipity['GET']['theme'])); 50 51 serendipity_set_config_var('template', htmlspecialchars($serendipity['GET']['theme'])); 52 serendipity_set_config_var('template_engine', isset($themeInfo['engine']) ? $themeInfo['engine'] : 'default'); 53 54 echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(TEMPLATE_SET, htmlspecialchars($serendipity['GET']['theme'])) .'</div>'; 55 } 56 ?> 57 58 <?php 59 if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] .'/layout.php') ) { 60 echo '<div class="serendipityAdminMsgNote"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="" />'. WARNING_TEMPLATE_DEPRECATED .'</div>'; 61 } 62 63 echo '<h3>' . STYLE_OPTIONS . '</h3>'; 64 if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) { 65 serendipity_smarty_init(); 66 include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php'; 67 } 68 69 if (is_array($template_config)) { 70 serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config); 71 72 if ($serendipity['POST']['adminAction'] == 'configure') { 73 foreach($serendipity['POST']['template'] AS $option => $value) { 74 template_option::set_config($option, $value); 75 } 76 echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; 77 } 78 79 echo '<form method="post" action="serendipity_admin.php">'; 80 echo '<input type="hidden" name="serendipity[adminModule]" value="templates" />'; 81 echo '<input type="hidden" name="serendipity[adminAction]" value="configure" />'; 82 83 include S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; 84 $template_vars =& serendipity_loadThemeOptions($template_config); 85 86 $template_options = new template_option(); 87 $template_options->import($template_config); 88 $template_options->values =& $template_vars; 89 90 serendipity_plugin_config( 91 $template_options, 92 $template_vars, 93 $serendipity['template'], 94 $serendipity['template'], 95 $template_options->keys, 96 true, 97 true, 98 true, 99 true, 100 'template' 101 ); 102 echo '</form><br />'; 103 serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); 104 } else { 105 echo '<p>' . STYLE_OPTIONS_NONE . '</p>'; 106 serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config); 107 } 108 109 echo '<h3>' . SELECT_TEMPLATE . '</h3>'; 110 ?> 111 <br /> 112 <?php 113 $i = 0; 114 $stack = array(); 115 serendipity_plugin_api::hook_event('backend_templates_fetchlist', $stack); 116 $themes = serendipity_fetchTemplates(); 117 foreach($themes AS $theme) { 118 $stack[$theme] = serendipity_fetchTemplateInfo($theme); 119 } 120 ksort($stack); 121 122 foreach ($stack as $theme => $info) { 123 $i++; 124 125 /* Sorry, but we don't display engines */ 126 if ( strtolower($info['engine']) == 'yes' ) { 127 continue; 128 } 129 130 $preview = ''; 131 $preview_link = false; 132 if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview_fullsize.jpg')) { 133 $preview .= '<a href="' . $serendipity['baseURL'] . $serendipity['templatePath'] . $theme . '/preview_fullsize.jpg" target="_blank">'; 134 $preview_link = true; 135 } elseif (!empty($info['preview_fullsizeURL'])) { 136 $preview .= '<a href="' . $info['preview_fullsizeURL'] . '" target="_blank">'; 137 $preview_link = true; 138 139 # } else { 140 # echo "No large preview"; 141 } 142 143 if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview.png')) { 144 $preview .= '<img src="' . $serendipity['templatePath'] . $theme . '/preview.png" width="100" style="border: 1px #000000 solid" />'; 145 } elseif (!empty($info['previewURL'])) { 146 $preview .= '<img src="' . $info['previewURL'] . '" width="100" style="border: 1px #000000 solid" />'; 147 } else { 148 $preview .= ' '; 149 } 150 151 if ($preview_link) { 152 $preview .= '</a>'; 153 } 154 155 if (empty($info['customURI'])) { 156 $info['customURI'] = ''; 157 } 158 159 $unmetRequirements = array(); 160 if ( isset($info['require serendipity']) && version_compare($info['require serendipity'], serendipity_getCoreVersion($serendipity['version']), '>') ) { 161 $unmetRequirements[] = 'Serendipity '. $info['require serendipity']; 162 } 163 164 /* TODO: Smarty versioncheck */ 165 166 $class = (($i % 2 == 0) ? 'even' : 'uneven'); 167 168 ?> 169 <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo $class ?>"> 170 <table width="100%" id="serendipity_theme_<?php echo $theme; ?>"> 171 <tr> 172 <td colspan="2"><span class="serendipityTemplateSelectName"><strong><?php echo $info['name']; ?></strong></span></td> 173 <td valign="middle" align="center" width="70" rowspan="2"> 174 <?php 175 if ( $serendipity['template'] != $theme ) { 176 if ( !sizeof($unmetRequirements) ) { 177 ?> 178 <a href="?serendipity[adminModule]=templates&serendipity[adminAction]=install&serendipity[theme]=<?php echo $theme . $info['customURI']; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/install_now' . $info['customIcon'] . '.png') ?>" alt="<?php echo SET_AS_TEMPLATE ?>" title="<?php echo SET_AS_TEMPLATE ?>" border="0" /></a> 179 <?php } else { ?> 180 <span class="serendipityTemplateSelectUnmetRequirements">style="color: #cccccc"><?php echo sprintf(UNMET_REQUIREMENTS, implode(', ', $unmetRequirements)); ?></span> 181 <?php 182 } 183 } ?> 184 </td> 185 </tr> 186 187 <tr> 188 <td width="100" style="padding-left: 10px"><?php echo $preview; ?></td> 189 <td valign="top"> 190 <span class="serendipityTemplateSelectDetails"><?php echo AUTHOR; ?>: <?php echo $info['author'];?></span><br /> 191 <span class="serendipityTemplateSelectDetails"><?php echo LAST_UPDATED; ?>: <?php echo $info['date']; ?></span><br /> 192 <span class="serendipityTemplateSelectDetails"><?php echo CUSTOM_ADMIN_INTERFACE; ?>: <?php echo $info['custom_admin_interface']; ?></span><br /> 193 </td> 194 </tr> 195 </table> 196 </div> 197 <?php 198 } 199 ?> 200 <?php 201 /* vim: set sts=4 ts=4 expandtab : */ 202 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |