<?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;
}
}