streams/Zotlabs/Widget/Categories.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2017-03-16 03:11:28 +00:00
<?php
namespace Zotlabs\Widget;
require_once('include/contact_widgets.php');
2017-03-16 03:11:28 +00:00
class Categories {
function widget($arr) {
2017-08-23 07:01:02 +00:00
$cards = ((array_key_exists('cards',$arr) && $arr['cards']) ? true : false);
2017-08-23 09:03:39 +00:00
if(($cards) && (! feature_enabled(\App::$profile['profile_uid'],'cards')))
2017-08-23 07:01:02 +00:00
return '';
2017-11-22 23:39:06 +00:00
$articles = ((array_key_exists('articles',$arr) && $arr['articles']) ? true : false);
if(($articles) && (! feature_enabled(\App::$profile['profile_uid'],'articles')))
return '';
2017-03-16 03:11:28 +00:00
if((! \App::$profile['profile_uid'])
2017-11-22 23:39:06 +00:00
|| (! perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) {
2017-03-16 03:11:28 +00:00
return '';
}
$cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat'],ENT_COMPAT,'UTF-8') : '');
$srchurl = (($cards) ? \App::$argv[0] . '/' . \App::$argv[1] : \App::$query_string);
2017-03-16 03:11:28 +00:00
$srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&');
$srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl);
2017-08-23 07:01:02 +00:00
if($cards)
return cardcategories_widget($srchurl, $cat);
2017-11-22 23:39:06 +00:00
elseif($articles)
return articlecategories_widget($srchurl, $cat);
2017-08-23 07:01:02 +00:00
else
return categories_widget($srchurl, $cat);
2017-03-16 03:11:28 +00:00
}
}