Skip to content

Commit

Permalink
Merge branch 'release/1.0.25'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zavy86 committed Mar 4, 2020
2 parents 0cd5a67 + 76f2387 commit dc7425a
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
@@ -1 +1 @@
1.0.24
1.0.25
1 change: 1 addition & 0 deletions classes/cObject.class.php
Expand Up @@ -191,6 +191,7 @@ public function getLogs($limit=null){
* Check if current object exist in database
*/
public function exists(){
if(!$this->id){return false;}
// make query
$query="SELECT COUNT(*) FROM `".static::$table."` WHERE `id`='".$this->id."'";
//api_dump($query,static::class."->exists query");
Expand Down
28 changes: 28 additions & 0 deletions functions/date.inc.php
Expand Up @@ -45,4 +45,32 @@ function api_date_format($datetime,$format="Y-m-d",$timezone=null){
return $dt->format($format);
}

/**
* Date Difference
*
* @param string $datetime_a Date Time in format YYYY-MM-DD [HH:II:SS]
* @param string $datetime_b Date Time in format YYYY-MM-DD [HH:II:SS]
* @param string $format Return format (d days | s seconds)
* @return double|false Date difference in selected format or false
*/
function api_date_difference($datetime_a=null,$datetime_b=null,$format="d"){
// check parameters
if(!$datetime_a || !$datetime_b){return false;}
if(!in_array($format,array("d","s"))){return false;}
// days format
if($format=="d"){
$datediff_a=strtotime(substr($datetime_a,0,10));
$datediff_b=strtotime(substr($datetime_b,0,10));
$difference=round(($datediff_b-$datediff_a)/60/60/24);
}
// seconds format
if($format=="s"){
$datediff_a=strtotime($datetime_a);
$datediff_b=strtotime($datetime_b);
$difference=$datediff_b-$datediff_a;
}
// return
return $difference;
}

?>
2 changes: 1 addition & 1 deletion functions/timestamp.inc.php
Expand Up @@ -136,7 +136,7 @@ function api_timestampDifferenceFrom($timestamp,$difference,$format=null){/** @t
/**
* Timestamp Difference Days
*
* @param integer $difference Number of seconds
* @param integer $difference Number of days
* @return string Formatted timestamp difference
*/
function api_timestampDifferenceDays($difference){
Expand Down
79 changes: 79 additions & 0 deletions functions/uploads.inc.php
Expand Up @@ -72,4 +72,83 @@ function api_uploads_remove($path,$file){
return true;
}

/**
* List of uploaded files
*
* @param string $path Directory starting after /uploads/
* @param string $file File to remove
* @return boolean
*/
function api_uploads_list($path,$file){
// check parameters
if(!trim($path,"/")){return false;}
// make uploads directory
$directory=DIR."uploads/".trim($path,"/")."/";
// scan directory
$files_array=scandir($directory);
if(!is_array($files_array)){$files_array=array();}
// remove directories
foreach($files_array as $key=>$file){
if(in_array($file,array(".",".."))){unset($files_array[$key]);}
if(is_dir($file)){unset($files_array[$key]);}
}
// return
return $files_array;
}

/**
* Size of uploaded file
*
* @param string $path Directory starting after /uploads/
* @param string $file File name
* @param string $format Format size with unit or return bytes
* @return double|string|false
*/
function api_uploads_size($path,$file,$format=false){
// check parameters
if(!trim($path,"/")){return false;}
// make uploads directory
$directory=DIR."uploads/".trim($path,"/")."/";
// check if file exists
if(!file_exists($directory.$file)){return false;}
// get file size
$size=filesize($directory.$file);
// format size
if($format){
if($size>=1073741824){
$return=round($size/1073741824,2)." GB";
}elseif($size>=1048576){
$return=round($size/1048576,2)." MB";
}elseif($size>=1024){
$return=round($size/1024)." KB";
}else{
$return=$size." Byte";
}
}else{
$return=$size;
}
// return
return $return;
}

/**
* Read uploaded file
*
* @param string $path Directory starting after /uploads/
* @param string $file File name
* @return boolean
*/
function api_uploads_read($path,$file){
// check parameters
if(!trim($path,"/")){return false;}
// make uploads directory
$directory=DIR."uploads/".trim($path,"/")."/";
// check if file exists
if(!file_exists($directory.$file)){return false;}
// get file content
$content=readfile($directory.$file);
// return
return $content;
}

?>
1 change: 1 addition & 0 deletions initializations.inc.php
Expand Up @@ -97,6 +97,7 @@
require_once(DIR."structures/strPanel.class.php");
require_once(DIR."structures/strParametersForm.class.php");
require_once(DIR."structures/strProgressBar.class.php");
require_once(DIR."structures/strSearchBar.class.php");
require_once(DIR."structures/strTab.class.php");
require_once(DIR."structures/strTable.class.php");

Expand Down
3 changes: 2 additions & 1 deletion localizations/default.xml
Expand Up @@ -95,7 +95,8 @@
<text key="table-td-delete">Delete</text>
<text key="table-td-undelete">Undelete</text>
<text key="table-td-remove">Remove</text>
<text key="table-td-status">Stato update</text>
<text key="table-td-status">Update status</text>
<text key="table-td-download">Download</text>

<!-- forms -->
<text key="form-fc-submit">Submit</text>
Expand Down
1 change: 1 addition & 0 deletions localizations/it_IT.xml
Expand Up @@ -96,6 +96,7 @@
<text key="table-td-undelete">Ripristina</text>
<text key="table-td-remove">Rimuovi</text>
<text key="table-td-status">Aggiorna stato</text>
<text key="table-td-download">Scarica</text>

<!-- forms -->
<text key="form-fc-submit">Salva</text>
Expand Down
2 changes: 1 addition & 1 deletion structures/strForm.class.php
Expand Up @@ -92,7 +92,7 @@ public function addField($typology,$name=null,$label=null,$value=null,$placehold
if($field->size<1 || $field->size>10){$field->size=10;}
if($field->typology=="file"){
$field->class="filestyle ".$field->class;
$field->tags="data-buttonText=\"\" data-iconName=\"fa fa-fw fa-folder-open-o faa-tada animated-hover\" data-placeholder=\"".api_text("form-input-file-placeholder")."\" ".$field->tags;
$field->tags="data-buttonText=\"\" data-iconName=\"fa fa-fw fa-folder-open-o faa-tada animated-hover\" data-placeholder=\"".api_text("form-input-file-placeholder")."\"".$field->tags;
if(!$field->enabled){$field->tags="data-disabled=\"true\" ".$field->tags;}
}
// text localized
Expand Down
75 changes: 75 additions & 0 deletions structures/strSearchBar.class.php
@@ -0,0 +1,75 @@
<?php
/**
* Search Bar
*
* Coordinator Structure Class for Search Bars
*
* @package Coordinator\Classes
* @author Manuel Zavatta <manuel.zavatta@gmail.com>
* @link http://www.coordinator.it
*/

/**
* Search bar structure class
*/
class strSearchBar{

/** Properties */
protected $id;
protected $action;
protected $class;
protected $style;
protected $tags;

/**
* Search Bar structure class
*
* @param string $action Submit URL
* @param string $class CSS class
* @param string $style Custom CSS
* @param string $tags Custom HTML tags
* @param string $id Search Bar ID, if null randomly generated
* @return boolean
*/
public function __construct($action,$class=null,$style=null,$tags=null,$id=null){
if(substr($action,0,1)=="?"){$action="index.php".$action;}
if(!$action){return false;}
$this->id="searchbar_".($id?$id:api_random());
$this->action=$action;
$this->class=$class;
$this->style=$style;
$this->tags=$tags;
return true;
}

/**
* Renderize Search Bar object
*
* @return string HTML source code
*/
public function render(){
// renderize search bar
$return.="<!-- search bar -->\n";
$return.="<form class=\"form-inline ".$this->class."\"";
$return.=" action=\"".$this->action."\"";
$return.=" method=\"POST\"";
$return.=" id=\"".$this->id."\"";
if($this->style){$return.=" style=\"".$this->style."\"";}
if($this->tags){$return.=" ".$this->tags;}
$return.=">\n";
$return.=" <div class=\"form-group\" style=\"width:100%;\">\n";
$return.=" <div class=\"input-group\" style=\"width:100%;\">\n";
$return.=" <input type=\"text\" class=\"form-control\" name=\"searchbar_query\" id=\"".$this->id."_input_search\" placeholder=\"".api_text("form-fc-search")."\" value=\"".$_REQUEST['searchbar_query']."\">\n";
$return.=" <div class=\"input-group-btn\">\n";
$return.=" <a role=\"button\" href=\"#\" class=\"btn btn-primary\" onClick=\"document.getElementById('".$this->id."').submit();\">".api_text("form-fc-search")."</a>\n";
$return.=" </div><!-- input-group-btn -->\n";
$return.=" </div><!-- /input-group -->\n";
$return.=" </div><!-- /form-group -->\n";
$return.="</form><!-- /form -->\n";
// return HTML source
return $return;
}

}

?>

0 comments on commit dc7425a

Please sign in to comment.