diff --git a/rock.php b/rock.php
index b64e2cc..0c5cf45 100644
--- a/rock.php
+++ b/rock.php
@@ -24,7 +24,7 @@
*/
class Rock {
private static $_controller;
-
+
/**
* Start application
*
@@ -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);
@@ -82,11 +82,11 @@ public static function start() {
$obj->setInPlugin($isInPlugin);
$obj->exec();
}
-
+
public static function setController($controller) {
self::$_controller = $controller;
- }
-
+ }
+
/**
* get current running controller object
*
@@ -94,7 +94,7 @@ public static function setController($controller) {
*/
public static function controller() {
return self::$_controller;
- }
+ }
}
/**
@@ -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
*
@@ -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
*
@@ -141,7 +141,7 @@ public function root() {
public function setPath($path) {
$this->_path = $path;
}
-
+
/**
* Set controller name
*
@@ -150,7 +150,7 @@ public function setPath($path) {
public function setName($name) {
$this->_name = $name;
}
-
+
/**
* Get controller name
*
@@ -159,7 +159,7 @@ public function setName($name) {
public function name() {
return $this->_name;
}
-
+
/**
* Set if the controller is in a plugin
*
@@ -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);
@@ -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
*
@@ -240,7 +240,7 @@ public function display($action = null) {
*
*/
class RModel {
-
+
}
/**
@@ -253,13 +253,13 @@ class RView {
*
*/
public function display() {
-
+
}
}
/**
* print data to screen
- *
+ *
* @param mixed $data1 data to be printed
*/
function p($data1 = null) {
@@ -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
@@ -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];
}
@@ -352,7 +352,7 @@ function xi($name) {
/**
* import a class file
- *
+ *
* @param string $class full class name
* @param boolean $isClass if file is class
*/
@@ -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();
@@ -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
@@ -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);
@@ -419,7 +419,7 @@ function o($config) {
$filename = array_shift($pieces);
$file = __ROOT__ . "/configs/" . $filename . "@" . __PLATFORM__ . ".php";
}
-
+
$options = $pieces;
$ret = require($file);
@@ -433,7 +433,7 @@ function o($config) {
return null;
}
$ret = rock_array_get($ret, $options);
-
+
$GLOBALS["ROCK_CONFIGS"][$config] = $ret;
return $ret;
}
@@ -443,7 +443,7 @@ function o($config) {
*
* Example:
* load_xml_config --> loadXmlConfig
- *
+ *
* @param string $name name to be converted
* @return string
*/
@@ -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;
@@ -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;
}
@@ -533,17 +533,17 @@ function rock_array_set(array $array, $keys, $value) {
/**
* pick values from an array, the make it as keys
- *
+ *
*
* $array = array(
* array("a" => 11, "b" => 12),
* array("a" => 21, "b" => 22)
* //...
* );
- *
+ *
* $array2 = rock_array_combine($array, "a", "b");
*
- *
+ *
* then $array2 will be:
*
* array(
@@ -551,20 +551,20 @@ function rock_array_set(array $array, $keys, $value) {
* 21 => 22
* );
*
- *
+ *
* if $valueName not be set, the element value be "value":
- *
+ *
*
* $array2 = rock_array_combine($array, "a");
- *
+ *
* array(
* 11 => array("a" => 11, "b" => 12),
* 21 => array("a" => 21, "b" => 22)
* );
*
- *
+ *
* 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
@@ -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)) {
@@ -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) {