CODE STYLE class.pmDashlet.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 12:55:53 -04:00
parent 7f1d0fad9c
commit 16b4ea4e2a

View File

@@ -4,7 +4,8 @@ require_once 'classes/interfaces/dashletInterface.php';
require_once 'classes/model/Dashlet.php';
require_once 'classes/model/DashletInstance.php';
class PMDashlet extends DashletInstance implements DashletInterface {
class PMDashlet extends DashletInstance implements DashletInterface
{
// Own properties
private $dashletInstance;
@@ -12,7 +13,9 @@ class PMDashlet extends DashletInstance implements DashletInterface {
// Interface functions
public static function getAdditionalFields($className) {
public static function getAdditionalFields ($className)
{
try {
if (! class_exists( $className )) {
self::setIncludePath();
@@ -21,15 +24,13 @@ class PMDashlet extends DashletInstance implements DashletInterface {
G::LoadClass( $className );
eval( "\$additionalFields = $className::getAdditionalFields(\$className);" );
return $additionalFields;
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function setup($dasInsUid) {
public function setup ($dasInsUid)
{
try {
$this->dashletInstance = $this->loadDashletInstance( $dasInsUid );
if (! isset( $this->dashletInstance['DAS_CLASS'] )) {
@@ -43,37 +44,41 @@ class PMDashlet extends DashletInstance implements DashletInterface {
}
$this->dashletObject = new $className();
$this->dashletObject->setup( $this->dashletInstance );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function render($width = 300) {
public function render ($width = 300)
{
try {
if (is_null( $this->dashletObject )) {
throw new Exception( 'Please call to the function "setup" before call the function "render".' );
}
$this->dashletObject->render( $width );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
// Getter and Setters
public function getDashletInstance() {
public function getDashletInstance ()
{
return $this->dashletInstance;
}
public function getDashletObject() {
public function getDashletObject ()
{
return $this->dashletObject;
}
// Own functions
public function getDashletsInstances($start = null, $limit = null) {
public function getDashletsInstances ($start = null, $limit = null)
{
try {
$dashletsInstances = array ();
$criteria = new Criteria( 'workflow' );
@@ -109,8 +114,7 @@ class PMDashlet extends DashletInstance implements DashletInterface {
try {
$user = $userInstance->load( $row['DAS_INS_OWNER_UID'] );
$row['DAS_INS_OWNER_TITLE'] = $user['USR_FIRSTNAME'] . ' ' . $user['USR_LASTNAME'];
}
catch (Exception $error) {
} catch (Exception $error) {
$this->remove( $row['DAS_INS_UID'] );
$row['DAS_INS_UID'] = '';
}
@@ -121,8 +125,7 @@ class PMDashlet extends DashletInstance implements DashletInterface {
try {
$department = $departmentInstance->load( $row['DAS_INS_OWNER_UID'] );
$row['DAS_INS_OWNER_TITLE'] = $department['DEPO_TITLE'];
}
catch (Exception $error) {
} catch (Exception $error) {
$this->remove( $row['DAS_INS_UID'] );
$row['DAS_INS_UID'] = '';
}
@@ -133,8 +136,7 @@ class PMDashlet extends DashletInstance implements DashletInterface {
try {
$group = $groupInstance->load( $row['DAS_INS_OWNER_UID'] );
$row['DAS_INS_OWNER_TITLE'] = $group['GRP_TITLE'];
}
catch (Exception $error) {
} catch (Exception $error) {
$this->remove( $row['DAS_INS_UID'] );
$row['DAS_INS_UID'] = '';
}
@@ -149,25 +151,25 @@ class PMDashlet extends DashletInstance implements DashletInterface {
$dataset->next();
}
return $dashletsInstances;
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function getDashletsInstancesQuantity() {
public function getDashletsInstancesQuantity ()
{
try {
$criteria = new Criteria( 'workflow' );
$criteria->addSelectColumn( '*' );
$criteria->addJoin( DashletInstancePeer::DAS_UID, DashletPeer::DAS_UID, Criteria::INNER_JOIN );
return DashletInstancePeer::doCount( $criteria );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function loadDashletInstance($dasInsUid) {
public function loadDashletInstance ($dasInsUid)
{
try {
$dashletInstance = $this->load( $dasInsUid );
//Load data from the serialized field
@@ -177,31 +179,31 @@ class PMDashlet extends DashletInstance implements DashletInterface {
$dashletFields = array ();
}
return array_merge( $dashletFields, $dashletInstance );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function saveDashletInstance($data) {
public function saveDashletInstance ($data)
{
try {
$this->createOrUpdate( $data );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function deleteDashletInstance($dasInsUid) {
public function deleteDashletInstance ($dasInsUid)
{
try {
$this->remove( $dasInsUid );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public function getDashletsInstancesForUser($userUid) {
public function getDashletsInstancesForUser ($userUid)
{
try {
$dashletsInstances = array ();
// Include required classes
@@ -317,13 +319,13 @@ class PMDashlet extends DashletInstance implements DashletInterface {
// Check for permission assigments
// ToDo: Next release
return array_values( $dashletsInstances );
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
public static function getXTemplate($className) {
public static function getXTemplate ($className)
{
try {
if (! class_exists( $className )) {
self::setIncludePath();
@@ -332,13 +334,13 @@ class PMDashlet extends DashletInstance implements DashletInterface {
G::LoadClass( $className );
eval( "\$additionalFields = $className::getXTemplate(\$className);" );
return $additionalFields;
}
catch (Exception $error) {
} catch (Exception $error) {
throw $error;
}
}
private static function setIncludePath() {
private static function setIncludePath ()
{
$oPluginRegistry = &PMPluginRegistry::getSingleton();
$pluginsDashlets = $oPluginRegistry->getDashlets();
foreach ($pluginsDashlets as $pluginDashlet) {