Exemplo n.º 1
0
 /**
  * Saves file which is available by @see ImageInstance::$imageUrl into @see $dir
  *
  * @param ImageInstance $imageInstance
  * @return int
  * @throws \Exception
  */
 public function save(ImageInstance $imageInstance)
 {
     if (!$this->checkDir()) {
         throw new \Exception('Wrong directory!');
     }
     $fileName = $imageInstance->getImageName();
     $fileFullName = $this->dir . DIRECTORY_SEPARATOR . $fileName;
     $imageUrl = $imageInstance->getImageUrl();
     return $this->createFile($fileFullName, $imageUrl);
 }
 /**
  * Checks if image exists and matches allowed formats @see $allowedFormats
  *
  * @param ImageInstance $imageInstance
  * @return bool
  */
 public function validate(ImageInstance $imageInstance)
 {
     $imageFormat = $this->getImageFormat($imageInstance->getImageFormatCode());
     if (empty($imageFormat)) {
         return false;
     }
     if (!in_array($imageFormat, $this->allowedFormats)) {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
Arquivo: index.php Projeto: fulldump/8
<?php

$id = '';
eval('$id=' . var_export($data['id'], true) . ';');
$edit = !in_array('noedit', $flags);
$image = ImageInstance::getByName($id);
if (null === $image) {
    $image = ImageInstance::INSERT();
    $image->setName($id);
}
$options = '';
if (array_key_exists('style', $data)) {
    $options = "/{$data['style']}";
}
$url = "/img/{$image->getImage()->getId()}{$options}";
if (in_array('background', $flags)) {
    if (array_key_exists('edit', $_GET) && Session::isLoggedIn() && $edit) {
        echo "<div style=\"background-image:url('{$url}')\" edit_id='{$id}' edit_options='{$options}' component='Image' class='background'></div>";
    } else {
        echo "<div style=\"background-image:url('{$url}')\" component='Image' class='background'></div>";
    }
} else {
    if (array_key_exists('edit', $_GET) && Session::isLoggedIn() && $edit) {
        echo "<img src='{$url}' alt='{$image->getDescription()}' edit_id='{$id}' edit_options='{$options}' component='Image' editable>";
    } else {
        echo "<img src='{$url}' alt='{$image->getDescription()}'>";
    }
}
Exemplo n.º 4
0
<?php

$id_image_instance = $_POST['id_image_instance'];
$id_image = $_POST['id_image'];
if (Session::isLoggedIn()) {
    ImageInstance::getByName($id_image_instance)->setImage(Image::ROW($id_image));
}