Files
pae.co.at/trunk copy/proactiveenglish/apps/frontend/modules/whoarewe/actions/actions.class.php
2017-03-02 21:57:21 -06:00

90 lines
2.2 KiB
PHP

<?php
/**
* whoarewe actions.
*
* @package pae
* @subpackage whoarewe
* @author Your name here
* @version SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
*/
class whoareweActions extends sfActions
{
/**
* Executes index action
*
*/
public function executeIndex()
{
$this->staff = EmployeePeer::getStaff();
$this->trainers = EmployeePeer::getTrainers();
}
/**
* Employee details page
*
* @return void
* @author Benjamin Ramey <ben.ramey@gmail.com>
**/
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();
}
}
}