Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hubzilla
core
Commits
477ed97c
Commit
477ed97c
authored
Mar 15, 2017
by
Zot
Committed by
Mario
Mar 29, 2017
Browse files
convert more widgets to classes
parent
242ef70a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Zotlabs/Widget/Collections.php
0 → 100644
View file @
477ed97c
<?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
);
}
}
Zotlabs/Widget/Profile
0 → 100644
View file @
477ed97c
<?php
namespace
Zotlabs\Widget
;
class
Profile
{
function
widget
(
$args
)
{
$block
=
observer_prohibited
();
return
profile_sidebar
(
\
App
::
$profile
,
$block
,
true
);
}
}
\ No newline at end of file
Zotlabs/Widget/Suggestions.php
0 → 100644
View file @
477ed97c
<?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
;
}
}
Zotlabs/Widget/Tagcloud.php
0 → 100644
View file @
477ed97c
<?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
;
}
}
Zotlabs/Widget/Zcard.php
0 → 100644
View file @
477ed97c
<?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
));
}
}
include/widgets.php
View file @
477ed97c
...
...
@@ -10,141 +10,8 @@ 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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment