Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
aa5bc800
Commit
aa5bc800
authored
Feb 19, 2007
by
Martyn Smith
Committed by
Martyn Smith
Feb 19, 2007
Browse files
Add views to selfsearch
parent
95d789e4
Changes
7
Hide whitespace changes
Inline
Side-by-side
htdocs/search/lib.php
View file @
aa5bc800
...
...
@@ -164,17 +164,21 @@ abstract class PluginSearch extends Plugin {
public
static
abstract
function
self_search
(
$query_string
,
$limit
,
$offset
,
$type
=
'all'
);
protected
static
function
self_search_make_links
(
$data
)
{
$wwwroot
=
get_config
(
'wwwroot'
);
if
(
$data
[
'count'
])
{
foreach
(
$data
[
'data'
]
as
&
$result
)
{
switch
(
$result
[
'type'
])
{
case
'artefact'
:
if
(
isset
(
$result
[
'artefacttype'
]))
{
safe_require
(
'artefact'
,
get_field
(
'artefact_installed_type'
,
'plugin'
,
'name'
,
$result
[
'artefacttype'
]));
$result
[
'links'
]
=
call_static_method
(
generate_artefact_class_name
(
$result
[
'artefacttype'
]),
'get_links'
,
$result
[
'id'
]);
}
else
{
log_debug
(
$result
);
}
safe_require
(
'artefact'
,
get_field
(
'artefact_installed_type'
,
'plugin'
,
'name'
,
$result
[
'artefacttype'
]));
$result
[
'links'
]
=
call_static_method
(
generate_artefact_class_name
(
$result
[
'artefacttype'
]),
'get_links'
,
$result
[
'id'
]);
break
;
case
'view'
:
$result
[
'links'
]
=
array
(
'_default'
=>
$wwwroot
.
'view/view.php?view='
.
$result
[
'id'
],
get_string
(
'editviewinformation'
)
=>
$wwwroot
.
'view/editmetadata.php?viewid='
.
$result
[
'id'
],
get_string
(
'editview'
)
=>
$wwwroot
.
'view/edit.php?viewid='
.
$result
[
'id'
],
get_string
(
'editaccess'
)
=>
$wwwroot
.
'view/editaccess.php?viewid='
.
$result
[
'id'
],
);
break
;
default
:
break
;
...
...
htdocs/search/solr/lang/en.utf8/search.solr.php
View file @
aa5bc800
...
...
@@ -30,3 +30,4 @@ $string['solrurl'] = 'Solr URL';
$string
[
'indexcontrol'
]
=
'Index Control'
;
$string
[
'reindexusers'
]
=
'Re-Index Users'
;
$string
[
'reindexartefacts'
]
=
'Re-Index Artefacts'
;
$string
[
'reindexviews'
]
=
'Re-Index Views'
;
htdocs/search/solr/lib.php
View file @
aa5bc800
...
...
@@ -56,6 +56,8 @@ class PluginSearchSolr extends PluginSearchInternal {
(
object
)
array
(
'plugin'
=>
'solr'
,
'event'
=>
'activateuser'
,
'callfunction'
=>
'event_reindex_user'
),
(
object
)
array
(
'plugin'
=>
'solr'
,
'event'
=>
'saveartefact'
,
'callfunction'
=>
'event_saveartefact'
),
(
object
)
array
(
'plugin'
=>
'solr'
,
'event'
=>
'deleteartefact'
,
'callfunction'
=>
'event_deleteartefact'
),
(
object
)
array
(
'plugin'
=>
'solr'
,
'event'
=>
'saveview'
,
'callfunction'
=>
'event_saveview'
),
(
object
)
array
(
'plugin'
=>
'solr'
,
'event'
=>
'deleteview'
,
'callfunction'
=>
'event_deleteview'
),
);
return
$subscriptions
;
...
...
@@ -83,6 +85,18 @@ class PluginSearchSolr extends PluginSearchInternal {
self
::
commit
();
}
public
static
function
event_saveview
(
$event
,
$view
)
{
if
(
get_config
(
'searchplugin'
)
!=
'solr'
)
{
return
;
}
self
::
index_view
(
$view
);
self
::
commit
();
}
public
static
function
event_deleteview
(
$event
,
$view
)
{
log_debug
(
'event_deleteview()'
);
}
public
static
function
has_config
()
{
return
true
;
}
...
...
@@ -115,7 +129,7 @@ END;
'type'
=>
'fieldset'
,
'legend'
=>
get_string
(
'indexcontrol'
,
'search.solr'
),
'collapsible'
=>
true
,
'collapsed'
=>
fals
e
,
'collapsed'
=>
tru
e
,
'elements'
=>
array
(
array
(
'type'
=>
'html'
,
...
...
@@ -126,6 +140,7 @@ END;
'value'
=>
'<table><tbody>'
.
'<tr><td><a href="" onclick="solr_reindex(this, \'user\'); return false;">'
.
hsc
(
get_string
(
'reindexusers'
,
'search.solr'
))
.
'</a></td></tr>'
.
'<tr><td><a href="" onclick="solr_reindex(this, \'artefact\'); return false;">'
.
hsc
(
get_string
(
'reindexartefacts'
,
'search.solr'
))
.
'</a></td></tr>'
.
'<tr><td><a href="" onclick="solr_reindex(this, \'view\'); return false;">'
.
hsc
(
get_string
(
'reindexviews'
,
'search.solr'
))
.
'</a></td></tr>'
.
'</tbody></table>'
,
),
),
...
...
@@ -222,10 +237,36 @@ END;
}
self
::
rebuild_users
();
self
::
rebuild_artefacts
();
self
::
rebuild_views
();
self
::
commit
();
self
::
optimize
();
}
public
static
function
rebuild_views
()
{
log_debug
(
'Starting rebuild_views()'
);
self
::
delete_bytype
(
'view'
);
$views
=
get_recordset
(
'view'
,
''
,
''
,
''
,
'*,'
.
db_format_tsfield
(
'ctime'
)
.
','
.
db_format_tsfield
(
'mtime'
));
while
(
$view
=
$views
->
FetchRow
())
{
$doc
=
array
(
'id'
=>
$view
[
'id'
],
'owner'
=>
$view
[
'owner'
],
'type'
=>
'view'
,
'title'
=>
$view
[
'title'
],
'description'
=>
strip_tags
(
$view
[
'description'
]),
'tags'
=>
join
(
', '
,
get_column
(
'view_tag'
,
'tag'
,
'view'
,
$view
[
'id'
])),
'ctime'
=>
$view
[
'ctime'
],
'mtime'
=>
$view
[
'mtime'
],
);
self
::
add_document
(
$doc
);
}
log_debug
(
'Completed rebuild_views()'
);
}
public
static
function
rebuild_artefacts
()
{
log_debug
(
'Starting rebuild_artefacts()'
);
...
...
@@ -294,6 +335,23 @@ END;
self
::
add_document
(
$doc
);
}
private
static
function
index_view
(
$view
)
{
$view
=
(
array
)
get_record
(
'view'
,
'id'
,
$view
[
'id'
],
null
,
null
,
null
,
null
,
'*,'
.
db_format_tsfield
(
'ctime'
)
.
','
.
db_format_tsfield
(
'mtime'
));
$doc
=
array
(
'id'
=>
$view
[
'id'
],
'owner'
=>
$view
[
'owner'
],
'type'
=>
'view'
,
'title'
=>
$view
[
'title'
],
'description'
=>
strip_tags
(
$view
[
'description'
]),
'tags'
=>
join
(
', '
,
get_column
(
'view_tag'
,
'tag'
,
'view'
,
$view
[
'id'
])),
'ctime'
=>
$view
[
'ctime'
],
'mtime'
=>
$view
[
'mtime'
],
);
self
::
add_document
(
$doc
);
}
private
static
function
index_user
(
$user
)
{
if
(
!
isset
(
$user
[
'id'
]))
{
throw
new
InvalidArgumentException
(
'Trying to index user with no id'
);
...
...
htdocs/search/solr/reindex.json.php
View file @
aa5bc800
...
...
@@ -43,6 +43,11 @@ switch ($type) {
PluginSearchSolr
::
commit
();
PluginSearchSolr
::
optimize
();
break
;
case
'view'
:
PluginSearchSolr
::
rebuild_views
();
PluginSearchSolr
::
commit
();
PluginSearchSolr
::
optimize
();
break
;
default
:
PluginSearchSolr
::
rebuild_all
();
break
;
...
...
htdocs/search/solr/version.php
View file @
aa5bc800
...
...
@@ -26,7 +26,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
->
version
=
2007021
401
;
$config
->
release
=
'0.
1
'
;
$config
->
version
=
2007021
900
;
$config
->
release
=
'0.
2
'
;
?>
htdocs/selfsearch.php
View file @
aa5bc800
...
...
@@ -56,9 +56,10 @@ results.rowfunction = function (r, n, d) {
for ( var k in r.links ) {
var button = BUTTON(null, k);
connect(button, 'onclick', function () {
document.location.href = r.links[k];
});
connect(button, 'onclick', partial(
function (link) { document.location.href = link },
r.links[k]
));
titleElement.push(button);
}
...
...
htdocs/view/editmetadata.php
View file @
aa5bc800
...
...
@@ -154,6 +154,8 @@ function createview1_submit(Pieform $form, $values) {
db_commit
();
handle_event
(
'saveview'
,
$view_id
);
$SESSION
->
add_ok_msg
(
get_string
(
'viewinformationsaved'
,
'view'
));
redirect
(
'/view/'
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment