function form()
 {
     $div =& html_div_center();
     $div->set_id("folderlist");
     /*
      * Add folder path to id inside a span
      */
     $path = html_div();
     $link = html_a(Util::format_URLPath('authortool/index.php', "status=list&current_folder_id=0"), "/", NULL, '_top', agt('accessfolder'));
     $path->add(agt("fd_folder:"), $link);
     foreach ($this->FolderDeeps as $FolderElement) {
         $link = html_a(Util::format_URLPath('authortool/index.php', "status=list&current_folder_id=" . $FolderElement['folder_id']), $FolderElement['folder_name'], NULL, '_top', agt('accessfolder'));
         $path->add($link);
     }
     $div->add($path);
     /*
      * Now we create a table into the div that'll contain folders & files list
      */
     $tableFolder =& html_table();
     /*
      * Header
      */
     /*
      * The next lines allow the user order folders & documents
      * clicking in any of the header th titles
      */
     $i = 0;
     foreach ($this->fdOrderbyArray as $orderb) {
         $fd_orderb_link = '';
         if ($orderb != "id") {
             if ($this->orderby == $orderb) {
                 $orderhow2 = $this->orderhow == 1 ? 0 : 1;
                 $fd_orderb_link = html_a(Util::format_URLPath('authortool/index.php', "status=list&current_folder_id=" . $this->FolderProperties['folder_id'] . "&orderby={$orderb}&\r\n\t\t\t\t\t\torderhow={$orderhow2}"), NULL, NULL, '_top', agt("fd_orderby") . _HTML_SPACE . agt($orderb));
                 $fd_orderb_image = $this->orderhow == 1 ? Theme::getThemeImage('up.png') : Theme::getThemeImage('down.png');
                 $fd_orderb_link->add(agt("fd_{$orderb}"), _HTML_SPACE, $fd_orderb_image);
             } else {
                 $fd_orderb_link = html_a(Util::format_URLPath('authortool/index.php', "status=list&current_folder_id=" . $this->FolderProperties['folder_id'] . "&orderby={$orderb}&\r\n\t\t\t\t\t\torderhow=0"), agt("fd_{$orderb}"), NULL, '_top', agt("fd_orderby") . _HTML_SPACE . agt($orderb));
             }
             $fd_orderb[$i] = html_th($fd_orderb_link);
             if ($orderb == "name") {
                 $fd_orderb[$i]->set_tag_attribute('colspan', 2);
             }
             $i++;
         }
     }
     $tableFolder->add($fd_orderb[0], $fd_orderb[1], $fd_orderb[2], $fd_orderb[3], $fd_orderb[4], $fd_orderb[5], $fd_orderb[6]);
     /*
      * checkbox index
      */
     $i = 0;
     /*
      * initial cell color
      */
     $altcellcolor = "altcellcolor2";
     /*
      * Now we'll add the folder list to the table
      */
     foreach ($this->FolderList as $FolderElement) {
         /*
          * Alternate cell color
          */
         $altcellcolor = $altcellcolor == "altcellcolor1" ? "altcellcolor2" : "altcellcolor1";
         if ($FolderElement['shared'] == 1) {
             $folderImage = Theme::getThemeImage("modules/links.png");
         } else {
             $folderImage = Theme::getThemeImage("filemanager/folder.png");
         }
         /*
          * Now depending on enviromental permissions, we'll add possible actions:
          */
         $actions = "";
         if ($FolderElement['folder_perms']['w']) {
             /*
              * Add edit action
              */
             $actions = html_div();
             $actions->add(html_a(Util::format_URLPath('authortool/index.php', "status=send_folder&current_folder_id=" . $FolderElement['folder_id']), Theme::getThemeImage("edit.png"), NULL, '_top', agt('editfolder')));
             $actions->add(_HTML_SPACE);
             /*
              * Add delete action
              */
             $actions->add(html_a(Util::format_URLPath('authortool/index.php', "status=delete&what=folder&current_folder_id=" . $FolderElement['folder_id']), Theme::getThemeImage("delete.png"), NULL, '_top', agt('deletefolder')));
             if (!$FolderElement['shared']) {
                 /*
                  * Add share action
                  */
                 $actions->add(_HTML_SPACE);
                 $actions->add(html_a(Util::format_URLPath('authortool/index.php', "status=send_folder&submit=1&shared=1" . "&folder_id=" . $FolderElement['folder_id'] . "&current_folder_id=" . $FolderProperties['folder_id'] . "&folder_name=" . $FolderElement['folder_name'] . "&folder_comment=" . $FolderElement['folder_comment'] . "&folder_perms=" . $FolderElement['folder_perms2']), Theme::getThemeImage("modules/links.png"), NULL, '_top', agt('sharefolder')));
             }
         }
         /*
          * Now we'll set the folder name element, which will be a
          * link to access to the folder. It will have the number of
          * direct folder and files it has in brakets.
          */
         $link = html_a(Util::format_URLPath('authortool/index.php', "status=list&current_folder_id=" . $FolderElement['folder_id']), $FolderElement['folder_name'], NULL, '_top', agt('accessfolder'));
         $count_element = " (" . $FolderElement['folder_count_element'] . ")";
         $link_td = html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL);
         $link_td->add($link, $count_element);
         /*
          * Add current row to the table 
          */
         $tableFolder->add_row(html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $folderImage), $link_td, html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $FolderElement['folder_date']), html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, substr($FolderElement['folder_comment'], 0, 30)), " ", " ", agt("fd_folder"), html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $actions));
         $i++;
     }
     /*
      * Needed for guessing file icon depending n the file extension
      */
     include_once Util::app_Path("filemanager/include/classes/filedisplay.class.php");
     /*
      * Now we'll add the file list to the table
      */
     if ($this->FileList[0]['document_id'] == NULL && $this->FolderList == NULL) {
         $the_td = html_td(NULL, NULL, agt('folder_empty'));
         $the_td->set_tag_attribute('colspan', 8);
         $the_td->set_tag_attribute('colspan', 8);
         $tableFolder->add_row($the_td);
     } else {
         foreach ($this->FileList as $FileElement) {
             /*
              * Alternate cell color
              */
             $altcellcolor = $altcellcolor == "altcellcolor1" ? "altcellcolor2" : "altcellcolor1";
             /*
              * Guess document file type image
              */
             $fileImage = Theme::getThemeImage("filemanager/" . fileDisplay::choose_image($FileElement['document_name']));
             /*
              * Set posible actions depending on permissions
              */
             $actions = html_div();
             if ($this->FolderProperties['folder_perms']['w']) {
                 /*
                  * Add edit action
                  */
                 $actions->add(html_a(Util::format_URLPath('authortool/index.php', "status=send_file&document_id=" . $FileElement['document_id']), Theme::getThemeImage("edit.png"), NULL, '_top', agt('editfile')));
                 $actions->add(_HTML_SPACE);
                 /*
                  * Add delete action
                  */
                 $actions->add(html_a(Util::format_URLPath('authortool/index.php', "status=delete&what=document&document_id=" . $FileElement['document_id']), Theme::getThemeImage("delete.png"), NULL, '_top', agt('deletefile')));
                 if ($this->FolderProperties['folder_perms']['p'] && !$FileElement['document_accepted']) {
                     /*
                      * Add share action
                      */
                     $actions->add(_HTML_SPACE);
                     $actions->add(html_a(Util::format_URLPath('authortool/index.php', "status=send_document&submit=1&shared=1" . "&document_id=" . $FileElement['document_id'] . "&document_comment=" . $FileElement['document_comment'] . "&document_name=" . $FileElement['document_name'] . "&document_mime=" . $FileElement['document_mime'] . "&document_md5=" . $FileElement['document_md5'] . "&document_junk=" . $FileElement['document_junk'] . "&date_publish=" . $FileElement['date_publish'] . "&document_name=" . $FileElement['document_name'] . "&document_size=" . $FileElement['document_size'] . "&authortool_editable=" . $FileElement['authortool_editable'] . "&current_folder_id=" . $FolderProperties['folder_id'] . "&folder_perms=" . $FileElement['folder_perms2']), Theme::getThemeImage("modules/addpage.png"), NULL, '_top', agt('sharefile')));
                 }
             }
             /*
              * Show share satus image
              */
             if ($FileElement['document_accepted']) {
                 $accepted = Theme::getThemeImage("right.png");
             } else {
                 $accepted = Theme::getThemeImage("wrong.png");
             }
             /*
              * Now we'll set the file name element, which will be a
              * link to show the file.
              */
             $link = html_a(Util::format_URLPath('authortool/index.php', "status=show_file&document_id=" . $FileElement['document_id']), $FileElement['document_name'], NULL, '_top', agt('showfile'));
             /*
              * Add current row to the table 
              */
             $tableFolder->add_row(html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $fileImage), html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $link), html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $FileElement['date_publish']), html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, substr($FileElement['document_comment'], 0, 30)), html_td('altcellcolor2', NULL, $FileElement['user_alias']), html_td('altcellcolor2', NULL, $accepted), html_td('altcellcolor2', NULL, $FileElement['document_mime']), html_td($altcellcolor == "altcellcolor2" ? $altcellcolor : NULL, NULL, $actions));
             $i++;
         }
     }
     /*
      * Finally add table to the main element (the div)
      */
     $div->add($tableFolder);
     /*
      * Add checkboxex actions (only delete for now)
      */
     /*
     		$submitdel = form_submit('delete', agt('delete'));
     		$submitdel->add(Theme::getThemeImage('filemanager/delete.gif'));
     		
     		$div->add(Theme::getThemeImage('filemanager/arrow_ltr.gif'));
     		$div->add(_HTML_SPACE);
     		$div->add(agt('execution'));
     		$div->add(_HTML_SPACE);
     		$div->add($submitdel);*/
     return $div;
 }
 function addDocumentInfo($_id, $_name, $_date, $_owner, $_owner_id, $_downs, $_size, $_visible = 1, $_lock = 1, $_share = 1, $_folder = false)
 {
     $user_id = $this->getViewVariable('user_id');
     $profile_id = $this->getViewVariable('profile_id');
     //If not Admin, teacher or tutor
     if ($profile_id >= 4) {
         //Test ownership and visibility
         if ($user_id != $_owner_id && $_visible == 0) {
             return;
         }
     }
     //Necesito dos clases: una para visible y otra para invisible. La de invisible es para diferenciar en la vista del propietario o administrador
     $row = html_tr();
     $elem1 = html_td('ptabla03', '', _HTML_SPACE);
     if ($_folder) {
         $link = $this->imag_alone(Util::format_URLPath('filemanager/index.php', "folder_id={$_id}"), Theme::getThemeImagePath('filemanager/folder.png'), agt('Entrar'));
     } else {
         include_once Util::app_Path("filemanager/include/classes/filedisplay.class.php");
         $image = Theme::getThemeImagePath("filemanager/" . fileDisplay::choose_image($_name));
         $link = html_a("#", "");
         $link->add(html_img($image, 16, 16, null, agt('Ver')));
         $path_action = Util::main_URLPath('var/data/' . $_name);
         $link->set_tag_attribute("onClick", "javascript:newWin('" . $path_action . "',750,400,25,100)");
     }
     $elem2 = html_td('ptabla03', '', $link);
     $elem2->set_tag_attribute('align', 'center');
     $elem3 = html_td('ptabla03', '', $_name);
     $elem4 = html_td('ptabla03', '', $_date);
     $elem5 = html_td('ptabla03', '', $_owner);
     $elem6 = html_td('ptabla03', '', $_downs);
     $elem7 = html_td('ptabla03', '', $_size);
     if (!$_folder) {
         $link = html_a("#", "");
         $link->add(html_img(Theme::getThemeImagePath('disquette.jpg'), null, null, null, agt('Descargar')));
         $path_action = Util::main_URLPath('var/data/' . $_name);
         $link->set_tag_attribute("onClick", "javascript:newWin('" . $path_action . "',750,400,25,100)");
     } else {
         $link = _HTML_SPACE;
     }
     $elem8 = html_td('ptabla03', '', $link);
     $elem8->set_tag_attribute('align', 'center');
     //---------------- TEST LOCK ---------------------------------------
     if ($_lock == 0 && $profile_id >= 4) {
         $elem9 = html_td('ptabla03', '', _HTML_SPACE);
         $elem9->set_tag_attribute('align', 'center');
         $elem10 = html_td('ptabla03', '', _HTML_SPACE);
         $elem10->set_tag_attribute('align', 'center');
         $elem11 = html_td('ptabla03', '', _HTML_SPACE);
         $elem11->set_tag_attribute('align', 'center');
         $elem12 = html_td('ptabla03', '', _HTML_SPACE);
         $elem12->set_tag_attribute('align', 'center');
         $elem13 = html_td('ptabla03', '', _HTML_SPACE);
         $elem13->set_tag_attribute('align', 'center');
         $elem14 = html_td('ptabla03', '', _HTML_SPACE);
         $elem14->set_tag_attribute('align', 'center');
         $row->add($elem1);
         $row->add($elem2);
         $row->add($elem3);
         $row->add($elem4);
         $row->add($elem5);
         $row->add($elem6);
         $row->add($elem7);
         $row->add($elem8);
         $row->add($elem9);
         $row->add($elem10);
         $row->add($elem11);
         $row->add($elem12);
         $row->add($elem13);
         $row->add($elem14);
         return $row;
     }
     //----------------- COMMON OPERATIONS ------------------------------
     $_fid = $this->getViewVariable('folder_id');
     if ($_folder) {
         $status = 'folder_id=' . $_fid . '&status=del&tp=f&id=';
     } else {
         $status = 'folder_id=' . $_fid . '&status=del&tp=d&id=';
     }
     $img = $this->imag_alone(Util::format_URLPath('filemanager/index.php', $status . $_id), Theme::getThemeImagePath('filemanager/delete.png'), agt('Borrar'));
     $elem9 = html_td('ptabla03', '', $img);
     $elem9->set_tag_attribute('align', 'center');
     $_fid = $this->getViewVariable('folder_id');
     if ($_folder) {
         $status = 'oldName=' . $_name . '&operation_id=rename&tp=f&id=';
     } else {
         $status = 'oldName=' . $_name . '&operation_id=rename&tp=d&id=';
     }
     $img = $this->imag_alone(Util::format_URLPath('filemanager/index.php', $status . $_id), Theme::getThemeImagePath('filemanager/rename.png'), agt('Renombrar'));
     $elem10 = html_td('ptabla03', '', $img);
     $elem10->set_tag_attribute('align', 'center');
     if ($_folder) {
         $status = 'operation_id=move&tp=f&id=';
     } else {
         $status = 'folder_id=' . $_fid . '&operation_id=move&tp=d&id=';
     }
     $img = $this->imag_alone(Util::format_URLPath('filemanager/index.php', $status . $_id), Theme::getThemeImagePath('filemanager/move.png'), agt('Mover'));
     $elem11 = html_td('ptabla03', '', $img);
     $elem11->set_tag_attribute('align', 'center');
     if ($_visible == 0) {
         $status = 'visible';
         $icon = 'invisible.png';
         $tooltip = 'Visible';
     } else {
         $status = 'invisible';
         $icon = 'visible.png';
         $tooltip = 'Invisible';
     }
     if ($_folder) {
         $status = 'status=' . $status . '&tp=f&id=';
     } else {
         $status = 'status=' . $status . '&tp=d&id=';
     }
     $img = $this->imag_alone(Util::format_URLPath('filemanager/index.php', $status . $_id), Theme::getThemeImagePath('filemanager/' . $icon), agt($tooltip));
     $elem12 = html_td('ptabla03', '', $img);
     $elem12->set_tag_attribute('align', 'center');
     if (!$_folder) {
         //--------- ONLY TEACHER, TUTOR OR ADMIN CAN LOCK FILES ----------------
         if ($profile_id < 4) {
             if ($_lock == 0) {
                 $status = 'lock';
                 $icon = 'lock.png';
                 $tooltip = 'Bloquear';
             } else {
                 $status = 'unlock';
                 $icon = 'unlock.png';
                 $tooltip = 'Desbloqear';
             }
             $status = 'status=' . $status . '&id=';
             $img = $this->imag_alone(Util::format_URLPath('filemanager/index.php', $status . $_id), Theme::getThemeImagePath('filemanager/' . $icon), agt($tooltip));
         } else {
             $img = _HTML_SPACE;
         }
         $elem13 = html_td('ptabla03', '', $img);
         $elem13->set_tag_attribute('align', 'center');
         if ($_share == 0) {
             $status = 'share';
             $icon = 'invisible.png';
             $tooltip = 'Compartir';
         } else {
             $status = 'unshare';
             $icon = 'visible.png';
             $tooltip = 'No compartir';
         }
         $status = 'status=' . $status . '&id=';
         $img = $this->imag_alone(Util::format_URLPath('filemanager/index.php', $status . $_id), Theme::getThemeImagePath('filemanager/' . $icon), agt($tooltip));
         $elem14 = html_td('ptabla03', '', $img);
         $elem14->set_tag_attribute('align', 'center');
     } else {
         $link = _HTML_SPACE;
         $elem13 = html_td('ptabla03', '', $link);
         $elem13->set_tag_attribute('align', 'center');
         $elem14 = html_td('ptabla03', '', $link);
         $elem14->set_tag_attribute('align', 'center');
     }
     //--------------------- ADD OPERATIONS INTO TR CONTAINET -----------------
     $row->add($elem1);
     $row->add($elem2);
     $row->add($elem3);
     $row->add($elem4);
     $row->add($elem5);
     $row->add($elem6);
     $row->add($elem7);
     $row->add($elem8);
     $row->add($elem9);
     $row->add($elem10);
     $row->add($elem11);
     $row->add($elem12);
     $row->add($elem13);
     $row->add($elem14);
     return $row;
 }