From 7fe908c50c8dbc5cc05f571dbe11d66141caacd4 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Thu, 14 Nov 2013 09:01:22 -0500 Subject: [PATCH] Cleaning up code to match coding guidelines --- server/lib/classes/aps_base.inc.php | 120 ++++++++++++++++++++++++++++++++---------------------------- 1 files changed, 64 insertions(+), 56 deletions(-) diff --git a/server/lib/classes/aps_base.inc.php b/server/lib/classes/aps_base.inc.php index 4c1512b..c4aaf52 100644 --- a/server/lib/classes/aps_base.inc.php +++ b/server/lib/classes/aps_base.inc.php @@ -43,61 +43,69 @@ class ApsBase { - protected $log_prefix = ''; - protected $fetch_url = ''; - protected $aps_version = ''; - protected $packages_dir = ''; - protected $temp_pkg_dir = ''; - protected $interface_pkg_dir = ''; - protected $interface_mode = false; // server mode by default + protected $log_prefix = ''; + protected $fetch_url = ''; + protected $aps_version = ''; + protected $packages_dir = ''; + protected $temp_pkg_dir = ''; + protected $interface_pkg_dir = ''; + protected $interface_mode = false; // server mode by default - /** - * Constructor - * - * @param $app the application instance (db handle + log method) - * @param $interface_mode act in interface (true) or server mode (false) - * @param $log_prefix a prefix to set before all log entries - */ - public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false) - { - $this->log_prefix = $log_prefix; - $this->interface_mode = $interface_mode; - $this->fetch_url = 'apscatalog.com'; - $this->aps_version = '1'; - $this->packages_dir = ISPC_ROOT_PATH.'/aps_packages'; - $this->interface_pkg_dir = ISPC_ROOT_PATH.'/web/sites/aps_meta_packages'; - } - - /** - * Converts a given value to it's native representation in 1024 units - * - * @param $value the size to convert - * @return integer and string - */ - public function convertSize($value) - { - $unit = array('Bytes', 'KB', 'MB', 'GB', 'TB'); - return @round($value/pow(1024, ($i = floor(log($value, 1024)))), 2).' '.$unit[$i]; - } - - /** - * Determine a specific xpath from a given SimpleXMLElement handle. If the - * element is found, it's string representation is returned. If not, - * the return value will stay empty - * - * @param $xml_handle the SimpleXMLElement handle - * @param $query the XPath query - * @param $array define whether to return an array or a string - * @return $ret the return string - */ - protected function getXPathValue($xml_handle, $query, $array = false) - { - $ret = ''; - - $xp_result = @($xml_handle->xpath($query)) ? $xml_handle->xpath($query) : false; - if($xp_result !== false) $ret = (($array === false) ? (string)$xp_result[0] : $xp_result); - - return $ret; - } + /** + * Constructor + * + * @param $app the application instance (db handle + log method) + * @param $interface_mode act in interface (true) or server mode (false) + * @param $log_prefix a prefix to set before all log entries + */ + + + public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false) + { + $this->log_prefix = $log_prefix; + $this->interface_mode = $interface_mode; + $this->fetch_url = 'apscatalog.com'; + $this->aps_version = '1'; + $this->packages_dir = ISPC_ROOT_PATH.'/aps_packages'; + $this->interface_pkg_dir = ISPC_ROOT_PATH.'/web/sites/aps_meta_packages'; + } + + + + /** + * Converts a given value to it's native representation in 1024 units + * + * @param $value the size to convert + * @return integer and string + */ + public function convertSize($value) + { + $unit = array('Bytes', 'KB', 'MB', 'GB', 'TB'); + return @round($value/pow(1024, ($i = floor(log($value, 1024)))), 2).' '.$unit[$i]; + } + + + + /** + * Determine a specific xpath from a given SimpleXMLElement handle. If the + * element is found, it's string representation is returned. If not, + * the return value will stay empty + * + * @param $xml_handle the SimpleXMLElement handle + * @param $query the XPath query + * @param $array define whether to return an array or a string + * @return $ret the return string + */ + protected function getXPathValue($xml_handle, $query, $array = false) + { + $ret = ''; + + $xp_result = @($xml_handle->xpath($query)) ? $xml_handle->xpath($query) : false; + if($xp_result !== false) $ret = (($array === false) ? (string)$xp_result[0] : $xp_result); + + return $ret; + } + } -?> \ No newline at end of file + +?> -- Gitblit v1.9.1