aboutsummaryrefslogtreecommitdiff
path: root/lib/elearning/PmWikiConnectedCMS.class.php
blob: 7de0a788e73a5acad1a06677e933db463b38751f (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO

/*
 * PmWikiConnectedCMS.class.php - Provides search capabilities
 * to search WikiFarm
 *
 * Copyright (C) 2006 - Marco Diedrich (mdiedric@uos.de)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

require_once 'clients/xml_rpc_webservice_client.php';
require_once 'clients/soap_webservice_client.php';
require_once 'clients/webservice_client.php';

/**
* main-class for connection to PmWiki
*
* This class contains the main methods of the elearning-interface to connect to PmWiki. Extends ConnectedCMS.
*
* @author   Marco Diedrich <mdiedric@uos.de>
* @access   public
* @modulegroup  elearning_interface_modules
* @module       PmWikiConnectedCMS
* @package  ELearning-Interface
*/

class PmWikiConnectedCMS extends ConnectedCMS
{
    public $client;
    public $api_key;
    public $field_script;

    function __construct($cms)
    {
        parent::__construct($cms);
        $this->client = WebserviceClient::instance( $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['ABSOLUTE_PATH_SOAP'] .
                                                                                                '?' . $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['URL_PARAMS'],
                                                                                                $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['WEBSERVICE_CLASS']);

        $this->api_key = $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['soap_data']['api-key'];
    }

    function init($cms)
    {
        parent::init($cms);
        $this->field_script = $GLOBALS['ELEARNING_INTERFACE_MODULES'][$cms]["field_script"];
    }

    /**
    * search for content modules
    *
    * returns found content modules
    * @param string $key keyword
    * @return array list of content modules
    */
    public function searchContentModules($key)
    {
        $fields_found = $this->client->call("search_content_modules", [
            $GLOBALS['ELEARNING_INTERFACE_MODULES'][$this->cms_type]['soap_data']['api-key'],
            $key
        ]);

        $result = [];
        foreach ($fields_found as $field) {
            $result[$field['field_id']] = [
                'ref_id'      => $field['field_id'],
                'type'        => $field['field_type'],
                'obj_id'      => null,
                'create_date' => $field['create_date'],
                'last_update' => $field['change_date'],
                'title'       => $field['field_title'],
                'description' => $field['field_description'],
            ];
        }
        return $result;
    }

}