File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.sortorder.php
<?php
/**
* This file contains the iwp_field_sortorder class
*
* @version $Id$
*
*
* @package IWP
* @subpackage IWP_FormFields
*/
/**
* Sortorder Field Class
* This class is used by the api form class to generate a sort order field
*
* @package IWP
* @subpackage IWP_FormFields
*/
class iwp_field_sortorder extends iwp_field {
/**
* This is the form field type of the field
*
* @var string
*/
public $type = 'sortorder';
/**
* For holding whether the label should be shown for this field or not
*
* @var Boolean
**/
protected $showLabel = true;
public $RequiredJs = array('../javascript/admin.field.sortorder.js');
/**
* __construct
* The constructor which calls the parent constructor that sets up the field name if it is passed in during the initialization
*
* @var string
*/
public function __construct($name=null){
parent::__construct($name);
}
/**
* GetFieldOutput
* Returns the HTML for this field. It generates the relevant parts, assigns them to template variables and returns a parse template file.
*
* @return string Returns the field HTML
*/
public function GetFieldOutput($setOnly=false){
if(empty($this->FieldValue)){
$this->FieldValue = 0;
}
$inputField = $this->Prepend.'<input type="text" id="'. iwp_htmlspecialchars($this->FieldName) .'" name="'. iwp_htmlspecialchars($this->FieldName) .'" value="'. iwp_htmlspecialchars($this->FieldValue) .'"';
$inputField .= $this->GetAttributes();
$highestNumber = (float)$this->db->FetchOne('select sortorder from ' . IWP_TABLE_CONTENT .' order by sortorder desc limit 1');
$lowestNumber = (float)$this->db->FetchOne('select sortorder from ' . IWP_TABLE_CONTENT .' order by sortorder asc limit 1');
$inputField .= ' style="width:30px;" class="Field" /> <a href="#" id="sortOrderFirstPosition">Set to First Position</a>
|
<a href="#" id="sortOrderLastPosition">Set to Last Position</a>
|
<a href="#" id="sortOrderResetPosition">Reset</a>'.$this->Append;
$inputField .= '<script type="text/javascript">
<!--
$(document).ready(function() {
SortOrderField.HighestNumber = '.($highestNumber+1).';
SortOrderField.LowestNumber = '.($lowestNumber-1).';
$("#sortOrderFirstPosition").bind("click", function(){ javascript:SortOrderField.GetSortOrder(\'lowest\'); return false; });
$("#sortOrderLastPosition").bind("click", function(){ javascript:SortOrderField.GetSortOrder(\'highest\'); return false; });
$("#sortOrderResetPosition").bind("click", function(){ javascript:SortOrderField.GetSortOrder(\'zero\'); return false; });
});
//-->
</script>';
parent::GetFieldOutput();
$this->template->Assign('inputField', $inputField);
$this->template->Assign('FieldName', $this->FieldName);
if (!$setOnly) {
return $this->template->ParseTemplate('form.field', true);
}
return '';
}
/**
* Validate
* This is the function that data for this field is passed to to ensure it was submitted properly.
*
* @return string|boolean If the data is not valid, it will return false, if it is valid it will return a value
*/
public function Validate($arrData){
return $arrData[$this->FieldName];
}
}