CODE STYLE

FILES:
gulliver/system/class.tree.php
workflow/engine/classes/class.memcached.php
workflow/engine/classes/class.net.php
workflow/engine/classes/entities/AppSolrQueue.php
workflow/engine/classes/entities/FacetInterfaceRequest.php
workflow/engine/classes/entities/FacetInterfaceResult.php
workflow/engine/classes/entities/FacetItem.php
workflow/engine/classes/entities/FacetResult.php
workflow/engine/classes/entities/SelectedFacetGroupItem.php
workflow/engine/classes/entities/SolrQueryResult.php
This commit is contained in:
jennylee
2012-10-22 16:35:54 -04:00
parent c2adddd9fc
commit dcf7b02979
10 changed files with 277 additions and 283 deletions

View File

@@ -54,7 +54,7 @@ class Tree extends Xml_Node
* *
* @return none * @return none
*/ */
function Tree ($xmlnode = null) public function Tree ($xmlnode = null)
{ {
if (! isset( $xmlnode )) { if (! isset( $xmlnode )) {
return; return;
@@ -87,7 +87,7 @@ class Tree extends Xml_Node
* @return object(Tree) $newNode * @return object(Tree) $newNode
*/ */
function &addChild ($name, $label, $attributes = array()) public function &addChild ($name, $label, $attributes = array())
{ {
$newNode = new Tree( new Xml_Node( $name, 'open', $label, $attributes ) ); $newNode = new Tree( new Xml_Node( $name, 'open', $label, $attributes ) );
$this->children[] = & $newNode; $this->children[] = & $newNode;
@@ -99,7 +99,7 @@ class Tree extends Xml_Node
* *
* @return string '<span>...</span>' * @return string '<span>...</span>'
*/ */
function printPlus () public function printPlus ()
{ {
$plus = 'none'; $plus = 'none';
$minus = 'none'; $minus = 'none';
@@ -121,7 +121,7 @@ class Tree extends Xml_Node
* *
* @return $this->value * @return $this->value
*/ */
function printLabel () public function printLabel ()
{ {
return $this->value; return $this->value;
} }
@@ -131,7 +131,7 @@ class Tree extends Xml_Node
* *
* @return string $html * @return string $html
*/ */
function printContent () public function printContent ()
{ {
$html = ''; $html = '';
$row = 0; $row = 0;
@@ -150,7 +150,7 @@ class Tree extends Xml_Node
* *
* @return $obj->printObject( array( 'node' => &$this ) ) * @return $obj->printObject( array( 'node' => &$this ) )
*/ */
function render () public function render ()
{ {
$obj = new objectTemplate( $this->template ); $obj = new objectTemplate( $this->template );
return $obj->printObject( array ('node' => &$this return $obj->printObject( array ('node' => &$this

View File

@@ -45,7 +45,7 @@ class PMmemcached
var $enabled = false; var $enabled = false;
var $supported = false; var $supported = false;
private static $instance = NULL; private static $instance = null;
public function __construct ($workspace) public function __construct ($workspace)
{ {
@@ -111,62 +111,71 @@ class PMmemcached
throw new Exception( "Deserializing is not allowed." ); throw new Exception( "Deserializing is not allowed." );
} }
function set ($key, $object, $timeout = 0) public function set ($key, $object, $timeout = 0)
{ {
if (! $this->connected) if (! $this->connected) {
return false; return false;
if ($this->class != 'filecache') }
if ($this->class != 'filecache') {
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout ); $this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout );
else } else {
$this->mem->set( $this->workspace . '_' . $key, $object ); $this->mem->set( $this->workspace . '_' . $key, $object );
} }
}
function get ($key) public function get ($key)
{ {
if (! $this->connected) if (! $this->connected) {
return false; return false;
}
return $this->mem->get( $this->workspace . '_' . $key ); return $this->mem->get( $this->workspace . '_' . $key );
} }
function add ($key, $value) public function add ($key, $value)
{ {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache')) {
return false; return false;
}
return $this->mem->add( $this->workspace . '_' . $key, $value ); return $this->mem->add( $this->workspace . '_' . $key, $value );
} }
function increment ($key, $value) public function increment ($key, $value)
{ {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache')) {
return false; return false;
}
return $this->mem->increment( $this->workspace . '_' . $key, $value ); return $this->mem->increment( $this->workspace . '_' . $key, $value );
} }
function delete ($key) public function delete ($key)
{ {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache')) {
return false; return false;
}
return $this->mem->delete( $this->workspace . '_' . $key ); return $this->mem->delete( $this->workspace . '_' . $key );
} }
function flush () public function flush ()
{ {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache')) {
return false; return false;
}
return $this->mem->flush(); return $this->mem->flush();
} }
function getStats () public function getStats ()
{ {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache')) {
return false; return false;
}
return $status = $this->mem->getStats(); return $status = $this->mem->getStats();
} }
function printDetails () public function printDetails ()
{ {
if ((! $this->connected) || ($this->class == 'filecache')) if ((! $this->connected) || ($this->class == 'filecache')) {
return false; return false;
}
$status = $this->mem->getStats(); $status = $this->mem->getStats();
echo "<table border='1'>"; echo "<table border='1'>";
echo "<tr><td>Memcache Server version:</td><td> " . $status["version"] . "</td></tr>"; echo "<tr><td>Memcache Server version:</td><td> " . $status["version"] . "</td></tr>";
@@ -195,6 +204,5 @@ class PMmemcached
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status["evictions"] . "</td></tr>"; echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status["evictions"] . "</td></tr>";
echo "</table>"; echo "</table>";
} }
} }

View File

@@ -31,7 +31,7 @@ class NET
* @param string $pHost * @param string $pHost
* @return void * @return void
*/ */
function __construct ($pHost) public function __construct ($pHost)
{ {
$this->errno = 0; $this->errno = 0;
$this->errstr = ""; $this->errstr = "";
@@ -56,7 +56,7 @@ class NET
* @param string $pHost * @param string $pHost
* @return void * @return void
*/ */
function resolv ($pHost) public function resolv ($pHost)
{ {
$aHost = explode( "\\", $pHost ); $aHost = explode( "\\", $pHost );
if (count( $aHost ) > 1) { if (count( $aHost ) > 1) {
@@ -75,7 +75,7 @@ class NET
} else { } else {
$ip = @gethostbyname( $ipHost ); $ip = @gethostbyname( $ipHost );
$long = ip2long( $ip ); $long = ip2long( $ip );
if ($long == - 1 || $long === FALSE) { if ($long == - 1 || $long === false) {
$this->errno = 2000; $this->errno = 2000;
$this->errstr = "NET::Host down"; $this->errstr = "NET::Host down";
$this->error = "Destination Host Unreachable"; $this->error = "Destination Host Unreachable";
@@ -92,7 +92,7 @@ class NET
* @param string $pPort * @param string $pPort
* @return true * @return true
*/ */
function scannPort ($pPort) public function scannPort ($pPort)
{ {
define( 'TIMEOUT', 5 ); define( 'TIMEOUT', 5 );
$hostip = @gethostbyname( $host ); // resloves IP from Hostname returns hostname on failure $hostip = @gethostbyname( $host ); // resloves IP from Hostname returns hostname on failure
@@ -114,7 +114,7 @@ class NET
* @param string $pHost * @param string $pHost
* @return true * @return true
*/ */
function is_ipaddress ($pHost) public function is_ipaddress ($pHost)
{ {
$key = true; $key = true;
#verifing if is a ip address #verifing if is a ip address
@@ -140,13 +140,14 @@ class NET
* @param string $pHost * @param string $pHost
* @return true * @return true
*/ */
function ping ($pTTL = 3000) public function ping ($pTTL = 3000)
{ {
$cmd = "ping -w $pTTL $this->ip"; $cmd = "ping -w $pTTL $this->ip";
$output = exec( $cmd, $a, $a1 ); $output = exec( $cmd, $a, $a1 );
$this->errstr = ""; $this->errstr = "";
for ($i = 0; $i < count( $a ); $i ++) for ($i = 0; $i < count( $a ); $i ++) {
$this->errstr += $a[$i]; $this->errstr += $a[$i];
}
$this->errno = $a1; $this->errno = $a1;
} }
@@ -157,7 +158,7 @@ class NET
* @param string $pPasswd * @param string $pPasswd
* @return void * @return void
*/ */
function loginDbServer ($pUser, $pPasswd) public function loginDbServer ($pUser, $pPasswd)
{ {
$this->db_user = $pUser; $this->db_user = $pUser;
$this->db_passwd = $pPasswd; $this->db_passwd = $pPasswd;
@@ -170,7 +171,7 @@ class NET
* @param string $pPort * @param string $pPort
* @return void * @return void
*/ */
function setDataBase ($pDb, $pPort = '') public function setDataBase ($pDb, $pPort = '')
{ {
$this->db_sourcename = $pDb; $this->db_sourcename = $pDb;
$this->db_port = $pPort; $this->db_port = $pPort;
@@ -182,7 +183,7 @@ class NET
* @param string $pDbDriver * @param string $pDbDriver
* @return void * @return void
*/ */
function tryConnectServer ($pDbDriver) public function tryConnectServer ($pDbDriver)
{ {
if ($this->errno != 0) { if ($this->errno != 0) {
return 0; return 0;
@@ -213,7 +214,6 @@ class NET
$this->errno = 10001; $this->errno = 10001;
} }
break; break;
case 'pgsql': case 'pgsql':
$this->db_port = ($this->db_port == "") ? "5432" : $this->db_port; $this->db_port = ($this->db_port == "") ? "5432" : $this->db_port;
$link = @pg_connect( "host='$this->ip' port='$this->db_port' user='$this->db_user' password='$this->db_passwd' dbname='$this->db_sourcename'" ); $link = @pg_connect( "host='$this->ip' port='$this->db_port' user='$this->db_user' password='$this->db_passwd' dbname='$this->db_sourcename'" );
@@ -227,7 +227,6 @@ class NET
$this->errno = 20001; $this->errno = 20001;
} }
break; break;
case 'mssql': case 'mssql':
if ($this->db_instance != "") { if ($this->db_instance != "") {
$str_port = ""; $str_port = "";
@@ -247,7 +246,6 @@ class NET
$this->errno = 30001; $this->errno = 30001;
} }
break; break;
case 'oracle': case 'oracle':
$this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "1521" : $this->db_port; $this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "1521" : $this->db_port;
try { try {
@@ -265,7 +263,6 @@ class NET
throw new Exception( "[erik] Couldn't connect to Oracle Server! - " . $e->getMessage() ); throw new Exception( "[erik] Couldn't connect to Oracle Server! - " . $e->getMessage() );
} }
break; break;
case 'informix': case 'informix':
break; break;
case 'sqlite': case 'sqlite':
@@ -284,7 +281,7 @@ class NET
* @param string $pDbDriver * @param string $pDbDriver
* @return void * @return void
*/ */
function tryOpenDataBase ($pDbDriver) public function tryOpenDataBase ($pDbDriver)
{ {
if ($this->errno != 0) { if ($this->errno != 0) {
return 0; return 0;
@@ -322,7 +319,6 @@ class NET
$this->errno = 10001; $this->errno = 10001;
} }
break; break;
case 'pgsql': case 'pgsql':
$this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "5432" : $this->db_port; $this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "5432" : $this->db_port;
$link = @pg_connect( "host='$this->ip' port='$this->db_port' user='$this->db_user' password='$this->db_passwd' dbname='$this->db_sourcename'" ); $link = @pg_connect( "host='$this->ip' port='$this->db_port' user='$this->db_user' password='$this->db_passwd' dbname='$this->db_sourcename'" );
@@ -342,7 +338,6 @@ class NET
$this->errno = 20001; $this->errno = 20001;
} }
break; break;
case 'mssql': case 'mssql':
// $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port; // $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port;
// $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); // $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd);
@@ -370,7 +365,6 @@ class NET
$this->errno = 30001; $this->errno = 30001;
} }
break; break;
case 'oracle': case 'oracle':
$this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "1521" : $this->db_port; $this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "1521" : $this->db_port;
$link = @oci_connect( $this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=$this->ip) (PORT=$this->db_port) )) (CONNECT_DATA=(SERVICE_NAME=$this->db_sourcename)))" ); $link = @oci_connect( $this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=$this->ip) (PORT=$this->db_port) )) (CONNECT_DATA=(SERVICE_NAME=$this->db_sourcename)))" );
@@ -393,10 +387,8 @@ class NET
$this->errno = 40001; $this->errno = 40001;
} }
break; break;
case 'informix': case 'informix':
break; break;
case 'sqlite': case 'sqlite':
break; break;
} }
@@ -412,15 +404,17 @@ class NET
* @param string $driver * @param string $driver
* @return void * @return void
*/ */
function getDbServerVersion ($driver) public function getDbServerVersion ($driver)
{ {
if (! isset( $this->ip )) if (! isset( $this->ip )) {
$this->ip = getenv( 'HTTP_CLIENT_IP' ); $this->ip = getenv( 'HTTP_CLIENT_IP' );
}
if (isset( $this->ip ) && isset( $this->db_user ) && isset( $this->db_passwd )) { if (isset( $this->ip ) && isset( $this->db_user ) && isset( $this->db_passwd )) {
try { try {
if (! isset( $this->db_sourcename )) if (! isset( $this->db_sourcename )) {
$this->db_sourcename = DB_NAME; $this->db_sourcename = DB_NAME;
}
$value = 'none'; $value = 'none';
$sDataBase = 'database_' . strtolower( DB_ADAPTER ); $sDataBase = 'database_' . strtolower( DB_ADAPTER );
if (G::LoadSystemExist( $sDataBase )) { if (G::LoadSystemExist( $sDataBase )) {
@@ -443,7 +437,7 @@ class NET
* @param string $pAdapter * @param string $pAdapter
* @return void * @return void
*/ */
function dbName ($pAdapter) public function dbName ($pAdapter)
{ {
switch ($pAdapter) { switch ($pAdapter) {
case 'mysql': case 'mysql':
@@ -473,7 +467,7 @@ class NET
* @param string $pAdapter * @param string $pAdapter
* @return void * @return void
*/ */
function showMsg () public function showMsg ()
{ {
if ($this->errno != 0) { if ($this->errno != 0) {
$msg = " $msg = "
@@ -497,7 +491,7 @@ class NET
* *
* @return string * @return string
*/ */
function getErrno () public function getErrno ()
{ {
return $this->errno; return $this->errno;
} }
@@ -508,11 +502,10 @@ class NET
* *
* @return string * @return string
*/ */
function getErrmsg () public function getErrmsg ()
{ {
return $this->errstr; return $this->errstr;
} }
} }
/** /**
@@ -523,8 +516,9 @@ class Stat
{ {
public $stutus; public $stutus;
function __construct () public function __construct ()
{ {
$this->status = false; $this->status = false;
} }
} }

View File

@@ -26,14 +26,12 @@ class Entity_AppSolrQueue extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ("appUid","appUpdated"
"appUid",
"appUpdated"
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }

View File

@@ -5,12 +5,14 @@ class Entity_FacetInterfaceRequest extends Entity_Base
{ {
public $searchText = ''; public $searchText = '';
public $selectedFacetsString = ''; // string of selected facet groups and public $selectedFacetsString = ''; // string of selected facet groups and
// items in format: // items in format:
// groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2, // groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2,
// groupkey3::groupdesc3:::itemkey3::itemdesc3 // groupkey3::groupdesc3:::itemkey3::itemdesc3
// var $selectedFacetFields = array(); // var $selectedFacetFields = array();
// var $selectedFacetTypes = array(); // var $selectedFacetTypes = array();
private function __construct () private function __construct ()
{ {
} }
@@ -27,14 +29,12 @@ class Entity_FacetInterfaceRequest extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ("searchText","selectedFacetsString"
"searchText",
"selectedFacetsString"
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }

View File

@@ -5,6 +5,7 @@ class Entity_FacetInterfaceResult extends Entity_Base
{ {
// array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text // array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text
public $aFacetGroup = array (); public $aFacetGroup = array ();
public $aSelectedFacetGroupItem = array (); public $aSelectedFacetGroupItem = array ();
public $sFilterText = ''; public $sFilterText = '';
@@ -25,15 +26,12 @@ class Entity_FacetInterfaceResult extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ("aFacetGroup","aSelectedFacetGroupItem","sFilterText"
"aFacetGroup",
"aSelectedFacetGroupItem",
"sFilterText"
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }

View File

@@ -5,6 +5,7 @@ require_once ('Base.php');
* *
* *
* *
*
* Entity Face item, represent an option in a facet group * Entity Face item, represent an option in a facet group
* *
* @author dev-HebertSaak * @author dev-HebertSaak
@@ -16,8 +17,10 @@ class Entity_FacetItem extends Entity_Base
public $facetPrintName = ''; public $facetPrintName = '';
public $facetCount = ''; public $facetCount = '';
public $facetSelectCondition = ''; // selected condition used to select public $facetSelectCondition = ''; // selected condition used to select
// this facet // this facet
private function __construct () private function __construct ()
{ {
} }
@@ -34,14 +37,12 @@ class Entity_FacetItem extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ("facetName","facetCount"
"facetName",
"facetCount"
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }

View File

@@ -23,15 +23,12 @@ class Entity_FacetResult extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ("aFacetGroups","aSelectedFacetGroups","sFilterText"
"aFacetGroups",
"aSelectedFacetGroups",
"sFilterText"
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }

View File

@@ -8,9 +8,11 @@ class Entity_SelectedFacetGroupItem extends Entity_Base
public $selectedFacetItemName = ''; public $selectedFacetItemName = '';
public $selectedFacetItemPrintName = ''; public $selectedFacetItemPrintName = '';
public $selectedFacetRemoveCondition = ''; // remove condition, string of public $selectedFacetRemoveCondition = ''; // remove condition, string of
// selected facets without this // selected facets without this
// facet // facet
private function __construct () private function __construct ()
{ {
} }
@@ -27,14 +29,12 @@ class Entity_SelectedFacetGroupItem extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ("selectedFacetGroupName","selectedFacetItemName"
"selectedFacetGroupName",
"selectedFacetItemName"
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }

View File

@@ -7,8 +7,10 @@ class Entity_SolrQueryResult extends Entity_Base
public $iTotalRecords = 0; public $iTotalRecords = 0;
public $iTotalDisplayRecords = 10; public $iTotalDisplayRecords = 10;
public $aaData = array (); // array of arrays of records to public $aaData = array (); // array of arrays of records to
// display // display
private function __construct () private function __construct ()
{ {
} }
@@ -25,16 +27,12 @@ class Entity_SolrQueryResult extends Entity_Base
$obj->initializeObject( $data ); $obj->initializeObject( $data );
$requiredFields = array ( $requiredFields = array ('sEcho','iTotalRecords','iTotalDisplayRecords','aaData'
'sEcho',
'iTotalRecords',
'iTotalDisplayRecords',
'aaData'
); );
$obj->validateRequiredFields( $requiredFields ); $obj->validateRequiredFields( $requiredFields );
return $obj; return $obj;
} }
} }