Esempio n. 1
0
 function getDocument($objectId, Search_Type_Factory_Interface $typeFactory)
 {
     /*
     	If you wonder why this method uses straight SQL and not trklib, it's because
     	trklib performs no meaningful work when extracting the data and strips all
     	required semantics.
     */
     $data = array('title' => $typeFactory->sortable(tr('Unknown')), 'language' => $typeFactory->identifier('unknown'));
     $item = $this->trklib->get_tracker_item($objectId);
     if (empty($item)) {
         return false;
     }
     $itemObject = Tracker_Item::fromInfo($item);
     if (empty($itemObject) || !$itemObject->getDefinition()) {
         // ignore corrupted items, e.g. where trackerId == 0
         return false;
     }
     $permNeeded = $itemObject->getViewPermission();
     $specialUsers = $itemObject->getSpecialPermissionUsers($objectId, 'Modify');
     $definition = Tracker_Definition::get($item['trackerId']);
     if (!$definition) {
         return $data;
     }
     foreach (self::getIndexableHandlers($definition, $item) as $handler) {
         $data = array_merge($data, $handler->getDocumentPart($typeFactory));
     }
     $ownerGroup = $itemObject->getOwnerGroup();
     $data = array_merge($data, array('title' => $typeFactory->sortable($this->trklib->get_isMain_value($item['trackerId'], $objectId)), 'modification_date' => $typeFactory->timestamp($item['lastModif']), 'creation_date' => $typeFactory->timestamp($item['created']), 'contributors' => $typeFactory->multivalue(array_unique(array($item['createdBy'], $item['lastModifBy']))), 'tracker_status' => $typeFactory->identifier($item['status']), 'tracker_id' => $typeFactory->identifier($item['trackerId']), 'view_permission' => $typeFactory->identifier($permNeeded), '_extra_users' => $specialUsers, '_permission_accessor' => $itemObject->getPerms(), '_extra_groups' => $ownerGroup ? array($ownerGroup) : null));
     return $data;
 }
Esempio n. 2
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     if (isset($data['relations']) || isset($data['relation_types'])) {
         return array();
     }
     $relations = array();
     $types = array();
     $from = $this->relationlib->get_relations_from($objectType, $objectId);
     foreach ($from as $rel) {
         $relations[] = Search_Query_Relation::token($rel['relation'], $rel['type'], $rel['itemId']);
         $types[] = $rel['relation'];
     }
     $to = $this->relationlib->get_relations_to($objectType, $objectId);
     foreach ($to as $rel) {
         $relations[] = Search_Query_Relation::token($rel['relation'] . '.invert', $rel['type'], $rel['itemId']);
         $types[] = $rel['relation'] . '.invert';
     }
     //take the type array and get a count of each indiv. type
     $type_count = array_count_values($types);
     $rel_count = array();
     foreach ($type_count as $key => $val) {
         //instead of returning an assoc. array, format to "relation:count" format for input in index
         $rel_count[] = $key . ":" . $val;
     }
     return array('relations' => $typeFactory->multivalue($relations), 'relation_types' => $typeFactory->multivalue(array_unique($types)), 'relation_count' => $typeFactory->multivalue($rel_count));
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 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)
 {
     /*
     	If you wonder why this method uses straight SQL and not trklib, it's because
     	trklib performs no meaningful work when extracting the data and strips all
     	required semantics.
     */
     $data = array('title' => $typeFactory->sortable(tr('Unknown')), 'language' => $typeFactory->identifier('unknown'));
     $item = $this->trklib->get_tracker_item($objectId);
     if ($item['status'] == 'c') {
         $permNeeded = 'tiki_p_view_trackers_closed';
     } elseif ($item['status'] == 'p') {
         $permNeeded = 'tiki_p_view_trackers_pending';
     } else {
         $permNeeded = 'tiki_p_view_trackers';
     }
     $definition = Tracker_Definition::get($item['trackerId']);
     if (!$definition) {
         return $data;
     }
     foreach ($this->getIndexableHandlers($definition, $item) as $baseKey => $handler) {
         $data = array_merge($data, $handler->getDocumentPart($baseKey, $typeFactory));
     }
     $data = array_merge($data, array('title' => $typeFactory->sortable($this->trklib->get_isMain_value($item['trackerId'], $objectId)), 'modification_date' => $typeFactory->timestamp($item['lastModif']), 'contributors' => $typeFactory->multivalue(array_unique(array($item['createdBy'], $item['lastModifBy']))), 'tracker_status' => $typeFactory->identifier($item['status']), 'tracker_id' => $typeFactory->identifier($item['trackerId']), 'parent_object_type' => $typeFactory->identifier('tracker'), 'parent_object_id' => $typeFactory->identifier($item['trackerId']), 'parent_view_permission' => $typeFactory->identifier($permNeeded)));
     return $data;
 }
Esempio n. 7
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     $geolib = TikiLib::lib('geo');
     $coordinates = $geolib->get_coordinates_string($objectType, $objectId);
     $alreadyLocated = isset($data['geo_located']) && $date['geo_located'] == 'y';
     return array('geo_located' => $typeFactory->identifier($coordinates || $alreadyLocated ? 'y' : 'n'), 'geo_location' => $typeFactory->identifier($coordinates));
 }
Esempio n. 8
0
 function getDocumentPart(Search_Type_Factory_Interface $typeFactory)
 {
     $item = $this->getValue();
     $baseKey = $this->getBaseKey();
     $out = array($baseKey => $typeFactory->numeric($item));
     return $out;
 }
Esempio n. 9
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     if (isset($data['allowed_groups'])) {
         return array();
     }
     $groups = array();
     if (isset($data['view_permission'])) {
         $viewPermission = is_object($data['view_permission']) ? $data['view_permission']->getValue() : $data['view_permission'];
         if (isset($data['_permission_accessor'])) {
             $accessor = $data['_permission_accessor'];
         } else {
             $accessor = $this->perms->getAccessor(array('type' => $objectType, 'object' => $objectId));
         }
         $groups = array_merge($groups, $this->getAllowedGroups($accessor, $viewPermission));
     }
     if (isset($data['parent_view_permission'], $data['parent_object_id'], $data['parent_object_type'])) {
         $viewPermission = is_object($data['parent_view_permission']) ? $data['parent_view_permission']->getValue() : $data['parent_view_permission'];
         $accessor = $this->perms->getAccessor(array('type' => $data['parent_object_type']->getValue(), 'object' => $data['parent_object_id']->getValue()));
         $groups = array_merge($groups, $this->getAllowedGroups($accessor, $viewPermission));
     }
     // Used for comments - must see the parent view permission in addition to a global permission to view comments
     if (isset($data['global_view_permission'])) {
         $globalPermission = $data['global_view_permission'];
         $globalPermission = $globalPermission->getValue();
         $groups = $this->getGroupExpansion($groups);
         $groups = $this->filterWithGlobalPermission($groups, $globalPermission);
     }
     if (!empty($data['_extra_groups'])) {
         $groups = array_merge($groups, $data['_extra_groups']);
     }
     return array('allowed_groups' => $typeFactory->multivalue(array_unique($groups)));
 }
Esempio n. 10
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     if (isset($data['categories']) || isset($data['deep_categories']) || $objectType === 'category') {
         return array();
     }
     $categories = $this->categlib->get_object_categories($objectType, $objectId, -1, false);
     // For forum posts, and
     if (isset($data['parent_object_id'], $data['parent_object_type'])) {
         $objectType = is_object($data['parent_object_type']) ? $data['parent_object_type']->getValue() : $data['parent_object_type'];
         $objectId = is_object($data['parent_object_id']) ? $data['parent_object_id']->getValue() : $data['parent_object_id'];
         $parentCategories = $this->categlib->get_object_categories($objectType, $objectId, -1, false);
         $categories = array_unique(array_merge($categories, $parentCategories));
     }
     if (empty($categories)) {
         $categories[] = 'orphan';
         $deepcategories = $categories;
     } else {
         $deepcategories = $this->getWithParent($categories);
     }
     $out = array('categories' => $typeFactory->multivalue($categories), 'deep_categories' => $typeFactory->multivalue($deepcategories));
     foreach ($this->categlib->getCustomFacets() as $rootId) {
         $filtered = array_filter($categories, function ($category) use($rootId) {
             return $this->categlib->get_category_parent($category) == $rootId;
         });
         $deepfiltered = array_filter($deepcategories, function ($category) use($rootId) {
             return $category != $rootId && $this->hasParent($category, $rootId);
         });
         $out["categories_under_{$rootId}"] = $typeFactory->multivalue($filtered);
         $out["deep_categories_under_{$rootId}"] = $typeFactory->multivalue($deepfiltered);
     }
     return $out;
 }
Esempio n. 11
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     if (isset($data['url'])) {
         return false;
     }
     $url = smarty_modifier_sefurl($objectId, $objectType);
     return array('url' => $typeFactory->identifier($url));
 }
Esempio n. 12
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     // Unless specified by content source explicitly, everything is searchable
     if (isset($data['searchable'])) {
         return [];
     }
     return array('searchable' => $typeFactory->identifier('y'));
 }
Esempio n. 13
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     if ($objectType === 'wiki page') {
         $objectType = 'wiki';
     }
     $visits = $this->statslib->object_hits($objectId, $objectType);
     return array('visits' => $typeFactory->sortable($visits));
 }
Esempio n. 14
0
 function getDocumentPart(Search_Type_Factory_Interface $typeFactory)
 {
     $possibilities = $this->getPossibilities();
     $value = $this->getValue();
     $label = isset($possibilities[$value]) ? $possibilities[$value] : '';
     $baseKey = $this->getBaseKey();
     return array($baseKey => $typeFactory->identifier($value), "{$baseKey}_text" => $typeFactory->sortable($label));
 }
Esempio n. 15
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     $ratings = $this->ratinglib->obtain_ratings($objectType, $objectId, $this->recalculate);
     $data = array();
     foreach ($ratings as $id => $value) {
         $data["adv_rating_{$id}"] = $typeFactory->sortable($value);
     }
     return $data;
 }
Esempio n. 16
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     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}");
     }
     return array('comment_count' => $typeFactory->sortable($comment_count));
 }
Esempio n. 17
0
 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']), 'creation_date' => $typeFactory->timestamp($item['created']), 'modification_date' => $typeFactory->timestamp($item['lastModif']), '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;
 }
Esempio n. 18
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     $title = empty($data['title']) ? null : $data['title']->getValue();
     $title = empty($title) ? '0' : $title;
     $substr = $this->substr;
     $strtoupper = $this->strtoupper;
     $first = $substr($title, 0, 1);
     $first = TikiLib::take_away_accent($first);
     $letter = $strtoupper($first);
     return array('title_initial' => $typeFactory->identifier($letter));
 }
Esempio n. 19
0
 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)));
 }
Esempio n. 20
0
 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));
 }
Esempio n. 21
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     $relations = array();
     $from = $this->relationlib->get_relations_from($objectType, $objectId);
     foreach ($from as $rel) {
         $relations[] = Search_Query_Relation::token($rel['relation'], $rel['type'], $rel['itemId']);
     }
     $to = $this->relationlib->get_relations_to($objectType, $objectId);
     foreach ($to as $rel) {
         $relations[] = Search_Query_Relation::token($rel['relation'] . '.invert', $rel['type'], $rel['itemId']);
     }
     return array('relations' => $typeFactory->multivalue($relations));
 }
Esempio n. 22
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     $groups = array();
     $followers = array();
     foreach ($this->getUsers($data, $objectType, $objectId) as $user) {
         $groups = array_merge($groups, $this->userlib->get_user_groups_inclusion($user));
         $userfollowers = $this->getFollowers($user);
         if (is_array($userfollowers)) {
             $followers = array_merge($followers, $userfollowers);
         }
     }
     unset($groups['Anonymous'], $groups['Registered']);
     return array('user_groups' => $typeFactory->multivalue(array_keys($groups)), 'user_followers' => $typeFactory->multivalue(array_unique($followers)));
 }
Esempio n. 23
0
 function getDocument($objectId, Search_Type_Factory_Interface $typeFactory)
 {
     $lib = TikiLib::lib('comments');
     $item = $lib->get_forum($objectId);
     $data = array('title' => $typeFactory->sortable($item['name']), 'creation_date' => $typeFactory->timestamp($item['created']), '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;
 }
Esempio n. 24
0
 function getDocumentPart(Search_Type_Factory_Interface $typeFactory)
 {
     $value = $this->getValue();
     if ('index' == $this->getOption('recalculate')) {
         $runner = $this->getFormulaRunner();
         $data = [];
         foreach ($runner->inspect() as $fieldName) {
             $data[$fieldName] = $this->getItemField($fieldName);
         }
         $runner->setVariables($data);
         $value = $runner->evaluate();
     }
     $baseKey = $this->getBaseKey();
     return array($baseKey => $typeFactory->sortable($value));
 }
Esempio n. 25
0
 function getData($objectType, $objectId, Search_Type_Factory_Interface $typeFactory, array $data = array())
 {
     $categories = $this->categlib->get_object_categories($objectType, $objectId, -1, false);
     // For forum posts, and
     if (isset($data['parent_object_id'], $data['parent_object_type'])) {
         $objectType = is_object($data['parent_object_type']) ? $data['parent_object_type']->getValue() : $data['parent_object_type'];
         $objectId = is_object($data['parent_object_id']) ? $data['parent_object_id']->getValue() : $data['parent_object_id'];
         $parentCategories = $this->categlib->get_object_categories($objectType, $objectId, -1, false);
         $categories = array_unique(array_merge($categories, $parentCategories));
     }
     if (empty($categories)) {
         $categories[] = 'orphan';
         $deepcategories = $categories;
     } else {
         $deepcategories = $this->getWithParent($categories);
     }
     return array('categories' => $typeFactory->multivalue($categories), 'deep_categories' => $typeFactory->multivalue($deepcategories));
 }
Esempio n. 26
0
 /**
  * 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;
 }
Esempio n. 27
0
 function getDocument($objectId, Search_Type_Factory_Interface $typeFactory)
 {
     global $prefs;
     $commentslib = TikiLib::lib('comments');
     $comment = $commentslib->get_comment($objectId);
     $lastModification = $comment['commentDate'];
     $content = $comment['data'];
     $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'];
         }
     }
     $data = array('title' => $typeFactory->sortable($comment['title']), 'language' => $typeFactory->identifier($forum_language), 'modification_date' => $typeFactory->timestamp($lastModification), 'contributors' => $typeFactory->multivalue(array_unique($author)), 'post_content' => $typeFactory->wikitext($content), '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'));
     return $data;
 }
Esempio n. 28
0
 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;
 }
Esempio n. 29
0
 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;
 }
Esempio n. 30
0
 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;
 }