diff --git a/mod/elgg_solr/lib/functions.php b/mod/elgg_solr/lib/functions.php index b80a363a40..e43a74b138 100644 --- a/mod/elgg_solr/lib/functions.php +++ b/mod/elgg_solr/lib/functions.php @@ -514,10 +514,6 @@ function elgg_solr_get_default_fq($params) { $fq['access'] = $access_query; } - if (!access_get_show_hidden_status()) { - $fq['enabled'] = 'enabled:"yes"'; - } - return $fq; } diff --git a/mod/elgg_solr/lib/hooks.php b/mod/elgg_solr/lib/hooks.php index 201c06a977..927ec3d714 100644 --- a/mod/elgg_solr/lib/hooks.php +++ b/mod/elgg_solr/lib/hooks.php @@ -11,10 +11,12 @@ */ function elgg_solr_file_search($hook, $type, $value, $params) { + $language = get_language(); $select = array( 'start' => $params['offset'], 'rows' => $params['limit'] ? $params['limit'] : 10, - 'fields' => array('id','title','description', 'score'), + 'querydefaultfield' => "text_{$language}", + 'query' => $params['query'], ); if ($params['select'] && is_array($params['select'])) { @@ -28,35 +30,12 @@ function elgg_solr_file_search($hook, $type, $value, $params) { $query = $client->createSelect($select); $default_sorts = array( - 'score' => 'desc', - 'time_created' => 'desc' + 'date_created' => 'desc' ); $sorts = $params['sorts'] ? $params['sorts'] : $default_sorts; $query->addSorts($sorts); - - $title_boost = elgg_solr_get_title_boost(); - $description_boost = elgg_solr_get_description_boost(); - - // get the dismax component and set a boost query - $dismax = $query->getEDisMax(); - $qf = "title^{$title_boost} description^{$description_boost} attr_content^{$description_boost}"; - if ($params['qf']) { - $qf = $params['qf']; - } - $dismax->setQueryFields($qf); - $dismax->setQueryAlternative('*:*'); - - - $boostQuery = elgg_solr_get_boost_query(); - if ($boostQuery) { - $dismax->setBoostQuery($boostQuery); - } - - // this query is now a dismax query - $query->setQuery($params['query']); - - + $params['fq']['type'] = 'type:object'; $params['fq']['subtype'] = 'subtype:file'; @@ -76,7 +55,7 @@ function elgg_solr_file_search($hook, $type, $value, $params) { // get highlighting component and apply settings $hl = $query->getHighlighting(); - $hlfields = array('title', 'attr_content', 'description'); + $hlfields = array("text_{$language}"); if ($params['hlfields']) { $hlfields = $params['hlfields']; } @@ -118,11 +97,11 @@ function elgg_solr_file_search($hook, $type, $value, $params) { $purifier = new HTMLPurifier($config); foreach ($resultset as $document) { - $search_results[$document->id] = array(); + $search_results[$document->guid] = array(); $snippet = ''; // highlighting results can be fetched by document id (the field defined as uniquekey in this schema) - $highlightedDoc = $highlighting->getResult($document->id); + $highlightedDoc = $highlighting->getResult($document->guid); if($highlightedDoc){ foreach($highlightedDoc as $field => $highlight) { @@ -139,13 +118,12 @@ function elgg_solr_file_search($hook, $type, $value, $params) { $snippet = $purifier->purify($snippet); } - $search_results[$document->id][$field] = $snippet; + $search_results[$document->guid][$field] = $snippet; } } - $search_results[$document->id]['score'] = $document->score; // normalize description with attr_content - $search_results[$document->id]['description'] = trim($search_results[$document->id]['description'] . ' ' . $search_results[$document->id]['attr_content']); + $search_results[$document->guid]["description_{$language}"] = trim($search_results[$document->guid]["description_{$language}"]); } // get the entities in a single query @@ -159,38 +137,28 @@ function elgg_solr_file_search($hook, $type, $value, $params) { )); } - $show_score = elgg_get_plugin_setting('show_score', 'elgg_solr'); foreach ($search_results as $guid => $matches) { foreach ($entities_unsorted as $e) { if ($e->guid == $guid) { $desc_suffix = ''; - if ($show_score == 'yes' && elgg_is_admin_logged_in()) { - $desc_suffix .= elgg_view('output/longtext', array( - 'value' => elgg_echo('elgg_solr:relevancy', array($matches['score'])), - 'class' => 'elgg-subtext' - )); - } - - - if ($matches['title']) { - $e->setVolatileData('search_matched_title', $matches['title']); + + if ($matches["title__{$language}"]) { + $e->setVolatileData('search_matched_title', $matches["title_{$language}"]); } else { - $e->setVolatileData('search_matched_title', $e->title); + $e->setVolatileData('search_matched_title', gc_explode_translation($e->title, $language)); } - if ($matches['description']) { - $desc = $matches['description']; + if ($matches["description_{$language}"]) { + $desc = $matches["description_{$language}"]; } else { - $desc = elgg_get_excerpt($e->description, 100); + $desc = elgg_get_excerpt(gc_explode_translation($e->description, $language), 100); } - - - unset($matches['title']); - unset($matches['description']); - unset($matches['score']); + + unset($matches["title_{$language}"]); + unset($matches["description_{$language}"]); $desc .= implode('...', $matches); $e->setVolatileData('search_matched_description', $desc . $desc_suffix); @@ -207,14 +175,14 @@ function elgg_solr_file_search($hook, $type, $value, $params) { } - - function elgg_solr_object_search($hook, $type, $return, $params) { + $language = get_language(); $select = array( 'start' => $params['offset'], 'rows' => $params['limit'] ? $params['limit'] : 10, - 'fields' => array('id','title','description','score') + 'query' => $params['query'], + 'querydefaultfield' => "text_{$language}" ); if ($params['select'] && is_array($params['select'])) { @@ -227,29 +195,11 @@ function elgg_solr_object_search($hook, $type, $return, $params) { // get an update query instance $query = $client->createSelect($select); - $title_boost = elgg_solr_get_title_boost(); - $description_boost = elgg_solr_get_description_boost(); - - // get the dismax component and set a boost query - $dismax = $query->getEDisMax(); - $qf = "title^{$title_boost} description^{$description_boost}"; - if ($params['qf']) { - $qf = $params['qf']; - } - $dismax->setQueryFields($qf); - $dismax->setQueryAlternative('*:*'); - - $boostQuery = elgg_solr_get_boost_query(); - if ($boostQuery) { - $dismax->setBoostQuery($boostQuery); - } - // this query is now a dismax query $query->setQuery($params['query']); - + $default_sorts = array( - 'score' => 'desc', - 'time_created' => 'desc' + 'date_created' => 'desc' ); $sorts = $params['sorts'] ? $params['sorts'] : $default_sorts; @@ -274,7 +224,7 @@ function elgg_solr_object_search($hook, $type, $return, $params) { // get highlighting component and apply settings $hl = $query->getHighlighting(); - $hlfields = array('title', 'description'); + $hlfields = array("text_{$language}"); if ($params['hlfields']) { $hlfields = $params['hlfields']; } @@ -315,11 +265,11 @@ function elgg_solr_object_search($hook, $type, $return, $params) { $search_results = array(); foreach ($resultset as $document) { - $search_results[$document->id] = array(); + $search_results[$document->guid] = array(); $snippet = ''; // highlighting results can be fetched by document id (the field defined as uniquekey in this schema) - $highlightedDoc = $highlighting->getResult($document->id); + $highlightedDoc = $highlighting->getResult($document->guid); if($highlightedDoc){ foreach($highlightedDoc as $field => $highlight) { @@ -336,11 +286,9 @@ function elgg_solr_object_search($hook, $type, $return, $params) { $snippet = $purifier->purify($snippet); } - $search_results[$document->id][$field] = $snippet; + $search_results[$document->guid][$field] = $snippet; } } - - $search_results[$document->id]['score'] = $document->score; } // get the entities @@ -353,36 +301,28 @@ function elgg_solr_object_search($hook, $type, $return, $params) { )); } - $show_score = elgg_get_plugin_setting('show_score', 'elgg_solr'); foreach ($search_results as $guid => $matches) { foreach ($entities_unsorted as $e) { $desc_suffix = ''; - if ($show_score == 'yes' && elgg_is_admin_logged_in()) { - $desc_suffix .= elgg_view('output/longtext', array( - 'value' => elgg_echo('elgg_solr:relevancy', array($matches['score'])), - 'class' => 'elgg-subtext' - )); - } if ($e->guid == $guid) { - if ($matches['title']) { - $e->setVolatileData('search_matched_title', $matches['title']); + if ($matches["title_{$language}"]) { + $e->setVolatileData('search_matched_title', $matches["title_{$language}"]); } else { - $e->setVolatileData('search_matched_title', $e->title); + $e->setVolatileData('search_matched_title', gc_explode_translation($e->title, $language)); } - if ($matches['description']) { - $desc = $matches['description']; + if ($matches["description_{$language}"]) { + $desc = $matches["description_{$language}"]; } else { - $desc = elgg_get_excerpt($e->description, 100); + $desc = elgg_get_excerpt(gc_explode_translation($e->description, $language), 100); } - unset($matches['title']); - unset($matches['description']); - unset($matches['score']); + unset($matches["title_{$language}"]); + unset($matches["description_{$language}"]); $desc .= implode('...', $matches); $e->setVolatileData('search_matched_description', $desc . $desc_suffix); @@ -401,15 +341,14 @@ function elgg_solr_object_search($hook, $type, $return, $params) { function elgg_solr_user_search($hook, $type, $return, $params) { + $language = get_language(); + $select = array( + 'querydefaultfield' => "text_{$language}", 'start' => $params['offset'], - 'rows' => $params['limit'] ? $params['limit'] : 10, - 'fields' => array('id','name','username', 'description', 'score') + 'rows' => $params['limit'] ? $params['limit'] : 10, + 'query' => $params['query'] ); - - if( $params['user_type'] ){ - $select['fields'][] = 'user_type'; - } if ($params['select'] && is_array($params['select'])) { $select = array_merge($select, $params['select']); @@ -422,41 +361,12 @@ function elgg_solr_user_search($hook, $type, $return, $params) { $query = $client->createSelect($select); $default_sorts = array( - 'score' => 'desc', - 'time_created' => 'desc' + 'date_created' => 'desc' ); - - $sorts = $params['sorts'] ? $params['sorts'] : $default_sorts; - $query->addSorts($sorts); - - $title_boost = elgg_solr_get_title_boost(); - $description_boost = elgg_solr_get_description_boost(); - - // get the dismax component and set a boost query - $dismax = $query->getEDisMax(); - $qf = "name^{$title_boost} username^{$title_boost} description^{$description_boost}"; - - if( $params['user_type'] ){ - $qf .= " user_type^{$title_boost}"; - } if ($params['qf']) { $qf = $params['qf']; } - $dismax->setQueryFields($qf); - $dismax->setQueryAlternative('*:*'); - - // no time boost for users - /* - $boostQuery = elgg_solr_get_boost_query(); - if ($boostQuery) { - $dismax->setBoostQuery($boostQuery); - } - * - */ - - // this query is now a dismax query - $query->setQuery($params['query']); // make sure we're only getting users $params['fq']['type'] = 'type:user'; @@ -475,13 +385,15 @@ function elgg_solr_user_search($hook, $type, $return, $params) { if (!empty($filter_queries)) { foreach ($filter_queries as $key => $value) { + if ($key == 'subtype') continue; $query->createFilterQuery($key)->setQuery($value); - } + } } - + // get highlighting component and apply settings $hl = $query->getHighlighting(); - $hlfields = array('name', 'username', 'description'); + $hlfields = array("text_{$language}"); + if ($params['hlfields']) { $hlfields = $params['hlfields']; } @@ -512,7 +424,8 @@ function elgg_solr_user_search($hook, $type, $return, $params) { } // Count the total number of documents found by solr - $count = $resultset->getNumFound(); + $count = $resultset->getNumFound(); + $hl_prefix = elgg_solr_get_hl_prefix(); $hl_suffix = elgg_solr_get_hl_suffix(); @@ -522,11 +435,11 @@ function elgg_solr_user_search($hook, $type, $return, $params) { $purifier = new HTMLPurifier($config); foreach ($resultset as $document) { - $search_results[$document->id] = array(); + $search_results[$document->guid] = array(); $snippet = ''; // highlighting results can be fetched by document id (the field defined as uniquekey in this schema) - $highlightedDoc = $highlighting->getResult($document->id); + $highlightedDoc = $highlighting->getResult($document->guid); if($highlightedDoc){ foreach($highlightedDoc as $field => $highlight) { @@ -543,10 +456,9 @@ function elgg_solr_user_search($hook, $type, $return, $params) { $snippet = $purifier->purify($snippet); } - $search_results[$document->id][$field] = $snippet; + $search_results[$document->guid][$field] = $snippet; } } - $search_results[$document->id]['score'] = $document->score; } // get the entities @@ -559,21 +471,13 @@ function elgg_solr_user_search($hook, $type, $return, $params) { )); } - $show_score = elgg_get_plugin_setting('show_score', 'elgg_solr'); foreach ($search_results as $guid => $matches) { foreach ($entities_unsorted as $e) { if ($e->guid == $guid) { $desc_suffix = ''; - if ($show_score == 'yes' && elgg_is_admin_logged_in()) { - $desc_suffix .= elgg_view('output/longtext', array( - 'value' => elgg_echo('elgg_solr:relevancy', array($matches['score'])), - 'class' => 'elgg-subtext' - )); - } - - if ($matches['name']) { - $name = $matches['name']; + if ($matches["name_{$language}"]) { + $name = $matches["name_{$language}"]; if ($matches['username']) { $name .= ' (@' . $matches['username'] . ')'; } @@ -584,7 +488,7 @@ function elgg_solr_user_search($hook, $type, $return, $params) { $e->setVolatileData('search_matched_title', $name); } else { - $name = $e->name; + $name = gc_explode_translation($e->name, $language); if ($matches['username']) { $name .= ' (@' . $matches['username'] . ')'; } @@ -596,11 +500,9 @@ function elgg_solr_user_search($hook, $type, $return, $params) { } // anything not already matched can be lumped in with the description - unset($matches['name']); + unset($matches["name_{$language}"]); unset($matches['username']); - unset($matches['score']); $desc_suffix .= implode('...', $matches); - $desc_hl = search_get_highlighted_relevant_substrings($e->description, $params['query']); $e->setVolatileData('search_matched_description', $desc_hl . $desc_suffix); $entities[] = $e; @@ -618,10 +520,13 @@ function elgg_solr_user_search($hook, $type, $return, $params) { function elgg_solr_group_search($hook, $type, $return, $params) { + $language = get_language(); + $select = array( 'start' => $params['offset'], 'rows' => $params['limit'] ? $params['limit'] : 10, - 'fields' => array('id','name','description', 'score') + 'query' => $params['query'], + 'querydefaultfield' => "text_{$language}", ); if ($params['select'] && is_array($params['select'])) { @@ -635,30 +540,12 @@ function elgg_solr_group_search($hook, $type, $return, $params) { $query = $client->createSelect($select); $default_sorts = array( - 'score' => 'desc', - 'time_created' => 'desc' + 'date_created' => 'desc' ); $sorts = $params['sorts'] ? $params['sorts'] : $default_sorts; $query->addSorts($sorts); - $title_boost = elgg_solr_get_title_boost(); - $description_boost = elgg_solr_get_description_boost(); - - // get the dismax component and set a boost query - $dismax = $query->getEDisMax(); - $qf = "name^{$title_boost} description^{$description_boost}"; - if ($params['qf']) { - $qf = $params['qf']; - } - $dismax->setQueryFields($qf); - $dismax->setQueryAlternative('*:*'); - - $boostQuery = elgg_solr_get_boost_query(); - if ($boostQuery) { - $dismax->setBoostQuery($boostQuery); - } - // this query is now a dismax query $query->setQuery($params['query']); @@ -666,6 +553,7 @@ function elgg_solr_group_search($hook, $type, $return, $params) { $params['fq']['type'] = 'type:group'; $default_fq = elgg_solr_get_default_fq($params); + unset($default_fq['subtype']); if ($params['fq']) { $filter_queries = array_merge($default_fq, $params['fq']); } @@ -681,7 +569,7 @@ function elgg_solr_group_search($hook, $type, $return, $params) { // get highlighting component and apply settings $hl = $query->getHighlighting(); - $hlfields = array('name', 'description'); + $hlfields = array("text_{$language}"); if ($params['hlfields']) { $hlfields = $params['hlfields']; } @@ -723,11 +611,11 @@ function elgg_solr_group_search($hook, $type, $return, $params) { $purifier = new HTMLPurifier($config); foreach ($resultset as $document) { - $search_results[$document->id] = array(); + $search_results[$document->guid] = array(); $snippet = ''; // highlighting results can be fetched by document id (the field defined as uniquekey in this schema) - $highlightedDoc = $highlighting->getResult($document->id); + $highlightedDoc = $highlighting->getResult($document->guid); if($highlightedDoc){ foreach($highlightedDoc as $field => $highlight) { @@ -744,11 +632,9 @@ function elgg_solr_group_search($hook, $type, $return, $params) { $snippet = $purifier->purify($snippet); } - $search_results[$document->id][$field] = $snippet; + $search_results[$document->guid][$field] = $snippet; } } - - $search_results[$document->id]['score'] = $document->score; } // get the entities @@ -761,41 +647,33 @@ function elgg_solr_group_search($hook, $type, $return, $params) { )); } - $show_score = elgg_get_plugin_setting('show_score', 'elgg_solr'); foreach ($search_results as $guid => $matches) { foreach ($entities_unsorted as $e) { $desc_suffix = ''; - if ($show_score == 'yes' && elgg_is_admin_logged_in()) { - $desc_suffix .= elgg_view('output/longtext', array( - 'value' => elgg_echo('elgg_solr:relevancy', array($matches['score'])), - 'class' => 'elgg-subtext' - )); - } if ($e->guid == $guid) { - if ($matches['name']) { - $name = $matches['name']; + if ($matches["name_{$language}"]) { + $name = $matches["name_{$language}"]; $e->setVolatileData('search_matched_name', $name); $e->setVolatileData('search_matched_title', $name); } else { - $name = $e->name; + $name = gc_explode_translation($e->name, $language); $e->setVolatileData('search_matched_name', $name); $e->setVolatileData('search_matched_title', $name); } - if ($matches['description']) { - $desc = $matches['description']; + if ($matches["description_{$language}"]) { + $desc = $matches["description_{$language}"]; } else { - $desc = search_get_highlighted_relevant_substrings($e->description, $params['query']); + $desc = search_get_highlighted_relevant_substrings(gc_explode_translation($e->description, $language), $params['query']); } - unset($matches['name']); - unset($matches['description']); - unset($matches['score']); + unset($matches["name_{$language}"]); + unset($matches["description_{$language}"]); $desc .= implode('...', $matches); $e->setVolatileData('search_matched_description', $desc . $desc_suffix); @@ -832,7 +710,9 @@ function elgg_solr_user_settings_save($hook, $type, $return, $params) { } - +/* Thursday, July 12 2018 + * this won't be used for now, temporarily disabled + */ function elgg_solr_tag_search($hook, $type, $return, $params) { $valid_tag_names = elgg_get_registered_tag_metadata_names(); @@ -864,7 +744,7 @@ function elgg_solr_tag_search($hook, $type, $return, $params) { $query_parts = array(); foreach ($search_tag_names as $tagname) { // @note - these need to be treated as literal exact matches, so encapsulate in double-quotes - $query_parts[] = 'tags:"' . elgg_solr_escape_special_chars($tagname . '%%' . $params['query']) . '"'; + //$query_parts[] = 'tags:"' . elgg_solr_escape_special_chars($tagname . '%%' . $params['query']) . '"'; } if (!$query_parts) { @@ -890,7 +770,7 @@ function elgg_solr_tag_search($hook, $type, $return, $params) { $default_sorts = array( 'score' => 'desc', - 'time_created' => 'desc' + 'date_created' => 'desc' ); $sorts = $params['sorts'] ? $params['sorts'] : $default_sorts; @@ -912,7 +792,7 @@ function elgg_solr_tag_search($hook, $type, $return, $params) { // get highlighting component and apply settings $hl = $query->getHighlighting(); - $hl->setFields(array('tags')); + //$hl->setFields(array('tags')); $hl->setSimplePrefix(''); $hl->setSimplePostfix(''); @@ -995,7 +875,7 @@ function elgg_solr_tag_search($hook, $type, $return, $params) { $e->setVolatileData('search_matched_title', $title); $e->setVolatileData('search_matched_description', elgg_get_excerpt($description) . $desc_suffix); - $e->setVolatileData('search_matched_extra', $matches['tags']); + //$e->setVolatileData('search_matched_extra', $matches['tags']); $entities[] = $e; } } @@ -1067,7 +947,7 @@ function elgg_solr_comment_search($hook, $type, $return, $params) { $select = array( 'start' => $params['offset'], 'rows' => $params['limit'] ? $params['limit'] : 10, - 'fields' => array('id', 'container_guid', 'description', 'owner_guid', 'time_created', 'score'), + 'fields' => array('id', 'container_guid', 'description', 'owner_guid', 'date_created', 'score'), ); if ($params['select'] && is_array($params['select'])) { @@ -1082,7 +962,7 @@ function elgg_solr_comment_search($hook, $type, $return, $params) { $default_sort = array( 'score' => 'desc', - 'time_created' => 'desc' + 'date_created' => 'desc' ); $sorts = $params['sorts'] ? $params['sorts'] : $default_sort; @@ -1210,7 +1090,7 @@ function elgg_solr_comment_search($hook, $type, $return, $params) { 'annotation_id' => substr(strstr(elgg_strip_tags($document->id), ':'), 1), 'text' => $snippet, 'owner_guid' => $document->owner_guid, - 'time_created' => $document->time_created, + 'date_created' => $document->date_created, ); $entity->setVolatileData('search_comments_data', $comments_data); diff --git a/mod/elgg_solr/start.php b/mod/elgg_solr/start.php index 713249516c..5c3a7af94e 100644 --- a/mod/elgg_solr/start.php +++ b/mod/elgg_solr/start.php @@ -36,9 +36,11 @@ function elgg_solr_init() { elgg_register_plugin_hook_handler('search', 'object', 'elgg_solr_object_search'); elgg_register_plugin_hook_handler('search', 'user', 'elgg_solr_user_search'); elgg_register_plugin_hook_handler('search', 'group', 'elgg_solr_group_search'); - elgg_register_plugin_hook_handler('search', 'tags', 'elgg_solr_tag_search'); + //elgg_register_plugin_hook_handler('search', 'tags', 'elgg_solr_tag_search'); + //elgg_register_plugin_hook_handler('search', ); + if ($is_elgg18) { // this is elgg 1.8 need to handle comments as annotations elgg_unregister_plugin_hook_handler('search', 'comments', 'search_comments_hook'); diff --git a/mod/elgg_solr/vendor/autoload.php b/mod/elgg_solr/vendor/autoload.php index bf4298592b..ba923bed9e 100644 --- a/mod/elgg_solr/vendor/autoload.php +++ b/mod/elgg_solr/vendor/autoload.php @@ -2,6 +2,6 @@ // autoload.php @generated by Composer -require_once __DIR__ . '/composer' . '/autoload_real.php'; +require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit9b2c0c462db63d8ab03db94c9650b99f::getLoader(); +return ComposerAutoloaderInitf66440e91f7ef7305417c79dbf9d16cb::getLoader(); diff --git a/mod/elgg_solr/vendor/composer.json b/mod/elgg_solr/vendor/composer.json new file mode 100644 index 0000000000..a2fa71b780 --- /dev/null +++ b/mod/elgg_solr/vendor/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "solarium/solarium": "3.6.0" + } +} diff --git a/mod/elgg_solr/vendor/composer.lock b/mod/elgg_solr/vendor/composer.lock new file mode 100644 index 0000000000..f4b789327f --- /dev/null +++ b/mod/elgg_solr/vendor/composer.lock @@ -0,0 +1,135 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "923248fbdac97c7d0e4f75dbcfaca88d", + "packages": [ + { + "name": "solarium/solarium", + "version": "3.6.0", + "source": { + "type": "git", + "url": "https://github.com/solariumphp/solarium.git", + "reference": "b945cbe4e8f96b639d82c4d1e2cae4ef3ab6fce5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/solariumphp/solarium/zipball/b945cbe4e8f96b639d82c4d1e2cae4ef3ab6fce5", + "reference": "b945cbe4e8f96b639d82c4d1e2cae4ef3ab6fce5", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "symfony/event-dispatcher": "~2.3|~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~3.7", + "satooshi/php-coveralls": "~1.0", + "squizlabs/php_codesniffer": "~1.4", + "zendframework/zendframework1": "~1.12" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "3.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Solarium\\": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "See GitHub contributors", + "homepage": "https://github.com/basdenooijer/solarium/contributors" + } + ], + "description": "PHP Solr client", + "homepage": "http://www.solarium-project.org", + "keywords": [ + "php", + "search", + "solr" + ], + "time": "2016-05-03T07:08:49+00:00" + }, + { + "name": "symfony/event-dispatcher", + "version": "v3.4.12", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "fdd5abcebd1061ec647089c6c41a07ed60af09f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/fdd5abcebd1061ec647089c6c41a07ed60af09f8", + "reference": "fdd5abcebd1061ec647089c6c41a07ed60af09f8", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2018-04-06T07:35:25+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/mod/elgg_solr/vendor/composer/ClassLoader.php b/mod/elgg_solr/vendor/composer/ClassLoader.php index 5e1469e830..4626994fd4 100644 --- a/mod/elgg_solr/vendor/composer/ClassLoader.php +++ b/mod/elgg_solr/vendor/composer/ClassLoader.php @@ -13,9 +13,7 @@ namespace Composer\Autoload; /** - * ClassLoader implements a PSR-0 class loader - * - * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. * * $loader = new \Composer\Autoload\ClassLoader(); * @@ -39,6 +37,8 @@ * * @author Fabien Potencier * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ */ class ClassLoader { @@ -53,8 +53,9 @@ class ClassLoader private $useIncludePath = false; private $classMap = array(); - private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; public function getPrefixes() { @@ -147,7 +148,7 @@ public function add($prefix, $paths, $prepend = false) * appending or prepending to the ones previously set for this namespace. * * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-0 base directories + * @param array|string $paths The PSR-4 base directories * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException @@ -271,6 +272,26 @@ public function isClassMapAuthoritative() return $this->classMapAuthoritative; } + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + /** * Registers this instance as an autoloader. * @@ -313,29 +334,34 @@ public function loadClass($class) */ public function findFile($class) { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - // class map lookup if (isset($this->classMap[$class])) { return $this->classMap[$class]; } - if ($this->classMapAuthoritative) { + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { return false; } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } $file = $this->findFileWithExtension($class, '.php'); // Search for Hack files if we are running on HHVM - if ($file === null && defined('HHVM_VERSION')) { + if (false === $file && defined('HHVM_VERSION')) { $file = $this->findFileWithExtension($class, '.hh'); } - if ($file === null) { + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { // Remember that this class does not exist. - return $this->classMap[$class] = false; + $this->missingClasses[$class] = true; } return $file; @@ -399,6 +425,8 @@ private function findFileWithExtension($class, $ext) if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { return $file; } + + return false; } } diff --git a/mod/elgg_solr/vendor/composer/LICENSE b/mod/elgg_solr/vendor/composer/LICENSE new file mode 100644 index 0000000000..1a28124886 --- /dev/null +++ b/mod/elgg_solr/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) 2016 Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/mod/elgg_solr/vendor/composer/autoload_files.php b/mod/elgg_solr/vendor/composer/autoload_files.php index 915496bea7..c25686b153 100644 --- a/mod/elgg_solr/vendor/composer/autoload_files.php +++ b/mod/elgg_solr/vendor/composer/autoload_files.php @@ -6,5 +6,5 @@ $baseDir = dirname($vendorDir); return array( - $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + '2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', ); diff --git a/mod/elgg_solr/vendor/composer/autoload_namespaces.php b/mod/elgg_solr/vendor/composer/autoload_namespaces.php index 7052e10e3d..4b77f0eccb 100644 --- a/mod/elgg_solr/vendor/composer/autoload_namespaces.php +++ b/mod/elgg_solr/vendor/composer/autoload_namespaces.php @@ -8,4 +8,5 @@ return array( 'Solarium\\' => array($vendorDir . '/solarium/solarium/library'), 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), + '' => array($baseDir . '/classes'), ); diff --git a/mod/elgg_solr/vendor/composer/autoload_real.php b/mod/elgg_solr/vendor/composer/autoload_real.php index 639a8d6ad6..18f6aa9ac9 100644 --- a/mod/elgg_solr/vendor/composer/autoload_real.php +++ b/mod/elgg_solr/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit9b2c0c462db63d8ab03db94c9650b99f +class ComposerAutoloaderInitf66440e91f7ef7305417c79dbf9d16cb { private static $loader; @@ -19,37 +19,52 @@ public static function getLoader() return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit9b2c0c462db63d8ab03db94c9650b99f', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitf66440e91f7ef7305417c79dbf9d16cb', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit9b2c0c462db63d8ab03db94c9650b99f', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitf66440e91f7ef7305417c79dbf9d16cb', 'loadClassLoader')); - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } + call_user_func(\Composer\Autoload\ComposerStaticInitf66440e91f7ef7305417c79dbf9d16cb::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } } $loader->register(true); - $includeFiles = require __DIR__ . '/autoload_files.php'; - foreach ($includeFiles as $file) { - composerRequire9b2c0c462db63d8ab03db94c9650b99f($file); + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInitf66440e91f7ef7305417c79dbf9d16cb::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequiref66440e91f7ef7305417c79dbf9d16cb($fileIdentifier, $file); } return $loader; } } -function composerRequire9b2c0c462db63d8ab03db94c9650b99f($file) +function composerRequiref66440e91f7ef7305417c79dbf9d16cb($fileIdentifier, $file) { - require $file; + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } } diff --git a/mod/elgg_solr/vendor/composer/autoload_static.php b/mod/elgg_solr/vendor/composer/autoload_static.php new file mode 100644 index 0000000000..98ccb2c409 --- /dev/null +++ b/mod/elgg_solr/vendor/composer/autoload_static.php @@ -0,0 +1,58 @@ + __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + ); + + public static $prefixLengthsPsr4 = array ( + 'S' => + array ( + 'Symfony\\Component\\EventDispatcher\\' => 34, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'Symfony\\Component\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher', + ), + ); + + public static $prefixesPsr0 = array ( + 'S' => + array ( + 'Solarium\\' => + array ( + 0 => __DIR__ . '/..' . '/solarium/solarium/library', + ), + ), + 'H' => + array ( + 'HTMLPurifier' => + array ( + 0 => __DIR__ . '/..' . '/ezyang/htmlpurifier/library', + ), + ), + ); + + public static $fallbackDirsPsr0 = array ( + 0 => __DIR__ . '/../..' . '/classes', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitf66440e91f7ef7305417c79dbf9d16cb::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf66440e91f7ef7305417c79dbf9d16cb::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInitf66440e91f7ef7305417c79dbf9d16cb::$prefixesPsr0; + $loader->fallbackDirsPsr0 = ComposerStaticInitf66440e91f7ef7305417c79dbf9d16cb::$fallbackDirsPsr0; + + }, null, ClassLoader::class); + } +} diff --git a/mod/elgg_solr/vendor/composer/installed.json b/mod/elgg_solr/vendor/composer/installed.json index ead4811c53..71d3a9033c 100644 --- a/mod/elgg_solr/vendor/composer/installed.json +++ b/mod/elgg_solr/vendor/composer/installed.json @@ -1,50 +1,4 @@ [ - { - "name": "ezyang/htmlpurifier", - "version": "v4.6.0", - "version_normalized": "4.6.0.0", - "source": { - "type": "git", - "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "6f389f0f25b90d0b495308efcfa073981177f0fd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/6f389f0f25b90d0b495308efcfa073981177f0fd", - "reference": "6f389f0f25b90d0b495308efcfa073981177f0fd", - "shasum": "" - }, - "require": { - "php": ">=5.2" - }, - "time": "2013-11-30 08:25:19", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "HTMLPurifier": "library/" - }, - "files": [ - "library/HTMLPurifier.composer.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL" - ], - "authors": [ - { - "name": "Edward Z. Yang", - "email": "admin@htmlpurifier.org", - "homepage": "http://ezyang.com" - } - ], - "description": "Standards compliant HTML filter written in PHP", - "homepage": "http://htmlpurifier.org/", - "keywords": [ - "html" - ] - }, { "name": "symfony/event-dispatcher", "version": "v2.7.3", @@ -75,7 +29,7 @@ "symfony/dependency-injection": "", "symfony/http-kernel": "" }, - "time": "2015-06-18 19:21:56", + "time": "2015-06-18T19:21:56+00:00", "type": "library", "extra": { "branch-alias": { @@ -130,7 +84,7 @@ "squizlabs/php_codesniffer": "~1.4", "zendframework/zendframework1": "~1.12" }, - "time": "2015-06-14 17:22:39", + "time": "2015-06-14T17:22:39+00:00", "type": "library", "extra": { "branch-alias": { @@ -160,5 +114,51 @@ "search", "solr" ] + }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.6.0", + "version_normalized": "4.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "6f389f0f25b90d0b495308efcfa073981177f0fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/6f389f0f25b90d0b495308efcfa073981177f0fd", + "reference": "6f389f0f25b90d0b495308efcfa073981177f0fd", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "time": "2013-11-30T08:25:19+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "HTMLPurifier": "library/" + }, + "files": [ + "library/HTMLPurifier.composer.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ] } ] diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/.gitattributes b/mod/elgg_solr/vendor/ezyang/htmlpurifier/.gitattributes new file mode 100644 index 0000000000..51e6483770 --- /dev/null +++ b/mod/elgg_solr/vendor/ezyang/htmlpurifier/.gitattributes @@ -0,0 +1 @@ +configdoc/usage.xml -crlf diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/benchmarks/.htaccess b/mod/elgg_solr/vendor/ezyang/htmlpurifier/benchmarks/.htaccess new file mode 100644 index 0000000000..3a42882788 --- /dev/null +++ b/mod/elgg_solr/vendor/ezyang/htmlpurifier/benchmarks/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README b/mod/elgg_solr/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README new file mode 100755 index 0000000000..2e35c1c3d0 --- /dev/null +++ b/mod/elgg_solr/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README @@ -0,0 +1,3 @@ +This is a dummy file to prevent Git from ignoring this empty directory. + + vim: et sw=4 sts=4 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/.htaccess b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/.htaccess new file mode 100644 index 0000000000..3a42882788 --- /dev/null +++ b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/compile-doxygen.sh b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/compile-doxygen.sh old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/flush-definition-cache.php b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/flush-definition-cache.php old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/generate-entity-file.php b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/generate-entity-file.php old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/generate-standalone.php b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/generate-standalone.php old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/merge-library.php b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/merge-library.php old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/regenerate-docs.sh b/mod/elgg_solr/vendor/ezyang/htmlpurifier/maintenance/regenerate-docs.sh old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/ezyang/htmlpurifier/tests/HTMLPurifier/Injector/RemoveSpansWithoutAttributesTest.php b/mod/elgg_solr/vendor/ezyang/htmlpurifier/tests/HTMLPurifier/Injector/RemoveSpansWithoutAttributesTest.php old mode 100644 new mode 100755 diff --git a/mod/elgg_solr/vendor/solarium/solarium/.coveralls.yml b/mod/elgg_solr/vendor/solarium/solarium/.coveralls.yml new file mode 100644 index 0000000000..1c8760a595 --- /dev/null +++ b/mod/elgg_solr/vendor/solarium/solarium/.coveralls.yml @@ -0,0 +1,3 @@ +service_name: travis-ci + +src_dir: library diff --git a/mod/elgg_solr/vendor/solarium/solarium/.travis.yml b/mod/elgg_solr/vendor/solarium/solarium/.travis.yml new file mode 100644 index 0000000000..a134d97c2a --- /dev/null +++ b/mod/elgg_solr/vendor/solarium/solarium/.travis.yml @@ -0,0 +1,30 @@ +language: php + +php: + - 5.6 + - 5.5 + - 5.4 + - 5.3 + - hhvm + - hhvm-nightly + +env: + - SYMFONY_VERSION=2.1.* + - SYMFONY_VERSION=2.2.* + - SYMFONY_VERSION=2.3.* + - SYMFONY_VERSION=2.4.* + - SYMFONY_VERSION=2.5.* + +before_script: + - bash -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != 'hhvm-nightly' ] && [ $TRAVIS_PHP_VERSION != '5.3' ]; then printf '\n\n\n\n' | pecl install pecl_http-1.7.6; fi" + - composer require --prefer-source --dev symfony/event-dispatcher:${SYMFONY_VERSION} + +script: vendor/bin/phpunit -c phpunit.xml.travis -v + +after_script: vendor/bin/coveralls -v + +matrix: + allow_failures: + - php: 5.3 + - php: hhvm + - php: hhvm-nightly \ No newline at end of file diff --git a/mod/solr_api/start.php b/mod/solr_api/start.php index 3cabe50bc4..4eac09d567 100644 --- a/mod/solr_api/start.php +++ b/mod/solr_api/start.php @@ -167,7 +167,9 @@ function get_list_of_deleted_records() { function get_user_list($offset) { + // @TODO check if the site url is either localhost or local ip address, replace with elgg if it is $site_url = elgg_get_site_url(); + $platform = explode('.', $site_url); $db_prefix = elgg_get_config('dbprefix'); $query = " SELECT e.guid, ue.name, ue.username, ue.email, e.type, e.time_created, e.enabled @@ -187,7 +189,8 @@ function get_user_list($offset) { 'type' => $user->type, 'date_created' => date("Y-m-d\TH:m:s\Z", $user->time_created), 'date_modified' => date("Y-m-d\TH:m:s\Z", $user->time_created), - 'url' => "{$site_url}profile/{$user->username}" + 'url' => "{$site_url}profile/{$user->username}", + 'platform' => $platform[0] ); } return $arr; @@ -196,6 +199,9 @@ function get_user_list($offset) { function get_group_list($offset) { // @TODO use SQL query syntax instead of using function elgg_get_entities() + $site_url = elgg_get_site_url(); + $platform = explode('.', $site_url); + $groups = elgg_get_entities(array( 'type' => 'group', 'limit' => 10, @@ -230,7 +236,8 @@ function get_group_list($offset) { 'access_id' => $group->access_id, 'date_created' => date("Y-m-d\TH:m:s\Z", $group->time_created), 'date_modified' => date("Y-m-d\TH:m:s\Z", $group->time_updated), - 'url' => $group->getURL() + 'url' => $group->getURL(), + 'platform' => $platform[0] ); } return $arr; @@ -238,6 +245,8 @@ function get_group_list($offset) { function get_entity_list($type, $subtype, $offset) { + $site_url = elgg_get_site_url(); + $platform = explode('.', $site_url); $entities = elgg_get_entities(array( 'type' => $type, 'subtype' => $subtype, @@ -246,32 +255,18 @@ function get_entity_list($type, $subtype, $offset) { )); foreach ($entities as $entity) { - - + if (is_Json($entity->title)) { - $title_array = json_decode($entity->title, true); - if (!isset($title_array['en']) || !isset($title_array['fr'])) { - $title_array['en'] = str_replace('"', '\"', $title_array); - $title_array['fr'] = str_replace('"', '\"', $title_array); - } else { - $title_array['en'] = str_replace('"', '\"', gc_explode_translation($entity->title, 'en')); - $title_array['fr'] = str_replace('"', '\"', gc_explode_translation($entity->title, 'fr')); - } - + $title_array['en'] = str_replace('"', '\"', gc_explode_translation($entity->title, 'en')); + $title_array['fr'] = str_replace('"', '\"', gc_explode_translation($entity->title, 'fr')); } else { $title_array['en'] = $entity->title; $title_array['fr'] = $entity->title; } if (is_Json($entity->description)) { - $description_array = json_decode($entity->description, true); - if (!isset($description_array['en']) || !isset($description_array['fr'])) { - $description_array['en'] = str_replace('"', '\"', $description_array); - $description_array['fr'] = str_replace('"', '\"', $description_array); - } else { - $description_array['en'] = str_replace('"', '\"', gc_explode_translation($entity->description, 'en')); - $description_array['fr'] = str_replace('"', '\"', gc_explode_translation($entity->description, 'fr')); - } + $description_array['en'] = str_replace('"', '\"', gc_explode_translation($entity->description, 'en')); + $description_array['fr'] = str_replace('"', '\"', gc_explode_translation($entity->description, 'fr')); } else { $description_array['en'] = $entity->description; $description_array['fr'] = $entity->description; @@ -286,7 +281,8 @@ function get_entity_list($type, $subtype, $offset) { 'access_id' => $entity->access_id, 'date_created' => date("Y-m-d\TH:m:s\Z", $entity->time_created), 'date_modified' => date("Y-m-d\TH:m:s\Z", $entity->time_updated), - 'url' => $entity->getURL() + 'url' => $entity->getURL(), + 'platform' => $platform[0] ); }