function initialize(&$request)
 {
     parent::initialize($request);
     $roleId = $request->getUserVar('roleId');
     assert(is_numeric($roleId));
     $this->setRoleId($roleId);
     if ($request->getUserVar('title')) {
         $title = $request->getUserVar('title');
     } else {
         $role =& new Role($roleId);
         $title = $role->getRoleName();
     }
     // Need a unique ID for each group listbuilder
     $this->setId($this->getId() . '-' . String::camelize(Locale::translate($title)));
     // Basic configuration
     $this->setTitle($title);
     $this->setSourceTitle('manager.setup.roleName');
     $this->setSourceType(LISTBUILDER_SOURCE_TYPE_TEXT);
     // Free text input
     $this->setListTitle('manager.setup.currentRoles');
     $this->setAttributeNames(array('manager.setup.roleAbbrev'));
     $this->_loadList($request);
     $this->addColumn(new GridColumn('item', 'manager.setup.roleName'));
     $this->addColumn(new GridColumn('attribute', 'manager.setup.roleAbbrev'));
 }
예제 #2
0
파일: Log.php 프로젝트: reekoheek/php-fw
	function log($priority, $message, $file = null, $line = null, $e = null) {
		$schema = "DEFAULT";
		$table = "logs";
		$trace = "";
		if (!empty($e)) {
			$trace = $e->getTraceAsString();
		}
		if (is_object($message)) {
			$message = JSON::encode($message);
		}
		$now = new Date();
		$log = array();
		$log["priority"] = $priority;
		$log["message"] = $message;
		$log["trace"] = $trace;
		$log["file"] = $file;
		$log["line"] = $line;
		$log["createdBy"] = "SYS";
		$log["createdTime"] = $now;
		$log["updatedBy"] = "SYS";
		$log["updatedTime"] = $now;

		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$insert = new Insert($table, $log, $schema);
		$link = DB::connect();
		$success = mysql_query($insert->sql(), $link);
		if (!$success) {
			$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "error", array($schema));
			throw new Exception("Cannot persist object. ".$result);
		}
	}
예제 #3
0
파일: Insert.php 프로젝트: reekoheek/php-fw
	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);
	}
예제 #4
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();
	}
예제 #5
0
파일: DB.php 프로젝트: reekoheek/php-fw
	function delete($table, $obj, $schema = "DEFAULT") {
		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$objId = Bean::get($obj, "__ID__");
		if (empty($objId)) {
			throw new Exception("Cannot delete unpersisted object");
		}
		$delete = new Delete($table, $obj, $schema);
		$success = DB::query($delete, $schema);
		if (!$success) {
			$result = Bean::invoke(String::camelize('_'.$driver.'_driver'), "error", array($schema));
			throw new Exception("Cannot delete object. ".$result);
		}
	}
예제 #6
0
	private function delegate() {
		$controller = String::camelize($this->map['controller']) . 'Controller';
		
		if (!class_exists($controller)) {
			trigger_error("Route Error: The class `{$controller}` does't appear to be valid.", E_USER_ERROR);
			die();
		}
		
		$klass = new $controller ($this->map);
		
		if(!method_exists($klass, $this->map['action'])) {
			trigger_error("Route Error: The method `{$this->map['action']}` does't appear to be valid.", E_USER_ERROR);
			die();
		}
		
		call_user_func_array(array($klass, $this->map['action']), array());
		
		if($klass->redirection !== true) new ActionView($klass, $this->map);
		
	}
 /**
  * Retrieve the requested operation from the request
  *
  * NB: This can be an operation that not actually
  * exists in the requested component.
  *
  * @param $request PKPRequest
  * @return string the requested operation or an empty string
  *  if none can be found.
  */
 function getRequestedOp(&$request)
 {
     if (is_null($this->_op)) {
         $this->_op = '';
         // Retrieve the service endpoint parts from the request.
         if (is_null($rpcServiceEndpointParts = $this->_getValidatedServiceEndpointParts($request))) {
             // Endpoint parts cannot be found in the request
             return '';
         }
         // Pop off the operation part
         $this->_op = String::camelize(array_pop($rpcServiceEndpointParts), CAMEL_CASE_HEAD_DOWN);
     }
     return $this->_op;
 }
예제 #8
0
 /**
  * Parse table properties to build class methods
  * 
  * @param string $field     The field name from the current table
  * @return array            An array of values to build the method
  */
 private function _parseVars($field)
 {
     $field['getMethodName'] = 'get' . String::camelize($field['Field']);
     $field['setMethodName'] = 'set' . String::camelize($field['Field']);
     if ($field['Key'] != '') {
         $field['LoadByMethodName'] = 'loadBy' . String::camelize($field['Field']);
         $field['LoadMethod'] = 'fetchAllObject';
         if ($field['Key'] == 'UNI' || $field['Key'] == 'PRI' && count($this->_primaryKeys) == 1) {
             $field['LoadMethod'] = 'fetchObject';
         }
     }
     return $field;
 }
예제 #9
0
파일: Query.php 프로젝트: reekoheek/php-fw
	function escape($value, $name) {
		$schema = $this->schema;
		$driver = $GLOBALS["CFG_DB"]->CON[$schema]->DRIVER;
		$value = Bean::invoke(String::camelize('_'.$driver.'_driver'), "escape", array($value, $name, $this->meta));
		return $value;
	}
예제 #10
0
 /**
  * Returns a canonical form of the property
  * name ready to be used as a property id in an
  * external context (e.g. Forms or Templates).
  * @return string
  */
 function getId()
 {
     // Replace special characters in XPath-like names
     // as 'person-group[@person-group-type="author"]'.
     $from = array('[', ']', '@', '"', '=');
     $to = array('-', '', '', '', '-');
     $propertyId = trim(str_replace($from, $to, $this->getName()), '-');
     $propertyId = String::camelize($propertyId);
     return $propertyId;
 }
예제 #11
0
	function query($query, $schema = "DEFAULT") {
		$q = "";
		if ($query instanceof Query) {
			$q = $query->sql();
		} else {
			$q = $query;
		}
		$link = MysqlDriver::connect($schema);
		$result = mysql_query($q, $link);
		$rows = array();
		if ($result) {
			if (is_bool($result)) {
				return $result;
			}
			
			$fieldNames = array();
			$camelizeNames = array();
			$fieldTypes = array();
			$fieldCount = mysql_num_fields($result);
			for ($i = 0; $i < $fieldCount; $i++) {
				$fieldNames[$i] = mysql_field_name($result, $i);
				$camelizeNames[$i] = String::camelize($fieldNames[$i]);
				$fieldTypes[$i] = mysql_field_type($result, $i);  
			}
			while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
				$r = array();
				for ($i = 0; $i < $fieldCount; $i++) {
					if ($fieldTypes[$i] == "datetime") {
						$r[$camelizeNames[$i]] = &new Date($row[$fieldNames[$i]]);
					} else {
						$r[$camelizeNames[$i]] = &$row[$fieldNames[$i]];
					}
				}
				$r["__ID__"] = $row["id"];
				$rows[] = &$r;
			}
			mysql_free_result($result);
			return $rows;
		} else {
			return false;
		}

	}
예제 #12
0
	function listen() {
		$this->pre();
		$methodName = String::camelize("do_".$this->method);
		Bean::invoke($this, $methodName);
		$this->post();
	}
 public function testCamelize()
 {
     $this->assertEquals('CamalCaseString', String::camelize('camal-case-string'));
 }
예제 #14
0
 function set_controller_class()
 {
     $name = $this->controller_name;
     $namespace = '\\Leeflets\\Controller\\';
     if (!$name && !$this->action) {
         $this->controller_name = 'home';
         $this->controller_class = $namespace . 'Home';
         $this->action = 'index';
         return;
     }
     $name = preg_replace('@[/\\-\\.]@', '_', $name);
     $class = $namespace . String::camelize($name);
     if (!class_exists($class)) {
         $path = File::get_class_file_path($this->config, ltrim($class, '\\'));
         if (!file_exists($path) || !method_exists($class, $this->action)) {
             $this->controller_name = 'error';
             $this->controller_class = $namespace . 'Error';
             $this->action = 'e404';
             return;
         }
     }
     $this->controller_class = $class;
 }
예제 #15
0
 /**
  * Set an object properties, the object must extends Document
  * 
  * @param Document $object      The object to set properties
  * @return Document             The object with setted properties
  */
 public function setObjProperties(Document $object)
 {
     foreach ($this->getValues() as $k => $v) {
         $method = 'set' . ucfirst(String::camelize($k));
         $object->{$method}($v);
     }
     return $object;
 }