From: dongsheng Date: Thu, 31 Jul 2008 02:51:28 +0000 (+0000) Subject: MDL-13766 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c5704ec65ad982ff346a03c9bdfcb5e2c748b8e5;p=moodle.git MDL-13766 1. Filepicker component for moodleform 2. Integrate TinyMCE and FilePicker 3. Fix show/hide bug in filepicker 4. Rewrite print_login function for ajax --- diff --git a/lang/en_utf8/repository.php b/lang/en_utf8/repository.php index 05932628a7..edecbd46d2 100644 --- a/lang/en_utf8/repository.php +++ b/lang/en_utf8/repository.php @@ -4,3 +4,16 @@ $string['repositories'] = 'Repositories'; $string['manageuserrepository'] = 'Manage individual repository'; $string['plugin'] = 'Repository Plug-ins'; $string['settings'] = 'Settings'; +$string['openpicker'] = 'Open file picker'; +$string['submit'] = 'Submit'; +$string['listview'] = 'List View'; +$string['thumbview'] = 'Thumbnail View'; +$string['search'] = 'Search '; +$string['logout'] = 'Logout'; +$string['loading'] = 'Loading...'; +$string['title'] = 'Repository File Picker'; +$string['filename'] = 'Filename'; +$string['sync'] = 'Sync'; +$string['download'] = 'Download'; +$string['back'] = '< Back'; +$string['close'] = 'Close'; diff --git a/lib/editor/tinymce.js.php b/lib/editor/tinymce.js.php index 486edaa53a..986da2ff74 100644 --- a/lib/editor/tinymce.js.php +++ b/lib/editor/tinymce.js.php @@ -205,18 +205,7 @@ echo <<httpswwwroot}/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id={$courseid}", - width: 480, - height: 380, - resizable: "yes", - inline: "yes", - close_previous: "no" - }, { - window: win, - input: field_name - }); - return false; + openpicker(); } function mce_saveOnSubmit(id) { var prevOnSubmit = document.getElementById(id).form.onsubmit; diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php new file mode 100644 index 0000000000..249dc19c58 --- /dev/null +++ b/lib/form/filepicker.php @@ -0,0 +1,51 @@ + + * @version 1.0 + * @since Moodle 2.0 + * @access public + */ +class MoodleQuickForm_filepicker extends HTML_QuickForm_button +{ + var $_helpbutton=''; + function setHelpButton($helpbuttonargs, $function='helpbutton'){ + if (!is_array($helpbuttonargs)){ + $helpbuttonargs=array($helpbuttonargs); + }else{ + $helpbuttonargs=$helpbuttonargs; + } + //we do this to to return html instead of printing it + //without having to specify it in every call to make a button. + if ('helpbutton' == $function){ + $defaultargs=array('', '', 'moodle', true, false, '', true); + $helpbuttonargs=$helpbuttonargs + $defaultargs ; + } + $this->_helpbutton=call_user_func_array($function, $helpbuttonargs); + } + function getHelpButton(){ + return $this->_helpbutton; + } + function getElementTemplateType(){ + if ($this->_flagFrozen){ + return 'nodisplay'; + } else { + return 'default'; + } + } + function toHtml() { + global $CFG; + if ($this->_flagFrozen) { + return $this->getFrozenHtml(); + } else { + $ret = get_repository_client(); + return $this->_getTabs() . '_getAttrString($this->_attributes) . ' onclick=\'openpicker()\' />'.$ret['html'].$ret['js']; + } + } +} diff --git a/lib/formslib.php b/lib/formslib.php index e8cd5789a5..bc00cf0b3e 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1850,6 +1850,7 @@ $GLOBALS['_HTML_QuickForm_default_renderer'] =& new MoodleQuickForm_Renderer(); MoodleQuickForm::registerElementType('checkbox', "$CFG->libdir/form/checkbox.php", 'MoodleQuickForm_checkbox'); MoodleQuickForm::registerElementType('file', "$CFG->libdir/form/file.php", 'MoodleQuickForm_file'); +MoodleQuickForm::registerElementType('filepicker', "$CFG->libdir/form/filepicker.php", 'MoodleQuickForm_filepicker'); MoodleQuickForm::registerElementType('group', "$CFG->libdir/form/group.php", 'MoodleQuickForm_group'); MoodleQuickForm::registerElementType('password', "$CFG->libdir/form/password.php", 'MoodleQuickForm_password'); MoodleQuickForm::registerElementType('passwordunmask', "$CFG->libdir/form/passwordunmask.php", 'MoodleQuickForm_passwordunmask'); diff --git a/lib/weblib.php b/lib/weblib.php index e95102e8af..83174aa19a 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -43,6 +43,8 @@ require_once("$CFG->libdir/filterlib.php"); require_once("$CFG->libdir/ajax/ajaxlib.php"); +require_once("$CFG->dirroot/repository/lib.php"); + /// Constants /// Define text formatting types ... eventually we can add Wiki, BBcode etc @@ -4871,6 +4873,8 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v if ($usehtmleditor) { $str_toggle = ''. get_string('editortoggle') .''; // Show shortcuts button if HTML editor is in use, but only if JavaScript is enabled (MDL-9556) + $ret = get_repository_client(); + $str .= $ret['html'].$ret['js']; $str .= '
'; $str .= ' - - - - - - - - - - - - - - -EOD; -echo $meta; +$ret = get_repository_client(); ?> @@ -122,314 +81,8 @@ if(btn){ }
- diff --git a/repository/boxnet/lang/en_utf8/repository_boxnet.php b/repository/boxnet/lang/en_utf8/repository_boxnet.php index 013c198347..184380bd89 100644 --- a/repository/boxnet/lang/en_utf8/repository_boxnet.php +++ b/repository/boxnet/lang/en_utf8/repository_boxnet.php @@ -8,3 +8,5 @@ $string['saved'] = 'Box.net data saved.'; $string['invalidpassword'] = 'Invalid password'; $stirng['invalidtoken'] = 'Invalid auth-token'; $string['nullfilelist'] = 'There are no files in this repository'; +$string['username'] = 'Box.net Account:'; +$string['password'] = 'Your Password:'; diff --git a/repository/boxnet/repository.class.php b/repository/boxnet/repository.class.php index 1374ceedde..7cd4b06a22 100755 --- a/repository/boxnet/repository.class.php +++ b/repository/boxnet/repository.class.php @@ -61,6 +61,9 @@ class repository_boxnet extends repository{ if ($entry = $DB->get_record('repository', array('id'=>$this->repositoryid))) { $ret->username = $entry->username; $ret->password = $entry->password; + } else { + $ret->username = ''; + $ret->password = ''; } return $ret; } @@ -126,9 +129,28 @@ class repository_boxnet extends repository{ $str .= '
'; $str .= ''; $str .= ''; - if($this->options['ajax']){ + if ($this->options['ajax']) { + $e1->type = 'hidden'; + $e1->name = 'ticket'; + $e1->value = $t['ticket']; + + $e2->type = 'hidden'; + $e2->name = 'id'; + $e2->value = $this->repositoryid; + + $e3->label = get_string('username', 'repository_boxnet'); + $e3->id = 'box_username'; + $e3->type = 'text'; + $e3->name = 'username'; + $e3->value = $ret->username; + + $e4->label = get_string('password', 'repository_boxnet'); + $e4->id = 'box_password'; + $e4->type = 'password'; + $e4->name = 'password'; + $ret = array(); - $ret['l'] = $str; + $ret['l'] = array($e1, $e2, $e3, $e4); return $ret; } else { echo $str; diff --git a/repository/flickr/lang/en_utf8/repository_flickr.php b/repository/flickr/lang/en_utf8/repository_flickr.php index ce54de8aba..43135b895d 100644 --- a/repository/flickr/lang/en_utf8/repository_flickr.php +++ b/repository/flickr/lang/en_utf8/repository_flickr.php @@ -2,3 +2,5 @@ $string['repositoryname'] = 'Flickr'; $string['repositorydesc'] = 'Repository for flickr.com'; $string['notitle'] = 'notitle'; +$string['username'] = 'Flickr Account:'; +$string['remember'] = 'Remember me'; diff --git a/repository/lib.php b/repository/lib.php index 28441215fa..431c1f2979 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -51,7 +51,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License */ require_once(dirname(dirname(__FILE__)) . '/config.php'); -require_once($CFG->libdir.'/filelib.php'); +require_once(dirname(dirname(__FILE__)).'/lib/filelib.php'); abstract class repository { protected $options; @@ -331,3 +331,416 @@ function repository_get_plugins(){ } return $ret; } +function get_repository_client(){ + global $CFG; + $strsubmit = get_string('submit', 'repository'); + $strlistview = get_string('listview', 'repository'); + $strthumbview = get_string('thumbview', 'repository'); + $strsearch = get_string('search', 'repository'); + $strlogout = get_string('logout', 'repository'); + $strloading = get_string('loading', 'repository'); + $strtitle = get_string('title', 'repository'); + $filename = get_string('filename', 'repository'); + $strsync = get_string('sync', 'repository'); + $strdownload = get_string('download', 'repository'); + $strback = get_string('back', 'repository'); + $strclose = get_string('close', 'repository'); + + $js = << + #list{line-height: 1.5em} + #list a{ padding: 3px } + #list li a:hover{ background: gray; color:white; } + #paging{margin:10px 5px; clear:both} + #paging a{padding: 4px; border: 1px solid gray} + #panel{padding:0;margin:0; text-align:left;} + .file_name{color:green;} + .file_date{color:blue} + .file_size{color:gray} + .grid{width:80px; float:left;text-align:center;} + .grid div{width: 80px; height: 36px; overflow: hidden} + .repo-opt{font-size: 10px;color:red} + + + + + + + + + + + + + + + + + + +EOD; + $html = << +
+ +EOD; + return array('html'=>$html, 'js'=>$js); +}