staff = EmployeePeer::getStaff(); $this->trainers = EmployeePeer::getTrainers(); } /** * Employee details page * * @return void * @author Benjamin Ramey **/ public function executeEmployee() { $slug = $this->getRequestParameter('employeeNameSlug'); $this->employee = EmployeePeer::getBySlug($slug); if(!$this->employee) { $this->forward404(); } $this->employee = $this->employee[0]; $this->employee->setCulture($this->getUser()->getCulture()); } private function Transform() { $path = sfConfig::get('sf_data_dir')."/xml/employees"; $allFiles = scandir($path); $files = array(); for($c = 0; $c < count($allFiles); $c++) { if(substr($allFiles[$c], -3) == "xml") array_push($files, $allFiles[$c]); } foreach($files as $file) { $emp = new Employee(); $xml = simplexml_load_file(sfConfig::get('sf_data_dir')."/xml/employees/".$file); $emp->setActive(true); $emp->setPosition("trainer"); $emp->setName((string)$xml->name); $emp->setSlug(str_replace(" ", "", strtolower((string)$xml->name))); $emp->setDegrees((string)$xml->degree); $emp->setPhone((string)$xml->contact->phone); $emp->setCellphone((string)$xml->contact->mobile); $emp->setEmail((string)$xml->contact->email); $emp->setPicture((string)$xml->portrait); $emp->setCulture('en'); $emp->setTitle((string)$xml->title->en); $emp->setCulture('de'); $emp->setTitle((string)$xml->title->de); foreach($xml->xpath('/trainer/biography') as $bio) { $emp->setCulture((string)$bio['lang']); $text = array(); foreach($bio->xpath('paragraph') as $para) { array_push($text, (string)$para); } $emp->setBiography(implode("\n\n", $text)); } $emp->save(); } } }