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)); }
function file_tag_file_to_list($file, $type = 'file') { $matches = false; $list = ''; if ($type == 'file') { $cnt = preg_match_all('/\\[(.*?)\\]/', $file, $matches, PREG_SET_ORDER); } else { $cnt = preg_match_all('/<(.*?)>/', $file, $matches, PREG_SET_ORDER); } if ($cnt) { foreach ($matches as $mtch) { if (strlen($list)) { $list .= ','; } $list .= file_tag_decode($mtch[1]); } } return $list; }