thd/apps/frontend/modules/editor/actions/segmentListJsonAction.class.php
changeset 35 94a1dc255022
equal deleted inserted replaced
34:56befcb22751 35:94a1dc255022
       
     1 <?php
       
     2 
       
     3 class segmentListJsonAction extends sfAction
       
     4 {
       
     5   public function execute($request)
       
     6   { 
       
     7 	header("Content-type: text/x-json");
       
     8 	$segments = '';
       
     9 	$this->ref = $this->getRequestParameter('ref');
       
    10 	$this->film_slug = $this->getRequestParameter('film_slug');
       
    11 	
       
    12 	// Get File segmentation Path
       
    13 	$this->path = sfConfig::get('app_storage_uploads');
       
    14 	$this->format = sfConfig::get('app_storage_format');
       
    15 	$file = $this->path.$this->ref."_".$this->film_slug.$this->format;
       
    16 	
       
    17 	
       
    18 	//Check if file exist
       
    19 	if (file_exists($file)) {
       
    20 		$fp = fopen($file, "r");
       
    21 		while (($data = fgetcsv($fp)) != FALSE) {
       
    22 		  $line = "{sin: " . $data[0] .
       
    23 		    ",sout: " . $data[1] .
       
    24 		    ",tag: '" . $data[2] . "'" .
       
    25 		    ",user: '" . $data[3] . "'}";
       
    26 		
       
    27 		  $lines[] = $line;
       
    28 		}
       
    29 		$segments = "[" . join($lines,',') . "]";
       
    30 	}
       
    31 	
       
    32 	// Render json
       
    33 	echo $segments;
       
    34   }
       
    35 }