/** * Synchronise RSS remote contents with articles * @param $id of the curent reader */ public function syncAction($id) { $em = $this->get('doctrine')->getManager(); $reader = $em->getRepository('KeosuCoreBundle:Reader')->find($id); //Convert it to a RssReader $rssReader = RssEventReader::constructfromReader($reader); //geting the feed as a string $rssurl = $rssReader->feed_url; $curl = curl_init($rssurl); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/xml', 'User-Agent: Keosu-UA')); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $feedstring = utf8_decode(curl_exec($curl)); curl_close($curl); //Parse feed to get all elements $craw = new Crawler($feedstring); $entries = $craw->filter('item'); //Item tag is an entry foreach ($entries as $entry) { $this->parseAndImportEvent($entry, $reader); } return $this->redirect($this->generateUrl('keosu_event_viewlist')); }
public function editAction($id) { $commonReader = $this->get('doctrine')->getManager()->getRepository('KeosuCoreBundle:Reader')->find($id); $rssEventReader = RssEventReader::constructfromReader($commonReader); return $this->editReader($rssEventReader, $commonReader); }