function get_content()
 {
     global $CFG, $WS, $USER;
     if (empty($WS->dfwiki)) {
         $this->content->text = get_string('block_warning', 'wiki');
         return $this->content;
     }
     //         $this->content->footer = '<br />'
     //             . helpbutton('ranking', $this->title, 'wiki', true, false, '', true)
     //             . $this->title;
     // dfwiki-block || course-block
     if ($this->instance->pagetype == 'mod-wiki-view') {
         $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id;
     } else {
         $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
     }
     if (!empty($WS->dfwiki) && $WS->dfwiki->votemode == 0) {
         $this->content->text = get_string('vote_warning', 'wiki');
         return $this->content;
     }
     $vote = optional_param('Vote', NULL, PARAM_ALPHA);
     $wikimanager = wiki_manager_get_instance();
     if ($WS->dfwiki->votemode == 1 and $vote == 'Vote') {
         $wikimanager->vote_page($WS->dfwiki->id, $WS->page, $WS->pagedata->version, $USER->username);
     }
     $ranking = $wikimanager->get_vote_ranking($WS->dfwiki->id);
     $this->content = new stdClass();
     if (!$ranking) {
         $this->content->text = get_string('nopages', 'wiki');
         $this->content->footer = '';
         return $this->content;
     }
     if (right_to_left()) {
         // rtl support for table cell alignment (nadavkav patch)
         $alignmentleft = 'right';
         $alignmentright = 'left';
     } else {
         $alignmentleft = 'left';
         $alignmentright = 'right';
     }
     $text = '<table border="0" width="100" cellpadding="0" cellspacing="0">' . '<tr><th>' . get_string('page') . '</th><th>' . get_string('votes', 'wiki') . '</th></tr>';
     $n_rows = 0;
     foreach ($ranking as $row) {
         $text .= '<tr><td align="' . $alignmentleft . '">' . '<a href="' . $dir . '&amp;page=' . urlencode($row->pagename) . '">' . $this->trim_string($row->pagename, 20) . '</a></td>' . '<td align="center">' . $row->votes . '</td></tr>';
         // Show only the first 5 rows.
         if (++$n_rows == 5) {
             break;
         }
     }
     $text .= '</table>';
     $this->content->text = $text;
     $this->content->footer = '&nbsp;';
     return $this->content;
 }
    function get_content()
    {
        global $CFG, $WS;
        if ($this->content !== NULL) {
            return $this->content;
        }
        //If we are out of a dfwiki activity or in a different
        //dfwiki format course and we want to create a block:
        if (empty($WS->dfwiki)) {
            $this->content->text = get_string('block_warning', 'wiki');
            return $this->content;
        }
        $this->content = new stdClass();
        $this->content->items = array();
        $this->content->icons = array();
        //$this->content->footer = '<br />'.helpbutton ('updated', get_string('block_updated', 'wiki'), 'wiki', true, false, '', true).get_string('block_updated', 'wiki');
        $ead = wiki_manager_get_instance();
        $pages = $ead->get_wiki_most_uptodate_pages(10);
        // dfwiki-block || course-block
        $dir = "";
        if ($this->instance->pagetype == "mod-wiki-view") {
            $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id;
        } else {
            $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
        }
        // rtl / ltr CSS alignment support (nadavkav)
        if (right_to_left()) {
            $nwikialignment = 'nwikirightnow';
        } else {
            $nwikialignment = 'nwikileftnow';
        }
        if (count($pages) != 0) {
            $text = '<table border="0" cellpadding="0" cellspacing="0">';
            $i = 1;
            foreach ($pages as $page) {
                $pageinfo = wiki_page_last_version($page);
                $brs = strlen($page) > 12 ? '<br />&nbsp;&nbsp;&nbsp;' : '';
                $text .= '<tr>
					<td class="' . $nwikialignment . '">
						' . $i . '- <a href="' . $dir . '&amp;page=' . urlencode($page) . '" title="' . $page . '">' . $this->trim_string($page, 40) . '</a>' . $brs . '
						&nbsp;-&nbsp;<small>(' . strftime('%d %b %y', $pageinfo->lastmodified) . ')</small>
						' . wiki_get_user_info($pageinfo->author, 40, false) . '
					</td>
					</tr>';
                $i++;
            }
            $text .= '</table>';
        } else {
            $text = get_string('nopages', 'wiki');
        }
        $this->content->text = $text;
        return $this->content;
    }
/**
 * execute configuration functions
 */
function wiki_config()
{
    $wikiManager = wiki_manager_get_instance('moodle');
    wiki_param(null, null, 'set_info');
    $course = wiki_param('course');
    require_login($course->id);
    wiki_setup_content();
    //execute setup callback functions
    wiki_execute_callbacks('dfsetup');
    /*$callbacks = wiki_get_callbacks ('dfsetup');
    	print_object ($callbacks);
    	foreach ($callbacks as $callback) {
    		if (function_exists($callback)) $callback ();
    	}*/
}
 function get_content()
 {
     global $CFG, $WS;
     if ($this->content !== NULL) {
         return $this->content;
     }
     //If we are out of a dfwiki activity or in a different
     //dfwiki format course and we want to create a block:
     if (empty($WS->dfwiki)) {
         $this->content->text = get_string('block_warning', 'wiki');
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     //$this->content->footer = '<br />'.helpbutton ('wanted', get_string('block_wanted', 'wiki'), 'wiki', true, false, '', true).get_string('block_wanted', 'wiki');
     //         $this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki') .
     //                 helpbutton ('wanted', get_string('block_wanted', 'wiki'), 'wiki', true, false, '', true);
     $ead = wiki_manager_get_instance();
     $pages = $ead->get_wiki_wanted_pages();
     $pages = wiki_remove_section_links($pages);
     // dfwiki-block || course-block
     $dir = "";
     if ($this->instance->pagetype == "mod-wiki-view") {
         $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id;
     } else {
         $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
     }
     if (count($pages) != 0) {
         $text = '<table border="0" cellpadding="0" cellspacing="0">';
         foreach ($pages as $page) {
             $text .= '<tr>
           <td class="nwikileftnow">
             ' . format_text($this->trim_string($page, 20), FORMAT_PLAIN) . '<a href="' . $dir . '&amp;page=' . urlencode($page) . '">?</a>
           </td>
           </tr>';
         }
         $text .= '</table>';
     } else {
         $text = get_string('nopages', 'wiki');
     }
     $this->content->text = $text;
     return $this->content;
 }
 function get_content()
 {
     global $CFG, $WS, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     //$this->content->footer = '<br />'.helpbutton ('contributions', get_string('block_contributions', 'wiki'), 'wiki', true, false, '', true).get_string('block_contributions', 'wiki');
     //$this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki').helpbutton ('contributions', get_string('block_contributions', 'wiki'), 'wiki', true, false, '', true);
     //If we are out of a dfwiki activity or in a different
     //dfwiki format course and we want to create a block:
     if (empty($WS->dfwiki)) {
         $this->content->text = get_string('block_warning', 'wiki');
         return $this->content;
     }
     $ead = wiki_manager_get_instance();
     $pages = $ead->user_activity($USER->username);
     $dir = "";
     if ($this->instance->pagetype == "mod-wiki-view") {
         $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id;
     } else {
         $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
     }
     if (count($pages) != 0) {
         $text = '<table border="0" cellpadding="0" cellspacing="0">';
         foreach ($pages as $page) {
             $pageinfo = wiki_page_last_version($page);
             $modif = $pageinfo->author == $USER->username ? '' : ' ' . wiki_get_user_info($pageinfo->author, 20, false);
             $text .= '<tr>
 				<td class="nwikileftnow">
 					<a href="' . $dir . '&amp;page=' . urlencode($page) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '" title="' . urlencode($page) . '">' . format_text($this->trim_string($page, 30), FORMAT_PLAIN) . '</a>' . $modif . '
 				</td>
 				</tr>';
         }
         $text .= '</table>';
     } else {
         $text = get_string('nopages', 'wiki');
     }
     $this->content->text = $text;
     return $this->content;
 }
    function get_content()
    {
        global $WS, $CFG;
        if ($this->content !== NULL) {
            return $this->content;
        }
        //Scritp WIKI_TREE
        $prop = null;
        $prop->type = 'text/javascript';
        if (isset($WS->dfcourse)) {
            $prop->src = '../mod/wiki/editor/wiki_tree.js';
        } else {
            $prop->src = 'editor/wiki_tree.js';
        }
        wiki_script('', $prop);
        $this->content = new stdClass();
        $this->content->items = array();
        $this->content->icons = array();
        //$this->content->footer = '<br />'.helpbutton ('index', get_string('block_index', 'wiki'), 'wiki', true, false, '', true).get_string('block_index', 'wiki');
        //If we are out of a dfwiki activity or in a different
        //dfwiki format course and we want to create a block:
        if (empty($WS->dfwiki)) {
            $this->content->text = get_string('block_warning', 'wiki');
            return $this->content;
        }
        $list = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="nwikileftnow">
			<ul class="wiki_listme">';
        $ead = wiki_manager_get_instance();
        if (isset($WS->pagedata->pagename)) {
            $this->levelsel = $ead->level($WS->pagedata->pagename);
        }
        //call recursive function
        $list .= $this->built_index($WS->dfwiki->pagename, 0);
        $list .= '</ul></td></tr></table>';
        $this->content->text = $list;
        $this->content->footer .= '<style>.wiki_listme { padding-right:5px; } .dir-rtl td.nwikileftnow  { text-align:right; } </style>';
        return $this->content;
    }
 function get_content()
 {
     global $CFG, $WS;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     //$this->content->footer = '<br />'.helpbutton ('navigator', get_string('block_navigator', 'wiki'), 'wiki', true, false, '', true).get_string('block_navigator', 'wiki');
     //         $this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki') .
     //                 helpbutton ('navigator', get_string('block_navigator', 'wiki'), 'wiki', true, false, '', true);
     // dfwiki-block || course-block
     $dir = "";
     if (isset($this->instance->pagetype)) {
         if ($this->instance->pagetype == "mod-wiki-view") {
             $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id;
         } else {
             $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
         }
     }
     //If we are out of a dfwiki activity or in a different
     //dfwiki format course and we want to create a block:
     if (empty($WS->dfwiki)) {
         $this->content->text = get_string('block_warning', 'wiki');
         return $this->content;
     }
     //starts ead tools
     $ead = wiki_manager_get_instance();
     $text = '<b><span class="nwikiunderline">' . get_string('camefrom', 'wiki') . '</span></b>';
     $camefroms = $ead->get_wiki_page_camefrom(addslashes($WS->pagedata->pagename));
     $text .= '<table border="0" cellpadding="0" cellspacing="0">';
     if ($camefroms == false) {
         $text .= '<tr><td></td></tr>';
     }
     foreach ($camefroms as $camefrom) {
         $text .= '<tr><td class="nwikileftnow"><a href="' . $dir . '&amp;page=' . urlencode($camefrom->pagename) . '">' . format_text($this->trim_string($camefrom->pagename, 36), FORMAT_HTML) . '</a></td></tr>';
     }
     $text .= '</table>';
     $text .= '<hr /><b><span class="nwikiunderline">' . get_string('goesto', 'wiki') . '</span></b>';
     $goestos = $ead->get_wiki_page_goesto($WS->pagedata->pagename);
     $text .= '<table border="0" cellpadding="0" cellspacing="0">';
     if ($goestos == false) {
         $text .= '<tr><td></td></tr>';
     }
     // rtl / ltr CSS alignment support (nadavkav)
     if (right_to_left()) {
         $nwikialignment = 'nwikirightnow';
     } else {
         $nwikialignment = 'nwikileftnow';
     }
     foreach ($goestos as $goesto) {
         if (wiki_page_exists($WS, $goesto)) {
             $text .= '<tr><td class="' . $nwikialignment . '"><a href="' . $dir . '&amp;page=' . urlencode($goesto) . '">' . format_text($this->trim_string($goesto, 37), FORMAT_HTML) . '</a></td></tr>';
         } else {
             $text .= '<tr><td class="' . $nwikialignment . '"><span class="nwikiwanted"><a href="' . $dir . '&amp;page=' . urlencode($goesto) . '">' . format_text($this->trim_string($goesto, 37), FORMAT_HTML) . '</a></span></td></tr>';
         }
     }
     $text .= '</table>';
     $this->content->text = $text;
     return $this->content;
 }
function wiki_ead_print_cleanpage()
{
    global $WS, $dfwiki_ead_stat;
    echo '<h1>' . get_string('cleanpage', 'wiki') . '</h1>';
    echo '<div class="box generalbox generalboxcontent boxaligncenter">';
    switch ($dfwiki_ead_stat) {
        case 'cleanok':
            echo '<h2>' . get_string('cleanok', 'wiki') . ' ' . stripslashes(optional_param('cleanpage', NULL, PARAM_FILE)) . '</h2><br />';
            echo '<form method="post" action="view.php?id=' . $WS->cm->id . '">
    				<div class="textcenter"><input type="submit" value="' . get_string('continue') . '" /></div>
    			</form>';
            break;
        case 'cleanconfirm':
            echo '<h2>' . get_string('cleanconfirm', 'wiki') . ' ' . stripslashes(optional_param('cleanpage', NULL, PARAM_FILE)) . '?</h2>';
            echo '<p>' . get_string('cleanmessage', 'wiki') . '</p>';
            echo '<form method="post" action="view.php?id=' . $WS->cm->id . '&amp;cleanpage=' . optional_param('cleanpage', NULL, PARAM_FILE) . '">
    				<table border="0" class="boxaligncenter">
    				<tr>
    				<td>
    					' . get_string('howmanyversions', 'wiki') . '
    				</td>
    				<td>
					<input type="hidden" name="dfsetup" value="2" />
					<select name="dfformcleanvers">';
            //get the versions count
            $pageinfo = wiki_page_last_version(optional_param('cleanpage', NULL, PARAM_FILE));
            $ead = wiki_manager_get_instance();
            $versions = $ead->versions(optional_param('cleanpage', NULL, PARAM_FILE));
            $ops = array(5, 10, 20, 50, 100, 150, 200, 300, 500, 1000);
            echo '<option value="' . $pageinfo->version . '" selected="selected">' . get_string('none') . '</option>';
            foreach ($ops as $op) {
                if ($op < $versions) {
                    echo '<option value="' . ($pageinfo->version - $op) . '">' . $op . '</option>';
                }
            }
            echo '			</select>
    				</td></tr>
    				</table>

    				<p class="textcenter">
						<input type="submit" name="dfformcleanconfirm" value="    ' . get_string('yes') . '    " />
    				</p>
					</form>


    				<form method="post" action="view.php?id=' . $WS->cm->id . '">
					<p class="textcenter">
						<input type="submit" value="    ' . get_string('no') . '    " />
					</p>
					</form>';
            break;
        case 'cleanerror':
            echo '<h2>' . get_string('cleanerror', 'wiki') . ' ' . stripslashes(optional_param('cleanpage', NULL, PARAM_FILE)) . '</h2><br />';
            echo '<form method="post" action="view.php?id=' . $WS->cm->id . '">
    				<div class="textcenter"><input type="submit" value="' . get_string('continue') . '" /></div>
    			  </form>';
            break;
    }
    echo '</div>';
}
function wiki_get_page_version($prefix, $pagename, $dfwikiid, $groupid, $memberid, $version)
{
    $pageid = new wiki_pageid($dfwikiid, $pagename, $version, $groupid, $memberid);
    $wikimanager = wiki_manager_get_instance();
    return $wikimanager->get_wiki_page_by_pageid($pageid);
}
 function get_content()
 {
     global $CFG, $WS, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     // dfwiki-block || course-block
     if (isset($this->instance->pagetype)) {
         if ($this->instance->pagetype == 'mod-wiki-view') {
             $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id . '&amp;name=dfwikipage';
         } else {
             $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
         }
     }
     $this->content = new stdClass();
     // If we are out of a dfwiki activity or in a different
     // dfwiki format course and we want to create a block:
     if (empty($WS->dfwiki)) {
         $this->content->footer = '';
         $this->content->text = get_string('block_warning', 'wiki');
         return $this->content;
     }
     $this->content->items = array();
     $this->content->icons = array();
     /*        $this->content->footer = '<br />' . helpbutton ('synonymous',
               $this->title, 'wiki', true, false, '', true) . $this->title;*/
     /*        $this->content->footer = '<hr />'.get_string('block_helpaboutblock', 'wiki') .
               helpbutton ('synonymous', get_string('block_synonymous', 'wiki'), 'wiki', true, false, '', true);*/
     $list = '';
     $wikimanager = wiki_manager_get_instance();
     $pageid = new wiki_pageid();
     if (preg_match("/^discussion:/", $WS->page) or !$wikimanager->page_exists($pageid)) {
         $this->content->text = get_string('nopages', 'wiki');
         return $this->content;
     }
     $delsyn = optional_param('delsyn', NULL, PARAM_FILE);
     // delete synonymous
     if (isset($delsyn)) {
         $wikimanager->delete_synonym(new wiki_synonym($delsyn, $pageid));
     }
     //wiki_dfform_param($WS);
     //insert new synonymous
     $syn = optional_param('dfformsyn', NULL, PARAM_FILE);
     if (isset($syn)) {
         $name = optional_param('dfformname', NULL, PARAM_FILE);
         $pageid_syn = clone $pageid;
         $pageid_syn->name = $name;
         if ($wikimanager->page_exists($pageid_syn)) {
             $list .= '<span class="except">' . get_string('synexists', 'wiki') . ' ' . $name . '</span><hr />';
         } else {
             $name = str_replace('\\', '_', str_replace('/', '_', $name));
             $synonym = new wiki_synonym($name, $pageid);
             if (!$wikimanager->insert_synonym($synonym)) {
                 $list .= '<span class="except">' . get_string('errorsaving') . '</span><hr />';
             }
             unset($syn);
         }
     }
     //print content
     $list .= '<table border="0">
             <tr>
                 <td><b>' . $this->trim_string($WS->page, 20) . '</b></td>
             </tr>';
     // select synonymous
     if ($syns = $wikimanager->get_synonyms($pageid)) {
         foreach ($syns as $syn) {
             $list .= "<tr><td>{$syn->name} ";
             if ($syn->deletable) {
                 $list .= '<a href="' . $dir . '&amp;gid=' . $pageid->groupid . '&amp;uid=' . $pageid->ownerid . '&amp;page=' . urlencode($pageid->name) . '&amp;delsyn=' . urlencode($syn->name) . '"><img src="' . $CFG->wwwroot . '/mod/wiki/images/delete.gif" alt="" /></a>';
             }
             $list .= '</td></tr>';
         }
     }
     $list .= '</table>';
     //Converts reserved chars for html to prevent chars misreading
     $pagetemp = stripslashes_safe($WS->page);
     if ($wikimanager->page_is_editable($pageid)) {
         $list .= '<br /><form method="post" action="' . $dir . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '&amp;page=' . urlencode($pagetemp) . '"><div>
                     <input type="text" name="dfformname" /><br />
                     <input type="submit" name="dfformsyn" value="' . get_string('add') . '" />
                 </div></form>';
     }
     $this->content->text = $list;
     return $this->content;
 }
function wiki_grade_get_wikigrade($WS, $gradeid = null)
{
    global $CFG, $USER;
    $wikimanager = wiki_manager_get_instance();
    $scale = get_record('scale', 'id', (int) $WS->dfwiki->notetype);
    $user = optional_param('uid', 0, PARAM_INT);
    $group = optional_param('gid', 0, PARAM_INT);
    $where = wiki_grade_get_sql_filter($WS->cm->groupmode, $WS->dfwiki->studentmode, $group, $user);
    if (!$gradeid) {
        $gradeid = get_field_sql('SELECT AVG(wikigrade) as wikigrade 
                                  FROM ' . $CFG->prefix . 'wiki_evaluation
                                  WHERE wikiid=' . $WS->dfwiki->id . ' AND pagename="' . addslashes($WS->page) . '"' . ' AND ' . $where . ' GROUP BY pagename, wikiid, groupid, ownerid');
    }
    if (!$gradeid) {
        return get_string('eval_notset', 'wiki');
    }
    $scale_values = split(',', $scale->scale);
    $num_values = count($scale_values);
    $values = array();
    $i = 0;
    while ($i < $num_values) {
        $values[$i + 1] = trim($scale_values[$i]);
        $i++;
    }
    $stringwikigrade = wiki_grade_translate($gradeid, $values);
    return $stringwikigrade;
}
function wiki_hist_move_ver($symbol, $num, $diff = 'diff')
{
    global $WS;
    //this is the destiny version
    $dest = $WS->pageolddata->version + $num;
    //get first and last version
    $last = $WS->pagedata->version;
    $ead = wiki_manager_get_instance();
    $vs = $ead->get_wiki_page_versions($WS->pageolddata->pagename);
    if (!$vs) {
        $vs = array();
    }
    $first = $last - count($vs);
    //get compare version
    $comp = $WS->pageverdata->version + $num;
    if ($comp > $last || $comp <= $first) {
        $comp = $WS->pageverdata->version;
    }
    //return symbol if it's printable
    if ($dest <= $last && $dest > $first) {
        return '<a 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=' . $dest . '/' . $comp . '&amp;dfcontent=11">' . $symbol . '</a>';
    }
    return '';
}
function parse_username_datetime($matches)
{
    $wikimanager = wiki_manager_get_instance();
    $page = wiki_param('pagedata');
    $author = $wikimanager->get_user_info($page->author);
    return $author->firstname . " " . $author->lastname . ", " . strftime('%x') . " - " . strftime('%X');
}
 function get_content()
 {
     global $CFG, $WS;
     $wiki = wiki_param('dfwiki');
     $groupmember = wiki_param('groupmember');
     if ($this->content !== NULL) {
         return $this->content;
     }
     //Scritp WIKI_TREE
     $prop = null;
     $prop->type = 'text/javascript';
     if (isset($WS->dfcourse)) {
         $prop->src = '../mod/wiki/editor/wiki_tree.js';
     } else {
         $prop->src = 'editor/wiki_tree.js';
     }
     wiki_script('', $prop);
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     //$this->content->footer = '<br />'.helpbutton ('list_pages', get_string('block_list_pages', 'wiki'), 'wiki', true, false, '', true).get_string('block_list_pages', 'wiki');
     $this->content->items[] = '<a href="http://www.google.com">google</a>';
     $this->content->icons[] = '<img src="icon.gif" alt="">';
     //If we are out of a dfwiki activity or in a different
     //dfwiki format course and we want to create a block:
     if (empty($WS->dfwiki)) {
         $this->content->text = get_string('block_warning', 'wiki');
         return $this->content;
     }
     $ead = wiki_manager_get_instance();
     $pages = $ead->get_wiki_page_names_of_wiki($wiki, $groupmember->groupid);
     $this->orderpages($pages);
     $syns = $ead->get_wiki_synonyms();
     $this->orderpages($syns);
     $list = '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="nwikileftnow">
 			<ul class="wiki_listme">';
     if (!isset($WS->pagedata->pagename)) {
         $WS->load_page_data();
     }
     if (count($pages) != 0) {
         foreach ($this->ordereds as $key => $ordered) {
             //chack if the letter is the curretn one.
             if ($key == $this->get_index($WS->pagedata->pagename)) {
                 $display = '';
                 $image_ico = $this->images['minus'];
             } else {
                 $display = 'display:none';
                 $image_ico = $this->images['plus'];
             }
             $list .= '<li class="wiki_listme">' . $image_ico . '<a href="#" class="wiki_folding">' . $key . '</a>
 					<ul class="wiki_listme" style="margin:auto auto auto 15px;' . $display . '">';
             // dfwiki-block || course-block
             $dir = "";
             if ($this->instance->pagetype == "mod-wiki-view") {
                 $dir = $CFG->wwwroot . '/mod/wiki/view.php?id=' . $WS->cm->id;
             } else {
                 $dir = $CFG->wwwroot . '/course/view.php?id=' . $WS->cm->course;
             }
             foreach ($ordered as $link) {
                 if (in_array($link, $syns)) {
                     $page_icon = $this->images['syn'];
                     $page = wiki_get_real_pagename($link);
                 } else {
                     $page_icon = $this->images['square'];
                     $page = $link;
                 }
                 $list .= '<li class="wiki_listme">' . $page_icon . '<a href="' . $dir . '&amp;page=' . urlencode($page) . '&amp;gid=' . $WS->groupmember->groupid . '&amp;uid=' . $WS->member->id . '" title="' . urlencode($link) . '">' . format_text($this->trim_string($link, 20), FORMAT_PLAIN) . '</a>' . '</li>';
             }
             $list .= '</ul></li>';
         }
     } else {
         $list .= '<li>' . get_string('nopages', 'wiki') . '</li>';
     }
     $list .= '</ul></td></tr></table>';
     $this->content->text = $list;
     $this->content->footer .= '<style>.wiki_listme { padding-right:5px; } .dir-rtl td.nwikileftnow  { text-align:right; } </style>';
     return $this->content;
 }
function wiki_print_teacher_selection($cm, $dfwiki)
{
    global $CFG, $COURSE;
    // dont print the list of teachers for wiki commune
    $cm = get_coursemodule_from_instance('wiki', $dfwiki->id, $COURSE->id);
    if (!($cm->groupmode == '0' && $dfwiki->studentmode == '0')) {
        if ($dfwiki->listofteachers) {
            //Course teachers list
            $wikimanager = wiki_manager_get_instance();
            $listteachers = get_course_teachers($COURSE->id);
            //$wikimanager->get_course_teachers($COURSE->id); //(nadavkav)
            //print the teachers list
            wiki_print_menu_teachers($listteachers, $cm);
        }
    }
}
/**
 * this function return an array with the pagenames of search results
 */
function wiki_part_search_result($text)
{
    global $CFG, $WS;
    $res = array('pagename' => array(), 'content' => array());
    // mount search string
    $field = '%';
    $fields = explode(' ', $text);
    foreach ($fields as $f) {
        $field .= $f . '%';
    }
    $ead = wiki_manager_get_instance();
    $wiki = wiki_param('dfwiki');
    $groupmember = wiki_param('groupmember');
    $pages = $ead->get_wiki_page_names_of_wiki($wiki, $groupmember->groupid);
    foreach ($pages as $page) {
        $pageinfo = wiki_page_last_version($page);
        $contentfound = count($fields) != 0;
        $namefound = count($fields) != 0;
        foreach ($fields as $f) {
            $f = stripslashes_safe($f);
            $namefound = $namefound && stripos($pageinfo->pagename, $f) !== false;
            $contentfound = $contentfound && strpos($pageinfo->content, $f) !== false;
        }
        if ($contentfound) {
            $res['content'][] = $pageinfo->pagename;
        }
        if ($namefound) {
            $res['pagename'][] = $pageinfo->pagename;
        }
    }
    // search in synonyms
    $wikimanager = wiki_manager_get_instance();
    $synonyms = $wikimanager->get_synonyms_by_wikiid($WS->dfwiki->id);
    foreach ($synonyms as $synonym) {
        $found = count($fields) != 0;
        foreach ($fields as $f) {
            $f = stripslashes_safe($f);
            $found = $found && stripos($synonym->name, $f) !== false;
        }
        if ($found && !in_array($synonym->pageid->name, $res['pagename'])) {
            $res['pagename'][] = $synonym->pageid->name;
        }
    }
    return $res;
}