Example #1
0
 function render()
 {
     # Validate permissions
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_statistics, '');
     # init
     $svcUserFilter = new Services_User_Filters($this->_daoFactory, $this->_settings);
     # set the page title
     $this->_pageTitle = _("Statistics");
     #- display stuff -#
     $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     $parsedSearch = $svcSearchQp->filterToQuery('', array('field' => '', 'direction' => ''), $this->_currentSession, $svcUserFilter->getIndexFilter($this->_currentSession['user']['userid']));
     $this->template('statistics', array('quicklinks' => $this->_settings->get('quicklinks'), 'filters' => $svcUserFilter->getFilterList($this->_currentSession['user']['userid'], 'filter'), 'parsedsearch' => $parsedSearch, 'limit' => $this->_params['limit']));
 }
Example #2
0
 /**
  * Search the spotweb database for a specific piece of information
  *
  * @param $outputtype
  */
 function search($outputtype)
 {
     # Check users' permissions
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_perform_search, '');
     $searchParams = array();
     /**
      * Now determine what type of information we are searching for using sabnzbd
      */
     if (($this->_params['t'] == "t" || $this->_params['t'] == "tvsearch") && $this->_params['rid'] != "") {
         # validate input
         if (!preg_match('/^[0-9]{1,6}$/', $this->_params['rid'])) {
             $this->showApiError(201);
             return;
         }
         # if
         /*
          * Actually retrieve the information from TVRage, based on the
          * tvrage passed by the API
          */
         $svcMediaInfoTvrage = new Services_MediaInformation_Tvrage($this->_daoFactory, $this->_settings);
         $svcMediaInfoTvrage->setSearchid($this->_params['rid']);
         $tvRageInfo = $svcMediaInfoTvrage->retrieveInfo();
         if (!$tvRageInfo->isValid()) {
             $this->showApiError(300);
             return;
         }
         # if
         /*
          * Try to parse the season parameter. This can be either in the form of S1, S01, 1, 2012, etc.
          * we try to standardize all these types of season definitions into one format.
          */
         $episodeSearch = '';
         $seasonSearch = '';
         if (preg_match('/^[sS][0-9]{1,2}$/', $this->_params['season']) || preg_match('/^[0-9]{1,4}$/', $this->_params['season'])) {
             /*
              * Did we get passed a 4 digit season (most likely a year), or a
              * two digit season?
              */
             if (strlen($this->_params['season']) < 3) {
                 if (is_numeric($this->_params['season'])) {
                     $seasonSearch = 'S' . str_pad($this->_params['season'], 2, "0", STR_PAD_LEFT);
                 } else {
                     $seasonSearch = $this->_params['season'];
                 }
                 # else
             } else {
                 $seasonSearch = $this->_params['season'] . ' ';
             }
             # else
         } elseif ($this->_params['season'] != "") {
             $this->showApiError(201);
             return;
         }
         # if
         /*
          * And try to add an episode parameter, basically the same set of rules
          * as for the season
          */
         if (preg_match('/^[eE][0-9]{1,2}$/', $this->_params['ep']) || preg_match('/^[0-9]{1,2}$/', $this->_params['ep']) || preg_match('/^[0-9]{1,2}\\/[0-9]{1,2}$/', $this->_params['ep'])) {
             if (is_numeric($this->_params['ep'])) {
                 $episodeSearch .= 'E' . str_pad($this->_params['ep'], 2, "0", STR_PAD_LEFT);
             } else {
                 $episodeSearch .= $this->_params['ep'];
             }
             # else
         } elseif ($this->_params['ep'] != "") {
             $this->showApiError(201);
             return;
         } else {
             // Complete season search, add wildcard character to season
             $seasonSearch .= '*';
             // and search for the text 'Season ' ...
             $searchParams['value'][] = "Titel:=:OR:+\"" . $tvRageInfo->getTitle() . "\" +\"Season " . (int) $this->_params['season'] . "\"";
         }
         # else
         /*
          * The + operator is supported both by PostgreSQL and MySQL's FTS
          *
          * We search both for S04E17 and S04 E17 (with a space)
          */
         $searchParams['value'][] = "Titel:=:OR:+\"" . $tvRageInfo->getTitle() . "\" +" . $seasonSearch . $episodeSearch;
         if (!empty($episodeSearch)) {
             $searchParams['value'][] = "Titel:=:OR:+\"" . $tvRageInfo->getTitle() . "\" +" . $seasonSearch . ' +' . $episodeSearch;
         }
         # if
     } elseif ($this->_params['t'] == "music") {
         if (empty($this->_params['artist']) && empty($this->_params['cat'])) {
             $this->_params['cat'] = 3000;
         } else {
             $searchParams['value'][] = "Titel:=:DEF:\"" . $this->_params['artist'] . "\"";
         }
         # if
     } elseif ($this->_params['t'] == "m" || $this->_params['t'] == "movie") {
         # validate input
         if ($this->_params['imdbid'] == "") {
             $this->showApiError(200);
             return;
         } elseif (!preg_match('/^[0-9]{1,8}$/', $this->_params['imdbid'])) {
             $this->showApiError(201);
             return;
         }
         # if
         /*
          * Actually retrieve the information from imdb, based on the
          * imdbid passed by the API
          */
         $svcMediaInfoImdb = new Services_MediaInformation_Imdb($this->_daoFactory, $this->_settings);
         $svcMediaInfoImdb->setSearchid($this->_params['imdbid']);
         $imdbInfo = $svcMediaInfoImdb->retrieveInfo();
         if (!$imdbInfo->isValid()) {
             $this->showApiError(300);
             return;
         }
         # if
         /* Extract the release date from the IMDB info page */
         if ($imdbInfo->getReleaseYear() != null) {
             $movieReleaseDate = '+(' . $imdbInfo->getReleaseYear() . ')';
         } else {
             $movieReleaseDate = '';
         }
         # else
         /*
          * Add movie title to the query
          */
         $searchParams['value'][] = "Titel:=:OR:+\"" . $imdbInfo->getTitle() . "\" " . $movieReleaseDate;
         // imdb sometimes returns the title translated, if so, pass the original title as well
         if ($imdbInfo->getAlternateTitle() != null) {
             $searchParams['value'][] = "Title:=:OR:+\"" . $imdbInfo->getAlternateTitle() . "\" " . $movieReleaseDate;
         }
         # if
     } elseif (!empty($this->_params['q'])) {
         $searchTerm = str_replace(" ", " +", $this->_params['q']);
         $searchParams['value'][] = "Titel:=:OR:+" . $searchTerm;
     }
     # elseif
     /*
      * When a user added a maximum age for queries, convert it to
      * a Spotweb query as well
      */
     if ($this->_params['maxage'] != "" && is_numeric($this->_params['maxage'])) {
         $searchParams['value'][] = "date:>:DEF:-" . $this->_params['maxage'] . "days";
     }
     # if
     /*
      * We combine the "newznabapi" categories, with a custom extension for
      * categories so we can filter deeper than the newznab API can per default
      */
     $tmpCat = array();
     foreach (explode(",", $this->_params['cat']) as $category) {
         $tmpCat[] = $this->nabcat2spotcat($category);
     }
     # foreach
     $searchParams['tree'] = implode(",", $tmpCat) . ',' . $this->_params['spotcat'];
     /*
      * Do not retrieve spots with a filesize of zero (these are very old spots,
      * which have no NZB linked to it) as they are useless for a API consumer
      */
     $searchParams['value'][] = "filesize:>:DEF:0";
     /*
      * Gather the preference of the results per page and use it in this
      * system as well when no value is explicitly provided
      */
     if (!empty($this->_params['limit']) && is_numeric($this->_params['limit']) && $this->_params['limit'] < 500) {
         $limit = $this->_params['limit'];
     } else {
         $limit = $this->_currentSession['user']['prefs']['perpage'];
     }
     # else
     if (!empty($this->_params['offset']) && is_numeric($this->_params['offset'])) {
         $pageNr = $this->_params['offset'];
     } else {
         $pageNr = 0;
     }
     # else
     /*
      * We get a bunch of query parameters, so now change this to the actual
      * search query the user requested including the required sorting
      */
     $svcUserFilter = new Services_User_Filters($this->_daoFactory, $this->_settings);
     $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     $parsedSearch = $svcSearchQp->filterToQuery($searchParams, array('field' => 'stamp', 'direction' => 'DESC'), $this->_currentSession, $svcUserFilter->getIndexFilter($this->_currentSession['user']['userid']));
     /*
      * Actually fetch the spots, we always perform
      * this action even when the watchlist is editted
      */
     $svcProvSpotList = new Services_Providers_SpotList($this->_daoFactory->getSpotDao());
     $spotsTmp = $svcProvSpotList->fetchSpotList($this->_currentSession['user']['userid'], $pageNr, $limit, $parsedSearch);
     $this->showResults($spotsTmp, $pageNr * $limit, $outputtype);
 }
Example #3
0
 function render()
 {
     # Make sure the proper permissions are met
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spotdetail, '');
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spots_index, '');
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_rssfeed, '');
     $nzbhandling = $this->_currentSession['user']['prefs']['nzbhandling'];
     # Don't allow the RSS feed to be cached
     $this->sendExpireHeaders(true);
     /*
      * Transform the query parameters to a list of filters, fields, 
      * sortings, etc.
      */
     $svcUserFilter = new Services_User_Filters($this->_daoFactory, $this->_settings);
     $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     $parsedSearch = $svcSearchQp->filterToQuery($this->_params['search'], array('field' => $this->_params['sortby'], 'direction' => $this->_params['sortdir']), $this->_currentSession, $svcUserFilter->getIndexFilter($this->_currentSession['user']['userid']));
     /* 
      * Actually fetch the spots
      */
     $pageNr = $this->_params['page'];
     $svcProvSpotList = new Services_Providers_SpotList($this->_daoFactory->getSpotDao());
     $spotsTmp = $svcProvSpotList->fetchSpotList($this->_currentSession['user']['userid'], $pageNr, $this->_currentSession['user']['prefs']['perpage'], $parsedSearch);
     # Create an XML document for RSS
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     $rss = $doc->createElement('rss');
     $rss->setAttribute('version', '2.0');
     $rss->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
     $doc->appendChild($rss);
     $atomSelfLink = $doc->createElementNS('http://www.w3.org/2005/Atom', 'atom10:link');
     $atomSelfLink->setAttribute('href', html_entity_decode($this->_tplHelper->makeSelfUrl("full")));
     $atomSelfLink->setAttribute('rel', 'self');
     $atomSelfLink->setAttribute('type', 'application/rss+xml');
     $channel = $doc->createElement('channel');
     $channel->appendChild($doc->createElement('generator', 'Spotweb v' . SPOTWEB_VERSION));
     $channel->appendChild($doc->createElement('language', 'nl'));
     $channel->appendChild($doc->createElement('title', 'Spotweb'));
     $channel->appendChild($doc->createElement('description', 'Spotweb RSS Feed'));
     $channel->appendChild($doc->createElement('link', $this->_tplHelper->makeBaseUrl("full")));
     $channel->appendChild($atomSelfLink);
     $channel->appendChild($doc->createElement('webMaster', $this->_currentSession['user']['mail'] . ' (' . $this->_currentSession['user']['firstname'] . ' ' . $this->_currentSession['user']['lastname'] . ')'));
     $channel->appendChild($doc->createElement('pubDate', date('r')));
     $rss->appendChild($channel);
     # Retrieve full spots so we can show images for spots etc.
     foreach ($spotsTmp['list'] as $spotHeaders) {
         try {
             $spot = $this->_tplHelper->getFullSpot($spotHeaders['messageid'], false);
             /*
              * We supress the error by using this ugly operator simply because the library
              * sometimes gives an notice and we cannot be bothered to fix it, but it does
              * give an incorrect and unusable RSS feed
              */
             $spot = @$this->_tplHelper->formatSpot($spot);
             $title = str_replace(array('<', '>', '&'), array('&#x3C;', '&#x3E;', '&amp;'), $spot['title']);
             $poster = empty($spot['spotterid']) ? $spot['poster'] : $spot['poster'] . " (" . $spot['spotterid'] . ")";
             $guid = $doc->createElement('guid', $spot['messageid']);
             $guid->setAttribute('isPermaLink', 'false');
             $description = $doc->createElement('description');
             $descriptionCdata = $doc->createCDATASection($spot['description'] . '<br /><font color="#ca0000">Door: ' . $poster . '</font>');
             $description->appendChild($descriptionCdata);
             $item = $doc->createElement('item');
             $item->appendChild($doc->createElement('title', $title));
             $item->appendChild($guid);
             $item->appendChild($doc->createElement('link', $this->_tplHelper->makeBaseUrl("full") . '?page=getspot&amp;messageid=' . urlencode($spot['messageid']) . $this->_tplHelper->makeApiRequestString()));
             $item->appendChild($description);
             $item->appendChild($doc->createElement('author', $spot['messageid'] . ' (' . $poster . ')'));
             $item->appendChild($doc->createElement('pubDate', date('r', $spot['stamp'])));
             $item->appendChild($doc->createElement('category', SpotCategories::HeadCat2Desc($spot['category']) . ': ' . SpotCategories::Cat2ShortDesc($spot['category'], $spot['subcata'])));
             $enclosure = $doc->createElement('enclosure');
             $enclosure->setAttribute('url', html_entity_decode($this->_tplHelper->makeNzbUrl($spot)));
             $enclosure->setAttribute('length', $spot['filesize']);
             switch ($nzbhandling['prepare_action']) {
                 case 'zip':
                     $enclosure->setAttribute('type', 'application/zip');
                     break;
                 default:
                     $enclosure->setAttribute('type', 'application/x-nzb');
             }
             # switch
             $item->appendChild($enclosure);
             $channel->appendChild($item);
         } catch (Exception $x) {
             // Article not found. ignore.
         }
         # catch
     }
     # foreach
     # Output XML
     $this->sendContentTypeHeader('rss');
     echo $doc->saveXML();
 }
Example #4
0
 function convertTreeFilterToQueryParams()
 {
     if (!isset($this->_params['parsedsearch']['categoryList'])) {
         return '';
     }
     # if
     if ($this->_treeFilterCache !== null) {
         return $this->_treeFilterCache;
     }
     # if
     # Rebuild the category tree
     $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     $this->_treeFilterCache = '&amp;search[tree]=' . urlencode($svcSearchQp->compressCategorySelection($this->_params['parsedsearch']['categoryList'], $this->_params['parsedsearch']['strongNotList']));
     return $this->_treeFilterCache;
 }
Example #5
0
 public function filterToQuery($search, $sort, $currentSession, $indexFilter)
 {
     $x = new Services_Search_QueryParser($this->_db->getDbHandle());
     return $x->filterToQuery($search, $sort, $currentSession, $indexFilter);
 }
Example #6
0
 function render()
 {
     SpotTiming::start(__CLASS__ . '::' . __FUNCTION__);
     # Give an page title
     $this->_pageTitle = _("overview");
     /* 
      * Make sure the user has the appropriate permissions
      */
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_view_spots_index, '');
     /*
      * When the user wants to perform a search, it needs specific search rights
      * as well
      */
     if (!empty($this->_params['search'])) {
         $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_perform_search, '');
     }
     # if
     /*
      * We get a bunch of query parameters, so now change this to the actual
      * search query the user requested including the required sorting
      */
     $svcUserFilter = new Services_User_Filters($this->_daoFactory, $this->_settings);
     $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     $parsedSearch = $svcSearchQp->filterToQuery($this->_params['search'], array('field' => $this->_params['sortby'], 'direction' => $this->_params['sortdir']), $this->_currentSession, $svcUserFilter->getIndexFilter($this->_currentSession['user']['userid']));
     /*
      * If any specific action was chosen, we perform that as well
      */
     if (isset($parsedSearch['filterValueList'][0]['fieldname']) && $parsedSearch['filterValueList'][0]['fieldname'] == "Watch") {
         # Make sure the appropriate permissions are set
         $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_keep_own_watchlist, '');
         $svcSpotStateListDao = new Services_Actions_SpotStateList($this->_daoFactory->getSpotStateListDao());
         switch ($this->_action) {
             case 'remove':
                 $svcSpotStateListDao->removeFromWatchList($this->_params['messageid'], $this->_currentSession['user']['userid']);
                 $spotsNotifications = new SpotNotifications($this->_daoFactory, $this->_settings, $this->_currentSession);
                 $spotsNotifications->sendWatchlistHandled($this->_action, $this->_params['messageid']);
                 break;
             case 'add':
                 $svcSpotStateListDao->addToWatchList($this->_params['messageid'], $this->_currentSession['user']['userid']);
                 $spotsNotifications = new SpotNotifications($this->_daoFactory, $this->_settings, $this->_currentSession);
                 $spotsNotifications->sendWatchlistHandled($this->_action, $this->_params['messageid']);
                 break;
             default:
         }
         # switch
     }
     # if
     /*
      * Get the offset from the URL, if none given, we default to zero
      */
     $pageNr = $this->_params['pagenr'];
     /* 
      * Actually fetch the spots, we always perform
      * this action even when the watchlist is editted
      */
     $svcProvSpotList = new Services_Providers_SpotList($this->_daoFactory->getSpotDao());
     $spotsTmp = $svcProvSpotList->fetchSpotList($this->_currentSession['user']['userid'], $pageNr, $this->_currentSession['user']['prefs']['perpage'], $parsedSearch);
     /*
      * If we are on the first page, we want to pass '-1' as the previous page,
      * so the templates can deduce we are on the first page.
      *
      * If there are no more spots, make sure we don't show
      * the nextpage link
      */
     if ($spotsTmp['hasmore']) {
         $nextPage = $pageNr + 1;
     } else {
         $nextPage = -1;
     }
     # else
     $prevPage = max($pageNr - 1, -1);
     #- display stuff -#
     $this->template('spots', array('spots' => $spotsTmp['list'], 'quicklinks' => $this->_settings->get('quicklinks'), 'filters' => $svcUserFilter->getFilterList($this->_currentSession['user']['userid'], 'filter'), 'nextPage' => $nextPage, 'prevPage' => $prevPage, 'parsedsearch' => $parsedSearch, 'data' => $this->_params['data']));
     SpotTiming::stop(__CLASS__ . '::' . __FUNCTION__);
 }
 public function filtersToXml($filterList)
 {
     $svcSearchQP = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     # create the XML document
     $doc = new DOMDocument('1.0', 'utf-8');
     $doc->formatOutput = true;
     $mainElm = $doc->createElement('spotwebfilter');
     $mainElm->appendChild($doc->createElement('version', '1.0'));
     $mainElm->appendChild($doc->createElement('generator', 'SpotWeb v' . SPOTWEB_VERSION));
     $doc->appendChild($mainElm);
     $filterListElm = $doc->createElement('filters');
     foreach ($filterList as $filter) {
         $filterElm = $doc->createElement('filter');
         $filterElm->appendChild($doc->createElement('id', $filter['id']));
         $filterElm->appendChild($doc->createElement('title', $filter['title']));
         $filterElm->appendChild($doc->createElement('icon', $filter['icon']));
         $filterElm->appendChild($doc->createElement('parent', $filter['tparent']));
         $filterElm->appendChild($doc->createElement('order', $filter['torder']));
         $filterElm->appendChild($doc->createElement('enablenotify', $filter['enablenotify']));
         /* 
          * Now add the tree. We get the list of filters as a tree, but we 
          * want to keep the XML as clean as possible so we try to compress it.
          *
          * First we have to extract the tree to a list of selections, strongnots
          * and excludes
          */
         $dynaList = explode(',', $filter['tree']);
         list($categoryList, $strongNotList) = $svcSearchQP->prepareCategorySelection($dynaList);
         $treeList = explode(',', $svcSearchQP->compressCategorySelection($categoryList, $strongNotList));
         $tree = $doc->createElement('tree');
         foreach ($treeList as $treeItem) {
             if (!empty($treeItem)) {
                 # determine what type of element this is
                 $treeType = 'include';
                 if ($treeItem[0] == '~') {
                     $treeType = 'strongnot';
                     $treeItem = substr($treeItem, 1);
                 } elseif ($treeItem[1] == '!') {
                     $treeType = 'exclude';
                     $treeItem = substr($treeItem, 1);
                 }
                 # else
                 # and create the XML item
                 $treeElm = $doc->createElement('item', $treeItem);
                 $treeElm->setAttribute('type', $treeType);
                 if (!empty($treeItem)) {
                     $tree->appendChild($treeElm);
                 }
                 # if
             }
             # if
         }
         # treeItems
         $filterElm->appendChild($tree);
         /* 
          * Prepare the filtervalue list to make it usable for the XML
          */
         $tmpFilterValues = explode('&', $filter['valuelist']);
         $filterValueList = array();
         foreach ($tmpFilterValues as $filterValue) {
             $tmpFilter = explode(':', urldecode($filterValue));
             /*
              * If the filter is missing the booloper, set it to be the default
              */
             if (count($tmpFilter) == 3) {
                 // old style filter
                 $tmpFilter = array(0 => $tmpFilter[0], 1 => $tmpFilter[1], 2 => 'DEF', 3 => $tmpFilter[2]);
             }
             // if
             # and create the actual filter
             if (count($tmpFilter) >= 4) {
                 $filterValueList[] = array('fieldname' => $tmpFilter[0], 'operator' => $tmpFilter[1], 'booloper' => $tmpFilter[2], 'value' => join(":", array_slice($tmpFilter, 3)));
             }
             # if
         }
         # foreach
         /* 
          * Now add the filter items (text searches etc)
          */
         if (!empty($filterValueList)) {
             $valuesElm = $doc->createElement('values');
             foreach ($filterValueList as $filterValue) {
                 # Create the value XML item
                 $itemElm = $doc->createElement('item');
                 $itemElm->appendChild($doc->createElement('fieldname', $filterValue['fieldname']));
                 $itemElm->appendChild($doc->createElement('operator', $filterValue['operator']));
                 $itemElm->appendChild($doc->createElement('booloper', $filterValue['booloper']));
                 $itemElm->appendChild($doc->createElement('value', $filterValue['value']));
                 $valuesElm->appendChild($itemElm);
             }
             # foreach
             $filterElm->appendChild($valuesElm);
         }
         # if
         /* 
          * Add the sorting items
          */
         if (!empty($filter['sorton'])) {
             $sortElm = $doc->createElement('sort');
             $itemElm = $doc->createElement('item');
             $itemElm->appendChild($doc->createElement('fieldname', $filter['sorton']));
             $itemElm->appendChild($doc->createElement('direction', $filter['sortorder']));
             $sortElm->appendChild($itemElm);
             $filterElm->appendChild($sortElm);
         }
         # if
         $filterListElm->appendChild($filterElm);
     }
     # foreach
     $mainElm->appendChild($filterListElm);
     /*
      * Create a new result object
      */
     $result = new Dto_FormResult('success');
     $result->addData('filters', $doc->saveXML());
     return $result;
 }
Example #8
0
 function categoriesToJson()
 {
     /*
      * Don't allow the tree to be cached, it contains the current state of the
      * tree
      */
     $this->sendExpireHeaders(true);
     /* First parse the search string so we know which items to select and which not */
     $svcUserFilter = new Services_User_Filters($this->_daoFactory, $this->_settings);
     $svcSearchQp = new Services_Search_QueryParser($this->_daoFactory->getConnection());
     $parsedSearch = $svcSearchQp->filterToQuery($this->_params['search'], array(), $this->_currentSession, $svcUserFilter->getIndexFilter($this->_currentSession['user']['userid']));
     if ($this->_params['disallowstrongnot']) {
         $parsedSearch['strongNotList'] = '';
     }
     # if
     $compressedCatList = ',' . $svcSearchQp->compressCategorySelection($parsedSearch['categoryList'], $parsedSearch['strongNotList']);
     //error_log($this->_params['search']['tree']);
     //var_dump($parsedSearch);
     //var_dump($compressedCatList);
     //die();
     echo "[";
     $hcatList = array();
     $typeCatTmp = '';
     $hcatTmp = '';
     foreach (SpotCategories::$_head_categories as $hcat_key => $hcat_val) {
         # The uer can opt to only show a specific category, if so, skip all others
         if ($hcat_key != $this->_params['category'] && $this->_params['category'] != '*') {
             continue;
         }
         # if
         # If the user choose to show only one category, we dont want the category item itself
         if ($this->_params['category'] == '*') {
             $hcatTmp = '{"title": "' . $hcat_val . '", "isFolder": true, "key": "cat' . $hcat_key . '",	"children": [';
         }
         # if
         $typeCatDesc = array();
         if (isset(SpotCategories::$_categories[$hcat_key]['z'])) {
             foreach (SpotCategories::$_categories[$hcat_key]['z'] as $type_key => $type_value) {
                 if ($type_key !== 'z' && ($this->_params['subcatz'] == $type_key || $this->_params['subcatz'] == '*')) {
                     # Now determine whether we need to enable the checkbox
                     $isSelected = strpos($compressedCatList, ',cat' . $hcat_key . '_z' . $type_key . ',') !== false ? "true" : "false";
                     # Is this strongnot?
                     $isStrongNot = strpos($compressedCatList, ',~cat' . $hcat_key . '_z' . $type_key . ',') !== false ? true : false;
                     if ($isStrongNot) {
                         $isStrongNot = '"strongnot": true, "addClass": "strongnotnode", ';
                         $isSelected = 'true';
                     } else {
                         $isStrongNot = '';
                     }
                     # if
                     # If the user choose to show only one categortype, we dont want the categorytype item itself
                     if ($this->_params['subcatz'] == '*') {
                         $typeCatTmp = '{"title": "' . $type_value . '", "isFolder": true, ' . $isStrongNot . ' "select": ' . $isSelected . ', "hideCheckbox": false, "key": "cat' . $hcat_key . '_z' . $type_key . '", "unselectable": false, "children": [';
                     }
                     # if
                 }
                 # if
                 $subcatDesc = array();
                 foreach (SpotCategories::$_subcat_descriptions[$hcat_key] as $sclist_key => $sclist_desc) {
                     if ($sclist_key !== 'z' && ($this->_params['subcatz'] == $type_key || $this->_params['subcatz'] == '*')) {
                         # We inherit the strongnode from our parent
                         $isStrongNot = strpos($compressedCatList, ',~cat' . $hcat_key . '_z' . $type_key . ',') !== false ? true : false;
                         if ($isStrongNot) {
                             $isStrongNot = '"strongnot": true, "addClass": "strongnotnode", ';
                         } else {
                             $isStrongNot = '';
                         }
                         # if
                         $subcatTmp = '{"title": "' . $sclist_desc . '", "isFolder": true, ' . $isStrongNot . ' "hideCheckbox": true, "key": "cat' . $hcat_key . '_z' . $type_key . '_' . $sclist_key . '", "unselectable": false, "children": [';
                         # echo ".." . $sclist_desc . " <br>";
                         $catList = array();
                         foreach (SpotCategories::$_categories[$hcat_key][$sclist_key] as $key => $valTmp) {
                             //error_log($hcat_key . ' => ' . $sclist_key . ' ==:: ' . $key);
                             if (in_array('z' . $type_key, $valTmp[2])) {
                                 $val = $valTmp[0];
                                 if (strlen($val) != 0 && strlen($key) != 0) {
                                     # Now determine whether we need to enable the checkbox
                                     $isSelected = strpos($compressedCatList, ',cat' . $hcat_key . '_z' . $type_key . '_' . $sclist_key . $key . ',') !== false ? true : false;
                                     $parentSelected = strpos($compressedCatList, ',cat' . $hcat_key . '_z' . $type_key . ',') !== false ? true : false;
                                     $isSelected = $isSelected || $parentSelected ? 'true' : 'false';
                                     /*
                                      * Is this strongnot?
                                      */
                                     $isStrongNot = strpos($compressedCatList, ',~cat' . $hcat_key . '_z' . $type_key . ',') !== false ? true : false;
                                     if (!$isStrongNot) {
                                         $isStrongNot = strpos($compressedCatList, ',~cat' . $hcat_key . '_z' . $type_key . '_' . $sclist_key . $key . ',') !== false ? true : false;
                                     }
                                     # if
                                     if ($isStrongNot) {
                                         $isStrongNot = '"strongnot": true, "addClass": "strongnotnode", ';
                                         $isSelected = 'true';
                                     } else {
                                         $isStrongNot = '';
                                     }
                                     # if
                                     $catList[] = '{"title": "' . $val . '", "icon": false, "select": ' . $isSelected . ', ' . $isStrongNot . '"key":"' . 'cat' . $hcat_key . '_z' . $type_key . '_' . $sclist_key . $key . '"}';
                                 }
                                 # if
                             }
                             # if
                         }
                         # foreach
                         $subcatTmp .= join(",", $catList);
                         $subcatDesc[] = $subcatTmp . "]}";
                     }
                     # if
                 }
                 # foreach
                 if ($type_key !== 'z') {
                     # If the user choose to show only one categortype, we dont want the categorytype item itself
                     if ($this->_params['subcatz'] == '*') {
                         $typeCatDesc[] = $typeCatTmp . join(",", $subcatDesc) . "]}";
                     } else {
                         if (!empty($subcatDesc)) {
                             $typeCatDesc[] = join(",", array_filter($subcatDesc));
                         }
                         # if
                     }
                     # else
                 } else {
                     $typeCatDesc[] = join(",", $subcatDesc);
                 }
                 # else
             }
             # foreach
         }
         # foreach
         # If the user choose to show only one category, we dont want the category item itself
         if ($this->_params['category'] == '*') {
             $hcatList[] = $hcatTmp . join(",", $typeCatDesc) . "]}";
         } else {
             $hcatList[] = join(",", $typeCatDesc);
         }
         # if
     }
     # foreach
     echo join(",", $hcatList);
     echo "]";
 }