|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package net.nemein.wiki |
|
4
|
|
|
* @author The Midgard Project, http://www.midgard-project.org |
|
5
|
|
|
* @copyright The Midgard Project, http://www.midgard-project.org |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
use midcom\datamanager\datamanager; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Wiki Site interface class. |
|
13
|
|
|
* |
|
14
|
|
|
* @package net.nemein.wiki |
|
15
|
|
|
*/ |
|
16
|
|
|
class net_nemein_wiki_viewer extends midcom_baseclasses_components_viewer |
|
17
|
|
|
{ |
|
18
|
15 |
|
public function _on_handle($handler_id, array $args) |
|
19
|
|
|
{ |
|
20
|
|
|
// Add machine-readable RSS link |
|
21
|
15 |
|
midcom::get()->head->add_link_head([ |
|
22
|
15 |
|
'rel' => 'alternate', |
|
23
|
15 |
|
'type' => 'application/rss+xml', |
|
24
|
15 |
|
'title' => sprintf($this->_l10n->get('latest updates in %s'), $this->_topic->extra), |
|
25
|
15 |
|
'href' => $this->router->generate('rss'), |
|
26
|
15 |
|
]); |
|
27
|
|
|
|
|
28
|
15 |
|
$this->add_stylesheet(MIDCOM_STATIC_URL . "/net.nemein.wiki/wiki.css"); |
|
29
|
|
|
|
|
30
|
15 |
|
if (midcom::get()->auth->user) { |
|
31
|
1 |
|
$user = midcom::get()->auth->user->get_storage(); |
|
32
|
1 |
|
if ($this->_topic->get_parameter('net.nemein.wiki:watch', $user->guid)) { |
|
33
|
|
|
$action = 'unsubscribe'; |
|
34
|
|
|
} else { |
|
35
|
1 |
|
$action = 'subscribe'; |
|
36
|
|
|
} |
|
37
|
1 |
|
$this->_node_toolbar->add_item([ |
|
38
|
1 |
|
MIDCOM_TOOLBAR_URL => "subscribe/index/", |
|
39
|
1 |
|
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get($action), |
|
40
|
1 |
|
MIDCOM_TOOLBAR_GLYPHICON => 'envelope-o', |
|
41
|
1 |
|
MIDCOM_TOOLBAR_POST => true, |
|
42
|
1 |
|
MIDCOM_TOOLBAR_POST_HIDDENARGS => [ |
|
43
|
1 |
|
$action => 1, |
|
44
|
1 |
|
'target' => 'folder', |
|
45
|
1 |
|
] |
|
46
|
1 |
|
]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
15 |
|
$this->_node_toolbar->add_item([ |
|
50
|
15 |
|
MIDCOM_TOOLBAR_URL => "orphans/", |
|
51
|
15 |
|
MIDCOM_TOOLBAR_LABEL => $this->_l10n->get('orphaned pages'), |
|
52
|
15 |
|
MIDCOM_TOOLBAR_GLYPHICON => 'chain-broken', |
|
53
|
15 |
|
]); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Indexes a wiki page. |
|
58
|
|
|
* |
|
59
|
|
|
* @param midcom_db_topic|midcom_core_dbaproxy $topic The topic which we are bound to. If this is not an object, the code |
|
60
|
|
|
* tries to load a new topic instance from the database identified by this parameter. |
|
61
|
|
|
*/ |
|
62
|
|
|
public static function index(datamanager $dm, midcom_services_indexer $indexer, $topic) |
|
63
|
|
|
{ |
|
64
|
|
|
$nav = new midcom_helper_nav(); |
|
65
|
|
|
$node = $nav->get_node($topic->id); |
|
66
|
|
|
|
|
67
|
|
|
$document = $indexer->new_document($dm); |
|
68
|
|
|
$document->topic_guid = $topic->guid; |
|
69
|
|
|
$document->topic_url = $node[MIDCOM_NAV_FULLURL]; |
|
70
|
|
|
$document->component = $topic->component; |
|
|
|
|
|
|
71
|
|
|
$indexer->index($document); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|