Add author management functionality and update routing rules
- Updated .htaccess rules to allow trailing slashes for specific routes. - Introduced a new .gitignore file to exclude the cache directory. - Created project configuration file for Serena with language and tool settings. - Implemented Authors class for managing author data, including methods for saving, deleting, and editing authors. - Added factory class for Authors to handle database interactions related to authors. - Developed Article class to manage article data and interactions, including fetching articles and updating views. - Created Page class with a placeholder method for sorting pages. - Added front factory class for fetching author details with caching.
This commit is contained in:
@@ -15,10 +15,11 @@ class ImageManipulator
|
||||
* @var resource
|
||||
*/
|
||||
protected $image;
|
||||
protected $img_src;
|
||||
|
||||
/**
|
||||
* Image manipulator constructor
|
||||
*
|
||||
*
|
||||
* @param string $file OPTIONAL Path to image file or image data as string
|
||||
* @return void
|
||||
*/
|
||||
@@ -26,8 +27,10 @@ class ImageManipulator
|
||||
{
|
||||
if (null !== $file) {
|
||||
if (is_file($file)) {
|
||||
$this -> img_src = $file;
|
||||
$this->setImageFile($file);
|
||||
} else {
|
||||
echo 'a'; exit;
|
||||
$this->setImageString($file);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +38,7 @@ class ImageManipulator
|
||||
|
||||
/**
|
||||
* Set image resource from file
|
||||
*
|
||||
*
|
||||
* @param string $file Path to image file
|
||||
* @return ImageManipulator for a fluent interface
|
||||
* @throws InvalidArgumentException
|
||||
@@ -68,10 +71,10 @@ class ImageManipulator
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set image resource from string data
|
||||
*
|
||||
*
|
||||
* @param string $data
|
||||
* @return ImageManipulator for a fluent interface
|
||||
* @throws RuntimeException
|
||||
@@ -99,7 +102,7 @@ class ImageManipulator
|
||||
* @return ImageManipulator for a fluent interface
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function resample($width, $height, $constrainProportions = true)
|
||||
public function resample( $width, $height, $constrainProportions = true )
|
||||
{
|
||||
if (!is_resource($this->image)) {
|
||||
throw new RuntimeException('No image set');
|
||||
@@ -111,14 +114,44 @@ class ImageManipulator
|
||||
$height = round($width / $this->width * $this->height);
|
||||
}
|
||||
}
|
||||
|
||||
$temp = imagecreatetruecolor($width, $height);
|
||||
|
||||
imagecopyresampled($temp, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
|
||||
|
||||
if ( function_exists('exif_read_data') )
|
||||
{
|
||||
$exif = exif_read_data( $this -> img_src );
|
||||
if ( $exif && isset($exif['Orientation']) )
|
||||
{
|
||||
$orientation = $exif['Orientation'];
|
||||
if ( $orientation != 1 )
|
||||
{
|
||||
$deg = 0;
|
||||
switch ($orientation)
|
||||
{
|
||||
case 3:
|
||||
$deg = 180;
|
||||
break;
|
||||
case 6:
|
||||
$deg = 270;
|
||||
break;
|
||||
case 8:
|
||||
$deg = 90;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $deg )
|
||||
$temp = imagerotate( $temp, $deg, 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->_replace($temp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enlarge canvas
|
||||
*
|
||||
*
|
||||
* @param int $width Canvas width
|
||||
* @param int $height Canvas height
|
||||
* @param array $rgb RGB colour values
|
||||
@@ -132,30 +165,30 @@ class ImageManipulator
|
||||
if (!is_resource($this->image)) {
|
||||
throw new RuntimeException('No image set');
|
||||
}
|
||||
|
||||
|
||||
$width = max($width, $this->width);
|
||||
$height = max($height, $this->height);
|
||||
|
||||
|
||||
$temp = imagecreatetruecolor($width, $height);
|
||||
if (count($rgb) == 3) {
|
||||
$bg = imagecolorallocate($temp, $rgb[0], $rgb[1], $rgb[2]);
|
||||
imagefill($temp, 0, 0, $bg);
|
||||
}
|
||||
|
||||
|
||||
if (null === $xpos) {
|
||||
$xpos = round(($width - $this->width) / 2);
|
||||
}
|
||||
if (null === $ypos) {
|
||||
$ypos = round(($height - $this->height) / 2);
|
||||
}
|
||||
|
||||
|
||||
imagecopy($temp, $this->image, (int) $xpos, (int) $ypos, 0, 0, $this->width, $this->height);
|
||||
return $this->_replace($temp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Crop image
|
||||
*
|
||||
*
|
||||
* @param int|array $x1 Top left x-coordinate of crop box or array of coordinates
|
||||
* @param int $y1 Top left y-coordinate of crop box
|
||||
* @param int $x2 Bottom right x-coordinate of crop box
|
||||
@@ -171,25 +204,25 @@ class ImageManipulator
|
||||
if (is_array($x1) && 4 == count($x1)) {
|
||||
list($x1, $y1, $x2, $y2) = $x1;
|
||||
}
|
||||
|
||||
|
||||
$x1 = max($x1, 0);
|
||||
$y1 = max($y1, 0);
|
||||
|
||||
|
||||
$x2 = min($x2, $this->width);
|
||||
$y2 = min($y2, $this->height);
|
||||
|
||||
|
||||
$width = $x2 - $x1;
|
||||
$height = $y2 - $y1;
|
||||
|
||||
|
||||
$temp = imagecreatetruecolor($width, $height);
|
||||
imagecopy($temp, $this->image, 0, 0, $x1, $y1, $width, $height);
|
||||
|
||||
|
||||
return $this->_replace($temp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace current image resource with a new one
|
||||
*
|
||||
*
|
||||
* @param resource $res New image resource
|
||||
* @return ImageManipulator for a fluent interface
|
||||
* @throws UnexpectedValueException
|
||||
@@ -207,10 +240,10 @@ class ImageManipulator
|
||||
$this->height = imagesy($res);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save current image to file
|
||||
*
|
||||
*
|
||||
* @param string $fileName
|
||||
* @return void
|
||||
* @throws RuntimeException
|
||||
@@ -223,7 +256,7 @@ class ImageManipulator
|
||||
throw new RuntimeException('Error creating directory ' . $dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
switch ($type) {
|
||||
case IMAGETYPE_GIF :
|
||||
|
||||
Reference in New Issue
Block a user