<commit_before><?php
namespace Videos\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use MarvinFileUploadUtils\FileUploadUtils;
use Zend\View\Model\JsonModel;

class VideosController extends AbstractActionController {
	protected $videosTable;
	
	public function indexAction() {
     $videosPaginator = $this->getVideosTable()->getNewestVideos();
     // set the current page to what has been passed in query string, or to 1 if none set
     $videosPaginator->setCurrentPageNumber($this->params()->fromRoute('page', 0));
     // set the number of items per page to 10
     $videosPaginator->setItemCountPerPage(15);
     
     return new ViewModel(array('videos'=>$videosPaginator,));
	}

	public function playAction(){
		
		$id = (int) $this->params()->fromRoute('id', 0);
		if (!$id) {
			return $this->redirect()->toRoute('videos');
		}
		
		// Get the Album with the specified id.  An exception is thrown
		// if it cannot be found, in which case go to the index page.
		try {
			$videoToplay = $this->getVideosTable()->getVideoSigle($id);
			$relatedVideos = $this->getVideosTable()->getRelatedVideos($videoToplay->title);
			$this->getVideosTable()->UpdateVideoViews($videoToplay->id,$videoToplay->views);
			
		}
		catch (\Exception $ex) {
			//change this to 404
			$this->flashmessenger()->addErrorMessage($ex->getMessage());
			return $this->redirect()->toRoute('videos');
		}
		
		return new ViewModel(array('playVideo'=>$videoToplay,
		                           'relatedVideos'=>$relatedVideos));
	}
	
	
	 public function VideosByCategoryAction(){

	 	$id = (int) $this->params()->fromRoute('id', 0);
	 	if (!$id) {
	 		return $this->redirect()->toRoute('video-categories');<commit_msg>Enhance script in getting related videos<commit_after><?php
namespace Videos\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use MarvinFileUploadUtils\FileUploadUtils;
use Zend\View\Model\JsonModel;

class VideosController extends AbstractActionController {
	protected $videosTable;
	
	public function indexAction() {
     $videosPaginator = $this->getVideosTable()->getNewestVideos();
     // set the current page to what has been passed in query string, or to 1 if none set
     $videosPaginator->setCurrentPageNumber($this->params()->fromRoute('page', 0));
     // set the number of items per page to 10
     $videosPaginator->setItemCountPerPage(15);
     
     return new ViewModel(array('videos'=>$videosPaginator,));
	}

	public function playAction(){
		
		$id = (int) $this->params()->fromRoute('id', 0);
		if (!$id) {
			return $this->redirect()->toRoute('videos');
		}
		
		// Get the Album with the specified id.  An exception is thrown
		// if it cannot be found, in which case go to the index page.
		try {
			$videoToplay = $this->getVideosTable()->getVideoSigle($id);
			$relatedVideos = $this->getVideosTable()->getRelatedVideos($videoToplay->title);
			$this->getVideosTable()->UpdateVideoViews($videoToplay->id,$videoToplay->views);
			
		}
		catch (\Exception $ex) {
			//change this to 404
			$this->flashmessenger()->addErrorMessage($ex->getMessage());
			return $this->redirect()->toRoute('videos');
		}
		
		// set the current page to what has been passed in query string, or to 1 if none set
		$relatedVideos->setCurrentPageNumber($this->params()->fromRoute('page', 0));
		// set the number of items per page to 10
		$relatedVideos->setItemCountPerPage(15);
		
		return new ViewModel(array('playVideo'=>$videoToplay,
		                           'relatedVideos'=>$relatedVideos));
	}
	
	
	 public function VideosByCategoryAction(){

	 	$id = (int) $this->params()->fromRoute('id', 0);
	 	if (!$id) {
	 		return $this->redirect()->toRoute('video-categories');
{'fraction_non_alphanumeric': 0.14656771799628943, 'fraction_numerical': 0.0074211502782931356, 'mean_word_length': 4.120759837177747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 69, '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': '3015928', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1127, 'n_words': 278}