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, 40 insertions, 83 deletions
diff --git a/h-source/Library/Scaffold.php b/h-source/Library/Scaffold.php
index a418b7c..7e43134 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 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -32,9 +32,6 @@ 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.
@@ -57,37 +54,30 @@ class Scaffold
//instance of Lang_{language}_Generic
public $strings = 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) {
+ public function __construct($type,$controller,$model,$viewArgs,$params = null) {
$this->_type = $type;
- $this->application = $application;
- $this->controller = $controller;
+ $this->_controller = $controller;
$this->model = $model;
$this->viewArgs = $viewArgs;
//get the generic language class
$this->strings = Factory_Strings::generic(Params::$language);
- $autoParams = self::$autoParams;
-
- if (!array_key_exists("postSubmitValue",$autoParams))
- {
- $autoParams['postSubmitValue'] = $this->strings->gtext('Save');
- }
+ $autoParams = array(
+ 'mainAction' => 'main',
+ 'modifyAction' => 'form/update',
+ 'associateAction' => 'associate',
+ 'panelController' => 'panel',
+ 'pageList' => true,
+ 'pageVariable' => 'page',
+ 'recordPerPage' => 10,
+ 'mainMenu' => 'panel,add',
+ 'formMenu' => 'panel,back',
+ 'postSubmitValue' => 'Save',
+ 'popup' => false,
+ 'popupType' => 'exclusive'
+ );
//set the $this->scaffold->params array
if (is_array($params)) {
@@ -97,7 +87,6 @@ class Scaffold
}
$this->params = $autoParams;
- $this->applicationUrl = isset($application) ? $application . "/" : null;
}
//ad some clauses to the select query
@@ -120,35 +109,11 @@ class Scaffold
{
$this->_primaryKey = $primaryKey;
- if (is_array($recordList) or strcmp($recordList,'') !== 0)
+ if (strcmp($recordList,'') !== 0)
{
- $recordListArray = is_array($recordList) ? $recordList : explode(',',$recordList);
-
+ $recordListArray = explode(',',$recordList);
foreach ($recordListArray as $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;");
- }
+ $this->itemList->addItem("simpleText",";$record;");
}
}
@@ -158,33 +123,26 @@ class Scaffold
{
foreach ($themeArray as $el)
{
- if (preg_match('/ledit\|(.*)/',$el,$matches))
+ switch ($el)
{
- $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;
- }
+ 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['mainAction'].'/;'.$primaryKey.';','Edit','Edit');
+ break;
}
}
}
@@ -199,8 +157,7 @@ class Scaffold
$this->queryType = $queryType;
$submitName = $this->model->getSubmitName($queryType);
$value = $this->params['postSubmitValue'];
- $viewStatus = Url::createUrl($this->viewArgs);
-
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$this->model->setForm($action.$viewStatus,array($submitName => $value),$method,$enctype);
$this->form = $this->model->form;
}