Update of /cvsroot/php-blog/additional_plugins/alpha/serendipity_event_advtypes
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv14504/alpha/serendipity_event_advtypes
Added Files:
README config.inc.php documentation_cs.html
documentation_cz.html index.tpl lang_cs.inc.php
lang_cz.inc.php lang_en.inc.php serendipity_event_advtypes.php
Log Message:
gitclone.sh autocommit
--- NEW FILE: config.inc.php ---
<?php
// Be nice to the frontend users. They don't need the additional constants and file lookups. Only load them when in Admin mode.
if ($serendipity['GET']['adminModule'] == 'templates' || $serendipity['POST']['adminModule'] != 'templates') {
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
}
$template_config = array(
array(
'var' => 'header_img',
'name' => 'Header Image',
'description' => 'TESTING/UNUSED: image for header of blog',
'type' => 'media',
'preview_width' => '500px',
'preview_height' => '100px',
'default' => serendipity_getTemplateFile('header.png'),
),
array(
'var' => 'colorset',
'name' => THEME_COLORSET,
'description' => THEME_COLORSET_DESC,
'type' => 'select',
'default' => 'blue',
'select_values' => array('default' => 'Default Blue', 'grey' => 'Grey Monotone', 'caramel' => 'Caramel', 'modern' => 'Modern Blue and Green')
),
array(
'var' => 'entryfooterposition',
'name' => FOOTER_POSITION,
'description' => FOOTER_POSITION_DESC,
'type' => 'radio',
'radio' => array('value' => array('true', 'false'),
'desc' => array(SMALL_BOX, BELOW_ENTRY)),
'default' => 'true',
),
array(
'var' => 'amount',
'name' => 'Number of navlinks',
'description' => 'Enter the number of navlinks you want to use in the navbar.',
'type' => 'string',
'default' => '5',
),
);
if (version_compare($serendipity['version'],"1.1.beta3") >= 0) {
$vars = serendipity_loadThemeOptions($template_config);
$navlinks = array();
for ($i = 0; $i < $vars['amount']; $i++) {
$navlinks[] = array(
'title' => $vars['navlink' . $i . 'text'],
'href' => $vars['navlink' . $i . 'url']
);
$template_config[] = array(
'var' => 'navlink' . $i . 'text',
'name' => NAV_LINK_TEXT . ' #' . $i,
'description' => NAV_LINK_DESC . ' #' .$i,
'type' => 'string',
'default' => constant('NAV_DEFAULT_' . $i),
);
$template_config[] = array(
'var' => 'navlink' . $i . 'url',
'name' => NAV_LINK_URL . ' #' . $i,
'description' => NAV_LINK_URL_DESC . ' #' . $i,
'type' => 'string',
'default' => '#',
);
}
$serendipity['smarty']->assign_by_ref('navlinks', $navlinks);
}
--- NEW FILE: lang_en.inc.php ---
<?php #
/**
* @version
* @author Translator Name <you...@ex...>
* EN-Revision: Revision of lang_en.inc.php
*/
@define("PLUGIN_ADVTYPES_TITLE", "Advanced configuration types");
@define("PLUGIN_ADVTYPES_DESC", "Provides advanced plugin and theme configuration options for Serendipity versions before 1.2.2 (currently supporting 'sequence' widget)");
@define('PLUGIN_ADVTYPES_NOTHING_TO_SEQUENCE', '<div>There are no items to be sequenced.</div><br />');
?>
--- NEW FILE: lang_cz.inc.php ---
<?php
/**
* @author Vladimir Ajgl <vl...@aj...>
* @translated 2009/02/16
* @author Vladimír Ajgl <vl...@aj...>
* @revisionDate 2009/08/26
*/
@define('PLUGIN_ADVTYPES_TITLE', 'Roz¹íøené typy konfigurace');
@define('PLUGIN_ADVTYPES_DESC', 'Poskytuje roz¹íøené volby pro nastavení pluginù a ¹ablon vzhledu pro verze Serendipity ni¾¹í ne¾ 1.2.2 (souèasné verze podporují widget \'sequence\')');
@define('PLUGIN_ADVTYPES_NOTHING_TO_SEQUENCE', '<div>®ádné polo¾ky ke zøetìzení.</div><br />');
--- NEW FILE: documentation_cz.html ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: documentation_cs.html ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: lang_cs.inc.php ---
<?php
/**
* @author Vladimir Ajgl <vl...@aj...>
* @translated 2009/02/16
* @author Vladimír Ajgl <vl...@aj...>
* @revisionDate 2009/08/26
*/
@define('PLUGIN_ADVTYPES_TITLE', 'Rozíøené typy konfigurace');
@define('PLUGIN_ADVTYPES_DESC', 'Poskytuje rozíøené volby pro nastavení pluginù a ablon vzhledu pro verze Serendipity nií ne 1.2.2 (souèasné verze podporují widget \'sequence\')');
@define('PLUGIN_ADVTYPES_NOTHING_TO_SEQUENCE', '<div>ádné poloky ke zøetìzení.</div><br />');
--- NEW FILE: serendipity_event_advtypes.php ---
<?php
if (IN_serendipity !== true) {
die ("Don't hack!");
}
# (c) 2007 by Jude 'judebert' Anthony, http://judebert.com/
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
#########################################################################################
class serendipity_event_advtypes extends serendipity_event {
var $debug;
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', PLUGIN_ADVTYPES_TITLE);
$propbag->add('description', PLUGIN_ADVTYPES_DESC);
$propbag->add('requirements', array(
'serendipity' => '1.1',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('version', '0.8');
$propbag->add('author', 'Judebert (<a href="http://judebert.com/">http://judebert.com/</a>)');
$propbag->add('stackable', false);
$propbag->add('event_hooks', array(
'backend_header' => true,
'backend_pluginconfig_media' => true,
'backend_pluginconfig_sequence' => true,
));
//$propbag->add('configuration', array('unused'));
$propbag->add('configuration', array('unused', 'sequence_tester', 'seqtest2'));
$propbag->add('groups', array('BACKEND_TEMPLATES'));
//$this->dependencies = array('serendipity_event_entryproperties' => 'keep');
}
function introspect_config_item($name, &$propbag) {
global $serendipity;
switch($name) {
case 'unused' :
$propbag->add('type', 'string');
$propbag->add('name', 'unused');
$propbag->add('description', 'unused');
$propbag->add('default', 'unused');
break;
case 'sequence_tester' :
$propbag->add('type', 'sequence');
$propbag->add('name', 'Unused Sequence Widget');
$propbag->add('description', 'A sequence widget to test the sequence widget code.');
$propbag->add('values', array('1' => array('display' => 'This', 'img' => serendipity_getTemplateFile('img/emoticons/cool.png')),
'2' => array('display' => 'That', 'img' => serendipity_getTemplateFile('img/emoticons/smile.png')),
'3' => array('display' => 'The Other', 'img' => serendipity_getTEmplateFile('img/s9y_banner_small.png')),
));
break;
case 'seqtest2' :
$propbag->add('type', 'sequence');
$propbag->add('name', 'Multiple Unused Sequence Widgets');
$propbag->add('description', 'A sequence widget to test the sequence widget code with multiple sequences.');
$propbag->add('values', array('First Item',
'Second Item' => array('display' => '2nd item'),
'Third Item',
));
$propbag->add('default', 'Third Item,Second Item,First Item');
break;
default:
return false;
}
return true;
}
function generate_content(&$title) {
$title = PLUGIN_ADVTYPES_TITLE;
}
function event_hook($event, &$bag, &$eventData, $addData = NULL) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_header':
// Output the JavaScript, if we must
$getModule = $serendipity['GET']['adminModule'];
$postModule = $serendipity['POST']['adminModule'];
if ($getModule == 'templates' || $postModule == 'templates' || $getModule == 'plugins' || $postModule == 'plugins') {
// Includes copied from include/admin/plugins.inc.php
echo '<script src="' . serendipity_getTemplateFile('dragdrop.js') . '" type="text/javascript"></script>';
//echo '<div class="warning js_warning"><em>' . PREFERENCE_USE_JS_WARNING . '</em></div>';
$media_js = serendipity_getTemplateFile('media_input.js');
if ($serendipity['version'][0] < 2) {
print <<<EOS
<script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>
EOS;
}
print <<<EOS
<script type="text/javascript">
function change_preview(id)
{
var text_box = document.getElementById("serendipity[template][" + id + "]");
var image_box = document.getElementById(id + "_preview");
var filename = text_box.value;
image_box.style.backgroundImage = "url(" + filename + ")";
}
function choose_media(id)
{
window.open('serendipity_admin_image_selector.php?serendipity[htmltarget]=' + id + '&serendipity[filename_only]=true', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');
}
</script>
EOS;
}
break;
case 'backend_pluginconfig_media':
// Print the HTML to display the popup media selector
$postKey = $eventData['postKey'];
$var = $eventData['config_item'];
$savedValue = $eventData['value'];
$cbag = $eventData['cbag'];
$cname = $cbag->get('name');
$cdesc = $cbag->get('description');
$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';
}
$media_link_text = MEDIA_LIBRARY;
print <<<EOS
<tr><td colspan="2">
<strong>$cname</strong>
<br /><span style="color: #5E7A94; font-size: 8pt;">$cdesc</span>
</td> </tr>
<tr>
<td style="border-bottom: 1px solid #000000">
<!-- <img id="{$var}_preview" src="$savedValue"> -->
<div id="{$var}_preview" style="background-image: url($savedValue); width:$preview_width; height: $preview_height;"> </div>
</td>
<td style="border-bottom: 1px solid #000000">
<input class="input_textbox" type="text" id="serendipity[$postKey][$var]" name="serendipity[$postKey][$var]" value="$savedValue" onchange="change_preview('$var')"/>
<br /><a href="#" onclick="choose_media('serendipity[$postKey][$var]')">$media_link_text</a>
</td>
</tr>
EOS;
return true;
break;
case 'backend_pluginconfig_sequence':
//
// Print the HTML to display the [drag-n-drop] orderable list
//
// 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.
//
// 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.
// Data sent by include/functions_plugins_admin.inc.php
// It also passes bag and plugin, but we don't need those
$postKey = $eventData['postKey'];
$var = $eventData['config_item'];
$savedValue = $eventData['value'];
$cbag = $eventData['cbag'];
// Get the data we need to display the list
if (!$savedValue) {
$savedValue = $eventData['default'];
}
$cname = $cbag->get('name');
$cdesc = $cbag->get('description');
/** 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 ($savedValue) {
$order = explode(',', $savedValue);
}
$uparrow_img = serendipity_getTemplateFile('admin/img/uparrow.png');
$downarrow_img = serendipity_getTemplateFile('admin/img/downarrow.png');
// $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 in
// introspect_config_items, but not been configured).
// 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 to use
// them in valid, but empty
$order = array();
}
// Start the row, add one cell for the name and description
print <<<EOS
<tr>
<td style="border-bottom: 1px solid #000000; vertical-align: top">
<strong>$cname</strong>
<br /><span style="color: #5E7A94; font-size: 8pt;">$cdesc</span>
</td>
EOS;
// Now add one cell for the list
print <<<EOS
<td style="border-bottom: 1px solid #000000; vertical-align: middle">
EOS;
// Print the list
print <<<EOS
<input type="hidden" name="serendipity[$postKey][$var]" id="${var}_value" value="$savedValue" />
<noscript>
<!-- Replace standard submit button when using up/down submits -->
<input type="hidden" name="SAVECONF" value="Save" />
</noscript>
<ol id="$var" class="sequence_container pluginmanager_container">
EOS;
$sort_idx == 0;
$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;
$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;
$onedown = implode(',' , $swapping);
}
// Print the HTML
//
// Set the item and its ID
print ' <li id="'.$id.'" class="sequence_item pluginmanager_item_even">' . "\n";
// Make a handle with ID 'g$id'
print ' <div id="g'.$id.'" class="pluginmanager_grablet sequence_grablet"><a href="#"></a></div>' . "\n";
// Add the item contents
print ' <span>'.$items[$id]['display'].'</span>' . "\n";
if (isset($items[$id]['img'])) {
print ' <img src="'.$items[$id]['img'].'" />' . "\n";
}
// Luddite submit buttons (please, think of the scriptless!)
print "<noscript><div>\n";
if ($sort_idx == 0) {
// Skip the move-up submit button
print " \n";
} else {
print <<<EOS
<button type="submit" name="serendipity[$postKey][$var]" value="$oneup">
<img src="$uparrow_img" alt="Move Up">
</button>
EOS;
}
if ($sort_idx == $last) {
// Skip the move-down submit button
print " \n";
} else {
print <<<EOS
<button type="submit" name="serendipity[$postKey][$var]" value="$onedown">
<img src="$downarrow_img" alt="Move Down">
</button>
EOS;
}
print "</div></noscript>\n";
// Close the item
print ' </li>'."\n";
// Next, please
$sort_idx++;
}
if (!is_array($items) or empty($order)) {
// Print the empty message
print(PLUGIN_ADVTYPES_NOTHING_TO_SEQUENCE);
}
// Print the Javascript to drag-n-drop the list
print <<<EOS
<script type="text/javascript">
function init_${var}_Sequence()
{
var lst = document.getElementById("${var}");
DragDrop.makeListContainer(lst, '${var}_group');
lst.onDragOut = function() {
//var seq = DragDrop.serData('${var}_group', null);
var seq = DragDrop.serData(null, '${var}');
var start = seq.indexOf("(");
var end = seq.indexOf(")");
seq = seq.slice((start + 1), end);
var order = document.getElementById("${var}_value");
order.value = seq;
};
}
addLoadEvent(init_${var}_Sequence);
</script>
EOS;
// Finish the row
print <<<EOS
</td>
EOS;
return true;
break;
}
}
return true;
}
}
/* vim: set sw=4 sts=4 ts=4 expandtab : */
--- NEW FILE: index.tpl ---
{if $is_embedded != true}
{if $is_xhtml}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{else}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
{/if}
<html>
<head>
<title>{$head_title|@default:$blogTitle} {if $head_subtitle} - {$head_subtitle}{/if}</title>
<meta http-equiv="Content-Type" content="text/html; charset={$head_charset}" />
<meta name="Powered-By" content="Serendipity v.{$head_version}" />
<link rel="stylesheet" type="text/css" href="{$head_link_stylesheet}" />
<link rel="alternate" type="application/rss+xml" title="{$blogTitle} RSS feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/index.rss2" />
<link rel="alternate" type="application/x.atom+xml" title="{$blogTitle} Atom feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/atom.xml" />
{if $entry_id}
<link rel="pingback" href="{$serendipityBaseURL}comment.php?type=pingback&entry_id={$entry_id}" />
{/if}
{if $template_option.header_img}
<style type="text/css">
#serendipity_banner {ldelim}
background-image:url("{$template_option.header_img}") !important;
{rdelim}
</style>
{/if}
{serendipity_hookPlugin hook="frontend_header"}
</head>
<body id="{if $head_version < 1.1}{else}{$template_option.colorset}{/if}">
{else}
{serendipity_hookPlugin hook="frontend_header"}
{/if}
{if $is_raw_mode != true}
<div id="serendipity_banner"><a id="topofpage"></a>
<div id="identity"><h1><a class="homelink1" href="{$serendipityBaseURL}">{$head_title|@default:$blogTitle|truncate:60:" ..."}</a></h1>
<h2><a class="homelink2" href="{$serendipityBaseURL}">{$head_subtitle|@default:$blogDescription}</a></h2></div>
<div id="navbar">
<ul>
{if $head_version < 1.1}
<!-- ****** Change navbar links here ****** -->
<li><a href="#">About</a></li>
<li><a href="#">Photos</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Music</a></li>
<li><a href="#">Contact</a></li>
{else}
{foreach from=$navlinks item="navlink"}
<li><a href="{$navlink.href}" title="{$navlink.title}">{$navlink.title}</a></li>
{/foreach}
{/if}
</ul>
</div>
</div>
<!-- sliding faux columns, part 1 -->
{if $leftSidebarElements > 0 && $rightSidebarElements > 0}
<!-- Case 1: 3 columns -->
<div class="sfc1">
<div class="sfc2">
{/if}
{if $leftSidebarElements > 0 && $rightSidebarElements == 0}
<!-- Case 2: 2 columns, sidebar left -->
<div class="sfc1">
{/if}
{if $leftSidebarElements == 0 && $rightSidebarElements > 0}
<!-- Case 3: 2 columns, sidebar right -->
<div class="sfc2">
{/if}
<!-- we don't need another case for no columns, that'll work anyhow -->
<!-- closed below -->
<!-- MAINPANE -->
<div id="mainpane">
{if $leftSidebarElements > 0 && $rightSidebarElements > 0}
<!-- Case 1: 3 columns -->
<div id="content" class="withboth">{$CONTENT}</div>
<div id="serendipityLeftSideBar" class="leftandright">{serendipity_printSidebar side="left"}</div>
<div id="serendipityRightSideBar">{serendipity_printSidebar side="right"}</div>
{/if}
{if $leftSidebarElements > 0 && $rightSidebarElements == 0}
<!-- Case 2: 2 columns, sidebar left -->
<div id="content" class="withleft">{$CONTENT}</div>
<div id="serendipityLeftSideBar" class="leftonly">{serendipity_printSidebar side="left"}</div>
{/if}
{if $leftSidebarElements == 0 && $rightSidebarElements > 0}
<!-- Case 3: 2 columns, sidebar right -->
<div id="content" class="withright">{$CONTENT}</div>
<div id="serendipityRightSideBar">{serendipity_printSidebar side="right"}</div>
{/if}
{if $leftSidebarElements == 0 && $rightSidebarElements == 0}
<!-- Case 4: 1 column, no sidebars -->
<div id="content" class="nosidebars">{$CONTENT}</div>
{/if}
</div><!-- END MAINPANE -->
<!-- sliding faux columns, part 2 -->
{if $leftSidebarElements > 0 && $rightSidebarElements > 0}
<!-- Case 1: 3 columns -->
</div><!-- closes .sfc2 -->
</div><!-- closes .sfc1 -->
{/if}
{if $leftSidebarElements > 0 && $rightSidebarElements == 0}
<!-- Case 2: 2 columns, sidebar left -->
</div><!-- closes .sfc1 -->
{/if}
{if $leftSidebarElements == 0 && $rightSidebarElements > 0}
<!-- Case 3: 2 columns, sidebar right -->
</div><!-- closes .sfc2 -->
{/if}
<!-- end sfc -->
{/if}
{$raw_data}
{serendipity_hookPlugin hook="frontend_footer"}
{if $is_embedded != true}
<div id="footer">
<p>{$CONST.POWERED_BY} <a href="http://www.s9y.org">s9y</a> - Design by <a href="http://www.carlgalloway.com">Carl</a> and <a href="http://www.yellowled.de">YellowLed</a></p>
</div>
</body>
</html>
{/if}
--- NEW FILE: README ---
This plugin simply enables the 'sequence' type in theme configurations for blogs
earlier than 1.2.2.
While there's no harm in having it installed on a 1.2.2 or later blog, other
than a slight performance hit and inclusion of the dragdrop.js on admin
header pages, there's no reason to have it there, either.
It can be safely removed.
Even with this plugin installed, you won't see configurable sequence entry
items unless you've also installed a theme or plugin that uses them.
The included "index.tpl" and "config.inc.php" files are an example of how to use the media selector in your own templates. They are modified from "One True Layout" by Carl Galloway and YellowLed.
The sequence selector is more complicated. The easiest case is to add an array
such as the following to your theme options or plugin introspection:
array(
'var' => 'category_precedence',
'name' => 'Category Precedence',
'description' => 'TESTING/UNUSED: The order in which categories will be tested',
'type' => 'sequence',
'items' => array('cat1', 'cat2', 'cat3'),
),
In this case, the items cat1, cat2, and cat3 will be displayed in a draggable list (or, if the user has no Javascript, in a list with up and down arrows). When the user submits changes, you'll get a list with the items in the desired order, separated by commas; for instance, 'cat1,cat3,cat2'.
Sometimes you won't want to display the actual item IDs themselves. For instance, when we want the user to choose the precedences of categories, we wouldn't want the user's choices to be 1,7,18,24,32; we'd want to show him category names.
To display something different for any item, just modify your array like this:
array(
'var' => 'category_precedence',
'name' => 'Category Precedence',
'description' => 'TESTING/UNUSED: The order in which categories will be tested',
'type' => 'sequence',
'items' => array('1' => array('display' => 'Category 1 Name'),
'27' => array('display' => 'Category 27 Name'),
'34' => array('display' => 'Category 34 Name'))
),
In this case, you'll get back the variable 'category_precedence', and it will be saved as "1,34,27" (or whatever order the user wants). However, the user will see a re-orderable list with the items 'Category 1 Name', 'Category 27 Name', and 'Category 34 Name'.
But we're not done yet! Sometimes a displayable name won't be enough. You may want thumbnails to improve the user experience. In that case, just add the 'img' key to your array, with a full URL. (Use serendipity_getTemplateFile() to find an image in the currently-used templates.)
array(
'var' => 'category_precedence',
'name' => 'Category Precedence',
'description' => 'TESTING/UNUSED: The order in which categories will be tested',
'type' => 'sequence',
'items' => array('1' => array('display' => 'This', 'img' => 'http://judebert.com/wasted_youth/classic.gif'),
'2' => array('display' => 'That', 'img' => serendipity_getTemplateFile('img/minus.png')),
'3' => array('display' => 'The Other', 'img' => serendipity_getTemplateFile('img/plus.png'))
)
),
In this case, the options displayed to the user will be 'This' with my reflective-ball image, 'That' with the minus sign from the default template, and 'The Other' with the plus sign from the default template. What you'll receive is the comma-separated list of IDs, such as '3,2,1'.
You can mix-and-match these styles as much as you want. Any item that doesn't have an 'img' associated with it will get no image. Any item that doesn't have a 'display' associated with it will be displayed using the item ID. You can have display variables for some items and no display variables for other items. It's all good.
|