Changeset 16455
- Timestamp:
- 05/23/08 14:36:35 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.helper.datamanager2/widget/tagpicker.php
r14893 r16455 53 53 54 54 /** 55 * whether the input should be shown in the widget, or not.55 * Whether the input should be shown in the widget, or not. 56 56 * 57 57 * @var boolean … … 59 59 */ 60 60 var $hideinput = false; 61 62 /** 63 * Whether to allow users to add tags that are not yet in database 64 * 65 * @var boolean 66 * @access public 67 */ 68 var $allow_other = false; 61 69 62 70 var $_taglist_html = ''; … … 125 133 function sync_type_with_widget($results) 126 134 { 127 $this->_type->value = $results[$this->name]; 135 if ( $this->allow_other 136 || empty($results[$this->name])) 137 { 138 // The simple way, just take what is given 139 $this->_type->value = $results[$this->name]; 140 return; 141 } 142 143 // Otherwise, validate the results 144 $tags_in_db = net_nemein_tag_handler::get_tags(); 145 146 $tags_from_user = explode(' ', $results[$this->name]); 147 148 $tags_to_save = array(); 149 150 foreach ($tags_from_user as $tag) 151 { 152 if (!isset($tags_in_db[$tag]) 153 { 154 // We don't have this tag, skip. 155 continue; 156 } 157 158 $tags_to_save[] = $tag; 159 } 160 161 $this->_type->value = implode(' ', $tags_to_save); 128 162 } 129 163 … … 132 166 $html = ''; 133 167 $tags = net_nemein_tag_handler::get_tags(); 134 $object_tags = explode( " ", $this->_type->value);168 $object_tags = explode(' ', $this->_type->value); 135 169 136 170 if (! empty($tags))
