function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $artlib = TikiLib::lib('art'); $article = $artlib->get_article($objectId, false); $data = array('title' => $typeFactory->sortable($article['title']), 'language' => $typeFactory->identifier($article['lang'] ? $article['lang'] : 'unknown'), 'modification_date' => $typeFactory->timestamp($article['publishDate']), 'contributors' => $typeFactory->multivalue(array($article['author'])), 'description' => $typeFactory->plaintext($article['heading']), 'topic_id' => $typeFactory->identifier($article['topicId']), 'article_content' => $typeFactory->wikitext($article['body']), 'article_topline' => $typeFactory->wikitext($article['topline']), 'article_subtitle' => $typeFactory->wikitext($article['subtitle']), 'article_author' => $typeFactory->plaintext($article['authorName']), 'view_permission' => $typeFactory->identifier('tiki_p_read_article'), 'parent_object_type' => $typeFactory->identifier('topic'), 'parent_object_id' => $typeFactory->identifier($article['topicId']), 'parent_view_permission' => $typeFactory->identifier('tiki_p_read_topic')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $artlib = TikiLib::lib('art'); $article = $artlib->get_article($objectId, false); if ($topic = $artlib->get_topic($article['topicId'])) { $topic_name = $topic['name']; } else { $topic_name = ''; } $rss_relations = TikiLib::lib('relation')->get_object_ids_with_relations_from('article', $objectId, 'tiki.rss.source'); $sitetitle = ''; $siteurl = ''; if ($rss_relations) { $rssId = reset($rss_relations); $rssModule = TikiLib::lib('rss')->get_rss_module($rssId); if ($rssModule['sitetitle']) { $sitetitle = $rssModule['sitetitle']; } if ($rssModule['siteurl']) { $siteurl = $rssModule['siteurl']; } } $data = array('title' => $typeFactory->sortable($article['title']), 'language' => $typeFactory->identifier($article['lang'] ? $article['lang'] : 'unknown'), 'modification_date' => $typeFactory->timestamp($article['publishDate']), 'contributors' => $typeFactory->multivalue(array($article['author'])), 'description' => $typeFactory->plaintext($article['heading']), 'sitetitle' => $typeFactory->plaintext($sitetitle), 'siteurl' => $typeFactory->plaintext($siteurl), 'topic_id' => $typeFactory->identifier($article['topicId']), 'topic_name' => $typeFactory->plaintext($topic_name), 'article_type' => $typeFactory->identifier($article['type']), 'article_content' => $typeFactory->wikitext($article['body']), 'article_topline' => $typeFactory->wikitext($article['topline']), 'article_subtitle' => $typeFactory->wikitext($article['subtitle']), 'article_author' => $typeFactory->plaintext($article['authorName']), 'view_permission' => $article['ispublished'] == 'y' ? $typeFactory->identifier('tiki_p_read_article') : $typeFactory->identifier('tiki_p_edit_article'), 'parent_object_type' => $typeFactory->identifier('topic'), 'parent_object_id' => $typeFactory->identifier($article['topicId']), 'parent_view_permission' => $typeFactory->identifier('tiki_p_read_topic'), 'published' => $article['ispublished'] == 'y' ? $typeFactory->identifier('y') : $typeFactory->identifier('n')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $filegallib = Tikilib::lib('filegal'); $file = $filegallib->get_file_info($objectId, true, false); $data = array('title' => $typeFactory->sortable(empty($file['name']) ? $file['filename'] : $file['name']), 'language' => $typeFactory->identifier('unknown'), 'creation_date' => $typeFactory->timestamp($file['created']), 'modification_date' => $typeFactory->timestamp($file['lastModif']), 'contributors' => $typeFactory->multivalue(array_unique(array($file['author'], $file['user'], $file['lastModifUser']))), 'description' => $typeFactory->plaintext($file['description']), 'filename' => $typeFactory->identifier($file['filename']), 'filetype' => $typeFactory->sortable(preg_replace('/^([\\w-]+)\\/([\\w-]+).*$/', '$1/$2', $file['filetype'])), 'filesize' => $typeFactory->plaintext($file['filesize']), 'gallery_id' => $typeFactory->identifier($file['galleryId']), 'file_comment' => $typeFactory->plaintext($file['comment']), 'file_content' => $typeFactory->plaintext($file['search_data']), 'parent_object_type' => $typeFactory->identifier('file gallery'), 'parent_object_id' => $typeFactory->identifier($file['galleryId']), 'parent_view_permission' => $typeFactory->identifier('tiki_p_download_files')); return $data; }
function getDocumentPart($baseKey, Search_Type_Factory_Interface $typeFactory) { $items = $this->getItemIds(); $list = $this->getItemLabels($items); $listtext = implode(' ', $list); return array($baseKey => $typeFactory->multivalue($items), "{$baseKey}_text" => $typeFactory->plaintext($listtext)); }
function getDocumentPart(Search_Type_Factory_Interface $typeFactory) { $baseKey = $this->getBaseKey(); $data = $this->getFieldData(); $listtext = implode(' ', $data['value']); return array($baseKey => $typeFactory->multivalue($data['value']), "{$baseKey}_text" => $typeFactory->plaintext($listtext)); }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $lib = TikiLib::lib('comments'); $item = $lib->get_forum($objectId); $data = array('title' => $typeFactory->sortable($item['name']), 'description' => $typeFactory->plaintext($item['description']), 'language' => $typeFactory->identifier($item['forumLanguage'] ?: 'unknown'), 'forum_section' => $typeFactory->identifier($item['section']), 'searchable' => $typeFactory->identifier('n'), 'view_permission' => $typeFactory->identifier('tiki_p_forum_read')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $wikilib = TikiLib::lib('wiki'); $info = $this->tikilib->get_page_info($objectId, true, true); if (!$info) { return false; } $contributors = $wikilib->get_contributors($objectId, $info['user']); if (!in_array($info['user'], $contributors)) { $contributors[] = $info['user']; } $data = array('title' => $typeFactory->sortable($info['pageName']), 'language' => $typeFactory->identifier(empty($info['lang']) ? 'unknown' : $info['lang']), 'modification_date' => $typeFactory->timestamp($info['lastModif']), 'description' => $typeFactory->plaintext($info['description']), 'contributors' => $typeFactory->multivalue($contributors), 'wiki_content' => $typeFactory->wikitext($info['data']), 'view_permission' => $typeFactory->identifier('tiki_p_view'), 'url' => $typeFactory->identifier($wikilib->sefurl($info['pageName'])), 'hash' => $typeFactory->identifier('')); if ($this->quantifylib) { $data['wiki_uptodateness'] = $typeFactory->sortable($this->quantifylib->getCompleteness($info['page_id'])); } if ($this->flaggedrevisionlib) { $data['wiki_approval_state'] = $typeFactory->identifier('none'); } $out = $data; if ($this->flaggedrevisionlib && $this->flaggedrevisionlib->page_requires_approval($info['pageName'])) { $out = array(); // Will provide two documents: one approved and one latest $versionInfo = $this->flaggedrevisionlib->get_version_with($info['pageName'], 'moderation', 'OK'); if (!$versionInfo || $versionInfo['version'] != $info['version']) { // No approved version or approved version differs, latest content marked as such $out[] = array_merge($data, array('hash' => $typeFactory->identifier('latest'), 'title' => $typeFactory->sortable(tr('%0 (latest)', $info['pageName'])), 'view_permission' => $typeFactory->identifier('tiki_p_wiki_view_latest'), 'wiki_approval_state' => $typeFactory->identifier('pending'), 'url' => $typeFactory->identifier(str_replace('&', '&', $wikilib->sefurl($info['pageName'], true)) . 'latest'))); } if ($versionInfo) { // Approved version not latest, include approved version in index // Also applies when versions are equal, data would be the same $out[] = array_merge($data, array('wiki_content' => $typeFactory->wikitext($versionInfo['data']), 'wiki_approval_state' => $typeFactory->identifier('approved'))); } } return $out; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { global $prefs; $commentslib = TikiLib::lib('comments'); $commentslib->extras_enabled(false); $comment = $commentslib->get_comment($objectId); $root_thread_id = $commentslib->find_root($comment['parentId']); if ($comment['parentId']) { $root = $commentslib->get_comment($root_thread_id); if (!$comment['title']) { $comment['title'] = $root['title']; } $root_author = array($root['userName']); } else { $root_author = array(); } $lastModification = $comment['commentDate']; $content = $comment['data']; $snippet = TikiLib::lib('tiki')->get_snippet($content); $author = array($comment['userName']); $thread = $commentslib->get_comments($comment['objectType'] . ':' . $comment['object'], $objectId, 0, 0); $forum_info = $commentslib->get_forum($comment['object']); $forum_language = $forum_info['forumLanguage'] ? $forum_info['forumLanguage'] : 'unknown'; if ($prefs['unified_forum_deepindexing'] == 'y') { foreach ($thread['data'] as $reply) { $content .= "\n{$reply['data']}"; $lastModification = max($lastModification, $reply['commentDate']); $author[] = $comment['userName']; } } $commentslib->extras_enabled(true); $data = array('title' => $typeFactory->sortable($comment['title']), 'language' => $typeFactory->identifier($forum_language), 'modification_date' => $typeFactory->timestamp($lastModification), 'contributors' => $typeFactory->multivalue(array_unique($author)), 'forum_id' => $typeFactory->identifier($comment['object']), 'forum_section' => $typeFactory->identifier($forum_info['section']), 'post_content' => $typeFactory->wikitext($content), 'post_snippet' => $typeFactory->plaintext($snippet), 'parent_thread_id' => $typeFactory->identifier($comment['parentId']), 'parent_object_type' => $typeFactory->identifier($comment['objectType']), 'parent_object_id' => $typeFactory->identifier($comment['object']), 'parent_view_permission' => $typeFactory->identifier('tiki_p_forum_read'), 'parent_contributors' => $typeFactory->multivalue(array_unique($root_author)), 'root_thread_id' => $typeFactory->identifier($root_thread_id)); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $lib = TikiLib::lib('filegal'); $item = $lib->get_file_gallery_info($objectId); $data = array('title' => $typeFactory->sortable($item['name']), 'description' => $typeFactory->plaintext($item['description']), 'language' => $typeFactory->identifier('unknown'), 'gallery_id' => $typeFactory->identifier($item['parentId']), 'searchable' => $typeFactory->identifier('n'), 'view_permission' => $typeFactory->identifier('tiki_p_view_file_gallery')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $lib = TikiLib::lib('categ'); $item = $lib->get_category($objectId); $data = array('title' => $typeFactory->sortable($item['name']), 'description' => $typeFactory->plaintext($item['description']), 'searchable' => $typeFactory->identifier('n'), 'view_permission' => $typeFactory->identifier('tiki_p_view_category')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $lib = TikiLib::lib('trk'); $tracker = $lib->get_tracker($objectId); if (!$tracker) { return false; } $data = array('title' => $typeFactory->sortable($tracker['name']), 'modification_date' => $typeFactory->timestamp($tracker['lastModif']), 'creation_date' => $typeFactory->timestamp($tracker['created']), 'description' => $typeFactory->plaintext($tracker['description']), 'searchable' => $typeFactory->identifier('n'), 'view_permission' => $typeFactory->identifier('tiki_p_view_trackers')); return $data; }
function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array()) { $tags = $this->freetaglib->get_tags_on_object($objectId, $objectType); $textual = array(); $ids = array(); foreach ($tags['data'] as $entry) { $textual[] = $entry['tag']; $ids[] = $entry['tagId']; } return array('freetags' => $typeFactory->multivalue($ids), 'freetags_text' => $typeFactory->plaintext(implode(' ', $textual))); }
function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array()) { $data = ''; if ($objectType == 'forum post') { $forumId = $this->commentslib->get_comment_forum_id($objectId); $comment_count = $this->commentslib->count_comments_threads("forum:{$forumId}", $objectId); } else { $comment_count = $this->commentslib->count_comments("{$objectType}:{$objectId}"); $data = implode(' ', $this->table->fetchColumn('data', array('object' => $objectId, 'objectType' => $objectType))); } return array('comment_count' => $typeFactory->numeric($comment_count), 'comment_data' => $typeFactory->plaintext($data)); }
/** * Return data array of last post for thread * * @param $threadId * @param Search_Type_Factory_Interface $typeFactory * @return array * @throws Exception */ function getForumLastPostData($threadId, Search_Type_Factory_Interface $typeFactory) { $commentslib = TikiLib::lib('comments'); $commentslib->extras_enabled(false); $comment = $commentslib->get_lastPost($threadId); $lastModification = isset($comment['commentDate']) ? $comment['commentDate'] : 0; $content = isset($comment['data']) ? $comment['data'] : ''; $snippet = TikiLib::lib('tiki')->get_snippet($content); $author = array(isset($comment['userName']) ? $comment['userName'] : ''); $commentslib->extras_enabled(true); $data = array('lastpost_title' => $typeFactory->sortable(isset($comment['title']) ? $comment['title'] : ''), 'lastpost_modification_date' => $typeFactory->timestamp($lastModification), 'lastpost_contributors' => $typeFactory->multivalue(array_unique($author)), 'lastpost_post_content' => $typeFactory->wikitext($content), 'lastpost_post_snippet' => $typeFactory->plaintext($snippet), 'lastpost_hits' => $typeFactory->numeric(isset($comment['hits']) ? $comment['hits'] : 0), 'lastpost_thread_id' => $typeFactory->identifier(isset($comment['thread_id']) ? $comment['thread_id'] : 0)); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $lib = TikiLib::lib('trk'); $field = $lib->get_tracker_field($objectId); if (!$field) { return false; } $trackername = tr('unknown'); if ($definition = Tracker_Definition::get($field['trackerId'])) { $trackername = $definition->getConfiguration('name'); } $data = array('title' => $typeFactory->sortable($field['name']), 'description' => $typeFactory->plaintext($field['description']), 'tracker_id' => $typeFactory->identifier($field['trackerId']), 'tracker_name' => $typeFactory->sortable($trackername), 'searchable' => $typeFactory->identifier('n'), 'view_permission' => $typeFactory->identifier('tiki_p_view_trackers')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $sheetlib = TikiLib::lib('sheet'); $info = $sheetlib->get_sheet_info($objectId); $values = $this->db->table('tiki_sheet_values'); $contributors = $values->fetchColumn($values->expr('DISTINCT `user`'), array('sheetId' => $objectId)); $lastModif = $values->fetchOne($values->max('begin'), array('sheetId' => $objectId)); $loader = new TikiSheetDatabaseHandler($objectId); $writer = new TikiSheetCSVHandler('php://output'); $grid = new TikiSheet(); $grid->import($loader); $grid->export($writer); $text = $writer->output; $data = array('title' => $typeFactory->sortable($info['title']), 'description' => $typeFactory->sortable($info['description']), 'modification_date' => $typeFactory->timestamp($lastModif), 'contributors' => $typeFactory->multivalue($contributors), 'sheet_content' => $typeFactory->plaintext($text), 'view_permission' => $typeFactory->identifier('tiki_p_view_sheet')); return $data; }
function getDocument($objectId, Search_Type_Factory_Interface $typeFactory) { $row = $this->db->table('users_groups')->fetchRow(['groupDesc'], array('groupName' => $objectId)); if (!$row) { return false; } $api = new TikiAddons_Api_Group(); $groupName = $objectId; $addongroup = false; $addonpendinggroup = false; $addonleadergroup = false; if ($ret = $api->getOrganicGroupName($objectId)) { $groupName = $ret; $addongroup = $api->isOrganicGroup($objectId); if ($addongroup == true && $api->getOrganicGroupPendingToken($objectId) == $objectId) { $addonpendinggroup = true; } if ($addongroup == true && $api->getOrganicGroupLeaderToken($objectId) == $objectId) { $addonleadergroup = true; } } $data = array('title' => $typeFactory->sortable($groupName), 'description' => $typeFactory->plaintext($row['groupDesc']), 'searchable' => $typeFactory->identifier('n'), 'view_permission' => $typeFactory->identifier('tiki_p_group_view'), 'addongroup' => $addongroup ? $typeFactory->identifier('y') : $typeFactory->identifier('n'), 'addonleadergroup' => $addonleadergroup ? $typeFactory->identifier('y') : $typeFactory->identifier('n'), 'addonpendinggroup' => $addonpendinggroup ? $typeFactory->identifier('y') : $typeFactory->identifier('n')); return $data; }
/** * This updates and recategorise the item when being reindexed, which allows you to recategorise all a tracker's items * if the parent tracker's categories have been changed (or following an upgrade for instance) * * Category fields don't actually need to be indexed as category objects are indexed separately. * * @param Search_Type_Factory_Interface $typeFactory * @return array * @throws Exception */ function getDocumentPart(Search_Type_Factory_Interface $typeFactory) { $value = array_filter(explode(',', $this->getValue())); if ($this->getOption('recategorize') === 'index') { // if using inherit this will get the tracker's categories too even if not saved $newValue = $this->getFieldData(); $newValue = $newValue['selected_categories']; $diff = array_diff($newValue, $value); if ($diff) { // unsaved categs found $categlib = TikiLib::lib('categ'); $itemId = $this->getItemId(); // update value TikiLib::lib('trk')->modify_field($itemId, $this->getConfiguration('fieldId'), implode(',', $newValue)); // check current categs $categories = $categlib->get_object_categories('trackeritem', $itemId); $missingCategories = array_diff($diff, $categories); if ($missingCategories) { // temporarily prevent incremental index update which happens in categlib causing an infinite loop global $prefs; $incPref = $prefs['unified_incremental_update']; $prefs['unified_incremental_update'] = 'n'; $categlib->categorize_any('trackeritem', $itemId, $missingCategories); $prefs['unified_incremental_update'] = $incPref; } } } // Indexing the value of the field anyway as it could be different from the 'categories' field if // you need to be more specific for filtering under a certain parent only. // // Warning to upgraders: older Tikis had no getDocumentPart so the comma-separated string was indexed // in the past. It now indexes an array. Use {$baseKey}_text instead for a space delimited string. $baseKey = $this->getBaseKey(); return array($baseKey => $typeFactory->multivalue($value), "{$baseKey}_text" => $typeFactory->plaintext(implode(' ', $value))); }
function getDocumentPart(Search_Type_Factory_Interface $typeFactory) { $baseKey = $this->getBaseKey(); $value = json_decode($this->getValue(), true); $value = isset($value['result']) ? $value['result'] : []; return array($baseKey => $typeFactory->multivalue(array_filter($value, 'is_string')), "{$baseKey}_text" => $typeFactory->plaintext(strip_tags(implode(' ', array_filter($value, 'is_string'))))); }
function getDocumentPart(Search_Type_Factory_Interface $typeFactory) { $baseKey = $this->getBaseKey(); return array($baseKey => $typeFactory->plaintext($this->renderInnerOutput())); }
function getDocumentPart(Search_Type_Factory_Interface $typeFactory) { $value = $this->getValue(); $baseKey = $this->getBaseKey(); return array($baseKey => $typeFactory->plaintext($value)); }
function getDocumentPart($baseKey, Search_Type_Factory_Interface $typeFactory) { $data = $this->getLinkData(array(), 0); $item = $data['value']; $dlist = $data['listdisplay']; $list = $data['list']; if (!empty($dlist)) { $label = isset($dlist[$item]) ? $dlist[$item] : ''; } else { $label = isset($list[$item]) ? $list[$item] : ''; } $out = array($baseKey => $typeFactory->sortable($item), "{$baseKey}_text" => $typeFactory->plaintext($label)); $indexRemote = array_filter(explode('|', $this->getOption('indexRemote'))); if (count($indexRemote) && is_numeric($item)) { $utilities = new Services_Tracker_Utilities(); $trackerId = $this->getOption('trackerId'); $itemData = $utilities->getItem($trackerId, $item); $definition = Tracker_Definition::get($trackerId); foreach ($indexRemote as $fieldId) { $field = $definition->getField($fieldId); $permName = $field['permName']; $out["{$baseKey}_{$permName}"] = $typeFactory->plaintext($itemData['fields'][$permName]); } } return $out; }