1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8class Search_ContentSource_CategorySource implements Search_ContentSource_Interface 9{ 10 private $db; 11 12 function __construct() 13 { 14 $this->db = TikiDb::get(); 15 } 16 17 function getDocuments() 18 { 19 return $this->db->table('tiki_categories')->fetchColumn('categId', []); 20 } 21 22 function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) 23 { 24 $lib = TikiLib::lib('categ'); 25 26 $item = $lib->get_category($objectId); 27 28 if (! $item) { 29 return false; 30 } 31 32 $data = [ 33 'title' => $typeFactory->sortable($item['name']), 34 'description' => $typeFactory->plaintext($item['description']), 35 'path' => $typeFactory->sortable($item['categpath']), 36 37 'searchable' => $typeFactory->identifier('n'), 38 39 'view_permission' => $typeFactory->identifier('tiki_p_view_category'), 40 ]; 41 42 return $data; 43 } 44 45 function getProvidedFields() 46 { 47 return [ 48 'title', 49 'description', 50 'path', 51 52 'searchable', 53 54 'view_permission', 55 ]; 56 } 57 58 function getGlobalFields() 59 { 60 return [ 61 'title' => true, 62 'description' => true, 63 ]; 64 } 65} 66