[geeklog-cvs] geeklog: List dynamic blocks on admin blocks page. New plugin fu...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Tue Mar 20 12:34:25 EDT 2012
changeset 8540:d829dcdc89d7
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/d829dcdc89d7
user: Tom <websitemaster at cogeco.net>
date: Tue Mar 20 12:09:26 2012 -0400
description:
List dynamic blocks on admin blocks page. New plugin function PLG_getBlocksConfig (feature request #0001434)
diffstat:
language/english.php | 15 +++++-----
language/english_utf-8.php | 15 +++++-----
public_html/admin/block.php | 63 ++++++++++++++++++++++++++++++++++++++++++--
system/lib-admin.php | 53 +++++++++++++++++++++++++++++++++++++
system/lib-plugins.php | 41 +++++++++++++++++++++++++++-
5 files changed, 167 insertions(+), 20 deletions(-)
diffs (truncated from 313 to 300 lines):
diff -r 9eba9d7e198c -r d829dcdc89d7 language/english.php
--- a/language/english.php Wed Mar 14 09:50:42 2012 -0400
+++ b/language/english.php Tue Mar 20 12:09:26 2012 -0400
@@ -687,8 +687,8 @@
2 => 'You do not have the necessary rights to edit this block.',
3 => 'Block Editor',
4 => 'There was a problem reading this feed (see error.log for details).',
- 5 => '',
- 6 => '',
+ 5 => 'Yes',
+ 6 => 'No',
7 => 'All',
8 => 'Block Security Level',
9 => 'Block Order',
@@ -702,12 +702,12 @@
17 => 'Block Content',
18 => 'Please fill in the Block Title and Content fields',
19 => 'Block Manager',
- 20 => '',
+ 20 => 'Regular Blocks',
21 => 'Block SecLev',
- 22 => '',
+ 22 => 'Dynamic Blocks',
23 => 'Block Order',
- 24 => '',
- 25 => 'To modify or delete a block, click on that block\'s edit icon below. To create a new block, click on "Create New" above. To move a block, click on the arrows or [R] and [L] boxes.',
+ 24 => 'Dynamic',
+ 25 => 'To modify or delete a regular block, click on that block\'s edit icon below. To create a new regular block, click on "Create New" above. To move a regular block, click on the arrows or [R] and [L] boxes. To edit dynamic blocks check the plugin configuration that the block is related too.',
26 => 'Layout Block',
27 => 'PHP Block',
28 => 'PHP Block Options',
@@ -750,7 +750,8 @@
65 => 'Order',
66 => 'Autotags',
67 => 'Check to allow autotags',
- 68 => 'The feed for this portal block is too long to display. Please set a maximum number of articles to import for the block in the block setup screen, or a global maximum in Geeklog Configuration.'
+ 68 => 'The feed for this portal block is too long to display. Please set a maximum number of articles to import for the block in the block setup screen, or a global maximum in Geeklog Configuration.',
+ 69 => 'Plugin Name'
);
###############################################################################
diff -r 9eba9d7e198c -r d829dcdc89d7 language/english_utf-8.php
--- a/language/english_utf-8.php Wed Mar 14 09:50:42 2012 -0400
+++ b/language/english_utf-8.php Tue Mar 20 12:09:26 2012 -0400
@@ -687,8 +687,8 @@
2 => 'You do not have the necessary rights to edit this block.',
3 => 'Block Editor',
4 => 'There was a problem reading this feed (see error.log for details).',
- 5 => '',
- 6 => '',
+ 5 => 'Yes',
+ 6 => 'No',
7 => 'All',
8 => 'Block Security Level',
9 => 'Block Order',
@@ -702,12 +702,12 @@
17 => 'Block Content',
18 => 'Please fill in the Block Title and Content fields',
19 => 'Block Manager',
- 20 => '',
+ 20 => 'Regular Blocks',
21 => 'Block SecLev',
- 22 => '',
+ 22 => 'Dynamic Blocks',
23 => 'Block Order',
- 24 => '',
- 25 => 'To modify or delete a block, click on that block\'s edit icon below. To create a new block, click on "Create New" above. To move a block, click on the arrows or [R] and [L] boxes.',
+ 24 => 'Dynamic',
+ 25 => 'To modify or delete a regular block, click on that block\'s edit icon below. To create a new regular block, click on "Create New" above. To move a regular block, click on the arrows or [R] and [L] boxes. To edit dynamic blocks check the plugin configuration that the block is related too.',
26 => 'Layout Block',
27 => 'PHP Block',
28 => 'PHP Block Options',
@@ -750,7 +750,8 @@
65 => 'Order',
66 => 'Autotags',
67 => 'Check to allow autotags',
- 68 => 'The feed for this portal block is too long to display. Please set a maximum number of articles to import for the block in the block setup screen, or a global maximum in Geeklog Configuration.'
+ 68 => 'The feed for this portal block is too long to display. Please set a maximum number of articles to import for the block in the block setup screen, or a global maximum in Geeklog Configuration.',
+ 69 => 'Plugin Name'
);
###############################################################################
diff -r 9eba9d7e198c -r d829dcdc89d7 public_html/admin/block.php
--- a/public_html/admin/block.php Wed Mar 14 09:50:42 2012 -0400
+++ b/public_html/admin/block.php Tue Mar 20 12:09:26 2012 -0400
@@ -383,7 +383,8 @@
reorderblocks();
- // writing the list
+ // Left
+ // Regular Blocks
$header_arr = array( # display 'text' and use table field 'field'
array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false),
array('text' => $LANG21[65], 'field' => 'blockorder', 'sort' => true),
@@ -399,6 +400,7 @@
$text_arr = array(
'has_extras' => true,
+ 'title' => "$LANG21[20] ($LANG21[40])",
'form_url' => $_CONF['site_admin_url'] . '/block.php'
);
@@ -419,13 +421,39 @@
. XHTML . '>'
);
- $retval .= ADMIN_list(
+ $retval .= ADMIN_list(
'blocks', 'ADMIN_getListField_blocks', $header_arr, $text_arr,
$query_arr, $defsort_arr, '', $token, '', $form_arr
);
+
- $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
+ // Dynamic blocks
+ $dyn_header_arr = array( # display 'text' and use table field 'field'
+ array('text' => $LANG21[65], 'field' => 'blockorder', 'sort' => true),
+ array('text' => $LANG21[69], 'field' => 'plugin', 'sort' => true),
+ array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true),
+ array('text' => $LANG21[48], 'field' => 'name', 'sort' => true),
+ array('text' => $LANG_ADMIN['type'], 'field' => 'type', 'sort' => true),
+ array('text' => $LANG_ADMIN['topic'], 'field' => 'topic', 'sort' => true),
+ array('text' => $LANG_ADMIN['enabled'], 'field' => 'is_enabled', 'sort' => true)
+ );
+
+ $dyn_text_arr = array(
+ 'title' => "$LANG21[22] ($LANG21[40])",
+ );
+
+ $leftblocks = PLG_getBlocksConfig('left', '', true);
+
+ // Sort Dynamic Blocks on Block Order
+ usort($leftblocks, "cmpDynamicBlocks");
+
+ $retval .= ADMIN_simpleList('ADMIN_getListField_dynamicblocks', $dyn_header_arr, $dyn_text_arr,
+ $leftblocks, '', $form_arr);
+
+
+ // Right
+ // Regular Blocks
$query_arr = array(
'table' => 'blocks',
'sql' => "SELECT * FROM {$_TABLES['blocks']} WHERE onleft = 0",
@@ -435,7 +463,7 @@
$text_arr = array(
'has_extras' => true,
- 'title' => "$LANG21[19] ($LANG21[41])",
+ 'title' => "$LANG21[20] ($LANG21[41])",
'form_url' => $_CONF['site_admin_url'] . '/block.php'
);
@@ -453,10 +481,37 @@
$query_arr, $defsort_arr, '', $token, '', $form_arr
);
+ // Dynamic blocks
+ $dyn_text_arr = array(
+ 'title' => "$LANG21[22] ($LANG21[41])",
+ );
+
+ $rightblocks = PLG_getBlocksConfig('right', '', true);
+
+ // Sort Dynamic Blocks on Block Order
+ usort($rightblocks, "cmpDynamicBlocks");
+
+ $retval .= ADMIN_simpleList('ADMIN_getListField_dynamicblocks', $dyn_header_arr, $dyn_text_arr,
+ $rightblocks, '', $form_arr);
+
+ $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
+
return $retval;
}
/**
+* Used by listblocks function when sorting the dynamic block array using the
+* usort function
+*
+* @return boolean
+*
+*/
+function cmpDynamicBlocks($a, $b)
+{
+ return $a["blockorder"] > $b["blockorder"];
+}
+
+/**
* Saves a block
*
* @param string $bid Block ID
diff -r 9eba9d7e198c -r d829dcdc89d7 system/lib-admin.php
--- a/system/lib-admin.php Wed Mar 14 09:50:42 2012 -0400
+++ b/system/lib-admin.php Tue Mar 20 12:09:26 2012 -0400
@@ -710,6 +710,59 @@
}
/**
+ * used for the list of blocks in admin/block.php
+ *
+ */
+function ADMIN_getListField_dynamicblocks($fieldname, $fieldvalue, $A, $icon_arr)
+{
+ global $_CONF, $LANG_ADMIN, $LANG21, $_IMAGE_TYPE, $_TABLES;
+
+ $retval = false;
+
+ switch ($fieldname) {
+ case 'title':
+ $retval = stripslashes($A['title']);
+ if (empty($retval)) {
+ $retval = '(' . $A['name'] . ')';
+ }
+ break;
+
+ case 'is_enabled':
+ if ($A['enable'] == 1) {
+ $retval = $LANG21[5]; // Yes
+ } else {
+ $retval = $LANG21[6]; // No
+ }
+ break;
+
+ case 'topic':
+ if ($A['topic_option'] == TOPIC_ALL_OPTION) {
+ $retval = $LANG21[7];
+ } elseif ($A['topic_option'] == TOPIC_HOMEONLY_OPTION) {
+ $retval = $LANG21[43];
+ } else {
+ $element_num = count($A['topic']);
+
+ if ($element_num == 0) {
+ $retval = $LANG21[47]; // None
+ } elseif ($element_num > 1) {
+ $retval = $LANG21[44]; // Multiple
+ } else {
+ $retval = DB_getItem($_TABLES['topics'], 'topic', "tid = '{$A['topic'][0]}'");
+ }
+ }
+
+ break;
+
+ default:
+ $retval = $fieldvalue;
+ break;
+ }
+
+ return $retval;
+}
+
+/**
* used for the list of groups and in the group editor in admin/group.php
*
*/
diff -r 9eba9d7e198c -r d829dcdc89d7 system/lib-plugins.php
--- a/system/lib-plugins.php Wed Mar 14 09:50:42 2012 -0400
+++ b/system/lib-plugins.php Tue Mar 20 12:09:26 2012 -0400
@@ -2439,8 +2439,8 @@
* Returns data for blocks on a given side and, potentially, for
* a given topic.
*
-* @param string $side Side to get blocks for (right or left for now)
-* @param string $topic Only get blocks for this topic
+* @param string $side Side to get blocks for (right or left for now)
+* @param string $topic Only get blocks for this topic
* @return array array of block data
* @link http://wiki.geeklog.net/index.php/Dynamic_Blocks
*
@@ -2471,6 +2471,43 @@
}
/**
+* Gets Geeklog blocks from plugins
+*
+* Returns config data for blocks on a given side and, potentially, for
+* a given topic.
+*
+* @param string $side Side to get blocks for (right or left for now)
+* @param string $topic Only get blocks for this topic
+* @return array array of block data
+* @link http://wiki.geeklog.net/index.php/Dynamic_Blocks
+*
+*/
+function PLG_getBlocksConfig($side, $topic='')
+{
+ global $_PLUGINS;
+
+ $ret = array();
+ foreach ($_PLUGINS as $pi_name) {
+ $function = 'plugin_getBlocksConfig_' . $pi_name;
+ if (function_exists($function)) {
+ $items = $function($side, $topic, $config);
+ if (is_array($items)) {
+ $ret = array_merge($ret, $items);
+ }
+ }
+ }
+
+ if (function_exists('CUSTOM_getBlocksConfig')) {
More information about the geeklog-cvs
mailing list