Adding more functionality.

This commit is contained in:
skeeter 2001-12-20 02:11:29 +00:00
parent 561da9b50f
commit 75e3d98a82
5 changed files with 645 additions and 59 deletions

View File

@ -6,6 +6,10 @@
class bophpwebhosting class bophpwebhosting
{ {
var $public_functions = array(
'delete' => True
);
var $so; var $so;
var $vfs; var $vfs;
var $rootdir; var $rootdir;
@ -19,6 +23,10 @@
var $file_attributes; var $file_attributes;
var $help_info; var $help_info;
var $delete;
var $rename;
var $go;
var $download = Array(); var $download = Array();
var $fileman = Array(); var $fileman = Array();
var $op; var $op;
@ -41,7 +49,6 @@
function bophpwebhosting() function bophpwebhosting()
{ {
// error_reporting (4);
$this->vfs = CreateObject('phpgwapi.vfs'); $this->vfs = CreateObject('phpgwapi.vfs');
$to_decode = Array( $to_decode = Array(
@ -55,29 +62,26 @@
'op', 'op',
'path', 'path',
'file', 'file',
'todir',
'sortby', 'sortby',
'fileman', 'fileman',
'messages', 'messages',
'help_name', 'help_name',
'renamefiles', 'renamefiles',
'comment_files', 'comment_files',
'show_upload_boxes' 'show_upload_boxes',
'submit',
'delete',
'go',
'rename'
); );
$c_to_decode = count($to_decode); $c_to_decode = count($to_decode);
for($i=0;$i<$c_to_decode;$i++) for($i=0;$i<$c_to_decode;$i++)
// @reset($GLOBALS['HTTP_GET_VARS']);
// while(list($name,$data) = each($GLOBALS['HTTP_GET_VARS']))
{ {
$this->initialize_vars($to_decode[$i]); $this->initialize_vars($to_decode[$i]);
} }
// @reset($GLOBALS['HTTP_POST_VARS']);
// while(list($name,$data) = each($GLOBALS['HTTP_POST_VARS']))
// {
// $this->initialize_vars($name,$data);
// }
$this->rootdir = $this->vfs->basedir; $this->rootdir = $this->vfs->basedir;
$this->fakebase = $this->vfs->fakebase; $this->fakebase = $this->vfs->fakebase;
$this->appname = $GLOBALS['phpgw_info']['flags']['currentapp']; $this->appname = $GLOBALS['phpgw_info']['flags']['currentapp'];
@ -106,6 +110,7 @@
$this->file_attributes = Array( $this->file_attributes = Array(
'name' => 'Filename', 'name' => 'Filename',
'deletable' => 'Deletable',
'mime_type' => 'MIME Type', 'mime_type' => 'MIME Type',
'size' => 'Size', 'size' => 'Size',
'created' => 'Created', 'created' => 'Created',
@ -208,7 +213,7 @@
# We determine if they're in their home directory or a group's directory, # We determine if they're in their home directory or a group's directory,
# and set the VFS working_id appropriately # and set the VFS working_id appropriately
### ###
if((preg_match ('+^'.$this->fakebase.'\/(.*)(\/|$)+U',$this->path,$this->matches)) && $this->matches[1] != $this->userinfo['account_lid']) if((preg_match('+^'.$this->fakebase.'\/(.*)(\/|$)+U',$this->path,$this->matches)) && $this->matches[1] != $this->userinfo['account_lid'])
{ {
$this->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]); $this->vfs->working_id = $GLOBALS['phpgw']->accounts->name2id($matches[1]);
} }
@ -216,20 +221,16 @@
{ {
$this->vfs->working_id = $this->userinfo['username']; $this->vfs->working_id = $this->userinfo['username'];
} }
// $this->load_files();
$this->load_help_info();
} }
function initialize_vars($name) function initialize_vars($name)
{ {
$var = ($GLOBALS['HTTP_GET_VARS'][$name]?$GLOBALS['HTTP_GET_VARS'][$name]:''); $var = ($GLOBALS['HTTP_GET_VARS'][$name]?$GLOBALS['HTTP_GET_VARS'][$name]:'');
$var = ($GLOBALS['HTTP_POST_VARS'][$name]?$GLOBALS['HTTP_POST_VARS'][$name]:$var); $var = ($GLOBALS['HTTP_POST_VARS'][$name]?$GLOBALS['HTTP_POST_VARS'][$name]:$var);
// if($var) if($this->debug)
// { {
// $this->$name = $var; echo '<!-- '.$name.' = '.$var.' -->'."\n";
// } }
if(is_array($this->$name) && $var) if(is_array($this->$name) && $var)
{ {
$temp = Array(); $temp = Array();
@ -245,7 +246,6 @@
} }
} }
} }
// elseif(isset($this->$name) && $var)
elseif($var) elseif($var)
{ {
$temp = urldecode($var); $temp = urldecode($var);
@ -323,6 +323,54 @@
return $this->files_array; return $this->files_array;
} }
function delete()
{
$numoffiles = count($this->fileman);
for($i=0;$i!=$numoffiles;$i++)
{
if ($this->fileman[$i])
{
$filesize = $this->vfs->get_size($this->path.SEP.$this->fileman[$i],Array(RELATIVE_USER_NONE));
if(!$this->vfs->delete($this->path.SEP.$this->fileman[$i],Array(RELATIVE_USER_NONE)))
{
$GLOBALS['phpgw']->common->error_list(Array('Could not delete '.$this->disppath.SEP.$this->fileman[$i]));
}
}
}
if(!$errors)
{
Header('Location: '.$GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => $this->appname.'.ui'.$this->appname.'.index',
'path' => $this->path
)
)
);
}
else
{
Header('Location: '.$GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => $this->appname.'.ui'.$this->appname.'.index',
'path' => $this->path,
'errors' => urlencode($errors)
)
)
);
}
}
function go()
{
Header('Location: '.$GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => $this->appname.'.ui'.$this->appname.'.index',
'path' => $this->todir
)
)
);
}
function load_help_info() function load_help_info()
{ {
$this->help_info = Array( $this->help_info = Array(
@ -359,7 +407,7 @@
array ("upload_file", "The full path of the local file to upload. You can type it in or use the Browse.. button to select it. The file will be uploaded to the current directory. You cannot upload directories, only files."), array ("upload_file", "The full path of the local file to upload. You can type it in or use the Browse.. button to select it. The file will be uploaded to the current directory. You cannot upload directories, only files."),
array ("upload_comment", "The inital comment to use for the newly uploaded file. Totally optional and completely arbitrary. You can [edit_comments|create or edit the comment] at any time in the future."), array ("upload_comment", "The inital comment to use for the newly uploaded file. Totally optional and completely arbitrary. You can [edit_comments|create or edit the comment] at any time in the future."),
array ("upload_files", "This will upload the files listed in the input boxes above, and store them in the current directory."), array ("upload_files", "This will upload the files listed in the input boxes above, and store them in the current directory."),
array ("show_upload_fields", "This setting determines how many [upload_files|upload fields] will be shown at once. You can change the default number that will be shown in the [preferences].") array ("show_upload_fields", "This setting determines how many [upload_files|upload fields] will be shown at once. You can change the default number that will be shown in the preferences.")
); );
} }
@ -378,14 +426,12 @@
if($size<1024) if($size<1024)
{ {
$rstring = $left.$size.'&nbsp;B&nbsp;&nbsp;'.$right; return $left.$size.'&nbsp;B&nbsp;&nbsp;'.$right;
} }
else else
{ {
$rstring = $left.round($size/1024).'&nbsp;KB'.$right; return $left.round($size/1024).'&nbsp;KB'.$right;
} }
return $rstring;
// return($this->eor($rstring,$return));
} }
### ###

View File

@ -5,6 +5,9 @@
var $public_functions = array( var $public_functions = array(
'index' => True, 'index' => True,
'action' => True,
'help' => True,
'history' => True,
'view' => True, 'view' => True,
'view_file' => True 'view_file' => True
); );
@ -30,7 +33,7 @@
function load_header() function load_header()
{ {
if(($this->bo->download && (count($this->bo->fileman) > 0)) || ($this->bo->op == 'view' && $this->bo->file) || ($this->bo->op == 'history' && $this->bo->file) || ($this->bo->op == 'help' && $this->bo->help_name)) if(($this->bo->download && (count($this->bo->fileman) > 0)) || ($this->bo->op == 'view' && $this->bo->file) || ($this->bo->op == 'history' && $this->bo->file) || ($this->bo->op == 'help' && $this->bo->help_name) || ($this->bo->delete && count($this->bo->fileman) > 0) || ($this->bo->go && isset($this->bo->todir)))
{ {
} }
else else
@ -162,20 +165,64 @@
} }
} }
function build_help($help_option) function action()
{
$actions = Array(
'delete' => lang('Delete'),
'go' => lang('Go To')
);
@reset($actions);
while(list($function,$text) = each($actions))
{
if(isset($this->bo->$function) && !empty($this->bo->$function) && trim($this->bo->$function) == $text)
{
if($this->bo->$function == 'go')
{
echo 'To Dir = '.$this->bo->todir.'<br>'."\n";
}
$this->bo->$function();
}
}
}
function help()
{
$this->bo->load_help_info();
@reset($this->bo->help_info);
while(list($num,$help_array) = each($this->bo->help_info))
{
if ($help_array[0] != $this->bo->help_name)
{
continue;
}
$help_array[1] = preg_replace("/\[(.*)\|(.*)\]/Ue","\$this->build_help('\\1','\\2')",$help_array[1]);
$help_array[1] = preg_replace("/\[(.*)\]/Ue","\$this->build_help('\\1','\\1')",$help_array[1]);
echo '<font size="+4">'."\n".ucwords(str_replace('_',' ',$help_array[0]))."\n".'</font></br>'."\n";
echo '<font size="+2">'."\n".$help_array[1].'</font>';
}
$GLOBALS['phpgw']->common->phpgw_exit ();
}
function build_help($help_option,$text='')
{ {
if($this->bo->settings['show_help']) if($this->bo->settings['show_help'])
{ {
return '<font size="-2" color="maroon" >'."\n" $help = ($text?'':'<font size="-2" color="maroon" >'."\n");
. ' <a href="' $help .= ' <a href="'
. $GLOBALS['phpgw']->link('/index.php', . $GLOBALS['phpgw']->link('/index.php',
Array( Array(
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.help', 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.help',
'help_name' => urlencode($help_option), 'help_name' => urlencode($help_option),
'op' => 'help'
) )
) )
. '" target="_new">[?]</a>'."\n" . '" target="_new">';
. ' </font>'; $help .= ($text?$text:'[?]');
$help .= '</a>';
$help .= ($text?'':"\n".' </font>');
return $help;
} }
else else
{ {
@ -193,6 +240,17 @@
return '<a href="'.$GLOBALS['phpgw']->link('/index.php',$array_params).'">'.$text.'</a>'; return '<a href="'.$GLOBALS['phpgw']->link('/index.php',$array_params).'">'.$text.'</a>';
} }
function build_upload_choices($number)
{
return $this->link(
Array(
'menuaction' => $GLOBALS['HTTP_GET_VARS']['menuaction'],
'path' => $this->bo->path,
'show_upload_boxes' => $number
),
$number).'&nbsp;&nbsp;';
}
function column_header($internal,$displayed,$link=True) function column_header($internal,$displayed,$link=True)
{ {
if($link) if($link)
@ -215,6 +273,341 @@
); );
} }
function display_buttons()
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'_buttons' => 'small_table.tpl'
)
);
$p->set_block('_buttons','table','table');
$p->set_block('_buttons','column_headers','column_headers');
$p->set_block('_buttons','column_headers_normal','column_headers_normal');
$p->set_block('_buttons','column_rows','column_rows');
$var = Array(
'table_extras' => '',
'tr_extras' => '',
'td_extras' => ' align="center" width="25%"'
);
$var['column_header'] = '<input type="submit" name="edit" value=" '.lang('Edit').' ">'.$this->build_help('edit');
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
$var['column_header'] = '<input type="submit" name="rename" value=" '.lang('Rename').' ">'.$this->build_help('rename');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = '<input type="submit" name="delete" value=" '.lang('Delete').' ">'.$this->build_help('delete');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = '<input type="submit" name="edit_comments" value=" '.lang('Edit Comments').' ">'.$this->build_help('edit_comments');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$var['column_header'] = '<input type="submit" name="go" value=" '.lang('Go To').' ">'.$this->build_help('go_to');
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
$var['column_header'] = '<input type="submit" name="copy" value=" '.lang('Copy To').' ">'.$this->build_help('copy_to');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = '<input type="submit" name="move" value=" '.lang('Move To').' ">'.$this->build_help('move_to');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
###
# First we get the directories in their home directory
###
$dirs[] = Array(
'directory' => $this->bo->fakebase,
'name' => $this->bo->userinfo['account_lid']
);
$ls_array = $this->bo->vfs->ls($this->bo->homedir,Array(RELATIVE_NONE),True,'Directory');
while(list($num,$dir) = each($ls_array))
{
$dirs[] = $dir;
}
###
# Then we get the directories in their membership's home directories
###
reset($this->bo->memberships);
while(list($num,$group_array) = each($this->bo->memberships))
{
###
# Don't list directories for groups that don't have access
###
if(!$this->bo->membership_applications[$group_array['account_name']][$this->bo->appname]['enabled'])
{
continue;
}
$dirs[] = Array(
'directory' => $this->bo->fakebase,
'name' => $group_array['account_name']
);
$ls_array = $this->bo->vfs->ls($this->bo->fakebase.SEP.$group_array['account_name'],Array(RELATIVE_NONE),True,'Directory');
while(list($num,$dir) = each($ls_array))
{
$dirs[] = $dir;
}
}
$dir_list = '';
reset($dirs);
while(list($num, $dir) = each($dirs))
{
if(!$dir['directory'])
{
continue;
}
###
# So we don't display //
###
if($dir['directory'] != '/')
{
$dir['directory'] .= SEP;
}
$selected = '';
if($num == 0)
{
$selected = ' selected';
}
###
# No point in displaying the current directory, or a directory that doesn't exist
###
if((($dir['directory'].$dir['name']) != $this->bo->path) && $this->bo->vfs->file_exists($dir['directory'].$dir['name'],Array(RELATIVE_NONE)))
{
$dir_list .= '<option value="'.urlencode($dir['directory'].$dir['name']).'"'.$selected.'>'.$dir['directory'].$dir['name'].'</option>';
}
}
$var['column_header'] = '<select name="todir">'.$dir_list.'</select>'.$this->build_help('directory_list');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
$var = Array(
'tr_extras' => '',
'td_extras' => ' colspan="2" align="center" width="50%"'
);
if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase)
{
$var['column_header'] = '<input type="submit" name="download" value=" '.lang('Download').' ">'.$this->build_help('download');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$var['column_header'] = '&nbsp;&nbsp;&nbsp;<input type="text" name="createdir" maxlength="255" size="15">&nbsp;<input type="submit" name="newdir" value=" '.lang('Create Folder').' ">'.$this->build_help('create_folder');
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
}
$var['column_header'] = '<input type="submit" name="update" value=" '.lang('Update').' ">'.$this->build_help('update');
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
if($this->bo->path != '/' && $this->bo->path != $this->bo->fakebase)
{
$var['column_header'] = '&nbsp;&nbsp;&nbsp;<input type="text" name="createfile" maxlength="255" size="15">&nbsp;<input type="submit" name="newfile" value=" '.lang('Create File').' ">'.$this->build_help('create_file');
}
else
{
$var['column_header'] = '&nbsp;';
}
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
if($this->bo->settings['show_command_line'])
{
$var = Array(
'tr_extras' => '',
'td_extras' => ' colspan="4" align="center" width="100%"',
'column_header' => '<input type="text" name="command_line" size="50">'.$this->build_help('command_line').'</br><input type="submit" name="execute" value="'.lang('Execute').'">'.$this->build_help('execute')
);
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
}
return $p->fp('output','table');
}
function display_summary_info($numoffiles,$usedspace)
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'_info' => 'small_table.tpl'
)
);
$p->set_block('_info','table','table');
$p->set_block('_info','column_headers','column_headers');
$p->set_block('_info','column_headers_normal','column_headers_normal');
$p->set_block('_info','column_rows','column_rows');
$this_homedir = ($this->bo->path == $this->bo->homedir || $this->bo->path == $this->bo->fakedir);
$info_columns = 4 + ($this_homedir?2:0);
$var = Array(
'table_extras' => ' cols="'.$info_columns.'"',
'tr_extras' => '',
'td_extras' => ' colspan="'.$info_columns.'" align="center" width="100%"',
'column_header' => $this->build_help('file_stats')
);
$p->set_var($var);
$p->parse('col_headers','column_headers',False);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
$var = Array(
'tr_extras' => '',
'td_extras' => ' align="right"'
);
$var['column_header'] = '<b>'.lang('Files').'</b>:';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$var['td_extras'] = ' align="left"';
$var['column_header'] = $numoffiles;
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="right"';
$var['column_header'] = '<b>'.lang('Used Space').'</b>:';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="left"';
$var['column_header'] = $this->bo->borkb($usedspace);
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
if($this_homedir)
{
$var['td_extras'] = ' align="right"';
$var['column_header'] = '<b>'.lang('Unused space').'</b>:';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="left"';
$var['column_header'] = $this->bo->borkb($this->bo->userinfo['hdspace'] - $usedspace);
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
}
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
if($this_homedir)
{
$var['td_extras'] = ' colspan="'.($info_columns / 2).'" align="right" width="50%"';
$var['column_header'] = '<b>'.lang('Total Files').'</b>:';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$var['td_extras'] = ' colspan="'.($info_columns / 2).'" align="left" width="50%"';
$var['column_header'] = count($this->bo->vfs->ls($this->bo->path,Array(RELATIVE_NONE)));
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$p->parse('list','column_rows',True);
$p->set_var('col_headers','');
}
return $p->fp('output','table');
}
function display_uploads()
{
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_file(
Array(
'_uploads' => 'small_table.tpl'
)
);
$p->set_block('_uploads','table','table');
$p->set_block('_uploads','column_headers','column_headers');
$p->set_block('_uploads','column_headers_normal','column_headers_normal');
$p->set_block('_uploads','column_rows','column_rows');
$var = Array(
'table_extras' => ' cols="3"',
'tr_extras' => ''
);
$var['td_extras'] = ' align="right" width="45%"';
$var['column_header'] = '<b>'.lang('File').'</b>'.$this->build_help('upload_file');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$var['td_extras'] = ' align="center" width="10%"';
$var['column_header'] = '&nbsp;';
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$var['td_extras'] = ' align="left" width="45%"';
$var['column_header'] = '<b>'.lang('Comment').'</b>'.$this->build_help('upload_comment');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',True);
$p->parse('list','column_rows',True);
$input_file = '<input type="file" name="upload_file[]" maxlength="255">';
$input_comment = '<input type="text" name="upload_comment[]">';
$var['tr_extras'] = '';
$var['td_extras'] = ' colspan="3" align="center"';
$var['column_header'] = '<input type="hidden" name="show_upload_boxes" value="'.$this->bo->show_upload_boxes.'">'."\n".$input_file.$input_comment;
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
for($i=1;$i<$this->bo->show_upload_boxes;$i++)
{
$var['column_header'] = $input_file.$input_comment;
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
}
$var['column_header'] = '<input type="submit" name="upload_files" value="'.lang('Upload Files').'">'.$this->build_help('upload_files');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
$var['column_header'] = lang('Show').'&nbsp;&nbsp;'.$this->build_upload_choices(5).$this->build_upload_choices(10).$this->build_upload_choices(20).$this->build_upload_choices(30).lang('upload fields').$this->build_help('show_upload_fields');
$p->set_var($var);
$p->parse('col_headers','column_headers_normal',False);
$p->parse('list','column_rows',True);
return '<form action="'.$GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => $this->bo->appname.'.bo'.$this->bo->appname.'.upload',
'path' => $this->bo->path
)
).'" method="post" enctype="multipart/form-data">'."\n".$p->fp('output','table').'</form>'."\n";
}
function index() function index()
{ {
$files_array = $this->bo->load_files(); $files_array = $this->bo->load_files();
@ -230,14 +623,21 @@
); );
$p->set_block('_index','index','index'); $p->set_block('_index','index','index');
$p->set_block('_index','column_headers','column_headers'); $p->set_block('_index','column_headers','column_headers');
$p->set_block('_index','column_headers_normal','column_headers_normal');
$p->set_block('_index','column_rows','column_rows'); $p->set_block('_index','column_rows','column_rows');
$tr = $this->nextmatchs->alternate_row_color($tr); $GLOBLAS['tr_color'] = $GLOBALS['phpgw_info']['theme']['row_off'];
$p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"'); $p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
$var = Array( $var = Array(
'form_action' => $GLOBALS['phpgw']->link('/index.php',
Array(
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.action',
'path' => urlencode($this->bo->path)
)
),
'img_up' => $this->link(Array( 'img_up' => $this->link(Array(
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index', 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
'path' => $this->bo->lesspath 'path' => urlencode($this->bo->lesspath)
), ),
$this->image('folder_up.gif',lang('Up'))), $this->image('folder_up.gif',lang('Up'))),
'help_up' => $this->build_help('up'), 'help_up' => $this->build_help('up'),
@ -263,8 +663,7 @@
$columns++; $columns++;
} }
} }
$tr = $this->nextmatchs->alternate_row_color($tr); $p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
$p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"');
$p->parse('col_row','column_rows',True); $p->parse('col_row','column_rows',True);
$p->set_var('colspan',$columns); $p->set_var('colspan',$columns);
@ -315,12 +714,12 @@
$p->set_var($var); $p->set_var($var);
$p->parse('col_headers','column_headers',True); $p->parse('col_headers','column_headers',True);
} }
$tr = $this->nextmatchs->alternate_row_color($tr); $p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
$p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"');
$p->parse('col_row','column_rows',True); $p->parse('col_row','column_rows',True);
$p->set_var('col_headers',''); $p->set_var('col_headers','');
} }
$usedspace = 0;
reset($files_array); reset($files_array);
$numoffiles = count($files_array); $numoffiles = count($files_array);
for($i=0;$i!=$numoffiles;$i++) for($i=0;$i!=$numoffiles;$i++)
@ -333,6 +732,8 @@
$p->set_var($var); $p->set_var($var);
$p->parse('col_headers','column_headers'); $p->parse('col_headers','column_headers');
$usedspace += $files['size'];
reset($this->bo->file_attributes); reset($this->bo->file_attributes);
while(list($internal,$displayed) = each($this->bo->file_attributes)) while(list($internal,$displayed) = each($this->bo->file_attributes))
{ {
@ -360,21 +761,24 @@
$var['column_header'] = $this->link( $var['column_header'] = $this->link(
Array( Array(
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view', 'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view',
// 'op' => 'view',
'path' => urlencode($this->bo->path), 'path' => urlencode($this->bo->path),
'file' => urlencode($files['name']) 'file' => urlencode($files['name'])
), ),
'<b>'.$files['name'].'</b>' '<b>'.$files['name'].'</b>'
); );
// $var['column_header'] = '<a href="'.$GLOBALS['phpgw']->link('/'.$this->bo->appname.'/view_file.php',
// Array(
// 'path' => urlencode($this->bo->path),
// 'file' => urlencode($files['name'])
// )
// ).'"><b>'.$files['name'].'</b></a>';
break; break;
} }
break; break;
case 'deletable':
if ($files['deleteable'] == 'N')
{
$var['column_header'] = $this->image('locked.gif','locked');
}
else
{
$var['column_header'] = '&nbsp;';
}
break;
case 'size': case 'size':
$var['column_header'] = $this->bo->borkb($files['size']); $var['column_header'] = $this->bo->borkb($files['size']);
$var['td_extras'] = ' align="right"'; $var['td_extras'] = ' align="right"';
@ -427,12 +831,14 @@
$p->parse('col_headers','column_headers',True); $p->parse('col_headers','column_headers',True);
} }
} }
$tr = $this->nextmatchs->alternate_row_color($tr); $p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
$p->set_var('tr_extras',' bgcolor="'.$tr.'" border="0"');
$p->parse('col_row','column_rows',True); $p->parse('col_row','column_rows',True);
$p->set_var('col_headers',''); $p->set_var('col_headers','');
} }
$p->set_var('buttons',$this->display_buttons());
$p->set_var('info',$this->display_summary_info($numoffiles,$usedspace));
$p->set_var('uploads',$this->display_uploads());
$p->pfp('output','index'); $p->pfp('output','index');
} }
@ -440,7 +846,6 @@
function view() function view()
{ {
if($this->bo->vfs->file_exists($this->bo->path.'/'.$this->bo->file,Array(RELATIVE_NONE))) if($this->bo->vfs->file_exists($this->bo->path.'/'.$this->bo->file,Array(RELATIVE_NONE)))
{ {
$content_type = $this->bo->vfs->file_type($this->bo->path.$this->bo->dispsep.$this->bo->file,Array(RELATIVE_NONE)); $content_type = $this->bo->vfs->file_type($this->bo->path.$this->bo->dispsep.$this->bo->file,Array(RELATIVE_NONE));
@ -501,6 +906,104 @@
} }
} }
function history()
{
$file = $this->bo->path.$this->bo->dispsep.$this->bo->file;
if($this->bo->vfs->file_exists($file,Array(RELATIVE_NONE)))
{
$col_headers = Array(
'Date' => 'created',
'Version' => 'version',
'Action Performed by' => 'owner_id',
'Operation' => 'comment'
);
$p = CreateObject('phpgwapi.Template',$this->template_dir);
$p->set_unknowns('remove');
$p->set_file(
Array(
'_history' => 'history.tpl'
)
);
$p->set_block('_history','history','history');
$p->set_block('_history','column_headers','column_headers');
$p->set_block('_history','column_rows','column_rows');
$var = Array(
'path' => $this->link(
Array(
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.index',
'path' => urlencode($this->bo->path)
),
$this->bo->path
),
'filename' => $this->link(
Array(
'menuaction' => $this->bo->appname.'.ui'.$this->bo->appname.'.view',
'path' => urlencode($this->bo->path),
'file' => urlencode($this->bo->file)
),
$this->bo->file
)
);
$p->set_var($var);
$GLOBALS['tr_color'] = $GLOBALS['phpgw_info']['theme']['row_off'];
$var = Array(
'td_extras' => ''
);
@reset($col_headers);
while(list($label,$field)= each($col_headers))
{
$var['column_header'] = '<b>'.$label.'</b>';
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
}
$p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
$p->parse('col_row','column_rows',True);
$p->set_var('col_headers','');
$journal_array = $this->bo->vfs->get_journal($file,Array(RELATIVE_NONE));
while(list($num,$journal_entry) = each($journal_array))
{
@reset($col_headers);
while(list($label,$field)= each($col_headers))
{
switch($field)
{
case 'owner_id':
$var['column_header'] = '<font size="-2">'.$GLOBALS['phpgw']->accounts->id2name($journal_entry[$field]).'</font>';
break;
case 'created':
if($journal_entry[$field] && $journal_entry[$field] != '0000-00-00')
{
$year = substr($journal_entry[$field],0,4);
$month = substr($journal_entry[$field],5,2);
$day = substr($journal_entry[$field],8,2);
$datetime = mktime(0,0,0,$month,$day,$year);
$var['column_header'] = '<font size="-2">'.date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],$datetime).'</font>';
}
else
{
$var['column_header'] = '<font size="-2">&nbsp;</font>';
}
break;
default:
$var['column_header'] = '<font size="-2">'.$journal_entry[$field].'</font>';
break;
}
$p->set_var($var);
$p->parse('col_headers','column_headers',True);
}
$p->set_var('tr_extras',' bgcolor="'.$this->nextmatchs->alternate_row_color().'" border="0"');
$p->parse('col_row','column_rows',True);
$p->set_var('col_headers','');
}
$p->pfp('output','history');
}
}
function view_file() function view_file()
{ {
$file = $this->bo->path.$this->bo->dispsep.$this->bo->file; $file = $this->bo->path.$this->bo->dispsep.$this->bo->file;

View File

@ -1206,7 +1206,7 @@ if ($edit)
{ {
$fileman[$j]; $fileman[$j];
$content = $$fileman[$j]; $content = $fileman[$j];
echo 'fileman['.$j.']: '.$fileman[$j].'<br><b>'.$content.'</b><br>'; echo 'fileman['.$j.']: '.$fileman[$j].'<br><b>'.$content.'</b><br>';
continue; continue;

View File

@ -0,0 +1,29 @@
<!-- BEGIN history -->
<table width="100%" border="1" cols="4">
<tr>
<td align="center" colspan="4">
<table width="100%" border="1">
<tr{tr_extras}>
<td align="center">
Path: {path}
</td>
<td align="center">
Filename: {filename}
</td>
</tr>
</table>
</hr>
</td>
</tr>
{col_row}
</table>
<!-- END history -->
<!-- BEGIN column_rows -->
<tr{tr_extras}>
{col_headers}
</tr>
<!-- END column_rows -->
<!-- BEGIN column_headers -->
<td{td_extras}>{column_header}</td>
<!-- END column_headers -->

View File

@ -2,6 +2,7 @@
<table width="100%" border="1" cols="{colspan}"> <table width="100%" border="1" cols="{colspan}">
<tr> <tr>
<td align="center" colspan="{colspan}"> <td align="center" colspan="{colspan}">
<form action="{form_action}" method="post">
<table width="100%" border="1"> <table width="100%" border="1">
<tr{tr_extras}> <tr{tr_extras}>
<td align="center"> <td align="center">
@ -17,24 +18,31 @@
</table> </table>
</hr> </hr>
</td> </td>
</tr> </tr>{col_row}
{col_row}
<tr> <tr>
<td align="center" colspan="{colspan}"> <td align="center" colspan="{colspan}">
</hr> </hr>{buttons}
<table width="100%" border="1"> </form>
{buttons} </td>
</table> </tr>
<tr>
<td align="center" colspan="{colspan}">{info}
</td>
</tr>
<tr>
<td align="center" colspan="{colspan}">{uploads}
</td> </td>
</tr> </tr>
</table> </table>
<!-- END index --> <!-- END index -->
<!-- BEGIN column_rows --> <!-- BEGIN column_rows -->
<tr{tr_extras}> <tr{tr_extras}>{col_headers}
{col_headers}
</tr> </tr>
<!-- END column_rows --> <!-- END column_rows -->
<!-- BEGIN column_headers --> <!-- BEGIN column_headers -->
<td{td_extras}><font size="-1">{column_header}</font></td> <td{td_extras}><font size="-2">{column_header}</font></td>
<!-- END column_headers --> <!-- END column_headers -->
<!-- BEGIN column_headers_normal -->
<td{td_extras}>{column_header}</td>
<!-- END column_headers_normal -->