From 581b54c974a9b9a050a8a0b9a17a19bd41b1f2f5 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 1 Apr 2012 21:28:31 -0400 Subject: [PATCH] allow users to set categories on their posts --- boot.php | 5 ++ include/contact_widgets.php | 28 ++++++++ include/conversation.php | 2 + include/text.php | 112 ++++++++++++++++++++++++++++++ mod/editpost.php | 2 + mod/item.php | 30 ++++++-- mod/profile.php | 21 +++++- view/categories_widget.tpl | 13 ++++ view/jot.tpl | 1 + view/theme/darkzero/style.css | 8 ++- view/theme/duepuntozero/style.css | 22 +++--- 11 files changed, 226 insertions(+), 18 deletions(-) create mode 100755 view/categories_widget.tpl diff --git a/boot.php b/boot.php index 2f2e28cebd..c2690f6ef0 100755 --- a/boot.php +++ b/boot.php @@ -293,6 +293,8 @@ class App { public $nav_sel; + public $category; + private $scheme; private $hostname; private $baseurl; @@ -377,6 +379,9 @@ class App { $this->argc = count($this->argv); if((array_key_exists('0',$this->argv)) && strlen($this->argv[0])) { $this->module = str_replace(".", "_", $this->argv[0]); + if(array_key_exists('2',$this->argv)) { + $this->category = $this->argv[2]; + } } else { $this->argc = 1; diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 7346b95afa..e0f37f078f 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, + + )); +} + diff --git a/include/conversation.php b/include/conversation.php index 5a922b2b52..df92a40ed0 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -974,6 +974,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), + '$category' => "", + '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), diff --git a/include/text.php b/include/text.php index 191f4fca8a..f204e3f9b9 100644 --- a/include/text.php +++ b/include/text.php @@ -1314,6 +1314,118 @@ function file_tag_file_query($table,$s,$type = 'file') { return " AND " . (($table) ? dbesc($table) . '.' : '') . "file regexp '" . dbesc($str) . "' "; } +// ex. given music,video return