/* The lock out time for max login attempts */
define('LOGIN_ATTEMPT_LOCKED_TIME', 60); //in minutes, default an hour, 60 minutes
+
+/* Constants for Transformable web service - @author Cindy */
+// Transformable assigned web service id to access transformable search service
+define('AT_TILE_ID', '90c3cd6f656739969847f3a99ac0f3c7');
+
+// The expire threshold of oauth access token, in second
+define('AT_TILE_OAUTH_TOKEN_EXPIRE_THRESHOLD', 93600); // in second, 24 hours
+
+// Transformable base URL
+define('AT_TILE_BASE_URL', 'http://localhost/transformable/');
+
+// The URL to the transformable web service search entry
+define('AT_TILE_SEARCH_URL', AT_TILE_BASE_URL.'search.php');
+
+// The URL to view the transformable course
+define('AT_TILE_VIEW_COURSE_URL', AT_TILE_BASE_URL.'home/course/index.php?_course_id=');
+
+// The URL to export common cartridge from transformable
+define('AT_TILE_EXPORT_URL', AT_TILE_BASE_URL.'home/imscc/ims_export.php?course_id=');
+
+// The URL to import common cartridge into transformable
+define('AT_TILE_IMPORT_URL', AT_TILE_BASE_URL.'home/ims/ims_import.php');
+
+// The URLs to perform oauth authentication
+define('AT_TILE_OAUTH_REGISTER_CONSUMER_URL', AT_TILE_BASE_URL.'oauth/register_consumer.php');
+define('AT_TILE_OAUTH_REQUEST_TOKEN_URL', AT_TILE_BASE_URL.'oauth/request_token.php');
+define('AT_TILE_OAUTH_AUTHORIZATION_URL', AT_TILE_BASE_URL.'oauth/authorization.php');
+define('AT_TILE_OAUTH_ACCESS_TOKEN_URL', AT_TILE_BASE_URL.'oauth/access_token.php');
+
+/* END - Constants for Transformable web service */
?>
) TYPE=MyISAM;
# END Adding feature of content pre-requisites
+
+# --------------------------------------------------------
+# Adding feature of oauth client
+# Table structure for table `oauth_client_servers`
+# since 1.6.5
+
+CREATE TABLE `oauth_client_servers` (
+ `oauth_server_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `oauth_server` VARCHAR(255) NOT NULL default '',
+ `consumer_key` TEXT NOT NULL ,
+ `consumer_secret` TEXT NOT NULL ,
+ `expire_threshold` INT NOT NULL default 0,
+ `create_date` datetime NOT NULL,
+ PRIMARY KEY ( `oauth_server_id` ),
+ UNIQUE INDEX idx_consumer ( `oauth_server` )
+) TYPE=MyISAM;
+
+# --------------------------------------------------------
+# Table structure for table `oauth_client_tokens`
+# since 1.6.5
+
+CREATE TABLE `oauth_client_tokens` (
+ `oauth_server_id` MEDIUMINT UNSIGNED NOT NULL,
+ `token` VARCHAR(50) NOT NULL default '',
+ `token_type` VARCHAR(50) NOT NULL NOT NULL default '',
+ `token_secret` TEXT NOT NULL,
+ `member_id` mediumint(8) unsigned NOT NULL ,
+ `assign_date` datetime NOT NULL,
+ PRIMARY KEY ( `oauth_server_id`, `token` )
+) TYPE=MyISAM;
+
+# END Adding feature of oauth client
UPDATE `modules` SET `dir_name` = '_core/imscp' WHERE `modules`.`dir_name` = '_core/content_packaging' LIMIT 1 ;
-INSERT INTO `modules` VALUES ('_core/modules', 2, 0, 8192, 0, 0);
\ No newline at end of file
+INSERT INTO `modules` VALUES ('_core/modules', 2, 0, 8192, 0, 0);
+
+# --------------------------------------------------------
+# Adding feature of oauth client
+# Table structure for table `oauth_client_servers`
+# since 1.6.5
+
+CREATE TABLE `oauth_client_servers` (
+ `oauth_server_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
+ `oauth_server` VARCHAR(255) NOT NULL default '',
+ `consumer_key` TEXT NOT NULL ,
+ `consumer_secret` TEXT NOT NULL ,
+ `expire_threshold` INT NOT NULL default 0,
+ `create_date` datetime NOT NULL,
+ PRIMARY KEY ( `oauth_server_id` ),
+ UNIQUE INDEX idx_consumer ( `oauth_server` )
+) TYPE=MyISAM;
+
+# --------------------------------------------------------
+# Table structure for table `oauth_client_tokens`
+# since 1.6.5
+
+CREATE TABLE `oauth_client_tokens` (
+ `oauth_server_id` MEDIUMINT UNSIGNED NOT NULL,
+ `token` VARCHAR(50) NOT NULL default '',
+ `token_type` VARCHAR(50) NOT NULL NOT NULL default '',
+ `token_secret` TEXT NOT NULL,
+ `member_id` mediumint(8) unsigned NOT NULL ,
+ `assign_date` datetime NOT NULL,
+ PRIMARY KEY ( `oauth_server_id`, `token` )
+) TYPE=MyISAM;
+
+# END Adding feature of oauth client
+
+# point tile.php to new location
+UPDATE `courses` SET main_links=replace(main_links, 'tile.php', 'mods/_standard/tile_search/tile.php'), home_links=replace(home_links, 'tile.php', 'mods/_standard/tile_search/tile.php');
if (isset($_REQUEST['to_tile']) && !isset($_POST['cancel'])) {
/* for TILE */
-
- /* redirect to TILE import servlet */
-
- require(AT_INCLUDE_PATH.'vitals.inc.php');
+ require_once(AT_INCLUDE_PATH.'vitals.inc.php');
if (!authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)) {
/* user can't be authenticated */
header('HTTP/1.1 404 Not Found');
echo 'Document not found.';
exit;
}
+
+ /* to avoid timing out on large files */
+ @set_time_limit(0);
+
+ // oauth authentication. Get oauth access token: $access_token_key
+ $client_callback_url = AT_BASE_HREF.'mods/_core/imscc/ims_export.php?to_tile=1'.SEP.'cid='.$cid;
+ include_once('../imscp/oauth/oauth_authenticate.php');
$m = md5(DB_PASSWORD . 'x' . ADMIN_PASSWORD . 'x' . $_SERVER['SERVER_ADDR'] . 'x' . $cid . 'x' . $_SESSION['course_id'] . 'x' . date('Ymd'));
- header('Location: '.AT_TILE_IMPORT. '?cp='.urlencode(AT_BASE_HREF. 'mods/_core/imscc/ims_export.php?cid='.$cid.'&c='.$_SESSION['course_id'].'&m='.$m));
+ $tile_import_url = AT_TILE_IMPORT_URL. '?oauth_token='.$access_token_key.'&url='.urlencode(AT_BASE_HREF. 'mods/_core/imscc/ims_export.php?cid='.$cid.'&c='.$_SESSION['course_id'].'&m='.$m);
+
+ $oauth_server_response = @file_get_contents($tile_import_url);
+
+ // handle OAUTH import response
+ foreach (explode('&', $oauth_server_response) as $rtn)
+ {
+ $rtn_pair = explode('=', $rtn);
+
+ if ($rtn_pair[0] == 'course_id') $tile_course_id = $rtn_pair[1];
+ if ($rtn_pair[0] == 'error') $error = $rtn_pair[1];
+ }
+
+ if ($tile_course_id > 0)
+ $msg->addFeedback(array('TILE_IMPORT_SUCCESS', AT_TILE_VIEW_COURSE_URL.$tile_course_id));
+ else
+ {
+ // No response from transformable, the package file might be too big
+ if (trim($error) == '') $error = _AT('tile_no_response');
+ $msg->addError(array('TILE_IMPORT_FAIL', $error));
+ }
+
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');
exit;
} else if (isset($_GET['m'])) {
/* for TILE */
if (isset($_REQUEST['to_tile']) && !isset($_POST['cancel'])) {
/* for TILE */
-
- /* redirect to TILE import servlet */
+ require(AT_INCLUDE_PATH.'vitals.inc.php');
if (!authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)) {
/* user can't be authenticated */
header('HTTP/1.1 404 Not Found');
echo 'Document not found.';
exit;
}
+ /* to avoid timing out on large files */
+ @set_time_limit(0);
+
+ // oauth authentication. Get oauth access token: $access_token_key
+ $client_callback_url = AT_BASE_HREF.'mods/_core/imscp/ims_export.php?to_tile=1'.SEP.'cid='.$cid;
+ include_once('oauth/oauth_authenticate.php');
$m = md5(DB_PASSWORD . 'x' . ADMIN_PASSWORD . 'x' . $_SERVER['SERVER_ADDR'] . 'x' . $cid . 'x' . $_SESSION['course_id'] . 'x' . date('Ymd'));
- header('Location: '.AT_TILE_IMPORT. '?cp='.urlencode(AT_BASE_HREF. 'mods/_core/imscp/ims_export.php?cid='.$cid.'&c='.$_SESSION['course_id'].'&m='.$m));
+ $tile_import_url = AT_TILE_IMPORT_URL. '?oauth_token='.$access_token_key.'&url='.urlencode(AT_BASE_HREF. 'mods/_core/imscp/ims_export.php?cid='.$cid.'&c='.$_SESSION['course_id'].'&m='.$m);
+
+ $oauth_server_response = @file_get_contents($tile_import_url);
+ // handle OAUTH import response
+ foreach (explode('&', $oauth_server_response) as $rtn)
+ {
+ $rtn_pair = explode('=', $rtn);
+
+ if ($rtn_pair[0] == 'course_id') $tile_course_id = $rtn_pair[1];
+ if ($rtn_pair[0] == 'error') $error = $rtn_pair[1];
+ }
+
+ if ($tile_course_id > 0)
+ $msg->addFeedback(array('TILE_IMPORT_SUCCESS', AT_TILE_VIEW_COURSE_URL.$tile_course_id));
+ else
+ {
+ // No response from transformable, the package file might be too big
+ if (trim($error) == '') $error = _AT('tile_no_response');
+ $msg->addError(array('TILE_IMPORT_FAIL', $error));
+ }
+
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');
exit;
} else if (isset($_GET['m'])) {
/* for TILE */
if ($msg->containsErrors()) {
if (isset($_GET['tile'])) {
- header('Location: '.$_base_path.'tools/tile/index.php');
+ header('Location: '.$_base_path.'mods/_standard/tile_search/index.php');
} else {
header('Location: index.php');
}
if ($msg->containsErrors()) {
if (isset($_GET['tile'])) {
- header('Location: '.$_base_path.'tools/tile/index.php');
+ header('Location: '.$_base_path.'mods/_standard/tile_search/index.php');
} else {
header('Location: index.php');
}
clr_dir($import_path);
if (isset($_GET['tile'])) {
- header('Location: '.$_base_path.'tools/tile/index.php');
+ header('Location: '.$_base_path.'mods/_standard/tile_search/index.php');
} else {
header('Location: index.php');
}
clr_dir($import_path);
if (isset($_GET['tile'])) {
- header('Location: '.$_base_path.'tools/tile/index.php');
+ header('Location: '.$_base_path.'mods/_standard/tile_search/index.php');
} else {
header('Location: index.php');
}
// Check if there are any errors during parsing.
if ($msg->containsErrors()) {
if (isset($_GET['tile'])) {
- header('Location: '.$_base_path.'tools/tile/index.php');
+ header('Location: '.$_base_path.'mods/_standard/tile_search/index.php');
} else {
header('Location: index.php');
}
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
}
if ($_GET['tile']) {
- header('Location: '.AT_BASE_HREF.'tools/tile/index.php');
+ header('Location: '.AT_BASE_HREF.'mods/_standard/tile_search/index.php');
} else {
header('Location: ./index.php?cid='.intval($_POST['cid']));
}
<label for="to_cc"><?php echo _AT('common_cartridge'); ?> </label>
</div>
<div class="row">
- <!--<input type="checkbox" name="to_tile" id="to_tile" value="1" />
- <label for="to_tile"><?php echo _AT('tile_export'); ?></label> <br /> -->
+ <input type="checkbox" name="to_tile" id="to_tile" value="1" />
+ <label for="to_tile"><?php echo _AT('tile_export'); ?></label> <br />
<input type="checkbox" name="to_a4a" id="to_a4a" value="1" />
<label for="to_a4a"><?php echo _AT('a4a_export'); ?></label>
</div>
--- /dev/null
+<?php
+// Modified from http://oauth.googlecode.com/svn/code/php/
+
+// vim: foldmethod=marker
+if (!defined('AT_INCLUDE_PATH')) exit;
+
+/* Generic exception class
+ */
+class OAuthException extends Exception {
+ function __construct($exception)
+ {
+ echo 'error='.urlencode($exception);
+ exit;
+ }
+}
+
+class OAuthConsumer {
+ public $key;
+ public $secret;
+
+ function __construct($key, $secret, $callback_url=NULL) {
+ // check if the consumer is registered
+// global $db;
+// $oAuthServerConsumersDAO = new OAuthServerConsumersDAO();
+// $consumer = $oAuthServerConsumersDAO->getByConsumerKeyAndSecret($key, $secret);
+//
+// if (!is_array($consumer)) throw new OAuthException('Consumer is not registered.');
+// else {
+ $this->key = $key;
+ $this->secret = $secret;
+ $this->callback_url = $callback_url;
+// }
+ }
+
+ function __toString() {
+ return "OAuthConsumer[key=$this->key,secret=$this->secret]";
+ }
+}
+
+class OAuthToken {
+ // access tokens and request tokens
+ public $key;
+ public $secret;
+
+ /**
+ * key = the token
+ * secret = the token secret
+ */
+ function __construct($key, $secret) {
+ $this->key = $key;
+ $this->secret = $secret;
+ }
+
+ /**
+ * generates the basic string serialization of a token that a server
+ * would respond to request_token and access_token calls with
+ */
+ function to_string() {
+ return "oauth_token=" .
+ OAuthUtil::urlencode_rfc3986($this->key) .
+ "&oauth_token_secret=" .
+ OAuthUtil::urlencode_rfc3986($this->secret);
+ }
+
+ function __toString() {
+ return $this->to_string();
+ }
+}
+
+class OAuthSignatureMethod {
+ public function check_signature(&$request, $consumer, $token, $signature) {
+ $built = $this->build_signature($request, $consumer, $token);
+ return $built == $signature;
+ }
+}
+
+class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
+ function get_name() {
+ return "HMAC-SHA1";
+ }
+
+ public function build_signature($request, $consumer, $token) {
+ $base_string = $request->get_signature_base_string();
+ $request->base_string = $base_string;
+
+ $key_parts = array(
+ $consumer->secret,
+ ($token) ? $token->secret : ""
+ );
+
+ $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
+ $key = implode('&', $key_parts);
+
+ return base64_encode(hash_hmac('sha1', $base_string, $key, true));
+ }
+}
+
+class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
+ public function get_name() {
+ return "PLAINTEXT";
+ }
+
+ public function build_signature($request, $consumer, $token) {
+ $sig = array(
+ OAuthUtil::urlencode_rfc3986($consumer->secret)
+ );
+
+ if ($token) {
+ array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
+ } else {
+ array_push($sig, '');
+ }
+
+ $raw = implode("&", $sig);
+ // for debug purposes
+ $request->base_string = $raw;
+
+ return OAuthUtil::urlencode_rfc3986($raw);
+ }
+}
+
+class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
+ public function get_name() {
+ return "RSA-SHA1";
+ }
+
+ protected function fetch_public_cert(&$request) {
+ // not implemented yet, ideas are:
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
+ // (2) fetch via http using a url provided by the requester
+ // (3) some sort of specific discovery code based on request
+ //
+ // either way should return a string representation of the certificate
+ throw Exception("fetch_public_cert not implemented");
+ }
+
+ protected function fetch_private_cert(&$request) {
+ // not implemented yet, ideas are:
+ // (1) do a lookup in a table of trusted certs keyed off of consumer
+ //
+ // either way should return a string representation of the certificate
+ throw Exception("fetch_private_cert not implemented");
+ }
+
+ public function build_signature(&$request, $consumer, $token) {
+ $base_string = $request->get_signature_base_string();
+ $request->base_string = $base_string;
+
+ // Fetch the private key cert based on the request
+ $cert = $this->fetch_private_cert($request);
+
+ // Pull the private key ID from the certificate
+ $privatekeyid = openssl_get_privatekey($cert);
+
+ // Sign using the key
+ $ok = openssl_sign($base_string, $signature, $privatekeyid);
+
+ // Release the key resource
+ openssl_free_key($privatekeyid);
+
+ return base64_encode($signature);
+ }
+
+ public function check_signature(&$request, $consumer, $token, $signature) {
+ $decoded_sig = base64_decode($signature);
+
+ $base_string = $request->get_signature_base_string();
+
+ // Fetch the public key cert based on the request
+ $cert = $this->fetch_public_cert($request);
+
+ // Pull the public key ID from the certificate
+ $publickeyid = openssl_get_publickey($cert);
+
+ // Check the computed signature against the one passed in the query
+ $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
+
+ // Release the key resource
+ openssl_free_key($publickeyid);
+
+ return $ok == 1;
+ }
+}
+
+class OAuthRequest {
+ private $parameters;
+ private $http_method;
+ private $http_url;
+ // for debug purposes
+ public $base_string;
+ public static $version = '1.0';
+ public static $POST_INPUT = 'php://input';
+
+ function __construct($http_method, $http_url, $parameters=NULL) {
+ @$parameters or $parameters = array();
+ $this->parameters = $parameters;
+ $this->http_method = $http_method;
+ $this->http_url = $http_url;
+ }
+
+
+ /**
+ * attempt to build up a request from what was passed to the server
+ */
+ public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
+ $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
+ ? 'http'
+ : 'https';
+ @$http_url or $http_url = $scheme .
+ '://' . $_SERVER['HTTP_HOST'] .
+ ':' .
+ $_SERVER['SERVER_PORT'] .
+ $_SERVER['REQUEST_URI'];
+ @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
+
+ // We weren't handed any parameters, so let's find the ones relevant to
+ // this request.
+ // If you run XML-RPC or similar you should use this to provide your own
+ // parsed parameter-list
+ if (!$parameters) {
+ // Find request headers
+ $request_headers = OAuthUtil::get_headers();
+
+ // Parse the query-string to find GET parameters
+ $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
+
+ // It's a POST request of the proper content-type, so parse POST
+ // parameters and add those overriding any duplicates from GET
+ if ($http_method == "POST"
+ && @strstr($request_headers["Content-Type"],
+ "application/x-www-form-urlencoded")
+ ) {
+ $post_data = OAuthUtil::parse_parameters(
+ file_get_contents(self::$POST_INPUT)
+ );
+ $parameters = array_merge($parameters, $post_data);
+ }
+
+ // We have a Authorization-header with OAuth data. Parse the header
+ // and add those overriding any duplicates from GET or POST
+ if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
+ $header_parameters = OAuthUtil::split_header(
+ $request_headers['Authorization']
+ );
+ $parameters = array_merge($parameters, $header_parameters);
+ }
+
+ }
+
+ return new OAuthRequest($http_method, $http_url, $parameters);
+ }
+
+ /**
+ * pretty much a helper function to set up the request
+ */
+ public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
+ @$parameters or $parameters = array();
+ $defaults = array("oauth_version" => OAuthRequest::$version,
+ "oauth_nonce" => OAuthRequest::generate_nonce(),
+ "oauth_timestamp" => OAuthRequest::generate_timestamp(),
+ "oauth_consumer_key" => $consumer->key);
+ if ($token)
+ $defaults['oauth_token'] = $token->key;
+
+ $parameters = array_merge($defaults, $parameters);
+
+ return new OAuthRequest($http_method, $http_url, $parameters);
+ }
+
+ public function set_parameter($name, $value, $allow_duplicates = true) {
+ if ($allow_duplicates && isset($this->parameters[$name])) {
+ // We have already added parameter(s) with this name, so add to the list
+ if (is_scalar($this->parameters[$name])) {
+ // This is the first duplicate, so transform scalar (string)
+ // into an array so we can add the duplicates
+ $this->parameters[$name] = array($this->parameters[$name]);
+ }
+
+ $this->parameters[$name][] = $value;
+ } else {
+ $this->parameters[$name] = $value;
+ }
+ }
+
+ public function get_parameter($name) {
+ return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
+ }
+
+ public function get_parameters() {
+ return $this->parameters;
+ }
+
+ public function unset_parameter($name) {
+ unset($this->parameters[$name]);
+ }
+
+ /**
+ * The request parameters, sorted and concatenated into a normalized string.
+ * @return string
+ */
+ public function get_signable_parameters() {
+ // Grab all parameters
+ $params = $this->parameters;
+
+ // Remove oauth_signature if present
+ // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
+ if (isset($params['oauth_signature'])) {
+ unset($params['oauth_signature']);
+ }
+
+ return OAuthUtil::build_http_query($params);
+ }
+
+ /**
+ * Returns the base string of this request
+ *
+ * The base string defined as the method, the url
+ * and the parameters (normalized), each urlencoded
+ * and the concated with &.
+ */
+ public function get_signature_base_string() {
+ $parts = array(
+ $this->get_normalized_http_method(),
+ $this->get_normalized_http_url(),
+ $this->get_signable_parameters()
+ );
+
+ $parts = OAuthUtil::urlencode_rfc3986($parts);
+
+ return implode('&', $parts);
+ }
+
+ /**
+ * just uppercases the http method
+ */
+ public function get_normalized_http_method() {
+ return strtoupper($this->http_method);
+ }
+
+ /**
+ * parses the url and rebuilds it to be
+ * scheme://host/path
+ */
+ public function get_normalized_http_url() {
+ $parts = parse_url($this->http_url);
+
+ $port = @$parts['port'];
+ $scheme = $parts['scheme'];
+ $host = $parts['host'];
+ $path = @$parts['path'];
+
+ $port or $port = ($scheme == 'https') ? '443' : '80';
+
+ if (($scheme == 'https' && $port != '443')
+ || ($scheme == 'http' && $port != '80')) {
+ $host = "$host:$port";
+ }
+ return "$scheme://$host$path";
+ }
+
+ /**
+ * builds a url usable for a GET request
+ */
+ public function to_url() {
+ $post_data = $this->to_postdata();
+ $out = $this->get_normalized_http_url();
+ if ($post_data) {
+ $out .= '?'.$post_data;
+ }
+ return $out;
+ }
+
+ /**
+ * builds the data one would send in a POST request
+ */
+ public function to_postdata() {
+ return OAuthUtil::build_http_query($this->parameters);
+ }
+
+ /**
+ * builds the Authorization: header
+ */
+ public function to_header() {
+ $out ='Authorization: OAuth realm=""';
+ $total = array();
+ foreach ($this->parameters as $k => $v) {
+ if (substr($k, 0, 5) != "oauth") continue;
+ if (is_array($v)) {
+ throw new OAuthException('Arrays not supported in headers');
+ }
+ $out .= ',' .
+ OAuthUtil::urlencode_rfc3986($k) .
+ '="' .
+ OAuthUtil::urlencode_rfc3986($v) .
+ '"';
+ }
+ return $out;
+ }
+
+ public function __toString() {
+ return $this->to_url();
+ }
+
+
+ public function sign_request($signature_method, $consumer, $token) {
+ $this->set_parameter(
+ "oauth_signature_method",
+ $signature_method->get_name(),
+ false
+ );
+ $signature = $this->build_signature($signature_method, $consumer, $token);
+ $this->set_parameter("oauth_signature", $signature, false);
+ }
+
+ public function build_signature($signature_method, $consumer, $token) {
+ $signature = $signature_method->build_signature($this, $consumer, $token);
+ return $signature;
+ }
+
+ /**
+ * util function: current timestamp
+ */
+ private static function generate_timestamp() {
+ return time();
+ }
+
+ /**
+ * util function: current nonce
+ */
+ private static function generate_nonce() {
+ $mt = microtime();
+ $rand = mt_rand();
+
+ return md5($mt . $rand); // md5s look nicer than numbers
+ }
+}
+
+class OAuthServer {
+ protected $timestamp_threshold; // in seconds, five minutes
+ protected $version = 1.0; // hi blaine
+ protected $signature_methods = array();
+
+ protected $data_store;
+
+ function __construct($data_store) {
+ $this->data_store = $data_store;
+ }
+
+ public function add_signature_method($signature_method) {
+ $this->signature_methods[$signature_method->get_name()] =
+ $signature_method;
+ }
+
+ // high level functions
+
+ /**
+ * process a request_token request
+ * returns the request token on success
+ */
+ public function fetch_request_token(&$request) {
+ $this->get_version($request);
+
+ $consumer = $this->get_consumer($request);
+
+ // no token required for the initial token request
+ $token = NULL;
+
+ $this->check_signature($request, $consumer, $token);
+
+ $new_token = $this->data_store->new_request_token($consumer);
+
+ return $new_token;
+ }
+
+ /**
+ * process an access_token request
+ * returns the access token on success
+ */
+ public function fetch_access_token(&$request) {
+ $this->get_version($request);
+
+ $consumer = $this->get_consumer($request);
+
+ // requires authorized request token
+ $token = $this->get_token($request, $consumer, "request");
+
+ $this->check_signature($request, $consumer, $token);
+
+ if ($this->data_store->lookup_authenticate_request_token($token))
+ {
+ $new_token = $this->data_store->new_access_token($token, $consumer);
+ return $new_token;
+ }
+ else
+ throw new OAuthException("User authenticate is not performed.");
+ }
+
+ /**
+ * verify an api call, checks all the parameters
+ */
+ public function verify_request(&$request) {
+ $this->get_version($request);
+ $consumer = $this->get_consumer($request);
+ $token = $this->get_token($request, $consumer, "access");
+ $this->check_signature($request, $consumer, $token);
+ return array($consumer, $token);
+ }
+
+ // Internals from here
+ /**
+ * version 1
+ */
+ private function get_version(&$request) {
+ $version = $request->get_parameter("oauth_version");
+ if (!$version) {
+ $version = 1.0;
+ }
+ if ($version && $version != $this->version) {
+ throw new OAuthException("OAuth version '$version' not supported");
+ }
+ return $version;
+ }
+
+ /**
+ * figure out the signature with some defaults
+ */
+ private function get_signature_method(&$request) {
+ $signature_method =
+ @$request->get_parameter("oauth_signature_method");
+ if (!$signature_method) {
+ $signature_method = "PLAINTEXT";
+ }
+ if (!in_array($signature_method,
+ array_keys($this->signature_methods))) {
+ throw new OAuthException(
+ "Signature method '$signature_method' not supported " .
+ "try one of the following: " .
+ implode(", ", array_keys($this->signature_methods))
+ );
+ }
+ return $this->signature_methods[$signature_method];
+ }
+
+ /**
+ * try to find the consumer for the provided request's consumer key
+ */
+ private function get_consumer(&$request) {
+ $consumer_key = @$request->get_parameter("oauth_consumer_key");
+ if (!$consumer_key) {
+ throw new OAuthException("Invalid consumer key");
+ }
+
+ $consumer = $this->data_store->lookup_consumer($consumer_key);
+ if (!$consumer) {
+ throw new OAuthException("Invalid consumer");
+ }
+
+ return $consumer;
+ }
+
+ /**
+ * try to find the token for the provided request's token key
+ */
+ private function get_token(&$request, $consumer, $token_type="access") {
+ $token_field = @$request->get_parameter('oauth_token');
+ $token = $this->data_store->lookup_token(
+ $consumer, $token_type, $token_field
+ );
+ if (!$token) {
+ throw new OAuthException("Invalid $token_type token: $token_field");
+ }
+ return $token;
+ }
+
+ /**
+ * all-in-one function to check the signature on a request
+ * should guess the signature method appropriately
+ */
+ private function check_signature(&$request, $consumer, $token) {
+ // this should probably be in a different method
+ $timestamp = @$request->get_parameter('oauth_timestamp');
+ $nonce = @$request->get_parameter('oauth_nonce');
+
+ $this->timestamp_threshold = $this->data_store->lookup_expire_threshold($consumer);
+
+ $this->check_timestamp($timestamp);
+ $this->check_nonce($consumer, $token, $nonce, $timestamp);
+
+ $signature_method = $this->get_signature_method($request);
+
+ $signature = $request->get_parameter('oauth_signature');
+ $valid_sig = $signature_method->check_signature(
+ $request,
+ $consumer,
+ $token,
+ $signature
+ );
+
+ if (!$valid_sig) {
+ throw new OAuthException("Invalid signature");
+ }
+ }
+
+ /**
+ * check that the timestamp is new enough
+ */
+ private function check_timestamp($timestamp) {
+ // verify that timestamp is recentish
+ // when threshold is 0, never expire
+ $now = time();
+ if ($this->timestamp_threshold <> 0 && $now - $timestamp > $this->timestamp_threshold) {
+ throw new OAuthException(
+ "Expired timestamp, yours $timestamp, ours $now"
+ );
+ }
+ }
+
+ /**
+ * check that the nonce is not repeated
+ */
+ private function check_nonce($consumer, $token, $nonce, $timestamp) {
+ // verify that the nonce is uniqueish
+ $found = $this->data_store->lookup_nonce(
+ $consumer,
+ $token,
+ $nonce,
+ $timestamp
+ );
+ if ($found) {
+ throw new OAuthException("Nonce already used: $nonce");
+ }
+ }
+
+}
+
+class OAuthDataStore {
+ function lookup_consumer($consumer_key) {
+ // implement me
+ }
+
+ function lookup_token($consumer, $token_type, $token) {
+ // implement me
+ }
+
+ function lookup_nonce($consumer, $token, $nonce, $timestamp) {
+ // implement me
+ }
+
+ function new_request_token($consumer) {
+ // return a new token attached to this consumer
+ }
+
+ function new_access_token($token, $consumer) {
+ // return a new access token attached to this consumer
+ // for the user associated with this token if the request token
+ // is authorized
+ // should also invalidate the request token
+ }
+
+}
+
+class OAuthUtil {
+ public static function urlencode_rfc3986($input) {
+ if (is_array($input)) {
+ return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
+ } else if (is_scalar($input)) {
+ return str_replace(
+ '+',
+ ' ',
+ str_replace('%7E', '~', rawurlencode($input))
+ );
+ } else {
+ return '';
+ }
+}
+
+
+ // This decode function isn't taking into consideration the above
+ // modifications to the encoding process. However, this method doesn't
+ // seem to be used anywhere so leaving it as is.
+ public static function urldecode_rfc3986($string) {
+ return urldecode($string);
+ }
+
+ // Utility function for turning the Authorization: header into
+ // parameters, has to do some unescaping
+ // Can filter out any non-oauth parameters if needed (default behaviour)
+ public static function split_header($header, $only_allow_oauth_parameters = true) {
+ $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
+ $offset = 0;
+ $params = array();
+ while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
+ $match = $matches[0];
+ $header_name = $matches[2][0];
+ $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
+ if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
+ $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
+ }
+ $offset = $match[1] + strlen($match[0]);
+ }
+
+ if (isset($params['realm'])) {
+ unset($params['realm']);
+ }
+
+ return $params;
+ }
+
+ // helper to try to sort out headers for people who aren't running apache
+ public static function get_headers() {
+ if (function_exists('apache_request_headers')) {
+ // we need this to get the actual Authorization: header
+ // because apache tends to tell us it doesn't exist
+ return apache_request_headers();
+ }
+ // otherwise we don't have apache and are just going to have to hope
+ // that $_SERVER actually contains what we need
+ $out = array();
+ foreach ($_SERVER as $key => $value) {
+ if (substr($key, 0, 5) == "HTTP_") {
+ // this is chaos, basically it is just there to capitalize the first
+ // letter of every word that is not an initial HTTP and strip HTTP
+ // code from przemek
+ $key = str_replace(
+ " ",
+ "-",
+ ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
+ );
+ $out[$key] = $value;
+ }
+ }
+ return $out;
+ }
+
+ // This function takes a input like a=b&a=c&d=e and returns the parsed
+ // parameters like this
+ // array('a' => array('b','c'), 'd' => 'e')
+ public static function parse_parameters( $input ) {
+ if (!isset($input) || !$input) return array();
+
+ $pairs = explode('&', $input);
+
+ $parsed_parameters = array();
+ foreach ($pairs as $pair) {
+ $split = explode('=', $pair, 2);
+ $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
+ $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
+
+ if (isset($parsed_parameters[$parameter])) {
+ // We have already recieved parameter(s) with this name, so add to the list
+ // of parameters with this name
+
+ if (is_scalar($parsed_parameters[$parameter])) {
+ // This is the first duplicate, so transform scalar (string) into an array
+ // so we can add the duplicates
+ $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
+ }
+
+ $parsed_parameters[$parameter][] = $value;
+ } else {
+ $parsed_parameters[$parameter] = $value;
+ }
+ }
+ return $parsed_parameters;
+ }
+
+ public static function build_http_query($params) {
+ if (!$params) return '';
+
+ // Urlencode both keys and values
+ $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
+ $values = OAuthUtil::urlencode_rfc3986(array_values($params));
+ $params = array_combine($keys, $values);
+
+ // Parameters are sorted by name, using lexicographical byte value ordering.
+ // Ref: Spec: 9.1.1 (1)
+ uksort($params, 'strcmp');
+
+ $pairs = array();
+ foreach ($params as $parameter => $value) {
+ if (is_array($value)) {
+ // If two or more parameters share the same name, they are sorted by their value
+ // Ref: Spec: 9.1.1 (1)
+ natsort($value);
+ foreach ($value as $duplicate_value) {
+ $pairs[] = $parameter . '=' . $duplicate_value;
+ }
+ } else {
+ $pairs[] = $parameter . '=' . $value;
+ }
+ }
+ // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
+ // Each name-value pair is separated by an '&' character (ASCII code 38)
+ return implode('&', $pairs);
+ }
+}
+
+?>
--- /dev/null
+<?php
+/****************************************************************/
+/* ATutor */
+/****************************************************************/
+/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
+/* Adaptive Technology Resource Centre / University of Toronto */
+/* http://atutor.ca */
+/* */
+/* 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. */
+/****************************************************************/
+// $Id: OAuthUtility.class.php 8901 2009-11-11 19:10:19Z cindy $
+
+/**
+* OAuth Utility functions
+* @access public
+* @author Cindy Qi Li
+*/
+
+if (!defined('AT_INCLUDE_PATH')) exit;
+
+class OAuthUtility {
+
+ /**
+ * This function checks whether the given URL is accessible.
+ * @access public
+ * @param URL
+ * @return true if accessible, otherwise, false
+ * @author Cindy Qi Li
+ */
+ public static function isAccessible($URL)
+ {
+ if (!@file_get_contents($URL))
+ return false;
+ return true;
+ }
+
+ /**
+ * This function checks whether the last access token for the current user
+ * is expired. If not, return it, otherwise, return empty.
+ * @access public
+ * @param none
+ * @return the access token if it's not expired, otherwise, empty.
+ * @author Cindy Qi Li
+ */
+ public static function getUnexpiredAccessToken()
+ {
+ global $db;
+
+ $sql = "SELECT token,
+ unix_timestamp(now()) now_timestamp,
+ unix_timestamp(addtime(oct.assign_date, ocs.expire_threshold)) expire_timestamp
+ FROM ".TABLE_PREFIX."oauth_client_servers ocs, ".TABLE_PREFIX."oauth_client_tokens oct
+ WHERE ocs.oauth_server_id=oct.oauth_server_id
+ AND oct.member_id=".$_SESSION['member_id']."
+ AND oct.token_type='access'
+ ORDER BY oct.assign_date DESC";
+
+ $result = mysql_query($sql, $db);
+
+ if (mysql_num_rows($result) == 0) return '';
+ else
+ {
+ $row = mysql_fetch_assoc($result);
+
+ if ($row['now_timestamp'] < $row['expire_timestamp'])
+ return $row['token'];
+ else
+ return '';
+ }
+ }
+}
+?>
--- /dev/null
+<?php\r
+/****************************************************************/\r
+/* ATutor */\r
+/****************************************************************/\r
+/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */\r
+/* Adaptive Technology Resource Centre / University of Toronto */\r
+/* http://atutor.ca */\r
+/* */\r
+/* This program is free software. You can redistribute it and/or*/\r
+/* modify it under the terms of the GNU General Public License */\r
+/* as published by the Free Software Foundation. */\r
+/****************************************************************/\r
+// $Id: index.php 8901 2009-11-11 19:10:19Z cindy $\r
+\r
+/**\r
+ * This script is called by mods/_core/imscp/ims_export.php\r
+ * to export course content out of ATutor and import into\r
+ * transformable.\r
+ * This script also used as a callback endpoint for Tansformable\r
+ * OAuth authentication.\r
+ * @access public\r
+ * @input 1. $client_callback_url is required\r
+ * 2. when called back by Transformable OAuth authentication, \r
+ * a request token var 'oauth_token' is required.\r
+ * @output $access_token_key, to import into transformable\r
+ */\r
+\r
+if (!defined('AT_INCLUDE_PATH')) \r
+{ // when the script is called back by oauth server, \r
+ define('AT_INCLUDE_PATH', '../../../../include/');\r
+ require_once(AT_INCLUDE_PATH.'vitals.inc.php');\r
+}\r
+\r
+require_once('OAuthUtility.class.php');\r
+require_once("OAuth.php");\r
+global $msg;\r
+\r
+// check whether the transformable url is accessible\r
+if (!OAuthUtility::isAccessible(AT_TILE_OAUTH_REGISTER_CONSUMER_URL))\r
+{\r
+ $msg->addError(array('TILE_AUTHENTICATION_FAIL', _AT('tile_not_accessible')));\r
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');\r
+ exit;\r
+}\r
+\r
+// check whether the last access token has expired. If not, return it, otherwise, get a new access token.\r
+// skip this step when this script is called by oauth server callback\r
+if (isset($_SESSION['member_id']))\r
+ $access_token_key = OAuthUtility::getUnexpiredAccessToken();\r
+\r
+if ($access_token_key == '')\r
+{ \r
+ // initialize basic variables\r
+ $sig_method = new OAuthSignatureMethod_HMAC_SHA1(); // use HMAC signature method as default\r
+ \r
+ if (!isset($_GET['oauth_token'])) // before oauth server authentication, get request token from oauth server\r
+ {\r
+ // 1. register consumer\r
+ $sql = "SELECT * FROM ".TABLE_PREFIX."oauth_client_servers \r
+ WHERE oauth_server='".mysql_real_escape_string(AT_TILE_BASE_URL)."'";\r
+ $result = mysql_query($sql, $db);\r
+ \r
+ if (mysql_num_rows($result) == 0)\r
+ {\r
+ $register_consumer_url = AT_TILE_OAUTH_REGISTER_CONSUMER_URL.'?consumer='.urlencode(AT_BASE_HREF).'&expire='.AT_TILE_OAUTH_TOKEN_EXPIRE_THRESHOLD;\r
+ $oauth_server_response = file_get_contents($register_consumer_url);\r
+ \r
+// debug('register consumer - request: '.$register_consumer_url);\r
+// debug('register consumer - OAUTH response: '.$oauth_server_response);\r
+ \r
+ // handle OAUTH response on register consumer\r
+ foreach (explode('&', $oauth_server_response) as $rtn)\r
+ {\r
+ $rtn_pair = explode('=', $rtn);\r
+ \r
+ if ($rtn_pair[0] == 'consumer_key') $consumer_key = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'consumer_secret') $consumer_secret = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'expire') $expire_threshold = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'error') $error = $rtn_pair[1];\r
+ }\r
+ \r
+ if ($error <> '')\r
+ {\r
+ $msg->addError(array('TILE_AUTHENTICATION_FAIL', $error));\r
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');\r
+ exit;\r
+ }\r
+ else\r
+ {\r
+ $sql = "INSERT INTO ".TABLE_PREFIX."oauth_client_servers\r
+ (oauth_server, consumer_key, consumer_secret, expire_threshold, create_date)\r
+ VALUES ('".mysql_real_escape_string(AT_TILE_BASE_URL)."', '".$consumer_key."',\r
+ '".$consumer_secret."', ".$expire_threshold.", now())";\r
+ $result = mysql_query($sql, $db);\r
+ $oauth_server_id = mysql_insert_id();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ $row = mysql_fetch_assoc($result);\r
+ $oauth_server_id = $row['oauth_server_id'];\r
+ $consumer_key = $row['consumer_key'];\r
+ $consumer_secret = $row['consumer_secret'];\r
+ $expire_threshold = $row['expire_threshold'];\r
+ }\r
+ $consumer = new OAuthConsumer($consumer_key, $consumer_secret, $client_callback_url);\r
+ \r
+ // debug('consumer: '.$consumer);\r
+ // debug('--- END OF REGISTERING CONSUMER ---');\r
+ \r
+ // 2. get request token\r
+ $req_req = OAuthRequest::from_consumer_and_token($consumer, NULL, "GET", AT_TILE_OAUTH_REQUEST_TOKEN_URL);\r
+ $req_req->sign_request($sig_method, $consumer, NULL);\r
+ \r
+ $oauth_server_response = file_get_contents($req_req);\r
+ \r
+ // debug('request token - request: '."\n".$req_req);\r
+ // debug('request token - response: '."\n".$oauth_server_response);\r
+ \r
+ // handle OAUTH request token response\r
+ foreach (explode('&', $oauth_server_response) as $rtn)\r
+ {\r
+ $rtn_pair = explode('=', $rtn);\r
+ \r
+ if ($rtn_pair[0] == 'oauth_token') $request_token_key = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'oauth_token_secret') $request_token_secret = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'error') $error = $rtn_pair[1];\r
+ }\r
+ \r
+ if ($error == '' && strlen($request_token_key) > 0 && strlen($request_token_secret) > 0)\r
+ {\r
+ $sql = "INSERT INTO ".TABLE_PREFIX."oauth_client_tokens\r
+ (oauth_server_id, token, token_type, token_secret, member_id, assign_date)\r
+ VALUES (".$oauth_server_id.", '".$request_token_key."', 'request',\r
+ '".$request_token_secret."', ".$_SESSION['member_id'].", now())";\r
+ $result = mysql_query($sql, $db);\r
+ }\r
+ else\r
+ {\r
+ $msg->addError(array('TILE_AUTHENTICATION_FAIL', $error));\r
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');\r
+ exit;\r
+ }\r
+ \r
+ $request_token = new OAuthToken($request_token_key, $request_token_secret);\r
+ \r
+ // debug('--- END OF REQESTING REQUEST TOKEN ---');\r
+ \r
+ // 3. authorization\r
+ $auth_req = AT_TILE_OAUTH_AUTHORIZATION_URL.'?oauth_token='.$request_token_key.'&oauth_callback='.urlencode($client_callback_url);\r
+ header('Location: '.$auth_req);\r
+ exit;\r
+ }\r
+ else // authenticated\r
+ {\r
+ // get consumer id by request token\r
+ $sql = "SELECT ocs.oauth_server_id, ocs.consumer_key, ocs.consumer_secret, \r
+ ocs.expire_threshold, oct.member_id, oct.token_secret\r
+ FROM ".TABLE_PREFIX."oauth_client_servers ocs, ".TABLE_PREFIX."oauth_client_tokens oct \r
+ WHERE ocs.oauth_server_id = oct.oauth_server_id\r
+ AND oct.token = '".$_GET['oauth_token']."'\r
+ AND token_type='request'";\r
+ \r
+ $result = mysql_query($sql, $db);\r
+ if (mysql_num_rows($result)==0)\r
+ {\r
+ $msg->addError(array('TILE_AUTHENTICATION_FAIL', _AT('wrong_request_token')));\r
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');\r
+ exit;\r
+ }\r
+ \r
+ $row = mysql_fetch_assoc($result); \r
+ \r
+ $consumer = new OAuthConsumer($row['consumer_key'], $row['consumer_secret'], $client_callback_url);\r
+ $request_token = new OAuthToken($_GET['oauth_token'], $row['token_secret']);\r
+ \r
+ // 4. get access token\r
+ $access_req = OAuthRequest::from_consumer_and_token($consumer, $request_token, "GET", AT_TILE_OAUTH_ACCESS_TOKEN_URL);\r
+ $access_req->sign_request($sig_method, $consumer, NULL);\r
+ \r
+ $oauth_server_response = file_get_contents($access_req);\r
+ \r
+ // debug('access token - request: '."\n".$access_req);\r
+ // debug('access token - response: '."\n".$oauth_server_response);\r
+ \r
+ // handle OAUTH response on access token\r
+ foreach (explode('&', $oauth_server_response) as $rtn)\r
+ {\r
+ $rtn_pair = explode('=', $rtn);\r
+ \r
+ if ($rtn_pair[0] == 'oauth_token') $access_token_key = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'oauth_token_secret') $access_token_secret = $rtn_pair[1];\r
+ if ($rtn_pair[0] == 'error') $error = $rtn_pair[1];\r
+ }\r
+ \r
+ if ($error == '' && strlen($access_token_key) > 0 && strlen($access_token_secret) > 0)\r
+ {\r
+ // insert access token\r
+ $sql = "INSERT INTO ".TABLE_PREFIX."oauth_client_tokens\r
+ (oauth_server_id, token, token_type, token_secret, member_id, assign_date)\r
+ VALUES (".$row['oauth_server_id'].", '".$access_token_key."', 'access',\r
+ '".$access_token_secret."', ".$row['member_id'].", now())";\r
+ $result = mysql_query($sql, $db);\r
+ \r
+ // delete request_token\r
+ $sql = "DELETE FROM ".TABLE_PREFIX."oauth_client_tokens\r
+ WHERE token = '".$_GET['oauth_token']."'\r
+ AND token_type='request'";\r
+ $result = mysql_query($sql, $db);\r
+ }\r
+ else\r
+ {\r
+ $msg->addError(array('TILE_AUTHENTICATION_FAIL', $error));\r
+ header('Location: '.AT_BASE_HREF.'mods/_core/imscp/index.php');\r
+ exit;\r
+ }\r
+ }\r
+}\r
+//debug('access token key: '.$access_token_key);\r
+// debug('--- END OF REQESTING ACCESS TOKEN ---');\r
+// exit;\r
+?>
\ No newline at end of file
function getLanguage($code, $charset = '') {
if (!$charset) {
if (isset($this->availableLanguages[$code])) {
- return current($this->availableLanguages[$code]);
+ if (is_array($this->availableLanguages[$code]))
+ foreach ($this->availableLanguages[$code] as $language)
+ return $language;
+// return current($this->availableLanguages[$code]);
} else {
+ debug('return false');
return FALSE;
}
}
/****************************************************************/
// $Id: import.php 7208 2008-01-09 16:07:24Z greg $
-define('AT_INCLUDE_PATH', '../../include/');
+define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
authenticate(AT_PRIV_CONTENT);
?>
-<form name="form1" method="post" action="tools/ims/ims_import.php?tile=1" onsubmit="openWindow('<?php echo AT_BASE_HREF; ?>tools/prog.php?tile=1');">
- <input type="hidden" name="url" value="<?php echo AT_TILE_EXPORT; ?>?cp=<?php echo $_GET['cp']; ?>" />
+<form name="form1" method="post" action="mods/_core/imscp/ims_import.php?tile=1" onsubmit="openWindow('<?php echo AT_BASE_HREF; ?>tools/prog.php?tile=1');">
+ <input type="hidden" name="url" value="<?php echo AT_TILE_EXPORT_URL.$_GET['tile_course_id']; ?>" />
<br />
<div class="input-form">
/****************************************************************/
/* ATutor */
/****************************************************************/
-/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
+/* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg */
/* Adaptive Technology Resource Centre / University of Toronto */
/* http://atutor.ca */
/* */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/****************************************************************/
-// $Id: index.php 7482 2008-05-06 17:44:49Z greg $
+// $Id: index.php 6614 2006-09-27 19:32:29Z greg $
define('AT_INCLUDE_PATH', '../../../include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-authenticate(AT_PRIV_CONTENT);
+require(AT_INCLUDE_PATH.'vitals.inc.php');
+require_once('classes/ResultParser.class.php');
-$path = array();
+//$default_results_per_page = 25;
+$default_results_per_page = 20;
-/* called at the start of en element */
-/* builds the $path array which is the path from the root to the current element */
-function startElement($parser, $name, $attrs) {
- global $path;
- array_push($path, $name);
-}
-
-/* called when an element ends */
-/* removed the current element from the $path */
-function endElement($parser, $name) {
- global $my_data, $path, $tile_title, $tile_description, $tile_identifier;
-
- if ($path == array('lom', 'general', 'title', 'langstring')) {
- $tile_title = $my_data;
- } else if ($path == array('lom', 'general', 'description', 'langstring')) {
- $tile_description = $my_data;
- } else if ($path == array('lom', 'general', 'identifier')) {
- $tile_identifier = $my_data;
- }
-
- $my_data = '';
- array_pop($path);
-}
+$browse = intval($browse);
-/* called when there is character data within elements */
-/* constructs the $items array using the last entry in $path as the parent element */
-function characterData($parser, $data){
- global $my_data;
- $my_data .= $data;
-}
+if (!isset($_REQUEST["results_per_page"])) $_REQUEST["results_per_page"] = $default_results_per_page;
-require (AT_INCLUDE_PATH.'header.inc.php');
+if ($_REQUEST['submit'] || isset($_REQUEST['p']))
+{
+ $keywords = trim($_REQUEST['keywords']);
+ //$title = trim($_REQUEST['title']);
+ //$description = trim($_REQUEST['description']);
+ //$author = trim($_REQUEST['author']);
+ $results_per_page = intval(trim($_REQUEST['results_per_page']));
-
-$msg->printAll();
-
-?>
-<form action="<?php echo $_SERVER['PHP_SELF']; ?>#search_results" method="get" name="form">
-
-<div class="input-form" style="width: 60%">
- <fieldset class="group_form"><legend class="group_form"><?php echo _AT('search'); ?></legend>
- <div class="row">
- <label for="words2"><?php echo _AT('search_words'); ?></label><br />
- <input type="text" name="query" size="40" id="words2" value="<?php echo stripslashes(htmlspecialchars($_GET['query'])); ?>" />
- </div>
-
- <div class="row">
- <?php echo _AT('search_in'); ?></label><br />
-
- <input type="radio" name="field" value="anyField" id="taf" <?php if (!isset($_GET['field']) || ($_GET['field'] == 'anyField')) { echo 'checked="checked"'; } ?> /><label for="taf"><?php echo _AT('tile_any_field'); ?></label><br />
- <input type="radio" name="field" value="title" id="tt" <?php if ($_GET['field'] == 'title') { echo 'checked="checked"'; } ?> /><label for="tt"><?php echo _AT('title'); ?></label><br />
- <input type="radio" name="field" value="author" id="ta" <?php if ($_GET['field'] == 'author') { echo 'checked="checked"'; } ?> /><label for="ta"><?php echo _AT('tile_author'); ?></label><br />
- <input type="radio" name="field" value="subject" id="tk" <?php if ($_GET['field'] == 'subject') { echo 'checked="checked"'; } ?> /><label for="tk"><?php echo _AT('tile_keyword'); ?></label><br />
- <input type="radio" name="field" value="description" id="td" <?php if ($_GET['field'] == 'description') { echo 'checked="checked"'; } ?> /><label for="td"><?php echo _AT('description'); ?></label><br />
- <input type="radio" name="field" value="technicalFormat" id="tf" <?php if ($_GET['field'] == 'technicalFormat') { echo 'checked="checked"'; } ?> /><label for="tf"><?php echo _AT('tile_technical_format'); ?></label>
- </div>
-
- <div class="row buttons">
- <input type="submit" name="submit" value="<?php echo _AT('search'); ?>" />
- </div>
-</div>
-</form>
-<br />
-<?php
-
-if (isset($_GET['query'])) {
- if (!extension_loaded('soap')) {
- require(AT_INCLUDE_PATH . 'classes/nusoap.php');
- // Create the client instance
- $client = new nusoapclient(AT_TILE_WSDL, true);
-
- // Check for an error
- $error = $client->getError();
- if ($error) {
- // Display the error
-
- $msg->addError('TILE_UNAVAILABLE');
- $msg->printAll();
-
- require(AT_INCLUDE_PATH.'footer.inc.php');
- exit;
+ if($keywords <> "")
+ // || $title <> "" || $description <> "" || $author <> "" || $_REQUEST["creativeCommons"] == "true"
+ {
+ $page = intval($_REQUEST['p']);
+ if (!$page) {
+ $page = 1;
+ }
+
+ if ($results_per_page > $default_results_per_page || $results_per_page == 0)
+ $results_per_page = $default_results_per_page;
+
+ $startRecNumber = $results_per_page*($page - 1);
+
+ $page_str = "results_per_page=".$results_per_page;
+ $url_search = "&maxResults=".$results_per_page."&start=".$results_per_page*($page - 1);
+
+ if ($keywords <> "")
+ {
+ $page_str .= SEP."keywords=".urlencode($keywords);
+ $url_search .= "&keywords=".urlencode($keywords);
+ }
+ // if ($title <> "")
+ // {
+ // $page_str .= SEP."title=".urlencode($title);
+ // $url_search .= "&title=".urlencode($title);
+ // }
+ // if ($description <> "")
+ // {
+ // $page_str .= SEP. "description=".urlencode($description);
+ // $url_search .= "&description=".urlencode($description);
+ // }
+ // if ($author <> "")
+ // {
+ // $page_str .= SEP. "author=".urlencode($author);
+ // $url_search .= "&author=".urlencode($author);
+ // }
+ //
+ // if (isset($_REQUEST["search_type"]))
+ // $page_str .= SEP."search_type=".$_REQUEST["search_type"];
+ //
+ // if ($_REQUEST["search_type"] == 0) $url_search .= "&allKeyWords=true";
+ // if ($_REQUEST["search_type"] == 1) $url_search .= "&anyKeyWords=true";
+ // if ($_REQUEST["search_type"] == 2) $url_search .= "&exactPhraseKeyWords=true";
+ // if ($_REQUEST["creativeCommons"] == "true")
+ // {
+ // $page_str .= SEP. "creativeCommons=true";
+ // $url_search .= "&creativeCommons=true";
+ // }
+
+ $url = AT_TILE_SEARCH_URL."?id=".AT_TILE_ID.$url_search;
+
+ $xml_results = file_get_contents($url);
+
+ if (!$xml_results)
+ {
+ $infos = array('CANNOT_CONNECT_SERVER', AT_TILE_SEARCH_URL);
+ $msg->addInfo($infos);
+ }
+ else
+ {
+ $resultParser = new ResultParser();
+ $resultParser->parse($xml_results);
+ $result_list = $resultParser->getParsedArray();
+
+ $savant->assign('result_list', $result_list);
+ $savant->assign('startRecNumber', $startRecNumber+1);
+ $savant->assign('results_per_page', $results_per_page);
+ $savant->assign('page_str', $page_str);
+ $savant->assign('instructor_role', 1);
}
-
- // Create the proxy
- $proxy = $client->getProxy();
- } else {
- // Create the client instance
- $proxy = new soapclient(AT_TILE_WSDL);
- }
-
-
- $search_input = array('query' => $_GET['query'], 'field' => $_GET['field'], 'content' => 'contentPackage');
-
- $results = $proxy->doSearch($search_input);
-
- if ($results) {
- $num_results = count($results);
- } else {
- $num_results = 0;
}
- echo '<h3>'. _AT('results_found', $num_results).'</h3>';
- echo '<ol>';
- if ($num_results) {
- foreach ($results as $result) {
-
- $xml_parser = xml_parser_create();
-
- xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); /* conform to W3C specs */
- xml_set_element_handler($xml_parser, 'startElement', 'endElement');
- xml_set_character_data_handler($xml_parser, 'characterData');
-
- if (!xml_parse($xml_parser, $result, true)) {
- die(sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
-
- xml_parser_free($xml_parser);
+}
- $tile_title = str_replace('<', '<', $tile_title);
+global $_custom_css, $onload;
+$_custom_css = $_base_path . 'mods/_standard/tile_search/module.css'; // use a custom stylesheet
+$onload = "document.form.keywords.focus();";
- echo '<li><strong>' . $tile_title . '</strong> - ';
- echo '<a href="'.AT_TILE_PREVIEW .'cp='.$tile_identifier.'&item='.$tile_identifier.'" target="_new">'._AT('preview').'</a>';
- echo ' | <a href="'.AT_TILE_EXPORT.'?cp='.$tile_identifier.'">'._AT('download').'</a>';
- if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
- echo ' | <a href="mods/_standard/tile/import.php?cp='.$tile_identifier.SEP.'title='.urlencode($tile_title).'">'._AT('import').'</a>';
- }
- echo '<br />';
- if (strlen($tile_description) > 200) {
- echo '<small>' . $tile_description . '</small>';
- } else {
- echo $tile_description;
- }
+require (AT_INCLUDE_PATH.'header.inc.php');
- echo '<br /></li>';
+$savant->display('tile_search/index.tmpl.php');
- unset($tile_title);
- unset($tile_description);
- unset($tile_identifier);
- }
- }
- echo '</ol>';
-}
- require(AT_INCLUDE_PATH.'footer.inc.php');
+require(AT_INCLUDE_PATH.'footer.inc.php');
?>
\ No newline at end of file
<?php\r
if (!defined('AT_INCLUDE_PATH')) { exit; }\r
-//if (!isset($this) || (isset($this) && (strtolower(get_class($this)) != 'module'))) { exit(__FILE__ . ' is not a Module'); }\r
-\r
-/* the URL to the WSDL of the TILE repository of choice. */\r
-//define('AT_TILE_WSDL', 'http://tile.atutor.ca/tile/services/search?wsdl');\r
-\r
-/* the URL to the content package export servlet of the TILE repository of choice. */\r
-//define('AT_TILE_EXPORT', 'http://tile.atutor.ca/tile/servlet/export');\r
-\r
-/* the URL to the content importing servlet of the TILE repository. */\r
-//define('AT_TILE_IMPORT', 'http://tile.atutor.ca/tile/servlet/put');\r
-\r
-//define('AT_TILE_PREVIEW', 'http://tile.atutor.ca/tile/servlet/view?view=item&');\r
\r
// if this module is to be made available to students on the Home or Main Navigation\r
-//$_student_tool = 'tile.php';\r
-\r
-//$this->_pages['tools/content/index.php']['children'] = array('tools/tile/index.php');\r
+$_student_tool = 'mods/_standard/tile_search/tile.php';\r
\r
-//instructor pages\r
-//$this->_pages['tools/tile/index.php']['title_var'] = 'tile_search';\r
-//$this->_pages['tools/tile/index.php']['parent'] = 'tools/content/index.php';\r
-//$this->_pages['tools/tile/index.php']['guide'] = 'instructor/?p=tile_repository.php';\r
+// Add menu item into "Manage" => "Content" \r
+$this->_pages['mods/_core/content/index.php']['children'] = array('mods/_standard/tile_search/index.php');\r
\r
-// $this->_pages['tools/tile/import.php']['title_var'] = 'import_content_package';\r
-// $this->_pages['tools/tile/import.php']['parent'] = 'tools/tile/index.php';\r
+// instructor page\r
+$this->_pages['mods/_standard/tile_search/index.php']['title_var'] = 'tile_search';\r
+$this->_pages['mods/_standard/tile_search/index.php']['parent'] = 'mods/_core/content/index.php';\r
+$this->_pages['mods/_standard/tile_search/index.php']['children'] = array('mods/_standard/tile_search/import.php');\r
+$this->_pages['mods/_standard/tile_search/index.php']['guide'] = 'instructor/?p=tile_repository.php';\r
\r
-//student pages\r
-//$this->_pages['tile.php']['title_var'] = 'tile_search';\r
-//$this->_pages['tile.php']['img'] = 'images/home-tile_search.png';\r
-//$this->_pages['tile.php']['text'] = _AT('tile_search_text');\r
+$this->_pages['mods/_standard/tile_search/import.php']['title_var'] = 'import';\r
+$this->_pages['mods/_standard/tile_search/import.php']['parent'] = 'mods/_standard/tile_search/index.php';\r
\r
+// student page\r
+$this->_pages['mods/_standard/tile_search/tile.php']['title_var'] = 'tile_search';\r
+$this->_pages['mods/_standard/tile_search/tile.php']['img'] = 'images/home-tile_search.png';\r
+$this->_pages['mods/_standard/tile_search/tile.php']['text'] = _AT('tile_search_text');\r
?>
\ No newline at end of file
/****************************************************************/
/* ATutor */
/****************************************************************/
-/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
+/* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg */
/* Adaptive Technology Resource Centre / University of Toronto */
/* http://atutor.ca */
/* */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/****************************************************************/
-// $Id: tile.php 7208 2008-01-09 16:07:24Z greg $
-
-define('AT_INCLUDE_PATH', 'include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-
-$path = array();
-
-/* called at the start of en element */
-/* builds the $path array which is the path from the root to the current element */
-function startElement($parser, $name, $attrs) {
- global $path;
- array_push($path, $name);
-}
-
-/* called when an element ends */
-/* removed the current element from the $path */
-function endElement($parser, $name) {
- global $my_data, $path, $tile_title, $tile_description, $tile_identifier;
-
- if ($path == array('lom', 'general', 'title', 'langstring')) {
- $tile_title = $my_data;
- } else if ($path == array('lom', 'general', 'description', 'langstring')) {
- $tile_description = $my_data;
- } else if ($path == array('lom', 'general', 'identifier')) {
- $tile_identifier = $my_data;
+// $Id: index.php 6614 2006-09-27 19:32:29Z greg $
+
+define('AT_INCLUDE_PATH', '../../../include/');
+require(AT_INCLUDE_PATH.'vitals.inc.php');
+require_once('classes/ResultParser.class.php');
+
+$default_results_per_page = 20;
+
+if (!isset($_REQUEST["results_per_page"])) $_REQUEST["results_per_page"] = $default_results_per_page;
+
+if ($_REQUEST['submit'] || isset($_REQUEST['p']))
+{
+ $keywords = trim($_REQUEST['keywords']);
+ //$title = trim($_REQUEST['title']);
+ //$description = trim($_REQUEST['description']);
+ //$author = trim($_REQUEST['author']);
+ $results_per_page = intval(trim($_REQUEST['results_per_page']));
+
+ if($keywords <> "")
+ // || $title <> "" || $description <> "" || $author <> "" || $_REQUEST["creativeCommons"] == "true"
+ {
+ $page = intval($_REQUEST['p']);
+ if (!$page) {
+ $page = 1;
+ }
+
+ if ($results_per_page > $default_results_per_page || $results_per_page == 0)
+ $results_per_page = $default_results_per_page;
+
+ $startRecNumber = $results_per_page*($page - 1);
+
+ $page_str = "results_per_page=".$results_per_page;
+ $url_search = "&maxResults=".$results_per_page."&start=".$results_per_page*($page - 1);
+
+ if ($keywords <> "")
+ {
+ $page_str .= SEP."keywords=".urlencode($keywords);
+ $url_search .= "&keywords=".urlencode($keywords);
+ }
+ // if ($title <> "")
+ // {
+ // $page_str .= SEP."title=".urlencode($title);
+ // $url_search .= "&title=".urlencode($title);
+ // }
+ // if ($description <> "")
+ // {
+ // $page_str .= SEP. "description=".urlencode($description);
+ // $url_search .= "&description=".urlencode($description);
+ // }
+ // if ($author <> "")
+ // {
+ // $page_str .= SEP. "author=".urlencode($author);
+ // $url_search .= "&author=".urlencode($author);
+ // }
+ //
+ // if (isset($_REQUEST["search_type"]))
+ // $page_str .= SEP."search_type=".$_REQUEST["search_type"];
+ //
+ // if ($_REQUEST["search_type"] == 0) $url_search .= "&allKeyWords=true";
+ // if ($_REQUEST["search_type"] == 1) $url_search .= "&anyKeyWords=true";
+ // if ($_REQUEST["search_type"] == 2) $url_search .= "&exactPhraseKeyWords=true";
+ // if ($_REQUEST["creativeCommons"] == "true")
+ // {
+ // $page_str .= SEP. "creativeCommons=true";
+ // $url_search .= "&creativeCommons=true";
+ // }
+
+ $url = AT_TILE_SEARCH_URL."?id=".AT_TILE_ID.$url_search;
+
+ $xml_results = file_get_contents($url);
+
+ if (!$xml_results)
+ {
+ $infos = array('CANNOT_CONNECT_SERVER', AT_TILE_SEARCH_URL);
+ $msg->addInfo($infos);
+ }
+ else
+ {
+ $resultParser = new ResultParser();
+ $resultParser->parse($xml_results);
+ $result_list = $resultParser->getParsedArray();
+
+ $savant->assign('result_list', $result_list);
+ $savant->assign('startRecNumber', $startRecNumber+1);
+ $savant->assign('results_per_page', $results_per_page);
+ $savant->assign('page_str', $page_str);
+ }
}
-
- $my_data = '';
- array_pop($path);
}
-/* called when there is character data within elements */
-/* constructs the $items array using the last entry in $path as the parent element */
-function characterData($parser, $data){
- global $my_data;
- $my_data .= $data;
-}
+global $_custom_css, $onload;
+$_custom_css = $_base_path . 'mods/_standard/tile_search/module.css'; // use a custom stylesheet
+$onload = "document.form.keywords.focus();";
require (AT_INCLUDE_PATH.'header.inc.php');
-?>
-<form action="<?php echo $_SERVER['PHP_SELF']; ?>#search_results" method="get" name="form">
-
-<div class="input-form" style="width: 40%">
- <div class="row">
- <label for="words2"><?php echo _AT('search_words'); ?></label><br />
- <input type="text" name="query" size="40" id="words2" value="<?php echo stripslashes(htmlspecialchars($_GET['query'])); ?>" />
- </div>
-
- <div class="row">
- <?php echo _AT('search_in'); ?><br />
-
- <input type="radio" name="field" value="anyField" id="taf" <?php if (!isset($_GET['field']) || ($_GET['field'] == 'anyField')) { echo 'checked="checked"'; } ?> /><label for="taf"><?php echo _AT('tile_any_field'); ?></label><br />
- <input type="radio" name="field" value="title" id="tt" <?php if ($_GET['field'] == 'title') { echo 'checked="checked"'; } ?> /><label for="tt"><?php echo _AT('title'); ?></label><br />
- <input type="radio" name="field" value="author" id="ta" <?php if ($_GET['field'] == 'author') { echo 'checked="checked"'; } ?> /><label for="ta"><?php echo _AT('tile_author'); ?></label><br />
- <input type="radio" name="field" value="subject" id="tk" <?php if ($_GET['field'] == 'subject') { echo 'checked="checked"'; } ?> /><label for="tk"><?php echo _AT('tile_keyword'); ?></label><br />
- <input type="radio" name="field" value="description" id="td" <?php if ($_GET['field'] == 'description') { echo 'checked="checked"'; } ?> /><label for="td"><?php echo _AT('description'); ?></label><br />
- <input type="radio" name="field" value="technicalFormat" id="tf" <?php if ($_GET['field'] == 'technicalFormat') { echo 'checked="checked"'; } ?> /><label for="tf"><?php echo _AT('tile_technical_format'); ?></label>
- </div>
-
- <div class="row buttons">
- <input type="submit" name="submit" value="<?php echo _AT('search'); ?>" />
- </div>
-</div>
-</form>
-<br />
-<?php
-
-if (isset($_GET['query'])) {
-
- if (!extension_loaded('soap')) {
- require(AT_INCLUDE_PATH . 'classes/nusoap.php');
- // Create the client instance
- $client = new nusoapclient(AT_TILE_WSDL, true);
-
- // Check for an error
- $error = $client->getError();
- if ($error) {
- // Display the error
-
- $msg->addError('TILE_UNAVAILABLE');
- $msg->printAll();
+$savant->display('tile_search/index.tmpl.php');
- require(AT_INCLUDE_PATH.'footer.inc.php');
- exit;
- }
-
- // Create the proxy
- $proxy = $client->getProxy();
- } else {
- // Create the client instance
- $proxy = new soapclient(AT_TILE_WSDL);
- }
-
- $search_input = array('query' => $_GET['query'], 'field' => $_GET['field'], 'content' => 'contentPackage');
-
- $results = $proxy->doSearch($search_input);
-
-
- if ($results) {
- $num_results = count($results);
- } else {
- $num_results = 0;
- }
- echo '<h3>'. _AT('results_found', $num_results).'</h3>';
- if ($num_results) {
- echo '<ol>';
- foreach ($results as $result) {
-
- $xml_parser = xml_parser_create();
-
- xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); /* conform to W3C specs */
- xml_set_element_handler($xml_parser, 'startElement', 'endElement');
- xml_set_character_data_handler($xml_parser, 'characterData');
-
- if (!xml_parse($xml_parser, $result, true)) {
- die(sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
-
- xml_parser_free($xml_parser);
-
- $tile_title = str_replace('<', '<', $tile_title);
-
- echo '<li><strong>' . $tile_title . '</strong> - ';
- echo '<a href="'.AT_TILE_PREVIEW .'cp='.$tile_identifier.'&item='.$tile_identifier.'" target="_new">'._AT('preview').'</a>';
- echo ' | <a href="'.AT_TILE_EXPORT.'?cp='.$tile_identifier.'">'._AT('download').'</a>';
- echo '<br />';
- if (strlen($tile_description) > 200) {
- echo '<small>' . $tile_description . '</small>';
- } else {
- echo $tile_description;
- }
-
- echo '<br /></li>';
-
- unset($tile_title);
- unset($tile_description);
- unset($tile_identifier);
- }
- echo '</ol>';
- }
-}
- require(AT_INCLUDE_PATH.'footer.inc.php');
+require(AT_INCLUDE_PATH.'footer.inc.php');
?>
\ No newline at end of file
--- /dev/null
+<?php\r
+/****************************************************************/\r
+/* ATutor */\r
+/****************************************************************/\r
+/* Copyright (c) 2002-2006 by Greg Gay & Joel Kronenberg */\r
+/* Adaptive Technology Resource Centre / University of Toronto */\r
+/* http://atutor.ca */\r
+/* */\r
+/* This program is free software. You can redistribute it and/or*/\r
+/* modify it under the terms of the GNU General Public License */\r
+/* as published by the Free Software Foundation. */\r
+/****************************************************************/\r
+// $Id: index.tmpl.php 6614 2006-09-27 19:32:29Z greg $\r
+\r
+?>\r
+<form action="<?php echo $_SERVER['PHP_SELF']; ?>#search_results" method="post" name="form">\r
+ <div class="input-form">\r
+\r
+ <div style="padding:1em;">\r
+ <?php echo _AT('tile_howto'); ?>\r
+ </div>\r
+ <table width="100%">\r
+ <tr>\r
+ <td width="20%"><label for="words2"><?php echo _AT('keywords'); ?></label></td>\r
+ <td><input type="text" name="keywords" size="100" id="words2" value="<?php echo $_REQUEST['keywords']; ?>" /></td>\r
+ </tr>\r
+<!--\r
+ <tr>\r
+ <td colspan="2">\r
+ <label for="results_per_page"><?php echo _AT('merlot_results_per_page'); ?></label>\r
+ <select name="results_per_page">\r
+ <option value="5" <?php if ($_REQUEST["results_per_page"] == 5) echo 'selected="selected"' ?>>5</option>\r
+ <option value="10" <?php if ($_REQUEST["results_per_page"] == 10) echo 'selected="selected"' ?>>10</option>\r
+ <option value="15" <?php if ($_REQUEST["results_per_page"] == 15) echo 'selected="selected"' ?>>15</option>\r
+ <option value="20" <?php if ($_REQUEST["results_per_page"] == 20) echo 'selected="selected"' ?>>20</option>\r
+ <option value="25" <?php if ($_REQUEST["results_per_page"] == 25) echo 'selected="selected"' ?>>25</option>\r
+ </select>\r
+ </td>\r
+ </tr>\r
+//-->\r
+ </table>\r
+ \r
+ <div class="row buttons">\r
+ <input type="submit" name="submit" value="<?php echo _AT('search'); ?>" />\r
+ </div>\r
+ </div>\r
+</form>\r
+\r
+<?php\r
+if (isset($this->result_list))\r
+{\r
+ if ($this->result_list['status'] == 'fail') // failed, display error\r
+ {\r
+ echo ' <div id="search_results"><span style="color:red">'._AT('error').': <br /></div>';\r
+ if (is_array($this->result_list['error']))\r
+ {\r
+ foreach ($this->result_list['error'] as $error)\r
+ echo $error."<br />";\r
+ }\r
+ echo "</span>";\r
+ }\r
+ else // success, display results\r
+ {\r
+ if (is_array($this->result_list))\r
+ {\r
+ $num_results = $this->result_list["summary"]["numOfTotalResults"];\r
+ $num_pages = max(ceil($num_results / $this->results_per_page), 1);\r
+ \r
+ echo ' <div id="search_results">';\r
+ echo " <h2>". _AT('results')." <small>(".$this->startRecNumber. " - " .$this->result_list["summary"]["lastResultNumber"]." out of ".$num_results.")</small></h2>";\r
+ \r
+ print_paginator($page, $num_results, htmlspecialchars($this-> page_str), $this->results_per_page);\r
+ \r
+ foreach ($this->result_list as $key=>$result)\r
+ {\r
+ if (is_int($key))\r
+ {\r
+ ?>\r
+ \r
+ <dl class="browse-result">\r
+ \r
+ <dt>\r
+<?php if (isset($this->instructor_role)) { ?>\r
+ <a href="<?php echo AT_TILE_EXPORT_URL.$result['courseID']; ?>">\r
+ <img src="<?php echo AT_BASE_HREF. 'images/up.png'?>" alt="<?php echo _AT('download_common_cartridge'); ?>" title="<?php echo _AT("download_common_cartridge"); ?>" border="0">\r
+ </a> \r
+ <a href="mods/_standard/tile_search/import.php?tile_course_id=<?php echo $result['courseID']; ?>&title=<?php echo urlencode($result['title']); ?>">\r
+ <img src="<?php echo AT_BASE_HREF. 'images/archive.gif'?>" alt="<?php echo _AT('import'); ?>" title="<?php echo _AT("import"); ?>" border="0">\r
+ </a>\r
+<?php }?>\r
+ </dt>\r
+ <dd>\r
+ <h3>\r
+ <a href="<?php echo AT_TILE_VIEW_COURSE_URL.$result['courseID']; ?>" target="_new" ><?php echo htmlspecialchars($result['title']); ?></a>\r
+ </h3>\r
+ </dd>\r
+<!-- \r
+ <dt><?php echo _AT("author"); ?></dt>\r
+ <dd><?php if ($result['authorName']=='') echo _AT('unknown'); else echo htmlspecialchars($result['authorName']); ?></dd>\r
+ -->\r
+ <dt><?php echo _AT("merlot_creation_date"); ?></dt>\r
+ <dd><?php echo $result['creationDate']; ?></dd>\r
+ \r
+ <dt><?php echo _AT("description"); ?></dt>\r
+ <dd><?php if ($result['description']=='') echo _AT('na'); else if (strlen($result['description']) > 120) echo substr(htmlspecialchars($result['description']), 0, 120). "..."; else echo htmlspecialchars($result['description']); ?></dd>\r
+<!-- \r
+ <dt><?php echo _AT("merlot_creative_commons"); ?></dt>\r
+ <dd><?php if ($result['creativeCommons'] == "true") echo _AT('yes'); else echo _AT('no'); ?></dd>\r
+ -->\r
+ </dl>\r
+ <br />\r
+ <?php\r
+ }\r
+ }\r
+ echo '</div>';\r
+ }\r
+ }\r
+}\r
+\r
+?>\r