convert more widgets to classes
This commit is contained in:
parent
242ef70a77
commit
477ed97c2f
51
Zotlabs/Widget/Collections.php
Normal file
51
Zotlabs/Widget/Collections.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
require_once('include/group.php');
|
||||
|
||||
class Collections {
|
||||
|
||||
function widget($args) {
|
||||
|
||||
$mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation');
|
||||
switch($mode) {
|
||||
case 'conversation':
|
||||
$every = argv(0);
|
||||
$each = argv(0);
|
||||
$edit = true;
|
||||
$current = $_REQUEST['gid'];
|
||||
$abook_id = 0;
|
||||
$wmode = 0;
|
||||
break;
|
||||
case 'connections':
|
||||
$every = 'connections';
|
||||
$each = 'group';
|
||||
$edit = true;
|
||||
$current = $_REQUEST['gid'];
|
||||
$abook_id = 0;
|
||||
$wmode = 0;
|
||||
case 'groups':
|
||||
$every = 'connections';
|
||||
$each = argv(0);
|
||||
$edit = false;
|
||||
$current = intval(argv(1));
|
||||
$abook_id = 0;
|
||||
$wmode = 1;
|
||||
break;
|
||||
case 'abook':
|
||||
$every = 'connections';
|
||||
$each = 'group';
|
||||
$edit = false;
|
||||
$current = 0;
|
||||
$abook_id = \App::$poi['abook_xchan'];
|
||||
$wmode = 1;
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
|
||||
return group_side($every, $each, $edit, $current, $abook_id, $wmode);
|
||||
}
|
||||
}
|
13
Zotlabs/Widget/Profile
Normal file
13
Zotlabs/Widget/Profile
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
|
||||
class Profile {
|
||||
|
||||
function widget($args) {
|
||||
$block = observer_prohibited();
|
||||
return profile_sidebar(\App::$profile, $block, true);
|
||||
}
|
||||
|
||||
}
|
58
Zotlabs/Widget/Suggestions.php
Normal file
58
Zotlabs/Widget/Suggestions.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
|
||||
class Suggestions {
|
||||
|
||||
function widget($arr) {
|
||||
|
||||
if((! local_channel()) || (! feature_enabled(local_channel(),'suggest')))
|
||||
return '';
|
||||
|
||||
|
||||
$r = suggestion_query(local_channel(),get_observer_hash(),0,20);
|
||||
|
||||
if(! $r) {
|
||||
return;
|
||||
}
|
||||
|
||||
$arr = array();
|
||||
|
||||
// Get two random entries from the top 20 returned.
|
||||
// We'll grab the first one and the one immediately following.
|
||||
// This will throw some entropy intot he situation so you won't
|
||||
// be looking at the same two mug shots every time the widget runs
|
||||
|
||||
$index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
|
||||
|
||||
for($x = $index; $x <= ($index+1); $x ++) {
|
||||
$rr = $r[$x];
|
||||
if(! $rr['xchan_url'])
|
||||
break;
|
||||
|
||||
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
|
||||
|
||||
$arr[] = array(
|
||||
'url' => chanlink_url($rr['xchan_url']),
|
||||
'profile' => $rr['xchan_url'],
|
||||
'name' => $rr['xchan_name'],
|
||||
'photo' => $rr['xchan_photo_m'],
|
||||
'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'],
|
||||
'conntxt' => t('Connect'),
|
||||
'connlnk' => $connlnk,
|
||||
'ignore' => t('Ignore/Hide')
|
||||
);
|
||||
}
|
||||
|
||||
$o = replace_macros(get_markup_template('suggest_widget.tpl'),array(
|
||||
'$title' => t('Suggestions'),
|
||||
'$more' => t('See more...'),
|
||||
'$entries' => $arr
|
||||
));
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
33
Zotlabs/Widget/Tagcloud.php
Normal file
33
Zotlabs/Widget/Tagcloud.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
// @FIXME The problem with this widget is that we don't have a search function for webpages
|
||||
// that we can send the links to. Then we should also provide an option to search webpages
|
||||
// and conversations.
|
||||
|
||||
class Tagcloud {
|
||||
|
||||
function widget($args) {
|
||||
|
||||
$o = '';
|
||||
$uid = \App::$profile_uid;
|
||||
$count = ((x($args,'count')) ? intval($args['count']) : 24);
|
||||
$flags = 0;
|
||||
$type = TERM_CATEGORY;
|
||||
|
||||
// @FIXME there exists no $authors variable
|
||||
$r = tagadelic($uid, $count, $authors, $owner, $flags, ITEM_TYPE_WEBPAGE, $type);
|
||||
|
||||
// @FIXME this should use a template
|
||||
|
||||
if($r) {
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rv) {
|
||||
$o .= '<span class="tag' . $rv[2] . '">' . $rv[0] .' </span> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
}
|
11
Zotlabs/Widget/Zcard.php
Normal file
11
Zotlabs/Widget/Zcard.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
class Zcard {
|
||||
|
||||
function widget($args) {
|
||||
$channel = channelx_by_n(\App::$profile_uid);
|
||||
return get_zcard($channel,get_observer_hash(),array('width' => 875));
|
||||
}
|
||||
}
|
@ -10,143 +10,10 @@ require_once('include/contact_widgets.php');
|
||||
require_once('include/attach.php');
|
||||
|
||||
|
||||
function widget_profile($args) {
|
||||
|
||||
$block = observer_prohibited();
|
||||
return profile_sidebar(App::$profile, $block, true);
|
||||
}
|
||||
|
||||
function widget_zcard($args) {
|
||||
|
||||
$block = observer_prohibited();
|
||||
$channel = channelx_by_n(App::$profile_uid);
|
||||
return get_zcard($channel,get_observer_hash(),array('width' => 875));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// FIXME The problem with the next widget is that we don't have a search function for webpages that we can send the links to.
|
||||
// Then we should also provide an option to search webpages and conversations.
|
||||
|
||||
function widget_tagcloud($args) {
|
||||
|
||||
$o = '';
|
||||
//$tab = 0;
|
||||
|
||||
$uid = App::$profile_uid;
|
||||
$count = ((x($args,'count')) ? intval($args['count']) : 24);
|
||||
$flags = 0;
|
||||
$type = TERM_CATEGORY;
|
||||
|
||||
// FIXME there exists no $authors variable
|
||||
$r = tagadelic($uid, $count, $authors, $owner, $flags, ITEM_TYPE_WEBPAGE, $type);
|
||||
|
||||
if($r) {
|
||||
$o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">';
|
||||
foreach($r as $rr) {
|
||||
$o .= '<span class="tag'.$rr[2].'">'.$rr[0].'</span> ' . "\r\n";
|
||||
}
|
||||
$o .= '</div></div>';
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
||||
function widget_collections($args) {
|
||||
require_once('include/group.php');
|
||||
|
||||
$mode = ((array_key_exists('mode',$args)) ? $args['mode'] : 'conversation');
|
||||
switch($mode) {
|
||||
case 'conversation':
|
||||
$every = argv(0);
|
||||
$each = argv(0);
|
||||
$edit = true;
|
||||
$current = $_REQUEST['gid'];
|
||||
$abook_id = 0;
|
||||
$wmode = 0;
|
||||
break;
|
||||
case 'connections':
|
||||
$every = 'connections';
|
||||
$each = 'group';
|
||||
$edit = true;
|
||||
$current = $_REQUEST['gid'];
|
||||
$abook_id = 0;
|
||||
$wmode = 0;
|
||||
case 'groups':
|
||||
$every = 'connections';
|
||||
$each = argv(0);
|
||||
$edit = false;
|
||||
$current = intval(argv(1));
|
||||
$abook_id = 0;
|
||||
$wmode = 1;
|
||||
break;
|
||||
case 'abook':
|
||||
$every = 'connections';
|
||||
$each = 'group';
|
||||
$edit = false;
|
||||
$current = 0;
|
||||
$abook_id = App::$poi['abook_xchan'];
|
||||
$wmode = 1;
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
|
||||
return group_side($every, $each, $edit, $current, $abook_id, $wmode);
|
||||
}
|
||||
|
||||
function widget_suggestions($arr) {
|
||||
|
||||
if((! local_channel()) || (! feature_enabled(local_channel(),'suggest')))
|
||||
return '';
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
$r = suggestion_query(local_channel(),get_observer_hash(),0,20);
|
||||
|
||||
if(! $r) {
|
||||
return;
|
||||
}
|
||||
|
||||
$arr = array();
|
||||
|
||||
// Get two random entries from the top 20 returned.
|
||||
// We'll grab the first one and the one immediately following.
|
||||
// This will throw some entropy intot he situation so you won't
|
||||
// be looking at the same two mug shots every time the widget runs
|
||||
|
||||
$index = ((count($r) > 2) ? mt_rand(0,count($r) - 2) : 0);
|
||||
|
||||
for($x = $index; $x <= ($index+1); $x ++) {
|
||||
$rr = $r[$x];
|
||||
if(! $rr['xchan_url'])
|
||||
break;
|
||||
|
||||
$connlnk = z_root() . '/follow/?url=' . $rr['xchan_addr'];
|
||||
|
||||
$arr[] = array(
|
||||
'url' => chanlink_url($rr['xchan_url']),
|
||||
'profile' => $rr['xchan_url'],
|
||||
'name' => $rr['xchan_name'],
|
||||
'photo' => $rr['xchan_photo_m'],
|
||||
'ignlnk' => z_root() . '/directory?ignore=' . $rr['xchan_hash'],
|
||||
'conntxt' => t('Connect'),
|
||||
'connlnk' => $connlnk,
|
||||
'ignore' => t('Ignore/Hide')
|
||||
);
|
||||
}
|
||||
|
||||
$o = replace_macros(get_markup_template('suggest_widget.tpl'),array(
|
||||
'$title' => t('Suggestions'),
|
||||
'$more' => t('See more...'),
|
||||
'$entries' => $arr
|
||||
));
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
||||
function widget_follow($args) {
|
||||
if(! local_channel())
|
||||
return '';
|
||||
|
Reference in New Issue
Block a user