Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
remove trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
iwind committed Jun 5, 2014
1 parent c3d957b commit 8033588
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions rock.php
Expand Up @@ -24,7 +24,7 @@
*/
class Rock {
private static $_controller;

/**
* Start application
*
Expand Down Expand Up @@ -73,7 +73,7 @@ public static function start() {
if (!($obj instanceof RController)) {
trigger_error("controller class '{$class}' must be a subclass of RController", E_USER_ERROR);
}

define("__ACTION__", $action);
$obj->setRoot($mainRoot);
$obj->setAction($action);
Expand All @@ -82,19 +82,19 @@ public static function start() {
$obj->setInPlugin($isInPlugin);
$obj->exec();
}

public static function setController($controller) {
self::$_controller = $controller;
}
}

/**
* get current running controller object
*
* @return RController
*/
public static function controller() {
return self::$_controller;
}
}
}

/**
Expand All @@ -106,16 +106,16 @@ class RController {
private $_path;
private $_name;
private $_inPlugin = false;

/**
* set current action name
* set current action name
*
* @param string $action action name
*/
public function setAction($action) {
$this->_action = $action;
}

/**
* Get action name
*
Expand All @@ -124,15 +124,15 @@ public function setAction($action) {
public function action() {
return $this->_action;
}

public function setRoot($root) {
$this->_root = $root;
}

public function root() {
return $this->_root;
}
}

/**
* Set controller file path
*
Expand All @@ -141,7 +141,7 @@ public function root() {
public function setPath($path) {
$this->_path = $path;
}

/**
* Set controller name
*
Expand All @@ -150,7 +150,7 @@ public function setPath($path) {
public function setName($name) {
$this->_name = $name;
}

/**
* Get controller name
*
Expand All @@ -159,7 +159,7 @@ public function setName($name) {
public function name() {
return $this->_name;
}

/**
* Set if the controller is in a plugin
*
Expand All @@ -168,35 +168,35 @@ public function name() {
public function setInPlugin($isInPlugin) {
$this->_inPlugin = $isInPlugin;
}

/**
* Call before actions
*
*/
public function onBefore() {

}

/**
* Call after actions
*
*/
public function onAfter() {

}

/**
* Execute action
*
*/
public function exec() {
Rock::setController($this);

if (class_exists("RPlugin")) {
RPlugin::callBefore();
}
$this->onBefore();

$method = "do" . $this->_action;
if (!method_exists($this, $method)) {
trigger_error("can not find action '{$this->_action}' in class '" . get_class($this) . "'", E_USER_ERROR);
Expand All @@ -205,13 +205,13 @@ public function exec() {
if (is_object($ret) && ($ret instanceof RView)) {
$ret->display();
}

$this->onAfter();
if (class_exists("RPlugin")) {
RPlugin::callAfter();
}
}

/**
* Display View
*
Expand Down Expand Up @@ -240,7 +240,7 @@ public function display($action = null) {
*
*/
class RModel {

}

/**
Expand All @@ -253,13 +253,13 @@ class RView {
*
*/
public function display() {

}
}

/**
* print data to screen
*
*
* @param mixed $data1 data to be printed
*/
function p($data1 = null) {
Expand Down Expand Up @@ -318,7 +318,7 @@ function rock_filter_param($param, $filter = true) {

/**
* get parameter value
*
*
* different from x($name), the value will not be filtered (trim or htmlspecialchars)
*
* @param string $name parameter name
Expand All @@ -329,7 +329,7 @@ function xn($name = nil) {
if ($name == nil) {
return array_merge(rock_filter_param($GLOBALS["ROCK_HTTP_VARS"], false), $GLOBALS["ROCK_USER_VARS"]);
}

if (array_key_exists($name, $GLOBALS["ROCK_USER_VARS"])) {
return $GLOBALS["ROCK_USER_VARS"][$name];
}
Expand All @@ -352,7 +352,7 @@ function xi($name) {

/**
* import a class file
*
*
* @param string $class full class name
* @param boolean $isClass if file is class
*/
Expand All @@ -361,7 +361,7 @@ function import($class, $isClass = true) {
if ($isClass && class_exists($className, false)) {
return $className;
}

$file = null;
if (strstr($class, "@")) {
$trace = debug_backtrace();
Expand All @@ -385,9 +385,9 @@ function import($class, $isClass = true) {

/**
* get configuration value
*
*
* support __PLATFORM__
*
*
* o("config.name") - find in app/configs/config.php directory
* o("@.config") - find config.php in current directory
* o("@.config.servers") - find config.php in current directory
Expand All @@ -399,7 +399,7 @@ function o($config) {
if (isset($GLOBALS["ROCK_CONFIGS"][$config])) {
return $GLOBALS["ROCK_CONFIGS"][$config];
}

$file = null;
$option = null;
$pieces = explode(".", $config);
Expand All @@ -419,7 +419,7 @@ function o($config) {
$filename = array_shift($pieces);
$file = __ROOT__ . "/configs/" . $filename . "@" . __PLATFORM__ . ".php";
}

$options = $pieces;
$ret = require($file);

Expand All @@ -433,7 +433,7 @@ function o($config) {
return null;
}
$ret = rock_array_get($ret, $options);

$GLOBALS["ROCK_CONFIGS"][$config] = $ret;
return $ret;
}
Expand All @@ -443,7 +443,7 @@ function o($config) {
*
* Example:<br/>
* load_xml_config --> loadXmlConfig
*
*
* @param string $name name to be converted
* @return string
*/
Expand All @@ -459,7 +459,7 @@ function rock_name_to_java($name) {
* @param array|string $keys key or keys, can be a.b.c
* @return mixed
* @see rock_array_set
*/
*/
function rock_array_get(array $array, $keys) {
if (is_array($keys) && empty($keys)) {
return $array;
Expand Down Expand Up @@ -487,7 +487,7 @@ function rock_array_get(array $array, $keys) {
return null;
}
}

return (is_array($lastArray) && array_key_exists($lastKey, $lastArray))? $lastArray[$lastKey] : null;
}

Expand Down Expand Up @@ -533,38 +533,38 @@ function rock_array_set(array $array, $keys, $value) {

/**
* pick values from an array, the make it as keys
*
*
* <code>
* $array = array(
* array("a" => 11, "b" => 12),
* array("a" => 21, "b" => 22)
* //...
* );
*
*
* $array2 = rock_array_combine($array, "a", "b");
* </code>
*
*
* then $array2 will be:
* <code>
* array(
* 11 => 12,
* 21 => 22
* );
* </code>
*
*
* if $valueName not be set, the element value be "value":
*
*
* <code>
* $array2 = rock_array_combine($array, "a");
*
*
* array(
* 11 => array("a" => 11, "b" => 12),
* 21 => array("a" => 21, "b" => 22)
* );
* </code>
*
*
* support dot (.) operator in keyName and valueName:
* - rock_array_combine($array, "a.b", "a.c");
* - rock_array_combine($array, "a.b", "a.c");
* $array[n][a][b] will be "key",$array[n][a][c] value be"value", here, n is index
*
* @param array $array array values to combine from
Expand Down Expand Up @@ -616,7 +616,7 @@ function rock_lang($code) {
}
$GLOBALS["ROCK_LANGS"] = array_merge($message, $GLOBALS["ROCK_LANGS"]);
}

$args = func_get_args();
unset($args[0]);
if (empty($args)) {
Expand All @@ -634,7 +634,7 @@ function rock_check_version() {
if (!isset($MONGO["servers"][0]["host"])) {
return;
}

//version 1.0.x
foreach ($MONGO["servers"] as $index => $server) {
foreach($server as $param => $value) {
Expand Down

0 comments on commit 8033588

Please sign in to comment.