ficus/beans/annotation/BeanConstantAnnotationAccessor.php 100644 1751 144 10505 10645132217 17460 ISHITOYA Kentaro
* @version $Id: BeanConstantAnnotationAccessor.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once "ficus/beans/Bean.php";
require_once "ficus/lang/reflect/annotation/ReflectionAnnotationProperty.php";
require_once "ficus/lang/reflect/annotation/ReflectionAnnotationClass.php";
/**
* @class Ficus_BeanConstantAnnotationAccessor
*/
class Ficus_BeanConstantAnnotationAccessor{
const METHOD_SIGNATURE = '/^(get|has)([a-zA-Z][a-zA-Z0-9_]*)/';
/**
* @var $annotations
*/
protected $annotations = null;
/*
* construct with bean
* @param $annotations Ficus_ReflectionAnnotation
*/
protected function __construct($annotations){
$this->annotations = $annotations;
}
/**
* get accessor
* @param $bean Ficus_Bean bean to parse
* @throw Ficus_IllegalBeanException illegal bean.
*/
public static final function getAccessor($bean){
Ficus_Assert::isInstanceOf($bean, "Ficus_Bean");
$class = new Ficus_ReflectionClass($bean);
$annotations = array_merge($class->getConstants(),
$class->getStaticProperties());
return new
Ficus_BeanConstantAnnotationAccessor($annotations);
}
/**
* get constant
* @param $name string of constant to get
* @return mixed value of constant
* @throw Ficus_ConstantNotFoundException when name was not exist
*/
public function get($name){
if($this->has($name)){
return $this->annotations[$name];
}else{
throw new Ficus_ConstantNotFoundException("$name constant is not found");
}
}
/**
* check for constant existans
* @param $name string name of constant
* @return boolean true if exists
*/
public function has($name){
if(isset($this->annotations[$name])){
return true;
}
return false;
}
/**
* get Property with name
* @return Ficus_ReflectionAnnotationProperty annotations
*/
public function getAnnotations(){
return $this->annotations;
}
/**
* syntax suger
* @param $name string name of function
* @param $argument array of argument
*/
public function __call($name, $argument){
if(preg_match(self::METHOD_SIGNATURE, $name, $matches)){
$operator = $matches[1];
$constant = $this->getProperName($matches[2]);
switch($operator){
case "has" :
return $this->has($constant);
}
if(is_null($constant)){
throw new Ficus_ConstantNotFoundException("$name constant is not found");
}
switch($operator){
case "get" :
return $this->get($constant);
}
}
$constant = $this->getProperName($name);
if(is_null($constant)){
throw new Ficus_ConstantNotFoundException("$name constant is not found");
}
return $this->get($constant);
}
/**
* get proper name from given string
* @param $name string name of constant
* @return string proper name
*/
protected function getProperName($name){
$constant = strtolower($name[0]) . substr($name, 1);
if($this->has($constant)){
return $constant;
}
$constant = ucfirst($name);
if($this->has($constant)){
return $constant;
}
return null;
}
}
?>
ficus/beans/annotation/BeanAnnotationAccessor.php 100644 1751 144 11236 10645132217 15750 ISHITOYA Kentaro
* @version $Id: BeanAnnotationAccessor.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once "ficus/beans/Bean.php";
require_once "ficus/lang/annotation/AuthorAnnotation.php";
require_once "ficus/lang/annotation/BriefAnnotation.php";
require_once "ficus/lang/annotation/ClassAnnotation.php";
require_once "ficus/lang/annotation/CommentAnnotation.php";
require_once "ficus/lang/annotation/ClassAnnotation.php";
require_once "ficus/lang/annotation/DefinedbyAnnotation.php";
require_once "ficus/lang/annotation/PackageAnnotation.php";
require_once "ficus/lang/annotation/VarAnnotation.php";
require_once "ficus/beans/annotation/BeanPropertyAnnotationAccessor.php";
require_once "ficus/beans/annotation/BeanClassAnnotationAccessor.php";
require_once "ficus/lang/reflect/annotation/ReflectionAnnotationProperty.php";
require_once "ficus/lang/reflect/annotation/ReflectionAnnotationClass.php";
/**
* @class Ficus_BeanAnnotationAccessor
*/
abstract class Ficus_BeanAnnotationAccessor{
const T_VAR = "var";
const T_DEFINEDBY = "definedby";
const T_NAME = "name";
const T_TYPE = "type";
const T_COMMENT = "comment";
const T_QNAME = "qname";
const T_BRIEF = "brief";
const T_CLASS = "class";
const T_PACKAGE = "package";
const T_AUTHOR = "author";
/**
* @var $annotations
*/
protected $annotations = null;
/*
* construct with bean
* @param $annotations Ficus_ReflectionAnnotation
*/
public function __construct($annotations){
$this->annotations = $annotations;
}
/**
* get accessor
* @param $bean Ficus_Bean bean to parse
* @throw Ficus_IllegalBeanException illegal bean.
*/
public static final function getAccessor($bean){
Ficus_ReflectionAnnotation::setPrefixes(array('Ficus_', 'Ficus_'));
Ficus_Assert::isInstanceOf($bean, "Ficus_Bean");
$refClass = new Ficus_ReflectionClass($bean);
$annotations = new Ficus_ReflectionAnnotationClass($refClass);
$class = new Ficus_BeanClassAnnotationAccessor($annotations);
$properties = $refClass->getProperties();
$propAnnotations = array();
foreach($properties as $property){
$property =
new Ficus_BeanPropertyAnnotationAccessor(
new Ficus_ReflectionAnnotationProperty($property));
$class->addProperty($property);
}
return $class;
}
/**
* get Property with name
* @return Ficus_ReflectionAnnotationProperty annotations
*/
public function getAnnotations(){
return $this->annotations;
}
/**
* get property name
* @return string name of property
*/
public function getName(){
return $this->getAnnotation(self::T_NAME);
}
/**
* get property type
* @return string type of property
*/
public function getType(){
return $this->getAnnotation(self::T_TYPE);
}
/**
* get property comment
* @return string comment of property
*/
public function getComment(){
return $this->getAnnotation(self::T_COMMENT);
}
/**
* get property label
* @return string label of property
*/
public function getLabel(){
return $this->getAnnotation(self::T_BRIEF);
}
/*
* get property qname
* @return string qname of property
*/
public function getQName(){
return $this->getAnnotation(self::T_QNAME);
}
/**
* get property definedby
* @return string definedby of property
*/
public function getDefinition(){
return $this->getAnnotation(self::T_DEFINEDBY);
}
/**
* get Annotation from name
* @param $name string annotation name
* @return string annotation value
*/
abstract protected function getAnnotation($name);
}
?>
ficus/beans/annotation/BeanClassAnnotationAccessor.php 100644 1751 144 10650 10645132217 16735 ISHITOYA Kentaro
* @version $Id: BeanClassAnnotationAccessor.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once "ficus/beans/annotation/BeanAnnotationAccessor.php";
/**
* @class Ficus_BeanClassAnnotationAccessor
*/
class Ficus_BeanClassAnnotationAccessor extends Ficus_BeanAnnotationAccessor{
/**
* @var $properties
*/
private $properties = null;
/**
* construct with bean
* @param $bean Ficus_Bean target bean
*/
public function __construct($annotations){
parent::__construct($annotations);
}
/**
* set properties annotations
* @param $property Ficus_BeanPropertyAnnotationAccessor accessor
*/
public function addProperty($property){
$property->setDomain($this->getQName());
$this->properties[$property->getName()] = $property;
}
/**
* get Annotation from name
* @param $name string annotation name
* @return string annotation value
*/
protected function getAnnotation($name){
if($name == self::T_BRIEF){
$annotation = $this->annotations->getAnnotation(self::T_BRIEF);
return $annotation->getBrief();
}else if($name == self::T_COMMENT){
$annotation = $this->annotations->getAnnotation(self::T_COMMENT);
return $annotation->getComment();
}else if($name == self::T_NAME){
$annotation = $this->annotations->getAnnotation(self::T_CLASS);
$class = $annotation->getClass();
preg_match('/[^_]+_Beans.*_([^_]+)Bean/', $class, $matches);
return $matches[1];
}else if($name == self::T_TYPE){
$annotation = $this->annotations->getAnnotation(self::T_CLASS);
return $annotation->getClass();
}else if($name == self::T_COMMENT){
$annotation = $this->annotations->getAnnotation(self::T_COMMENT);
return $annotation->getComment();
}else if($name == self::T_BRIEF){
$annotation = $this->annotations->getAnnotation(self::T_BRIEF);
return $annotation->getBrief();
}else if($name == self::T_DEFINEDBY){
$annotation = $this->annotations->getAnnotation(self::T_DEFINEDBY);
return $annotation->getDefinedBy();
}
}
/**
* type name
*/
public function getTypename(){
$classname =
str_replace(".", "_", strtolower($this->getPackageName()));
$classname = "{$classname}_" . $this->getName();
return $classname;
}
/**
* get ClassAnnotation
* @return Ficus_ReflectionAnnotationClass
*/
public function getClassAnnotation(){
return $this->classAnnotation;
}
/**
* get property author
* @return string author of class
*/
public function getAuthor(){
$annotation = $this->annotations->getAnnotation(self::T_AUTHOR);
return $annotation->getAuthor();
}
/**
* get property author
* @return string author of class
*/
public function getPackageName(){
$annotation = $this->annotations->getAnnotation(self::T_PACKAGE);
return $annotation->getPackage();
}
/**
* get PropertyAnnotations
* @reuturn array array of Ficus_ReflectionAnnotationProperty
*/
public function getPropertyAnnotations(){
return $this->properties;
}
/**
* get Property with name
* @param $name string name of property
* @return Ficus_ReflectionAnnotationProperty annotations
*/
public function getPropertyAnnotation($name){
return $this->properties[$name];
}
}
?>
ficus/beans/annotation/BeanPropertyAnnotationAccessor.php 100644 1751 144 6716 10645132217 17504 ISHITOYA Kentaro
* @version $Id: BeanPropertyAnnotationAccessor.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once "ficus/beans/annotation/BeanAnnotationAccessor.php";
/**
* @class Ficus_BeanPropertyAnnotationAccessor
*/
class Ficus_BeanPropertyAnnotationAccessor extends Ficus_BeanAnnotationAccessor{
/**
* domain
*/
private $domain = null;
/**
* construct with bean
* @param $annotations annotations
*/
public function __construct($annotations){
parent::__construct($annotations);
}
/**
* set Domain
*/
public function setDomain($domain){
$this->domain = $domain;
}
/**
* get Annotation from name
* @param $name string annotation name
* @return string annotation value
*/
protected function getAnnotation($name){
if($name == self::T_BRIEF){
$annotation = $this->annotations->getAnnotation(self::T_BRIEF);
return $annotation->getBrief();
}else if($name == self::T_COMMENT){
$annotation = $this->annotations->getAnnotation(self::T_COMMENT);
return $annotation->getComment();
}else if($name == self::T_DEFINEDBY){
$annotation = $this->annotations->getAnnotation(self::T_DEFINEDBY);
return $annotation->getDefinedBy();
}else if($name == self::T_QNAME){
$domain = $this->getDomain();
return "$domain." . $this->getName();
}else{
$annotation = $this->annotations->getAnnotation(self::T_VAR);
$name = "get" . ucfirst($name);
return $annotation->{$name}();
}
}
/**
* get domain
* @return string domain
*/
public function getDomain(){
return $this->domain;
}
/**
* get range
* @return string range
*/
public function getRange(){
$annotation = $this->annotations->getAnnotation(self::T_VAR);
return $annotation->getType();
}
/**
* is property is array
* @return boolean is property is array
*/
public function isArray(){
$annotation = $this->annotations->getAnnotation(self::T_VAR);
return $annotation->isArray();
}
/**
* is property is class
* @return boolean is property is class
*/
public function isClass(){
$annotation = $this->annotations->getAnnotation(self::T_VAR);
return $annotation->isClass();
}
/**
* is property is literal
* @return boolean is property is literal
*/
public function isLiteral(){
return (!$this->isClass());
}
}
?>
ficus/beans/Bean.php 100644 1751 144 23003 10645132217 10053 ISHITOYA Kentaro
* @version $Id: Bean.php 2 2007-07-11 10:37:48Z ishitoya $
*
* Abstract Bean.
* __set and __get mediates $bean->setData() of $bean->getData()
* on Java or other languge, you must implement
* $bean->set("Data", $object) or $bean->get("Data") to mediate beans method.
*/
require_once "ficus/lang/Serializable.php";
require_once "ficus/net/URI.php";
require_once "ficus/exception/MethodNotFoundException.php";
require_once "ficus/exception/IllegalArgumentException.php";
require_once "ficus/exception/PropertyNotFoundException.php";
require_once "ficus/exception/NotReadyException.php";
require_once "ficus/beans/BeanComponentFactory.php";
require_once "ficus/beans/annotation/BeanAnnotationAccessor.php";
/**
* @class Ficus_Bean
*/
abstract class Ficus_Bean implements Ficus_Serializable{
const METHOD_SIGNATURE = '/^(set|get|add|delete|shift|push|pop|insert|numOf|count|clear|has|isEmpty|is|enable|disable)([a-zA-Z][a-zA-Z0-9_]*)/';
const METHOD_SIGNATURE_SUFFIX = '/^([a-zA-Z][a-zA-Z0-9_]*?)(EqualsTo)/';
const BEAN_METHOD_SIGNATURE = '/^get([a-zA-Z][a-zA-Z0-9_]*)Bean/';
/**
* serialize bean
* @param $type string type of serializer
* @return string serialized string
*/
public function serialize($type = null){
if(is_null($type)){
$reflection = new ReflectionClass($this);
$props = $reflection->getDefaultProperties();
foreach($props as $key => $value){
$props[$key] = $this->$key;
}
return serialize($props);
}
if($type instanceof Ficus_BeanSerializer){
$serializer = $type;
}else{
$factory =
Ficus_BeanComponentFactory::getComponent("BeanSerializerFactory");
$serializer = $factory->create($type);
}
if(func_num_args() > 1){
$arguments = func_get_args();
array_shift($arguments);
return $serializer->serialize($this, $arguments);
}else{
return $serializer->serialize($this);
}
}
public function unserialize($serialized){
$unserialized = unserialize($serialized);
foreach($unserialized as $key => $value){
$this->$key = $value;
}
}
/**
* deserialize bean
* @param $type string type of deserializer
*/
public function deserialize($data, $deserializer=null){
if(($deserializer instanceof Ficus_BeanDeserializer) == false){
$factory =
Ficus_BeanComponentFactory::getComponent(
"BeanDeserializerFactory");
$deserializer = $factory->create($data);
}
return $deserializer->deserialize($this, $data);
}
/**
* create clone
* @return Ficus_Bean cloned object
*/
public function createClone(){
$clone = clone $this;
return $clone;
}
/**
* set value to specified property
* @param $name string property name
* @param $value mixed value to set
*/
public function set($name, $value){
if($this->has($name) == false){
throw new Ficus_PropertyNotFoundException("property $name is not found");
}
$this->{$name} = $value;
}
/**
* get value
* @return mixed value
*/
public function get($name, $index = null){
if($this->has($name) == false){
throw new Ficus_PropertyNotFoundException("property $name is not found");
}
$method = "get" . ucfirst($name);
if(method_exists($this, $method)){
return $this->{$method}();
}
if(is_null($index)){
return $this->{$name};
}else{
return $this->{$name}[$index];
}
}
/**
* has property
* @param $name string property name
* @return boolean true if property exists
*/
public function has($name){
return property_exists($this, $name);
}
/**
* other functions
*/
public function __call($name, $arguments){
return $this->__onCall($name, $arguments);
}
/**
* handle call
*/
protected function __onCall($name, $arguments){
$class = new ReflectionClass($this);
if($class->hasProperty($name)){
$property = $class->getProperty($name);
if($property->isStatic()){
$values = $class->getStaticProperties();
$value = $values[$name];
}else{
$value = $this->{$name};
}
if(isset($arguments[0])){
return $value[$arguments[0]];
}else{
return $value;
}
}
if(preg_match(self::METHOD_SIGNATURE, $name, $matches)){
$operator = $matches[1];
$property = strtolower($matches[2][0]) . substr($matches[2], 1);
switch($operator){
case "has" :
return $this->has($property);
}
if($this->has($property)){
switch($operator){
case "set" :
$this->{$property} = $arguments[0];
return;
case "get" :
if(isset($arguments[0])){
if(is_null($arguments[0])){
return null;
}
if(isset($this->{$property}[$arguments[0]])){
return $this->{$property}[$arguments[0]];
}else{
return null;
}
}
return $this->{$property};
case "add" :
case "push" :
return array_push($this->{$property}, $arguments[0]);
case "shift" :
return array_shift($this->{$property});
case "pop" :
return array_pop($this->{$property});
case "delete" :
if(isset($arguments[0])){
if((is_numeric($arguments[0]) ||
is_string($arguments[0])) &&
isset($this->{$property}[$arguments[0]])){
$temp = $this->{$property}[$arguments[0]];
unset($this->{$property}[$arguments[0]]);
return $temp;
}else{
foreach($this->{$property} as $key => $item){
if($item == $arguments[0]){
unset($this->{$property}[$key]);
return $item;
}
}
return;
}
}
break;
case "insert" :
if(isset($arguments[0])){
$this->{$property}[$arguments[0]] = $arguments[1];
return;
}
break;
case "numOf" :
case "count" :
return count($this->{$property});
case "clear" :
if(is_array($this->{$property})){
$this->{$property} = array();
}else{
$this->{$property} = null;
}
return;
case "isEmpty" :
return empty($this->{$property});
case "is" :
return (boolean)$this->{$property};
case "enable" :
$this->{$property} = true;
return;
case "disable" :
$this->{$property} = false;
return;
}
}
}
if(preg_match(self::METHOD_SIGNATURE_SUFFIX, $name, $matches)){
$operator = $matches[2];
$property = strtolower($matches[1][0]) . substr($matches[1], 1);
if($this->has($property)){
switch($operator){
case "EqualsTo" :
return Ficus_Types::equalsByToString($arguments[0],
$this->{$property});
}
}
}
if(method_exists($this, $name)){
call_user_func_array(array($this, $name), $arguments);
}else if(isset($property) &&
$this->has($property) == false){
throw new Ficus_PropertyNotFoundException("property $property is not found.");
}else{
throw new Ficus_MethodNotFoundException("method $name is not found.");
}
}
}
ficus/media/audio/AudioBean.php 100644 1751 144 2726 10647426442 12126 ISHITOYA Kentaro
* @version $Id: AudioBean.php 15 2007-07-18 15:02:48Z ishitoya $
*
* Page component factory
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/media/audio/AudioConstants.php");
/**
* @class Ficus_AudioBean
*/
class Ficus_AudioBean extends Ficus_Bean implements Ficus_AudioConstants{
/**
* length
*/
protected $length;
/**
* filename
*/
protected $filename;
/**
* bitrate
*/
protected $bitrate;
/**
* frequency
*/
protected $frequency;
/**
* codec
*/
protected $codec;
/**
* method
*/
protected $method;
}
?>
ficus/media/audio/AudioConstants.php 100644 1751 144 2014 10647426442 13223 ISITOYA Kentaro
* @version $Id: AudioConstants.php 15 2007-07-18 15:02:48Z ishitoya $
*
* subversion constants
*/
/**
* @interface Ficus_AudioConstants
*/
interface Ficus_AudioConstants
{
}
?>
ficus/media/image/ImageConstants.php 100644 1751 144 2053 10647426442 13170 ISITOYA Kentaro
* @version $Id: ImageConstants.php 15 2007-07-18 15:02:48Z ishitoya $
*
* subversion constants
*/
/**
* @interface Ficus_AudioConstants
*/
interface Ficus_ImageConstants
{
const FORMAT_JPEG = "jpg";
}
?>
ficus/media/video/VideoConstants.php 100644 1751 144 2053 10647426442 13240 ISITOYA Kentaro
* @version $Id: VideoConstants.php 15 2007-07-18 15:02:48Z ishitoya $
*
* subversion constants
*/
/**
* @interface Ficus_VideoConstants
*/
interface Ficus_VideoConstants
{
const CODEC_FLASH = "flv";
}
?>
ficus/media/video/VideoBean.php 100644 1751 144 3066 10647426442 12136 ISHITOYA Kentaro
* @version $Id: VideoBean.php 15 2007-07-18 15:02:48Z ishitoya $
*
* Page component factory
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/media/video/VideoConstants.php");
/**
* @class Ficus_VideoBean
*/
class Ficus_VideoBean extends Ficus_Bean implements Ficus_VideoConstants{
/**
* length
*/
protected $length;
/**
* filename
*/
protected $filename;
/**
* bitrate
*/
protected $bitrate;
/**
* fps
*/
protected $fps;
/**
* height
*/
protected $height;
/**
* width
*/
protected $width;
/**
* codec
*/
protected $codec;
/**
* color
*/
protected $color;
}
?>
ficus/pages/PageController.php 100644 1751 144 11111 10646126776 12150 ISHITOYA Kentaro
* @version $Id: PageController.php 7 2007-07-14 10:55:18Z ishitoya $
*/
require_once("smarty/Smarty.class.php");
require_once("ficus/pages/PageModeExtractor.php");
require_once("ficus/lang/ClassLoader.php");
require_once("ficus/exception/ClassNotFoundException.php");
require_once("ficus/exception/PageNotFoundException.php");
require_once("ficus/lang/Class.php");
require_once("ficus/lang/String.php");
require_once("ficus/pages/PageComponentFactory.php");
require_once("ficus/pages/PageConstants.php");
/**
* @class Ficus_PageController
*/
class Ficus_PageController implements Ficus_PageConstants{
/**
* cache dir
*/
protected $cacheDir = null;
/**
* base dir
*/
protected $baseDir = null;
/**
* pages
*/
protected $pages = array();
/**
* mode extractor
*/
protected $extractor = null;
/**
* constructor
*/
public function __construct(){
$templates =
Ficus_Dir::normalize(Ficus_File::currentDir() . "/templates");
Ficus_PageComponentFactory::getSmarty()->addPath(self::TEMPLATE_NAME,
$templates);
}
/**
* set base dir
*/
public function setBaseDir($base){
$this->baseDir = Ficus_Dir::normalize($base);
$template = $this->baseDir . "/" . self::TEMPLATES_DIR;
$smarty = Ficus_PageComponentFactory::getSmarty();
$smarty->addUserPath(self::TEMPLATE_NAME, $template);
$smarty->setTemplateDir($template);
}
/**
* call method
* @param $name string name of page
* @param $mode string name of mode
* @param $buffering boolean buffering
* @return mixed return value of method
*/
public function execute($name = null, $mode = null, $buffering = false){
$request = new Ficus_PageRequest(func_get_args());
if(is_null($name)){
$name =
Ficus_PageComponentFactory::getPageLoader()->dispatch($request);
}
if($this->isPageExists($name) == false){
$this->addPage($name);
}
if(is_null($mode)){
$mode = $this->getMode($name);
}
$page = $this->pages[$name]["page"];
if($page->authorization() == self::FORWARDED){
return;
}
if($buffering == true){
try{
Ficus_Assert::isInstanceOf($page, "Ficus_BufferedPage");
}catch(Ficus_TypeMismatchException $e){
throw new Ficus_IllegalArgumentException("out buffering is on, but page has not ability to buffer.");
}
$page->enableOutputBuffering();
}else{
if($page instanceof Ficus_BufferedPage){
$page->disableOutputBuffering();
}
}
return call_user_func(array($page, $mode), $request);
}
/**
* get mode from extractor
* @param $name String name of page
* @return String of mode name
*/
protected function getMode($name){
$mode = $this->pages[$name]["extractor"]->getMode();
return $mode;
}
/**
* add a page to pages array
* @param $name String name of page
*/
protected function addPage($name){
$page = Ficus_PageComponentFactory::getPageLoader()->load($name);
$extractor = new Ficus_PageModeExtractor($page);
$extractor->setDefaultMode($page->getDefaultMode());
$this->pages[$name]["page"] = $page;
$this->pages[$name]["extractor"] = $extractor;
}
/**
* checks page exist in pages array
* @param $name String name of page
* @return boolean return true if page exists
*/
protected function isPageExists($name){
return array_key_exists($name, $this->pages);
}
}
?> ficus/pages/AbstractInlinePage.php 100644 1751 144 3656 10645132217 12710 ISHITOYA Kentaro
* @version $Id: AbstractInlinePage.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once("ficus/pages/InlinePage.php");
require_once("ficus/exception/IllegalArgumentException.php");
/**
* @class Ficus_AbstractInlinePage
*/
abstract class Ficus_AbstractInlinePage extends Ficus_InlinePage{
/**
* constructor
*/
protected function onConstruct(){
}
/**
* on called
* @param $mode string name of mode
* @param $args array of args of do method
*/
protected function onDo($mode, $args){
}
/**
* on done
* @param $mode string name of mode
* @param $args array of args of do method
*/
protected function onDone($mode, $args){
$this->display();
}
/**
* on exception
* @param $mode string name of mode
* @param $args array of args of do method
* @param $exception Exception exception
*/
protected function onException($mode, $args, $exception){
$this->display(self::PAGE_EXCEPTION_TEMPLATE);
}
/**
* show default
*/
public function doDefault(){
}
}
?> ficus/pages/AbstractPage.php 100644 1751 144 4321 10645132217 11537 ISHITOYA Kentaro
* @version $Id: AbstractPage.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once("ficus/pages/Page.php");
require_once("ficus/exception/IllegalArgumentException.php");
/**
* @class Ficus_AbstractPage
*/
abstract class Ficus_AbstractPage extends Ficus_Page{
/**
* constructor
*/
protected function onConstruct(){
}
/**
* get default mode
* @return string default mode name
*/
public function getDefaultMode(){
return self::PAGE_DEFAULT_MODE;
}
/**
* on called
* @param $mode string name of mode
* @param $args array of args of do method
*/
protected function onDo($mode, $args){
$this->setNextAction(self::PAGE_DEFAULT_MODE);
}
/**
* on exception
* @param $mode string name of mode
* @param $args array of args of do method
* @param $exception Exception exception
*/
protected function onException($mode, $args, $exception){
$template = Ficus_Registry::search(self::REGISTRY_EXCEPTION_TEMPLATE);
if($template){
$this->display($template);
}else{
$this->display(self::DEFAULT_EXCEPTION_TEMPLATE);
}
}
/**
* on authorization
*/
protected function onAuthorization(){
return self::AUTHORIZATION_NOT_REQUIRED;
}
/**
* show default
*/
public function doDefault(){
}
}
?> ficus/pages/beans/PageVisitBean.php 100644 1751 144 4702 10645132217 12753 ISHITOYA Kentaro
* @version $Id: PageVisitBean.php 2 2007-07-11 10:37:48Z ishitoya $
*
* Page component factory
*/
require_once("ficus/beans/Bean.php");
/**
* @class Ficus_PageVisitBean
*/
class Ficus_PageVisitBean extends Ficus_Bean
implements S2AnA_AuthenticationContext, Ficus_PageConstants{
/**
* environments
*/
protected $request;
/**
* user name
*/
protected $user;
/**
* password
*/
protected $password;
/**
* constructor
*/
public function __construct(){
$this->getUserPrincipal();
}
/**
* is guest
* @return boolean true if guest
*/
public function isGuest(){
return ($this->user === self::USER_GUEST);
}
/**
* is logined
* @return boolean true if logined
*/
public function isLogined(){
return ($this->isGuest() === false);
}
/**
* user authentication
*/
public function getUserPrincipal(){
$this->request = $_REQUEST;
if(isset($_SERVER[self::KEY_USER])){
$this->user = $_SERVER[self::KEY_USER];
$this->password = $_SERVER[self::KEY_PASSWORD];
}else{
session_start();
if(isset($_SESSION[self::KEY_USER])){
$this->user = $_SESSION[self::KEY_USER];
}else{
$this->user = self::USER_GUEST;
}
}
}
/**
* is authenticated
*/
public function isAuthenticated(){
return $this->isLogined();
}
/**
* is user in role
*/
public function isUserInRole($roleName){
return true;
}
}
?>
ficus/pages/beans/PageEnvironmentsBean.php 100644 1751 144 2471 10645132217 14345 ISHITOYA Kentaro
* @version $Id: PageEnvironmentsBean.php 2 2007-07-11 10:37:48Z ishitoya $
*
* Page component factory
*/
require_once("ficus/beans/Bean.php");
/**
* @class Ficus_PageEnvironmentsBean
*/
class Ficus_PageEnvironmentsBean extends Ficus_Bean
implements Ficus_PageConstants{
/**
* environments
*/
protected $values;
/**
* constructor
*/
public function __construct(){
$this->values = array_merge($_SERVER, $_ENV);
}
}
?>
ficus/pages/scaffold/util/ScaffoldTemplateParser.php 100644 1751 144 7141 10645132217 16332 ISHITOYA Kentaro
* @version $Id: ScaffoldTemplateParser.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_ScaffoldTemplateParser
*/
class Ficus_ScaffoldTemplateParser
implements Ficus_S2DaoModelConstants{
public static function getTemplate($part){
Ficus_Assert::isInstanceOf($part, "Ficus_ScaffoldPart");
if($part->value() instanceof Ficus_S2DaoEntity){
$entityName = $part->value()->getEntityName();
$settings = Ficus_Registry::search("tableSettings");
if(isset($settings[$entityName]) &&
isset($settings[$entityName]["view"])){
return $settings[$entityName]["view"];
}
}
return false;
}
public static function parse($template, $part, $recursive = true){
Ficus_Assert::isInstanceOf($part, "Ficus_ScaffoldPart");
preg_match_all('/[{][$](.+?)[}]/', $template, $regs);
$ret = $template;
foreach($regs[1] as $property){
$name = explode(".", $property);
$value = self::getValue($name, $part, $recursive);
if(is_null($value) == false){
$ret = str_replace("{\$$property}", $value, $ret);
}
}
if($ret == $template){
return "";
}else{
return $ret;
}
}
protected static function getValue($name, $part, $recursive){
$prop = array_shift($name);
if($part instanceof Ficus_ScaffoldPart){
$part = $part->getParts($prop);
if($part instanceof Ficus_ScaffoldPart){
if($part->type() == self::TYPE_LIST){
$key = $part->value()->name();
if(is_null($key) == false){
return $part->value()->names($part->value()->name());
}
$key = $part->value()->name();
$names = $part->value()->names();
$i = 0;
foreach($names as $name){
if($i == $key){
return $name;
}
$i++;
}
return null;
}else if(empty($name) == false){
return self::getValue($name, $part, $recursive);
}
}
$value = $part->value();
if($recursive == true&&
$value instanceof Ficus_S2DaoEntity){
$template = self::getTemplate($value);
if(is_null($template) == false){
return self::parse($template, $value, $recursive);
}
}
return $value;
}
return null;
}
}
?> ficus/pages/scaffold/util/ScaffoldMediator.php 100644 1751 144 12077 10647425604 15201 ISHITOYA Kentaro
* @version $Id: ScaffoldMediator.php 14 2007-07-18 14:55:12Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_ScaffoldMediator
*/
class Ficus_ScaffoldMediator implements Ficus_ScaffoldConstants{
/**
* target entity
*/
protected $target = null;
/**
* configuration
*/
protected $configuration = null;
/**
* s2daoManager
*/
protected $daoManager = null;
/**
* entity
*/
protected $entity = null;
/**
* request
*/
protected $request = null;
/**
* organizer factory
*/
protected $organizerFactory = null;
/**
* smarty
*/
protected $smarty = null;
/**
* form bean
*/
protected $form = null;
/**
* construct
* @param $target string target entity name
*/
public function __construct(){
$settings = Ficus_Registry::search(self::REGISTRY_SETTINGS);
$this->configuration = new Ficus_ScaffoldConfiguration($settings);
$this->daoManager = new Ficus_S2DaoManager();
$this->request = new Ficus_PageRequest();
$this->organizerFactory = new Ficus_ScaffoldOrganizerFactory($this);
$this->smarty = Ficus_ScaffoldComponentFactory::getSmarty();
$templates =
Ficus_Dir::normalize(Ficus_File::currentDir() . "/../templates");
$this->smarty->addPath(self::SCAFFOLD_TEMPLATES, $templates);
if(Ficus_Registry::search(self::REGISTRY_SCAFFOLD_TEMPLATES)){
$dir =
Ficus_Registry::search(self::REGISTRY_SCAFFOLD_TEMPLATES);
$templates = Ficus_ClassPath::search($dir);
if(empty($templates)){
throw new Ficus_IllegalArgumentException("directory $dir is not found in class path");
}
$templates = $templates[0];
$this->smarty->addUserPath(self::SCAFFOLD_TEMPLATES, $templates);
}
}
/**
* set target
* @param $target string target
*/
public function setTarget($target){
$this->target = $target;
$this->daoManager->setTarget($target);
}
/**
* set entity
*/
public function setEntity($entity){
$this->entity = $entity;
}
/**
* set form bean
*/
public function setFormBean($bean){
$this->form = $bean;
}
/**
* get form bean
*/
public function formBean(){
return $this->form;
}
/**
* set request
*/
public function setRequest($request){
$this->request = $request;
}
/**
* get request
*/
public function request(){
return $this->request;
}
/**
* get entity
*/
public function entity(){
return $this->entity;
}
/**
* get smarty
*/
public function smarty(){
return $this->smarty;
}
/**
* configuration
* @return Ficus_ScaffoldConfiguration
*/
public function configuration(){
$this->isInitialized();
return $this->configuration;
}
/**
* organizer factory
*/
public function organizerFactory(){
return $this->organizerFactory;
}
/**
* table
*/
public function table($name = null){
if(is_null($name)){
$name = $this->target;
}
return $this->configuration->table($name);
}
/**
* dao managert
* @return Ficus_S2DaoManager
*/
public function daoManager(){
$this->isInitialized();
return $this->daoManager;
}
/**
* get Container
*/
public function getContainer($entity){
$builder = new Ficus_ConcreteScaffoldBuilder($this);
return $builder->build($entity);
}
/**
* deserializeEntity
*/
public function getEntityFromRequest(){
return $this->daoManager->deserializeEntity(
$this->request->requests());
}
/**
* check is initialized
*/
protected final function isInitialized(){
if(is_null($this->target)){
throw new Ficus_NotReadyException("target must be initialized before runch any public functions");
}
return;
}
}
?> ficus/pages/scaffold/util/TableManagerProxy.php 100644 1751 144 4751 10645132217 15330 ISHITOYA Kentaro
* @version $Id: TableManagerProxy.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_TableManagerProxy
*/
class Ficus_TableManagerProxy extends Ficus_Bean{
/**
* @var entity entity
*/
protected $entity;
/**
* get form.
* @param $table string target table name
* @return string form html
*/
public function getForm($table, $mode){
$controller =
Ficus_PageComponentFactory::getPageController();
if($this->isEmptyEntity() == false){
$form = $controller->execute("common.TableManager", $mode, true,
array("table" => $table),
array("inline" => "inline"),
array("entity" => $entity));
}else{
$form = $controller->execute("common.TableManager", $mode, true,
array("table" => $table),
array("inline" => "inline"));
}
return $form;
}
/**
* change Action and Mode
* @param $form string form
* @param $nextAction string next action
* @return string normalized form
*/
public function normalizeForm($form, $pagename, $nextAction){
$form = preg_replace('/action=".*?"/',
"action=\"?$pagename\"", $form);
$form = preg_replace('/type="submit" name=".*?"/', "type=\"submit\" name=\"$nextAction\"", $form);
return $form;
}
}
?>
ficus/pages/scaffold/ScaffoldManager.php 100644 1751 144 17372 10647426442 14036 ISHITOYA Kentaro
* @version $Id: ScaffoldManager.php 15 2007-07-18 15:02:48Z ishitoya $
*/
require_once("ficus/config/Registry.php");
/**
* @class Ficus_ScaffoldManager
*/
class Ficus_ScaffoldManager extends Ficus_Bean
implements Ficus_ScaffoldConstants{
/**
* foreperson
*/
protected $foreperson = null;
/**
* target
*/
protected $target = null;
/**
* page
*/
protected $page = null;
/**
* action
*/
protected $action = null;
/**
* mediator
*/
protected $mediator = null;
/**
* fuzzy
*/
protected $fuzzy = false;
/**
* construct
*/
public function __construct($page){
$this->mediator = new Ficus_ScaffoldMediator();
$this->guess($page);
}
/**
* is guess able
* @return boolean true if guessable
*/
public function isGuessable(){
if($this->page instanceof Ficus_ScaffoldPage &&
$this->page->isEmptyTarget() == false){
return true;
}
return $this->page->request()->has(self::KEY_TARGET);
}
/**
* guess action
* @param $args array of request
*/
public function guess($page){
$this->setPage($page);
$request = $page->request();
$form = new Ficus_ScaffoldFormBean();
$form->setAction($page->nextAction());
$form->setPage($page->pagename());
$this->setFormFromRequest($form, "target", self::KEY_TARGET);
$this->setFormFromRequest($form, "do", self::KEY_DO);
$this->setFormFromRequest($form, "method", self::KEY_METHOD);
$this->setFormFromRequest($form, "message", self::KEY_MESSAGE);
$this->setFormFromRequest($form, "transition", self::KEY_TRANSITION);
$this->setFormFromRequest($form, "submitTitle",
self::KEY_SUBMIT_TITLE);
$this->setFormBean($form);
if($this->isGuessable()){
if($page instanceof Ficus_ScaffoldPage){
$target = $page->target();
$foreperson = $page->foreperson();
}else{
$target = $request->extractAsString(self::KEY_TARGET);
$foreperson = $request->extractAsString(self::KEY_FOREPERSON);
}
$this->setTarget($target);
$this->setAction($foreperson);
}
}
/**
* set bean data from request
*/
private function setFormFromRequest($form, $property, $key){
$value = $this->page->request()->extractAsString($key);
if(is_null($value) == false){
$form->set($property, $value);
}
}
/**
* set request
*/
public function setPage($page){
$this->page = $page;
}
/**
* set Target
* @param $target string target
*/
public function setTarget($target){
$this->initialize($target);
$this->formBean()->setTarget($target);
}
/**
* set Action
*/
public function setAction($action){
$this->isInitialized();
$this->action = $action;
$this->foreperson =
$this->createForeperson($this->action);
$this->formBean()->setForeperson($action);
}
/**
* set form bean
*/
public function setFormBean($bean){
$this->mediator->setFormBean($bean);
}
/**
* get form bean
*/
public function formBean(){
return $this->mediator->formBean();
}
/**
* mediator
*/
public function mediator(){
return $this->mediator;
}
/**
* organize a scaffold
*/
public function organize(){
$this->isInitialized();
if(is_null($this->action)){
throw new Ficus_NotReadyException("action is empty, you must run guess or setAction before runch organize method");
}
$scaffold = $this->foreperson->organize();
$smarty = Ficus_ScaffoldComponentFactory::getSmarty();
$form = $this->mediator->formBean();
if(is_null($form) == false){
$smarty->assign(self::KEY_PAGE, $form->page());
$smarty->assign(self::KEY_METHOD, $form->method());
$smarty->assign(self::KEY_ACTION, $form->action());
$smarty->assign(self::KEY_TARGET, $form->target());
$smarty->assign(self::KEY_DO, $form->do());
$smarty->assign(self::KEY_MESSAGE, $form->message());
$smarty->assign(self::KEY_TRANSITION, $form->transition());
$smarty->assign(self::KEY_FOREPERSON, $form->foreperson());
$smarty->assign(self::KEY_SUBMIT_TITLE,
$form->submitTitle());
}
$smarty->assign(self::KEY_SCAFFOLD, $scaffold);
$scaffold = $smarty->fetch($this->template($this->action));
if($this->fuzzy){
$header = $smarty->fetch(self::TEMPLATE_HEADER);
$footer = $smarty->fetch(self::TEMPLATE_FOOTER);
$scaffold = $header . $scaffold . $footer;
}
return $scaffold;
}
/**
* set entity
*/
public function setEntity($entity){
$this->mediator->setEntity($entity);
}
/**
* get deserialized entity
*/
public function getEntityFromRequest(){
return $this->mediator->getEntityFromRequest();
}
/**
* fuzzy
*/
public function setFuzzy($fuzzy){
$this->fuzzy = $fuzzy;
}
/**
* is initialized
*/
protected final function isInitialized(){
if(is_null($this->target)){
throw new Ficus_NotReadyException("target is empty, you must run setTarget or guess before runch any public functions");
}
}
/**
* get template
*/
protected function template($action){
return "Scaffold" . ucfirst($action);
}
/**
* initialize
*/
protected function initialize($target){
$this->target = $target;
$this->mediator->setTarget($this->target);
$this->mediator->setRequest($this->page->request());
}
/**
* create foreperson
* @param $action string action
* @param $mediator Ficus_ScaffoldMediator mediator
* @return UTil_ScaffoldForeperson
*/
protected function createForeperson($action){
switch($action){
case(self::ACTION_VIEW):
return new Ficus_ViewScaffoldForeperson($this->mediator);
case(self::ACTION_LIST):
return new Ficus_ListScaffoldForeperson($this->mediator);
case(self::ACTION_EDIT):
return new Ficus_EditScaffoldForeperson($this->mediator);
case(self::ACTION_NEW):
return new Ficus_NewScaffoldForeperson($this->mediator);
case(self::ACTION_DELETE):
return new Ficus_DeleteScaffoldForeperson($this->mediator);
default: throw new Ficus_NotSupportedException("scaffold foreperson $action is not available");
}
}
}
?>
ficus/pages/scaffold/ScaffoldConstants.php 100644 1751 144 5544 10647426442 14416 ISHITOYA Kentaro
* @version $Id: ScaffoldConstants.php 15 2007-07-18 15:02:48Z ishitoya $
*/
require_once("ficus/config/Registry.php");
/**
* @interface ScaffoldConstants
*/
interface Ficus_ScaffoldConstants{
const REGISTRY_SETTINGS = "scaffoldSettings";
const REGISTRY_TABLESETTINGS = "tableSettings";
const REGISTRY_SMARTYCACHE = "smarty.cache";
const REGISTRY_SCAFFOLD_TEMPLATES = "scaffold.templates";
const REGISTRY_NOLABELS = "nolabels";
const REGISTRY_EXCLUDES = "excludes";
const REGISTRY_NOCHILDREN = "nochildren";
const REGISTRY_DEFAULTS = "defaults";
const REGISTRY_TRANSITION = "transition";
const REGISTRY_PROPERTIES = "properties";
const REGISTRY_VALIDATORS = "validators";
const REGISTRY_CONSTRAINT = "constraint";
const REGISTRY_PARENT = "parent";
const METHOD_PREFIX = "do";
const ACTION_PREFIX = "scaffold";
const ACTION_NEW = "new";
const ACTION_LIST = "list";
const ACTION_VIEW = "view";
const ACTION_EDIT = "edit";
const ACTION_DELETE = "delete";
const DO_DEFAULT = "default";
const DO_CHILDREN = "children";
const DO_CONFIRM = "confirm";
const DO_SUBMIT = "submit";
const SCAFFOLD_TEMPLATES = "scaffold";
const TEMPLATE_HEADER = "scaffoldHeader";
const TEMPLATE_FOOTER = "scaffoldFooter";
const KEY_SCAFFOLD = "scaffold";
const KEY_PAGE = "scaffold_nextPage";
const KEY_METHOD = "scaffold_method";
const KEY_ACTION = "scaffold_nextAction";
const KEY_TARGET = "scaffold_target";
const KEY_DO = "scaffold_do";
const KEY_MESSAGE = "scaffold_message";
const KEY_TRANSITION = "scaffold_transition";
const KEY_SUBMIT_TITLE = "scaffold_submitTitle";
const KEY_FOREPERSON = "scaffold_foreperson";
const KEY_HELPER = "scaffold_helper";
const KEY_ID = "scaffold_id";
const KEY_IDS = "scaffold_ids";
const METHOD_POST = "post";
const METHOD_GET = "get";
const SMARTY_SCAFFOLD = "scaffold";
const DEFAULT_SCAFFOLD_TEMPLATE = "Scaffold.tpl";
}
?>
ficus/pages/scaffold/ListScaffoldForeperson.php 100644 1751 144 4063 10647425604 15412 ISHITOYA Kentaro
* @version $Id: ListScaffoldForeperson.php 14 2007-07-18 14:55:12Z ishitoya $
*/
require_once("ficus/pages/AbstractPage.php");
require_once("ficus/config/Registry.php");
require_once("ficus/db/s2dao/models/serializer/S2DaoArrayEntityDeserializer.php");
require_once("common/AbstractPage.php");
/**
* @class Ficus_ListScaffoldForeperson
*/
class Ficus_ListScaffoldForeperson extends Ficus_AbstractScaffoldForeperson{
/**
* do default
*/
public function doDefault(){
$dto = $this->mediator->daoManager()->getPagerDto($args);
$helper = new S2Dao_PagerViewHelper($dto);
$entities =
$this->mediator->daoManager()->dao()->getWithCondition($dto);
$container = $this->mediator->getContainer($entities);
$organizer =
$this->mediator->organizerFactory()->createListOrganizer();
$organizer->setItemTemplate("itemWithMenu");
$organizer->setRowTemplate("rowWithMenu");
$organizer->setHeaderTemplate("headerWithMenu");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$this->mediator->smarty()->assign(self::KEY_HELPER, $helper);
return $container->build();
}
}
?>
ficus/pages/scaffold/ScaffoldPage.php 100644 1751 144 12737 10647426442 13340 ISHITOYA Kentaro
* @version $Id: ScaffoldPage.php 15 2007-07-18 15:02:48Z ishitoya $
*/
require_once("ficus/pages/BufferedPage.php");
/**
* @class Ficus_Page
*/
abstract class Ficus_ScaffoldPage extends Ficus_BufferedPage
implements Ficus_ScaffoldConstants{
protected $manager = null;
protected $target = null;
protected $foreperson = null;
/**
* on called
* @param $mode string name of mode
* @param $args array of args of do method
*/
protected function onDo($mode, $args){
if(($action = $this->isScaffoldAction($mode))){
Ficus_PageComponentFactory::getSmarty()->addPath(self::SMARTY_SCAFFOLD, Ficus_Dir::normalize(Ficus_File::currentDir() . "/templates"));
if(empty($this->target)){
if($this->request->has(self::KEY_TARGET)){
$this->target =
$this->request->extractAsString(self::KEY_TARGET);
}else{
throw new Ficus_NotReadyException("scaffold action needs target table, set " . self::KEY_TARGET . "parameter or set target property.");
}
}
$this->foreperson = strtolower($action);
$action = $this->getScaffoldAction($action);
$this->setNextAction($action);
$this->manager = new Ficus_ScaffoldManager($this);
}
}
/**
* exec scaffold
*/
protected function buildScaffold(){
$scaffold = $this->manager->organize();
$this->assign(self::SMARTY_SCAFFOLD, $scaffold);
}
/**
* on execute finished
* @param $mode string name of mode
* @param $args array of args of do method
* @param $result mixed switch
*/
protected function onDone($mode, $args, $result){
if($this->isScaffoldAction($mode) &&
$result == self::MODE_TEMPLATE){
$this->buildScaffold();
$mode = $this->foreperson;
$template = $this->getModeTemplate($mode);
if(Ficus_PageComponentFactory::getSmarty()
->isTemplateExists($template)){
return parent::onDone($mode, $args, $template);
}else{
return parent::onDone($mode, $args,
self::DEFAULT_SCAFFOLD_TEMPLATE);
}
}
return parent::onDone($mode, $args, $result);
}
/**
* scaffold
*/
protected function execScaffoldAction($arg){
$result = $this->dispatchScaffoldEvent($args);
if(is_null($result)){
return self::MODE_TEMPLATE;
}
}
/**
* do new
*/
public function __call($name, $args){
if($this->methodExists($name) &&
preg_match('/^doScaffold.*$/', $name)){
return $this->execScaffoldAction($args);
}
return parent::__call($name, $args);
}
/**
* check for method existance
*/
protected function methodExists($method){
if(preg_match('/^doScaffold(.*)$/', $method, $regs)){
$action = strtolower($regs[1]);
if($action == self::ACTION_NEW || $action == self::ACTION_EDIT ||
$action == self::ACTION_LIST || $action == self::ACTION_VIEW ||
$action == self::ACTION_DELETE){
return true;
}
}
return parent::methodExists($method);
}
/**
* get modes
*/
public function getModes(){
$modes = parent::getModes();
$modes[] = $this->getScaffoldAction(self::ACTION_NEW);
$modes[] = $this->getScaffoldAction(self::ACTION_EDIT);
$modes[] = $this->getScaffoldAction(self::ACTION_DELETE);
$modes[] = $this->getScaffoldAction(self::ACTION_VIEW);
$modes[] = $this->getScaffoldAction(self::ACTION_LIST);
return $modes;
}
/**
* get action
*/
protected function getScaffoldAction($action){
return self::ACTION_PREFIX . ucfirst($action);
}
/**
* is scaffold action
*/
protected function isScaffoldAction($mode){
if(preg_match('/^' . self::ACTION_PREFIX . '(.*)$/', $mode, $regs)){
return $regs[1];
}
return false;
}
/**
* call event handler
*/
protected function dispatchScaffoldEvent($args){
$do = $this->manager->formBean()->do();
$methodDefault = "onDoScaffold" . ucfirst($this->foreperson);
$method = $methodDefault . ucfirst($do);
if(method_exists($this, $method)){
return $this->{$method}($args);
}
if(method_exists($this, $methodDefault)){
return $this->{$methodDefault}($args);
}
return null;
}
}
?>
ficus/pages/scaffold/ScaffoldComponentFactory.php 100644 1751 144 5731 10647426442 15732 ISHITOYA Kentaro
* @version $Id: ScaffoldComponentFactory.php 15 2007-07-18 15:02:48Z ishitoya $
*
* Scaffold component factory
*/
require_once("ficus/io/File.php");
require_once("ficus/config/Registry.php");
/**
* @class Ficus_ScaffoldComponentFactory
*/
class Ficus_ScaffoldComponentFactory extends Ficus_S2ContainerComponentFactory{
const KEY_SMARTY = "scaffoldSmarty";
/**
* dicon file name registry key
*/
const REGISTRY_DICON_FILENAME = "scaffold.dicon";
/**
* dicon namespace registry key
*/
const REGISTRY_DICON_NAMESPACE = "scaffold.namespace";
/**
* Default dicon file name.
*/
const DEFAULT_DICON_FILENAME = 'scaffold.dicon';
/**
* dicon namespace.
*/
const DEFAULT_DICON_NAMESPACE = 'scaffold.scheme';
/**
* get Dicon file name from registry
* @return string dicon filename
*/
protected function getDiconFileNameRegistry(){
return self::REGISTRY_DICON_FILENAME;
}
/**
* get Dicon namespace from registry
* @return string dicon namespace
*/
protected function getDiconNameSpaceRegistry(){
return self::REGISTRY_DICON_NAMESPACE;
}
/**
* get dicon file name
* @return string dicon file name
*/
protected function getDefaultDiconFileName(){
return Ficus_File::currentDir()
->resolve(self::DEFAULT_DICON_FILENAME)->getPath();
}
/**
* get defoult dicon namespace
* @return string dicon namespace
*/
protected function getDefaultDiconNameSpace(){
return self::DEFAULT_DICON_NAMESPACE;
}
/**
* get component
* @param $name string name of component
* @param $class string class name
* @return Ficus_ScaffoldComponentFactory
*/
public static function getComponent($name, $class = __CLASS__){
return parent::getComponent($name, $class);
}
/**
* Get smarty
*
* @param $name string component name.
* @return mixed component.
*/
public static function getSmarty() {
return self::getComponent(self::KEY_SMARTY);
}
}
?>
ficus/pages/scaffold/container/ScaffoldPart.php 100644 1751 144 2264 10645132217 15316 ISHITOYA Kentaro
* @version $Id: ScaffoldPart.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_ScaffoldPart
*/
interface Ficus_ScaffoldPart{
/**
* organize
* @param $organizer Ficus_ScaffoldOrganizer organizer
*/
public function accept($organizer);
}
?> ficus/pages/scaffold/container/ScaffoldPartsContainer.php 100644 1751 144 2346 10645132217 17345 ISHITOYA Kentaro
* @version $Id: ScaffoldPartsContainer.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_ScaffoldPartsContainer
*/
interface Ficus_ScaffoldPartsContainer extends Ficus_ScaffoldPart{
/**
* organize
*/
public function build();
}
?>
ficus/pages/scaffold/container/ConcreteScaffoldPartsContainer.php 100644 1751 144 6705 10645132217 21033 ISHITOYA Kentaro
* @version $Id: ConcreteScaffoldPartsContainer.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_ConcreteScaffoldPartsContainer
*/
class Ficus_ConcreteScaffoldPartsContainer extends Ficus_Bean
implements Ficus_S2DaoModelConstants, Ficus_ScaffoldPartsContainer{
/**
* entity
*/
protected $entity = null;
/**
* @var organizers
*/
protected $organizers = array();
/**
* @var parts
*/
protected $parts = array();
/**
* constructor
*/
public function __construct($entity){
$this->entity = $entity;
}
/**
* organize
*/
public function build(){
$result = "";
foreach($this->organizers as $organizer){
$organizer->startVisit($this);
$this->accept($organizer);
$organizer->endVisit($this);
$result .= $organizer->result();
}
return $result;
}
/**
* organize
* @param $organizer Ficus_ScaffoldOrganizer organizer
*/
public function accept($organizer){
foreach($this->parts as $part){
$organizer->visit($part);
}
}
/**
* returns part
* @param $property string name to get
* @return Ficus_ScaffoldPart part
*/
public function get($property){
if($this->has($property)){
return $this->parts[$property];
}else{
throw new Ficus_PropertyNotFoundException("property $property is not found");
}
}
/**
* has
* @params $property string property name to check
* @return boolean true if exists
*/
public function has($property){
if(array_key_exists($property, $this->parts)){
return true;
}
return parent::has($property);
}
const METHOD_SIGNATURE = '/^(get|has)(.*?)$/';
/**
* get property
* @param $name string method name
* @param $arguments array of arguments
*/
public function __call($name, $arguments){
if(preg_match(self::METHOD_SIGNATURE, $name, $regs)){
$property = trim($regs[2]);
if(empty($regs[1]) == false){
$operation = trim($regs[1]);
}
if($operation == "get"){
return $this->get($property);
}else if($operation == "has"){
return $this->has($property);
}
}
return parent::__call($name, $arguments);
}
}
?>
ficus/pages/scaffold/container/ScaffoldPartsContainerList.php 100644 1751 144 5247 10645132217 20204 ISHITOYA Kentaro
* @version $Id: ScaffoldPartsContainerList.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_ScaffoldPartsContainerList
*/
class Ficus_ScaffoldPartsContainerList extends Ficus_Bean
implements Ficus_S2DaoModelConstants, Ficus_ScaffoldPartsContainer{
/**
* @var container
*/
protected $organizers = array();
/**
* @var parts
*/
protected $containers = array();
/**
* organize
*/
public function build(){
$result = "";
foreach($this->organizers as $organizer){
$organizer->startVisit($this);
$this->accept($organizer);
$organizer->endVisit($this);
$result .= $organizer->result();
}
return $result;
}
/**
* organize
* @param $organizer Ficus_ScaffoldOrganizer organizer
*/
public function accept($organizer){
foreach($this->containers as $container){
$container->addOrganizers($organizer);
$container->build($organizer);
$container->clearOrganizers();
}
}
/**
* returns part
* @param $name string name to get
* @return Ficus_ScaffoldPart part
*/
public function get($index){
if($this->has($index)){
return $this->containers[$index];
}else{
throw new Ficus_PropertyNotFoundException("property $property is not found");
}
}
/**
* has
* @params $property string property name to check
* @return boolean true if exists
*/
public function has($index){
if(array_key_exists($index, $this->containers)){
return true;
}
return parent::has($index);
}
}
?>
ficus/pages/scaffold/container/ScaffoldPartsFactory.php 100644 1751 144 3127 10645132217 17030 ISHITOYA Kentaro
* @version $Id: ScaffoldPartsFactory.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
/**
* @class Ficus_ScaffoldPartsFactory
*/
class Ficus_ScaffoldPartsFactory
implements Ficus_S2DaoModelConstants{
const SUFFIX = "ScaffoldPart";
const PACKAGE = "interface.";
/**
* create part
* @param $context string context
* @param $property string property name
* @param $type string type of part
* @param $datatype string datatype of part
* @return Ficus_ScaffoldPart part
*/
public static function create($property, $type, $datatype){
$component = self::PACKAGE . "Ficus_Concrete" . self::SUFFIX;
$component = Ficus_ClassLoader::load($component);
return $component;
}
}
?> ficus/pages/scaffold/container/AbstractScaffoldPart.php 100644 1751 144 5036 10645132217 17002 ISHITOYA Kentaro
* @version $Id: AbstractScaffoldPart.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_AbstractScaffoldPart
*/
abstract class Ficus_AbstractScaffoldPart extends Ficus_Bean
implements Ficus_S2DaoModelConstants, Ficus_ScaffoldPart{
const TEMPLATE_PREFIX = "common/scaffold/";
const TEMPLATE_EXTENSION = ".tpl";
protected $name;
protected $type;
protected $value;
protected $label;
protected $remark;
protected $template = null;
protected $parts = array();
protected static $smarty = null;
protected function prefix(){
return self::TEMPLATE_PREFIX;
}
protected function template(){
if(is_null($this->template)){
$classname = get_class($this);
$tempalte = substr($classname, strpos($classname, _));
return $this->prefix() . $template . self::TEMPLATE_EXTENSION;
}else{
return $this->prefix() . $this->template .
self::TEMPLATE_EXTENSION;
}
}
public function onBuild(){
if(is_null(self::$smarty)){
self::$smarty = Ficus_PageComponentFactory::getSmarty();
}
self::$smarty->assign("part", $this);
}
public function fetch(){
$this->onDisplay();
return self::$smarty->fetch($this->template());
}
public function display(){
$this->onDisplay();
self::$smarty->display($this->template());
}
public function isComposite(){
if(empty($this->parts)){
return false;
}
return true;
}
}
?>
ficus/pages/scaffold/container/ConcreteScaffoldPart.php 100644 1751 144 5454 10647425603 17013 ISHITOYA Kentaro
* @version $Id: ConcreteScaffoldPart.php 14 2007-07-18 14:55:12Z ishitoya $
*
*/
require_once("ficus/beans/Bean.php");
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
/**
* @class Ficus_ConcreteScaffoldPart
*/
class Ficus_ConcreteScaffoldPart extends Ficus_Bean
implements Ficus_S2DaoModelConstants, Ficus_ScaffoldPart{
/**
* parent
*/
protected $parent;
/**
* entity name
*/
protected $entity;
/**
* name of part
*/
protected $name;
/**
* type of part
*/
protected $type;
/**
* validators
*/
protected $validators = array();
/**
* constraint
*/
protected $constraint = array();
/**
* value of the part
*/
protected $value;
/**
* label of the part
*/
protected $label;
/**
* remark of the part
*/
protected $remark;
/**
* settings
*/
protected $settings;
/**
* composite parts
*/
protected $parts = array();
/**
* organize
* @param $organizer Ficus_ScaffoldOrganizer organizer
*/
public function accept($organizer){
$organizer->visit($this);
}
/**
* check is composite part
* @return boolean true if composite
*/
public function isComposite(){
if(empty($this->parts)){
return false;
}
return true;
}
/**
* returns qualified name
* @return string name
*/
public function qname(){
if($this->hasParent()){
return $this->parent->qname() . "__" . get_class($this->entity) . "_" . $this->name;
}else{
return get_class($this->entity) . "_" . $this->name;
}
}
/**
* check has parent
* @return boolean true if has parent
*/
public function hasParent(){
if(is_null($this->parent)){
return false;
}
return true;
}
}
?>
ficus/pages/scaffold/ScaffoldConfiguration.php 100644 1751 144 7310 10647426442 15242 ISHITOYA Kentaro
* @version $Id: ScaffoldConfiguration.php 15 2007-07-18 15:02:48Z ishitoya $
*
*/
/**
* @class Ficus_ScaffoldConfiguration
*/
class Ficus_ScaffoldConfiguration implements Ficus_ScaffoldConstants{
/**
* $settings array scaffold settings
*/
protected $settings = array();
/**
* $tables Ficus_ScaffoldTableConfiguration
*/
protected $tables = array();
/**
* constructor
*/
public function __construct($settings){
if(isset($settings[self::REGISTRY_TABLESETTINGS]) == false){
throw new Ficus_IllegalArgumentException("settings must have TableSettings field");
}
foreach($settings[self::REGISTRY_TABLESETTINGS] as $name => $setting){
$this->tables[$name] = $this->createTableConfiguration($setting);
}
}
/**
* get table settings
* @param $name string name of table
* @return Ficus_ScaffoldTableConfiguration
*/
public function table($name){
if(isset($this->tables[$name])){
return $this->tables[$name];
}else{
throw new Ficus_IllegalArgumentException("table $name is not found");
}
}
/**
* create Ficus_ScaffoldTableConfiguration from array
* @param $settings array of settings
* @return Ficus_ScaffoldTableConfiguration configuration
*/
protected function createTableConfiguration($settings){
$config = new Ficus_ScaffoldTableConfiguration();
if(isset($settings[self::REGISTRY_EXCLUDES])){
foreach($settings[self::REGISTRY_EXCLUDES] as $table => $column){
if(is_array($column)){
foreach($column as $prop){
$config->addExcludeProperty($table, $prop);
}
}else{
$config->addExcludeProperty($table, $column);
}
}
}
if(isset($settings[self::REGISTRY_NOLABELS])){
foreach($settings[self::REGISTRY_NOLABELS] as $table => $column){
$config->addNoLabelProperty($table, $column);
}
}
if(isset($settings[self::REGISTRY_DEFAULTS])){
foreach($settings[self::REGISTRY_DEFAULTS] as $column => $value){
$config->addDefaultValues($column, $value);
}
}
if(isset($settings[self::REGISTRY_PARENT])){
$config->setParentPart($settings[self::REGISTRY_PARENT]);
}
if(isset($settings[self::REGISTRY_TRANSITION])){
$config->setTransitions($settings[self::REGISTRY_TRANSITION]);
}
if(isset($settings[self::REGISTRY_PROPERTIES])){
$config->setProperties($settings[self::REGISTRY_PROPERTIES]);
}
if(isset($settings[self::REGISTRY_NOCHILDREN])){
$config->setNoChildren(true);
}
return $config;
}
}
?>
ficus/pages/scaffold/ViewScaffoldForeperson.php 100644 1751 144 3433 10647425604 15411 ISHITOYA Kentaro
* @version $Id: ViewScaffoldForeperson.php 14 2007-07-18 14:55:12Z ishitoya $
*/
require_once("ficus/pages/AbstractPage.php");
require_once("ficus/config/Registry.php");
require_once("common/AbstractPage.php");
/**
* @class Ficus_ViewScaffoldForeperson
*/
class Ficus_ViewScaffoldForeperson extends Ficus_AbstractScaffoldForeperson{
/**
* view
* @param $args array of arguments
*/
public function doDefault(){
$id = $this->mediator->request()->extractAsInt(self::KEY_ID);
$entity = $this->mediator->daoManager()->getSingleEntity($id);
$container = $this->mediator->getContainer($entity);
$organizer =
$this->mediator->organizerFactory()->createViewOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
return $container->build();
}
}
?>
ficus/pages/scaffold/ScaffoldForeperson.php 100644 1751 144 2236 10647426442 14557 ISHITOYA Kentaro
* @version $Id: ScaffoldForeperson.php 15 2007-07-18 15:02:48Z ishitoya $
*/
require_once("ficus/config/Registry.php");
/**
* @interface ScaffoldForeperson
*/
interface Ficus_ScaffoldForeperson{
/**
* organaize scaffold
* @return string organized result
*/
public function organize();
}
?>
ficus/pages/scaffold/DeleteScaffoldForeperson.php 100644 1751 144 4513 10647425604 15701 ISHITOYA Kentaro
* @version $Id: DeleteScaffoldForeperson.php 14 2007-07-18 14:55:12Z ishitoya $
*/
require_once("ficus/pages/AbstractPage.php");
require_once("ficus/config/Registry.php");
/**
* @class Ficus_DeleteScaffoldForeperson
*/
class Ficus_DeleteScaffoldForeperson extends Ficus_AbstractScaffoldForeperson{
/**
* delete
*/
public function doDefault(){
$ids = $this->mediator->request()->extractAsInt(self::KEY_IDS);
$entities = $this->mediator->daoManager()->getEntities($ids);
$container = $this->mediator->getContainer($entities);
$organizer =
$this->mediator->organizerFactory()->createListOrganizer();
$organizer->setItemTemplate("item");
$organizer->setRowTemplate("row");
$organizer->setHeaderTemplate("header");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$this->mediator->smarty()->assign(self::KEY_IDS, $ids);
$this->mediator->formBean()->setDo(self::DO_SUBMIT);
return $container->build();
}
/**
* delete submit
*/
public function doSubmit(){
$ids = $this->mediator->request()->extractAsString(self::KEY_IDS);
$dao = $this->mediator->daoManager()->dao();
$entity = $dao->entity();
foreach($ids as $id){
$entity->setId($id);
$dao->delete($entity);
}
$this->mediator->smarty()->assign(self::KEY_IDS, $ids);
return "";
}
}
?>
ficus/pages/scaffold/ScaffoldFormBean.php 100644 1751 144 3741 10647426442 14130 ISHITOYA Kentaro
* @version $Id: ScaffoldFormBean.php 15 2007-07-18 15:02:48Z ishitoya $
*
*/
require_once("ficus/db/s2dao/models/S2DaoModelConstants.php");
require_once("ficus/db/s2dao/models/S2DaoDataAccessObject.php");
/**
* @class Ficus_ScaffoldFormBean
*/
class Ficus_ScaffoldFormBean extends Ficus_Bean
implements Ficus_ScaffoldConstants{
/**
* $page string form action
*/
protected $page = null;
/**
* $method string form method post or get
*/
protected $method = self::METHOD_POST;
/**
* $action string page's action, not a scaffold action
*/
protected $action = null;
/**
* $target string target table name
*/
protected $target = null;
/**
* $do string scaffold's action.
*/
protected $do = null;
/**
* $submitTitle string submit button value
*/
protected $submitTitle = self::SUBMIT_TITLE;
/**
* $transition string transition
*/
protected $transition = null;
/**
* $foreperson string foreperson
*/
protected $foreperson = null;
/**
* $message string message
*/
protected $message = null;
}
?>
ficus/pages/scaffold/components21.dtd 100644 1751 144 2773 10645120161 13300
ficus/pages/scaffold/NewScaffoldForeperson.php 100644 1751 144 7565 10647425604 15242 ISHITOYA Kentaro
* @version $Id: NewScaffoldForeperson.php 14 2007-07-18 14:55:12Z ishitoya $
*/
require_once("ficus/config/Registry.php");
/**
* @class Ficus_NewScaffoldForeperson
*/
class Ficus_NewScaffoldForeperson extends Ficus_AbstractScaffoldForeperson{
/**
* new
* @param $args array of arguments
*/
public function doDefault(){
if(is_null($this->mediator->entity())){
$entity = $this->mediator->daoManager()->entity();
}else{
$entity = $this->mediator->entity();
}
return $this->buildNew($entity);
}
/**
* new
* @param $args array of arguments
*/
public function doChildren(){
$entity = $this->mediator->getEntityFromRequest();
return $this->buildNew($entity);
}
/**
* new
* @param $args array of arguments
*/
public function doConfirm(){
$entity = $this->mediator->getEntityFromRequest();
$container = $this->mediator->getContainer($entity);
$organizer =
$this->mediator->organizerFactory()->createViewOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$container->addOrganizers(
$this->mediator->organizerFactory()->createHiddenOrganizer());
$this->mediator->formBean()->setDo(self::DO_SUBMIT);
return $container->build();
}
/**
* new
* @param $args array of arguments
*/
public function doSubmit(){
$entity = $this->mediator->getEntityFromRequest();
$container = $this->mediator->getContainer($entity);
$organizer =
$this->mediator->organizerFactory()->createViewOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$entity->insert();
return $container->build();
}
/**
* buildNew
*/
protected function buildNew($entity){
$transition = null;
if($this->mediator->request()->has(self::KEY_TRANSITION)){
$transition = $this->mediator->request()->extractAsString(
self::KEY_TRANSITION);
$this->mediator->table()->setCurrentTransition($transition);
}
$container = $this->mediator->getContainer($entity);
$organizer = $this->mediator->organizerFactory()->createNewOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$transition = $this->mediator->table()->getNextTransition($transition);
if($transition == null){
$this->mediator->formBean()->setDo(self::DO_CONFIRM);
}else{
$this->mediator->formBean()->setDo(self::DO_CHILDREN);
$this->mediator->formBean()->setTransition($transition);
}
return $container->build();
}
}
?>
ficus/pages/scaffold/AbstractScaffoldForeperson.php 100644 1751 144 3725 10645132217 16237 ISHITOYA Kentaro
* @version $Id: AbstractScaffoldForeperson.php 2 2007-07-11 10:37:48Z ishitoya $
*/
require_once("ficus/config/Registry.php");
/**
* @class Ficus_AbstractScaffoldForeperson
*/
abstract class Ficus_AbstractScaffoldForeperson
implements Ficus_ScaffoldForeperson, Ficus_ScaffoldConstants{
protected $mediator = null;
/**
* constructor
*/
public function __construct($mediator){
$this->mediator = $mediator;
}
/**
* invoke
*/
protected function invoke(){
if($this->mediator->request()->has(self::KEY_DO)){
$key = $this->mediator->request()->extractAsString(self::KEY_DO);
}else{
$key = self::DO_DEFAULT;
}
$method = self::METHOD_PREFIX . ucfirst($key);
if(method_exists($this, $method) == false){
throw new Ficus_IllegalArgumentException("method $method is not implemented");
}
return $this->{$method}();
}
/**
* organaize scaffold
* @return string organized result
*/
public function organize(){
return $this->invoke();
}
}
?>
ficus/pages/scaffold/organizer/ScaffoldOrganizer.php 100644 1751 144 2172 10645132217 16364 ISHITOYA Kentaro
* @version $Id: ScaffoldOrganizer.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
/**
* @class Ficus_ScaffoldOrganizer
*/
interface Ficus_ScaffoldOrganizer{
/**
* visit part
* @param $part Ficus_ScaffoldPart part
*/
public function visit($part);
}
?> ficus/pages/scaffold/organizer/ListScaffoldOrganizer.php 100644 1751 144 12770 10646126775 17262 ISHITOYA Kentaro
* @version $Id: ListScaffoldOrganizer.php 7 2007-07-14 10:55:18Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_ListScaffoldOrganizer
*/
class Ficus_ListScaffoldOrganizer
extends Ficus_AbstractScaffoldOrganizer{
const TEMPLATE_PREFIX = "list/";
protected $rowTemplate = "";
protected $headerTemplate = "";
protected $header = "";
protected $rows = array();
/**
* prefix
* @return string template prefix
*/
public function prefix(){
return parent::prefix() . self::TEMPLATE_PREFIX;
}
/**
* on visit
* @param $part Ficus_ScaffoldPart part
*/
protected function onVisit($part){
$config = $this->mediator->table();
$entityName = $part->entity()->getEntityName();
if($part->type() == self::TYPE_DIRECT){
return;
}
if($config->isExcludeProperty($part)){
return;
}
$value = null;
if($part->value() instanceof Ficus_S2DaoEntity){
if($part->type() == self::TYPE_LIST){
$key = $part->value()->name();
if(is_null($key)){
$value = "";
}else{
$value = $part->value()->names($part->value()->name());
}
}else if($template =
Ficus_ScaffoldTemplateParser::getTemplate($part)){
$value =
Ficus_ScaffoldTemplateParser::parse($template, $part);
}else{
$value = $this->getChildren($part);
}
}else{
$value = $part->value();
}
$this->assign("part", $part);
$this->assign("value", $value);
return $this->fetch($this->itemTemplate);
}
/**
* start visit
* @param $container Ficus_ScaffoldPartsContainer
*/
public function startVisit($container){
if($container instanceof Ficus_ScaffoldPartsContainerList){
if($container->isEmptyContainers()){
return;
}
$container = $container->get(0);
$parts = $container->parts();
$this->assign("delete", "delete");
$this->header = $this->createHeader($parts);
$this->clear("delete");
}
}
/**
* end visit
* @param $container Ficus_ScaffoldPartsContainer
*/
public function endVisit($container){
if($container instanceof Ficus_ConcreteScaffoldPartsContainer){
$this->assign("entity", $container->entity());
$this->assign("result", $this->result);
$result = $this->fetch($this->rowTemplate);
$this->rows[] = $result;
$this->result = "";
}else if($container instanceof Ficus_ScaffoldPartsContainerList){
$this->assign("header", $this->header);
$this->assign("rows", $this->rows);
$this->addResult($this->fetch($this->entityTemplate));
}
}
/**
* create header
* @param $parts array of interface part
* @return string header
*/
protected function createHeader($parts){
$labels = array();
$config = $this->mediator->table();
foreach($parts as $part){
if($config->isExcludeProperty($part)){
continue;
}
if($part->type() == self::TYPE_DIRECT){
continue;
}
$labels[] = $part->label();
}
$this->assign("labels", $labels);
return $this->fetch($this->headerTemplate);
}
/**
* get child
*/
protected function getChildren($part){
$input = "";
foreach($part->parts() as $child){
$result = $this->result;
$this->result = "";
$child->accept($this);
$input .= $this->result;
$this->result = $result;
$this->assign("nolabel", false);
}
$this->clear("entity");
$this->assign("result", $input);
$row = $this->fetch($this->rowTemplate);
$rows = array();
$rows[] = $row;
$this->assign("header", $this->createHeader($part->parts()));
$this->assign("rows", $rows);
return $this->fetch($this->entityTemplate);
}
/*
* set header template
* @param $headerTemplate string template file name
*/
public function setHeaderTemplate($headerTemplate){
$this->headerTemplate = $headerTemplate;
}
/*
* set row template
* @param $headerTemplate string template file name
*/
public function setRowTemplate($rowTemplate){
$this->rowTemplate = $rowTemplate;
}
}
?> ficus/pages/scaffold/organizer/NewScaffoldOrganizer.php 100644 1751 144 11342 10647425604 17064 ISHITOYA Kentaro
* @version $Id: NewScaffoldOrganizer.php 14 2007-07-18 14:55:12Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_NewScaffoldOrganizer
*/
class Ficus_NewScaffoldOrganizer
extends Ficus_AbstractScaffoldOrganizer{
const TEMPLATE_PREFIX = "form/";
/**
* @var $hiddens array hidden parts
*/
protected $hiddens = array();
/**
* prefix
* @return string template prefix
*/
public function prefix(){
return parent::prefix() . self::TEMPLATE_PREFIX;
}
/**
* on visit
* @param $part Ficus_ScaffoldPart part
*/
protected function onVisit($part){
$config = $this->mediator->table();
$entityName = $part->entity()->getEntityName();
if($part->type() == self::TYPE_DIRECT &&
$part->value() == null){
if(($value = $config->getDefaultValue($part)) !== null){
$part->setValue($value);
}
$this->hiddens[] = $part;
return;
}
if($config->isExcludeProperty($part) &&
$config->isTransitionParentProperty($part) == false){
$this->hiddens[] = $part;
return;
}
$input = null;
if($config->isTransitionParentProperty($part)){
$input = $this->getChildren($part);
}else if($part->value() instanceof Ficus_S2DaoEntity){
if($part->type() == self::TYPE_LIST){
$key = $part->value()->name();
if(is_null($key)){
$key = $config->getDefaultValue($part);
}
$this->assign("qname", $part->qname());
$this->assign("items", $part->value()->names());
$this->assign("selected", $key);
$input = $this->fetch("select");
}else if($config->isNoChildren()){
return;
}else{
$input = $this->getChildren($part);
}
}else{
$this->assign("qname", $part->qname());
$this->assign("value", $part->value());
$this->assign("validators", $part->validators());
$input =
$this->fetch("input");
}
if($config->isTransitionProperty($part) == false &&
$config->isTransitionParentProperty($part) == false){
$this->hiddens[] = $part;
return;
}
if($config->isNoLabelProperty($part)){
$this->assign("nolabel", true);
}
$this->assign("qname", $part->qname());
$this->assign("label", $part->label());
$this->assign("validators", $part->validators());
$this->assign("input", $input);
return $this->fetch($this->itemTemplate);
}
/**
* get child
*/
protected function getChildren($part){
$input = "";
$result = $this->result;
foreach($part->parts() as $child){
$this->result = "";
$child->accept($this);
$input .= $this->result;
$this->assign("nolabel", false);
}
$this->result = $result;
$this->assign("result", $input);
return $this->fetch($this->entityTemplate);
}
/**
* on end visit
* @param $container Ficus_ScaffoldPartsContainer
*/
protected function onEndVisit($container){
foreach($this->hiddens as $hidden){
$this->showHidden($hidden);
}
}
/**
* show hidden
*/
protected function showHidden($hidden){
if($hidden->value() instanceof Ficus_S2DaoEntity){
foreach($hidden->parts() as $part){
$this->addResult($this->showHidden($part));
}
return;
}
$this->assign("qname", $hidden->qname());
$this->assign("value", $hidden->value());
$this->addResult($this->fetch("hidden"));
}
}
?> ficus/pages/scaffold/organizer/ScaffoldOrganizerFactory.php 100644 1751 144 5242 10645132217 17715 ISHITOYA Kentaro
* @version $Id: ScaffoldOrganizerFactory.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
/**
* @class Ficus_ScaffoldOrganizerFactory
*/
class Ficus_ScaffoldOrganizerFactory implements Ficus_S2DaoModelConstants{
const SUFFIX = "ScaffoldPart";
const PACKAGE = "interface.";
/**
* mediator
*/
protected $mediator = null;
/**
* constructor
* @param $mediator Ficus_ScaffoldMediator mediator
*/
public function __construct($mediator){
$this->mediator = $mediator;
}
/**
* get Organizer
*/
public function create($context){
$classname = "Ficus_" . $context . "ScaffoldOrganizer";
$organizer = new $classname($this->mediator);
return $organizer;
}
/**
* get View Organizer
* @return Ficus_ViewInterfaceOrganizer view organizer
*/
public function createViewOrganizer(){
return $this->create("View");
}
/**
* create List Organizer
* @return Ficus_ListInterfaceOrganizer list organizer
*/
public function createListOrganizer(){
return $this->create("List");
}
/**
* create Edit Organizer
* @return Ficus_EditInterfaceOrganizer edit organizer
*/
public function createEditOrganizer(){
return $this->create("Edit");
}
/**
* create New Organizer
* @return Ficus_NewInterfaceOrganizer new organizer
*/
public function createNewOrganizer(){
$organizer = $this->create("New");
$organizer->mediator()->table()->addExcludeProperty("*", "id");
return $organizer;
}
/**
* create Hidden Organizer
* @return Ficus_HiddenInterfaceOrganizer hidden organizer
*/
public function createHiddenOrganizer(){
return $this->create("Hidden");
}
}
?> ficus/pages/scaffold/organizer/ViewScaffoldOrganizer.php 100644 1751 144 6154 10645132217 17223 ISHITOYA Kentaro
* @version $Id: ViewScaffoldOrganizer.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_ViewScaffoldOrganizer
*/
class Ficus_ViewScaffoldOrganizer
extends Ficus_AbstractScaffoldOrganizer{
const TEMPLATE_PREFIX = "view/";
/**
* prefix
* @return string template prefix
*/
public function prefix(){
return parent::prefix() . self::TEMPLATE_PREFIX;
}
/**
* on visit
* @param $part Ficus_ScaffoldPart part
*/
protected function onVisit($part){
$config = $this->mediator->table();
$entityName = $part->entity()->getEntityName();
if($part->type() == self::TYPE_DIRECT){
return;
}
if($config->isExcludeProperty($part)){
return;
}
$value = null;
if($part->value() instanceof Ficus_S2DaoEntity){
if($part->type() == self::TYPE_LIST){
$key = $part->value()->name();
if(is_null($key)){
$value = "";
}else{
$value = $part->value()->names($part->value()->name());
}
}else if($template =
Ficus_ScaffoldTemplateParser::getTemplate($part)){
$value =
Ficus_ScaffoldTemplateParser::parse($template, $part);
}else{
$value = $this->getChildren($part);
}
}else{
$value = $part->value();
}
if($config->isNoLabelProperty($part)){
$this->assign("nolabel", true);
}
$this->assign("label", $part->label());
$this->assign("value", $value);
$result = $this->fetch($this->itemTemplate);
$this->addResult($result);
}
/**
* get child
*/
protected function getChildren($part){
$input = "";
foreach($part->parts() as $child){
$result = $this->result;
$this->result = "";
$child->accept($this);
$input = $this->result;
$this->result = $result;
$this->assign("nolabel", false);
}
$this->assign("result", $input);
return $this->fetch($this->entityTemplate);
}
}
?> ficus/pages/scaffold/organizer/HiddenScaffoldOrganizer.php 100644 1751 144 4104 10645132217 17475 ISHITOYA Kentaro
* @version $Id: HiddenScaffoldOrganizer.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_HiddenScaffoldOrganizer
*/
class Ficus_HiddenScaffoldOrganizer
extends Ficus_AbstractScaffoldOrganizer{
const TEMPLATE_PREFIX = "form/";
/**
* prefix
* @return string template prefix
*/
public function prefix(){
return parent::prefix() . self::TEMPLATE_PREFIX;
}
/**
* on visit
* @param $part Ficus_ScaffoldPart part
*/
protected function onVisit($part){
$entityName = $part->entity()->getEntityName();
$this->showHidden($part);
}
/**
* end visit
* @param $container Ficus_ScaffoldPartsContainer
*/
public function endVisit($container){
}
/**
* show hidden
*/
protected function showHidden($hidden){
if($hidden->value() instanceof Ficus_S2DaoEntity){
foreach($hidden->parts() as $part){
$this->showHidden($part);
}
return;
}
$this->assign("qname", $hidden->qname());
$this->assign("value", $hidden->value());
$this->addResult($this->fetch("hidden"));
}
}
?> ficus/pages/scaffold/organizer/EditScaffoldOrganizer.php 100644 1751 144 10250 10647425604 17215 ISHITOYA Kentaro
* @version $Id: EditScaffoldOrganizer.php 14 2007-07-18 14:55:12Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_EditScaffoldOrganizer
*/
class Ficus_EditScaffoldOrganizer
extends Ficus_AbstractScaffoldOrganizer{
const TEMPLATE_PREFIX = "form/";
/**
* @var $hiddens array hidden parts
*/
protected $hiddens = array();
/**
* prefix
* @return string template prefix
*/
public function prefix(){
return parent::prefix() . self::TEMPLATE_PREFIX;
}
/**
* on visit
* @param $part Ficus_ScaffoldPart part
*/
protected function onVisit($part){
$config = $this->mediator->table();
$entityName = $part->entity()->getEntityName();
if($part->type() == self::TYPE_DIRECT){
$this->hiddens[] = $part;
return;
}
if($config->isExcludeProperty($part)){
$this->hiddens[] = $part;
return;
}
$input = null;
if($part->value() instanceof Ficus_S2DaoEntity){
if($part->type() == self::TYPE_LIST){
$this->assign("qname", $part->qname());
$this->assign("items", $part->value()->names());
$this->assign("selected", $part->value()->name());
$input = $this->fetch("select");
}else if($config->isNoChildren()){
return;
}else{
$input = $this->getChildren($part);
}
}else{
$this->assign("qname", $part->qname());
$this->assign("value", $part->value());
$this->assign("validators", $part->validators());
$input = $this->fetch("input");
}
if($config->isTransitionProperty($part) == false){
$this->hiddens[] = $part;
return;
}
if($config->isNoLabelProperty($part)){
$this->assign("nolabel", true);
}
$this->assign("qname", $part->qname());
$this->assign("label", $part->label());
$this->assign("validators", $part->validators());
$this->assign("input", $input);
$this->addResult($this->fetch($this->itemTemplate));
}
/**
* get child
*/
protected function getChildren($part){
$input = "";
$result = $this->result;
foreach($part->parts() as $child){
$this->result = "";
$child->accept($this);
$input .= $this->result;
$this->assign("nolabel", false);
}
$this->result = $result;
$this->assign("result", $input);
return $this->fetch($this->entityTemplate);
}
/**
* on end visit
* @param $container Ficus_ScaffoldPartsContainer
*/
protected function onEndVisit($container){
foreach($this->hiddens as $hidden){
$this->showHidden($hidden);
}
}
/**
* show hidden
*/
protected function showHidden($hidden){
if($hidden->value() instanceof Ficus_S2DaoEntity){
foreach($hidden->parts() as $part){
$this->showHidden($part);
}
return;
}
$this->assign("qname", $hidden->qname());
$this->assign("value", $hidden->value());
$this->addResult($this->fetch("hidden"));
}
}
?> ficus/pages/scaffold/organizer/AbstractScaffoldOrganizer.php 100644 1751 144 11674 10645132217 20077 ISHITOYA Kentaro
* @version $Id: AbstractScaffoldOrganizer.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_AbstractScaffoldOrganizer
*/
abstract class Ficus_AbstractScaffoldOrganizer
implements Ficus_ScaffoldOrganizer, Ficus_S2DaoModelConstants{
const TEMPLATE_SUFFIX = ".tpl";
/**
* itemtemplate
*/
protected $itemTempalte = "";
/**
* entity template
*/
protected $entityTemplate = "";
/**
* result
*/
protected $result = "";
/**
* mediator
*/
protected $mediator = null;
/**
* constructor
* @param $mediator Ficus_ScaffoldMediator mediator
*/
public function __construct($mediator){
$this->mediator = $mediator;
}
/**
* prefix
* @return string template prefix
*/
public function prefix(){
return "";
}
/**
* get template file name
* @param $type string type of template
* @return string template filename
*/
public function template($type){
return $this->prefix() . $type . self::TEMPLATE_SUFFIX;
}
/**
* item template
* @param $template string template
*/
public function setItemTemplate($itemTemplate){
$this->itemTemplate = $itemTemplate;
}
/**
* entity template
* @param $template string template
*/
public function setEntityTemplate($entityTemplate){
$this->entityTemplate = $entityTemplate;
}
/**
* get mediator
*/
public function mediator(){
return $this->mediator;
}
/**
* visit part
* @param $part Ficus_ScaffoldPart part
*/
public function visit($part){
Ficus_Assert::isInstanceOf($part, "Ficus_ScaffoldPart");
$this->mediator->smarty()->clear("value");
$this->mediator->smarty()->clear("qname");
$this->mediator->smarty()->clear("nolabel");
$result = $this->onVisit($part);
$this->addResult($result);
}
/**
* start visit
* @param $container Ficus_ScaffoldPartsContainer
*/
public function startVisit($container){
Ficus_Assert::isInstanceOf($container, "Ficus_ScaffoldPartsContainer");
$this->onStartVisit($container);
}
/**
* end visit
* @param $container Ficus_ScaffoldPartsContainer
*/
public function endVisit($container){
Ficus_Assert::isInstanceOf($container, "Ficus_ScaffoldPartsContainer");
$this->onEndVisit($container);
$this->mediator->smarty()->assign("result", $this->result);
$this->result = $this->fetch($this->entityTemplate);
}
/**
* result
*/
public function result(){
return $this->result;
}
/**
* on visit
* @param $part Ficus_ScaffoldPart part
*/
abstract protected function onVisit($part);
/**
* on start visit
* @param $container Ficus_ScaffoldPartsContainer
*/
protected function onStartVisit($container){
//do nothing
}
/**
* on end visit
* @param $container Ficus_ScaffoldPartsContainer
*/
protected function onEndVisit($container){
//do nothing
}
/**
* add result
*/
protected function addResult($result){
$this->result .= $result;
}
/**
* assign
* @param $name name of variable
* @param $var mixed variable
*/
protected function assign($name, $var){
$this->mediator->smarty()->assign($name, $var);
}
/**
* fetch
* @param $template string template
* @return string result
*/
protected function fetch($type){
return $this->mediator->smarty()->fetch($this->template($type));
}
/**
* display
* @param $template string template
*/
protected function display($type){
$this->mediator->smarty()->fetch($this->display($type));
}
/**
* clear
* @param $name string name of property
*/
protected function clear($name){
$this->mediator->smarty()->clear($name);
}
}
?> ficus/pages/scaffold/EditScaffoldForeperson.php 100644 1751 144 7624 10647425604 15372 ISHITOYA Kentaro
* @version $Id: EditScaffoldForeperson.php 14 2007-07-18 14:55:12Z ishitoya $
*/
require_once("ficus/pages/AbstractPage.php");
require_once("ficus/config/Registry.php");
/**
* @class Ficus_EditScaffoldForeperson
*/
class Ficus_EditScaffoldForeperson extends Ficus_AbstractScaffoldForeperson{
/**
* edit
* @param $args array of arguments
*/
public function doDefault(){
$id = $this->mediator->request()->extractAsInt(self::KEY_ID);
$entity = $this->mediator->daoManager()->getSingleEntity($id);
return $this->buildEdit($entity);
}
/**
* new
* @param $args array of arguments
*/
public function doChildren(){
$entity = $this->mediator->getEntityFromRequest();
return $this->buildNew($entity);
}
/**
* edit confirm
* @param $args array of arguments
*/
public function doConfirm(){
$entity = $this->mediator->getEntityFromRequest();
$container = $this->mediator->getContainer($entity);
$organizer =
$this->mediator->organizerFactory()->createViewOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$container->addOrganizers(
$this->mediator->organizerFactory()->createHiddenOrganizer());
$this->mediator->formBean()->setDo(self::DO_SUBMIT);
return $container->build();
}
/**
* edit submit
* @param $args array of arguments
*/
public function doSubmit(){
$entity = $this->mediator->getEntityFromRequest();
$container = $this->mediator->getContainer($entity);
$organizer =
$this->mediator->organizerFactory()->createViewOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$entity->update();
return $container->build();
}
/**
* buildNew
*/
protected function buildEdit($entity){
$transition = null;
if($this->mediator->request()->has(self::KEY_TRANSITION)){
$transition = $this->mediator->request()->extractAsString(
self::KEY_TRANSITION);
$this->mediator->table()->setCurrentTransition($transition);
}
$container = $this->mediator->getContainer($entity);
$organizer =
$this->mediator->organizerFactory()->createEditOrganizer();
$organizer->setItemTemplate("row");
$organizer->setEntityTemplate("table");
$container->addOrganizers($organizer);
$transition = $this->mediator->table()->getNextTransition($transition);
if($transition == null){
$this->mediator->formBean()->setDo(self::DO_CONFIRM);
}else{
$this->mediator->formBean()->setDo(self::DO_CHILDREN);
$this->mediator->formBean()->setTransition($transition);
}
return $container->build();
}
}
?>
ficus/pages/scaffold/scaffold.dicon 100644 1751 144 532 10645120256 13026
Ficus_Registry::search(Ficus_ScaffoldConstants::REGISTRY_SMARTYCACHE)
ficus/pages/scaffold/builder/ConcreteScaffoldBuilder.php 100644 1751 144 10617 10647425603 17154 ISHITOYA Kentaro
* @version $Id: ConcreteScaffoldBuilder.php 14 2007-07-18 14:55:12Z ishitoya $
*
*/
require_once("ficus/lang/Assert.php");
/**
* @class Ficus_AbstractScaffoldBuilder
*/
class Ficus_ConcreteScaffoldBuilder
implements Ficus_ScaffoldBuilder, Ficus_ScaffoldConstants{
/**
* mediator
*/
protected $mediator = null;
/**
* constructor
* @param $mediator Ficus_ScaffoldMediator mediator
*/
public function __construct($mediator){
$this->mediator = $mediator;
}
/**
* build interface from entity
* @param $entity Ficus_S2DaoEntity entity
*/
public function build($entity){
if($entity instanceof S2Dao_ArrayList){
$list = new Ficus_ScaffoldPartsContainerList();
foreach($entity as $target){
$list->addContainers($this->createContainer($target));
}
return $list;
}else{
return $this->createContainer($entity);
}
}
/**
* create container
* @param $parts array of parts
* @return Ficus_ConcreateScaffoldPartsContainer
*/
protected function createContainer($entity){
Ficus_Assert::isInstanceOf($entity, "Ficus_S2DaoEntity");
$parts = $this->buildParts($entity);
$container = new Ficus_ConcreteScaffoldPartsContainer($entity);
$container->setParts($parts);
return $container;
}
/**
* build parts array
* @param $entity Ficus_S2DaoEntity target entity
* @return array of parts
*/
protected function buildParts($entity){
$reader = new Ficus_S2DaoEntityAnnotationReader($entity);
$settings = $this->mediator->table($entity->getEntityName());
if($settings->isEmptyParentPart("parent") == false){
$settings = $this->mediator->table($settings->parentPart());
}
$settings = $settings->properties();
$reader->sort($settings);
$parts = array();
$properties = $reader->properties();
foreach($properties as $property){
$value = $entity->get($property);
$setting = $settings[$property];
$part = $this->buildPart($reader, $property, $value, $setting);
$parts[$property] = $part;
}
return $parts;
}
/**
* build part
* @param $reader Ficus_S2DaoEntityAnnotationReader reader
* @param $property string property name
* @param $value mixed value
* @return Ficus_ScaffoldPart part
*/
protected function buildPart($reader, $property, $value, $setting){
$type = $reader->type($property);
$label = $reader->label($property);
$remark = $reader->remark($property);
$datatype = $reader->datatype($property);
$validators = $setting[self::REGISTRY_VALIDATORS];
$constraint = $setting[self::REGISTRY_CONSTRAINT];
$part = Ficus_ScaffoldPartsFactory::create(
$property, $type, $datatype);
$part->setEntity($reader->getTarget());
$part->setName($property);
$part->setType($type);
$part->setLabel($label);
$part->setRemark($remark);
$part->setValidators($validators);
$part->setConstraint($constraint);
if($value instanceof Ficus_S2DaoEntity){
$parts = $this->buildParts($value);
foreach($parts as $child){
$child->setParent($part);
}
$part->setParts($parts);
}
$part->setValue($value);
return $part;
}
}
?> ficus/pages/scaffold/builder/ScaffoldBuilder.php 100644 1751 144 2204 10645132217 15434 ISHITOYA Kentaro
* @version $Id: ScaffoldBuilder.php 2 2007-07-11 10:37:48Z ishitoya $
*
*/
/**
* @class Ficus_ScaffoldBuilder
*/
interface Ficus_ScaffoldBuilder{
/**
* build interface from entity
* @param $entity Ficus_S2DaoEntity entity
*/
public function build($entity);
}
?> ficus/pages/scaffold/ScaffoldTableConfiguration.php 100644 1751 144 16016 10647426442 16235 ISHITOYA Kentaro
* @version $Id: ScaffoldTableConfiguration.php 15 2007-07-18 15:02:48Z ishitoya $
*
*/
/**
* @class Ficus_ScaffoldTableConfiguration
*/
class Ficus_ScaffoldTableConfiguration extends Ficus_Bean
implements Ficus_ScaffoldConstants, Ficus_S2DaoModelConstants{
/**
* exclude pattern
*/
protected $excludes = array();
/**
* no label
*/
protected $nolabels = array();
/**
* no children
*/
protected $noChildren = true;
/**
* transitions
*/
protected $transitions = array();
/**
* current Transition
*/
protected $currentTransition = array();
/**
* default values
*/
protected $defaultValues = array();
/**
* property settings
*/
protected $properties = array();
/**
* parent Part
*/
protected $parentPart = null;
/**
* check for exclude
* @param $part Ficus_ScaffoldPart part to check
*/
public function isExcludeProperty($part){
$entityName = $this->getQname($part);
if((isset($this->excludes["*"]) &&
in_array($part->name(), $this->excludes["*"])) ||
(isset($this->excludes[$entityName]) &&
in_array($part->name(), $this->excludes[$entityName])) ||
(isset($this->excludes[$entityName]) &&
$this->excludes[$entityName][0] == "*")){
return true;
}
return false;
}
/**
* check for exclude
* @param $part Ficus_ScaffoldPart part to check
*/
public function isNoLabelProperty($part){
$entityName = $this->getQname($part);
if(array_key_exists($entityName, $this->nolabels) &&
$this->nolabels[$entityName] == $part->name()){
return true;
}
return false;
}
/**
* check for transition property
* @param $part Ficus_ScaffoldPart part to check
*/
public function isTransitionProperty($part){
$entityName = $this->getQname($part);
if(empty($this->currentTransition)){
return true;
}
if($part->value() instanceof Ficus_S2DaoEntity &&
in_array($this->getEntityQname($part), $this->currentTransition)){
return true;
}
if(in_array($entityName, $this->currentTransition) == false){
return false;
}
return true;
}
/**
* check is parent of transition property
*/
public function isTransitionParentProperty($part){
if($part->type() == self::TYPE_FOREIGN){
$parent = $this->getEntityQname($part);
foreach($this->currentTransition as $transition){
if(strpos($transition, $parent) === 0){
return true;
}
}
}
return false;
}
/**
* get default value
* @param $part Ficus_ScaffoldPart part to check
*/
public function getDefaultValue($part){
if($part->type() != self::TYPE_LIST &&
$part->type() != self::TYPE_DIRECT){
return null;
}
$qname = $this->getQname($part) . "." . $part->name();
if(preg_match('/Direct$/', $qname) == false){
$qname .= "Direct";
}
if(isset($this->defaultValues[$qname])){
return $this->defaultValues[$qname];
}
return null;
}
/**
* is no children
*/
public function isNoChildren(){
return $this->noChildren;
}
/**
* ignore parts pattern
* @param $entityname string ignore entity name
* @param $property string when null, ignore class
*/
public function addExcludeProperty($entityname, $property = null){
$this->excludes[$entityname][] = $property;
}
/**
* no label pattern
*/
public function addNoLabelProperty($entityname, $property = null){
$this->nolabels[$entityname] = $property;
}
/**
* set no children
* @param $noChildren boolean set to true, ignore child entities
*/
public function setNoChildren($noChildren){
$this->noChildren = $noChildren;
}
/**
* set transition
* @param $transition string transition
*/
public function setCurrentTransition($transition){
$transition = explode(",", $transition);
$this->currentTransition = array();
foreach($transition as $trans){
$this->currentTransition[] = trim($trans);
}
}
/**
* set transitions
* @param $transitions array transitions
*/
public function setTransitions($transitions){
$this->transitions = $transitions;
}
/**
* set default values
*/
public function addDefaultValues($column, $value){
$this->defaultValues[$column] = $value;
}
/**
* get qname
*/
protected function getQname($part){
$entityName = $part->entity()->getEntityName();
if($part->hasParent()){
$entityName = $this->getQname($part->parent()) . "." . $entityName;
}
return $entityName;
}
/**
* get Entity qname
*/
protected function getEntityQname($part){
if(($part->value() instanceof Ficus_S2DaoEntity) == false){
return "";
}
$entityName = $part->value()->getEntityName();
$qname = $this->getQname($part);
return $qname . "." . $entityName;
}
/**
* get Next transition
* @param $key string current transition, if ommited, return first one
* @return string next transition
*/
public function getNextTransition($key = null){
$transitions = $this->transitions;
if(empty($transitions)){
return false;
}
if(is_null($key)){
return array_shift($transitions);
}else{
reset($transitions);
while($value = each($transitions)){
if($value["value"] == $key){
$next = each($transitions);
if($next == false){
return false;
}
return $next["value"];
}
}
}
return false;
}
}
?>
ficus/pages/scaffold/templates/ScaffoldView.tpl 100644 1751 144 47 10646126775 15320 {$scaffold}
{$scaffold_message}
ficus/pages/scaffold/templates/form/row.tpl 100644 1751 144 122 10645120161 14506
{if $nolabel == false}
{$label} |
{/if}
{$input} |
ficus/pages/scaffold/templates/form/select.tpl 100644 1751 144 517 10645120161 15166
ficus/pages/scaffold/templates/form/input.tpl 100644 1751 144 377 10647425603 15065
ficus/pages/scaffold/templates/form/table.tpl 100644 1751 144 36 10645120161 14752
ficus/pages/scaffold/templates/form/hidden.tpl 100644 1751 144 72 10645120161 15116
ficus/pages/scaffold/templates/list/itemWithMenu.tpl 100644 1751 144 332 10646126775 16353 {if $part->name() == "id"}
{assign var="entity" value=$part->entity()}
{$value} |
{else}
{$value} |
{/if}
ficus/pages/scaffold/templates/list/rowWithMenu.tpl 100644 1751 144 372 10646126775 16230 {$result}
{if $entity !== null}
編集 |
|
{/if}
ficus/pages/scaffold/templates/list/headerWithMenu.tpl 100644 1751 144 206 10645120161 16623
{foreach from=$labels item=label}
{$label} |
{/foreach}
{if $delete}
編集 |
削除 |
{/if}
ficus/pages/scaffold/templates/list/row.tpl 100644 1751 144 24 10645120161 14477 {$result}
ficus/pages/scaffold/templates/list/item.tpl 100644 1751 144 23 10645120161 14625 {$value} |
ficus/pages/scaffold/templates/list/header.tpl 100644 1751 144 117 10645120161 15143
{foreach from=$labels item=label}
{$label} |
{/foreach}
ficus/pages/scaffold/templates/list/table.tpl 100644 1751 144 121 10645120161 14775
{$header}
{foreach from=$rows item=row}
{$row}
{/foreach}
ficus/pages/scaffold/templates/view/row.tpl 100644 1751 144 122 10645120161 14515
{if $nolabel == false}
{$label} |
{/if}
{$value} |
ficus/pages/scaffold/templates/view/table.tpl 100644 1751 144 36 10645120161 14761
ficus/pages/scaffold/templates/ScaffoldSubmit.tpl 100644 1751 144 47 10645120161 15627 {$scaffold}
{$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldNewSubmit.tpl 100644 1751 144 47 10645120161 16301 {$scaffold}
{$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldEdit.tpl 100644 1751 144 562 10647425604 15307
{$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldList.tpl 100644 1751 144 2406 10647425604 15354 æ–°è¦ä½œæˆ
{if $scaffold_helper->getDisplayPageIndexEnd()}
{if $scaffold_helper->isPrev()}
å‰ã®{$scaffold_helper->getLimit()}件
{/if}
{section name="scaffold_page" loop=$scaffold_helper->getDisplayPageIndexEnd()+1 start=$scaffold_helper->getDisplayPageIndexBegin()}
{if $smarty.section.scaffold_page.index == $scaffold_helper->getPageIndex()}
{$smarty.section.scaffold_page.index+1}
{else}
{$smarty.section.scaffold_page.index+1}
{/if}
{/section}
{if $scaffold_helper->isNext()}
次ã®{$scaffold_helper->getLimit()}件
{/if}
{/if}
{$scaffold_message}
ficus/pages/scaffold/templates/Scaffold.tpl 100644 1751 144 176 10646126775 14510 {include file="header.tpl" title="$scaffold_title"}
管ç†ãƒ¡ãƒ‹ãƒ¥ãƒ¼
{$scaffold}
{include file="footer.tpl"}
ficus/pages/scaffold/templates/exception.tpl 100644 1751 144 102 10645120161 14730 {$exception}
{$exception->getTraceAsString()}
ficus/pages/scaffold/templates/ScaffoldDeleteSubmit.tpl 100644 1751 144 33 10645120161 16745 {$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldEditSubmit.tpl 100644 1751 144 47 10645120161 16435 {$scaffold}
{$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldNew.tpl 100644 1751 144 1026 10647425604 15167
{$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldConfirm.tpl 100644 1751 144 562 10647425604 16017
{$scaffold_message}
ficus/pages/scaffold/templates/ScaffoldNewConfirm.tpl 100644 1751 144 562 10647425604 16471
{$scaffold_message}
ficus/pages/scaffold/templates/footer.tpl 100644 1751 144 20 10645120161 14207