aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Scaffold.php
diff options
context:
space:
mode:
Diffstat (limited to 'h-source/Library/Scaffold.php')
-rwxr-xr-xh-source/Library/Scaffold.php123
1 files changed, 83 insertions, 40 deletions
diff --git a/h-source/Library/Scaffold.php b/h-source/Library/Scaffold.php
index 4c5b46c..a418b7c 100755
--- a/h-source/Library/Scaffold.php
+++ b/h-source/Library/Scaffold.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2011 Antonio Gallo
+// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -32,6 +32,9 @@ class Scaffold
protected $_primaryKey = null; //the primary key of the table
protected $_controller = null; //the name of the controller
+ public $application = null; //the name of the application
+ public $applicationUrl = null; //the url of the application
+ public $controller = null; //the name of the controller
public $model = null; //the reference to the model associated with the controller
public $viewArgs = array(); //the associative array representing the status args of the main action of the controller.
@@ -54,30 +57,37 @@ class Scaffold
//instance of Lang_{language}_Generic
public $strings = null;
- public function __construct($type,$controller,$model,$viewArgs,$params = null) {
+ public static $autoParams = array(
+ 'mainAction' => 'main',
+ 'modifyAction' => 'form/update',
+ 'associateAction' => 'associate',
+ 'panelController' => 'panel',
+ 'pageList' => true,
+ 'pageVariable' => 'page',
+ 'recordPerPage' => 20,
+ 'mainMenu' => 'panel,add',
+ 'formMenu' => 'panel,back',
+ 'popup' => false,
+ 'popupType' => 'exclusive'
+ );
+
+ public function __construct($type,$application, $controller,$model,$viewArgs,$params = null) {
$this->_type = $type;
- $this->_controller = $controller;
+ $this->application = $application;
+ $this->controller = $controller;
$this->model = $model;
$this->viewArgs = $viewArgs;
//get the generic language class
$this->strings = Factory_Strings::generic(Params::$language);
- $autoParams = array(
- 'mainAction' => 'main',
- 'modifyAction' => 'form/update',
- 'associateAction' => 'associate',
- 'panelController' => 'panel',
- 'pageList' => true,
- 'pageVariable' => 'page',
- 'recordPerPage' => 10,
- 'mainMenu' => 'panel,add',
- 'formMenu' => 'panel,back',
- 'postSubmitValue' => $this->strings->gtext('Save'),
- 'popup' => false,
- 'popupType' => 'exclusive'
- );
+ $autoParams = self::$autoParams;
+
+ if (!array_key_exists("postSubmitValue",$autoParams))
+ {
+ $autoParams['postSubmitValue'] = $this->strings->gtext('Save');
+ }
//set the $this->scaffold->params array
if (is_array($params)) {
@@ -87,6 +97,7 @@ class Scaffold
}
$this->params = $autoParams;
+ $this->applicationUrl = isset($application) ? $application . "/" : null;
}
//ad some clauses to the select query
@@ -109,11 +120,35 @@ class Scaffold
{
$this->_primaryKey = $primaryKey;
- if (strcmp($recordList,'') !== 0)
+ if (is_array($recordList) or strcmp($recordList,'') !== 0)
{
- $recordListArray = explode(',',$recordList);
+ $recordListArray = is_array($recordList) ? $recordList : explode(',',$recordList);
+
foreach ($recordListArray as $record) {
- $this->itemList->addItem("simpleText",";$record;");
+ if (preg_match('/\[\[checkbox\]\](\;)(.*?)(\;)/',$record,$matches))
+ {
+ $this->itemList->addItem("checkbox",encode($matches[2]),";".$matches[2].";","",";".$primaryKey.";");
+ }
+ else if (preg_match('/\[\[checkbox\:(.*?)\]\](\;)(.*?)(\;)/',$record,$matches))
+ {
+ $this->itemList->addItem("checkbox",encode($matches[3]),";".$matches[3].";",$matches[1],";".$primaryKey.";");
+ }
+ else if (preg_match('/\[\[input\]\](\;)(.*?)(\;)/',$record,$matches))
+ {
+ $this->itemList->addItem("input",encode($matches[2]),";".$matches[2].";",";".$primaryKey.";");
+ }
+ else if (preg_match('/\[\[ledit\]\](\;)(.*?)(\;)/',$record,$matches))
+ {
+ $this->itemList->addItem("link",$this->applicationUrl . $this->controller.'/'.$this->params['modifyAction']."/;$primaryKey;","",";".$matches[2].";");
+ }
+ else if (strstr($record, ';'))
+ {
+ $this->itemList->addItem("simpleText","$record");
+ }
+ else
+ {
+ $this->itemList->addItem("simpleText",";$record;");
+ }
}
}
@@ -123,26 +158,33 @@ class Scaffold
{
foreach ($themeArray as $el)
{
- switch ($el)
+ if (preg_match('/ledit\|(.*)/',$el,$matches))
{
- case 'moveup':
- $this->itemList->addItem('moveupForm',$this->_controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
- break;
- case 'movedown':
- $this->itemList->addItem('movedownForm',$this->_controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
- break;
- case 'link':
- $this->itemList->addItem('associateForm',$this->_controller.'/'.$this->params['associateAction'],";".$primaryKey.";");
- break;
- case 'edit':
- $this->itemList->addItem('editForm',$this->_controller.'/'.$this->params['modifyAction'],";".$primaryKey.";");
- break;
- case 'del':
- $this->itemList->addItem('delForm',$this->_controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
- break;
- case 'ledit':
- $this->itemList->addItem('ledit',$this->_controller.'/'.$this->params['modifyAction'].'/;'.$primaryKey.';','Edit','Edit');
- break;
+ $this->itemList->addItem('ledit',$matches[1],'Edit','Edit');
+ }
+ else
+ {
+ switch ($el)
+ {
+ case 'moveup':
+ $this->itemList->addItem('moveupForm',$this->applicationUrl . $this->controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
+ break;
+ case 'movedown':
+ $this->itemList->addItem('movedownForm',$this->applicationUrl . $this->controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
+ break;
+ case 'link':
+ $this->itemList->addItem('associateForm',$this->applicationUrl . $this->controller.'/'.$this->params['associateAction'],";".$primaryKey.";");
+ break;
+ case 'edit':
+ $this->itemList->addItem('editForm',$this->applicationUrl . $this->controller.'/'.$this->params['modifyAction'],";".$primaryKey.";");
+ break;
+ case 'del':
+ $this->itemList->addItem('delForm',$this->applicationUrl . $this->controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
+ break;
+ case 'ledit':
+ $this->itemList->addItem('ledit',$this->applicationUrl . $this->controller.'/'.$this->params['modifyAction'].'/;'.$primaryKey.';','Edit','Edit');
+ break;
+ }
}
}
}
@@ -157,7 +199,8 @@ class Scaffold
$this->queryType = $queryType;
$submitName = $this->model->getSubmitName($queryType);
$value = $this->params['postSubmitValue'];
- $viewStatus = Url::createUrl(array_values($this->viewArgs));
+ $viewStatus = Url::createUrl($this->viewArgs);
+
$this->model->setForm($action.$viewStatus,array($submitName => $value),$method,$enctype);
$this->form = $this->model->form;
}