aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-24 15:35:24 -0700
committerfriendica <info@friendica.com>2013-10-24 15:35:24 -0700
commitd51aa653e2c19c226f3f2bb0767cf9eeeb0dff39 (patch)
treeafa5be5a40111ec1426464ba00e66785b0e8c125 /include
parentcb84485f7c9c57d96aaa03fe793e7d8d6f971aec (diff)
downloadvolse-hubzilla-d51aa653e2c19c226f3f2bb0767cf9eeeb0dff39.tar.gz
volse-hubzilla-d51aa653e2c19c226f3f2bb0767cf9eeeb0dff39.tar.bz2
volse-hubzilla-d51aa653e2c19c226f3f2bb0767cf9eeeb0dff39.zip
passing vars to widgets in Comanche - !this breaks existing widget declarations!
See the wiki for updated syntax but basically it's now [widget=name][var=varname]varvalue[/var]...[/widget]
Diffstat (limited to 'include')
-rw-r--r--include/comanche.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/include/comanche.php b/include/comanche.php
index f1dd0e521..4c6ea2f54 100644
--- a/include/comanche.php
+++ b/include/comanche.php
@@ -2,6 +2,7 @@
require_once('include/security.php');
require_once('include/menu.php');
+
// When editing a webpage - a dropdown is needed to select a page layout
// On submit, the pdl_select value (which is the mid of an item with item_restrict = ITEM_PDL) is stored in
// the webpage's resource_id, with resource_type 'pdl'.
@@ -126,11 +127,19 @@ function comanche_webpage(&$a,$s) {
// the global app environment, or config storage until we implement argument passing
-function comanche_widget($name,$args = null) {
+function comanche_widget($name,$text) {
$a = get_app();
+ $vars = array();
+ $cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $vars[$mtch[1]] = $mtch[2];
+ }
+ }
+
$func = 'widget_' . trim($name);
if(function_exists($func))
- return $func($args);
+ return $func($vars);
}
@@ -152,10 +161,10 @@ function comanche_region(&$a,$s) {
// need to modify this to accept parameters
- $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER);
+ $cnt = preg_match_all("/\[widget=(.*?)\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
- $s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s);
+ $s = str_replace($mtch[0],comanche_widget(trim($mtch[1]),$mtch[2]),$s);
}
}