From 581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 1 Apr 2012 21:28:31 -0400 Subject: allow users to set categories on their posts --- include/contact_widgets.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include/contact_widgets.php') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 7346b95af..e0f37f078 100755 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -103,3 +103,31 @@ function fileas_widget($baseurl,$selected = '') { )); } +function categories_widget($baseurl,$selected = '') { + $a = get_app(); + + $saved = get_pconfig($a->profile['profile_uid'],'system','filetags'); + if(! strlen($saved)) + return; + + $matches = false; + $terms = array(); + $cnt = preg_match_all('/<(.*?)>/',$saved,$matches,PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $unescaped = xmlify(file_tag_decode($mtch[1])); + $terms[] = array('name' => $unescaped,'selected' => (($selected == $unescaped) ? 'selected' : '')); + } + } + + return replace_macros(get_markup_template('categories_widget.tpl'),array( + '$title' => t('Categories'), + '$desc' => '', + '$sel_all' => (($selected == '') ? 'selected' : ''), + '$all' => t('Everything'), + '$terms' => $terms, + '$base' => $baseurl, + + )); +} + -- cgit v1.2.3