Ejemplo n.º 1
0
 /**
  * Return HTML for insertion in the head of a document to include Marginalia Javascript
  * and initialize Marginalia.  If necessary, also creates relevant user preferences 
  * (necessary for Marginalia to function correctly).
  */
 public static function header_html()
 {
     global $CFG, $USER;
     $anscripts = listMarginaliaJavascript();
     for ($i = 0; $i < count($anscripts); ++$i) {
         require_js(ANNOTATION_PATH . '/marginalia/' . $anscripts[$i]);
     }
     require_js(array(ANNOTATION_PATH . '/marginalia-config.js', ANNOTATION_PATH . '/marginalia-strings.js', ANNOTATION_PATH . '/smartquote.js', ANNOTATION_PATH . '/MoodleMarginalia.js'));
     // Bits of YUI
     require_js(array($CFG->wwwroot . '/lib/yui/yahoo-dom-event/yahoo-dom-event.js', $CFG->wwwroot . '/lib/yui/autocomplete/autocomplete-min.js'));
     $meta = "<link rel='stylesheet' type='text/css' href='" . s($CFG->wwwroot) . "/lib/yui/autocomplete/assets/skins/sam/autocomplete.css'/>\n" . "<link rel='stylesheet' type='text/css' href='" . s(ANNOTATION_PATH) . "/marginalia/marginalia.css'/>\n" . "<link rel='stylesheet' type='text/css' href='" . s(ANNOTATION_PATH) . "/annotation-styles.php'/>\n";
     /*		Hack for attempt to get this working with the block:
     		$meta = "<script type='text/javascript'>\n"
     			."  domutil.loadStylesheet( '".s($CFG->wwwroot)."/lib/yui/autocomplete/assets/skins/sam/autocomplete.css');\n"
     			."  domutil.loadStylesheet( '".ANNOTATION_PATH.'/marginalia/marginalia.css'."');\n"
     			."  domutil.loadStylesheet( '".ANNOTATION_PATH.'/annotation-styles.php'."');\n"
     			."</script>\n";
     */
     return $meta;
 }
Ejemplo n.º 2
0
 /**
  * Requires for annotation features
  */
 protected function emit_requires_annotate()
 {
     global $PAGE;
     $blockpath = '/blocks/marginalia';
     $PAGE->requires->css($blockpath . "/marginalia/marginalia.css");
     $PAGE->requires->css($blockpath . "/annotation-styles.php");
     // Scripts are loaded in page header (second parameter is true)
     // This could slow things down, but for now it's needed at least for
     // jQuery as js_init is fishy.
     $anscripts = listMarginaliaJavascript();
     for ($i = 0; $i < count($anscripts); ++$i) {
         $PAGE->requires->js($blockpath . '/marginalia/' . $anscripts[$i], true);
     }
     $PAGE->requires->js($blockpath . '/marginalia-config.js', true);
     $PAGE->requires->js($blockpath . '/MoodleMarginalia.js', true);
     $PAGE->requires->css("/lib/yui/autocomplete/assets/skins/sam/autocomplete.css");
     //$PAGE->requires->yui2_lib( '/lib/yui/yahoo-dom-event/yahoo-dom-event.js' );
     //		'/lib/yui/datasource/datasource-min.js',
     $PAGE->requires->yui2_lib('autocomplete');
 }
Ejemplo n.º 3
0
 /**
  * Requires for annotation features
  */
 protected function emit_requires_annotate()
 {
     global $PAGE;
     $blockpath = '/blocks/marginalia';
     $PAGE->requires->css($blockpath . "/marginalia/marginalia.css");
     $PAGE->requires->css($blockpath . "/annotation-styles.php");
     // Scripts are loaded in page header (second parameter is true)
     // This could slow things down, but for now it's needed at least for
     // jQuery as js_init is fishy.
     $anscripts = listMarginaliaJavascript();
     for ($i = 0; $i < count($anscripts); ++$i) {
         $PAGE->requires->js($blockpath . '/marginalia/' . $anscripts[$i], true);
     }
     $PAGE->requires->js($blockpath . '/marginalia-config.js', true);
     $PAGE->requires->js($blockpath . '/MoodleMarginalia.js', true);
     // Moodle has changed how YUI2 code is included. The correct way to deal
     // with this means changing how Marginalia uses YUI. I don't want to mess
     // with that now. My plan (admittedly not high priority) is to use jQuery
     // autocomplete instead, and to apply it only when users type twitter-style
     // tags (e.g. #mytag). This also eliminates the YUI code, which makes me
     // happy (not that there's anything necessarily wrong with YUI, but for
     // jQuery is far more practical for the DOM manipulation Marginalia needs).
     // For now I'm simply disabling autocomplete. Sorry! #geof#
     //$PAGE->requires->css( "/lib/yui/autocomplete/assets/skins/sam/autocomplete.css" );
     //$PAGE->requires->yui2_lib( '/lib/yui/yahoo-dom-event/yahoo-dom-event.js' );
     //		'/lib/yui/datasource/datasource-min.js',
     //$PAGE->requires->yui2_lib( 'autocomplete' );
 }
Ejemplo n.º 4
0
 function injectMarginalia($hookName, $args)
 {
     $templateManager =& $args[0];
     $template =& $args[1];
     if (in_array($template, $this->getEnabledTemplates())) {
         $baseUrl = $templateManager->get_template_vars('baseUrl');
         $additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
         $journal =& $templateManager->get_template_vars('currentJournal');
         "annovan";
         //#geof# must fix
         $serviceUrl = $journal->getUrl() . '/marginalia';
         $user =& Request::getUser();
         if ($user) {
             $currentUser = "******" . $user->getUsername() . "'";
         } else {
             $currentUser = '******';
         }
         $head_html = "<link rel='stylesheet' type='text/css' href='" . $baseUrl . '/' . PLUGIN_PATH . '/' . "marginalia.css'/>\n" . "<link rel='stylesheet' type='text/css' href='" . $baseUrl . '/' . MARGINALIA_PATH . '/' . "marginalia.css'/>\n" . "<link rel='stylesheet' type='text/css' href='" . $baseUrl . '/' . MARGINALIA_PATH . '/' . "marginalia-direct.css'/>\n" . "<script type='text/javascript' src='" . $serviceUrl . "/strings.js'></script>\n";
         if (MARGINALIA_COMPILED_JS) {
             $head_html .= "<script type='text/javascript' src='" . $baseUrl . '/' . MARGINALIA_PATH . "/marginalia-all.js'></script>\n" . "<script type='text/javascript' src='" . $baseUrl . '/' . PLUGIN_PATH . "/ojs-annotate.js'></script>\n";
         } else {
             $marginaliaFiles = listMarginaliaJavascript();
             foreach ($marginaliaFiles as $name) {
                 $head_html .= "<script type='text/javascript' src='" . $baseUrl . '/' . MARGINALIA_PATH . '/' . htmlspecialchars($name) . "'></script>\n";
             }
             $head_html .= "<script type='text/javascript' src='" . $baseUrl . '/' . PLUGIN_PATH . "/ojs-annotate.js'></script>\n";
         }
         $csrfCookie = Config::getVar('general', 'session_cookie_name');
         $head_html .= "<script language='javascript' type='text/javascript'>\n" . "  var serviceRoot = '" . $serviceUrl . "';\n" . "\tojsAnnotationInit( serviceRoot, {$currentUser}, '{$csrfCookie}' );\n" . "</script>\n";
         //."  var  serviceRoot = '".$baseUrl.'/index.php/'.$journalName.'/marginalia'."';\n"
         $templateManager->assign('additionalHeadData', $additionalHeadData . "\n" . $head_html);
     }
     return false;
 }
Ejemplo n.º 5
0
	The comments in this file are here to illustrate how to add annotation to a page.  I
	have included comments about Moodle also, as this is a clearer example than the actual
	Moodle code (which includes all the features of Moodle forums, not just annotations).
	This looks complicated with the comments.  Scroll to the second entry below (id="m2")
	to see how simple this stuff really is in practice.
	
	$Id$
	-->
	<title>Annotation Example</title>
	<!-- These all need to be included.  The order
	for inclusion matters for some of them. -->
	<?php 
require_once 'config.php';
require_once 'marginalia-php/embed.php';
global $CFG;
$marginaliaFiles = listMarginaliaJavascript();
foreach ($marginaliaFiles as $name) {
    echo "<script type='text/javascript' src='marginalia/" . htmlspecialchars($name) . "'></script>\n";
}
?>
	
	<script type="text/javascript" src="marginalia/track-changes.js"></script>
	<link rel="stylesheet" type="text/css" href="marginalia/marginalia-direct.css"/>
	
	<!-- This stylesheet includes styling for the annotation margin.  The code makes heavy
	uses of CSS, so a stylesheet provides extensive controls over the look and feel of
	the interface (e.g. add graphics or icons, change the look and position of the delete
	button, number the annotation notes in the margin). -->
	<link rel="stylesheet" type="text/css" href="marginalia/marginalia.css"/>
	
	<!-- Some of the formatting and layout must be custom -->