aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-01-28 15:23:42 -0800
committerredmatrix <git@macgirvin.com>2016-01-28 15:23:42 -0800
commit35a9a468ceeb7b8e8b5ae2f026d3bdd76dff68be (patch)
treede00e5bf297bac33a03681b4f1907f02efdeb768
parent5f1eb18da4d6380b64e83e0eeda6f1037de2fec9 (diff)
downloadvolse-hubzilla-35a9a468ceeb7b8e8b5ae2f026d3bdd76dff68be.tar.gz
volse-hubzilla-35a9a468ceeb7b8e8b5ae2f026d3bdd76dff68be.tar.bz2
volse-hubzilla-35a9a468ceeb7b8e8b5ae2f026d3bdd76dff68be.zip
widget_item - provide ability to use the page title instead of the message_id to locate the desired item. You can use either, but the page title is often easier to use and discover.
-rw-r--r--doc/Widgets.md7
-rw-r--r--include/widgets.php20
-rw-r--r--version.inc2
3 files changed, 21 insertions, 8 deletions
diff --git a/doc/Widgets.md b/doc/Widgets.md
index 10fc75cf8..8442bf687 100644
--- a/doc/Widgets.md
+++ b/doc/Widgets.md
@@ -74,8 +74,11 @@ Some/many of these widgets have restrictions which may restrict the type of page
* suggestedchats - "interesting" chatrooms chosen for the current observer
-* item - displays a single webpage item by mid
- * args: mid - message_id of webpage to display (must be webpage, not a conversation item)
+* item - displays a single webpage item by mid or page title
+ * args:
+ * channel_id - channel that owns the content, defualt is the profile_uid
+ * mid - message_id of webpage to display (must be webpage, not a conversation item)
+ * title - URL page title of webpage (must provide one of either title or mid)
<br />&nbsp;<br />
* photo - display a single photo
diff --git a/include/widgets.php b/include/widgets.php
index 891e9c018..7e502e4c2 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -817,7 +817,7 @@ function widget_item($arr) {
return '';
- if(! $arr['mid'])
+ if((! $arr['mid']) && (! $arr['title']))
return '';
if(! perm_is_allowed($channel_id, get_observer_hash(), 'view_pages'))
@@ -826,10 +826,20 @@ function widget_item($arr) {
require_once('include/security.php');
$sql_extra = item_permissions_sql($channel_id);
- $r = q("select * from item where mid = '%s' and uid = %d and item_type = " . intval(ITEM_TYPE_WEBPAGE) . " $sql_extra limit 1",
- dbesc($arr['mid']),
- intval($channel_id)
- );
+ if($arr['title']) {
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid
+ where item.uid = %d and sid = '%s' and service = 'WEBPAGE' and item_type = %d $sql_options $revision limit 1",
+ intval($channel_id),
+ dbesc($arr['title']),
+ intval(ITEM_TYPE_WEBPAGE)
+ );
+ }
+ else {
+ $r = q("select * from item where mid = '%s' and uid = %d and item_type = " . intval(ITEM_TYPE_WEBPAGE) . " $sql_extra limit 1",
+ dbesc($arr['mid']),
+ intval($channel_id)
+ );
+ }
if(! $r)
return '';
diff --git a/version.inc b/version.inc
index a9ccde1f5..b9468dd8c 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2016-01-27.1291H
+2016-01-28.1292H