aboutsummaryrefslogblamecommitdiffstats
path: root/Zotlabs/Widget/Categories.php
blob: 0a1c800612df1756c7e06fd055cfa0589421fac7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

     





                                                           

                         


                     
                                            




                               

                                                                                            
                                                                                                                                         


                                  



                                                                                                              
 
                            
                                                                     


                                                         
 

         
<?php

/**
 *   * Name: Categories
 *   * Description: Display a menu with links to categories
 *   * Requires: channel, articles, cards, cloud
 */

namespace Zotlabs\Widget;

use App;
use Zotlabs\Lib\Apps;

require_once('include/contact_widgets.php');

class Categories {

	function widget($arr) {

		$files = ((array_key_exists('files',$arr) && $arr['files']) ? true : false);

		if(!App::$profile['profile_uid'] || !perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_stream')) {
			return '';
		}

		$cat = ((x($_REQUEST, 'cat')) ? htmlspecialchars($_REQUEST['cat'], ENT_COMPAT, 'UTF-8') : '');
		$srchurl = App::$query_string;
		$srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is', '', $srchurl), '&');
		$srchurl = str_replace(['?f=','&f=', '/?'], ['', '', ''], $srchurl);

		if($files) {
			return filecategories_widget($srchurl, $cat);
		}

		return categories_widget($srchurl, $cat);

	}
}