add a scale element to the frame view. Include some bits from StorageAreas to make it work
parent
9e9b1a3a35
commit
568160e5aa
|
@ -1,51 +1,81 @@
|
||||||
<?php
|
<?php
|
||||||
require_once( 'database.php' );
|
require_once( 'database.php' );
|
||||||
class Storage {
|
class Storage {
|
||||||
public function __construct( $IdOrRow = NULL ) {
|
public function __construct( $IdOrRow = NULL ) {
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
if ( $IdOrRow ) {
|
if ( $IdOrRow ) {
|
||||||
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
|
||||||
$row = dbFetchOne( 'SELECT * FROM Storage WHERE Id=?', NULL, array( $IdOrRow ) );
|
$row = dbFetchOne( 'SELECT * FROM Storage WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||||
if ( ! $row ) {
|
if ( ! $row ) {
|
||||||
Error("Unable to load Storage record for Id=" . $IdOrRow );
|
Error("Unable to load Storage record for Id=" . $IdOrRow );
|
||||||
}
|
}
|
||||||
} elseif ( is_array( $IdOrRow ) ) {
|
} elseif ( is_array( $IdOrRow ) ) {
|
||||||
$row = $IdOrRow;
|
$row = $IdOrRow;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( $row ) {
|
|
||||||
foreach ($row as $k => $v) {
|
|
||||||
$this->{$k} = $v;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$this->{'Name'} = '';
|
|
||||||
$this->{'Path'} = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if ( $row ) {
|
||||||
|
foreach ($row as $k => $v) {
|
||||||
|
$this->{$k} = $v;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->{'Name'} = '';
|
||||||
|
$this->{'Path'} = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function Path() {
|
public function Path() {
|
||||||
if ( isset( $this->{'Path'} ) and ( $this->{'Path'} != '' ) ) {
|
if ( isset( $this->{'Path'} ) and ( $this->{'Path'} != '' ) ) {
|
||||||
return $this->{'Path'};
|
return $this->{'Path'};
|
||||||
} else if ( ! isset($this->{'Id'}) ) {
|
} else if ( ! isset($this->{'Id'}) ) {
|
||||||
return ZM_DIR_EVENTS;
|
$path = ZM_DIR_EVENTS;
|
||||||
}
|
if ( $path[0] != '/' ) {
|
||||||
return $this->{'Name'};
|
$this->{'Path'} = ZM_PATH_WEB.'/'.ZM_DIR_EVENTS;
|
||||||
}
|
} else {
|
||||||
public function __call( $fn, array $args= NULL){
|
$this->{'Path'} = ZM_DIR_EVENTS;
|
||||||
if(isset($this->{$fn})){
|
}
|
||||||
return $this->{$fn};
|
return $this->{'Path'};
|
||||||
#array_unshift($args, $this);
|
|
||||||
#call_user_func_array( $this->{$fn}, $args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public static function find_all() {
|
return $this->{'Name'};
|
||||||
$storage_areas = array();
|
}
|
||||||
$result = dbQuery( 'SELECT * FROM Storage ORDER BY Name');
|
public function Name() {
|
||||||
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' );
|
if ( isset( $this->{'Name'} ) and ( $this->{'Name'} != '' ) ) {
|
||||||
foreach ( $results as $row => $obj ) {
|
return $this->{'Name'};
|
||||||
$storage_areas[] = $obj;
|
} else if ( ! isset($this->{'Id'}) ) {
|
||||||
}
|
return 'Default';
|
||||||
return $storage_areas;
|
|
||||||
}
|
}
|
||||||
|
return $this->{'Name'};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __call( $fn, array $args= NULL){
|
||||||
|
if(isset($this->{$fn})){
|
||||||
|
return $this->{$fn};
|
||||||
|
#array_unshift($args, $this);
|
||||||
|
#call_user_func_array( $this->{$fn}, $args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static function find_all() {
|
||||||
|
$storage_areas = array();
|
||||||
|
$result = dbQuery( 'SELECT * FROM Storage ORDER BY Name');
|
||||||
|
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Storage' );
|
||||||
|
foreach ( $results as $row => $obj ) {
|
||||||
|
$storage_areas[] = $obj;
|
||||||
|
}
|
||||||
|
return $storage_areas;
|
||||||
|
}
|
||||||
|
public function disk_usage_percent() {
|
||||||
|
$path = $this->Path();
|
||||||
|
$total = disk_total_space( $path );
|
||||||
|
if ( ! $total ) {
|
||||||
|
Error("disk_total_space returned false for " . $path );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
$free = disk_free_space( $path );
|
||||||
|
if ( ! $free ) {
|
||||||
|
Error("disk_free_space returned false for " . $path );
|
||||||
|
}
|
||||||
|
$usage = round(($total - $free) / $total * 100);
|
||||||
|
return $usage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
function changeScale() {
|
||||||
|
var scale = $('scale').get('value');
|
||||||
|
var img = $('frameImg');
|
||||||
|
if ( img ) {
|
||||||
|
var baseWidth = $('base_width').value;
|
||||||
|
var baseHeight = $('base_height').value;
|
||||||
|
var newWidth = ( baseWidth * scale ) / SCALE_BASE;
|
||||||
|
var newHeight = ( baseHeight * scale ) / SCALE_BASE;
|
||||||
|
|
||||||
|
img.style.width = newWidth + "px";
|
||||||
|
img.style.height = newHeight + "px";
|
||||||
|
}
|
||||||
|
Cookie.write( 'zmWatchScale', scale, { duration: 10*365 } );
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
var SCALE_BASE = <?php echo SCALE_BASE ?>;
|
Loading…
Reference in New Issue