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;
|
$ischat = false;
|
||||||
|
|
||||||
if(is_array($opts)) {
|
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']) : '');
|
$menu_name = ((x($opts,'menu_name')) ? escape_tags($opts['menu_name']) : '');
|
||||||
$ischat = ((x($opts,'ischat')) ? intval($opts['ischat']) : 0);
|
$ischat = ((x($opts,'ischat')) ? intval($opts['ischat']) : 0);
|
||||||
}
|
}
|
||||||
|
@ -16,13 +16,12 @@ require_once('include/widgets.php');
|
|||||||
|
|
||||||
|
|
||||||
function pdl_selector($uid, $current="") {
|
function pdl_selector($uid, $current="") {
|
||||||
|
|
||||||
$o = '';
|
$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",
|
$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);
|
$arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
|
||||||
@ -31,7 +30,7 @@ function pdl_selector($uid,$current="") {
|
|||||||
$entries = $arr['entries'];
|
$entries = $arr['entries'];
|
||||||
$current = $arr['current'];
|
$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' => '');
|
$entries[] = array('title' => t('Default'), 'mid' => '');
|
||||||
foreach($entries as $selection) {
|
foreach($entries as $selection) {
|
||||||
$selected = (($selection == $current) ? ' selected="selected" ' : '');
|
$selected = (($selection == $current) ? ' selected="selected" ' : '');
|
||||||
@ -45,6 +44,7 @@ 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);
|
$cnt = preg_match_all("/\[comment\](.*?)\[\/comment\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
@ -121,15 +121,15 @@ function comanche_get_channel_id() {
|
|||||||
$channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0);
|
$channel_id = ((is_array(get_app()->profile)) ? get_app()->profile['profile_uid'] : 0);
|
||||||
if((! $channel_id) && (local_channel()))
|
if((! $channel_id) && (local_channel()))
|
||||||
$channel_id = local_channel();
|
$channel_id = local_channel();
|
||||||
|
|
||||||
return $channel_id;
|
return $channel_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function comanche_block($name) {
|
function comanche_block($name) {
|
||||||
|
$o = '';
|
||||||
$channel_id = comanche_get_channel_id();
|
$channel_id = comanche_get_channel_id();
|
||||||
|
|
||||||
if($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",
|
$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),
|
intval($channel_id),
|
||||||
dbesc($name)
|
dbesc($name)
|
||||||
@ -138,11 +138,12 @@ function comanche_block($name) {
|
|||||||
$o = '<div class="widget bblock">';
|
$o = '<div class="widget bblock">';
|
||||||
if($r[0]['title'])
|
if($r[0]['title'])
|
||||||
$o .= '<h3>' . $r[0]['title'] . '</h3>';
|
$o .= '<h3>' . $r[0]['title'] . '</h3>';
|
||||||
|
|
||||||
$o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
|
$o .= prepare_text($r[0]['body'], $r[0]['mimetype']);
|
||||||
$o .= '</div>';
|
$o .= '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +155,9 @@ function comanche_block($name) {
|
|||||||
// of what template and webpage options we might desire.
|
// of what template and webpage options we might desire.
|
||||||
|
|
||||||
function comanche_webpage(&$a,$s) {
|
function comanche_webpage(&$a,$s) {
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
$matches = array();
|
||||||
|
|
||||||
$cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER);
|
$cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
@ -171,8 +173,9 @@ function comanche_webpage(&$a,$s) {
|
|||||||
|
|
||||||
|
|
||||||
function comanche_widget($name, $text) {
|
function comanche_widget($name, $text) {
|
||||||
$a = get_app();
|
|
||||||
$vars = array();
|
$vars = array();
|
||||||
|
$matches = array();
|
||||||
|
|
||||||
$cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
|
$cnt = preg_match_all("/\[var=(.*?)\](.*?)\[\/var\]/ism", $text, $matches, PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
foreach($matches as $mtch) {
|
foreach($matches as $mtch) {
|
||||||
@ -187,6 +190,7 @@ 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);
|
$cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER);
|
||||||
if($cnt) {
|
if($cnt) {
|
||||||
@ -244,7 +248,3 @@ function register_page_template($arr) {
|
|||||||
get_app()->page_layouts[$arr['template']] = array($arr['variant']);
|
get_app()->page_layouts[$arr['template']] = array($arr['variant']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
function get_browser_language() {
|
function get_browser_language() {
|
||||||
$langs = array();
|
$langs = array();
|
||||||
|
$lang_parse = array();
|
||||||
|
|
||||||
if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) {
|
if (x($_SERVER,'HTTP_ACCEPT_LANGUAGE')) {
|
||||||
// break up string into pieces (languages and q factors)
|
// break up string into pieces (languages and q factors)
|
||||||
@ -144,15 +145,15 @@ function load_translation_table($lang, $install = false) {
|
|||||||
/**
|
/**
|
||||||
* @brief translate string if translation exists.
|
* @brief translate string if translation exists.
|
||||||
*
|
*
|
||||||
* @param $s string that should get translated
|
* @param string $s string that should get translated
|
||||||
* @param $ctx optional context to appear in po file
|
* @param string $ctx optional context to appear in po file
|
||||||
* @return translated string if exists, otherwise return $s
|
* @return translated string if exists, otherwise return $s
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function t($s, $ctx = '') {
|
function t($s, $ctx = '') {
|
||||||
global $a;
|
global $a;
|
||||||
|
|
||||||
$cs = $ctx?"__ctx:".$ctx."__ ".$s:$s;
|
$cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s;
|
||||||
if(x($a->strings, $cs)) {
|
if(x($a->strings, $cs)) {
|
||||||
$t = $a->strings[$cs];
|
$t = $a->strings[$cs];
|
||||||
return is_array($t) ? $t[0] : $t;
|
return is_array($t) ? $t[0] : $t;
|
||||||
@ -218,7 +219,7 @@ function detect_language($s) {
|
|||||||
// strip off bbcode
|
// strip off bbcode
|
||||||
$naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body);
|
$naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body);
|
||||||
if(mb_strlen($naked_body) < intval($min_length)) {
|
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 '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,6 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
|
|
||||||
logger('photo_upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
|
logger('photo_upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
|
||||||
|
|
||||||
|
|
||||||
$maximagesize = get_config('system','maximagesize');
|
$maximagesize = get_config('system','maximagesize');
|
||||||
|
|
||||||
if(($maximagesize) && ($filesize > $maximagesize)) {
|
if(($maximagesize) && ($filesize > $maximagesize)) {
|
||||||
@ -134,7 +133,6 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$ph = photo_factory($imagedata, $type);
|
$ph = photo_factory($imagedata, $type);
|
||||||
|
|
||||||
if(! $ph->is_valid()) {
|
if(! $ph->is_valid()) {
|
||||||
@ -204,7 +202,6 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
$errors = true;
|
$errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($errors) {
|
if($errors) {
|
||||||
q("delete from photo where resource_id = '%s' and uid = %d",
|
q("delete from photo where resource_id = '%s' and uid = %d",
|
||||||
dbesc($photo_hash),
|
dbesc($photo_hash),
|
||||||
@ -220,7 +217,6 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
|
|
||||||
$width_x_height = $ph->getWidth() . 'x' . $ph->getHeight();
|
$width_x_height = $ph->getWidth() . 'x' . $ph->getHeight();
|
||||||
|
|
||||||
$basename = basename($filename);
|
|
||||||
$mid = item_message_id();
|
$mid = item_message_id();
|
||||||
|
|
||||||
// Create item container
|
// Create item container
|
||||||
@ -291,9 +287,17 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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) {
|
function photos_albums_list($channel, $observer) {
|
||||||
|
|
||||||
$channel_id = $channel['channel_id'];
|
$channel_id = $channel['channel_id'];
|
||||||
@ -310,7 +314,6 @@ function photos_albums_list($channel,$observer) {
|
|||||||
intval($channel_id),
|
intval($channel_id),
|
||||||
intval(PHOTO_NORMAL),
|
intval(PHOTO_NORMAL),
|
||||||
intval(PHOTO_PROFILE)
|
intval(PHOTO_PROFILE)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// add various encodings to the array so we can just loop through and pick them out in a template
|
// 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;
|
$ret['albums'][] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
|
||||||
|
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function photos_album_widget($channelx,$observer,$albums = null) {
|
function photos_album_widget($channelx,$observer,$albums = null) {
|
||||||
@ -395,16 +398,31 @@ function photos_list_photos($channel,$observer,$album = '') {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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) {
|
function photos_album_exists($channel_id, $album) {
|
||||||
$r = q("SELECT id from photo where album = '%s' and uid = %d limit 1",
|
$r = q("SELECT id FROM photo WHERE album = '%s' AND uid = %d limit 1",
|
||||||
dbesc($album),
|
dbesc($album),
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (($r) ? true : false);
|
return (($r) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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) {
|
function photos_album_rename($channel_id, $oldname, $newname) {
|
||||||
return q("UPDATE photo SET album = '%s' WHERE album = '%s' AND uid = %d",
|
return q("UPDATE photo SET album = '%s' WHERE album = '%s' AND uid = %d",
|
||||||
dbesc($newname),
|
dbesc($newname),
|
||||||
@ -437,8 +455,8 @@ function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') {
|
|||||||
$str = implode(',',$arr);
|
$str = implode(',',$arr);
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function photos_create_item($channel, $creator_hash, $photo, $visible = 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_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
|
||||||
$item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
|
$item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
|
||||||
|
|
||||||
$title = '';
|
|
||||||
$mid = item_message_id();
|
$mid = item_message_id();
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
@ -477,6 +494,6 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
|
|||||||
|
|
||||||
$result = item_store($arr);
|
$result = item_store($arr);
|
||||||
$item_id = $result['item_id'];
|
$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) {
|
function permissions_sql($owner_id, $remote_verified = false, $groups = null) {
|
||||||
|
|
||||||
if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
|
|
||||||
return '';
|
|
||||||
|
|
||||||
$local_channel = local_channel();
|
$local_channel = local_channel();
|
||||||
$remote_channel = remote_channel();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct permissions
|
* 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) {
|
function item_permissions_sql($owner_id, $remote_verified = false, $groups = null) {
|
||||||
|
|
||||||
if(defined('STATUSNET_PRIVACY_COMPATIBILITY'))
|
|
||||||
return '';
|
|
||||||
|
|
||||||
$local_channel = local_channel();
|
$local_channel = local_channel();
|
||||||
$remote_channel = remote_channel();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct permissions
|
* Construct permissions
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
require_once('include/dir_fns.php');
|
require_once('include/dir_fns.php');
|
||||||
require_once('include/zot.php');
|
require_once('include/zot.php');
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* poco_load
|
* poco_load
|
||||||
*
|
*
|
||||||
* xchan is your connection
|
* 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
|
* the given uid, cid to the global contact entry. There can be many uid/cid combinations
|
||||||
* pointing to the same global contact id.
|
* pointing to the same global contact id.
|
||||||
*
|
*
|
||||||
|
* @param string $xchan
|
||||||
|
* @param string $url
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function poco_load($xchan = '', $url = null) {
|
function poco_load($xchan = '', $url = null) {
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
if($xchan && ! $url) {
|
if($xchan && ! $url) {
|
||||||
$r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1",
|
$r = q("select xchan_connurl from xchan where xchan_hash = '%s' limit 1",
|
||||||
@ -43,7 +40,6 @@ function poco_load($xchan = '',$url = null) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ;
|
$url = $url . '?f=&fields=displayName,hash,urls,photos,rating' ;
|
||||||
|
|
||||||
logger('poco_load: ' . $url, LOGGER_DEBUG);
|
logger('poco_load: ' . $url, LOGGER_DEBUG);
|
||||||
@ -184,7 +180,6 @@ function poco_load($xchan = '',$url = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$total ++;
|
$total ++;
|
||||||
|
|
||||||
}
|
}
|
||||||
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
|
logger("poco_load: loaded $total entries",LOGGER_DEBUG);
|
||||||
|
|
||||||
@ -193,7 +188,6 @@ function poco_load($xchan = '',$url = null) {
|
|||||||
db_utcnow(), db_quoteinterval('2 DAY')
|
db_utcnow(), db_quoteinterval('2 DAY')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -230,7 +224,6 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false
|
|||||||
);
|
);
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -246,8 +239,8 @@ function count_common_friends_zcid($uid,$zcid) {
|
|||||||
|
|
||||||
if(count($r))
|
if(count($r))
|
||||||
return $r[0]['total'];
|
return $r[0]['total'];
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = false) {
|
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;
|
return $r;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -284,8 +276,8 @@ function count_all_friends($uid,$cid) {
|
|||||||
|
|
||||||
if(count($r))
|
if(count($r))
|
||||||
return $r[0]['total'];
|
return $r[0]['total'];
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -358,8 +350,6 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) {
|
|||||||
|
|
||||||
function update_suggestions() {
|
function update_suggestions() {
|
||||||
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
$dirmode = get_config('system', 'directory_mode');
|
$dirmode = get_config('system', 'directory_mode');
|
||||||
if($dirmode === false)
|
if($dirmode === false)
|
||||||
$dirmode = DIRECTORY_MODE_NORMAL;
|
$dirmode = DIRECTORY_MODE_NORMAL;
|
||||||
@ -374,8 +364,6 @@ function update_suggestions() {
|
|||||||
if(! $url)
|
if(! $url)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ret = z_fetch_url($url);
|
$ret = z_fetch_url($url);
|
||||||
|
|
||||||
if($ret['success']) {
|
if($ret['success']) {
|
||||||
@ -388,7 +376,6 @@ function update_suggestions() {
|
|||||||
db_utcnow(), db_quoteinterval('7 DAY')
|
db_utcnow(), db_quoteinterval('7 DAY')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$j = json_decode($ret['body'],true);
|
$j = json_decode($ret['body'],true);
|
||||||
if($j && $j['success']) {
|
if($j && $j['success']) {
|
||||||
foreach($j['entries'] as $host) {
|
foreach($j['entries'] as $host) {
|
||||||
@ -422,7 +409,6 @@ function poco($a,$extended = false) {
|
|||||||
$system_mode = true;
|
$system_mode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json');
|
$format = (($_REQUEST['format']) ? $_REQUEST['format'] : 'json');
|
||||||
|
|
||||||
$justme = false;
|
$justme = false;
|
||||||
@ -487,8 +473,8 @@ function poco($a,$extended = false) {
|
|||||||
$startIndex = intval($_GET['startIndex']);
|
$startIndex = intval($_GET['startIndex']);
|
||||||
if(! $startIndex)
|
if(! $startIndex)
|
||||||
$startIndex = 0;
|
$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) {
|
if($system_mode) {
|
||||||
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where ( abook_flags & " . ABOOK_FLAG_SELF .
|
$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($itemsPerPage),
|
||||||
intval($startIndex)
|
intval($startIndex)
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d
|
$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",
|
$sql_extra LIMIT %d OFFSET %d",
|
||||||
intval($channel_id),
|
intval($channel_id),
|
||||||
@ -527,7 +512,6 @@ function poco($a,$extended = false) {
|
|||||||
|
|
||||||
$ret['entry'] = array();
|
$ret['entry'] = array();
|
||||||
|
|
||||||
|
|
||||||
$fields_ret = array(
|
$fields_ret = array(
|
||||||
'id' => false,
|
'id' => false,
|
||||||
'guid' => false,
|
'guid' => false,
|
||||||
@ -540,10 +524,10 @@ function poco($a,$extended = false) {
|
|||||||
'rating' => false
|
'rating' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all'))
|
if((! x($_GET,'fields')) || ($_GET['fields'] === '@all')) {
|
||||||
foreach($fields_ret as $k => $v)
|
foreach($fields_ret as $k => $v)
|
||||||
$fields_ret[$k] = true;
|
$fields_ret[$k] = true;
|
||||||
else {
|
} else {
|
||||||
$fields_req = explode(',',$_GET['fields']);
|
$fields_req = explode(',',$_GET['fields']);
|
||||||
foreach($fields_req as $f)
|
foreach($fields_req as $f)
|
||||||
$fields_ret[trim($f)] = true;
|
$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 = '') {
|
function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
|
||||||
if(! $term)
|
if(! $term)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$r = q("select * from term
|
$r = q("select * from term
|
||||||
where uid = %d and oid = %d and otype = %d and type = %d
|
where uid = %d and oid = %d and otype = %d and type = %d
|
||||||
and term = '%s' and url = '%s' ",
|
and term = '%s' and url = '%s' ",
|
||||||
@ -50,6 +51,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
|
|||||||
);
|
);
|
||||||
if($r)
|
if($r)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$r = q("insert into term (uid, oid, otype, type, term, url)
|
$r = q("insert into term (uid, oid, otype, type, term, url)
|
||||||
values( %d, %d, %d, %d, '%s', '%s') ",
|
values( %d, %d, %d, %d, '%s', '%s') ",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
@ -59,9 +61,11 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') {
|
|||||||
dbesc($term),
|
dbesc($term),
|
||||||
dbesc($url)
|
dbesc($url)
|
||||||
);
|
);
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_terms_oftype($arr,$type) {
|
function get_terms_oftype($arr,$type) {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if(! (is_array($arr) && count($arr)))
|
if(! (is_array($arr) && count($arr)))
|
||||||
@ -74,6 +78,7 @@ function get_terms_oftype($arr,$type) {
|
|||||||
foreach($arr as $x)
|
foreach($arr as $x)
|
||||||
if($x['type'] == $t)
|
if($x['type'] == $t)
|
||||||
$ret[] = $x;
|
$ret[] = $x;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +117,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
|
|||||||
if($authors) {
|
if($authors) {
|
||||||
if(! is_array($authors))
|
if(! is_array($authors))
|
||||||
$authors = array($authors);
|
$authors = array($authors);
|
||||||
|
|
||||||
stringify_array_elms($authors,true);
|
stringify_array_elms($authors,true);
|
||||||
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
|
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
|
||||||
}
|
}
|
||||||
@ -158,16 +164,17 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $
|
|||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function tags_sort($a,$b) {
|
function tags_sort($a,$b) {
|
||||||
if(strtolower($a[0]) == strtolower($b[0]))
|
if(strtolower($a[0]) == strtolower($b[0]))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
|
return((strtolower($a[0]) < strtolower($b[0])) ? -1 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dir_tagadelic($count = 0) {
|
function dir_tagadelic($count = 0) {
|
||||||
|
|
||||||
$sql_options = '';
|
|
||||||
$count = intval($count);
|
$count = intval($count);
|
||||||
|
|
||||||
// Fetch tags
|
// Fetch tags
|
||||||
@ -208,7 +215,7 @@ function dir_tagadelic($count = 0) {
|
|||||||
|
|
||||||
function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
|
function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
|
||||||
$o = '';
|
$o = '';
|
||||||
$tab = 0;
|
|
||||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
@ -218,12 +225,14 @@ function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$
|
|||||||
}
|
}
|
||||||
$o .= '</div></div>';
|
$o .= '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function wtagblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
|
function wtagblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) {
|
||||||
$o = '';
|
$o = '';
|
||||||
$tab = 0;
|
|
||||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
@ -237,13 +246,13 @@ function wtagblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type
|
|||||||
}
|
}
|
||||||
$o .= '</div></div>';
|
$o .= '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function catblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_CATEGORY) {
|
function catblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_CATEGORY) {
|
||||||
$o = '';
|
$o = '';
|
||||||
$tab = 0;
|
|
||||||
|
|
||||||
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
$r = tagadelic($uid,$count,$authors,$flags,$restrict,$type);
|
||||||
|
|
||||||
@ -258,14 +267,13 @@ function catblock($uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type =
|
|||||||
}
|
}
|
||||||
$o .= '</div></div>';
|
$o .= '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function dir_tagblock($link,$r) {
|
function dir_tagblock($link,$r) {
|
||||||
$o = '';
|
$o = '';
|
||||||
$tab = 0;
|
|
||||||
|
|
||||||
if(! $r)
|
if(! $r)
|
||||||
$r = get_app()->data['directory_keywords'];
|
$r = get_app()->data['directory_keywords'];
|
||||||
@ -277,14 +285,12 @@ function dir_tagblock($link,$r) {
|
|||||||
}
|
}
|
||||||
$o .= '</div></div>';
|
$o .= '</div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants"
|
* 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
|
* 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.
|
* require obj_verbs() to provide full conjugations and specify which form to use in the $_REQUEST params to this module.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function obj_verbs() {
|
function obj_verbs() {
|
||||||
$verbs = array(
|
$verbs = array(
|
||||||
'has' => array( t('have'), t('has')),
|
'has' => array( t('have'), t('has')),
|
||||||
@ -304,20 +308,21 @@ function obj_verbs() {
|
|||||||
|
|
||||||
$arr = array('verbs' => $verbs);
|
$arr = array('verbs' => $verbs);
|
||||||
call_hooks('obj_verbs', $arr);
|
call_hooks('obj_verbs', $arr);
|
||||||
|
|
||||||
return $arr['verbs'];
|
return $arr['verbs'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function obj_verb_selector($current = '') {
|
function obj_verb_selector($current = '') {
|
||||||
$verbs = obj_verbs();
|
$verbs = obj_verbs();
|
||||||
$o .= '<select class="obj-verb-selector" name="verb" >';
|
$o = '<select class="obj-verb-selector" name="verb">';
|
||||||
foreach($verbs as $k => $v) {
|
foreach($verbs as $k => $v) {
|
||||||
$selected = (($k == $current) ? ' selected="selected" ' : '');
|
$selected = (($k == $current) ? ' selected="selected" ' : '');
|
||||||
$o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[1] . '</option>';
|
$o .= '<option value="' . urlencode($k) . '"' . $selected . '>' . $v[1] . '</option>';
|
||||||
}
|
}
|
||||||
$o .= '</select>';
|
$o .= '</select>';
|
||||||
return $o;
|
|
||||||
|
|
||||||
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_things($profile_hash,$uid) {
|
function get_things($profile_hash,$uid) {
|
||||||
@ -382,8 +387,8 @@ function get_things($profile_hash,$uid) {
|
|||||||
|
|
||||||
if(! $things[$rr['obj_verb']])
|
if(! $things[$rr['obj_verb']])
|
||||||
$things[$rr['obj_verb']] = array();
|
$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();
|
$sorted_things = array();
|
||||||
if($things) {
|
if($things) {
|
||||||
@ -395,6 +400,6 @@ function get_things($profile_hash,$uid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//logger('things: ' . print_r($sorted_things,true));
|
//logger('things: ' . print_r($sorted_things,true));
|
||||||
return $sorted_things;
|
|
||||||
|
|
||||||
|
return $sorted_things;
|
||||||
}
|
}
|
Reference in New Issue
Block a user