public function ImageTag()
 {
     if (is_numeric($this->Image())) {
         return Image::get()->byID($this->Image())->SetSize($this->imageWidth, $this->imageHeight)->getTag();
     }
     return $this->image;
 }
 protected function runBeforeTemplateParsing($objTemplate, $objItem)
 {
     $this->imgSize = deserialize($this->imgSize, true);
     if ($objTemplate->isAuthor && !$objItem->raw['published']) {
         $objTemplate->unpublished = true;
     }
     // media
     $strMedia = '';
     if ($objItem->raw['mediaType'] == 'video') {
         $objItem->addYouTube = true;
         $objItem->youtube = preg_replace('@.*watch\\?v=([^&]+).*@i', '$1', $objItem->pinBoardYouTube);
         $objYouTube = YouTubeVideo::getInstance()->setData($objItem->row());
         $objYouTube->autoplay = true;
         $strMedia = $objYouTube->generate();
     } elseif ($objItem->pinBoardImage) {
         $strMedia = $objItem->pinBoardImage;
     }
     if ($strMedia && $objItem->raw['mediaType'] == 'image') {
         $objTemplate->media = \Image::get($strMedia, $this->imgSize[0], $this->imgSize[1], $this->imgSize[2]);
         $arrSize = getimagesize(urldecode(TL_ROOT . '/' . $objTemplate->media));
         if (count($arrSize) > 1) {
             $objTemplate->imgSizeParsed = 'width="' . $arrSize[0] . '" height="' . $arrSize[1] . '"';
         }
     } else {
         $objTemplate->media = $strMedia;
     }
 }
 /**
  * cache the images to static::$images
  *
  * @param $template
  *
  * @throws \Exception
  */
 public function cachedImages($template)
 {
     if (TL_MODE === 'FE') {
         /** @var \PageModel $objPage */
         global $objPage;
         $layout = $objPage->getRelated('layout');
         if ($layout->activateImageSecSet && $template->singelSRC || $template->multiSRC) {
             $template->size = deserialize($template->size);
             if ($template->size[0] || $template->size[1]) {
                 if ($image = $template->singleSRC) {
                     $images = array($image);
                 }
                 if ($images = $template->multiSRC) {
                     if (!is_array($images)) {
                         $images = deserialize($images);
                     }
                 }
                 if (is_array($images)) {
                     foreach ($images as $image) {
                         $file = \FilesModel::findByUuid($image);
                         $path = \Image::get($file->path, $template->size[0], $template->size[1], $template->size[2]);
                         $buffer = array('path' => $file->path);
                         if (!isset(static::$images[$path])) {
                             static::$images[$path] = $buffer;
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * @return string
  */
 public function generate()
 {
     if (TL_MODE === 'BE') {
         $template = new \BackendTemplate('be_wildcard');
         $template->wildcard = '### ANTRAGO Event-Details ###';
         $template->title = 'Event Details';
         //"Kategorien: " . implode(', ',deserialize($this->arrData['ac_categories']));
         return $template->parse();
     }
     // hole event details;
     $url = $_SERVER["REQUEST_URI"];
     $id = explode("veranstaltung=", $url)[1];
     $this->configuration = AntragoConnector::getAntragoConfiguration($this->arrData['ac_event_details_config']);
     $db = \Database::getInstance();
     $this->product = $db->prepare("SELECT * FROM tl_antrago_products WHERE productId=?")->execute($id)->fetchAssoc();
     $this->formConfig = array('showRegisterForm' => $this->arrData['ac_event_details_show_register'], 'showApplicationForm' => $this->arrData['ac_event_details_show_applicationform']);
     // contact
     $this->contact = $db->prepare("SELECT * FROM tl_antrago_contacts WHERE id =?")->execute($this->product['productContact'])->fetchAssoc();
     $oContactImage = \FilesModel::findByPk($this->contact['image']);
     // Add cover image
     if ($oContactImage !== null) {
         $sImage = \Image::get($oContactImage->path, '80', '100', 'center_center');
     }
     $this->contact['image'] = $sImage;
     return parent::generate();
 }
Exemplo n.º 5
0
 public function localupdate()
 {
     if ($this->canEdit() && ($imageDataString = $this->request->requestVar('imageData')) && ($imageID = $this->request->requestVar('imageID')) && ($image = Image::get()->byID(Convert::raw2sql($imageID)))) {
         //$imageDataString = file_get_contents($newFile);
         $imageData = base64_decode(preg_replace('#^data:image/\\w+;base64,#i', '', $imageDataString));
         $path = $image->getFullPath();
         // if we have a new file + old path, overwrite old image wiith new image.
         if ($imageData && $path) {
             // Do we need to validate it the filetype is still the same as the original?
             //$f = finfo_open();
             //$mime_type = finfo_buffer($f, $imageData, FILEINFO_MIME_TYPE);
             //finfo_close($f);
             file_put_contents($path, $imageData);
             $image->forceChange();
             $image->deleteFormattedImages();
             $image->write();
             // return new thumbnail
             $formattedImage = $image->getFormattedImage('SetWidth', Config::inst()->get('Image', 'asset_preview_width'));
             $thumbnail = $formattedImage ? $formattedImage->URL : '';
             if ($this->request->isAjax()) {
                 $this->request->addHeader('Content-type', 'application/json');
                 return json_encode(['thumbnail' => $thumbnail]);
             }
             return $thumbnail;
         }
     }
 }
Exemplo n.º 6
0
 function &create(&$root, &$pipeline)
 {
     $name = $root->get_attribute('name');
     $value = $root->get_attribute('value');
     $url_autofix = new AutofixUrl();
     $src = $url_autofix->apply(trim($root->get_attribute("src")));
     $src_img = Image::get($pipeline->guess_url($src), $pipeline);
     if (is_null($src_img)) {
         error_log(sprintf("Cannot open image at '%s'", $src));
         if ($root->has_attribute('width')) {
             $width = px2pt($root->get_attribute('width'));
         } else {
             $width = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
         }
         if ($root->has_attribute('height')) {
             $height = px2pt($root->get_attribute('height'));
         } else {
             $height = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
         }
         $alt = $root->get_attribute('alt');
         $css_state =& $pipeline->getCurrentCSSState();
         $box =& new ButtonBrokenImagebox($width, $height, $alt, $name, $value, $css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
         $box->readCSS($css_state);
         return $box;
     }
     $css_state =& $pipeline->getCurrentCSSState();
     $box =& new ButtonImageBox($src_img, $name, $value, $css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
     $box->readCSS($css_state);
     $box->_setupSize();
     return $box;
 }
 protected function runBeforeTemplateParsing($objTemplate, $arrItem)
 {
     $objTemplate->ago = DateUtil::getTimeElapsed($arrItem['raw']['date']);
     $objTemplate->commentCount = \CommentsModel::countPublishedBySourceAndParent('tl_news', $arrItem['fields']['id']);
     $objTemplate->isAuthor = $arrItem['raw']['memberAuthor'] == \FrontendUser::getInstance()->id;
     $this->imgSize = deserialize($this->imgSize, true);
     if ($objTemplate->isAuthor && !$arrItem['raw']['published']) {
         $objTemplate->unpublished = true;
     }
     // media
     $strMedia = '';
     if ($arrItem['raw']['mediaType'] == 'video') {
         $arrItem['fields']['addYouTube'] = true;
         $arrItem['fields']['youtube'] = preg_replace('@.*watch\\?v=([^&]+).*@i', '$1', $arrItem['fields']['pinBoardYouTube']);
         $objYouTube = YouTubeVideo::getInstance()->setData($arrItem['fields']);
         $strMedia = $objYouTube->getCachedYouTubePreviewImage();
     } elseif ($arrItem['fields']['pinBoardImage']) {
         $strMedia = $arrItem['fields']['pinBoardImage'];
     }
     if ($strMedia) {
         $objTemplate->media = \Image::get($strMedia, $this->imgSize[0], $this->imgSize[1], $this->imgSize[2]);
         $arrSize = getimagesize(urldecode(TL_ROOT . '/' . $objTemplate->media));
         if (count($arrSize) > 1) {
             $objTemplate->imgSizeParsed = 'width="' . $arrSize[0] . '" height="' . $arrSize[1] . '"';
         }
     }
 }
 public function processRecord($record, $columnMap, &$results, $preview = false)
 {
     // Get Current Object
     $objID = parent::processRecord($record, $columnMap, $results, $preview);
     $object = DataObject::get_by_id($this->objectClass, $objID);
     $this->extend("onBeforeProcess", $object, $record, $columnMap, $results, $preview);
     // Loop through all fields and setup associations
     foreach ($record as $key => $value) {
         // Find any categories (denoted by a 'CategoryXX' column)
         if (strpos($key, 'Category') !== false) {
             $category = CatalogueCategory::get()->filter("Title", $value)->first();
             if ($category) {
                 $object->Categories()->add($category);
             }
         }
         // Find any Images (denoted by a 'ImageXX' column)
         if (strpos($key, 'Image') !== false && $key != "Images") {
             $image = Image::get()->filter("Name", $value)->first();
             if ($image) {
                 $object->Images()->add($image);
             }
         }
         // Find any related products (denoted by a 'RelatedXX' column)
         if (strpos($key, 'Related') !== false && $key != "RelatedProducts") {
             $product = Product::get()->filter("StockID", $value)->first();
             if ($product) {
                 $object->RelatedProducts()->add($product);
             }
         }
     }
     $this->extend("onAfterProcess", $object, $record, $columnMap, $results, $preview);
     $object->destroy();
     unset($object);
     return $objID;
 }
 /**
  * Displays a random image with colorbox effect from a given assets subfolder
  * Uses template "csoft-shortcode/templates/Includes/RandomImage.ss" for output 
  * 
  * @param mixed $arguments (folder='subfolder_in_assets' align='left|right')
  * @param $content = null
  * @param $parser = null
  * @return processed template RandomImage.ss
  */
 public static function cwsShortCodeRandomImageHandler($arguments, $content = null, $parser = null)
 {
     // only proceed if subfolder was defined
     if (!isset($arguments['folder'])) {
         return;
     }
     // sanitize user inputs
     $folder = Convert::raw2sql($arguments['folder']);
     $align = isset($arguments['align']) ? strtolower(Convert::raw2xml($arguments['align'])) : '';
     // fetch all images in random order from the user defined folder
     $folder = Folder::get()->filter('Filename', "assets/{$folder}/")->First();
     $randomImage = $folder ? Image::get()->filter('ParentID', $folder->ID)->sort('RAND()') : false;
     // exit if user defined folder does not contain any image
     if (!$randomImage) {
         return;
     }
     // extract image caption from image filename
     $caption = $randomImage->Title;
     if (preg_match('#(\\d*-)?(.+)\\.(jpg|gif|png)#i', $caption, $matches)) {
         $caption = ucfirst(str_replace('-', ' ', $matches[2]));
     }
     // prepare data for output
     $data = array('RandomImage' => $randomImage->First(), 'Alignment' => $align, 'Caption' => $caption);
     // load template and process data
     $template = new SSViewer('RandomImage');
     return $template->process(new ArrayData($data));
 }
Exemplo n.º 10
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     $intList = $this->athletes_group;
     $objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList);
     //$objMembers = \MembersModel;
     // Return if no Members were found
     if (!$objMembers->numRows) {
         return;
     }
     $strLink = '';
     // Generate a jumpTo link
     if ($this->jumpTo > 0) {
         $objJump = \PageModel::findByPk($this->jumpTo);
         if ($objJump !== null) {
             $strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s');
         }
     }
     $arrMembers = array();
     // Generate Members
     while ($objMembers->next()) {
         $strPhoto = '';
         $objPhoto = \FilesModel::findByPk($objMembers->photo);
         // Add photo image
         if ($objPhoto !== null) {
             $strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center'));
         }
         $arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : '');
     }
     $this->Template->members = $arrMembers;
 }
Exemplo n.º 11
0
 /**
  * @return array
  * @todo Criar uma view no BD para retornar essas informações
  */
 public function getArrayDados()
 {
     $informante = (new PessoaFisicaDAO())->getById($this->dto->getCdPfInformante());
     $cd_condominio = '';
     $condominio = '';
     $condominio_foto = '';
     $setor = '';
     $setor_foto = '';
     if ($this->dto->getCdSetor()) {
         $setorDTO = (new SetorDAO())->getById($this->dto->getCdSetor());
         $condominioDTO = (new PessoaJuridicaDAO())->getById($setorDTO->getCdCondominio());
         $setor = $setorDTO->getNmSetor();
         $setor_foto = Image::get($setorDTO);
         $cd_condominio = $condominioDTO->getCdPessoaJuridica();
         $condominio = $condominioDTO->getNmFantasia();
         $condominio_foto = Image::get($condominioDTO);
     }
     $categoria = new CategoriaValorDAO();
     $estagio = '';
     if ($this->dto->getCdCatgEstagio()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgEstagio(), $this->dto->getCdCatgEstagio());
         $estagio = $catg->getDescVlCatg();
     }
     $tipo = '';
     if ($this->dto->getCdCatgTipo()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgTipo(), $this->dto->getCdCatgTipo());
         $tipo = $catg->getDescVlCatg();
     }
     return array('cd_ocorrencia' => $this->dto->getCdOcorrencia(), 'cd_setor' => $this->dto->getCdSetor(), 'setor' => $setor, 'setor_foto' => $setor_foto, 'cd_condominio' => $cd_condominio, 'condominio' => $condominio, 'condominio_foto' => $condominio_foto, 'cd_pf_informante' => $this->dto->getCdPfInformante(), 'informante' => $informante->getNmPessoaFisica(), 'informante_foto' => Image::get($informante), 'desc_assunto' => $this->dto->getDescAssunto(), 'desc_ocorrencia' => $this->dto->getDescOcorrencia(), 'dt_ocorrencia' => (new DateTime($this->dto->getDtOcorrencia()))->format('d/m/Y'), 'dt_fim' => $this->dto->getDtFim() ? (new DateTime($this->dto->getDtFim()))->format('d/m/Y') : 'em aberto', 'desc_conclusao' => $this->dto->getDescConclusao(), 'cd_catg_estagio' => $this->dto->getCdCatgEstagio(), 'cd_vl_catg_estagio' => $this->dto->getCdVlCatgEstagio(), 'estagio' => $estagio, 'cd_catg_tipo' => $this->dto->getCdCatgTipo(), 'cd_vl_catg_tipo' => $this->dto->getCdVlCatgTipo(), 'tipo' => $tipo);
 }
Exemplo n.º 12
0
 public function getArrayDados()
 {
     $pessoaFisicaDao = new PessoaFisicaDAO();
     $setorDTO = (new SetorDAO())->getById($this->dto->getCdSetor());
     $setorDados = (new SetorModel())->setDTO($setorDTO)->getArrayDados();
     $executor = '';
     $executor_foto = '';
     if ($this->dto->getCdPfExecutor()) {
         $execDTO = $pessoaFisicaDao->getById($this->dto->getCdPfExecutor());
         $executor = $execDTO->getNmPessoaFisica();
         $executor_foto = Image::get($execDTO);
     } else {
         $execDTO = new PessoaFisicaDTO();
         $executor = 'Executor não definido';
         $executor_foto = Image::get($execDTO);
     }
     $solicitante = '';
     $solicitante_foto = '';
     if ($this->dto->getCdPfSolicitante()) {
         $soDTO = $pessoaFisicaDao->getById($this->dto->getCdPfSolicitante());
         $solicitante = $soDTO->getNmPessoaFisica();
         $solicitante_foto = Image::get($soDTO);
     }
     $ocorrencia = '';
     $dt_ocorrencia = '';
     if ($this->dto->getCdOcorrencia()) {
         /** @var  $ocorrenciaDTO */
         $ocorrenciaDTO = (new OcorrenciaDAO())->getById($this->dto->getCdOcorrencia());
         $ocorrencia = $ocorrenciaDTO->getDescAssunto();
         $dt_ocorrencia = (new DateTime($ocorrenciaDTO->getDtOcorrencia()))->format('d/m/Y');
     }
     $categoria = new CategoriaValorDAO();
     $estagio = '';
     if ($this->dto->getCdCatgEstagio()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgEstagio(), $this->dto->getCdCatgEstagio());
         $estagio = $catg->getDescVlCatg();
     }
     $tipo = '';
     if ($this->dto->getCdCatgTipo()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgTipo(), $this->dto->getCdCatgTipo());
         $tipo = $catg->getDescVlCatg();
     }
     $sub_tipo = '';
     if ($this->dto->getCdCatgSubTipo()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgSubTipo(), $this->dto->getCdCatgSubTipo());
         $sub_tipo = $catg->getDescVlCatg();
     }
     $atendimento = '';
     if ($this->dto->getCdCatgAvalAtendimento()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgAvalAtendimento(), $this->dto->getCdCatgAvalAtendimento());
         $atendimento = $catg->getDescVlCatg();
     }
     $qualidade = '';
     if ($this->dto->getCdCatgAvalQualidade()) {
         $catg = $categoria->getBy2Ids($this->dto->getCdVlCatgAvalQualidade(), $this->dto->getCdCatgAvalQualidade());
         $qualidade = $catg->getDescVlCatg();
     }
     return array('cd_ordem_servico' => $this->dto->getCdOrdemServico(), 'cd_setor' => $this->dto->getCdSetor(), 'setor_dados' => $setorDados, 'cd_ocorrencia' => $this->dto->getCdOcorrencia(), 'desc_ocorrencia' => $ocorrencia, 'dt_ocorrencia' => $dt_ocorrencia, 'desc_assunto' => $this->dto->getDescAssunto(), 'desc_ordem_servico' => $this->dto->getDescOrdemServico(), 'desc_conclusao' => $this->dto->getDescConclusao() ? $this->dto->getDescConclusao() : 'Não informada.', 'cd_pf_executor' => $this->dto->getCdPfExecutor(), 'executor' => $executor, 'executor_foto' => $executor_foto, 'cd_pf_solicitante' => $this->dto->getCdPfSolicitante(), 'solicitante' => $solicitante, 'solicitante_foto' => $solicitante_foto, 'cd_catg_estagio' => $this->dto->getCdCatgEstagio(), 'cd_vl_catg_estagio' => $this->dto->getCdVlCatgEstagio(), 'cd_catg_tipo' => $this->dto->getCdCatgTipo(), 'cd_vl_catg_tipo' => $this->dto->getCdVlCatgTipo(), 'cd_catg_sub_tipo' => $this->dto->getCdCatgSubTipo(), 'cd_vl_catg_sub_tipo' => $this->dto->getCdVlCatgSubTipo(), 'cd_catg_aval_atendimento' => $this->dto->getCdCatgAvalAtendimento(), 'cd_vl_catg_aval_atendimento' => $this->dto->getCdVlCatgAvalAtendimento(), 'desc_aval_atendimento' => $atendimento, 'cd_catg_aval_qualidade' => $this->dto->getCdCatgAvalQualidade(), 'cd_vl_catg_aval_qualidade' => $this->dto->getCdVlCatgAvalQualidade(), 'desc_aval_qualidade' => $qualidade, 'valor_material' => 'R$ ' . number_format($this->dto->getValorMaterial(), 2, ',', '.'), 'valor_servico' => 'R$ ' . number_format($this->dto->getValorServico(), 2, ',', '.'), 'icon_atendimento' => $this->getIcons($this->dto->getCdVlCatgAvalQualidade()), 'icon_qualidade' => '', 'estagio' => $estagio, 'tipo' => $tipo, 'sub_tipo' => $sub_tipo, 'dt_inicio' => (new DateTime($this->dto->getDtInicio()))->format('d/m/Y'), 'dt_fim' => $this->dto->getDtFim() ? (new DateTime($this->dto->getDtFim()))->format('d/m/Y') : 'em aberto');
 }
 function testSaveSnapshot()
 {
     $obj = $this->objFromFixture('ExtensionData', 'testmodule');
     $realUrl = 'http://openbees.org/images/Demo.jpg';
     $imageId = ExtensionSnapshot::save_snapshot($realUrl, $obj->Name);
     $image = Image::get()->byID($imageId);
     $this->assertFileExists(BASE_PATH . DIRECTORY_SEPARATOR . $image->Filename);
 }
Exemplo n.º 14
0
 public function addTypeIcon($row, $label, DataContainer $dc, $args = null)
 {
     $args[0] = \Image::getHtml(\Image::get('system/modules/mail_to/assets/mail-open-image.png', 16, 16));
     $objFile = FilesModel::findByUuid($row['folder']);
     $args[2] = $objFile !== null ? $objFile->path : '-';
     $args[5] = Date::parse(Date::getFormatFromRgxp('datim'), $row['lastrun']);
     return $args;
 }
 /**
  * Get the path to the resized image
  */
 protected static function getResponsiveImage($arrSize, $strSrc)
 {
     $varImagePath = null;
     if ($arrSize[0] > 0 || $arrSize[1] > 0) {
         $varImagePath = \Image::get($strSrc, $arrSize[0], $arrSize[1], $arrSize[3]);
     }
     return $varImagePath;
 }
 /**
  * Generate a song row and return it as HTML string
  * @param array
  * @return string
  */
 public function generateItemRow($arrRow)
 {
     $objImage = \FilesModel::findByPk($arrRow['singleSRC']);
     if ($objImage !== null) {
         $strImage = \Image::getHtml(\Image::get($objImage->path, '30', '30', 'center_center'));
     }
     return '<div><div style="float:left; margin-right:10px;">' . $strImage . '</div>' . $arrRow['title'] . '</div>';
 }
 function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TextField("Hyperlink", "Hyperlink (e.g. http://www.silverstripe.co.nz)"));
     $fields->push(new HeaderField("MakeSureToUploadImageFirst", "Please make sure image is uploaded first in file and images section", 5));
     $fields->push(new DropdownField("LogoID", "Image / Picture / Logo", array(0 => "--- please select ---") + Image::get()->map()->toArray()));
     return $fields;
 }
Exemplo n.º 18
0
 public function generateActRow($arrRow)
 {
     $objImage = \FilesModel::findByPk($arrRow['singleSRC']);
     if ($objImage !== null) {
         $strImage = \Image::getHtml(\Image::get($objImage->path, '25', '33', 'center_center'));
     }
     return '<div><div style="float:left; margin-right:10px;">' . $strImage . '</div>' . $arrRow['title'] . ' <br /><span style="padding-left:3px;color:#b3b3b3;">[' . $arrRow['post'] . ']</span></div>';
 }
Exemplo n.º 19
0
 /**
  * Generate the widget and return it as string
  * @param array
  * @return string
  */
 public function parse($arrAttributes = null)
 {
     if ($this->varValue != '') {
         $blnTemporaryFile = $this->isTemporaryFile($this->varValue);
         if ($blnTemporaryFile) {
             $strNew = $this->getThumbnailPath($this->varValue);
             // Auto-resize the user avatar
             if (\Config::get('avatar_user_autoresize')) {
                 $this->varValue = \Image::get($this->varValue, $this->arrAvatarSize[0], $this->arrAvatarSize[1], 'center_center');
                 // Copy the file
                 if (\Files::getInstance()->rename($this->varValue, $strNew)) {
                     $this->varValue = $strNew;
                     $blnTemporaryFile = false;
                 }
             } else {
                 // If the file is temporary but has the exact avatar dimensions
                 // there is no need to crop it just treat it as a ready avatar
                 $arrSize = @getimagesize(TL_ROOT . '/' . $this->varValue);
                 if ($arrSize[0] == $this->arrAvatarSize[0] && $arrSize[1] == $this->arrAvatarSize[1] && \Files::getInstance()->rename($this->varValue, $strNew)) {
                     $this->varValue = $strNew;
                     $blnTemporaryFile = false;
                 }
             }
         }
         // Temporary file
         if ($blnTemporaryFile) {
             // Crop the file
             if (\Input::post('crop') != '') {
                 list($intPositionX, $intPositionY) = explode(',', \Input::post('crop'));
                 $this->varValue = $this->cropImage($this->varValue, $intPositionX, $intPositionY);
                 $this->thumbnail = \Image::getHtml($this->varValue);
                 $this->imgSize = @getimagesize(TL_ROOT . '/' . $this->varValue);
                 $this->set = $this->varValue;
                 $this->noCrop = true;
             } else {
                 // Crop mode
                 $strThumbnail = $this->getThumbnail($this->varValue);
                 $this->thumbnail = \Image::getHtml($strThumbnail);
                 $this->imgSize = @getimagesize(TL_ROOT . '/' . $strThumbnail);
             }
         } else {
             // Avatar
             $this->avatar = \Image::getHtml(\Image::get($this->varValue, $this->arrAvatarSize[0], $this->arrAvatarSize[1], 'center_center'));
             $this->set = $this->varValue;
         }
     }
     $this->ajax = \Environment::get('isAjaxRequest');
     $this->delete = $GLOBALS['TL_LANG']['MSC']['delete'];
     $this->deleteTitle = specialchars($GLOBALS['TL_LANG']['MSC']['delete']);
     $this->crop = $GLOBALS['TL_LANG']['MSC']['avatar_crop'];
     $this->cropTitle = specialchars($GLOBALS['TL_LANG']['MSC']['avatar_crop']);
     $this->extensions = json_encode(trimsplit(',', $this->getAllowedExtensions()));
     $this->sizeLimit = $this->getMaximumFileSize();
     $this->avatarSize = json_encode($this->arrAvatarSize);
     $this->texts = json_encode(array('text' => array('formatProgress' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_formatProgress'], 'failUpload' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_failUpload'], 'waitingForResponse' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_waitingForResponse'], 'paused' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_paused']), 'messages' => array('tooManyFilesError' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_tooManyFilesError'], 'unsupportedBrowser' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_unsupportedBrowser']), 'retry' => array('autoRetryNote' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_autoRetryNote']), 'deleteFile' => array('confirmMessage' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_confirmMessage'], 'deletingStatusText' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_deletingStatusText'], 'deletingFailedText' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_deletingFailedText']), 'paste' => array('namePromptMessage' => $GLOBALS['TL_LANG']['MSC']['avatar_fineuploader_namePromptMessage'])));
     $this->labels = array('drop' => $GLOBALS['TL_LANG']['MSC']['avatar_drop'], 'upload' => $GLOBALS['TL_LANG']['MSC']['avatar_upload'], 'processing' => $GLOBALS['TL_LANG']['MSC']['avatar_processing']);
     return parent::parse($arrAttributes);
 }
Exemplo n.º 20
0
 /**
  * Generate the content element
  */
 protected function compile()
 {
     global $objPage;
     if (substr($this->url, 0, 7) == 'mailto:') {
         $this->url = \String::encodeEmail($this->url);
     } else {
         $this->url = ampersand($this->url);
     }
     $embed = explode('%s', $this->embed);
     if ($this->linkTitle == '') {
         $this->linkTitle = $this->url;
     }
     // Use an image instead of the title
     if ($this->useImage && $this->singleSRC != '' && is_numeric($this->singleSRC)) {
         $objModel = \FilesModel::findByPk($this->singleSRC);
         if ($objModel !== null && is_file(TL_ROOT . '/' . $objModel->path)) {
             $this->Template = new \FrontendTemplate('ce_hyperlink_image');
             $this->Template->setData($this->arrData);
             $objFile = new \File($objModel->path);
             if ($objFile->isGdImage) {
                 $size = deserialize($this->size);
                 $intMaxWidth = TL_MODE == 'BE' ? 320 : $GLOBALS['TL_CONFIG']['maxImageWidth'];
                 // Adjust the image size
                 if ($intMaxWidth > 0 && ($size[0] > $intMaxWidth || !$size[0] && $objFile->width > $intMaxWidth)) {
                     $size[0] = $intMaxWidth;
                     $size[1] = floor($intMaxWidth * $objFile->height / $objFile->width);
                 }
                 $src = \Image::get($objModel->path, $size[0], $size[1], $size[2]);
                 if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) {
                     $this->Template->arrSize = $imgSize;
                     $this->Template->imgSize = ' ' . $imgSize[3];
                 }
                 $this->Template->src = TL_FILES_URL . $src;
                 $this->Template->alt = specialchars($this->alt);
                 $this->Template->linkTitle = specialchars($this->linkTitle);
                 $this->Template->caption = $this->caption;
             }
         }
     }
     if (strncmp($this->rel, 'lightbox', 8) !== 0 || $objPage->outputFormat == 'xhtml') {
         $this->Template->attribute = ' rel="' . $this->rel . '"';
     } else {
         $this->Template->attribute = ' data-lightbox="' . substr($this->rel, 9, -1) . '"';
     }
     $this->Template->rel = $this->rel;
     // Backwards compatibility
     $this->Template->href = $this->url;
     $this->Template->embed_pre = $embed[0];
     $this->Template->embed_post = $embed[1];
     $this->Template->link = $this->linkTitle;
     $this->Template->linkTitle = specialchars($this->linkTitle);
     $this->Template->target = '';
     // Override the link target
     if ($this->target) {
         $this->Template->target = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"';
     }
 }
Exemplo n.º 21
0
 /**
  * Add an image to each record
  * @param array         $row
  * @param string        $label
  * @param DataContainer $dc
  * @param array         $args
  *
  * @return array
  */
 public function addImage($row, $label, DataContainer $dc, $args)
 {
     $objImage = \FilesModel::findByPk($row['singleSRC']);
     if ($objImage !== null) {
         $strImage = \Image::getHtml(\Image::get($objImage->path, '80', '60', 'center_center'));
     }
     $args[0] = $strImage;
     return $args;
 }
Exemplo n.º 22
0
 /**
  * Resizes an image image
  * @return boolean
  */
 public function resize()
 {
     try {
         // Create new Image object //
         $im = new Imagick($this->image->get('image_path'));
         // Resize the image //
         $im->scaleimage($this->image->get('height'), $this->image->get('width'));
         // Grab the output from writing the image to disk //
         $return = $im->writeimage($this->image->get('resized_path'));
         // Clean up memory //
         $im->clear();
         $im->destroy();
         // $return only returns true if image is written //
         return $return ? true : false;
     } catch (Exception $e) {
         $this->log->exceptionLog($e, __METHOD__);
     }
 }
Exemplo n.º 23
0
 public function getBasicInfo()
 {
     $nascimento = (new DateTime($this->dto->getDtNascimento()))->format('d/m/Y');
     $converted = str_replace('/', '-', $nascimento);
     $date = new DateTime($converted);
     // data de nascimento
     $interval = $date->diff(new DateTime());
     // data definida
     return array('id' => $this->dto->getCdPessoaFisica(), 'nome' => $this->dto->getNmPessoaFisica(), 'foto' => Image::get($this->dto), 'email' => $this->dto->getEmail(), 'nascimento' => (new DateTime($this->dto->getDtNascimento()))->format('d/m/Y'), 'idade' => $interval->format('%Y anos'));
 }
Exemplo n.º 24
0
 /**
  * Add an image to each record
  * @param array
  * @param string
  * @return string
  */
 public function addPreviewImage($row, $label)
 {
     if ($row['screenshot'] != '') {
         $objFile = FilesModel::findByPk($row['screenshot']);
         if ($objFile !== null) {
             $label = '<img src="' . TL_FILES_URL . Image::get($objFile->path, 160, 120, 'center_top') . '" width="160" height="120" alt="" class="theme_preview">' . $label;
         }
     }
     return $label;
 }
Exemplo n.º 25
0
 public function listPerson($row)
 {
     if ($row['image'] != null) {
         $objFile = \FilesModel::findByPk(deserialize($row['image']));
         $singleSRC = $objFile->path;
         $sReturn = '<figure style="float: left; margin-right: 1em;"><img src="' . Image::get($singleSRC, 80, 80, 'center_top') . '"></figure>';
     }
     $sReturn .= '<div>' . $row['lastname'] . ', ' . $row['firstname'] . '</div>';
     return $sReturn;
 }
Exemplo n.º 26
0
 /**
  * Add an image to each record
  *
  * @param array  $row
  * @param string $label
  *
  * @return string
  */
 public function addPreviewImage($row, $label)
 {
     if ($row['screenshot'] != '') {
         $objFile = FilesModel::findByUuid($row['screenshot']);
         if ($objFile !== null) {
             $label = Image::getHtml(Image::get($objFile->path, 160, 120, 'center_top'), '', 'class="theme_preview"') . ' ' . $label;
         }
     }
     return $label;
 }
 public function generateProductJSON()
 {
     $data = array('title' => $this->Title, 'description' => $this->Description);
     if ($image = Image::get()->byId($this->ImageID)) {
         $data['image'] = array('path' => $image->Filename, 'title' => $image->Title);
     }
     // Prefix our JSON with ")]}',\n". Angular.js handles it for us on the client.
     // http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx
     $JSON = ")]}',\n" . json_encode($data);
     return $JSON;
 }
Exemplo n.º 28
0
 public static function flushImage($imageID)
 {
     $image = Image::get()->byID($imageID);
     if ($image && $image->exists()) {
         $exp = 'obj.http.x-url ~ "^/' . preg_quote($image->getFilename()) . '$"';
         // image itself
         $exp .= ' || obj.http.x-url ~ "^/' . preg_quote($image->Parent()->getFilename()) . '_resampled/(.*)\\-' . preg_quote($image->Name) . '$"';
         // resampled versions
         return static::performFlush($exp);
     }
     return false;
 }
Exemplo n.º 29
0
 /**
  * @return array
  */
 public function getArrayDados()
 {
     $apartamento = (new SetorDAO())->getById($this->dto->getCdApartamento());
     $setor = (new SetorDAO())->getById($apartamento->getCdSetorGrupo());
     $condominio = (new PessoaJuridicaDAO())->getById($setor->getCdCondominio());
     $dt_entrada = (new DateTime($this->dto->getDtEntrada()))->format('d/m/Y');
     $dt_saida = $this->dto->getDtSaida() ? (new DateTime($this->dto->getDtSaida()))->format('d/m/Y') : 'Morador';
     $pessoa = (new PessoaFisicaDAO())->getById($this->dto->getCdPessoaFisica());
     $pessoaNome = $pessoa->getNmPessoaFisica();
     $pessoaFoto = Image::get($pessoa);
     return array('id_m_end' => $this->dto->getNrSequencia(), 'cd_pessoa_fisica' => $this->dto->getCdPessoaFisica(), 'pessoa' => $pessoaNome, 'pessoa_foto' => $pessoaFoto, 'm_end_dt_entrada' => $dt_entrada, 'm_end_dt_saida' => $dt_saida, 'cd_apartamento' => $this->dto->getCdApartamento(), 'apartamento' => $apartamento->getNmSetor(), 'cd_setor' => $setor->getCdSetor(), 'setor' => $setor->getNmSetor(), 'cd_condominio' => $condominio->getCdPessoaJuridica(), 'condominio' => $condominio->getNmFantasia(), 'residente' => $this->dto->getFgResidente() == 'S' ? 'Sim' : 'Não');
 }
 function parse($value, &$pipeline)
 {
     global $g_config;
     if (!$g_config['renderimages']) {
         return CSSListStyleImage::default_value();
     }
     if (preg_match('/url\\(([^)]+)\\)/', $value, $matches)) {
         $url = $matches[1];
         $full_url = $pipeline->guess_url(css_remove_value_quotes($url));
         return new ListStyleImage($full_url, Image::get($full_url, $pipeline));
     }
     return CSSListStyleImage::default_value();
 }