| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 10 /** 11 * @tag select:OPTIONS_SOURCE 12 * @known_parent WactFormTag 13 * @forbid_end_tag 14 * @req_const_attributes target 15 * @convert_to_expression from 16 * @package wact 17 * @version $Id: select_options_source.tag.php 5945 2007-06-06 08:31:43Z pachanga $ 18 */ 19 class WactSelectOptionsSource extends WactRuntimeDatasourceComponentTag 20 { 21 protected $runtimeComponentName = 'WactSelectOptionsSourceComponent'; 22 protected $runtimeIncludeFile = 'limb/wact/src/components/form/WactSelectOptionsSourceComponent.class.php'; 23 24 function generateTagContent($code) 25 { 26 $targets = $this->_getTargetsAsArray(); 27 if(!$this->_isTargetsOk($targets)) 28 return; 29 30 if($value = $this->getAttribute('use_as_name')) 31 $code->writePHP($this->getComponentRefCode() . '->useAsName("' . $value . '");'); 32 33 if($value = $this->getAttribute('use_as_id')) 34 $code->writePHP($this->getComponentRefCode() . '->useAsId("' . $value . '");'); 35 36 if($value = $this->getAttribute('default_value')) 37 $code->writePHP($this->getComponentRefCode() . '->setDefaultValue("' . $value . '");'); 38 39 if($value = $this->getAttribute('default_name')) 40 $code->writePHP($this->getComponentRefCode() . '->setDefaultName("' . $value . '");'); 41 42 foreach($targets as $target) 43 { 44 $target_tag = $this->parent->findChild($target); 45 $code->writePhp($target_tag->getComponentRefCode() . '->setChoices(' . $this->getComponentRefCode() .'->getChoices());') . "\n"; 46 } 47 } 48 49 function _isTargetsOk($targets) 50 { 51 foreach($targets as $target) 52 { 53 $target_tag = $this->parent->getChild($target); 54 55 if(!is_a($target_tag, 'WactSelectTag')) 56 { 57 $this->raiseCompilerError('Select tag not found', 58 array('id' => $target)); 59 return false; 60 } 61 } 62 return true; 63 } 64 65 function _getTargetsAsArray() 66 { 67 $targets = $this->getAttribute('target'); 68 69 $result = array(); 70 71 $pieces = explode(',', $targets); 72 foreach($pieces as $piece) 73 $result[] = trim($piece); 74 75 return $result; 76 } 77 } 78 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Dec 1 03:56:46 2008 | Cross-referenced by PHPXref 0.7 |