Commit 6acbbfa4 authored by Jim Tittsler's avatar Jim Tittsler
Browse files

trivial modifications to wikimedia repository for WikiEducator

parent c20e59d0
# ignore OSXisms
.DS_Store
# editor debris
*~
*.swp
......@@ -2,7 +2,7 @@
$capabilities = array(
'repository/wikimedia:view' => array(
'repository/wikieducator:view' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
......
......@@ -24,6 +24,6 @@
*/
$string['keyword'] = 'Full text';
$string['pluginname'] = 'Wikimedia';
$string['wikimedia:view'] = 'View wikimedia repository';
$string['configplugin'] = 'Wikimedia repository type configuration';
$string['pluginname'] = 'WikiEducator';
$string['wikimedia:view'] = 'View WikiEducator repository';
$string['configplugin'] = 'WikiEducator repository type configuration';
......@@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
require_once('wikimedia.php');
require_once('wikieducator.php');
/**
* repository_wikimedia class
......@@ -29,16 +29,16 @@ require_once('wikimedia.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class repository_wikimedia extends repository {
class repository_wikieducator extends repository {
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
parent::__construct($repositoryid, $context, $options);
$this->keyword = optional_param('wikimedia_keyword', '', PARAM_RAW);
$this->keyword = optional_param('wikieducator_keyword', '', PARAM_RAW);
if (empty($this->keyword)) {
$this->keyword = optional_param('s', '', PARAM_RAW);
}
}
public function get_listing($path = '', $page = '') {
$client = new wikimedia;
$client = new wikieducator;
$list = array();
$list['list'] = $client->search_images($this->keyword);
$list['nologin'] = true;
......@@ -51,10 +51,10 @@ class repository_wikimedia extends repository {
// if check_login returns false,
// this function will be called to print a login form.
public function print_login() {
$keyword->label = get_string('keyword', 'repository_wikimedia').': ';
$keyword->label = get_string('keyword', 'repository_wikieducator').': ';
$keyword->id = 'input_text_keyword';
$keyword->type = 'text';
$keyword->name = 'wikimedia_keyword';
$keyword->name = 'wikieducator_keyword';
$keyword->value = '';
$form = array();
......@@ -68,7 +68,7 @@ class repository_wikimedia extends repository {
return false;
}
public function search($search_text) {
$client = new wikimedia;
$client = new wikieducator;
$search_result = array();
$search_result['list'] = $client->search_images($search_text);
return $search_result;
......
pix/icon.png

1 KB | W: | H:

pix/icon.png

912 Bytes | W: | H:

pix/icon.png
pix/icon.png
pix/icon.png
pix/icon.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -15,4 +15,4 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
$plugin->version = 2009080102;
$plugin->version = 2010081801;
<?php
// This file is part of Moodle - http://moodle.org/
// This file is derived from a part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -16,24 +16,24 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* wikimedia class
* class for communication with Wikimedia Commons API
* wikieducator class
* class for communication with WikiEducator using the MediaWiki API
*
* @author Dongsheng Cai <dongsheng@moodle.com>, Raul Kern <raunator@gmail.com>
* @author Jim Tittsler <jim@oerfoundation.org> based on the wikimedia repository by Dongsheng Cai <dongsheng@moodle.com>, Raul Kern <raunator@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
define('WIKIMEDIA_THUMBS_PER_PAGE', 24);
define('WIKIMEDIA_FILE_NS', 6);
define('WIKIMEDIA_IMAGE_SIDE_LENGTH', 1024);
define('WIKIEDUCATOR_THUMBS_PER_PAGE', 24);
define('WIKIEDUCATOR_FILE_NS', 6);
define('WIKIEDUCATOR_IMAGE_SIDE_LENGTH', 1024);
class wikimedia {
class wikieducator {
private $_conn = null;
private $_param = array();
public function __construct($url = '') {
if (empty($url)) {
$this->api = 'http://commons.wikimedia.org/w/api.php';
$this->api = 'http://wikieducator.org/api.php';
} else {
$this->api = $url;
}
......@@ -115,7 +115,7 @@ class wikimedia {
return $image_url;
} else {
$thumb_url = '';
$commons_main_dir = 'http://upload.wikimedia.org/wikipedia/commons/';
$commons_main_dir = 'http://wikieducator.org/';
if ($image_url) {
$short_path = str_replace($commons_main_dir, '', $image_url);
$extension = pathinfo($short_path, PATHINFO_EXTENSION);
......@@ -146,12 +146,12 @@ class wikimedia {
$this->_param['action'] = 'query';
$this->_param['generator'] = 'search';
$this->_param['gsrsearch'] = $keyword;
$this->_param['gsrnamespace'] = WIKIMEDIA_FILE_NS;
$this->_param['gsrlimit'] = WIKIMEDIA_THUMBS_PER_PAGE;
$this->_param['gsrnamespace'] = WIKIEDUCATOR_FILE_NS;
$this->_param['gsrlimit'] = WIKIEDUCATOR_THUMBS_PER_PAGE;
$this->_param['prop'] = 'imageinfo';
$this->_param['iiprop'] = 'url|dimensions|mime';
$this->_param['iiurlwidth'] = WIKIMEDIA_IMAGE_SIDE_LENGTH;
$this->_param['iiurlheight'] = WIKIMEDIA_IMAGE_SIDE_LENGTH;
$this->_param['iiurlwidth'] = WIKIEDUCATOR_IMAGE_SIDE_LENGTH;
$this->_param['iiurlheight'] = WIKIEDUCATOR_IMAGE_SIDE_LENGTH;
//didn't work with POST
$content = $this->_conn->get($this->api, $this->_param);
$result = unserialize($content);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment