<?php
-// Lazy ClassLoader
-function __autoload( $class_name ){
- $s = '';
- $a = explode( '_', $class_name );
- foreach( $a as &$folder ){
- if ( $s!='' )
- $s .= '/';
- $s .= strtolower( $folder );
- }
- require_once($s.'.php');
+function __autoload($class_name)
+{
+ require_once strtolower(str_replace('_', '/', $class_name)) . '.php';
}
-final class IPF{
-
+final class IPF
+{
private static $settings = array();
- private static function applySettings($settings){
- foreach($settings as $key=>$val){
+ private static function applySettings($settings)
+ {
+ foreach($settings as $key=>$val)
IPF::$settings[strtolower($key)] = $val;
- }
}
- private static function loadSettings(){
+ private static function loadSettings()
+ {
$settings_file = IPF::$settings['project_path'].DIRECTORY_SEPARATOR.'settings.php';
IPF::$settings['settings_file'] = $settings_file;
{
IPF::$settings['ipf_path']=$ipf_path;
IPF::$settings['project_path']=$project_path;
- try{
+ try {
IPF::loadSettings();
- date_default_timezone_set(IPF::$settings['time_zone']);
- }catch(IPF_Exception_Settings $e){
+ date_default_timezone_set(IPF::$settings['time_zone']);
+ } catch(IPF_Exception_Settings $e) {
die('Setting Error: '.$e->getMessage()."\n");
}
}
- private function __construct(){}
- private function __clone(){}
+ private function __construct() {}
+ private function __clone() {}
- public static function get($name,$default=null){
- if (isset(IPF::$settings[$name]))
- return IPF::$settings[$name];
- return $default;
- }
+ public static function get($name, $default=null)
+ {
+ if (isset(IPF::$settings[$name]))
+ return IPF::$settings[$name];
+ return $default;
+ }
public static function loadFunction($function)
{
- if (function_exists($function)) {
+ if (function_exists($function))
return;
- }
$elts = explode('_', $function);
array_pop($elts);
$file = strtolower(implode(DIRECTORY_SEPARATOR, $elts)).'.php';
return new $model();
}
- public static function getUploadPath($params=array()){
- $upload_path = IPF::get('upload_path', '/tmp');
- if (isset($params['upload_path'])) {
- $upload_path = $params['upload_path'];
- }
- return $upload_path;
+ public static function getUploadPath()
+ {
+ return IPF::get('upload_path', '/tmp');
}
- public static function getUploadUrl($params=array()){
- $upload_url = IPF::get('upload_url', '/media/upload');
- if (isset($params['upload_url'])) {
- $upload_url = $params['upload_url'];
- }
- return $upload_url;
+ public static function getUploadUrl()
+ {
+ return IPF::get('upload_url', '/media/upload');
}
}
return $t;
}
-
}
}
- function save($parent_obj){
- if ($this->parentModel->exists()){
+ function save($parent_obj)
+ {
+ if ($this->parentModel->exists()) {
$objects = IPF_ORM_Query::create()
->from(get_class($this->model))
->orderby('id')
continue;
@list($x1,$x2,$id,$x3) = @explode('_',$form->prefix);
- if ($id==$obj->id){
- if ($form->cleaned_data[0]==true)
+ if ($id == $obj->id) {
+ if ($form->cleaned_data[0]==true) {
$obj->delete();
- else{
+ } else {
unset($form->cleaned_data[0]);
- foreach($form->fields as $fname=>$f){
- if (is_a($f,'IPF_Form_Field_File')){
+ foreach($form->fields as $fname=>$f) {
+ if (is_a($f,'IPF_Form_Field_File')) {
if($form->cleaned_data[$fname]===null)
continue;
if($form->cleaned_data[$fname]=='')
}
$fk_local = $this->getFkLocal();
- foreach($this->formset as $form){
- if ($form->isValid()){
+ foreach ($this->formset as $form) {
+ if ($form->isValid()) {
if ($form->isAdd){
unset($form->cleaned_data[0]);
$form->cleaned_data[$fk_local] = $parent_obj->id;
}
}
}
-}
\ No newline at end of file
+}
function IPF_Context_Upload($request)
{
- return array('UPLOAD_URL' => IPF::get('upload_url'));
+ return array('UPLOAD_URL' => IPF::getUploadUrl());
}
function IPF_Context_Current($request)
<?php
-class IPF_Form_DB_Email extends IPF_Form_DB{
+class IPF_Form_DB_Email extends IPF_Form_DB
+{
public $type = 'varchar';
public $extra = array('size' => 200);
- function formField($def, $form_field='IPF_Form_Field_Email'){
+ function formField($def, $form_field='IPF_Form_Field_Email')
+ {
return parent::formField($def, $form_field);
}
}
+
<?php
-class IPF_Form_DB_File extends IPF_Form_DB{
- function formField($def, $form_field='IPF_Form_Field_File'){
- return parent::formField($def, $form_field);
+class IPF_Form_DB_File extends IPF_Form_DB
+{
+ function formField($def, $form_field='IPF_Form_Field_File')
+ {
+ $field = parent::formField($def, $form_field);
+ $field->uploadTo = @$this->extra['uploadTo'];
+ return $field;
}
}
+
<?php
-class IPF_Form_DB_Image extends IPF_Form_DB{
- function formField($def, $form_field='IPF_Form_Field_Image'){
+class IPF_Form_DB_Image extends IPF_Form_DB_File
+{
+ function formField($def, $form_field='IPF_Form_Field_Image')
+ {
return parent::formField($def, $form_field);
}
}
+
$this->widget = $widget;
}
- function clean($value)
+ public function clean($value)
{
if ($this->required and in_array($value, $this->empty_values)) {
throw new IPF_Exception_Form(__('This field is required.'));
class IPF_Form_Field_File extends IPF_Form_Field
{
public $widget = 'IPF_Form_Widget_FileInput';
- public $move_function = 'IPF_Form_Field_moveToUploadFolder';
- public $remove_function = 'IPF_Form_Field_removeFile';
- public $rename_function = 'IPF_Form_Field_renameFile';
public $max_size = 20971520; // 20MB
- public $move_function_params = array();
+ public $uploadTo = '';
- function clean($value)
+ protected function removeFile($data)
{
- if (@$value['remove']===true){
- IPF::loadFunction($this->remove_function);
- return call_user_func($this->remove_function, $value['data']);
- }
- if (@$value['name']!=@$value['rename']){
- IPF::loadFunction($this->rename_function);
- return call_user_func($this->rename_function, $value);
- }
+ return null;
+ }
+
+ protected function getRelativePath($filename)
+ {
+ if ($this->uploadTo)
+ return $this->uploadTo . DIRECTORY_SEPARATOR . $filename;
+ else
+ return $filename;
+ }
+
+ protected function getAbsolutePath($filename)
+ {
+ $upload_root = IPF::getUploadPath() . DIRECTORY_SEPARATOR;
+ if ($this->uploadTo)
+ return $upload_root . $this->uploadTo . DIRECTORY_SEPARATOR . $filename;
+ else
+ return $upload_root . $filename;
+ }
+
+ protected function renameFile($old_name, $new_name)
+ {
+ @rename(getAbsolutePath($old_name), getAbsolutePath($new_name));
+ return getRelativePath($new_name);
+ }
+
+ public function clean($value)
+ {
+ IPF_Utils::makeDirectories($this->getAbsolutePath(''));
+
+ if (@$value['remove'] === true)
+ return $this->removeFile($value['data']);
+
+ if (@$value['name'] != @$value['rename'])
+ return $this->renameFile(@$value['name'], @$value['rename']);
+
$value = @$value['data'];
-
- if (@$value['name']=='')
+
+ if (@$value['name'] == '')
return '';
parent::clean($value);
- $errors = array();
- $no_files = false;
switch ($value['error']) {
- case UPLOAD_ERR_OK:
- break;
- case UPLOAD_ERR_INI_SIZE:
- case UPLOAD_ERR_FORM_SIZE:
- throw new IPF_Exception_Form(__('The uploaded file is too large. Reduce the size of the file and send it again.'));
- break;
- case UPLOAD_ERR_PARTIAL:
- throw new IPF_Exception_Form(__('The upload did not complete. Please try to send the file again.'));
- break;
- case UPLOAD_ERR_NO_FILE:
- throw new IPF_Exception_Form(__('No files were uploaded. Please try to send the file again.'));
- break;
- case UPLOAD_ERR_NO_TMP_DIR:
- case UPLOAD_ERR_CANT_WRITE:
- throw new IPF_Exception_Form(__('The server has no temporary folder correctly configured to store the uploaded file.'));
- break;
- case UPLOAD_ERR_EXTENSION:
- throw new IPF_Exception_Form(__('The uploaded file has been stopped by an extension.'));
- break;
- default:
- throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.'));
+ case UPLOAD_ERR_OK:
+ break;
+ case UPLOAD_ERR_INI_SIZE:
+ case UPLOAD_ERR_FORM_SIZE:
+ throw new IPF_Exception_Form(__('The uploaded file is too large. Reduce the size of the file and send it again.'));
+ break;
+ case UPLOAD_ERR_PARTIAL:
+ throw new IPF_Exception_Form(__('The upload did not complete. Please try to send the file again.'));
+ break;
+ case UPLOAD_ERR_NO_FILE:
+ throw new IPF_Exception_Form(__('No files were uploaded. Please try to send the file again.'));
+ break;
+ case UPLOAD_ERR_NO_TMP_DIR:
+ case UPLOAD_ERR_CANT_WRITE:
+ throw new IPF_Exception_Form(__('The server has no temporary folder correctly configured to store the uploaded file.'));
+ break;
+ case UPLOAD_ERR_EXTENSION:
+ throw new IPF_Exception_Form(__('The uploaded file has been stopped by an extension.'));
+ break;
+ default:
+ throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.'));
}
if ($value['size'] > $this->max_size) {
throw new IPF_Exception_Form(sprintf(__('The uploaded file is to big (%1$s). Reduce the size to less than %2$s and try again.'),
IPF_Utils::prettySize($value['size']),
IPF_Utils::prettySize($this->max_size)));
}
- IPF::loadFunction($this->move_function);
- return call_user_func($this->move_function, $value, $this->move_function_params);
- }
-}
-
-function IPF_Form_Field_moveToUploadFolder($value, $params=array())
-{
- $upload_path = IPF::getUploadPath($params);
- $name = IPF_Utils::cleanFileName($value['name'], $upload_path);
- $dest = $upload_path.DIRECTORY_SEPARATOR.$name;
- if (!move_uploaded_file($value['tmp_name'], $dest)) {
- throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.'));
+ $name = IPF_Utils::cleanFileName($value['name'], $this->getAbsolutePath(''));
+ $dest = $this->getAbsolutePath($name);
+ if (!move_uploaded_file($value['tmp_name'], $dest))
+ throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.'));
+ @chmod($dest, IPF::get('file_permission'));
+ return $this->getRelativePath($name);
}
- @chmod($dest, IPF::get('file_permission'));
- return $name;
-}
-
-
-function IPF_Form_Field_removeFile($value, $params=array()){
- return null;
-}
-
-function IPF_Form_Field_renameFile($value, $params=array()){
- $upload_path = IPF::getUploadPath($params);
- $old_name = @$upload_path.DIRECTORY_SEPARATOR.$value['name'];
- $new_name = @$upload_path.DIRECTORY_SEPARATOR.$value['rename'];
- @rename($old_name, $new_name);
- return @$value['rename'];
}
<?php
-class IPF_Form_Field_Image extends IPF_Form_Field_File{
- public $widget = 'IPF_Form_Widget_Image';
- public $move_function = 'IPF_Form_Field_moveImageToUploadFolder';
-}
-
-function IPF_Form_Field_moveImageToUploadFolder($value, $params=array())
+class IPF_Form_Field_Image extends IPF_Form_Field_File
{
- $name = IPF_Form_Field_moveToUploadFolder($value, $params);
- $upload_path = IPF::getUploadPath($params);
- $image = $upload_path.DIRECTORY_SEPARATOR.$name;
+ public $widget = 'IPF_Form_Widget_Image';
- if(!getimagesize($image))
- throw new IPF_Exception_Form(__('An error occured when upload the image.'));
- return $name;
+ public function clean($value)
+ {
+ $name = parent::clean($value);
+ if ($name) {
+ $image = IPF::getUploadPath() . DIRECTORY_SEPARATOR . $name;
+ if (!getimagesize($image))
+ throw new IPF_Exception_Form(__('An error occured when upload the image.'));
+ }
+ return $name;
+ }
}
$db_columns = $this->model->getTable()->getColumns();
$db_relations = $this->model->getTable()->getRelations();
- if ($user_fields===null){
-
+ if ($user_fields === null) {
if (isset($extra['exclude']))
$exclude = $extra['exclude'];
else
$exclude = array();
- foreach($db_columns as $name=>$col){
+ foreach($db_columns as $name=>$col) {
if (array_search($name,$exclude)!==false)
continue;
$this->addDBField($name,$col);
}
- foreach($db_relations as $name => $relation){
+ foreach($db_relations as $name => $relation) {
if (array_search($name,$exclude)!==false)
continue;
$this->addDBRelation($name,$relation,$col);
- }
- }
- else{
- foreach($user_fields as $uname){
+ }
+ } else {
+ foreach($user_fields as $uname) {
$add_method = 'add__'.$uname.'__field';
- if (method_exists($this,$add_method)){
+ if (method_exists($this,$add_method)) {
$this->$add_method();
continue;
}
- if (array_key_exists($uname,$db_columns))
+ if (array_key_exists($uname,$db_columns)) {
$this->addDBField($uname,$db_columns[$uname]);
- elseif (array_key_exists($uname,$db_relations)){
- $lfn = $db_relations[$uname]->getLocalFieldName();
- if (isset($db_columns[$lfn]))
- $col = $db_columns[$lfn];
- else
- $col = array();
+ } elseif (array_key_exists($uname,$db_relations)) {
+ $lfn = $db_relations[$uname]->getLocalFieldName();
+ if (isset($db_columns[$lfn]))
+ $col = $db_columns[$lfn];
+ else
+ $col = array();
$this->addDBRelation($uname,$db_relations[$uname],$col);
}
}
}
}
- function addDBField($name,$col){
+ function addDBField($name, $col)
+ {
if ($name==$this->model->getTable()->getIdentifier())
return;
$defaults = array('blank' => true, 'verbose' => $name, 'help_text' => '', 'editable' => true);
$type = $col['type'];
- if (isset($col['notblank']))
+ if (isset($col['notblank'])) {
if ($col['notblank'])
$defaults['blank'] = false;
else
$defaults['blank'] = true;
+ }
if (isset($col['length']))
$defaults['max_length'] = (int)($col['length']);
+
if (isset($col['email']))
$type = 'email';
$cn = 'IPF_Form_DB_'.$type;
- $db_field = new $cn('', $name);
+ $db_field = new $cn('', $name, $col);
- if (null !== ($form_field=$db_field->formField($defaults))) {
+ $form_field = $db_field->formField($defaults);
+ if ($form_field !== null)
$this->fields[$name] = $form_field;
- }
}
- function addDBRelation($name,$relation,$col){
-
- if (isset($col['notblank']))
- $blank = false;
- else
- $blank = true;
+ function addDBRelation($name, $relation, $col)
+ {
+ if (isset($col['notblank']))
+ $blank = false;
+ else
+ $blank = true;
- if ($relation->getType()==IPF_ORM_Relation::ONE_AGGREGATE){
+ if ($relation->getType()==IPF_ORM_Relation::ONE_AGGREGATE) {
$name .= "_id";
$db_field = new IPF_Form_DB_Foreignkey('',$name);
$defaults = array('blank' => $blank, 'verbose' => $name, 'help_text' => '', 'editable' => true, 'model'=>$relation->getClass());
$this->fields[$name] = $form_field;
return;
}
- if ($relation->getType()==IPF_ORM_Relation::MANY_AGGREGATE){
+ if ($relation->getType()==IPF_ORM_Relation::MANY_AGGREGATE) {
$db_field = new IPF_Form_DB_ManyToMany('',$name);
$defaults = array('blank' => $blank, 'verbose' => $name, 'help_text' => '', 'editable' => true, 'model'=>$relation->getClass());
$form_field = $db_field->formField($defaults);
}
}
- function fields(){ return $this->user_fields; }
+ function fields()
+ {
+ return $this->user_fields;
+ }
function save($commit=true)
{
//throw new IPF_Exception_Form(__('Cannot save the model from an invalid form.'));
}
}
+
public $allow_extended = true;
public $allow_delete = true;
- public $additional_params = array();
-
public function render($name, $value, $extra_attrs=array())
{
$sim = '';
- if (isset($value['data'])){
+ if (isset($value['data'])) {
$value = $value['data'];
- if (is_string($value) && $value!=''){
- if ($this->allow_extended){
- $sim = '<nobr>Currently: <input name="'.$name.'_name" value="'.$value.'" type="hidden" /><input name="'.$name.'_rename" value="'.$value.'" id="id_'.$name.'_rename" type="text" style="width:150px;" /> <a target="_blank" href="'.IPF::getUploadUrl($this->additional_params).$value.'">view</a>';
- if ($this->allow_delete)
- $sim .= ' | <input name="'.$name.'_remove" value="1" id="id_'.$name.'_remove" type="checkbox" /> <label class="file_remove" for="id_'.$name.'_remove">Remove</label></nobr>';
- $sim .= ' Change:';
- }
- else
- $sim = '<nobr>Currently: <b>'.$value.'</b><br> Change: ';
+ if (is_string($value) && $value != '') {
+ if ($this->allow_extended) {
+ $sim = '<nobr>Currently: <input name="'.$name.'_name" value="'.$value.'" type="hidden" /><input name="'.$name.'_rename" value="'.$value.'" id="id_'.$name.'_rename" type="text" style="width:150px;" /> <a target="_blank" href="'.IPF::getUploadUrl().$value.'">view</a>';
+ if ($this->allow_delete)
+ $sim .= ' | <input name="'.$name.'_remove" value="1" id="id_'.$name.'_remove" type="checkbox" /> <label class="file_remove" for="id_'.$name.'_remove">Remove</label></nobr>';
+ $sim .= ' Change:';
+ } else {
+ $sim = '<nobr>Currently: <b>'.$value.'</b><br> Change: ';
+ }
}
}
$value = '';
return $sim.parent::render($name, $value, $extra_attrs);
}
- public function valueFromFormData($name, &$data){
- if (isset($data[$name])) {
- $remove = false;
- if (isset($data[$name.'_remove']))
- if ($data[$name.'_remove']==1)
- $remove = true;
- $res = array('data'=>$data[$name], 'remove'=>$remove);
- if (isset($data[$name.'_rename']))
- $res['rename'] = $data[$name.'_rename'];
- if (isset($data[$name.'_name']))
- $res['name'] = $data[$name.'_name'];
- return $res;
- }
- return null;
+ public function valueFromFormData($name, &$data)
+ {
+ if (!isset($data[$name]))
+ return null;
+ $remove = isset($data[$name.'_remove']) && $data[$name.'_remove'] == 1;
+ $res = array('data'=>$data[$name], 'remove'=>$remove);
+ if (isset($data[$name.'_rename']))
+ $res['rename'] = $data[$name.'_rename'];
+ if (isset($data[$name.'_name']))
+ $res['name'] = $data[$name.'_name'];
+ return $res;
}
- public function valueToFormData($name, $data){
- if (isset($data[$name])) {
- $remove = false;
- if (isset($data[$name.'_remove']))
- if ($data[$name.'_remove']==1)
- $remove = true;
- $res = array('data'=>$data[$name], 'remove'=>$remove);
- return $res;
- }
- return null;
+ public function valueToFormData($name, $data)
+ {
+ if (!isset($data[$name]))
+ return null;
+ $remove = isset($data[$name.'_remove']) && $data[$name.'_remove'] == 1;
+ return array('data'=>$data[$name], 'remove'=>$remove);
}
}
+
'file',
'image',
'html',
+ 'uploadTo',
);
}
--- /dev/null
+<?php
+
+class IPF_ORM_Validator_UploadTo
+{
+ public function validate($value)
+ {
+ return true;
+ }
+}
+
<?php
-class IPF_Utils {
-
- public static function isValidName( $s, $max_length=50 ){
+class IPF_Utils
+{
+ public static function isValidName($s, $max_length=50)
+ {
if (!is_string($s))
return false;
if ( (strlen($s)==0) || (strlen($s)>$max_length) )
return true;
}
- public static function isEmail($value){
+ public static function isEmail($value)
+ {
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$name = mb_strtolower($name, 'UTF-8');
$name = mb_ereg_replace("/\015\012|\015|\012|\s|[^A-Za-z0-9\.\-\_]/", '_', $name);
- while(file_exists($path.$name)){
+ while (file_exists($path . $name)) {
$pathinfo = pathinfo($name);
$filename = $pathinfo['filename'];
$split = explode('_', $filename);
$n = count($split);
- if ($n<2){
+ if ($n < 2) {
$filename .= '_2';
- }
- else{
+ } else {
$x = $split[$n-1];
- if (is_numeric($x)){
+ if (is_numeric($x)) {
$split[$n-1] = ((int)$x)+1;
- }
- else
+ } else {
$split[] = '2';
+ }
$filename = '';
- foreach($split as $sp){
- if ($filename!='') $filename.='_';
+ foreach ($split as $sp) {
+ if ($filename != '')
+ $filename .= '_';
$filename .= $sp;
}
}
return (preg_match('!^(http|https|ftp|gopher)\://('.$ip.'|'.$dom.')!i', $url)) ? true : false;
}
- static function humanTitle($s){
+ static function humanTitle($s)
+ {
$s = ucfirst(str_replace('_',' ',str_replace('_id','',$s)));
- $ns = '';
- for ($i=0; $i<strlen($s); $i++){
- if ( ($i>0) && (ucfirst($s[$i-1])!=$s[$i-1]) && (ucfirst($s[$i])==$s[$i]) )
- $ns .= ' ';
- if ($s[$i]=='_')
- $ns .= ' ';
- else
- $ns .= $s[$i];
- }
- return $ns;
+ $ns = '';
+ for ($i = 0; $i < strlen($s); ++$i) {
+ if ( ($i>0) && (ucfirst($s[$i-1])!=$s[$i-1]) && (ucfirst($s[$i])==$s[$i]) )
+ $ns .= ' ';
+
+ if ($s[$i] == '_')
+ $ns .= ' ';
+ else
+ $ns .= $s[$i];
+ }
+ return $ns;
}
static function randomString($len=35)
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$lchars = strlen($chars);
$i = 0;
- while ($i<$len) {
+ while ($i < $len) {
$string .= substr($chars, mt_rand(0, $lchars-1), 1);
$i++;
}
static function dateCompare($date1, $date2=null)
{
- if (strlen($date1) == 10){
+ if (strlen($date1) == 10) {
$date1 .= ' 23:59:59';
}
if (is_null($date2)) {
return $date2 - $date1;
}
- static function appLabelByModel($model){
- foreach (IPF_Project::getInstance()->appList() as $app){
- foreach($app->modelList() as $m){
+ static function appLabelByModel($model)
+ {
+ foreach (IPF_Project::getInstance()->appList() as $app) {
+ foreach($app->modelList() as $m) {
if ($model==$m)
return strtolower($app->getLabel());
}
return '';
}
- public static function makeDirectories($path, $mode = 0777){
- if ( ! $path) {
+ public static function makeDirectories($path, $mode=0777)
+ {
+ if (!$path)
return false;
- }
- if (is_dir($path) || is_file($path)) {
+
+ if (is_dir($path) || is_file($path))
return true;
- }
+
return mkdir(trim($path), $mode, true);
}
- public static function removeDirectories($folderPath){
- if (is_dir($folderPath)){
- foreach (scandir($folderPath) as $value){
- if ($value != '.' && $value != '..'){
+ public static function removeDirectories($folderPath)
+ {
+ if (is_dir($folderPath)) {
+ foreach (scandir($folderPath) as $value) {
+ if ($value != '.' && $value != '..') {
$value = $folderPath . "/" . $value;
if (is_dir($value)) {
self::removeDirectories($value);
}
}
- public static function copyDirectory($source, $dest){
+ public static function copyDirectory($source, $dest)
+ {
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Loop through the folder
$dir = dir($source);
- while (false !== $entry = $dir->read()){
+ while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
return $s;
}
- public static function timestamp(){
- list($f,$i) = explode(' ',microtime());
- return $i.substr((string)$f,2,6);
+ public static function timestamp()
+ {
+ list($f,$i) = explode(' ',microtime());
+ return $i.substr((string)$f,2,6);
}
- static function TrimP($html){
+ static function TrimP($html)
+ {
$strL = "<p>"; $lenL = 3;
$strR = "</p>"; $lenR = 4;
if (0 == strcasecmp(substr($html, 0, $lenL), $strL)
return $html;
}
- static function moneyFormat($val){
+ static function moneyFormat($val)
+ {
return number_format((float)$val,2);
}
- static function toSlug($slug){
- if ($slug){
+ static function toSlug($slug)
+ {
+ if ($slug)
return strtolower(preg_replace('/[^A-Z^a-z^0-9^\/\_]+/', '-', $slug));
- }
return $slug;
}
-
-
}