72 lines
2.2 KiB
PHP
72 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* employee actions.
|
|
*
|
|
* @package pae
|
|
* @subpackage employee
|
|
* @author Your name here
|
|
* @version SVN: $Id: actions.class.php 2288 2006-10-02 15:22:13Z fabien $
|
|
*/
|
|
class employeeActions extends autoemployeeActions
|
|
{
|
|
/**
|
|
* Override of base-class method to handle saving
|
|
* the partial that does the picture edit field.
|
|
*
|
|
* @return void
|
|
* @author Benjamin Ramey <ben.ramey@gmail.com>
|
|
**/
|
|
public function updateEmployeeFromRequest()
|
|
{
|
|
parent::updateEmployeeFromRequest();
|
|
|
|
$request = $this->getRequest();
|
|
|
|
// create the slug
|
|
$slug = strtolower(preg_replace("/\W+/", "", $this->employee->getName()));
|
|
$this->employee->setSlug($slug);
|
|
|
|
// save the titles which are also internationalized
|
|
foreach($request->getParameter('title') as $culture => $value)
|
|
{
|
|
$this->employee->setCulture($culture);
|
|
$this->employee->setTitle($value);
|
|
}
|
|
|
|
// save the biographies as we also use a custom template for them
|
|
foreach($request->getParameter('biography') as $culture => $value)
|
|
{
|
|
$this->employee->setCulture($culture);
|
|
$this->employee->setBiography($value);
|
|
}
|
|
|
|
// save the picture as we use a custom template for it
|
|
if($request->hasFiles())
|
|
{
|
|
foreach($request->getFileNames() as $fileName)
|
|
{
|
|
if($request->getFileSize($fileName) <= 0)
|
|
continue;
|
|
|
|
$employeeImagePath = sfConfig::get('sf_web_dir').'/images/whoarewe/employees';
|
|
$pictureName = str_replace(" ", "", $this->employee->getName()) . $request->getFileExtension($fileName);
|
|
$request->moveFile($fileName, $employeeImagePath.'/'.$pictureName);
|
|
|
|
// resize the image to the standard size
|
|
$image = new phMagick($employeeImagePath.'/'.$pictureName);
|
|
$image->setDestination($employeeImagePath.'/'.$pictureName);
|
|
$image->resize(200, 0);
|
|
|
|
// create the thumbnail image
|
|
$thumbnail = $image;
|
|
$thumbnail->setDestination($employeeImagePath.'/thumb_'.$pictureName);
|
|
$thumbnail->resize(70,0);
|
|
|
|
// save the image name in the employee
|
|
$this->employee->setPicture($pictureName);
|
|
}
|
|
}
|
|
}
|
|
}
|