Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27345/include
Modified Files:
Tag: branch-smarty
functions_installer.inc.php
Log Message:
- Draft for new import framework. It's working, but might need some changes to make it a little more pretty
Note: Please review your importer methods, like validateData() etc.
- Split importer and exporter up into two menuitems
- Don't let serendipity_guessInput() parse data, it should just act on the data given
- Add 'file' type to serendipity_guessInput(), implementing <input type="file">
Index: functions_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/Attic/functions_installer.inc.php,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- functions_installer.inc.php 15 Nov 2004 10:31:48 -0000 1.1.2.3
+++ functions_installer.inc.php 15 Nov 2004 21:06:48 -0000 1.1.2.4
@@ -141,7 +141,7 @@
}
function serendipity_parseTemplate($n, $raw = false, $prepend_var = null, $get_defaults = true) {
- global $serendipity;
+ global $serendipity;
if (is_array($prepend_var)) {
$config = $configRaw = &$prepend_var;
@@ -156,13 +156,13 @@
$maxt = count($t);
for ($x=0; $x<$maxt; $x++) {
- $l = $t[$x];
+ $l = $t[$x];
$l = trim($l);
if ($l != '') {
- switch ($l[0]) {
+ switch ($l[0]) {
- // New Configure section
+ // New Configure section
case '/':
if ($l[1] == '/') {
$current = @constant(trim(substr($l, 2)));
@@ -176,7 +176,7 @@
// A configure option
case '$':
- // Grep out the name, type and default
+ // Grep out the name, type and default
preg_match('#\{([^|]+\|[^|]+\|([^}]+)?)\}[^/]+/{2}(.+)#msi', $l, $match);
// Make vars containing the elements in the | list
@@ -184,18 +184,27 @@
// Only show directives which are destined for this user. On installation, show everyting.
if (IS_installed === false || $serendipity['serendipityUserlevel'] >= $permission) {
- $cdef = ($get_defaults ? serendipity_query_default($name, $distdefault, $usertemplate, $type) : '');
- $config['categories'][$current][] = $configRaw[] = array(
- 'longname' => @constant($constant),
- 'name' => $name,
- 'type' => $type,
- 'default' => $cdef,
- 'distdefault' => serendipity_replaceEmbeddedConfigvars($distdefault),
- 'desc' => serendipity_replaceEmbeddedConfigVars(@constant(trim($match[3]))),
- 'valid_for' => $permission,
- 'flags' => explode(',', $flags)
- );
- }
+ $cdef = ($get_defaults ? serendipity_query_default($name, $distdefault, $usertemplate, $type) : '');
+ $distDefault = serendipity_replaceEmbeddedConfigvars($distdefault);
+
+ /* Expand 'list' type, to a normal assocaitive array */
+ if ( $type == 'list' && preg_match_all("/([^\=]+)\=\>([^\,]+)\,?/i", $distDefault, $res)) {
+ $distDefault = array();
+ foreach ( $res[1] as $k => $v ) {
+ $distDefault[$res[1][$k]] = $res[2][$k];
+ }
+ }
+ $config['categories'][$current][] = $configRaw[] = array(
+ 'longname' => @constant($constant),
+ 'name' => $name,
+ 'type' => $type,
+ 'default' => $cdef,
+ 'distdefault' => $distDefault,
+ 'desc' => serendipity_replaceEmbeddedConfigVars(@constant(trim($match[3]))),
+ 'valid_for' => $permission,
+ 'flags' => explode(',', $flags)
+ );
+ }
break;
}
}
@@ -217,7 +226,7 @@
}
function serendipity_guessInput($type, $name, $value='', $default='') {
-global $serendipity;
+ global $serendipity;
if ($name == 'rewrite' && $default == $value && isset($serendipity['rewrite_default']) && $serendipity['rewrite_default'] != '') {
$value = $serendipity['rewrite_default'];
@@ -235,17 +244,20 @@
case 'protected' :
echo '<input type="password" size="30" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
break;
+
case 'list' :
- preg_match_all("/([^\=]+)\=\>([^\,]+)\,?/i", $default, $res);
echo '<select name="'. $name .'">';
- for ($x=0; $x<sizeof($res[1]); $x++) {
+ foreach ((array)$default as $k=>$v) {
printf('<option value="%s"%s>%s</option>'. "\n",
- $res[1][$x],
- (($res[1][$x] == $value) ? ' selected="selected"' : ''),
- $res[2][$x]);
+ $k,
+ (($k == $value) ? ' selected="selected"' : ''),
+ $v);
}
echo '</select>';
break;
+ case 'file' :
+ echo '<input type="file" size="30" name="' . $name . '" />';
+ break;
default :
echo '<input type="text" size="30" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
break;
@@ -359,7 +371,7 @@
<?php }
if ( sizeof($t['categories']) > 1 ) { ?>
<div align="right">
- <a style="border:0; text-decoration: none" href="#" onclick="showConfigAll(<?php echo count($t['categories']); ?>)" title="<?php echo TOGGLE_ALL; ?>"><img src="<?php echo serendipity_getTemplateFile('img/'. ($folding === true ? 'plus' : 'minus') .'.png') ?>" id="optionall" alt="+/-" border="0" /> <?php echo TOGGLE_ALL; ?></a></a><br />
+ <a style="border:0; text-decoration: none" href="#" onClick="showConfigAll(<?php echo count($t['categories']); ?>)" title="<?php echo TOGGLE_ALL; ?>"><img src="<?php echo serendipity_getTemplateFile('img/'. ($folding === true ? 'plus' : 'minus') .'.png') ?>" id="optionall" alt="+/-" border="0" /> <?php echo TOGGLE_ALL; ?></a></a><br />
</div>
<?php
}
@@ -373,7 +385,7 @@
?>
<tr>
<th align="left" colspan="2" style="padding-left: 15px;">
- <a style="border:0; text-decoration: none" href="#" onclick="showConfig('el<?php echo $el_count; ?>'); return false" title="<?php echo TOGGLE_OPTION; ?>"><img src="<?php echo serendipity_getTemplateFile('img/'. ($folding === true ? 'plus' : 'minus') .'.png') ?>" id="optionel<?php echo $el_count; ?>" alt="+/-" border="0" /> <?php echo $key; ?></a></th>
+ <a style="border:0; text-decoration: none" href="#" onClick="showConfig('el<?php echo $el_count; ?>'); return false" title="<?php echo TOGGLE_OPTION; ?>"><img src="<?php echo serendipity_getTemplateFile('img/'. ($folding === true ? 'plus' : 'minus') .'.png') ?>" id="optionel<?php echo $el_count; ?>" alt="+/-" border="0" /> <?php echo $key; ?></a></th>
</tr>
<?php } ?>
<tr>
@@ -824,4 +836,4 @@
return preg_replace('@/include$@', '', dirname($file)) . '/';
}
-?>
\ No newline at end of file
+?>
|