Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Fix failing style tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Jun 13, 2014
1 parent 6d3a4b1 commit d841910
Show file tree
Hide file tree
Showing 83 changed files with 385 additions and 395 deletions.
71 changes: 35 additions & 36 deletions core/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
/** Web Api Controller */
class ApiController extends REST_Controller
{

private $httpSuccessCode = array(
'index' => 200, // 200 OK
'get' => 200,
Expand Down Expand Up @@ -73,7 +72,7 @@ protected function _exceptionHandler(Exception $e)
default:
$httpCode = 400; // 400 Bad Request
}
return array($errorInfo, $httpCode);
return array($errorInfo, $httpCode);
}

/**
Expand Down Expand Up @@ -104,49 +103,49 @@ protected function _exceptionHandler(Exception $e)
* for given url: {base_path}/rest/item/duplicate/2, Midas will call
* 'itemDuplicate' in ApiComponent (in core module) to do the api;
*/

protected function _genericAction($args, $resource, $restAction, $apiFunctions, $moduleName = null)
{
$ApiComponent = MidasLoader::loadComponent('Api'.$resource, $moduleName);
$httpCode = $this->httpSuccessCode[strtolower($restAction)];
$calledFunction = $apiFunctions['default'];
$apiResults = array();
try
$ApiComponent = MidasLoader::loadComponent('Api'.$resource, $moduleName);
$httpCode = $this->httpSuccessCode[strtolower($restAction)];
$calledFunction = $apiFunctions['default'];
$apiResults = array();
try
{
$userDao = $this->_getUser($args);
if(isset($args['method']))
{
$userDao = $this->_getUser($args);
if(isset($args['method']))
$method = strtolower($args['method']);
if(array_key_exists($method, $apiFunctions))
{
$method = strtolower($args['method']);
if(array_key_exists($method, $apiFunctions))
{
$calledFunction = $apiFunctions[$method];
}
else
{
throw new Exception('Server error. Operation ' . $args['method'] . ' is not supported.', -100);
}
}
if(method_exists($ApiComponent, $calledFunction . 'Wrapper')) {
$calledFunction = $calledFunction . 'Wrapper';
}
$resultsArray = $ApiComponent->$calledFunction($args, $userDao);
if(isset($resultsArray))
{
$apiResults['data'] = $resultsArray;
$calledFunction = $apiFunctions[$method];
}
else // if the api function doesn't provide an return value
else
{
$apiResults['msg'] = "succeed!"; // there is no exception if code reaches here
throw new Exception('Server error. Operation ' . $args['method'] . ' is not supported.', -100);
}
}
catch(Exception $e)
if(method_exists($ApiComponent, $calledFunction . 'Wrapper'))
{
list($apiResults['error'], $httpCode) = $this->_exceptionHandler($e);
$calledFunction = $calledFunction . 'Wrapper';
}
$this->_response->setHttpResponseCode($httpCode);
// only the data assigned to '$this->view->apiresults' will be serilized
// in requested format (json, xml, etc) and filled in response body
$this->view->apiresults = $apiResults;
$resultsArray = $ApiComponent->$calledFunction($args, $userDao);
if(isset($resultsArray))
{
$apiResults['data'] = $resultsArray;
}
else // if the api function doesn't provide an return value
{
$apiResults['msg'] = "succeed!"; // there is no exception if code reaches here
}
}
catch(Exception $e)
{
list($apiResults['error'], $httpCode) = $this->_exceptionHandler($e);
}
$this->_response->setHttpResponseCode($httpCode);
// only the data assigned to '$this->view->apiresults' will be serilized
// in requested format (json, xml, etc) and filled in response body
$this->view->apiresults = $apiResults;
}

/**
Expand Down Expand Up @@ -215,4 +214,4 @@ public function optionsAction()
{
$this->_response->setHeader('Allow', 'OPTIONS');
}
} // end class
}
22 changes: 5 additions & 17 deletions library/KWUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
?>
<?php

/**
* globally useful utility functions.
*/
class KWUtils
{

{
CONST DEFAULT_MKDIR_MODE = 0775;

/**
Expand Down Expand Up @@ -83,7 +81,6 @@ public static function isWindows()
return (strtolower(substr(PHP_OS, 0, 3)) == "win");
}


/**
* @method escapeCommand
* will escape a command respecting the format of the current platform
Expand Down Expand Up @@ -130,7 +127,7 @@ public static function exec($command, &$output = null, $chdir = '', &$return_val
{
if(!getcwd())
{
throw new Exception ('getcwd failed');
throw new Exception('getcwd failed');
}
$currCwd = getcwd();

Expand Down Expand Up @@ -158,7 +155,6 @@ public static function exec($command, &$output = null, $chdir = '', &$return_val
}
}


/**
* @method isLinux()
* @return True if the current platform is Linux
Expand All @@ -168,8 +164,6 @@ public static function isLinux()
return (strtolower(substr(PHP_OS, 0, 5)) == "linux");
}



/**
* @method prepareExecCommand
* will prepare an executable application and params for command line
Expand Down Expand Up @@ -199,7 +193,6 @@ public static function prepareExecCommand($app_name, $params = array())
return escapeshellarg($app_name).' '.implode(' ', $escapedParams);
}


/**
* @method isExecutable will return true if the app can be found and is
* executable, can optionally look in the path.
Expand Down Expand Up @@ -239,7 +232,7 @@ public static function isExecutable($app_name, $check_in_path = false)
* can't be found, or if $check_execution_flag is set and the app is not
* executable.
*/
public static function findApp($app_name, $check_execution_flag )
public static function findApp($app_name, $check_execution_flag)
{
$PHP_PATH_SEPARATOR = ":";
// split path
Expand Down Expand Up @@ -274,9 +267,6 @@ public static function findApp($app_name, $check_execution_flag )
return $path_to_app;
}




/**
* @method formatAppName
* Format the application name according to the platform.
Expand All @@ -290,7 +280,6 @@ public static function formatAppName($app_name)
return $app_name;
}


/**
* @method recursiveRemoveDirectory
* Helper function to recursively delete a directory
Expand Down Expand Up @@ -345,5 +334,4 @@ public static function recursiveRemoveDirectory($directorypath)
}
return true;
}

}
}
5 changes: 3 additions & 2 deletions modules/batchmake/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
limitations under the License.
=========================================================================*/

/** App controller for the batchmake module */
class Batchmake_AppController extends MIDAS_GlobalModule
{
public $moduleName='batchmake';
} // end class
public $moduleName = 'batchmake';
}
21 changes: 11 additions & 10 deletions modules/batchmake/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

require_once BASE_PATH . '/modules/api/library/APIEnabledNotification.php';

/** notification manager*/
/** Notification manager for the batchmake module */
class Batchmake_Notification extends ApiEnabled_Notification
{
public $moduleName = 'batchmake';
public $_components = array('Utility', 'Internationalization');
public $_moduleComponents=array('KWBatchmake','Api');
public $_moduleComponents = array('KWBatchmake', 'Api');

/** init notification process*/
/** init notification process */
public function init()
{
$this->enableWebAPI($this->moduleName);
Expand All @@ -36,10 +37,10 @@ public function init()
}//end init

/**
*@method getDashboard
*will generate information about this module to display on the Dashboard
*@return array with key being the module name, the value being an array
of configuration correctness values (0 or 1).
* @method getDashboard
* will generate information about this module to display on the Dashboard
* @return array with key being the module name, the value being an array
* of configuration correctness values (0 or 1).
*/
public function getDashboard()
{
Expand All @@ -48,9 +49,9 @@ public function getDashboard()
}

/**
*@method getLeftLink
* @method getLeftLink
* will generate a link for this module to be displayed in the main view.
*@return ['batchmake' => [ link to batchmake module, module icon image path]]
* @return ['batchmake' => [ link to batchmake module, module icon image path]]
*/
public function getLeftLink()
{
Expand All @@ -59,4 +60,4 @@ public function getLeftLink()
$moduleWebroot = $baseURL . '/' . MIDAS_BATCHMAKE_MODULE;
return array(ucfirst(MIDAS_BATCHMAKE_MODULE) => array($moduleWebroot . '/index', $baseURL . '/modules/batchmake/public/images/cmake.png'));
}
} // end class
}
3 changes: 2 additions & 1 deletion modules/cleanup/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
limitations under the License.
=========================================================================*/

/** App controller for the cleanup module */
class Cleanup_AppController extends MIDAS_GlobalModule
{
public $moduleName = 'cleanup';
} // end class
}
3 changes: 2 additions & 1 deletion modules/comments/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
limitations under the License.
=========================================================================*/

/** App controller for the comments module */
class Comments_AppController extends MIDAS_GlobalModule
{
public $moduleName = 'comments';
} // end class
}
4 changes: 2 additions & 2 deletions modules/communityagreement/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
*/
class Communityagreement_AppController extends MIDAS_GlobalModule
{
public $moduleName='communityagreement';
public $moduleName = 'communityagreement';

/**
* Communityagreement_Agreement Model
* @var Communityagreement_AgreementModelBase
*/
var $Communityagreement_Agreement;
} // end class
}
4 changes: 2 additions & 2 deletions modules/communityagreement/models/AppDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
*/
class Communityagreement_AppDao extends MIDAS_GlobalDao
{
public $moduleName='communityagreement';
} // end class
public $moduleName = 'communityagreement';
}
2 changes: 1 addition & 1 deletion modules/communityagreement/models/AppModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
*/
class Communityagreement_AppModel extends MIDASModel
{
public $moduleName='communityagreement';
public $moduleName = 'communityagreement';
}
5 changes: 3 additions & 2 deletions modules/dicomextractor/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
limitations under the License.
=========================================================================*/

/** App controller for the dicomextractor module */
class Dicomextractor_AppController extends MIDAS_GlobalModule
{
public $moduleName='dicomextractor';
} // end class
public $moduleName = 'dicomextractor';
}
10 changes: 5 additions & 5 deletions modules/dicomextractor/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
limitations under the License.
=========================================================================*/

/** Config controller for the dicomextractor controller */
class Dicomextractor_ConfigController extends Dicomextractor_AppController
{
public $_moduleForms = array('Config');
public $_components = array('Utility', 'Date');
public $_moduleForms = array('Config');
public $_components = array('Utility', 'Date');

/** index action*/
/** index action */
function indexAction()
{
$this->requireAdminPrivileges();
Expand Down Expand Up @@ -72,8 +73,7 @@ function indexAction()
$applicationConfig['global']['dcm2xml'] = $this->_getParam('dcm2xml');
$applicationConfig['global']['dcmj2pnm'] = $this->_getParam('dcmj2pnm');
$applicationConfig['global']['dcmftest'] = $this->_getParam('dcmftest');
$applicationConfig['global']['dcmdictpath'] =
$this->_getParam('dcmdictpath');
$applicationConfig['global']['dcmdictpath'] = $this->_getParam('dcmdictpath');
$this->Component->Utility->createInitFile(BASE_PATH."/core/configs/".$this->moduleName.".local.ini", $applicationConfig);
echo JsonComponent::encode(array(true, 'Changes saved'));
}
Expand Down
Loading

0 comments on commit d841910

Please sign in to comment.