예제 #1
0
	function doIndex() {
		$modules = array();
		reset($GLOBALS['CFG_RPC']->MODULES);
		while (list($moduleKey,$moduleCfg) = each($GLOBALS['CFG_RPC']->MODULES)) {
			try {
				$clazz = new ReflectionClass($moduleCfg->NAME);
				$module["name"] = $moduleCfg->NAME;
				while (list(,$methodCfg) = each($moduleCfg->METHODS)) {
					$methodRef = $clazz->getMethod($methodCfg);
					$parameterCfgs = $methodRef->getParameters();
					$parameters = array();
					$args = array();
					while(list(,$param) = each($parameterCfgs)) {
						$parameters[] = $param->getName();
						$args[] = "'ps[]=' + ".$param->getName();
					}
					$parameters[] = '__callback';
	
					$method = array();
					$method["name"] = $methodCfg;
					$method["parameters"] = implode(', ', $parameters);
					$method["args"] = implode(" + '&' + ", $args);
	
					$module["methods"][] = $method;
				}
				$modules[] = $module;
			} catch (Exception $e) {
				continue;
			}
		}
		$this->modules = $modules;
		header('Content-type: text/plain');
		Apu::dispatch("/faces/rpc.php");
		exit;
	}
예제 #2
0
	function validate(&$action) {
		Apu::dispatch($action->validation);
		if (!empty($GLOBALS["VALIDATION"])) {
			reset($GLOBALS["VALIDATION"]);
			while (list($method, $methodValidations) = each($GLOBALS["VALIDATION"])) {
				if ($method == "-" || $method == $action->method) {
					reset($methodValidations);
					while (list($field, $fieldValidations) = each($methodValidations)) {
						$fieldValue = $action->get($field);
						while (list($i, $val) = each($fieldValidations)) {
							$function = $val["validate"];
							$not = false;
							if (substr($val["validate"], 0, 1) == "!") {
								$function = trim($function, "!");
								$not = true;
							}
							$validate = Bean::invoke("Validation", $function, array(&$action, $val, $field, $not));
							if ($not) {
								$validate = !$validate;
							}
							if (!$validate) {
								$defaultMessage = $GLOBALS["CFG_VALIDATION"]->MSG[$val["validate"]];
								$action->addMsgMessage($defaultMessage, $field);
							}
						}
					}
				}
			}
		}
	}
예제 #3
0
파일: apu.php 프로젝트: reekoheek/php-fw
	function listen() {
		$pathInfo = Apu::fetchPath();
		$className = String::camelize("_".$pathInfo["class"]."_action");
		reset($GLOBALS["CFG_ACTION"]->NS);
		foreach ($GLOBALS["CFG_ACTION"]->NS as $ns) {
			Apu::import($ns.'/'.$className.".php");
		}
		$action = new $className($pathInfo["method"]);
		$action->listen();
	}
예제 #4
0
	function doIndex() {
		reset($GLOBALS["MENU"]);
		$menus = array();
		while (list($id, $menu) = each($GLOBALS["MENU"])) {
			$menu["name"] = $id;
			MenuAction::insertMenu($menus, ltrim($id, 'menu.'), $menu);
			
		}
		$_REQUEST["menu"] = $menus;
		$date = new Date();
		$_REQUEST["date"] = $date->__toString();
		Apu::dispatch("/todo/faces/menu/menu.php");
	}
예제 #5
0
파일: Msg.php 프로젝트: reekoheek/php-fw
	function init() {
		$lang = Locale::lang();
		if ($GLOBALS["CFG_APU"]->DEBUG) {
			Session::remove(MSG_SCOPE, "lang");
		}
		if (Session::load(MSG_SCOPE, "lang") != $lang) {
			reset($GLOBALS["CFG_MSG"]->NS);
			while (list(,$value) = each($GLOBALS["CFG_MSG"]->NS)) {
				try { Apu::dispatch($value.".php"); } catch (Exception $e) {}
				try { Apu::dispatch($value.'_'.strtolower($lang).".php"); } catch (Exception $e) {}
			}
			Session::save(MSG_SCOPE, $lang, "lang");			
			//Session::save(MSG_SCOPE, $GLOBALS[MSG_SCOPE], "msgList");
		}
	}
예제 #6
0
<?php
Apu::import("/action/Action.php");

class JsonAction extends Action {
	var $json;
	
	function post() {
		echo JSON::encode($this->json);	
	}
}
?>
예제 #7
0
	function back($name, $url) {
		$value = Msg::get($name);
		return "<input type=\"button\" class=\"Button\" id=\"$name\" name=\"$name\" value=\"$value\" onclick=\"window.location.href = '".Apu::base()."/$url'\"/>\n";
	}
예제 #8
0
<? Apu::import("/tag/FormTag.php") ?>
<script type="text/javascript" src="themes/prototype.js"></script>
<script type="text/javascript" src="themes/apu.js"></script>
<script type="text/javascript" src="<?=Apu::theme()?>/init.js"></script>

<style>
@IMPORT url("<?=Apu::theme()?>/main.css");
@IMPORT url("<?=Apu::theme()?>/application.css");
</style>

<div class="Frame">
	<div class="Title"><?=Msg::get("LookupAction.view.title")?></div>
	<div class="Message"><?=Msg::message("LookupAction.view.description")?></div>
	<div>
		<table class="Form">
			<tr>
				<td><?=Msg::get("lookup.type")?></td>
				<td>:</td>
				<td><?=nl2br($this->lookup["type"])?></td>
			</tr>
			<tr>
				<td><?=Msg::get("lookup.code")?></td>
				<td>:</td>
				<td><?=nl2br($this->lookup["code"])?></td>
			</tr>
			<tr>
				<td><?=Msg::get("lookup.name")?></td>
				<td>:</td>
				<td><?=nl2br($this->lookup["name"])?></td>
			</tr>
			<tr>
예제 #9
0
<?php
Apu::import("/dao/BaseDao.php");

class UserDao extends BaseDao {
	
}
?>
예제 #10
0
파일: Insert.php 프로젝트: reekoheek/php-fw
<?php
Apu::import("/db/DB.php");
Apu::import("/db/MysqlDriver.php");
Apu::import("/db/Exp.php");
Apu::import("/db/Query.php");

class Insert extends Query {
	var $value;

	function __construct($table, $value, $schema = "DEFAULT") {
		parent::__construct($table, $schema);
		$this->value = $value;
	}

	function valueString() {
		reset($this->meta);
		$values = array();
		while(list(,$meta) = each($this->meta)) {
			$value = Bean::get($this->value, String::camelize($meta["name"]));
			$values[] = $this->escape($value, $meta["name"]);
		}
		return implode(', ', $values);
	}
	function sql() {
		$sql = sprintf("insert into %s(%s) values(%s)", $this->tableString(), $this->fieldString(), $this->valueString());
		return $sql;
	}
}
?>
예제 #11
0
파일: index.php 프로젝트: reekoheek/php-fw
<?php
$__time = microtime(true);
require_once("apu/apu.php");
Apu::listen();
//echo "<pre>";
//debug_r($_SERVER['REQUEST_URI'], false);
//echo "\n\n";
//debug_r($_REQUEST);
//echo "</pre>";
echo sprintf("%01.20f", microtime(true) - $__time);
?>
예제 #12
0
파일: DB.php 프로젝트: reekoheek/php-fw
<?php
Apu::import("/db/Insert.php");
Apu::import("/db/Update.php");
Apu::import("/db/Delete.php");
Apu::import("/log/Log.php");
Apu::import("/common/Date.php");

define("DB_SCOPE", "DB");

class DB extends BaseClass {
	function connect($schema = "DEFAULT") {
		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "connect", array($schema));
		return $result;
	}

	function query($query, $schema = "DEFAULT") {
		if ($query instanceof Query) {
			Log::debug($query->sql(), __FILE__, __LINE__);
		} else {
			Log::debug($query, __FILE__, __LINE__);
		}
		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "query", array($query, $schema));
		return $result;
	}

	function unique($query, $schema = "DEFAULT") {
		if ($query instanceof Query) {
			Log::debug($query->sql(), __FILE__, __LINE__);
		} else {
예제 #13
0
	function doLogout() {
		$this->addMsgMessage("message.alreadyLogout");
		Session::destroy();
		Msg::save($this->messages);
		Apu::redirect("login");
	}
예제 #14
0
<?php
Apu::import("/message/Msg.php");
Apu::import("/common/String.php");
Apu::import("/common/Session.php");
Apu::import("/util/Bean.php");

define("ACTION_SCOPE", "ACTION");

abstract class BaseAction extends BaseClass {
	var $method;
	var $_time;

	function __construct($method) {
		$this->method = $method;
	}

	function save($key) {
		Session::save(ACTION_SCOPE, $this->$key, get_class($this).".$key");
	}

	function fetch($key) {
		$value = Session::load(ACTION_SCOPE, get_class($this).".$key");
		Bean::set($this, $key, $value);
		return $value;
	}

	function remove($key = null) {
		if ($key == null) {
			$key = get_class($this);
		} else {
			$key = get_class($this).".$key";
예제 #15
0
<?php
Apu::import("/action/BaseAction.php");
Apu::import("/db/DB.php");
Apu::import("/db/Select.php");
class BenchmarkAction extends BaseAction {
	function doIndex() {
		header('Content-type: text/plain');
		echo "Hello World\n";
	}

	function doUsedb() {
		header('Content-type: text/plain');
		echo "Hello World\n";
		$result = DB::query(new Select("logs"));
		foreach($result as $row) {
			$a[] = $row;
		}
		$result = DB::query(new Select("lookups"));
		foreach($result as $row) {
			$a[] = $row;
		}
	}
}
?>
예제 #16
0
	function doAdd() {
		Apu::dispatch("/todo/faces/task/task_add.php");
	}
예제 #17
0
				<a href="" id="next" onclick="return false;">
					<img src="<?=Apu::theme()?>/img/next.gif" style="float: left;"/>
				</a>
				<a href="" id="last" onclick="return false;">
					<img src="<?=Apu::theme()?>/img/last.gif" style="float: left;"/>
				</a>
			</div>
			<div style="float: right;">
				<a href="" id="add" onclick="return false;">
					<img src="<?=Apu::theme()?>/img/add.gif" style="float: left;"/>
				</a>
				<script type="text/javascript">
					Event.observe($('add'), "click", LookupList.add);
				</script>
				<a href="" id="search" onclick="return false;">
					<img src="<?=Apu::theme()?>/img/search.gif" style="float: left;"/>
				</a>
				<script type="text/javascript">
					Event.observe($('search'), "click", LookupList.search);
				</script>
			</div>			
		</td>
	</tr>
</table>

<form method="post" action="lookup/search">
<div class="Frame" id="searchFrame" style="width: 250px;display: none">
	<div class="Title"><?=Msg::get("LookupAction.search.title")?></div>
	<div class="Message"><?=Msg::message("LookupAction.search.description")?></div>
	<div align="center">
		<table class="Form">
예제 #18
0
파일: login.php 프로젝트: reekoheek/php-fw
<? Apu::import("/tag/FormTag.php"); ?>
<style>
@IMPORT url("<?=Apu::theme()?>/main.css");
@IMPORT url("<?=Apu::theme()?>/application.css");
</style>

<script type="text/javascript" src="<?=Apu::base()?>/themes/prototype.js"></script>
<script type="text/javascript" src="<?=Apu::base()?>/themes/apu.js"></script>
<script type="text/javascript" src="<?=Apu::theme()?>/init.js"></script>
<script type="text/javascript">
if (window.top.location.href != window.location.href) {
	window.top.location.href = window.location.href;
}

var windowOnLoad = function(evt) {
	Position.absolutize($('login'));
	Position.centerize($('login'));
	$('centerized').style.position = "relative";
	Position.centerize($('centerized'));
}
Event.observe(window, "load", windowOnLoad);
Event.observe(window, "resize", windowOnLoad);
</script>

<form method="post" action="login/login">
<div class="Frame" style="width: 400px" id="login">
	<div class="Title"><?=Msg::get("LoginAction.title")?></div>
	<div class="Message"><?=Msg::message("LoginAction.description")?></div>
	<div style="height: 130px">
		<table id="centerized"><tr><td>
		<img src="themes/apu/img/security.gif"/>
예제 #19
0
파일: Locale.php 프로젝트: reekoheek/php-fw
<?php
Apu::import("/message/Msg.php");

class Locale extends BaseClass {
	function lang($lang = null) {
		if ($lang == null) {
			$sessionLang = Session::load(MSG_SCOPE, "lang");
			if (empty($sessionLang)) {
				Session::save(MSG_SCOPE, Locale::_defaultBrowserLang(), "lang");
			}
			return Session::load(MSG_SCOPE, "lang");
		} else {
			Session::save(MSG_SCOPE, $lang, "lang");
		}
	}

	function _defaultBrowserLang() {
		$langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
		$langs = explode(",", $langs);
		reset($langs);
		while (list($key, $lang) = each($langs)) {
			$lang = explode(";", $lang);
			$lang = $lang[0];
			$lang = explode("-", $lang);
			return $lang[0];
		}
	}
}
?>
예제 #20
0
<?php
Apu::import("/action/JsonAction.php");

class LogAction extends JsonAction {
	var $message;
	
	function doIndex() {
		$result = new stdClass();
		$result->message = $this->message;
		$this->json = $result;	 
	}
}
?>
예제 #21
0
	function checkLogin() {
		$user = UserDao::loginUserName();
		if (empty($user)) {
			Apu::redirect("login");
		}
	}
예제 #22
0
<?php
Apu::import("/action/BaseAction.php");
class BenchmarkCaseAction extends BaseAction {
	function doIndex() {
?>
<style>
body, table, tr, th, td {
	font-family: Lucida Console;
	font-size: 11px;
}
</style>
<?php
		$iteration = 10;
		$urls = array();
		$urls[] = 'http://codeigniter.dev.ku/benchmark/';
		$urls[] = 'http://todo.dev.ku/benchmark/';
		$urls[] = 'http://cakephp.dev.ku/benchmarks';
		$this->_benchmark($urls, $iteration);
		echo '<br/><br/>';
		$urls = array();
		$urls[] = 'http://codeigniter.dev.ku/benchmark/usedb/';
		$urls[] = 'http://todo.dev.ku/benchmark/usedb/';
		$urls[] = 'http://cakephp.dev.ku/benchmarks/usedb/';
		$this->_benchmark($urls, $iteration);
	}

	function _benchmark($urls, $iteration) {
		$result = array();
		echo "<table border=\"1\" width=\"100%\">\n<tr>\n<th>x</th>\n";
		reset($urls);
		foreach ($urls as $url) {
예제 #23
0
파일: Action.php 프로젝트: reekoheek/php-fw
<?php
Apu::import("/action/BaseAction.php");
Apu::import("/action/Validatable.php");
Apu::import("/action/Populatable.php");
Apu::import("/json/JSON.php");
Apu::import("/validation/Validation.php");

abstract class Action extends BaseAction implements Validatable, Populatable {
	var $messages;
	var $validation;
	var $serverDatas;

	function __construct($method) {
		parent::__construct($method);
		$this->messages = array();
	}

	function validate() {
		if (empty($this->validation)) {
			return;
		}
		Validation::validate($this);
	}

	function populate() {
		$scope = $GLOBALS["CFG_ACTION"]->SCOPE;
		$scopeVars = Bean::get('$'.$scope);
		while (list($key, $var) = each($scopeVars)) {
			if ($scope == "_REQUEST" || $scope == "_POST" || $scope == "_GET") {
				$key = str_replace("_", ".", $key);
			}
예제 #24
0
	function doDel() {
		try {
			$this->lookup = LookupDao::byId($this->id);
			DB::delete("lookups", $this->lookup);
			Apu::redirect("lookup");
		} catch (Exception $e) {
			$this->addMsgString($e->getMessage());
			Msg::save($this->messages);
			Apu::redirect("lookup");
		}
	}