Changeset 5964
- Timestamp:
- 11/11/07 01:18:40 (2 years ago)
- Files:
-
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_autocomplete_td.php (modified) (3 diffs)
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_td.php (modified) (4 diffs)
- plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php (modified) (20 diffs)
- plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_autocomplete_td.php
r5929 r5964 2 2 { 3 3 <?php 4 $tableDelimiter = sfConfig::get('app_sf_extjs_theme_plugin_table_delimiter', '-'); 4 5 5 6 // TODO: improve getting the primary-key-name (check if exists and outside the template) … … 27 28 28 29 $columnPk = $completeColumns['related'][$relatedClassName]['pk']; 29 $columnName = $relatedClassName. "/".$columnPk->getName();30 $columnName = $relatedClassName.'/'.$columnPk->getName(); 30 31 31 32 // add column PK if not already in list … … 61 62 <?php 62 63 // TODO: to make it work with componentents and partials, check the method getColumnAjaxDefinition instead of processColumnAutocompleteName (which can than get private) 63 // value data, unfortunately we cannot use the '/' to distinquish the class and the field, because the name is used as variable in _list_ajax_layout.php64 // value data, NOW WE CAN PROBABLE, OBSOLETE: unfortunately we cannot use the '/' to distinquish the class and the field, because the name is used as variable in _list_ajax_layout.php 64 65 ?> 65 "<?php echo str_replace('/', '_',$columnName) ?>": "[?php echo str_replace('"', '\"', $results-><?php echo $this->processColumnAutocompleteName($column->getPhpName()) ?>) ?]"66 "<?php echo str_replace('/',$tableDelimiter,$columnName) ?>": "[?php echo str_replace('"', '\"', $results-><?php echo $this->processColumnAutocompleteName($column->getPhpName()) ?>) ?]" 66 67 [?php $i++; ?] 67 68 [?php endif; ?] plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_json_list_td.php
r5891 r5964 4 4 { 5 5 <?php 6 7 $tableDelimiter = sfConfig::get('app_sf_extjs_theme_plugin_table_delimiter', '-'); 6 8 7 9 // TODO: improve getting the primary-key-name (check if exists and outside the template) … … 28 30 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 29 31 $columnPk = $completeColumns['related'][$relatedClassName]['pk']; 30 $columnName = $relatedClassName. "/".$columnPk->getName();32 $columnName = $relatedClassName.'/'.$columnPk->getName(); 31 33 32 34 // add column if not already in list … … 48 50 if (!$foreign = (false !== strpos($column->getName(), '/'))) 49 51 { 50 $columnName = strtolower($this->getClassName()). "/".$column->getName();52 $columnName = strtolower($this->getClassName()).'/'.$column->getName(); 51 53 } 52 54 … … 66 68 } 67 69 68 // value data, unfortunately we cannot use the '/' to distinquish the class and the field, because the name is used as variable in _list_ajax_layout.php 69 echo "\"".str_replace('/','_',$columnName)."\": \"[?php echo str_replace('\"', '\\\"', ".$this->getColumnAjaxTag($column).") ?]\""; 70 // value data, NOW WE CAN PROBABLY /// OBSOLETE: unfortunately we cannot use the '/' to distinquish the class and the field, because the name is used as variable in _list_ajax_layout.php 71 // echo "\"".str_replace('/','_',$columnName)."\": \"[?php echo str_replace('\"', '\\\"', ".$this->getColumnAjaxTag($column).") ?]\""; 72 echo "\"".str_replace('/',$tableDelimiter,$columnName)."\": \"[?php echo str_replace('\"', '\\\"', ".$this->getColumnAjaxTag($column).") ?]\""; 70 73 71 74 //don't add it twice plugins/sfExtjsThemePlugin/data/generator/sfPropelAdmin/extjs/template/templates/_list_ajax_layout.php
r5948 r5964 1 [?php 2 /* 3 * Created on 2-sep-2007 4 * 5 * by Leon van der Ree 6 */ 7 ?] 1 [?php /* * Created on 2-sep-2007 * * by Leon van der Ree */ ?] 8 2 9 3 <?php … … 20 14 } 21 15 16 $tableDelimiter = sfConfig::get('app_sf_extjs_theme_plugin_table_delimiter', '-'); 22 17 23 18 // get generator.yml options: … … 44 39 if (false !== strpos($group_field, '/')) 45 40 { 46 $group_field = str_replace('/', '_', $group_field); 41 if ($tableDelimiter != '/' ) 42 { 43 $group_field = str_replace('/', $tableDelimiter, $group_field); 44 } 47 45 } 48 46 else 49 47 { 50 $group_field = $prefix. "_".$group_field;48 $group_field = $prefix.$tableDelimiter.$group_field; 51 49 } 52 50 } … … 91 89 92 90 // Always add the primary key 93 $listDisplay[0] = array('name' => $prefix. "_".$columns['pk']->getName(),94 'mapping' => $prefix. "_".$columns['pk']->getName(),91 $listDisplay[0] = array('name' => $prefix.$tableDelimiter.$columns['pk']->getName(), 92 'mapping' => $prefix.$tableDelimiter.$columns['pk']->getName(), 95 93 'type' => extjs_convert_propel_type($columns['pk']->getType())); 96 94 … … 101 99 { 102 100 // Add id 103 $listDisplay[$i] = array('name' => $class. "_".$relatedClasses['pk']->getName(),104 'mapping' => $class. "_".$relatedClasses['pk']->getName(),101 $listDisplay[$i] = array('name' => $class.$tableDelimiter.$relatedClasses['pk']->getName(), 102 'mapping' => $class.$tableDelimiter.$relatedClasses['pk']->getName(), 105 103 'type' => extjs_convert_propel_type($relatedClasses['pk']->getType())); 106 104 $i++; … … 108 106 foreach ($relatedClasses['columns'] as $relatedColumn => $col) 109 107 { 110 $listDisplay[$i] = array('name' => $class. '_'.$relatedColumn,111 'mapping' => $class. '_'.$relatedColumn,108 $listDisplay[$i] = array('name' => $class.$tableDelimiter.$relatedColumn, 109 'mapping' => $class.$tableDelimiter.$relatedColumn, 112 110 'type' => extjs_convert_propel_type($col->getType())); 113 111 $i++; … … 119 117 foreach ($columns['column'] as $column) 120 118 { 121 $listDisplay[$i] = array('name' => $prefix. "_".$column->getName(),122 'mapping' => $prefix. "_".$column->getName(),119 $listDisplay[$i] = array('name' => $prefix.$tableDelimiter.$column->getName(), 120 'mapping' => $prefix.$tableDelimiter.$column->getName(), 123 121 'type' => extjs_convert_propel_type($column->getType())); 124 122 … … 126 124 } 127 125 128 $options = array('id' => $prefix. "_".$pkn,126 $options = array('id' => $prefix.$tableDelimiter.$pkn, 129 127 'root' => 'data', 130 128 'totalProperty' => 'totalCount'); … … 171 169 [?php if ($key) : 172 170 if (false !== strpos($key, '/')): 173 $key_new = str_replace('/', '_', $key); 171 if ($tableDelimiter != '/') 172 { 173 $key_new = str_replace('/', $tableDelimiter, $key); 174 } 175 else 176 { 177 $key_new = $key; 178 } 174 179 else: 175 $key_new = '<?php echo $prefix ?> _'.$key;180 $key_new = '<?php echo $prefix ?>/'.$key; 176 181 endif; 177 182 echo '// '.$key_new ?] // TODO: use this for sort working... … … 193 198 194 199 $pk = $relatedClasses['pk']->getName(); 195 $listDisplay = array(array('name' => $class. '_'.$pk, 'mapping' => $class.'_'.$pk));200 $listDisplay = array(array('name' => $class.$tableDelimiter.$pk, 'mapping' => $class.$tableDelimiter.$pk)); 196 201 197 202 // iterate through all requested columns of current class … … 206 211 <?php 207 212 // add colum to array 208 $listDisplay[] = array('name' => $class. '_'.$columnName, 'mapping' => $class.'_'.$columnName);213 $listDisplay[] = array('name' => $class.$tableDelimiter.$columnName, 'mapping' => $class.$tableDelimiter.$columnName); 209 214 ?> 210 215 <?php … … 217 222 <?php endforeach; ?> 218 223 <?php 219 $options = array('id' => $class. '_'.$pk,224 $options = array('id' => $class.$tableDelimiter.$pk, 220 225 'root' => 'data', 221 226 'totalProperty' => 'totalCount'); 222 227 $jsReader = extjs_data_reader($options, $listDisplay, 'json'); 223 228 224 // TODO: This would be nice, eventually $url = $controller->genUrl($this->getModuleName().'/jsonList'.$relatedClassName;225 // It probably is easier to use the general jsonListSuccess.php and provide arguments like ?table=relatedClassName226 // For now, the old way, which already works (although not perfectly)227 229 $url = $controller->genUrl($this->getModuleName().'/jsonListAutocomplete?class='.$class); 228 //TODO: sortInfo columnName can be wrong! now the latest column is taken, you should be able to set this. 230 229 231 $options = array('url' => $url, 230 232 'baseParams' => array('filter' => 'query'), 231 233 'reader' => $jsReader, 232 'sortInfo' => array('field' => $class. '_'.$columnName, 'direction' => 'asc'),234 'sortInfo' => array('field' => $class.$tableDelimiter.$columnName, 'direction' => 'asc'), 233 235 'remoteSort' => 'true'); 234 236 $jsDataStore = extjs_data_store($options); 235 237 ?> 236 238 var <?= strtolower($class) ?>_ds = <?php echo $jsDataStore ?>; 237 // disabled238 // <?php echo strtolower($class) ?>_ds.load({params:{start:0, limit:10000}}); // TODO: do I need to say more, this is a hack to preload everything, which probably isn't desired... (but when something isn't there, but it is requested by the renderer with its ID javascript breaks. Requesting the id would be ideal, but because it runs in a seperate thread I don't know how yet...239 239 240 240 function <?php echo strtolower($class) ?>_ds_add_preloaded_from_index(index, value) { … … 245 245 var Record = Ext.data.Record.create(<?php echo _extjs_property_encode($fields) ?>); 246 246 247 var r = new Record({ 248 <?php echo $class.'_'.$pk ?>: value 247 248 var record_data = Array(); 249 record_data['<?php echo $class.$tableDelimiter.$pk ?>'] = value; 249 250 <?php 250 251 $hs = $this->getParameterValue('list.hide', array()); … … 259 260 [?php if ($sf_user->hasCredential(<?php echo $credentials ?>)): ?] 260 261 <?php endif; ?> 261 <?php echo ", ".$class.'_'.$columnName ?>: ds.getAt(index).get('<?php echo $class.'_'.$columnName ?>')262 record_data['<?php echo $class.$tableDelimiter.$columnName ?>'] = ds.getAt(index).get('<?php echo $class.$tableDelimiter.$columnName ?>'); 262 263 <?php 263 264 //don't add it twice … … 268 269 <?php endif; ?> 269 270 <?php endforeach; ?> 270 });271 var r = new Record(record_data); 271 272 272 273 <?php echo strtolower($class) ?>_ds.add(r); 274 273 275 } 274 276 … … 307 309 { 308 310 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 309 $key = $relatedClassName. "_".$completeColumns['related'][$relatedClassName]['pk']->getName(); // removed $relatedClassName.'_'.311 $key = $relatedClassName.$tableDelimiter.$completeColumns['related'][$relatedClassName]['pk']->getName(); 310 312 } 311 313 else … … 331 333 // if value in foreign datastore, return this value 332 334 if (<?php echo $foreign_ds ?>.getById(value)) { 333 return <?php echo $foreign_ds ?>.getById(value).get('<?php echo $relatedClassName. "_".$name ?>');335 return <?php echo $foreign_ds ?>.getById(value).get('<?php echo $relatedClassName.$tableDelimiter.$name ?>'); 334 336 // if not in foreign datastore, test if it is preloaded (this can be out-dated therefor do it after checking datastore) 335 337 } else if ((index = ds.find('<?php echo $key ?>', value)) != -1) { … … 337 339 <?php echo $foreign_ds ?>_add_preloaded_from_index(index, value); 338 340 339 return ds.getAt(index).get('<?php echo $relatedClassName. '_'.$name ?>');341 return ds.getAt(index).get('<?php echo $relatedClassName.$tableDelimiter.$name ?>'); 340 342 } else { 341 343 //TODO if value still not found the foreign-data-store should get it from the server! (but I don't think this will be necesarry occur) … … 377 379 { 378 380 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 379 $dataIndex = $relatedClassName. "_".$completeColumns['related'][$relatedClassName]['pk']->getName();381 $dataIndex = $relatedClassName.$tableDelimiter.$completeColumns['related'][$relatedClassName]['pk']->getName(); 380 382 } 381 383 else 382 384 { 383 $dataIndex = strtolower($this->getClassName()). "_".$column->getName();385 $dataIndex = strtolower($this->getClassName()).$tableDelimiter.$column->getName(); 384 386 } 385 387 … … 412 414 <?php endforeach; ?> 413 415 [?php include_partial('<?php echo $this->getModuleName() ?>/list_ajax_plugin') ?] 416 414 417 cm = <?php echo _extjs_write_class('grid.ColumnModel', array($cmOptions), true, $expander) ?>; 415 418 plugins/sfExtjsThemePlugin/lib/sfExtjsPropelAdminGenerator.php
r5948 r5964 161 161 addTab('Edit number ' + gridContextMenu.rowRecord['".$pkName."'], { url: '".$url."', params: '".$pkName."=' + gridContextMenu.rowRecord['".$pkName."'], scripts: true }, 'edit_' + gridContextMenu.rowRecord['".$pkName."']); 162 162 }"; 163 //return '<li>[?php echo link_to(image_tag(\''.$icon.'\', array(\'alt\' => __(\''.$name.'\'), \'title\' => __(\''.$name.'\'))), \''.$this->getModuleName(). '/'.$action.$url_params.($options ? ', '.$phpOptions : '').') ?]</li>'."\n";163 //return '<li>[?php echo link_to(image_tag(\''.$icon.'\', array(\'alt\' => __(\''.$name.'\'), \'title\' => __(\''.$name.'\'))), \''.$this->getModuleName().$tableDelimiter.$action.$url_params.($options ? ', '.$phpOptions : '').') ?]</li>'."\n"; 164 164 165 165 return $html; … … 292 292 { 293 293 $definition = array(); 294 $tableDelimiter = sfConfig::get('app_sf_extjs_theme_plugin_table_delimiter', '-'); 294 295 295 296 sfLoader::loadHelpers('Extjs'); … … 335 336 list($relatedClassPhpName) = explode('::', $column->getPhpName()); 336 337 list($relatedClassName, $relatedColumn) = explode('/', $column->getName()); 337 $valueField = $relatedClassName. "_".$columns['related'][$relatedClassName]['pk']->getName();338 $valueField = $relatedClassName.$tableDelimiter.$columns['related'][$relatedClassName]['pk']->getName(); 338 339 339 340 $cbOptions = array('hiddenName' => strtolower($relatedClassPhpName).'_'.$relatedColumn.'_combo', 340 341 'name' => strtolower($relatedClassPhpName).'_'.$relatedColumn.'_combo', 341 342 'valueField' => $valueField, 342 'displayField' => $relatedClassName. "_".$relatedColumn,343 'displayField' => $relatedClassName.$tableDelimiter.$relatedColumn, 343 344 'queryParam' => 'filters['.$column->getName().']', 344 345 'store' => strtolower($relatedClassPhpName).'_ds'

