Changeset 8435
- Timestamp:
- 04/13/08 13:33:31 (5 months ago)
- Files:
-
- plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/data/generator/sfAdvancedAdmin/default/template/actions/actions.class.php (modified) (1 diff)
- plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/lib/helper/AdvancedAdminHelper.php (modified) (1 diff)
- plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/lib/sfAdvancedAdminGenerator.class.php (modified) (1 diff)
- plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/lib/sfAdvancedManyToMany.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/data/generator/sfAdvancedAdmin/default/template/actions/actions.class.php
r8312 r8435 246 246 247 247 $class = $this->getClassName(); 248 $related_class = sfPropelManyToMany::getRelatedClass($class, $through_class); 249 $related_table = constant($related_class.'Peer::TABLE_NAME'); 250 $middle_table = constant($through_class.'Peer::TABLE_NAME'); 251 $this_table = constant($class.'Peer::TABLE_NAME'); 252 253 $related_column = sfPropelManyToMany::getRelatedColumn($class, $through_class); 254 $column = sfPropelManyToMany::getColumn($class, $through_class); 248 $related_class = sfAdvancedManyToMany::getRelatedClass($class, $through_class); 249 $related_table = $this->getTableName($related_class); 250 $middle_table = $this->getTableName($through_class); 251 $this_table = $this->getTableName($class); 252 253 $related_column = sfAdvancedManyToMany::getRelatedColumn($class, $through_class); 254 $column = sfAdvancedManyToMany::getColumn($class, $through_class); 255 256 if (false !== strpos($through_class, '.')) { 257 list($through_class, $source_column) = explode('.', $through_class, 2); 258 } 255 259 256 260 ?> 257 <?php if ( $input_type == 'admin_double_list' || $input_type == 'admin_check_list' || $input_type == 'admin_select_list'): ?>261 <?php if (preg_match('/^(self_reference_)?admin_(double|check|select)_list$/', $input_type)): ?> 258 262 <?php if ($credentials): $credentials = str_replace("\n", ' ', var_export($credentials, true)) ?> 259 263 if ($this->getUser()->hasCredential(<?php echo $credentials ?>)) plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/lib/helper/AdvancedAdminHelper.php
r8312 r8435 33 33 echo input_hidden_tag($input_name); 34 34 } 35 ?> 35 36 function object_self_reference_admin_double_list($object, $method, $options = array()) 37 { 38 $callback = '_self_reference_many_to_many_object_list'; 39 40 return object_admin_double_list($object, $method, $options, $callback); 41 } 42 43 function object_self_reference_admin_select_list($object, $method, $options = array()) 44 { 45 $callback = '_self_reference_many_to_many_object_list'; 46 47 return object_admin_select_list($object, $method, $options, $callback); 48 } 49 50 function object_self_reference_admin_check_list($object, $method, $options = array()) 51 { 52 $callback = '_self_reference_many_to_many_object_list'; 53 54 return object_admin_check_list($object, $method, $options, $callback); 55 } 56 57 function _self_reference_many_to_many_object_list($object, $method, $options) 58 { 59 $full_through_class = _get_option($options, 'through_class'); 60 list($through_class, $source_column) = explode('.', $full_through_class, 2); 61 62 $class = get_class($object); 63 $relation_method = 'get' . $through_class . 'sRelatedBy' . $class . 'Id'; 64 $related_column = sfAdvancedManyToMany::getRelatedColumn($class, $full_through_class); 65 $related_column_name = $related_column->getColumnName(); 66 $related_method = 'get' . $class . 'RelatedBy' . $related_column->getPhpName(); 67 68 $criteria = new Criteria; 69 $criteria->add(constant($class . 'Peer::ID'), $object->getId(), Criteria::NOT_EQUAL); 70 $criteria->addJoin(constant($class . 'Peer::ID'), constant($through_class . 'Peer::' . $related_column_name)); 71 72 $objects = call_user_func(array($class . 'Peer', 'doSelect'), $criteria); 73 $objects_associated = array_map(create_function('$o', 'return $o->' . $related_method . '();'), call_user_func(array($object, $relation_method))); 74 $ids = array_map(create_function('$o', 'return $o->getPrimaryKey();'), $objects_associated); 75 76 return array($objects, $objects_associated, $ids); 77 } plugins/sfAdvancedAdminGeneratorPlugin/branches/naholyr/lib/sfAdvancedAdminGenerator.class.php
r8312 r8435 22 22 class sfAdvancedAdminGenerator extends sfPropelAdminGenerator 23 23 { 24 25 /** 26 * Returns table name from "extended" class name (supports the Class.Column syntax 27 * used for self-referencing many-to-many relations). 28 * 29 * @param string $class_name 30 * @return string 31 */ 32 public function getTableName($class_name) 33 { 34 if (false !== strpos($class_name, '.')) { 35 list($class_name, $ref_column) = explode('.', $class_name, 2); 36 } 37 38 return constant($class_name . 'Peer::TABLE_NAME'); 39 } 40 24 41 /** 25 42 * Initializes the current sfGenerator instance.