$string['backoldversion'] = 'Back to old version';
$string['backpage'] = 'Back to page';
$string['backtomapmenu'] = 'Back to map menu';
- $string['changerate']='Do you wish to change it?';
+ $string['changerate'] = 'Do you wish to change it?';
-$string['insertimage'] = 'Insert an image...';
-$string['insertimage_help'] = 'This drop-down list will insert an image to the wiki editor. If you need to add more images to the wiki, please use "Files" tab.';
+ $string['cannotmanagefiles'] = 'You don\'t have permission to manage the wiki files.';
+ $string['cannotviewfiles'] = 'You don\'t have permission to view the wiki files.';
$string['comparesel'] = 'Compare selected';
$string['comments'] = 'Comments';
$string['commentscount'] = 'Comments ({$a})';
$string['history_help'] = 'The history lists links to previous versions of the page.';
$string['html'] = 'HTML';
$string['insertcomment'] = 'Insert comment';
++$string['insertimage'] = 'Insert an image...';
++$string['insertimage_help'] = 'This drop-down list will insert an image to the wiki editor. If you need to add more images to the wiki, please use "Files" tab.';
$string['invalidlock'] = 'This page is already locked by another user.';
$string['invalidparameters'] = 'Invalid parameters have been given.';
$string['invalidsesskey'] = 'The given sesskey is not valid. Please resend data again';
$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
- $parser_options = array('link_callback' => '/mod/wiki/locallib.php:wiki_parser_link', 'link_callback_args' => array('swid' => $options['swid']), 'table_callback' => '/mod/wiki/locallib.php:wiki_parser_table', 'real_path_callback' => '/mod/wiki/locallib.php:wiki_parser_real_path', 'real_path_callback_args' => array('context' => $context, 'component' => 'mod_wiki', 'filearea' => 'attachments', 'pageid' => $options['pageid']), 'pageid' => $options['pageid'], 'pretty_print' => (isset($options['pretty_print']) && $options['pretty_print']), 'printable' => (isset($options['printable']) && $options['printable']));
- $parser_options = array('link_callback' => '/mod/wiki/locallib.php:wiki_parser_link',
++ $parser_options = array(
++ 'link_callback' => '/mod/wiki/locallib.php:wiki_parser_link',
+ 'link_callback_args' => array('swid' => $options['swid']),
+ 'table_callback' => '/mod/wiki/locallib.php:wiki_parser_table',
+ 'real_path_callback' => '/mod/wiki/locallib.php:wiki_parser_real_path',
+ 'real_path_callback_args' => array(
+ 'context' => $context,
+ 'component' => 'mod_wiki',
+ 'filearea' => 'attachments',
+ 'subwikiid'=> $subwiki->id,
+ 'pageid' => $options['pageid']
+ ),
+ 'pageid' => $options['pageid'],
+ 'pretty_print' => (isset($options['pretty_print']) && $options['pretty_print']),
+ 'printable' => (isset($options['printable']) && $options['printable'])
+ );
return wiki_parser_proxy::parse($pagecontent, $markup, $parser_options);
}
/**
* Returns an absolute path link, unless there is no such link.
*
- * @param string url Link's URL
- * @param string url Link's URL or filename
-- * @param stdClass context filearea params
-- * @param string filearea
-- * @param int fileareaid
++ * @param string $url Link's URL or filename
++ * @param stdClass $context filearea params
++ * @param string $component The component the file is associated with
++ * @param string $filearea The filearea the file is stored in
++ * @param int $swid Sub wiki id
*
-- * @return File full path
++ * @return string URL for files full path
*/
- function wiki_parser_real_path($url, $context, $filearea, $fileareaid) {
+ function wiki_parser_real_path($url, $context, $component, $filearea, $swid) {
global $CFG;
if (preg_match("/^(?:http|ftp)s?\:\/\//", $url)) {
return $html;
}
- public function wiki_print_subwiki_selector($wiki, $subwiki, $page) {
- public function wiki_print_subwiki_selector($wiki, $subwiki, $page, $pagetype) {
++ public function wiki_print_subwiki_selector($wiki, $subwiki, $page, $pagetype = 'view') {
global $CFG, $USER;
require_once($CFG->dirroot . '/user/lib.php');
- case 'view':
- $baseurl = new moodle_url('/mod/wiki/view.php');
- break;
+ switch ($pagetype) {
- $baseurl = null;
+ case 'files':
+ $baseurl = new moodle_url('/mod/wiki/files.php');
+ break;
++ case 'view':
+ default:
++ $baseurl = new moodle_url('/mod/wiki/view.php');
++ break;
+ }
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$select->label = get_string('mapmenu', 'wiki') . ': ';
return $this->output->container($this->output->render($select), 'midpad');
}
- function wiki_files_tree($context, $subwiki) {
++ public function wiki_files_tree($context, $subwiki) {
+ return $this->render(new wiki_files_tree($context, $subwiki));
+ }
+ public function render_wiki_files_tree(wiki_files_tree $tree) {
+ if (empty($tree->dir['subdirs']) && empty($tree->dir['files'])) {
+ $html = $this->output->box(get_string('nofilesavailable', 'repository'));
+ } else {
+ $htmlid = 'wiki_files_tree_'.uniqid();
+ $module = array('name'=>'mod_wiki', 'fullpath'=>'/mod/wiki/module.js');
+ $this->page->requires->js_init_call('M.mod_wiki.init_tree', array(false, $htmlid), false, $module);
+ $html = '<div id="'.$htmlid.'">';
+ $html .= $this->htmllize_tree($tree, $tree->dir);
+ $html .= '</div>';
+ }
+ return $html;
+ }
+
+ /**
+ * Internal function - creates htmls structure suitable for YUI tree.
+ */
+ protected function htmllize_tree($tree, $dir) {
+ global $CFG;
+ $yuiconfig = array();
+ $yuiconfig['type'] = 'html';
+
+ if (empty($dir['subdirs']) and empty($dir['files'])) {
+ return '';
+ }
+ $result = '<ul>';
+ foreach ($dir['subdirs'] as $subdir) {
+ $image = $this->output->pix_icon("f/folder", $subdir['dirname'], 'moodle', array('class'=>'icon'));
+ $result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.s($subdir['dirname']).'</div> '.$this->htmllize_tree($tree, $subdir).'</li>';
+ }
+ foreach ($dir['files'] as $file) {
+ $url = file_encode_url("$CFG->wwwroot/pluginfile.php", '/'.$tree->context->id.'/mod_wiki/attachments/' . $tree->subwiki->id . '/'. $file->get_filepath() . $file->get_filename(), true);
+ $filename = $file->get_filename();
+ $icon = mimeinfo("icon", $filename);
+ $image = $this->output->pix_icon("f/$icon", $filename, 'moodle', array('class'=>'icon'));
+ $result .= '<li yuiConfig=\''.json_encode($yuiconfig).'\'><div>'.$image.' '.html_writer::link($url, $filename).'</div></li>';
+ }
+ $result .= '</ul>';
+
+ return $result;
+ }
+ }
+
+ class wiki_files_tree implements renderable {
+ public $context;
+ public $dir;
+ public $subwiki;
+ public function __construct($context, $subwiki) {
+ $fs = get_file_storage();
+ $this->context = $context;
+ $this->subwiki = $subwiki;
+ $this->dir = $fs->get_area_tree($context->id, 'mod_wiki', 'attachments', $subwiki->id);
+ }
}