OXID eShop CE  4.9.7
 All Classes Files Functions Variables Pages
oxUtilsFile Class Reference
+ Inheritance diagram for oxUtilsFile:
+ Collaboration diagram for oxUtilsFile:

Public Member Functions

 __construct ()
 getNewFilesCounter ()
 normalizeDir ($sDir)
 copyDir ($sSourceDir, $sTargetDir)
 deleteDir ($sSourceDir)
 readRemoteFileAsString ($sPath)
 processFiles ($oObject=null, $aFiles=array(), $blUseMasterImage=false, $blUnique=true)
 checkFile ($sFile)
 urlValidate ($sLink)
 processFile ($sFileName, $sUploadPath)
 getImageDirByType ($sType, $blGenerated=false)
 translateError ($iError)
- Public Member Functions inherited from oxSuperCfg
 __call ($sMethod, $aArgs)
 getConfig ()
 setConfig ($oConfig)
 getSession ()
 setSession ($oSession)
 getUser ()
 setUser ($oUser)
 isAdmin ()
 setAdminMode ($blAdmin)

Public Attributes

const PROMO_PICTURE_DIR = 'promo'

Protected Member Functions

 _setNewFilesCounter ($iNewFilesCounter)
 _prepareImageName ($sValue, $sType, $blDemo, $sImagePath, $blUnique=true)
 _getImagePath ($sType)
 _getImageSize ($sImgType, $iImgNum, $sImgConf)
 _copyFile ($sSource, $sTarget)
 _moveImage ($sSource, $sTarget)
 _getUniqueFileName ($sFilePath, $sFileName, $sFileExt, $sSufix="", $blUnique=true)

Protected Attributes

 $_iMaxPicImgCount = 12
 $_iMaxZoomImgCount = 12
 $_aTypeToPath
 $_aBadFiles = array('php', 'php3', 'php4', 'php5', 'phps', 'php6', 'jsp', 'cgi', 'cmf', 'exe')
 $_aAllowedFiles = array('gif', 'jpg', 'jpeg', 'png', 'pdf')
 $_iNewFilesCounter = 0

Additional Inherited Members

- Static Protected Attributes inherited from oxSuperCfg
static $_oConfig = null
static $_oSession = null
static $_oRights = null
static $_oActUser = null
static $_blIsAdmin = null

Detailed Description

File manipulation utility class

Definition at line 6 of file oxutilsfile.php.

Constructor & Destructor Documentation

oxUtilsFile::__construct ( )

Class constructor, initailizes pictures count info (_iMaxPicImgCount/_iMaxZoomImgCount)

Returns
null

Reimplemented from oxSuperCfg.

Definition at line 111 of file oxutilsfile.php.

Member Function Documentation

oxUtilsFile::_copyFile (   $sSource,
  $sTarget 
)
protected

Copy file from source to target location

Parameters
string$sSourcefile location
string$sTargetfile location
Returns
bool

Definition at line 349 of file oxutilsfile.php.

oxUtilsFile::_getImagePath (   $sType)
protected

Returns image storage path

Parameters
string$sTypeimage type
Returns
string

Definition at line 301 of file oxutilsfile.php.

oxUtilsFile::_getImageSize (   $sImgType,
  $iImgNum,
  $sImgConf 
)
protected

Returns array of sizes which are used to resize images. If size is not defined - NULL will be returned

Parameters
string$sImgTypeimage type (TH, TC, ICO etc), can be useful for modules
int$iImgNumnumber of image (e.g. numper of ZOOM1 is 1)
string$sImgConfconfig parameter name, which keeps size info
Returns
array | null

Definition at line 319 of file oxutilsfile.php.

oxUtilsFile::_getUniqueFileName (   $sFilePath,
  $sFileName,
  $sFileExt,
  $sSufix = "",
  $blUnique = true 
)
protected

Checks if file with same name does not exist, if exists - addes number prefix to file name Returns unique file name.

Parameters
string$sFilePathfile storage path/folder (e.g. /htdocs/out/img/)
string$sFileNamename of file (e.g. picture1)
string$sFileExtfile extension (e.g. gif)
string$sSufixfile name sufix (e.g. _ico)
bool$blUniqueTRUE - generates unique file name, FALSE - just glues given parts of file name
Returns
string

Definition at line 605 of file oxutilsfile.php.

oxUtilsFile::_moveImage (   $sSource,
  $sTarget 
)
protected

Moves image from source to target location

Parameters
string$sSourceimage location
string$sTargetimage copy location
Returns
bool

Definition at line 374 of file oxutilsfile.php.

oxUtilsFile::_prepareImageName (   $sValue,
  $sType,
  $blDemo,
  $sImagePath,
  $blUnique = true 
)
protected

Prepares image file name

Parameters
object$sValueuploadable file name
string$sTypeimage type
object$blDemoif true = whecks if file type is defined in oxutilsfile::_aAllowedFiles
string$sImagePathfinal image file location
bool$blUniqueif TRUE - generates unique file name
Returns
string

Definition at line 260 of file oxutilsfile.php.

oxUtilsFile::_setNewFilesCounter (   $iNewFilesCounter)
protected

Setter for param _iNewFilesCounter which counts how many new files added.

Parameters
integer$iNewFilesCounterNew files count.

Definition at line 137 of file oxutilsfile.php.

oxUtilsFile::checkFile (   $sFile)

Checks if passed file exists and may be opened for reading. Returns true on success.

Parameters
string$sFileName of file to check
Returns
bool

Definition at line 484 of file oxutilsfile.php.

oxUtilsFile::copyDir (   $sSourceDir,
  $sTargetDir 
)

Copies directory tree for creating a new shop.

Parameters
string$sSourceDirSource directory
string$sTargetDirTarget directory

Definition at line 164 of file oxutilsfile.php.

oxUtilsFile::deleteDir (   $sSourceDir)

Deletes directory tree.

Parameters
string$sSourceDirPath to directory
Returns
null

Definition at line 200 of file oxutilsfile.php.

oxUtilsFile::getImageDirByType (   $sType,
  $blGenerated = false 
)

Returns image storage path

Parameters
string$sTypeimage type
bool$blGeneratedgenerated image dir.
Returns
string

Definition at line 633 of file oxutilsfile.php.

oxUtilsFile::getNewFilesCounter ( )

Getter for param _iNewFilesCounter which counts how many new files added.

Returns
integer

Definition at line 127 of file oxutilsfile.php.

oxUtilsFile::normalizeDir (   $sDir)

Normalizes dir by adding missing trailing slash

Parameters
string$sDirDirectory
Returns
string

Definition at line 149 of file oxutilsfile.php.

oxUtilsFile::processFile (   $sFileName,
  $sUploadPath 
)

Process uploaded files. Returns unique file name, on fail false

Parameters
string$sFileNameform file item name
string$sUploadPathRELATIVE (to config sShopDir parameter) path for uploaded file to be copied
Exceptions
oxExceptionif file is not valid
Returns
string

Definition at line 551 of file oxutilsfile.php.

oxUtilsFile::processFiles (   $oObject = null,
  $aFiles = array(),
  $blUseMasterImage = false,
  $blUnique = true 
)

Uploaded file processor (filters, etc), sets configuration parameters to passed object and returns it.

Parameters
object$oObjectobject, that parameters are modified according to passed files
array$aFilesname of files to process
bool$blUseMasterImageuse master image as source for processing
bool$blUniqueTRUE - forces new file creation with unique name
Returns
object

Definition at line 404 of file oxutilsfile.php.

oxUtilsFile::readRemoteFileAsString (   $sPath)

Reads remote stored file. Returns contents of file.

Parameters
string$sPathRemote file path & name
Returns
string

Definition at line 233 of file oxutilsfile.php.

oxUtilsFile::translateError (   $iError)

Translate php file upload errors to user readable format.

Parameters
integer$iErrorphp file upload error number
Returns
string

Definition at line 652 of file oxutilsfile.php.

oxUtilsFile::urlValidate (   $sLink)

Checks if given URL is accessible (HTTP-Code: 200)

Parameters
string$sLinkgiven link
Returns
boolean

Definition at line 514 of file oxutilsfile.php.

Member Data Documentation

oxUtilsFile::$_aAllowedFiles = array('gif', 'jpg', 'jpeg', 'png', 'pdf')
protected

Definition at line 97 of file oxutilsfile.php.

oxUtilsFile::$_aBadFiles = array('php', 'php3', 'php4', 'php5', 'phps', 'php6', 'jsp', 'cgi', 'cmf', 'exe')
protected

Definition at line 90 of file oxutilsfile.php.

oxUtilsFile::$_aTypeToPath
protected

Definition at line 35 of file oxutilsfile.php.

oxUtilsFile::$_iMaxPicImgCount = 12
protected

Definition at line 21 of file oxutilsfile.php.

oxUtilsFile::$_iMaxZoomImgCount = 12
protected

Definition at line 28 of file oxutilsfile.php.

oxUtilsFile::$_iNewFilesCounter = 0
protected

Definition at line 104 of file oxutilsfile.php.

const oxUtilsFile::PROMO_PICTURE_DIR = 'promo'

Definition at line 14 of file oxutilsfile.php.


The documentation for this class was generated from the following file: