mirror of https://github.com/xfarrow/phpxpress.git
Update to 1.0.4
* It is now possible to use both Custom and Bootstrap colors; * Fixed some reference errors * Version is now a function rather than a comment in the source code
This commit is contained in:
parent
adc6089ba1
commit
2efc085d3f
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PhpXpress v1.0.1
|
||||
/*
|
||||
*
|
||||
* @see https://github.com/xfarrow/phpxpress The PhpXpress GitHub project
|
||||
*
|
||||
|
@ -32,7 +31,7 @@
|
|||
*/
|
||||
function setDataSource($dataSource){
|
||||
if(!is_array($dataSource))
|
||||
throw new InvalidArgumentException('Parameter dataSource must be an array.');
|
||||
throw new \InvalidArgumentException('Parameter dataSource must be an array.');
|
||||
|
||||
foreach($dataSource as $caption => $link){
|
||||
$this->addElement($caption, $link);
|
||||
|
@ -60,7 +59,7 @@
|
|||
function setActiveLocation($activeLocation){
|
||||
|
||||
if(!is_scalar($activeLocation) && !is_string($activeLocation))
|
||||
throw new InvalidArgumentException('Parameter activeLocation can be either an int or a string. None of these provided.');
|
||||
throw new \InvalidArgumentException('Parameter activeLocation can be either an int or a string. None of these provided.');
|
||||
|
||||
$this->activeLocation = $activeLocation;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PhpXpress v1.0.1
|
||||
*
|
||||
* @see https://github.com/xfarrow/phpxpress The PhpXpress GitHub project
|
||||
*
|
||||
|
@ -57,7 +56,7 @@
|
|||
|
||||
function setImageSource($imageSource){
|
||||
if(!is_string($imageSource))
|
||||
throw new InvalidArgumentException('Parameter imageSource must be a string.');
|
||||
throw new \InvalidArgumentException('Parameter imageSource must be a string.');
|
||||
|
||||
$this->imageSource = $imageSource;
|
||||
}
|
||||
|
@ -211,7 +210,7 @@
|
|||
*/
|
||||
function onFieldDisplaying($functionName){
|
||||
if(!is_callable($functionName))
|
||||
throw new InvalidArgumentException("Couldn't call $functionName. You must provide the name of a function.");
|
||||
throw new \InvalidArgumentException("Couldn't call $functionName. You must provide the name of a function.");
|
||||
|
||||
$this -> onFieldDisplayingFunctionName = $functionName;
|
||||
}
|
||||
|
|
|
@ -1,37 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace PhpXpress;
|
||||
|
||||
class Code{
|
||||
|
||||
public static function doublequote($string){
|
||||
return '"' . $string . '"';
|
||||
}
|
||||
private static $colors_array = array( "blue" => "primary",
|
||||
"gray" => "secondary",
|
||||
"green" => "success",
|
||||
"red" => "danger",
|
||||
"yellow" => "warning",
|
||||
"cyan" => "info",
|
||||
"white" => "light",
|
||||
"black" => "dark");
|
||||
|
||||
public static function bootstrapColors($color){
|
||||
if($color == 'blue')
|
||||
return 'primary';
|
||||
|
||||
if($color == 'gray')
|
||||
return 'secondary';
|
||||
if(array_key_exists($color, self::$colors_array)){
|
||||
return self::$colors_array[$color];
|
||||
}
|
||||
|
||||
if($color == 'green')
|
||||
return 'success';
|
||||
if(in_array($color, self::$colors_array)){
|
||||
return $color;
|
||||
}
|
||||
|
||||
if($color == 'red')
|
||||
return 'danger';
|
||||
|
||||
if($color == 'yellow')
|
||||
return 'warning';
|
||||
|
||||
if($color == 'cyan')
|
||||
return 'info';
|
||||
|
||||
if($color == 'white')
|
||||
return 'light';
|
||||
|
||||
if($color == 'black')
|
||||
return 'dark';
|
||||
|
||||
throw new InvalidArgumentException('Color not valid. Available colors: blue, gray, green, red, yellow, cyan, white, black');
|
||||
throw new \InvalidArgumentException("Color $color is not valid. Available colors: blue, gray, green, red, yellow, cyan, white, black");
|
||||
}
|
||||
|
||||
public static function phpxpress_version(){
|
||||
return "1.0.4";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PhpXpress v1.0.1
|
||||
*
|
||||
* @see https://github.com/xfarrow/phpxpress The PhpXpress GitHub project
|
||||
*
|
||||
|
@ -47,12 +46,12 @@
|
|||
$this->size = "btn-sm";
|
||||
|
||||
else
|
||||
throw new InvalidArgumentException('Parameter size must be either default, large or small.');
|
||||
throw new \InvalidArgumentException('Parameter size must be either default, large or small.');
|
||||
}
|
||||
|
||||
public function setDarkTheme($bool){
|
||||
if(!is_bool($bool))
|
||||
throw new InvalidArgumentException('Parameter must be a bool.');
|
||||
throw new \InvalidArgumentException('Parameter must be a bool.');
|
||||
|
||||
$this->darkTheme = $bool;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PhpXpress v1.0.3
|
||||
*
|
||||
* @see https://github.com/xfarrow/phpxpress The PhpXpress GitHub project
|
||||
*
|
||||
|
@ -69,7 +68,7 @@
|
|||
function draw(){
|
||||
|
||||
if(!isset($this->dataSource)){
|
||||
throw new BadFunctionCallException('Error: datasource not set.');
|
||||
throw new \BadFunctionCallException('Error: datasource not set.');
|
||||
}
|
||||
|
||||
$tableClass = "table";
|
||||
|
@ -151,7 +150,7 @@
|
|||
*/
|
||||
function setDataSource(Array $dataSource){
|
||||
if(isset($this-> dataSource))
|
||||
throw new BadFunctionCallException("Cannot add datasource to a Table already having a datasource");
|
||||
throw new \BadFunctionCallException("Cannot add datasource to a Table already having a datasource");
|
||||
|
||||
if(empty($dataSource)){
|
||||
$this->dataSource = [];
|
||||
|
@ -166,7 +165,7 @@
|
|||
$is_array_of_arrays = true;
|
||||
}
|
||||
else{
|
||||
throw new InvalidArgumentException('Parameter "datasource" must be an' .
|
||||
throw new \InvalidArgumentException('Parameter "datasource" must be an' .
|
||||
'array of array(s) or array of object(s)');
|
||||
}
|
||||
|
||||
|
@ -179,10 +178,10 @@
|
|||
return $is_array_of_arrays;
|
||||
}
|
||||
else
|
||||
throw new InvalidArgumentException('Parameter "datasource" must be an' .
|
||||
throw new \InvalidArgumentException('Parameter "datasource" must be an' .
|
||||
'array of array(s) or array of object(s)');
|
||||
})) > 0){
|
||||
throw new InvalidArgumentException('Parameter "datasource" must be an' .
|
||||
throw new \InvalidArgumentException('Parameter "datasource" must be an' .
|
||||
'array of array(s) or array of object(s)');
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +226,7 @@
|
|||
function setCustomCaptions(Array $captions){
|
||||
|
||||
if(empty($this->dataSource))
|
||||
throw new BadFunctionCallException('Before setting Custom captions, a non empty datasource must be provided first.');
|
||||
throw new \BadFunctionCallException('Before setting Custom captions, a non empty datasource must be provided first.');
|
||||
|
||||
$provided = count($captions);
|
||||
$expected = count($this->columnCaptions);
|
||||
|
@ -235,7 +234,7 @@
|
|||
if($provided == $expected)
|
||||
$this -> columnCaptions = $captions;
|
||||
else
|
||||
throw new LengthException('Number of provided captions not matching the datasource ones.
|
||||
throw new \LengthException('Number of provided captions not matching the datasource ones.
|
||||
Provided: ' . $provided . "; Expected: " . $expected);
|
||||
}
|
||||
|
||||
|
@ -276,7 +275,7 @@
|
|||
function invisible_column($column_name){
|
||||
|
||||
if(!isset($this->dataSource) || empty($this->dataSource))
|
||||
throw new BadFunctionCallException('Unable to call invisible_column() if the datasource is not set or empty.');
|
||||
throw new \BadFunctionCallException('Unable to call invisible_column() if the datasource is not set or empty.');
|
||||
|
||||
if(is_array($this->dataSource[0])){
|
||||
$array_keys = array_keys($this -> dataSource[0]);
|
||||
|
@ -286,12 +285,12 @@
|
|||
}
|
||||
|
||||
if(!in_array($column_name, $array_keys)){
|
||||
throw new InvalidArgumentException("The provided column $column_name is not present in the datasource's column keys");
|
||||
throw new \InvalidArgumentException("The provided column $column_name is not present in the datasource's column keys");
|
||||
}
|
||||
|
||||
if(isset($this->invisible_columns)){
|
||||
if(in_array($column_name, $this->invisible_columns))
|
||||
throw new InvalidArgumentException("The provided column $column_name is already invisible");
|
||||
throw new \InvalidArgumentException("The provided column $column_name is already invisible");
|
||||
|
||||
array_push($this->invisible_columns, $column_name);
|
||||
}
|
||||
|
@ -315,42 +314,42 @@
|
|||
*/
|
||||
function onValueDisplaying($functionName){
|
||||
if(!is_callable($functionName))
|
||||
throw new InvalidArgumentException("Couldn't call $functionName. You must provide the name of a function.");
|
||||
throw new \InvalidArgumentException("Couldn't call $functionName. You must provide the name of a function.");
|
||||
|
||||
$this -> onValueDisplayingFunctionName = $functionName;
|
||||
}
|
||||
|
||||
function setDarkTheme($bool){
|
||||
if(!is_bool($bool)){
|
||||
throw new InvalidArgumentException('Parameter must be a boolean.');
|
||||
throw new \InvalidArgumentException('Parameter must be a boolean.');
|
||||
}
|
||||
$this->darkTheme = $bool;
|
||||
}
|
||||
|
||||
function setStripedRows($bool){
|
||||
if(!is_bool($bool)){
|
||||
throw new InvalidArgumentException('Parameter must be a boolean.');
|
||||
throw new \InvalidArgumentException('Parameter must be a boolean.');
|
||||
}
|
||||
$this->stripedRows = $bool;
|
||||
}
|
||||
|
||||
function setBordered($bool){
|
||||
if(!is_bool($bool)){
|
||||
throw new InvalidArgumentException('Parameter must be a boolean.');
|
||||
throw new \InvalidArgumentException('Parameter must be a boolean.');
|
||||
}
|
||||
$this->bordered = $bool;
|
||||
}
|
||||
|
||||
function setHoverAnimation($bool){
|
||||
if(!is_bool($bool)){
|
||||
throw new InvalidArgumentException('Parameter must be a boolean.');
|
||||
throw new \InvalidArgumentException('Parameter must be a boolean.');
|
||||
}
|
||||
$this->hoverAnimation = $bool;
|
||||
}
|
||||
|
||||
function setSmall($bool){
|
||||
if(!is_bool($bool)){
|
||||
throw new InvalidArgumentException('Parameter must be a boolean.');
|
||||
throw new \InvalidArgumentException('Parameter must be a boolean.');
|
||||
}
|
||||
$this->small = $bool;
|
||||
}
|
||||
|
@ -358,7 +357,7 @@
|
|||
// to be used before setting the datasource
|
||||
function setPedanticTypeCheck($bool){
|
||||
if(!is_bool($bool)){
|
||||
throw new InvalidArgumentException('Parameter must be a boolean.');
|
||||
throw new \InvalidArgumentException('Parameter must be a boolean.');
|
||||
}
|
||||
if(isset($this->datasource)){
|
||||
echo "<b>Warning</b>Use of pedantic type check after datasource is set. Instruction ignored.";
|
||||
|
|
Loading…
Reference in New Issue