Skip to content

Commit

Permalink
more images and some fixes on the file manager
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jan 3, 2010
1 parent 7a80b0d commit 0e003d6
Show file tree
Hide file tree
Showing 42 changed files with 233 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app_controller.php
Expand Up @@ -51,7 +51,7 @@ class AppController extends Controller
function beforeFilter()
{
parent::beforeFilter();
var_dump( Configure::load( 'images' ) );
Configure::load( 'images' );

$this->Session->write( 'Auth', ClassRegistry::init( 'Core.User' )->find( 'first', array( 'conditions' => array( 'User.id' => 2 ) ) ) );

Expand Down
81 changes: 49 additions & 32 deletions config/images.php
@@ -1,7 +1,7 @@
<?php
$config['Site']['Images']['path'] = 'core/icons/';
$config['Site']['Images']['images'] = array(
'acitons' => array(
$config['CoreImages']['path'] = 'core/icons/';
$config['CoreImages']['images'] = array(
'actions' => array(
'accept' => 'accept.png',
'add' => 'add.png',
'addCategory' => 'addCategory.png',
Expand Down Expand Up @@ -45,30 +45,32 @@

'applications' => array(
'ai' => '',
'doc' => '',
'doc' => 'doc.png',
'docx' => 'docx.png',
'dwt' => 'dwt.png',
'eps' => '',
'mirc' => 'mirc.png',
'ods' => 'ooMaths.png',
'odt' => 'ooWord.png',
'pdf' => 'pdf.png',
'ppt' => '',
'ppt' => 'ppt.png',
'pptx' => 'ppt.png',
'ps' => '',
'ps' => 'ps.png',
'psd' => 'psd.png',
'rtf' => '',
'txt' => 'txt.png',
'xls' => '',
'xls' => 'sxl.png',
'xlsx' => 'xlsx.png'
),

'archives' => array(
'7z' => '7z.png',
'cab' => '',
'cab' => 'cab.png',
'dll' => 'dll.png',
'exe' => 'exe.png',
'msi' => '',
'rar' => 'win-rar.png',
'tar' => 'tar.png',
'zip' => '',
),

Expand All @@ -87,32 +89,37 @@

'images' => array(
'bmp' => 'bmp.png',
'gif' => '',
'gif' => 'gif.png',
'ico' => '',
'jpe' => 'jpg.png',
'jpeg' => 'jpg.png',
'jpg' => 'jpg.png',
'png' => 'png.png',
'svg' => '',
'svg' => 'svg.png',
'svgz' => '',
'tif' => '',
'tiff' => ''
'tga' => 'tga/png',
'tif' => 'tiff.png',
'tiff' => 'tiff.png'
),

'multiMedia' => array(
'3gp' => '',
'mov' => '',
'mp2' => '',
'mp3' => '',
'mp4' => 'mp4.png',
'oog' => '',
'ra' => 'rm.png',
'ram' => 'rm.png',
'rm' => 'rm.png',
'rmi' => 'rm.png',
'qt' => 'qt.png',
'vlc' => 'vlc.png',
'mwa' => 'wma.png'
'3gp' => '3gp.png',
'dvi' => 'dvi.png',
'mov' => 'mov.png',
'mp2' => 'mp2.png',
'mp3' => 'mp3.png',
'mp4' => 'mp4.png',
'mpeg' => 'mpeg.png',
'ogg' => 'ogg.png',
'ra' => 'rm.png',
'ram' => 'rm.png',
'rm' => 'rm.png',
'rmi' => 'rm.png',
's3m' => 's3m.png',
'qt' => 'qt.png',
'vlc' => 'vlc.png',
'wav' => 'wav.png',
'wma' => 'wma.png'
),

'notifications' => array(
Expand Down Expand Up @@ -140,6 +147,12 @@
'yahoo' => 'yahoo-messanger.png'
),

'unknown' => array(
'unknown' => 'unknown.png',
'readme' => 'readme.png',
'' => 'readme.png'
),

'weather' => array(
'clear' => 'clear.png',
'clear-night' => 'clear-night.png',
Expand All @@ -153,17 +166,21 @@
),

'web' => array(
'css' => '',
'asx' => 'asx.png',
'css' => 'css.png',
'flv' => 'flv.png',
'htm' => 'html.png',
'html' => 'html.png',
'js' => '',
'java' => 'java.png',
'js' => 'js.png',
'json' => '',
'php' => '',
'php3' => '',
'php4' => '',
'php5' => '',
'php6' => '',
'php' => 'php.png',
'php3' => 'php.png',
'php4' => 'php.png',
'php5' => 'php.png',
'php6' => 'php.png',
'py' => 'py.png',
'sql' => 'sql.png',
'swf' => 'flv.png',
'xml' => 'xml.png'
)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions plugins/management/controllers/file_manager_controller.php
Expand Up @@ -10,7 +10,10 @@ class FileManagerController extends ManagementAppController
var $uses = array( 'Management.Files', 'Management.Folders' );

var $helpers = array(
'Image',

'Number'

);

function admin_index( $path = '-' )
Expand Down
47 changes: 41 additions & 6 deletions plugins/management/models/files.php
Expand Up @@ -21,7 +21,7 @@ class Files extends ManagementAppModel

function beforeFind( $queryData )
{
$this->basePath = Configure::read( 'FileManager.base_path' );
$this->basePath = APP; //Configure::read( 'FileManager.base_path' );

if ( empty( $this->basePath ) )
{
Expand Down Expand Up @@ -74,10 +74,10 @@ function find( $findType = 'all', $conditions = array() )
$data = Cache::read( 'files_'.sha1( $this->path.$conditions ) );
if ( $data !== false )
{
return $data;
//return $data;
}

return $this->__read( $findType, $conditions );
return (array)$this->__read( $findType, $conditions );
}

function chmod( $path )
Expand All @@ -101,6 +101,8 @@ function __read( $findType, $conditions )
$this->return;

Cache::write( 'files_'.sha1( $this->path.$conditions ), $this->return );

return $this->return;
}

function __advancedFileFind( $conditions )
Expand All @@ -123,14 +125,21 @@ function __advancedFileFind( $conditions )
{
$Folder = new Folder( $this->path );
$this->return[$i]['File']['path'] = $Folder->path.DS.$file;
$this->return[$i]['File']['relative'] = $this->__relativePath( $Folder->path.DS.$file );
$this->return[$i]['File']['relative'] = $this->__relativePath( $this->return[$i]['File']['path'] );

$stat = stat( $this->return[$i]['File']['path'] );
$this->__fileStatus( $i, $stat );

if ( $this->recursive > -1 )
{
$this->return[$i]['File']['accessed'] = date( 'Y-m-d H:i:s', $stat['atime'] );
$this->return[$i]['File']['modified'] = date( 'Y-m-d H:i:s', $stat['mtime'] );
$this->return[$i]['File']['created'] = date( 'Y-m-d H:i:s', $stat['ctime'] );

$File = new File( $this->return[$i]['File']['path'] );
$info = $File->info();
$this->return[$i]['File']['dirname'] = $info['dirname'];
$this->return[$i]['File']['basename'] = $info['basename'];
$this->return[$i]['File']['name'] = $info['basename'];
$this->return[$i]['File']['extension'] = $info['extension'];
$this->return[$i]['File']['filename'] = $info['filename'];
$this->return[$i]['File']['writable'] = $File->writable();
Expand All @@ -139,7 +148,7 @@ function __advancedFileFind( $conditions )
{
$this->return[$i]['File']['size'] = $File->size();
$this->return[$i]['File']['owner'] = $File->owner();
$this->return[$i]['File']['gorup'] = $File->group();
$this->return[$i]['File']['group'] = $File->group();
$this->return[$i]['File']['accessed'] = $File->lastAccess();
$this->return[$i]['File']['modidfied'] = $File->lastChange();
$this->return[$i]['File']['charmod'] = $File->perms();
Expand Down Expand Up @@ -167,6 +176,32 @@ function __advancedFileFind( $conditions )
return true;
}

function __fileStatus( $currentI, $stat )
{
$ts=array(
0140000=>'ssocket', 0120000=>'llink', 0100000=>'-file',
0060000=>'bblock', 0040000=>'ddir', 0020000=>'cchar',
0010000=>'pfifo'
);
$p = $stat['mode'];
$t = decoct( $stat['mode'] & 0170000 );

$str =(array_key_exists(octdec($t),$ts))?$ts[octdec($t)]{0}:'u';
$str.=(($p&0x0100)?'r':'-').(($p&0x0080)?'w':'-');
$str.=(($p&0x0040)?(($p&0x0800)?'s':'x'):(($p&0x0800)?'S':'-'));
$str.=(($p&0x0020)?'r':'-').(($p&0x0010)?'w':'-');
$str.=(($p&0x0008)?(($p&0x0400)?'s':'x'):(($p&0x0400)?'S':'-'));
$str.=(($p&0x0004)?'r':'-').(($p&0x0002)?'w':'-');
$str.=(($p&0x0001)?(($p&0x0200)?'t':'x'):(($p&0x0200)?'T':'-'));

$this->return[$currentI]['File']['permission'] = $str;
$this->return[$currentI]['File']['octal'] = sprintf("0%o", 0777 & $p);
$this->return[$currentI]['File']['owner'] = $stat['uid'];
$this->return[$currentI]['File']['group'] = $stat['gid'];
$this->return[$currentI]['File']['owner_name'] = ( function_exists( 'posix_getpwuid' ) ) ? posix_getpwuid( $this->return[$currentI]['File']['owner'] ) : '';
$this->return[$currentI]['File']['group_name'] = ( function_exists( 'posix_getgrgid' ) ) ? posix_getgrgid( $this->return[$currentI]['File']['group'] ) : '';
}

function __simpleFileFind( $conditions )
{
if ( empty( $FileList[1] ) )
Expand Down
8 changes: 4 additions & 4 deletions plugins/management/models/folders.php
Expand Up @@ -21,7 +21,7 @@ class Folders extends ManagementAppModel

function beforeFind( $queryData )
{
$this->basePath = Configure::read( 'FileManager.base_path' );
$this->basePath = APP; //Configure::read( 'FileManager.base_path' );

if ( empty( $this->basePath ) )
{
Expand Down Expand Up @@ -76,7 +76,7 @@ function find( $findType = 'all', $conditions = array() )
//return $data;
}

return $this->__read( $findType, $conditions );
return (array)$this->__read( $findType, $conditions );
}

function chmod( $path )
Expand Down Expand Up @@ -134,8 +134,8 @@ function __advancedFolderFind( $conditions )
if ( $this->recursive > -1 )
{
$this->return[$i]['Folder']['accessed'] = date( 'Y-m-d H:i:s', $stat['atime'] );
$this->return[$i]['Folder']['modified'] = date( 'Y-m-d H:i:s', $stat['atime'] );
$this->return[$i]['Folder']['created'] = date( 'Y-m-d H:i:s', $stat['atime'] );
$this->return[$i]['Folder']['modified'] = date( 'Y-m-d H:i:s', $stat['mtime'] );
$this->return[$i]['Folder']['created'] = date( 'Y-m-d H:i:s', $stat['ctime'] );

if ( $this->recursive > 0 )
{
Expand Down
25 changes: 18 additions & 7 deletions plugins/management/views/file_manager/admin_index.ctp
Expand Up @@ -58,6 +58,21 @@
)
)
);
?>
<tr class="<?php echo $this->Core->rowClass(); ?>">
<td>&nbsp;</td>
<td><?php echo $this->Image->image( 'actions', 'arrow-left' ); ?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<?php

foreach ( $folders as $folder )
{
Expand All @@ -66,9 +81,7 @@
<td><?php echo $this->Form->checkbox( 'Folder.'.$folder['Folder']['path'] ); ?>&nbsp;</td>
<td>
<?php
echo $this->Html->image(

);
echo $this->Image->findByChildren( $folder['Folder']['Children'] );
?>
</td>
<td>
Expand Down Expand Up @@ -121,9 +134,7 @@
<td><?php echo $this->Form->checkbox( 'File.'.$file['File']['path'] ); ?>&nbsp;</td>
<td>
<?php
echo $this->Html->image(

);
echo $this->Image->findByExtention( $file['File']['extension'] );
?>
</td>
<td>
Expand All @@ -132,7 +143,7 @@
$file['File']['name'],
array(
'action' => 'view',
$file['File']['Path']
$file['File']['path']
)
);
?>
Expand Down

0 comments on commit 0e003d6

Please sign in to comment.