### Eclipse Workspace Patch 1.0 #P moodle20 Index: mod/resource/type/file/resource.class.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/resource/type/file/resource.class.php,v retrieving revision 1.100 diff -u -r1.100 resource.class.php --- mod/resource/type/file/resource.class.php 15 Jun 2009 07:57:54 -0000 1.100 +++ mod/resource/type/file/resource.class.php 21 Jun 2009 18:45:38 -0000 @@ -193,6 +193,8 @@ */ function display() { global $CFG, $THEME, $USER, $PAGE; + ///Yahoo javascript libaries for updating embedded object size + $PAGE->requires->yui_lib('container'); /// Set up generic stuff first, including checking for access parent::display(); @@ -386,8 +388,6 @@ if (empty($frameset) and !$embedded and !$inpopup and ($resource->options == "frame" || $resource->options == "objectframe") and empty($USER->screenreader)) { /// display the resource into a object tag if ($resource->options == "objectframe") { - ///Yahoo javascript libaries for updating embedded object size - $PAGE->requires->yui_lib('container'); ///Moodle Header and navigation bar $navigation = build_navigation($this->navlinks, $cm); Index: repository/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/repository/lib.php,v retrieving revision 1.181 diff -u -r1.181 lib.php --- repository/lib.php 16 Jun 2009 02:42:32 -0000 1.181 +++ repository/lib.php 21 Jun 2009 18:45:39 -0000 @@ -1722,6 +1722,26 @@ return true; } +function repository_head_setup() { + global $PAGE; + + $PAGE->requires->yui_lib('yahoo'); + $PAGE->requires->yui_lib('dom'); + $PAGE->requires->yui_lib('element'); + $PAGE->requires->yui_lib('event'); + $PAGE->requires->yui_lib('json'); + $PAGE->requires->yui_lib('treeview'); + $PAGE->requires->yui_lib('dragdrop'); + $PAGE->requires->yui_lib('container'); + $PAGE->requires->yui_lib('resize'); + $PAGE->requires->yui_lib('layout'); + $PAGE->requires->yui_lib('connection'); + $PAGE->requires->yui_lib('button'); + $PAGE->requires->yui_lib('selector'); + $PAGE->requires->js('repository/repository.src.js')->in_head(); + $PAGE->requires->css('repository/repository.css.php'); +} + /** * Return javascript to create file picker to browse repositories * @global object $CFG @@ -1740,111 +1760,8 @@ $video_file_ext = json_encode($ft->get_file_ext(array('video'))); $accepted_file_ext = json_encode($ft->get_file_ext($accepted_filetypes)); - $css = ''; $js = ''; if (!isset($CFG->filepickerjsloaded)) { - $css .= << -@import "$CFG->httpswwwroot/lib/yui/resize/assets/skins/sam/resize.css"; -@import "$CFG->httpswwwroot/lib/yui/container/assets/skins/sam/container.css"; -@import "$CFG->httpswwwroot/lib/yui/layout/assets/skins/sam/layout.css"; -@import "$CFG->httpswwwroot/lib/yui/button/assets/skins/sam/button.css"; -@import "$CFG->httpswwwroot/lib/yui/assets/skins/sam/treeview.css"; - - - - -EOD; - $PAGE->requires->yui_lib('yahoo'); - $PAGE->requires->yui_lib('dom'); - $PAGE->requires->yui_lib('element'); - $PAGE->requires->yui_lib('event'); - $PAGE->requires->yui_lib('json'); - $PAGE->requires->yui_lib('treeview'); - $PAGE->requires->yui_lib('dragdrop'); - $PAGE->requires->yui_lib('container'); - $PAGE->requires->yui_lib('resize'); - $PAGE->requires->yui_lib('layout'); - $PAGE->requires->yui_lib('connection'); - $PAGE->requires->yui_lib('button'); - $PAGE->requires->yui_lib('selector'); - require_js(array( - 'repository/repository.src.js' - )); $lang = array(); $lang['title'] = get_string('title', 'repository'); $lang['preview'] = get_string('preview', 'repository'); @@ -1931,5 +1848,5 @@ $js .= "\r\n"; $js .= ""; - return array('css'=>$css, 'js'=>$js); + return $js; } Index: lib/editor/tinymce/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/editor/tinymce/lib.php,v retrieving revision 1.5 diff -u -r1.5 lib.php --- lib/editor/tinymce/lib.php 20 Jun 2009 11:00:41 -0000 1.5 +++ lib/editor/tinymce/lib.php 21 Jun 2009 18:45:37 -0000 @@ -51,11 +51,15 @@ return true; } - public function use_editor($elementid, array $options=null) { + public function head_setup() { global $CFG, $PAGE; - + require_once("$CFG->dirroot/repository/lib.php"); $PAGE->requires->js('/lib/editor/tinymce/tiny_mce_src.js'); $PAGE->requires->js('/lib/editor/tinymce/extra/tinymce_utils.js'); + } + + public function use_editor($elementid, array $options=null) { + global $PAGE; $PAGE->requires->js_function_call('mce_init_editor', array($elementid, $this->get_init_params($elementid, $options))); } Index: lib/ajax/ajaxlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/ajax/ajaxlib.php,v retrieving revision 1.60 diff -u -r1.60 ajaxlib.php --- lib/ajax/ajaxlib.php 17 Jun 2009 05:34:10 -0000 1.60 +++ lib/ajax/ajaxlib.php 21 Jun 2009 18:45:37 -0000 @@ -657,7 +657,9 @@ $this->jss[] = $manager->js($jsurl, true); } foreach ($cssurls as $cssurl) { - //$manager->css($cssurl, true); + // this might be a bit problematic because it requires yui to be + // requested before print_header() - this was not required in 1.9.x + $manager->css($cssurl, true); } } Index: lib/form/filemanager.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/form/filemanager.php,v retrieving revision 1.22 diff -u -r1.22 filemanager.php --- lib/form/filemanager.php 18 Jun 2009 06:31:51 -0000 1.22 +++ lib/form/filemanager.php 21 Jun 2009 18:45:38 -0000 @@ -9,6 +9,7 @@ function MoodleQuickForm_filemanager($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG; + require_once("$CFG->dirroot/repository/lib.php"); $options = (array)$options; foreach ($options as $name=>$value) { @@ -20,6 +21,8 @@ $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + + repository_head_setup(); } function setName($name) { @@ -162,15 +165,14 @@ } $client_id = uniqid(); - $repo_info = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']); + $str .= $repojs = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']); $html = $this->_get_draftfiles($draftitemid, $client_id); $accessiblefp = get_string('accessiblefilepicker', 'repository'); $str = $this->_getTabs(); $str .= $html; - $str .= $repo_info['css']; - $str .= $repo_info['js']; + $str .= $repojs; $str .= << Index: lib/form/editor.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/form/editor.php,v retrieving revision 1.15 diff -u -r1.15 editor.php --- lib/form/editor.php 20 Jun 2009 11:00:41 -0000 1.15 +++ lib/form/editor.php 21 Jun 2009 18:45:38 -0000 @@ -15,6 +15,7 @@ function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG; + require_once("$CFG->dirroot/repository/lib.php"); $options = (array)$options; foreach ($options as $name=>$value) { @@ -29,6 +30,9 @@ $this->_options['context'] = get_context_instance(CONTEXT_SYSTEM); } parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes); + + repository_head_setup(); + editors_head_setup(); } function setName($name) { @@ -171,9 +175,9 @@ require_once($CFG->dirroot.'/repository/lib.php'); $client_id = uniqid(); - $ret = repository_get_client($ctx, $client_id, array('image', 'video', 'media'), '*'); + $repojs = repository_get_client($ctx, $client_id, array('image', 'video', 'media'), '*'); - $str .= $ret['css'].$ret['js']; + $str .= $repojs; $str .= << id2clientid['$id'] = '$client_id'; Index: lib/form/filepicker.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/form/filepicker.php,v retrieving revision 1.28 diff -u -r1.28 filepicker.php --- lib/form/filepicker.php 18 Jun 2009 06:31:51 -0000 1.28 +++ lib/form/filepicker.php 21 Jun 2009 18:45:38 -0000 @@ -18,6 +18,7 @@ function MoodleQuickForm_filepicker($elementName=null, $elementLabel=null, $attributes=null, $options=null) { global $CFG; + require_once("$CFG->dirroot/repository/lib.php"); $options = (array)$options; foreach ($options as $name=>$value) { @@ -29,6 +30,8 @@ $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']); } parent::HTML_QuickForm_input($elementName, $elementLabel, $attributes); + + repository_head_setup(); } function setHelpButton($helpbuttonargs, $function='helpbutton') { @@ -84,14 +87,14 @@ $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); } $client_id = uniqid(); - $repository_info = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']); + $repojs = repository_get_client($context, $client_id, $this->_options['filetypes'], $this->_options['returnvalue']); $id = $this->_attributes['id']; $elname = $this->_attributes['name']; $str = $this->_getTabs(); $str .= ''; - $str .= $repository_info['css'].$repository_info['js']; + $str .= $repojs; $str .= <<$straddfile Index: lib/editorlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/editorlib.php,v retrieving revision 1.15 diff -u -r1.15 editorlib.php --- lib/editorlib.php 20 Jun 2009 11:00:41 -0000 1.15 +++ lib/editorlib.php 21 Jun 2009 18:45:36 -0000 @@ -112,6 +112,30 @@ } /** + * Setup all JS and CSS needed for editors. + * @return void + */ +function editors_head_setup() { + global $CFG; + + if (empty($CFG->texteditors)) { + $CFG->texteditors = 'tinymce,textarea'; + } + $active = explode(',', $CFG->texteditors); + + foreach ($active as $editorname) { + if (!$editor = get_texteditor($editorname)) { + continue; + } + if (!$editor->supported_by_browser()) { + // bad luck, this editor is not compatible + continue; + } + $editor->head_setup(); + } +} + +/** * Base abstract text editor class. * * @copyright 2009 Petr Skoda {@link http://skodak.org} @@ -150,6 +174,13 @@ * @return void */ public abstract function use_editor($elementid, array $options=null); + + /** + * Setup all JS and CSS needed for editor. + * @return void + */ + public function head_setup() { + } } Index: repository/repository.css.php =================================================================== RCS file: repository/repository.css.php diff -N repository/repository.css.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ repository/repository.css.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,88 @@ + +/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */ +/* copy from yui/examples/treeview/assets/css/folders/tree.css */ +/* first or middle sibling, no children */ +.ygtvtn { background: url(pixpath;?>/y/tn.gif) 0 0 no-repeat; width:17px; height:22px; } +/* first or middle sibling, collapsable */ +.ygtvtm { background: url(pixpath;?>/y/tm.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* first or middle sibling, collapsable, hover */ +.ygtvtmh { background: url(pixpath;?>/y/tmh.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* first or middle sibling, expandable */ +.ygtvtp { background: url(pixpath;?>/y/tp.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* first or middle sibling, expandable, hover */ +.ygtvtph { background: url(pixpath;?>/y/tph.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* last sibling, no children */ +.ygtvln { background: url(pixpath;?>/y/ln.gif) 0 0 no-repeat; width:17px; height:22px; } +/* Last sibling, collapsable */ +.ygtvlm { background: url(pixpath;?>/y/lm.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* Last sibling, collapsable, hover */ +.ygtvlmh { background: url(pixpath;?>/y/lmh.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* Last sibling, expandable */ +.ygtvlp { background: url(pixpath;?>/y/lp.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* Last sibling, expandable, hover */ +.ygtvlph { background: url(pixpath;?>/y/lph.gif) 0 0 no-repeat; width:34px; height:22px; cursor:pointer } +/* Loading icon */ +.ygtvloading { background: url(pixpath;?>/y/loading.gif) 0 0 no-repeat; width:16px; height:22px; } +/* the style for the empty cells that are used for rendering the depth + * of the node */ +.ygtvdepthcell { background: url(pixpath;?>/y/vline.gif) 0 0 no-repeat; width:17px; height:22px; } +.ygtvblankdepthcell { width:17px; height:22px; } +/* the style of the div around each node */ +.ygtvitem { } +.ygtvitem table{ margin-bottom:0; } +.ygtvitem td { border:none;padding:0; } +/* the style of the div around each node's collection of children */ +.ygtvchildren { } +* html .ygtvchildren { height:1%; } +/* the style of the text label in ygTextNode */ +.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover { margin-left:2px; text-decoration: none; } + + +.file-picker{font-size:12px;} +.file-picker strong{background:#FFFFCC} +.file-picker a{color: #336699} +.file-picker a:hover{background:#003366;color:white} +.fp-panel{padding:0;margin:0; text-align:left;} +.fp-login-form{text-align:center} +.fp-searchbar{float:right} +.fp-viewbar{width:300px;float:left} +.fp-toolbar{padding: .8em;background: #FFFFCC;text-align:center;margin: 3px} +.fp-toolbar a{padding: 0 .5em} +.fp-list{list-style-type:none;padding:0;float:left;width:100%;margin:0;} +.fp-list li{border-bottom:1px dotted gray;margin-bottom: 1em;} +.fp-repo-name{display:block;padding: .5em;margin-bottom: .5em} +.fp-pathbar{margin: .4em;border-bottom: 1px dotted gray;} +.fp-pathbar a{padding: .4em;} +.fp-rename-form{text-align:center} +.fp-rename-form p{margin: 1em;} +.fp-upload-form{margin: 2em 0;text-align:center} +.fp-upload-btn a{cursor: default;background: white;border:1px solid gray;color:black;padding: .5em} +.fp-upload-btn a:hover {background: grey;color:white} +.fp-paging{margin:1em .5em; clear:both;text-align:center;line-height: 2.5em;} +.fp-paging a{padding: .5em;border: 1px solid #CCC} +.fp-paging a.cur_page{border: 1px solid blue} +.fp-popup{text-align:center} +.fp-grid{float:left;text-align:center;} +.fp-grid div{overflow: hidden} +.fp-grid p{margin:0;padding:0;background: #FFFFCC} +.fp-grid .label{height:48px;text-align:center} +.fp-grid span{color:gray} + + +/* TODO: Fix IE6 somehow +.yui-skin-sam .yui-panel .hd{} +*/ \ No newline at end of file