function html_table_field_a($title, $fd, $vars, $a_href, $a_ID, $a_target, $a_text, $a_custom) { global $CN_str_point, $CN_color_minus, $CN_NO_ROLLUP; $col = count($fd); if ($a_ID) { ++$col; } echo "<tr> <th colspan={$col}> {$title} </th> </tr>"; html_th($fd); echo "<th></th>"; $rollup = array_fill(0, $col - 1, ''); foreach ($vars as $key => $val) { echo "<tr>"; $i = 0; foreach ($fd as $k => $v) { if (array_key_exists($k, $val)) { if (preg_match("/^[+-]?\\d+\\.?\\d*?\$/", $val[$k])) { $str = str_replace('.', $CN_str_point, $val[$k]); if ($str < 0) { $color = "<font color={$CN_color_minus}>"; $end_color = "</font>"; } else { $color = ""; $end_color = ""; } $rollup[$i] += $val[$k]; } else { $str = $val[$k]; $color = ""; $end_color = ""; } } else { $str = ""; $color = ""; $end_color = ""; } echo "<td>{$color}" . $str . $end_color . "</td>"; ++$i; } if ($a_ID) { if (!is_array($a_ID)) { echo "<td><a {$a_target} href={$a_href}?ID={$val[$a_ID]}{$a_custom}>{$a_text}</a></td>"; } else { $gets = ''; $i = 1; foreach ($a_ID as $idv) { $gets .= "{$idv}={$val[$idv]}"; if ($i < count($a_ID)) { $gets .= "&"; } $i++; } echo "<td><a {$a_target} href={$a_href}?{$gets}{$a_custom}>{$a_text}</a></td>"; } } } if (!$CN_NO_ROLLUP) { echo "<tr>"; for ($i = 0; $i < $col; $i++) { echo "<th>{$rollup[$i]}</th>"; } echo "</tr>"; } }
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; }