コード例 #1
0
function displaydir($wdir)
{
    //  $wdir == / or /a or /a/b/c/d  etc
    global $basedir;
    global $id;
    global $USER, $CFG;
    global $choose;
    $fullpath = $basedir . $wdir;
    check_dir_exists($fullpath, true);
    $directory = opendir($fullpath);
    // Find all files
    while (false !== ($file = readdir($directory))) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (is_dir($fullpath . "/" . $file)) {
            $dirlist[] = $file;
        } else {
            $filelist[] = $file;
        }
    }
    closedir($directory);
    $strname = get_string("name");
    $strsize = get_string("size");
    $strmodified = get_string("modified");
    $straction = get_string("action");
    $strmakeafolder = get_string("makeafolder");
    $struploadafile = get_string("uploadafile");
    $strwithchosenfiles = get_string("withchosenfiles");
    $strmovetoanotherfolder = get_string("movetoanotherfolder");
    $strmovefilestohere = get_string("movefilestohere");
    $strdeletecompletely = get_string("deletecompletely");
    $strcreateziparchive = get_string("createziparchive");
    $strrename = get_string("rename");
    $stredit = get_string("edit");
    $strunzip = get_string("unzip");
    $strlist = get_string("list");
    $strrestore = get_string("restore");
    $strchoose = get_string("choose");
    $prop = null;
    $prop->action = "index.php";
    $prop->method = "post";
    $prop->id = "dirform";
    wiki_form_start($prop);
    wiki_div_start();
    $prop = null;
    $prop->name = "choose";
    $prop->value = $choose;
    wiki_input_hidden($prop);
    wiki_hr();
    $prop = null;
    $prop->border = "0";
    $prop->spacing = "2";
    $prop->padding = "2";
    $prop->width = "640";
    $prop->class = "files";
    $prop->header = true;
    $prop->styleth = "width:5%";
    wiki_table_start($prop);
    $prop = null;
    $prop->header = true;
    $prop->align = "left";
    $prop->class = "header name";
    wiki_change_column($prop);
    echo $strname;
    $prop = null;
    $prop->header = true;
    $prop->align = "right";
    $prop->class = "header size";
    wiki_change_column($prop);
    echo $strsize;
    $prop = null;
    $prop->header = true;
    $prop->align = "right";
    $prop->class = "header date";
    wiki_change_column($prop);
    echo $strmodified;
    $prop = null;
    $prop->header = true;
    $prop->align = "right";
    $prop->class = "header commands";
    wiki_change_column($prop);
    echo $straction;
    if ($wdir == "/") {
        $wdir = "";
    }
    if (!empty($wdir)) {
        $dirlist[] = '..';
    }
    $count = 0;
    $header = true;
    if (!empty($dirlist)) {
        asort($dirlist);
        foreach ($dirlist as $dir) {
            if ($header) {
                $header = false;
                $prop = null;
                $prop->header = true;
            } else {
                $prop = null;
            }
            if ($dir == '..') {
                $fileurl = rawurlencode(dirname($wdir));
                $prop->style = "white-space: nowrap;";
                $prop->align = "center";
                $prop->classtr = "folder";
                wiki_change_row($prop);
                echo ' ';
                $prop = null;
                $prop->class = 'name';
                $prop->align = 'left';
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                $prop = null;
                $prop->src = $CFG->pixpath . '/f/parent.gif';
                $prop->height = "16";
                $prop->width = "16";
                $prop->alt = get_string('parentfolder');
                $out = wiki_img($prop, true);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl;
                wiki_a($out, $prop);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl;
                wiki_a(get_string('parentfolder'), $prop);
                wiki_change_column();
                echo ' ';
                wiki_change_column();
                echo ' ';
                wiki_change_column();
                echo ' ';
            } else {
                $count++;
                $filename = $fullpath . "/" . $dir;
                $fileurl = rawurlencode($wdir . "/" . $dir);
                $filesafe = rawurlencode($dir);
                $filesize = display_size(get_directory_size("{$fullpath}/{$dir}"));
                $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
                $prop->align = "center";
                $prop->style = "white-space: nowrap;";
                $prop->class = "checkbox";
                $prop->classtr = "folder";
                wiki_change_row($prop);
                $prop = null;
                $prop->name = 'file' . $count;
                $prop->value = $fileurl;
                wiki_input_checkbox($prop);
                $prop = null;
                $prop->class = 'name';
                $prop->align = "left";
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                $prop = null;
                $prop->src = $CFG->pixpath . '/f/folder.gif';
                $prop->height = "16";
                $prop->width = "16";
                $prop->alt = "Folder";
                $out = wiki_img($prop, true);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl . '&choose=' . $choose;
                wiki_a($out, $prop);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&wdir=' . $fileurl . '&choose=' . $choose;
                wiki_a(htmlspecialchars($dir), $prop);
                $prop = null;
                $prop->class = 'size';
                $prop->align = "right";
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                echo $filesize;
                $prop = null;
                $prop->class = 'date';
                $prop->align = "right";
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                echo $filedate;
                $prop = null;
                $prop->class = 'commands';
                $prop->align = "right";
                $prop->style = "white-space: nowrap;";
                wiki_change_column($prop);
                $prop = null;
                $prop->href = 'index.php?id=' . $id . '&wdir=' . $wdir . '&file=' . $filesafe . '&action=rename&choose=' . $choose;
                wiki_a($strrename, $prop);
                //echo "<a href=\"index.php?id=$id&amp;wdir=$wdir&amp;file=$filesafe&amp;action=rename&amp;choose=$choose\">$strrename</a>";
            }
        }
    }
    if (!empty($filelist)) {
        asort($filelist);
        foreach ($filelist as $file) {
            $icon = mimeinfo("icon", $file);
            $count++;
            $filename = $fullpath . "/" . $file;
            $fileurl = "{$wdir}/{$file}";
            $filesafe = rawurlencode($file);
            $fileurlsafe = rawurlencode($fileurl);
            $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
            if (substr($fileurl, 0, 1) == '/') {
                $selectfile = substr($fileurl, 1);
            } else {
                $selectfile = $fileurl;
            }
            if ($header) {
                $header = false;
                $prop = null;
                $prop->header = true;
            } else {
                $prop = null;
            }
            $prop->align = "center";
            $prop->style = "white-space: nowrap;";
            $prop->class = "checkbox";
            $prop->classtr = "file";
            wiki_change_row($prop);
            $prop = null;
            $prop->name = 'file' . $count;
            $prop->value = $fileurl;
            wiki_input_checkbox($prop);
            $prop = null;
            $prop->align = "left";
            $prop->class = "name nwikileftnow";
            wiki_change_column($prop);
            if ($CFG->slasharguments) {
                $ffurl = "/file.php/" . $id . $fileurl;
            } else {
                $ffurl = "/file.php?file=/" . $id . $fileurl;
            }
            link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" height=\"16\" width=\"16\" alt=\"File\" />", 480, 640);
            echo '&nbsp;';
            link_to_popup_window($ffurl, "display", htmlspecialchars($file), 480, 640);
            $file_size = filesize($filename);
            $prop = null;
            $prop->class = 'size';
            $prop->align = "right";
            $prop->style = "white-space: nowrap;";
            wiki_change_column($prop);
            echo display_size($file_size);
            $prop = null;
            $prop->class = 'date';
            $prop->align = "right";
            $prop->style = "white-space: nowrap;";
            wiki_change_column($prop);
            echo $filedate;
            if ($choose) {
                $edittext = "<b><a onMouseDown=\"return set_value('{$selectfile}')\" href=\"\">{$strchoose}</a></b>&nbsp;";
            } else {
                $edittext = '';
            }
            if ($icon == "text.gif" || $icon == "html.gif") {
                $edittext .= "<a href=\"index.php?id={$id}&amp;wdir={$wdir}&amp;file={$fileurl}&amp;action=edit&amp;choose={$choose}\">{$stredit}</a>";
            } else {
                if ($icon == "zip.gif") {
                    $edittext .= "<a href=\"index.php?id={$id}&amp;wdir={$wdir}&amp;file={$fileurl}&amp;action=unzip&amp;sesskey={$USER->sesskey}&amp;choose={$choose}\">{$strunzip}</a>&nbsp;";
                    $edittext .= "<a href=\"index.php?id={$id}&amp;wdir={$wdir}&amp;file={$fileurl}&amp;action=listzip&amp;sesskey={$USER->sesskey}&amp;choose={$choose}\">{$strlist}</a> ";
                }
            }
            $prop = null;
            $prop->class = 'commands';
            $prop->align = "right";
            $prop->style = "white-space: nowrap;";
            wiki_change_column($prop);
            echo $edittext;
            echo "<a href=\"index.php?id={$id}&amp;wdir={$wdir}&amp;file={$filesafe}&amp;action=rename&amp;choose={$choose}\">{$strrename}</a>";
        }
    }
    if ($header) {
        $prop = null;
        $prop->header = true;
        wiki_table_end($prop);
        $header = false;
    } else {
        wiki_table_end();
    }
    wiki_hr();
    if (empty($wdir)) {
        $wdir = "/";
    }
    $prop = null;
    $prop->name = "id";
    $prop->value = $id;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "choose";
    $prop->value = $choose;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "wdir";
    $prop->value = $wdir;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "sesskey";
    $prop->value = $USER->sesskey;
    wiki_input_hidden($prop);
    $options = array("move" => "{$strmovetoanotherfolder}", "delete" => "{$strdeletecompletely}", "zip" => "{$strcreateziparchive}");
    if (!empty($count)) {
        choose_from_menu($options, "action", "", "{$strwithchosenfiles}...", "javascript:document.forms['dirform'].submit()");
    }
    wiki_div_end();
    wiki_form_end();
    $prop = null;
    $prop->border = "0";
    $prop->spacing = "2";
    $prop->padding = "2";
    $prop->class = "boxalignright";
    $prop->aligntd = "center";
    wiki_table_start($prop);
    if (!empty($USER->fileop) and $USER->fileop == "move" and $USER->filesource != $wdir) {
        $prop = null;
        $prop->action = "index.php";
        $prop->method = "get";
        wiki_form_start($prop);
        wiki_div_start();
        $prop = null;
        $prop->name = "choose";
        $prop->value = $choose;
        wiki_input_hidden($prop);
        $prop = null;
        $prop->name = "id";
        $prop->value = $id;
        wiki_input_hidden($prop);
        $prop = null;
        $prop->name = "wdir";
        $prop->value = $wdir;
        wiki_input_hidden($prop);
        $prop = null;
        $prop->name = "action";
        $prop->value = "paste";
        wiki_input_hidden($prop);
        $prop = null;
        $prop->name = "sesskey";
        $prop->value = $USER->sesskey;
        wiki_input_hidden($prop);
        $prop = null;
        $prop->value = $strmovefilestohere;
        wiki_input_submit($prop);
        wiki_div_end();
        wiki_form_end();
        $prop = null;
        $prop->align = "right";
        wiki_change_column($prop);
    }
    $prop = null;
    $prop->action = "index.php";
    $prop->method = "get";
    wiki_form_start($prop);
    wiki_div_start();
    $prop = null;
    $prop->name = "choose";
    $prop->value = $choose;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "id";
    $prop->value = $id;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "wdir";
    $prop->value = $wdir;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "action";
    $prop->value = "mkdir";
    wiki_input_hidden($prop);
    $prop = null;
    $prop->value = $strmakeafolder;
    wiki_input_submit($prop);
    wiki_div_end();
    wiki_form_end();
    $prop = null;
    $prop->align = "right";
    wiki_change_column($prop);
    $prop = null;
    $prop->action = "index.php";
    $prop->method = "get";
    wiki_form_start($prop);
    wiki_div_start();
    $prop = null;
    $prop->name = "choose";
    $prop->value = $choose;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "id";
    $prop->value = $id;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "wdir";
    $prop->value = $wdir;
    wiki_input_hidden($prop);
    $prop = null;
    $prop->name = "action";
    $prop->value = "upload";
    wiki_input_hidden($prop);
    $prop = null;
    $prop->value = $struploadafile;
    wiki_input_submit($prop);
    wiki_div_end();
    wiki_form_end();
    wiki_table_end();
    wiki_hr();
}
コード例 #2
0
function wiki_hist_diff_print_versions($diff = "diff")
{
    global $WS;
    //if ($diff=="newdiff"){
    $vers->current = $WS->pageolddata->version;
    $vers->old = $WS->pageverdata->version;
    wiki_size_text(get_string('comparingwith', 'wiki', $vers), 2);
    //}
    $prev = $WS->pageolddata->version - 1;
    $next = $WS->pageolddata->version + 1;
    $specialvers = array();
    $prop = null;
    $prop->href = 'view.php?id=' . $WS->linkid . '&amp;page=' . $diff . '/' . urlencode($WS->pageolddata->pagename) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;ver=' . $WS->pageolddata->version . '/1&amp;dfcontent=11';
    if ($WS->pageolddata->version != 1) {
        $out = wiki_a(get_string('initial', 'wiki'), $prop, true);
    } else {
        $out = '<b>1</b>';
    }
    $specialvers[1] = $out;
    $prop = null;
    $prop->href = 'view.php?id=' . $WS->linkid . '&amp;page=' . $diff . '/' . urlencode($WS->pageolddata->pagename) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;ver=' . $WS->pageolddata->version . '/' . $next . '&amp;dfcontent=11';
    $out = wiki_a(get_string('next'), $prop, true);
    $specialvers[$next] = $out;
    $prop = null;
    $prop->href = 'view.php?id=' . $WS->linkid . '&amp;page=' . $diff . '/' . urlencode($WS->pageolddata->pagename) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;ver=' . $WS->pageolddata->version . '/' . $prev . '&amp;dfcontent=11';
    $out = wiki_a(get_string('previous'), $prop, true);
    $specialvers[$prev] = $out;
    $prop = null;
    $prop->href = 'view.php?id=' . $WS->linkid . '&amp;page=' . $diff . '/' . urlencode($WS->pageolddata->pagename) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;ver=' . $WS->pageolddata->version . '&amp;dfcontent=11';
    $out = wiki_a(get_string('current', 'wiki'), $prop, true);
    $specialvers[$WS->pagedata->version] = $out;
    print_simple_box_start('center', '100%', '', '20');
    //get how many versions have the page
    $ead = wiki_manager_get_instance();
    $vers = $ead->get_wiki_page_versions($WS->pageolddata->dfwiki);
    if (!$vers) {
        $vers = array();
    }
    $vers = count($vers);
    echo get_string('comparewith', 'wiki') . ': ';
    //wiki_table_start();
    $j = false;
    for ($i = $WS->pagedata->version; $i > $WS->pagedata->version - $vers && $i > 0; $i--) {
        /*
         *if($j){
         *    wiki_change_column();
         *}else {
         *    $j=true;
         *}
         */
        //put in bold the compared version
        if ($i == $WS->pageverdata->version) {
            $bolds = array('<b>', '</b>');
        } else {
            $bolds = array('', '');
        }
        //print the version link
        if (isset($specialvers[$i])) {
            echo $bolds[0] . $specialvers[$i] . $bolds[1];
        } else {
            $prop = null;
            if ($i != $WS->pageolddata->version) {
                $prop->href = 'view.php?id=' . $WS->linkid . '&amp;page=' . $diff . '/' . urlencode($WS->pageolddata->pagename) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;ver=' . $WS->pageolddata->version . '/' . $i . '&amp;dfcontent=11';
                wiki_a($bolds[0] . $i . $bolds[1], $prop);
            } else {
                echo '<b>' . $i . '</b> ';
            }
        }
        if ($i != $WS->pagedata->version - $vers + 1 && $i > 1) {
            //wiki_change_column();
            echo '- ';
        }
    }
    wiki_table_end();
    print_simple_box_end();
    wiki_br();
}
コード例 #3
0
function wiki_admin($WS)
{
    global $CFG, $COURSE;
    $context = get_context_instance(CONTEXT_MODULE, $WS->cm->id);
    require_capability('mod/wiki:editawiki', $context);
    $ead = wiki_manager_get_instance();
    //new wiki_ead_tools();
    $tools = array(array(get_string('mostviewed', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . "&amp;dfcontent=0"), array(get_string('updatest', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . "&amp;dfcontent=1"), array(get_string('newest', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . "&amp;dfcontent=2"), array(get_string('wanted', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . "&amp;dfcontent=3"), array(get_string('orphaned', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . "&amp;dfcontent=4"), array(get_string('activestusers', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . "&amp;dfcontent=5"));
    $table1->align = array("left");
    $table1->tablealign = "left";
    $table1->width = '100%';
    $table1->cellpadding = 2;
    $table1->cellspacing = 0;
    $table1->head = array(get_string("stads", "wiki"));
    //print public tools
    $i = 20;
    foreach ($tools as $tool) {
        $prop = null;
        $prop->href = $tool[1];
        $out = wiki_a($tool[0], $prop, true);
        $table1->data[] = array($out);
        $i++;
    }
    if (isset($table1->data)) {
        print_table($table1);
    }
    wiki_br(1);
    $table2->align = array("left");
    $table2->tablealign = "left";
    $table2->width = '100%';
    $table2->cellpadding = 2;
    $table2->cellspacing = 0;
    $table2->head = array(get_string("admin", "wiki"));
    //teacher page dependant tools
    $tools = array(array(get_string('delpage', 'wiki'), $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;delpage=' . urlencode($WS->pagedata->pagename) . '&amp;dfsetup=0'), array(get_string('updatepage', 'wiki'), $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;updatepage=' . urlencode($WS->pagedata->pagename) . '&amp;dfsetup=1'), array(get_string('cleanpage', 'wiki'), $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;cleanpage=' . urlencode($WS->pagedata->pagename) . '&amp;dfsetup=2'));
    //teacher non page dependant tools
    $tools_indep = array(array(get_string('exportxml', 'wiki'), $CFG->wwwroot . '/mod/wiki/xml/exportxml.php?id=' . $WS->cm->id . '&amp;pageaction=exportxml'), array(get_string('importxml', 'wiki'), $CFG->wwwroot . '/mod/wiki/xml/importxml.php?id=' . $WS->cm->id), array(get_string('viewexported', 'wiki'), $CFG->wwwroot . '/mod/wiki/xml/index.php?id=' . $WS->dfwiki->course . '&amp;wdir=/exportedfiles'), array(get_string('exporthtml', 'wiki'), $CFG->wwwroot . '/mod/wiki/html/exporthtml.php?id=' . $WS->cm->id), array(get_string('wikitopdf', 'wiki'), $CFG->wwwroot . '/mod/wiki/wikitopdf.php?id=' . $WS->cm->id . '&amp;cid=' . $COURSE->id . '&amp;gid=' . $WS->groupmember->groupid . '&amp;page=' . urlencode($WS->pagedata->pagename) . '&amp;version=' . $WS->pagedata->version), array(get_string('wikibooktopdf', 'wiki'), $CFG->wwwroot . '/mod/wiki/export/wikibook2pdf/wikibooktopdf.php?cmid=' . $WS->cm->id . '&amp;cid=' . $COURSE->id . '&amp;gid=' . $WS->groupmember->groupid), array(get_string('eval_reports', 'wiki'), $CFG->wwwroot . '/mod/wiki/grades/grades.evaluation.php?cid=' . $COURSE->id . '&amp;cmid=' . $WS->cm->id));
    //public tools
    $tools_sens = array(array($WS->pagedata->editable == 0, get_string('en1page', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;enpage=' . urlencode($WS->pagedata->pagename) . '&amp;dfsetup=3'), array($WS->pagedata->editable == 1, get_string('en0page', 'wiki'), $CFG->wwwroot . $WS->wikitype . $WS->linkid . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;enpage=' . urlencode($WS->pagedata->pagename) . '&amp;dfsetup=3'));
    if (wiki_can_change($WS)) {
        foreach ($tools as $tool) {
            $prop = null;
            $prop->href = $tool[1];
            $out = wiki_a($tool[0], $prop, true);
            $table2->data[] = array($out);
            $i++;
        }
        foreach ($tools_indep as $tool) {
            $prop = null;
            $prop->href = $tool[1];
            $out = wiki_a($tool[0], $prop, true);
            $table2->data[] = array($out);
        }
        foreach ($tools_sens as $tool) {
            if ($tool[0]) {
                //    				$table2->data[] = array("<form id=\"form$i\" action=\"".$tool[2]."\" method=\"post\">"."\n".'<div><a href="javascript:document.forms[\'form'.$i.'\'].submit()" title="'.$tool[1].' '.$WS->pagedata->pagename.'">'.$tool[1].' '.$WS->pagedata->pagename.'</a>'.$tool[3]."\n"."</div></form>"."\n");
                $prop = null;
                $prop->href = $tool[2];
                $out = wiki_a($tool[1] . " " . $WS->pagedata->pagename, $prop, true);
                $table2->data[] = array($out);
                $i++;
            }
        }
    }
    if (isset($table2->data)) {
        print_table($table2);
    }
}
コード例 #4
0
function wiki_print_edit_smileis(&$WS)
{
    global $CFG;
    $smileis = array(':-)', ':-D', ';-)', ':-/', 'V-.', ':-P', 'B-)', '^-)', '8-)', '8-o', ':-(', '8-.', ':-I', ':-X', ':o)', 'P-|', '8-[', 'xx-P', '|-.', '}-]');
    //import javascript
    $prop = null;
    $prop->href = '#';
    if (isset($WS->dfcourse)) {
        $prop->class = 'wiki_folding_co';
    } else {
        $prop->class = 'wiki_folding';
    }
    $button = wiki_a('', $prop, true);
    $prop = null;
    $prop->class = 'wiki_listme';
    $prop->classli = 'wiki_listme';
    wiki_start_ul($prop);
    $prop = null;
    $prop->src = $CFG->wwwroot . '/mod/wiki/editor/images/ed_smiley1.gif';
    if (isset($WS->dfcourse)) {
        $prop->class = 'icsme_co';
    } else {
        $prop->class = 'icsme';
    }
    wiki_img($prop);
    echo $button;
    $prop = null;
    $prop->class = 'wiki_listme';
    $prop->style = 'margin:auto auto auto 5px;display:none';
    $prop->classli = 'wiki_listme';
    wiki_start_ul($prop);
    //generate tree content.
    $put = 1;
    foreach ($smileis as $smiley) {
        //image url: http://147.83.59.184/moodle15/file.php/#courseid/
        $img = $smiley;
        replace_smilies($img);
        $prop = null;
        $prop->href = 'javascript:insertTags(\'' . $smiley . '\',\'\',\'\')';
        wiki_a($img, $prop);
        //only 10 emoticons per line
        if ($put > 4) {
            wiki_br();
            $put = 0;
        }
        $put++;
    }
    wiki_end_ul();
    wiki_end_ul();
}