attributes['cultivar']) || !$this->attributes['cultivar'])
$this->attributes['cultivar'] = '';
$input = '';
$hint = i18n::s('cultivar');
$fields[] = array($label, $input, $hint);
// hybride
$label = i18n::s('hybride:');
if(!isset($this->attributes['hybride']) || !$this->attributes['hybride'])
$this->attributes['hybride'] = '';
$input = '';
$hint = i18n::s('hybride');
$fields[] = array($label, $input, $hint);
// variete
$label = i18n::s('variete:');
if(!isset($this->attributes['variete']) || !$this->attributes['variete'])
$this->attributes['variete'] = '';
$input = '';
$hint = i18n::s('Variété');
$fields[] = array($label, $input, $hint);
// Forme
$label = i18n::s('forme :');
if(!isset($this->attributes['forme']) || !$this->attributes['forme'])
$this->attributes['forme'] = '';
$input = '';
$hint = i18n::s('Forme ');
$fields[] = array($label, $input, $hint);
// sous Espece
$label = i18n::s('sous-espece :');
if(!isset($this->attributes['sousespece']) || !$this->attributes['sousespece'])
$this->attributes['sousespece'] = '';
$input = '';
$hint = i18n::s('sous espece');
$fields[] = array($label, $input, $hint);
return $fields;
}
/**
* identify one instance
*
* This function returns a string that identify uniquely one overlay instance.
* When this information is saved, it can be used later on to retrieve one page
* and its content.
*
* @returns a unique string, or NULL
*
* @see articles/edit.php
*/
function get_id() {
if(isset($this->attributes['id']))
return ':plant:'.$this->attributes['id'];
return NULL;
}
/**
* get an overlaid label
*
* Accepted action codes:
* - 'edit' the modification of an existing object
* - 'delete' the deleting form
* - 'new' the creation of a new object
* - 'view' a displayed object
*
* @see overlays/overlay.php
*
* @param string the target label
* @param string the on-going action
* @return the label to use
*/
function get_label($name, $action='view') {
global $context;
// the target label
switch($name) {
// description label
case 'description':
return i18n::s('Description');
// page title
case 'page_title':
switch($action) {
case 'edit':
return i18n::s('Editer une plante');
case 'delete':
return i18n::s('Effacer une plante');
case 'new':
return i18n::s('Nouvelle plante');
case 'view':
default:
// use the article title as the page title
return NULL;
}
// title label
case 'title':
return i18n::s('Plant');
// title hint
case 'title_hint':
return i18n::s('Full name');
}
// no match
return NULL;
}
function &get_live_title($host=NULL) {
$text = '
';
return $text;
}
/**
* display the content of one record
*
* Accepted variant codes:
* - 'box' - displayed in a box
* - 'list' - part of a list
* - 'view' - in the main viewing panel
*
* @see overlays/overlay.php
*
* @param string the on-going action
* @param array the hosting record
* @return some HTML to be inserted into the resulting page
*/
function get_text($variant='view', $host=NULL) {
global $context;
// text to return
$text = '';
switch($variant) {
// nothing in a box
case 'box':
return NULL;
// in a list of items, show only the espece
case 'list';
//return '
';
return NULL;
// default case
case 'view':
default:
// image
/*include_once($context['path_to_root'].'/images/images.php');
foreach($images = Images::list_by_date_for_anchor('article:'.$host['id'], 0, 20, 'raw') as $image) {
$src = Images::get_icon_href($image);
$title = $image['title'];
$url = Images::get_url($image['id']);
//$url = Images::get_thumbnail_href($image['id']);
$text .= ''.Skin::build_image('bottom', $src, $title, $url ).'';
}
*/
// finalize the table
return $text;
}
}
/**
* retrieve the content of one modified overlay
*
* @see overlays/overlay.php
*
* @param the fields as filled by the end user
* @return the updated fields
*/
function parse_fields($fields) {
$this->attributes['cultivar'] = isset($fields['cultivar']) ? $fields['cultivar'] : '';
$this->attributes['hybride'] = isset($fields['hybride']) ? $fields['hybride'] : '';
$this->attributes['variete'] = isset($fields['variete']) ? $fields['variete'] : '';
$this->attributes['sousespece'] = isset($fields['sousespece']) ? $fields['sousespece'] : '';
$this->attributes['forme'] = isset($fields['forme']) ? $fields['forme'] : '';
return $this->attributes;
}
/**
* remember an action once it's done
*
* Following actions are recognized:
* - 'insert' - insert a new record in the side table
* - 'update' - update an existing record
* - 'delete' - suppress a record in the database
*
* To enforce database consistency, and in case of 'update' the function
* deletes the record and create it again.
*
* @param string the action 'insert', 'update' or 'delete'
* @param array the hosting record
* @return FALSE on error, TRUE otherwise
*/
function remember($variant, $host) {
global $context;
// id cannot be empty
if(!$host['id'] || !is_numeric($host['id']))
return;
// article title is also plant full name
if(isset($host['full_name']))
$title = $host['full_name'];
else
$title = $host['title'];
// set default values for this editor
$this->attributes = Surfer::check_default_editor($this->attributes);
// build the update query
switch($variant) {
// delete a record
case 'delete':
$query = "DELETE FROM ".SQL::table_name('plantes')." WHERE id = ".SQL::escape($host['id']);
SQL::query($query);
return TRUE;
// delete the record, then re-create it -- to survive database inconsistencies
case 'update':
$query = "DELETE FROM ".SQL::table_name('plantes')." WHERE id = ".SQL::escape($host['id']);
SQL::query($query);
// in sert a new record in the database
case 'insert':
$query = "INSERT INTO ".SQL::table_name('plantes')." SET \n"
."id='".SQL::escape($host['id'])."', \n"
."cultivar='".SQL::escape($this->attributes['cultivar'])."', \n"
."hybride='".SQL::escape($this->attributes['hybride'])."', \n"
."variete='".SQL::escape($this->attributes['variete'])."', \n"
."forme='".SQL::escape($this->attributes['forme'])."', \n"
."sousespece='".SQL::escape($this->attributes['sousespece'])."'";
return SQL::query($query);
}
// unknown action
return TRUE;
}
/**
* create tables for classic_cars
*
*/
function setup() {
global $context;
$fields = array();
/**
$fields['id'] = "MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT";
$fields['espece'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['nom_latin'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['famille'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['cultivar'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['sous_espece'] = "VARCHAR(255) DEFAULT '' NOT NULL";
$fields['forme'] = "VARCHAR(255) DEFAULT '' NOT NULL";
*/
$fields['id'] = "MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT";
$fields['cultivar'] = "VARCHAR(255) DEFAULT '' NULL";
$fields['hybride'] = "VARCHAR(2) DEFAULT '' NULL";
$fields['variete'] = "VARCHAR(255) DEFAULT '' NULL";
$fields['forme'] = "VARCHAR(255) DEFAULT '' NULL";
$fields['sousespece'] = "VARCHAR(255) DEFAULT '' NULL";
$indexes = array();
$indexes['PRIMARY KEY'] = "(id)";
$indexes['INDEX cultivar'] = "(cultivar(255))";
return SQL::setup_table('plantes', $fields, $indexes);
}
}
?>