Merge pull request #916 from dawnbreak/docu
Some cleanups and documentation.
This commit is contained in:
commit
958a140f64
@ -9,7 +9,7 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
|
||||
$ischat = false;
|
||||
|
||||
if(is_array($opts)) {
|
||||
$menu_id = ((x($opts,'menu_id')) ? intval($opt['menu_id']) : 0);
|
||||
$menu_id = ((x($opts,'menu_id')) ? intval($opts['menu_id']) : 0);
|
||||
$menu_name = ((x($opts,'menu_name')) ? escape_tags($opts['menu_name']) : '');
|
||||
$ischat = ((x($opts,'ischat')) ? intval($opts['ischat']) : 0);
|
||||
}
|
||||
|
@ -15,14 +15,13 @@ require_once('include/widgets.php');
|
||||
// page layout from the given description
|
||||
|
||||
|
||||
function pdl_selector($uid,$current="") {
|
||||
|
||||
function pdl_selector($uid, $current="") {
|
||||
$o = '';
|
||||
|
||||
$sql_extra = item_permissions_sql($uid);
|
||||
//$sql_extra = item_permissions_sql($uid);
|
||||
|
||||
$r = q("select item_id.*, mid from item_id left join item on iid = item.id where item_id.uid = %d and item_id.uid = item.uid and service = 'PDL' order by sid asc",
|
||||
intval($owner)
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
$arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
|
||||
@ -31,7 +30,7 @@ function pdl_selector($uid,$current="") {
|
||||
$entries = $arr['entries'];
|
||||
$current = $arr['current'];
|
||||
|
||||
$o .= "<select name=\"pdl_select\" id=\"pdl_select\" size=\"1\" >";
|
||||
$o .= '<select name="pdl_select" id="pdl_select" size="1">';
|
||||
$entries[] = array('title' => t('Default'), 'mid' => '');
|
||||
foreach($entries as $selection) {
|
||||
$selected = (($selection == $current) ? ' selected="selected" ' : '');
|
||||
@ -44,12 +43,13 @@ function pdl_selector($uid,$current="") {
|
||||
|
||||
|
||||
|
||||
function comanche_parser(&$a,$s) {
|
||||
function comanche_parser(&$a, $s) {
|
||||
$matches = array();
|
||||
|
||||
$cnt = preg_match_all("/\[comment\](.*?)\[\/comment\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||
if($cnt) {
|
||||
foreach($matches as $mtch) {
|
||||
$s = str_replace($mtch[0],'',$s);
|
||||
$s = str_replace($mtch[0], '', $s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,14 +99,14 @@ function comanche_parser(&$a,$s) {
|
||||
function comanche_menu($name,$class = '') {
|
||||
$channel_id = comanche_get_channel_id();
|
||||
if($channel_id) {
|
||||
$m = menu_fetch($name,$channel_id,get_observer_hash());
|
||||
return menu_render($m,$class);
|
||||
$m = menu_fetch($name,$channel_id, get_observer_hash());
|
||||
return menu_render($m, $class);
|
||||
}
|
||||
}
|
||||
|
||||
function comanche_replace_region($match) {
|
||||
$a = get_app();
|
||||
if(array_key_exists($match[1],$a->page)) {
|
||||
if(array_key_exists($match[1], $a->page)) {
|
||||
return $a->page[$match[1]];
|
||||
}
|
||||
}
|
||||
@ -121,15 +121,15 @@ function comanche_get_channel_id() {
|
||||
$channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0);
|
||||
if((! $channel_id) && (local_channel()))
|
||||
$channel_id = local_channel();
|
||||
|
||||
return $channel_id;
|
||||
}
|
||||
|
||||
function comanche_block($name) {
|
||||
|
||||
$o = '';
|
||||
$channel_id = comanche_get_channel_id();
|
||||
|
||||
if($channel_id) {
|
||||
$o = '';
|
||||
$r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1",
|
||||
intval($channel_id),
|
||||
dbesc($name)
|
||||
@ -138,11 +138,12 @@ function comanche_block($name) {
|
||||
$o = '<div class="widget bblock">';
|
||||
if($r[0]['title'])
|
||||
$o .= '<h3>' . $r[0]['title'] . '</h3>';
|
||||
$o .= prepare_text($r[0]['body'],$r[0]['mimetype']);
|
||||
$o .= '</div>';
|
||||
|
||||
$o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
|
||||
$o .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
@ -154,8 +155,9 @@ function comanche_block($name) {
|
||||
// of what template and webpage options we might desire.
|
||||
|
||||
function comanche_webpage(&$a,$s) {
|
||||
|
||||
$ret = array();
|
||||
$matches = array();
|
||||
|
||||
$cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||
if($cnt) {
|
||||
foreach($matches as $mtch) {
|
||||
@ -170,9 +172,10 @@ function comanche_webpage(&$a,$s) {
|
||||
// the global app environment, or config storage until we implement argument passing
|
||||
|
||||
|
||||
function comanche_widget($name,$text) {
|
||||
$a = get_app();
|
||||
function comanche_widget($name, $text) {
|
||||
$vars = array();
|
||||
$matches = array();
|
||||
|
||||
$cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
|
||||
if($cnt) {
|
||||
foreach($matches as $mtch) {
|
||||
@ -186,12 +189,13 @@ function comanche_widget($name,$text) {
|
||||
}
|
||||
|
||||
|
||||
function comanche_region(&$a,$s) {
|
||||
function comanche_region(&$a, $s) {
|
||||
$matches = array();
|
||||
|
||||
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||
if($cnt) {
|
||||
foreach($matches as $mtch) {
|
||||
$s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s);
|
||||
$s = str_replace($mtch[0], comanche_menu(trim($mtch[1])), $s);
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +248,3 @@ function register_page_template($arr) {
|
||||
get_app()->page_layouts[$arr['template']] = array($arr['variant']);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
function get_browser_language() {
|
||||
$langs = array();
|
||||
$lang_parse = array();
|
||||
|
||||
if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) {
|
||||
// break up string into pieces (languages and q factors)
|
||||
@ -144,16 +145,16 @@ function load_translation_table($lang, $install = false) {
|
||||
/**
|
||||
* @brief translate string if translation exists.
|
||||
*
|
||||
* @param $s string that should get translated
|
||||
* @param $ctx optional context to appear in po file
|
||||
* @param string $s string that should get translated
|
||||
* @param string $ctx optional context to appear in po file
|
||||
* @return translated string if exists, otherwise return $s
|
||||
*
|
||||
*/
|
||||
function t($s,$ctx = '') {
|
||||
function t($s, $ctx = '') {
|
||||
global $a;
|
||||
|
||||
$cs = $ctx?"__ctx:".$ctx."__ ".$s:$s;
|
||||
if(x($a->strings,$cs)) {
|
||||
$cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s;
|
||||
if(x($a->strings, $cs)) {
|
||||
$t = $a->strings[$cs];
|
||||
return is_array($t) ? $t[0] : $t;
|
||||
}
|
||||
@ -218,7 +219,7 @@ function detect_language($s) {
|
||||
// strip off bbcode
|
||||
$naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body);
|
||||
if(mb_strlen($naked_body) < intval($min_length)) {
|
||||
logger('detect language: string length less than ' . intval($min_length), LOGGER_DATA);
|
||||
logger('string length less than ' . intval($min_length), LOGGER_DATA);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,6 @@ function photo_upload($channel, $observer, $args) {
|
||||
|
||||
logger('photo_upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
|
||||
|
||||
|
||||
$maximagesize = get_config('system','maximagesize');
|
||||
|
||||
if(($maximagesize) && ($filesize > $maximagesize)) {
|
||||
@ -134,7 +133,6 @@ function photo_upload($channel, $observer, $args) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
$ph = photo_factory($imagedata, $type);
|
||||
|
||||
if(! $ph->is_valid()) {
|
||||
@ -204,7 +202,6 @@ function photo_upload($channel, $observer, $args) {
|
||||
$errors = true;
|
||||
}
|
||||
|
||||
|
||||
if($errors) {
|
||||
q("delete from photo where resource_id = '%s' and uid = %d",
|
||||
dbesc($photo_hash),
|
||||
@ -220,7 +217,6 @@ function photo_upload($channel, $observer, $args) {
|
||||
|
||||
$width_x_height = $ph->getWidth() . 'x' . $ph->getHeight();
|
||||
|
||||
$basename = basename($filename);
|
||||
$mid = item_message_id();
|
||||
|
||||
// Create item container
|
||||
@ -254,7 +250,7 @@ function photo_upload($channel, $observer, $args) {
|
||||
// We should also put a width_x_height on large photos. Left as an exercise for
|
||||
// devs looking fo simple stuff to fix.
|
||||
|
||||
$larger = feature_enabled($channel['channel_id'],'large_photos');
|
||||
$larger = feature_enabled($channel['channel_id'], 'large_photos');
|
||||
if($larger) {
|
||||
$tag = '[zmg]';
|
||||
if($r2)
|
||||
@ -291,15 +287,23 @@ function photo_upload($channel, $observer, $args) {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function photos_albums_list($channel,$observer) {
|
||||
/**
|
||||
* @brief Returns a list with all photo albums observer is allowed to see.
|
||||
*
|
||||
* Returns an associative array with all albums where observer has permissions.
|
||||
*
|
||||
* @param array $channel
|
||||
* @param array $observer
|
||||
* @return bool|array false if no view_photos permission or an array
|
||||
* * success (bool)
|
||||
* * albums (array)
|
||||
*/
|
||||
function photos_albums_list($channel, $observer) {
|
||||
|
||||
$channel_id = $channel['channel_id'];
|
||||
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
|
||||
|
||||
if(! perm_is_allowed($channel_id,$observer_xchan,'view_photos'))
|
||||
if(! perm_is_allowed($channel_id, $observer_xchan, 'view_photos'))
|
||||
return false;
|
||||
|
||||
// FIXME - create a permissions SQL which works on arbitrary observers and channels, regardless of login or web status
|
||||
@ -310,7 +314,6 @@ function photos_albums_list($channel,$observer) {
|
||||
intval($channel_id),
|
||||
intval(PHOTO_NORMAL),
|
||||
intval(PHOTO_PROFILE)
|
||||
|
||||
);
|
||||
|
||||
// add various encodings to the array so we can just loop through and pick them out in a template
|
||||
@ -330,8 +333,8 @@ function photos_albums_list($channel,$observer) {
|
||||
$ret['albums'][] = $entry;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function photos_album_widget($channelx,$observer,$albums = null) {
|
||||
@ -395,17 +398,32 @@ function photos_list_photos($channel,$observer,$album = '') {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function photos_album_exists($channel_id,$album) {
|
||||
$r = q("SELECT id from photo where album = '%s' and uid = %d limit 1",
|
||||
/**
|
||||
* @brief Check if given photo album exists in channel.
|
||||
*
|
||||
* @param int $channel_id id of the channel
|
||||
* @param string $album name of the album
|
||||
* @return boolean
|
||||
*/
|
||||
function photos_album_exists($channel_id, $album) {
|
||||
$r = q("SELECT id FROM photo WHERE album = '%s' AND uid = %d limit 1",
|
||||
dbesc($album),
|
||||
intval($channel_id)
|
||||
);
|
||||
|
||||
return (($r) ? true : false);
|
||||
}
|
||||
|
||||
function photos_album_rename($channel_id,$oldname,$newname) {
|
||||
/**
|
||||
* @brief Renames a photo album in a channel.
|
||||
*
|
||||
* @todo Do we need to check if new album name already exists?
|
||||
* @param int $channel_id id of the channel
|
||||
* @param string $oldname The name of the album to rename
|
||||
* @param string $newname The new name of the album
|
||||
* @return bool|array
|
||||
*/
|
||||
function photos_album_rename($channel_id, $oldname, $newname) {
|
||||
return q("UPDATE photo SET album = '%s' WHERE album = '%s' AND uid = %d",
|
||||
dbesc($newname),
|
||||
dbesc($oldname),
|
||||
@ -437,8 +455,8 @@ function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') {
|
||||
$str = implode(',',$arr);
|
||||
return $str;
|
||||
}
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
|
||||
@ -448,7 +466,6 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
|
||||
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
|
||||
$item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
|
||||
|
||||
$title = '';
|
||||
$mid = item_message_id();
|
||||
|
||||
$arr = array();
|
||||
@ -477,6 +494,6 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
|
||||
|
||||
$result = item_store($arr);
|
||||
$item_id = $result['item_id'];
|
||||
return $item_id;
|
||||
|
||||
return $item_id;
|
||||
}
|
||||
|
@ -150,11 +150,7 @@ function change_channel($change_channel) {
|
||||
*/
|
||||
function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
|
||||
|
||||
if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
|
||||
return '';
|
||||
|
||||
$local_channel = local_channel();
|
||||
$remote_channel = remote_channel();
|
||||
|
||||
/**
|
||||
* Construct permissions
|
||||
@ -223,11 +219,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
|
||||
*/
|
||||
function item_permissions_sql($owner_id, $remote_verified = false, $groups = null) {
|
||||
|
||||
if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
|
||||
return '';
|
||||
|
||||
$local_channel = local_channel();
|
||||
$remote_channel = remote_channel();
|
||||
|
||||
/**
|
||||
* Construct permissions
|
||||
|
@ -3,7 +3,7 @@
|
||||
require_once('include/dir_fns.php');
|
||||
require_once('include/zot.php');
|
||||
|
||||
/*
|
||||
/**
|
||||
* poco_load
|
||||
*
|
||||
* xchan is your connection
|
||||
@ -21,13 +21,10 @@ require_once('include/zot.php');
|
||||
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
|
||||
* pointing to the same global contact id.
|
||||
*
|
||||
* @param string $xchan
|
||||
* @param string $url
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
function poco_load($xchan = '',$url = null) {
|
||||
$a = get_app();
|
||||
function poco_load($xchan = '', $url = null) {
|
||||
|
||||
if($xchan && ! $url) {
|
||||
$r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1",
|
||||
@ -43,7 +40,6 @@ function poco_load($xchan = '',$url = null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ;
|
||||
|
||||
logger('poco_load: ' . $url, LOGGER_DEBUG);
|
||||
@ -184,7 +180,6 @@ function poco_load($xchan = '',$url = null) {
|
||||
}
|
||||
|
||||
$total ++;
|
||||
|
||||
}
|
||||
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
|
||||
|
||||
@ -193,7 +188,6 @@ function poco_load($xchan = '',$url = null) {
|
||||
db_utcnow(), db_quoteinterval('2 DAY')
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +224,6 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false
|
||||
);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -246,8 +239,8 @@ function count_common_friends_zcid($uid,$zcid) {
|
||||
|
||||
if(count($r))
|
||||
return $r[0]['total'];
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = false) {
|
||||
@ -269,7 +262,6 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
|
||||
);
|
||||
|
||||
return $r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -284,8 +276,8 @@ function count_all_friends($uid,$cid) {
|
||||
|
||||
if(count($r))
|
||||
return $r[0]['total'];
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -358,9 +350,7 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
|
||||
|
||||
function update_suggestions() {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
$dirmode = get_config('system','directory_mode');
|
||||
$dirmode = get_config('system', 'directory_mode');
|
||||
if($dirmode === false)
|
||||
$dirmode = DIRECTORY_MODE_NORMAL;
|
||||
|
||||
@ -374,8 +364,6 @@ function update_suggestions() {
|
||||
if(! $url)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
$ret = z_fetch_url($url);
|
||||
|
||||
if($ret['success']) {
|
||||
@ -388,7 +376,6 @@ function update_suggestions() {
|
||||
db_utcnow(), db_quoteinterval('7 DAY')
|
||||
);
|
||||
|
||||
|
||||
$j = json_decode($ret['body'],true);
|
||||
if($j && $j['success']) {
|
||||
foreach($j['entries'] as $host) {
|
||||
@ -422,7 +409,6 @@ function poco($a,$extended = false) {
|
||||
$system_mode = true;
|
||||
}
|
||||
|
||||
|
||||
$format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json');
|
||||
|
||||
$justme = false;
|
||||
@ -487,8 +473,8 @@ function poco($a,$extended = false) {
|
||||
$startIndex = intval($_GET['startIndex']);
|
||||
if(! $startIndex)
|
||||
$startIndex = 0;
|
||||
$itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
|
||||
|
||||
$itemsPerPage = ((x($_GET,'count') && intval($_GET['count'])) ? intval($_GET['count']) : $totalResults);
|
||||
|
||||
if($system_mode) {
|
||||
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF .
|
||||
@ -496,8 +482,7 @@ function poco($a,$extended = false) {
|
||||
intval($itemsPerPage),
|
||||
intval($startIndex)
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
|
||||
$sql_extra LIMIT %d OFFSET %d",
|
||||
intval($channel_id),
|
||||
@ -525,8 +510,7 @@ function poco($a,$extended = false) {
|
||||
}
|
||||
}
|
||||
|
||||
$ret['entry'] = array();
|
||||
|
||||
$ret['entry'] = array();
|
||||
|
||||
$fields_ret = array(
|
||||
'id' => false,
|
||||
@ -540,10 +524,10 @@ function poco($a,$extended = false) {
|
||||
'rating' => false
|
||||
);
|
||||
|
||||
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
|
||||
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) {
|
||||
foreach($fields_ret as $k => $v)
|
||||
$fields_ret[$k] = true;
|
||||
else {
|
||||
} else {
|
||||
$fields_req = explode(',',$_GET['fields']);
|
||||
foreach($fields_req as $f)
|
||||
$fields_ret[trim($f)] = true;
|
||||
|
@ -38,6 +38,7 @@ function term_query($table,$s,$type = TERM_UNKNOWN) {
|
||||
function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
|
||||
if(! $term)
|
||||
return false;
|
||||
|
||||
$r = q("select * from term
|
||||
where uid = %d and oid = %d and otype = %d and type = %d
|
||||
and term = '%s' and url = '%s' ",
|
||||
@ -50,6 +51,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
|
||||
);
|
||||
if($r)
|
||||
return false;
|
||||
|
||||
$r = q("insert into term (uid, oid, otype, type, term, url)
|
||||
values( %d, %d, %d, %d, '%s', '%s') ",
|
||||
intval($uid),
|
||||
@ -59,9 +61,11 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
|
||||
dbesc($term),
|
||||
dbesc($url)
|
||||
);
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
function get_terms_oftype($arr,$type) {
|
||||
$ret = array();
|
||||
if(! (is_array($arr) && count($arr)))
|
||||
@ -74,6 +78,7 @@ function get_terms_oftype($arr,$type) {
|
||||
foreach($arr as $x)
|
||||
if($x['type'] == $t)
|
||||
$ret[] = $x;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -112,6 +117,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
|
||||
if($authors) {
|
||||
if(! is_array($authors))
|
||||
$authors = array($authors);
|
||||
|
||||
stringify_array_elms($authors,true);
|
||||
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
|
||||
}
|
||||
@ -132,7 +138,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
|
||||
if(! $r)
|
||||
return array();
|
||||
|
||||
// Find minimum and maximum log-count.
|
||||
// Find minimum and maximum log-count.
|
||||
$tags = array();
|
||||
$min = 1e9;
|
||||
$max = -1e9;
|
||||
@ -158,16 +164,17 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
|
||||
return $tags;
|
||||
}
|
||||
|
||||
|
||||
function tags_sort($a,$b) {
|
||||
if(strtolower($a[0]) == strtolower($b[0]))
|
||||
return 0;
|
||||
return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
|
||||
if(strtolower($a[0]) == strtolower($b[0]))
|
||||
return 0;
|
||||
|
||||
return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
|
||||
}
|
||||
|
||||
|
||||
function dir_tagadelic($count = 0) {
|
||||
|
||||
$sql_options = '';
|
||||
$count = intval($count);
|
||||
|
||||
// Fetch tags
|
||||
@ -179,7 +186,7 @@ function dir_tagadelic($count = 0) {
|
||||
if(! $r)
|
||||
return array();
|
||||
|
||||
// Find minimum and maximum log-count.
|
||||
// Find minimum and maximum log-count.
|
||||
$tags = array();
|
||||
$min = 1e9;
|
||||
$max = -1e9;
|
||||
@ -207,65 +214,66 @@ function dir_tagadelic($count = 0) {
|
||||
|
||||
|
||||
function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
|
||||
$o = '';
|
||||
$tab = 0;
|
||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||
$o = '';
|
||||
|
||||
if($r) {
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||
|
||||
if($r) {
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function wtagblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
|
||||
$o = '';
|
||||
$tab = 0;
|
||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||
$o = '';
|
||||
|
||||
if($r) {
|
||||
$c = q("select channel_address from channel where channel_id = %d limit 1",
|
||||
intval($uid)
|
||||
);
|
||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
if($r) {
|
||||
$c = q("select channel_address from channel where channel_id = %d limit 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Tags') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag' . $rr[2] . '">#</span><a href="channel/' . $c[0]['channel_address'] . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function catblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_CATEGORY) {
|
||||
$o = '';
|
||||
$tab = 0;
|
||||
$o = '';
|
||||
|
||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||
|
||||
if($r) {
|
||||
$c = q("select channel_address from channel where channel_id = %d limit 1",
|
||||
intval($uid)
|
||||
);
|
||||
if($r) {
|
||||
$c = q("select channel_address from channel where channel_id = %d limit 1",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<a href="channel/' . $c[0]['channel_address']. '?f=&cat=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function dir_tagblock($link,$r) {
|
||||
$o = '';
|
||||
$tab = 0;
|
||||
|
||||
if(! $r)
|
||||
$r = get_app()->data['directory_keywords'];
|
||||
@ -277,14 +285,12 @@ function dir_tagblock($link,$r) {
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants"
|
||||
* We use the first person form when creating an activity, but the third person for use in activities
|
||||
@ -292,8 +298,6 @@ function dir_tagblock($link,$r) {
|
||||
* require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function obj_verbs() {
|
||||
$verbs = array(
|
||||
'has' => array( t('have'), t('has')),
|
||||
@ -304,20 +308,21 @@ function obj_verbs() {
|
||||
|
||||
$arr = array('verbs' => $verbs);
|
||||
call_hooks('obj_verbs', $arr);
|
||||
|
||||
return $arr['verbs'];
|
||||
}
|
||||
|
||||
|
||||
function obj_verb_selector($current = '') {
|
||||
$verbs = obj_verbs();
|
||||
$o .= '<select class="obj-verb-selector" name="verb" >';
|
||||
$o = '<select class="obj-verb-selector" name="verb">';
|
||||
foreach($verbs as $k => $v) {
|
||||
$selected = (($k == $current) ? ' selected="selected" ' : '');
|
||||
$o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[1] . '</option>';
|
||||
}
|
||||
$o .= '</select>';
|
||||
return $o;
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
function get_things($profile_hash,$uid) {
|
||||
@ -382,8 +387,8 @@ function get_things($profile_hash,$uid) {
|
||||
|
||||
if(! $things[$rr['obj_verb']])
|
||||
$things[$rr['obj_verb']] = array();
|
||||
$things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
|
||||
|
||||
$things[$rr['obj_verb']][] = array('term' => $rr['term'],'url' => $rr['url'],'img' => $rr['imgurl'], 'profile' => $rr['profile_name'],'term_hash' => $rr['term_hash'], 'likes' => $l,'like_count' => count($l),'like_label' => tt('Like','Likes',count($l),'noun'));
|
||||
}
|
||||
$sorted_things = array();
|
||||
if($things) {
|
||||
@ -395,6 +400,6 @@ function get_things($profile_hash,$uid) {
|
||||
}
|
||||
}
|
||||
//logger('things: ' . print_r($sorted_things,true));
|
||||
return $sorted_things;
|
||||
|
||||
return $sorted_things;
|
||||
}
|
Reference in New Issue
Block a user