thd/apps/frontend/modules/editor/actions/segmentListJsonAction.class.php
author ymh <ymh.work@gmail.com>
Wed, 01 Jun 2016 14:07:43 +0200
changeset 103 d2af8a210f5d
parent 35 94a1dc255022
permissions -rw-r--r--
merge bundle

<?php

class segmentListJsonAction extends sfAction
{
  public function execute($request)
  { 
	header("Content-type: text/x-json");
	$segments = '';
	$this->ref = $this->getRequestParameter('ref');
	$this->film_slug = $this->getRequestParameter('film_slug');
	
	// Get File segmentation Path
	$this->path = sfConfig::get('app_storage_uploads');
	$this->format = sfConfig::get('app_storage_format');
	$file = $this->path.$this->ref."_".$this->film_slug.$this->format;
	
	
	//Check if file exist
	if (file_exists($file)) {
		$fp = fopen($file, "r");
		while (($data = fgetcsv($fp)) != FALSE) {
		  $line = "{sin: " . $data[0] .
		    ",sout: " . $data[1] .
		    ",tag: '" . $data[2] . "'" .
		    ",user: '" . $data[3] . "'}";
		
		  $lines[] = $line;
		}
		$segments = "[" . join($lines,',') . "]";
	}
	
	// Render json
	echo $segments;
  }
}