<commit_before><?php

class MemberGalleryPage extends Page
{
	function requireDefaultRecords()
	{
		if(!DataObject::get('MemberGalleryPage'))
		{
			$page = new MemberGalleryPage();
			$page->Title = 'Galerie';
			$page->URLSegment = 'galleries';
			$page->write();
			$page->doPublish();
		}
	}
	
	public function Member()
	{
 		$member = null;
		$id = 0;
		switch(Director::urlParam('Action'))
		{
			case 'my':
			case 'new-gallery':
				$id = Director::urlParam('ID');
				break;
				
			default:
				if($this->Gallery() != null) $id = $this->Gallery()->MemberID;
		}
 		
		/*if($id)
		{
			$member = DataObject::get_by_id('Member', $id);
		}
		else
		{
			$member = Member::currentUser();
		}*/
		
		$member = ($id) ? DataObject::get_by_id('Member', $id) : Member::currentUser(); 
		return $member;
	}
	
	public function Gallery()
	{
 		$gallery = null;
 		
		if(is_numeric(Director::urlParam('ID')))
		{
			$gallery = DataObject::get_by_id('ImageGallery', Director::urlParam('ID'));
		}
		return $gallery;
	}
	
	public function Image()
	{
		$image = null;
		if(is_numeric(Director::urlParam('OtherID')))
		{
			$image = DataObject::get_by_id('File', Director::urlParam('OtherID'));
			$image = $image->newClassInstance('ImageGallery_Image');
		}
		return $image->ImageGalleryID == Director::urlParam('ID') ? $image : null;
	}
}

class MemberGalleryPage_Controller extends Page_Controller
{
	protected $my_galleries_cache;
	
	function init()
	{
		Requirements::themedCSS('Gallery');
		$member = $this->Member() ? $this->Member() : null;
		$nicknameText = ($member) ? ($member->Nickname . '\'s ') : '';
		
		$this->Title = $nicknameText . ' Fotoalben';
		
		parent::init();
 	}
	
	public function my()
	{
		return array('CurrentProfile' => $this->Member(), 'Galleries' => $this->MyGalleries(), 'CanAddGallery' => $this->CanAddGallery());
	}
	
	public function new_gallery()
	{
		return array('CurrentProfile' => $this->Member(), 'NewGalleryForm' => $this->NewGalleryForm());
	}
	
	public function upload()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery(), 'ImageUploadForm' => $this->ImageUploadForm());
	}
	
	public function edit()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery(), 'EditGalleryForm' => $this->EditGalleryForm());
	}
	
	public function show()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery());
	}
	
	public function show_image()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery(), 'CurrentImage' => $this->Image());
	}
	
	public function EditGalleryForm()<commit_msg>added delete function for images<commit_after><?php

class MemberGalleryPage extends Page
{
	function requireDefaultRecords()
	{
		if(!DataObject::get('MemberGalleryPage'))
		{
			$page = new MemberGalleryPage();
			$page->Title = 'Galerie';
			$page->URLSegment = 'galleries';
			$page->write();
			$page->doPublish();
		}
	}
	
	public function Member()
	{
 		$member = null;
		$id = 0;
		switch(Director::urlParam('Action'))
		{
			case 'my':
			case 'new-gallery':
				$id = Director::urlParam('ID');
				break;
				
			default:
				if($this->Gallery() != null) $id = $this->Gallery()->MemberID;
		}
 		
		/*if($id)
		{
			$member = DataObject::get_by_id('Member', $id);
		}
		else
		{
			$member = Member::currentUser();
		}*/
		
		$member = ($id) ? DataObject::get_by_id('Member', $id) : Member::currentUser(); 
		return $member;
	}
	
	public function Gallery()
	{
 		$gallery = null;
 		
		if(is_numeric(Director::urlParam('ID')))
		{
			$gallery = DataObject::get_by_id('ImageGallery', Director::urlParam('ID'));
		}
		return $gallery;
	}
	
	public function Image()
	{
		$image = null;
		if(is_numeric(Director::urlParam('OtherID')))
		{
			$image = DataObject::get_by_id('File', Director::urlParam('OtherID'));
			$image = $image->newClassInstance('ImageGallery_Image');
		}
		return $image->ImageGalleryID == Director::urlParam('ID') ? $image : null;
	}
}

class MemberGalleryPage_Controller extends Page_Controller
{
	protected $my_galleries_cache;
	
	function init()
	{
		Requirements::themedCSS('Gallery');
		$member = $this->Member() ? $this->Member() : null;
		$nicknameText = ($member) ? ($member->Nickname . '\'s ') : '';
		
		$this->Title = $nicknameText . ' Fotoalben';
		
		parent::init();
 	}
	
	public function my()
	{
		return array('CurrentProfile' => $this->Member(), 'Galleries' => $this->MyGalleries(), 'CanAddGallery' => $this->CanAddGallery());
	}
	
	public function new_gallery()
	{
		return array('CurrentProfile' => $this->Member(), 'NewGalleryForm' => $this->NewGalleryForm());
	}
	
	public function upload()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery(), 'ImageUploadForm' => $this->ImageUploadForm());
	}
	
	public function edit()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery(), 'EditGalleryForm' => $this->EditGalleryForm());
	}
	
	public function show()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery());
	}
	
	public function show_image()
	{
		return array('CurrentProfile' => $this->Member(), 'CurrentGallery' => $this->Gallery(), 'CurrentImage' => $this->Image());
	}
	
	public function delete_image() {
		$imageID = Director::urlParam('OtherID');
		if(DataObject::get_by_id('Image', $imageID)->OwnerID = Member::currentUserID()){
			DataObject::delete_by_id('Image', $imageID);
		}
		Director::redirect(Director::baseURL() . 'galleries/show/' . Director::urlParam('ID'));
	}
	
	public function EditGalleryForm()
{'fraction_non_alphanumeric': 0.1949317738791423, 'fraction_numerical': 0.000354421407052986, 'mean_word_length': 4.527913809990205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 94, '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': '2213921', 'n_tokens_mistral': 2157, 'n_tokens_neox': 1895, 'n_words': 332}