75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Created by CS medien- & kommunikationssysteme.
|
|
* @author Christian Steinle
|
|
* @date 03.08.2016
|
|
*
|
|
* @copyright CS medien- & kommunikationssysteme (http://www.steinle-computer.de)
|
|
*/
|
|
|
|
namespace Model;
|
|
|
|
|
|
use Helper\Database;
|
|
use Helper\Registry;
|
|
|
|
class ImageTextModel extends Database
|
|
{
|
|
const TBL_NAME = TBL_IMAGE_TEXT;
|
|
|
|
const PRIMARY_KEY = 'imageTextID';
|
|
|
|
|
|
/**
|
|
* Setzt die Relationen zu anderen Modellen
|
|
* @author Christian Steinle
|
|
*/
|
|
public static function setRelations()
|
|
{
|
|
static::$relations = array(
|
|
0 => array(
|
|
'ownKey' => 'imageID',
|
|
'foreignModel' => 'Model\\ImageModel',
|
|
'foreignKey' => 'imageID'
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Erzeugt die benötigten Bilder im Medien-Pfad und bereitet den Request auf
|
|
* @author Christian Steinle
|
|
*
|
|
* @param array $request
|
|
*/
|
|
protected static function beforeInsert(array &$request)
|
|
{
|
|
$registry = Registry::getInstance();
|
|
$imageData = $registry->editorConfig['imageDimension']['image'];
|
|
$standardImagePath = substr(str_replace(PATH_PREFIX, '', PATH_ROOT), 0, -1) . $imageData['standardImage'];
|
|
$navID = $request['navID'];
|
|
unset($request['navID']);
|
|
|
|
$mediaPath = $registry->editorConfig['mediaPath'] . $navID . '/';
|
|
if (!is_dir($mediaPath))
|
|
{
|
|
mkdir($mediaPath, 0775, true);
|
|
}
|
|
|
|
$filename = end(explode('/', $standardImagePath));
|
|
$newFilename = ImageModel::getUniqueFilename($mediaPath, $filename);
|
|
$fileArray = ImageModel::filenameToArray($filename);
|
|
$request['imageOrigName'] = $fileArray['filename'];
|
|
$request['imageExtension'] = $fileArray['extension'];
|
|
$request['imageName'] = $newFilename;
|
|
list($width, $height) = getimagesize($standardImagePath);
|
|
$request['imageTop'] = 0;
|
|
$request['imageLeft'] = 0;
|
|
$request['imageHeight'] = $height;
|
|
$request['imageWidth'] = $width;
|
|
$request['imageTextModel'] = true;
|
|
ImageModel::copyStandardImage($mediaPath, $newFilename . '.' . $fileArray['extension'], 'image');
|
|
}
|
|
|
|
|
|
} |