-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbcdSearchPlugin.inc.php
53 lines (44 loc) · 1.53 KB
/
AbcdSearchPlugin.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
import('lib.pkp.classes.plugins.GenericPlugin');
import('lib.pkp.plugins.importexport.users.PKPUserImportExportPlugin');
import('plugins.generic.AbcdSearch.AbcdSearchDAO');
class AbcdSearchPlugin extends GenericPlugin {
public function register($category, $path, $mainContextId = null) {
$success = parent::register($category, $path, $mainContextId);
if ($success && $this->getEnabled()) {
HookRegistry::register('LoadHandler', array($this, 'setPageHandler'));
}
return $success;
}
//montando a página
public function setPageHandler($hookName, $params) {
$page = $params[0];
//site.com/editora/$page
if ($page === 'abcdsearch') {
$this->import('AbcdSearchPluginHandler');
define('HANDLER_CLASS', 'AbcdSearchPluginHandler');
return true;
}
return false;
}
public function obterDados() {
//depende diretamente de abcdsearchdao
$abcdSearchDAO = new AbcdSearchDAO();
try {
$dados = $abcdSearchDAO->obterDados();
if (count($dados) > 0) {
return $dados;
} else {
return "Nenhum resultado encontrado";
}
} catch (Exception $e) {
return "Erro: " . $e->getMessage();
}
}
function getDisplayName() {
return __('plugins.generic.abcdsearch.displayName');
}
function getDescription() {
return __('plugins.generic.abcdsearch.description');
}
}