<commit_before><?php
class changeSitetreeForm extends SitetreeForm 
{
  public function setup()  
  {
    parent::setup();
    
    // set sitetree for form
    $tree = siteManager::getInstance()->getSitetreeForForm($this->object->site, null, false, array('lft'=>$this->object->lft, 'rgt'=>$this->object->rgt));
    
    $this->widgetSchema['parent'] = new sfWidgetFormChoice(array('choices'=>$tree));
    $this->validatorSchema['parent'] = new sfValidatorCallback(array('callback'=>array($this, 'checkParent')), array('invalid'=>'This is already the parent page'));
    $this->widgetSchema->setHelp('parent', 'Select where you want to move this page to - the page you select will become the parent page');
    
    $this->useFields(array('parent'));
  }
  
  
  public function checkParent($validator, $value)
  {
    $currentParent = $this->object->getNode()->getParent();
    
    if ($value == $currentParent->route_name)
    {
      $error = new sfValidatorError($validator, 'invalid');
      throw new sfValidatorErrorSchema($validator, array('parent' => $error));
    }
    
    return $value;
  }
  
  
  public function doSave($con = null) 
  {
    $parent = SitetreeTable::getInstance()->findOneByRouteName($this->getValue('parent'));
    $this->object->getNode()->moveAsLastChildOf($parent);
  }  
}<commit_msg>Fix for moving parent - accidentally moving site! <commit_after><?php
class changeSitetreeForm extends SitetreeForm 
{
  public function setup()  
  {
    parent::setup();
    
    // set sitetree for form
    $tree = siteManager::getInstance()->getSitetreeForForm($this->object->site, null, false, array('lft'=>$this->object->lft, 'rgt'=>$this->object->rgt), 'id');
    
    $this->widgetSchema['parent'] = new sfWidgetFormChoice(array('choices'=>$tree));
    $this->validatorSchema['parent'] = new sfValidatorCallback(array('callback'=>array($this, 'checkParent')), array('invalid'=>'This is already the parent page'));
    $this->widgetSchema->setHelp('parent', 'Select where you want to move this page to - the page you select will become the parent page');
    
    $this->useFields(array('parent', 'site'));
  }
  
  
  public function checkParent($validator, $value)
  {
    $currentParent = $this->object->getNode()->getParent();
    
    if ($value == $currentParent->route_name)
    {
      $error = new sfValidatorError($validator, 'invalid');
      throw new sfValidatorErrorSchema($validator, array('parent' => $error));
    }
    
    return $value;
  }
  
  
  public function doSave($con = null) 
  {
    $parent = SitetreeTable::getInstance()->findOneById($this->getValue('parent'));
    $this->object->getNode()->moveAsLastChildOf($parent);
  }  
}
{'fraction_non_alphanumeric': 0.16889880952380953, 'fraction_numerical': 0.0, 'mean_word_length': 4.211240310077519, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '969685', 'n_tokens_mistral': 791, 'n_tokens_neox': 803, 'n_words': 167}