#changelist { position:relative;}
+#changelist table{ width:100%;}
.change-list .filtered table { border-right:1px solid #ddd; }
.change-list .filtered { min-height:400px; _height:400px; }
.change-list .filtered { background:white url(../img/changelist-bg.gif) top right repeat-y !important; }
#changelist-filter li.selected a { color:#5b80b2 !important; }
/* DATE DRILLDOWN */
-.change-list ul.toplinks { display:block; background:white url(../img/nav-bg-reverse.gif) 0 -10px repeat-x; border-top:1px solid white; float:left; padding:0 !important; margin:0 !important; width:100%; }
+.change-list ul.toplinks { display:block; background:white url(../img/nav-bg-reverse.gif) 0 -10px repeat-x; border-top:1px solid white; float:left; padding:0 !important; margin:0 !important; }
.change-list ul.toplinks li { float: left; width: 9em; padding:3px 6px; font-weight: bold; list-style-type:none; }
.change-list ul.toplinks .date-back a { color:#999; }
.change-list ul.toplinks .date-back a:hover { color:#036; }
-body.dashboard { margin:0; padding:0; font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif; color:#333; background:url('../img/topbg.gif') left top repeat-x; }
+body{ margin:0; padding:0; font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif; color:#333; background:url('../img/topbg.gif') left top repeat-x; }
body.simple { margin:10; padding:10; font-family:"Lucida Grande","Bitstream Vera Sans",Verdana,Arial,sans-serif; color:#333; }
a:link, a:visited { color: #005681; text-decoration:none; }
/* PAGE STRUCTURE */
-#ipfcontainer { position:relative; width:100%; min-width:760px; }
+#ipfcontainer { position:relative; min-width:760px; }
#ipfcontent { margin:10px 10px; }
#ipfheader { width:100%;}
#ipfcontent-main { float:left; width:100%; }
/* COLUMN TYPES */
.colMS { margin-right:245px !important; }
.colSM { margin-left:245px !important; }
-.colSM #ipfcontent-related { float:left; margin-right:0; margin-left:-230px; }
+.colSM #ipfcontent-related { float:left; margin-right:0; margin-left:-230px; }
.colSM #ipfcontent-main { float:right; }
.popup .colM { width:95%; }
.subcol { float:left; width:46%; margin-right:15px; }
-.dashboard #content { width:500px; }
+.index {width:500px;}
/* HEADER */
#ipfheader { overflow:hidden; height:43px; }
thead th { font-weight:bold; color:#666; padding:2px 5px; font-size:11px; background:url(../img/hbg.gif) top left repeat-x; border-left:1px solid #ABB0BE; border-bottom:1px solid #ABB0BE; }
thead th:first-child { border-left:none !important; }
.superwide table th, .superwide table td, .superwide table input, .superwide table select { font-size:10px; }
-.module table { border-collapse: collapse; }
+.module { width:100%;}
+.module table { border-collapse: collapse; width:100%;}
+.module table th{ width:90%;}
thead th.optional { font-weight:normal !important; }
#ipfhome-page table.module tr:hover { background:#EDF3FE; }
fieldset { border:1px solid #eee; }
-<?php
+<?php
class IPF_Admin_Model{
static $models = array();
-
+
public static function register($classModel, $classAdmin){
IPF_Admin_Model::$models[$classModel] = new $classAdmin($classModel);
}
}
return null;
}
-
+
var $modelName = null;
var $model = null;
var $inlineInstances = array();
public function __construct($modelName){
$this->modelName = $modelName;
}
-
+
public function setUp(){
$this->model = new $this->modelName;
}
public function getPerms($request){
return array('view', 'add', 'change', 'delete');
}
-
+
protected function setInlines($model, &$data){
$il = $this->inlines();
if (is_array($il)){
}
}
}
-
+
protected function saveInlines($obj){
foreach($this->inlineInstances as $inlineInstance){
$inlineInstance->save($obj);
}
}
-
+
protected function _setupEditForm($form){
$this->_setupForm($form);
}
protected function _setupForm($form){
}
-
+
public function fields(){return null;}
public function inlines(){return null;}
-
+
public function isValidInlines(){
foreach($this->inlineInstances as &$il){
if ($il->isValid()===false){
$this->names = $this->list_display();
else
$this->names = $this->model->getTable()->getColumnNames();
-
+
foreach ($this->names as $name){
$this->header[$name] = new IPF_Template_ContextVars(array(
'title'=>IPF_Utils::humanTitle($name),
public function ListItemsQuery(){
$this->q = IPF_ORM_Query::create()->from($this->modelName)->orderby('id desc');
}
-
+
public function ListRow($o){
$row = array();
-
+
foreach($this->header as &$h){
$listMethod = 'column_'.$h['name'];
if (method_exists($this,$listMethod))
$t = $o->getTable()->getTypeOf($h['name']);
$str = $o->$h['name'];
if ($t=='boolean'){
- if ($str)
+ if ($str)
$str = '<img src="'.IPF::get('admin_media_url').'img/icon-yes.gif" alt="True" />';
- else
+ else
$str = '<img src="'.IPF::get('admin_media_url').'img/icon-no.gif" alt="False" />';
}
}
$this->linksRow(&$row, $o);
return $row;
}
-
+
protected function linksRow($row, $o){
if (method_exists($this,'list_display_links')){
$links_display = $this->list_display_links();
}
}
}
-
+
protected function UrlForResult($o){
return $o->__get($this->model->getTable()->getIdentifier()).'/';
}
protected function _getChangeTemplate(){
return 'admin/change.html';
}
-
+
// Views Function
public function AddItem($request, $lapp, $lmodel){
if ($request->method == 'POST'){
$this->setInlines($this->model, &$data);
}
$context = array(
- 'page_title'=>'Add '.$this->modelName,
+ 'page_title'=>'Add '.$this->modelName,
'classname'=>$this->modelName,
'form'=>$form,
'inlineInstances'=>$this->inlineInstances,
);
return IPF_Shortcuts::RenderToResponse($this->_getAddTemplate(), $context, $request);
}
-
+
public function EditItem($request, $lapp, $lmodel, $o){
if ($request->method == 'POST'){
$data = $request->POST+$request->FILES;
$form = $this->_getEditForm($o,&$data,array('user_fields'=>$this->fields()));
$this->_setupEditForm($form);
$this->setInlines($o, &$data);
-
+
if ( ($form->isValid()) && ($this->isValidInlines()) ) {
//print_r($form->cleaned_data);
$item = $form->save();
$this->_setupEditForm($form);
$this->setInlines($o, &$data);
}
-
+
$context = array(
- 'page_title'=>'Edit '.$this->modelName,
+ 'page_title'=>'Edit '.$this->modelName,
'classname'=>$this->modelName,
'object'=>$o,
'form'=>$form,
return new IPF_HTTP_Response_Redirect($url);
}
$context = array(
- 'page_title'=>'Delete '.$this->modelName,
+ 'page_title'=>'Delete '.$this->modelName,
'classname'=>$this->modelName,
'object'=>$o,
'lapp'=>$lapp,
public function ListItems($request){
$this->ListItemsQuery();
$this->ListItemsHeader();
-
+
$currentPage = (int)@$request->GET['page'];
-
+
$pager = new IPF_ORM_Pager_LayoutArrows(
new IPF_ORM_Pager($this->q, $currentPage, $this->perPage),
new IPF_ORM_Pager_Range_Sliding(array('chunk' => 10)),
$pager->setTemplate('<a href="{%url}">{%page}</a> ');
$pager->setSelectedTemplate('<span class="this-page">{%page}</span> ');
$objects = $pager->getPager()->execute();
-
+
$context = array(
- 'page_title'=>$this->modelName.' List',
+ 'page_title'=>$this->modelName.' List',
'header'=>$this->header,
'classname'=>$this->modelName,
'objects'=>$objects,
<div id="ipfcontent">
<h1>{$page_title}</h1>
-
+
<form method="post" {if $form.hasFileField() }enctype="multipart/form-data"{/if}>
<fieldset>
<table>
{$form.render_table}
</table>
</fieldset>
+ {if $inlineInstances}
{foreach $inlineInstances as $inline}
<fieldset class="inlineTabular" style="border:none; width:auto; float:left; padding:0; margin:10px 10px 10px 0;">
<legend>{$inline->getLegend()}</legend>
</table>
</fieldset>
{/foreach}
+ {/if}
<div style="clear:both;"></div>
<div class="submit-row">
<input type="submit" value="Save" class="default" />
</div>
- </form>
-
+ </form>
+
</div>
{/block}
<title>{$page_title} - IPF Administration</title>
</head>
-<body class="dashboard">
+<body>
<script type="text/javascript" src="{$ADMIN_MEDIA_URL}js/jquery.js"></script>
<br class="clear" />
</div>
<!-- END Header -->
-
+
<div class="breadcrumbs">
{block breadcrumbs} <a href="{url 'IPF_Admin_Views_Index'}">Home</a>{/block}
</div>
<div id="ipfcontent">
<h1>{$page_title}</h1>
-
+
<form method="post" {if $form.hasFileField()}enctype="multipart/form-data"{/if}>
<fieldset>
<table>
{$form.render_table}
</table>
</fieldset>
+ {if $inlineInstances}
{foreach $inlineInstances as $inline}
<fieldset class="inlineTabular" style="border:none; width:auto; float:left; padding:0; margin:10px 10px 10px 0;">
<legend>{$inline->getLegend()}</legend>
</table>
</fieldset>
{/foreach}
+ {/if}
<div style="clear:both;"></div>
<div class="submit-row">
{if array_search('delete',$perms)!==false}<p class="float-left"><a href="{url 'IPF_Admin_Views_DeleteItem', array($lapp, $lmodel, $object.id)}" class="deletelink">Delete</a></p>{/if}
<input type="submit" value="Save" class="default" />
</div>
- </form>
-
+ </form>
+
</div>
{/block}
{block content}
-<div id="ipfcontent" class="colMS">
+<div id="ipfcontent" class="index">
<h1>{$page_title}</h1>
<div id="ipfcontent-main">
<div class="module">
<div id="ipfcontent">
<h1>{$page_title}</h1>
<ul class="object-tools">{if array_search('add',$perms)!==false}<li><a href="add/" class="addlink">Add {$classname}</a></li>{/if}</ul>
- <div id="changelist" class="module filtered">
+ <div id="changelist">
<!--div id="changelist-filter">
<h2>Filter</h2>
</div>
-
-
-
-
-
-
</div>
$this->model = $extra['model'];
else
throw new IPF_Exception_Form(__('Unknown model for form'));
-
+
if (isset($extra['user_fields']))
$this->user_fields = $extra['user_fields'];
-
+
$user_fields = $this->fields();
$db_columns = $this->model->getTable()->getColumns();
$db_relations = $this->model->getTable()->getRelations();
-
+
if ($user_fields===null){
- if (isset($extra['exclude']))
+ if (isset($extra['exclude']))
$exclude = $extra['exclude'];
else
$exclude = array();
-
+
foreach($db_columns as $name=>$col){
if (array_search($name,$exclude)!==false)
continue;
}
}
}
-
+
function addDBField($name,$col){
if ($name==$this->model->getTable()->getIdentifier())
return;
-
+
$defaults = array('blank' => true, 'verbose' => $name, 'help_text' => '', 'editable' => true);
$type = $col['type'];
-
+
if (isset($col['notblank']))
if ($col['notblank'])
$defaults['blank'] = false;
$type = 'image';
$cn = 'IPF_Form_DB_'.$type;
-
+
$db_field = new $cn('', $name);
//echo $name;
//print_r($defaults);
-
+
if (null !== ($form_field=$db_field->formField($defaults))) {
$this->fields[$name] = $form_field;
}
if ( ! $this->_errorStack) {
$this->_errorStack = new IPF_ORM_Validator_ErrorStack(get_class($this));
}
-
+
return $this->_errorStack;
}
if ($state == null) {
return $this->_state;
}
-
+
$err = false;
if (is_integer($state)) {
if ($state >= 1 && $state <= 6) {
if (isset($this->_values[$fieldName])) {
return $this->_values[$fieldName];
}
-
+
try {
if ( ! isset($this->_references[$fieldName]) && $load) {
$rel = $this->_table->getRelation($fieldName);
} else {
$old = $this->_data[$fieldName];
}
-
+
if ($this->_isValueModified($type, $old, $value)) {
if ($value === null) {
$value = self::$_null;
public function coreSetRelated($name, $value)
{
$rel = $this->_table->getRelation($name);
-
+
if ($value === null) {
$value = self::$_null;
}
-
+
// one-to-many or one-to-one relation
if ($rel instanceof IPF_ORM_Relation_ForeignKey || $rel instanceof IPF_ORM_Relation_LocalKey) {
if ( ! $rel->isOneToOne()) {
if ($this->_state == self::STATE_LOCKED) {
return false;
}
-
+
$stateBeforeLock = $this->_state;
$this->_state = self::STATE_LOCKED;
-
+
$a = array();
foreach ($this as $column => $value) {
$i = $this->_table->getIdentifier();
$a[$i] = $this->getIncremented();
}
-
+
if ($deep) {
foreach ($this->_references as $key => $relation) {
if (! $relation instanceof IPF_ORM_Null) {
$a[$key] = $value;
}
}
-
+
$this->_state = $stateBeforeLock;
return $a;
{
$this->getNode()->delete();
}
-
+
public function free($deep = false)
{
if ($this->_state != self::STATE_LOCKED) {
{
return (string) $this->_oid;
}
-
+
public function ModelAdmin(){
$cn = get_class($this);
if (isset(IPF_Admin_Model::$models[$cn]))
{
foreach ($cleaned_values as $key=>$val) {
$validators = $this->getTable()->getFieldValidators($key);
- if (array_key_exists('image',$validators) || array_key_exists('file',$validators)){
+ if (
+ array_key_exists('image',$validators) ||
+ array_key_exists('file',$validators) ||
+ array_key_exists('email',$validators)
+ ){
if (($val!==null) && ($val==''))
continue;
}