From: <rob...@us...> - 2012-03-27 21:28:16
|
Revision: 40444 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=40444&view=rev Author: robertplummer Date: 2012-03-27 21:28:09 +0000 (Tue, 27 Mar 2012) Log Message: ----------- [ENH] Added a way to set input defaults for queryInputs Modified Paths: -------------- trunk/lib/core/Tracker/Query.php Modified: trunk/lib/core/Tracker/Query.php =================================================================== --- trunk/lib/core/Tracker/Query.php 2012-03-27 20:42:10 UTC (rev 40443) +++ trunk/lib/core/Tracker/Query.php 2012-03-27 21:28:09 UTC (rev 40444) @@ -45,7 +45,8 @@ private $debug = false; private $concat = true; private $filterType = array(); - + private $inputDefaults = array(); + public static function tracker($tracker) { return new self($tracker); @@ -775,9 +776,10 @@ return $itemId; } - private function getInputsForItem($itemId, $includeJs) + private function getInputsForItem($itemId = 0, $includeJs) { $headerlib = TikiLib::lib("header"); + $itemId = (int)$itemId; if ($includeJs == true) $headerlibClone = clone $headerlib; @@ -790,11 +792,17 @@ $itemData = TikiLib::lib("trk")->get_tracker_item($itemId); foreach ($trackerDefinition->getFields() as $field) { + $fieldKey = ($this->byName == true ? $field['name'] : $field['fieldId']); + if ($includeJs == true) $headerlib->clear_js(); $field['ins_id'] = "ins_" . $field['fieldId']; + if ($itemId == 0 && isset($this->inputDefaults)) { + $field['value'] = $this->inputDefaults[$fieldKey]; + } + $fieldHandler = $fieldFactory->getHandler($field, $itemData); $fieldInput = $fieldHandler->renderInput(); @@ -802,7 +810,7 @@ if ($includeJs == true) $fieldInput = $fieldInput . $headerlib->output_js(); - $fields[$this->byName == true ? $field['name'] : $field['fieldId']] = $fieldInput; + $fields[$fieldKey] = $fieldInput; } if ($includeJs == true) //restore the header to the way it was originally @@ -811,6 +819,12 @@ return $fields; } + public function inputDefaults($defaults = array()) + { + $this->inputDefaults = $defaults; + return $this; + } + public function queryInputs($includeJs = false) { $query = $this->query(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |