[limb-svn] r6259 - in 3.x/trunk/limb/cms: src/controller src/model template/admin_user
svn at limb-project.com
svn at limb-project.com
Tue Sep 4 17:46:13 MSD 2007
Author: serega
Date: 2007-09-04 17:46:13 +0400 (Tue, 04 Sep 2007)
New Revision: 6259
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6259
Added:
3.x/trunk/limb/cms/src/model/lmbCmsFileStorage.class.php
Modified:
3.x/trunk/limb/cms/src/controller/AdminUserController.class.php
3.x/trunk/limb/cms/template/admin_user/delete.html
Log:
-- minor fixes in user module of CMS package
-- lmbCmsFileStorage added to help implementing simple file or images storages
Modified: 3.x/trunk/limb/cms/src/controller/AdminUserController.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/controller/AdminUserController.class.php 2007-09-03 12:20:41 UTC (rev 6258)
+++ 3.x/trunk/limb/cms/src/controller/AdminUserController.class.php 2007-09-04 13:46:13 UTC (rev 6259)
@@ -37,7 +37,7 @@
function doDetail()
{
- $this->view->set('user', new rtUser((int)$this->request->get('id')));
+ $this->view->set('user', new lmbCmsUser((int)$this->request->get('id')));
}
protected function _import($item)
@@ -58,7 +58,7 @@
function doDelete()
{
- $this->performCommand('limb/cms/src/command/lmbCmsDeleteObjectCommand', 'rtUser');
+ $this->performCommand('limb/cms/src/command/lmbCmsDeleteObjectCommand', 'lmbCmsUser');
}
function doChangePassword()
Added: 3.x/trunk/limb/cms/src/model/lmbCmsFileStorage.class.php
===================================================================
--- 3.x/trunk/limb/cms/src/model/lmbCmsFileStorage.class.php (rev 0)
+++ 3.x/trunk/limb/cms/src/model/lmbCmsFileStorage.class.php 2007-09-04 13:46:13 UTC (rev 6259)
@@ -0,0 +1,79 @@
+<?php
+lmb_require('limb/fs/src/lmbFs.class.php');
+lmb_require('limb/net/src/lmbMimeType.class.php');
+
+class lmbCmsFileStorage
+{
+ protected $root_dir;
+
+ function __construct($root_dir)
+ {
+ $this->root_dir = $root_dir;
+ lmbFs :: mkdir($this->root_dir);
+ }
+
+ function storeFile($source, $mime_type = null)
+ {
+ if(!$mime_type)
+ $mime_type = lmbMimeType :: getFileMimeType($source);
+
+ if($mime_type == 'application/octet-stream')
+ $mime_type = 'video/x-flv';
+
+ $file_id = $this->_makeUniqueIdentifier($mime_type);
+
+ $dest = $this->_getMediaFile($file_id);
+ lmbFs :: cp($source, $dest);
+ return $file_id;
+ }
+
+ function removeFile($file_id)
+ {
+ if($file = $this->getFilePath($file_id))
+ {
+ unlink($file);
+ return true;
+ }
+ return false;
+ }
+
+ function getFilePath($file_id)
+ {
+ if(!file_exists($file = $this->_getMediaFile($file_id)))
+ return null;
+
+ return $file;
+ }
+
+ function hasFile($file_id)
+ {
+ return $this->getFilePath($file_id) !== null;
+ }
+
+ function getFileSize($file_id)
+ {
+ if(!$file_path = $this->getFilePath($file_id))
+ return null;
+ return filesize($file_path);
+ }
+
+ function getFileUrl($file_id)
+ {
+ $result = str_replace(strtolower($_SERVER['DOCUMENT_ROOT']), '',
+ strtolower(lmbFs :: normalizePath($this->getFilePath($file_id))));
+ return '/' . ltrim($result, '/');
+ }
+
+ protected function _getMediaFile($file_id)
+ {
+ $md5 = md5($file_id);
+ return $this->root_dir . '/' . $md5{0} . '/' . $file_id;
+ }
+
+ protected function _makeUniqueIdentifier($mime_type)
+ {
+ return uniqid() . '.' . lmbMimeType :: getExtension($mime_type);
+ }
+}
+
+?>
\ No newline at end of file
Modified: 3.x/trunk/limb/cms/template/admin_user/delete.html
===================================================================
--- 3.x/trunk/limb/cms/template/admin_user/delete.html 2007-09-03 12:20:41 UTC (rev 6258)
+++ 3.x/trunk/limb/cms/template/admin_user/delete.html 2007-09-04 13:46:13 UTC (rev 6259)
@@ -7,7 +7,7 @@
<form id='delete_form' name='delete_form' method='post' runat='server'>
- <active_record:fetch class_path='src/model/rtUser' target="items_to_delete">
+ <active_record:fetch class_path='limb/cms/src/model/lmbCmsUser' target="items_to_delete">
<fetch:param record_ids="{$#request.ids}">
</active_record:fetch>
More information about the limb-svn
mailing list