本文整理汇总了PHP中JUDirectoryHelper::renderImages方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::renderImages方法的具体用法?PHP JUDirectoryHelper::renderImages怎么用?PHP JUDirectoryHelper::renderImages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::renderImages方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addIcon
protected function addIcon($image, $locationTable)
{
if ($image['name']) {
$mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp");
if (in_array($image['type'], $mime_types)) {
$this->removeIcon($locationTable);
$imageOriginalDirectory = JPATH_ROOT . "/media/com_judirectory/images/location/original/" . $this->listing_id . "/";
$imageDirectory = JPATH_ROOT . "/media/com_judirectory/images/location/" . $this->listing_id . "/";
if (!JFolder::exists($imageOriginalDirectory)) {
$file_index = $imageOriginalDirectory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($imageDirectory)) {
$file_index = $imageDirectory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
$image_file_name = $locationTable->id . "_" . JUDirectoryHelper::fileNameFilter($image['name']);
if (JFile::upload($image['tmp_name'], $imageOriginalDirectory . $image_file_name) && JUDirectoryHelper::renderImages($imageOriginalDirectory . $image_file_name, $imageDirectory . $image_file_name, 'location_image', true, null, $this->listing_id)) {
$locationTable->image = $image_file_name;
$locationTable->store();
}
} else {
JError::raise(E_NOTICE, 500, JText::sprintf('COM_JUDIRECTORY_LOCATION_ICON_IS_NOT_VALID_MIME_TYPE', implode(",", $mime_types)));
}
}
}
示例2: onImport
public function onImport($value, &$message = '')
{
$imageDir = JPATH_ROOT . '/' . JUDirectoryFrontHelper::getDirectory('listing_image_directory', 'media/com_judirectory/images/listing/');
$originalDir = $imageDir . 'original/';
$imagePath = JUDirectoryHelper::getPhysicalPath($value);
$oldImagePath = '';
if (!$this->is_new && $this->listing->image) {
$oldImagePath = JPath::clean($originalDir . $this->listing->image);
}
if ($imagePath != $oldImagePath) {
if ($imagePath && JFile::exists($imagePath)) {
if (JFile::exists($oldImagePath)) {
JFile::delete($imageDir . $this->listing->image);
JFile::delete($originalDir . $this->listing->image);
}
$imageName = basename($imagePath);
$imageName = $this->listing_id . "_" . JUDirectoryHelper::fileNameFilter($imageName);
JFile::copy($imagePath, $originalDir . $imageName);
JUDirectoryHelper::renderImages($originalDir . $imageName, $imageDir . $imageName, 'listing_image', true, null, $this->listing_id);
$value = $imageName;
return basename($value);
} else {
$message = $value . JText::_(' does not exist');
}
}
return false;
}
示例3: saveCategoryImage
public function saveCategoryImage($pk, $table, &$data)
{
$app = JFactory::getApplication();
$jInput = $app->input;
if ($pk > 0) {
if ($jInput->post->getInt('remove_jform_images_intro_image', 0) == 1 || $jInput->post->getInt('remove_jform_images_detail_image', 0) == 1 && $jInput->post->getInt('use_detail_image', 0) == 1) {
$intro_image_dir = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . $data['images']['intro_image'];
$ori_intro_image_dir = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . 'original/' . $data['images']['intro_image'];
$data['images']['intro_image'] = '';
$data['images']['intro_image_alt'] = '';
$data['images']['intro_image_caption'] = '';
JFile::delete($ori_intro_image_dir);
JFile::delete($intro_image_dir);
}
if ($jInput->post->getInt('remove_jform_images_detail_image', 0) == 1) {
$full_image_dir = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . $data['images']['detail_image'];
$ori_full_image_dir = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . "original/" . $data['images']['detail_image'];
$data['images']['detail_image'] = '';
$data['images']['detail_image_alt'] = '';
$data['images']['detail_image_caption'] = '';
JFile::delete($full_image_dir);
JFile::delete($ori_full_image_dir);
}
}
$mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp");
$num_files_failed_mime_type = 0;
$images = $app->input->files->get('images', array());
$old_ori_intro_image_path = isset($data['images']['intro_image']) && $data['images']['intro_image'] ? JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . 'original/' . $data['images']['intro_image'] : '';
$old_intro_image_path = $old_ori_intro_image_path ? JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . $data['images']['intro_image'] : '';
$old_ori_detail_image_path = isset($data['images']['detail_image']) && $data['images']['detail_image'] ? JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . 'original/' . $data['images']['detail_image'] : '';
$old_detail_image_path = $old_ori_detail_image_path ? JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . $data['images']['detail_image'] : '';
foreach ($images as $key => $image) {
if ($image['name']) {
if (!in_array($image['type'], $mime_types)) {
$num_files_failed_mime_type++;
continue;
}
$info = pathinfo($image['name']);
$replace = array('id' => $table->id, 'listing' => '', 'category' => $table->title, 'image_name' => $info['filename']);
$image['name'] = JUDirectoryHelper::parseImageNameByTags($replace, 'category', $table->id, null) . '.' . $info['extension'];
if ($key == 'intro' && $app->input->post->get('use_detail_image', 0) != 1) {
$new_ori_image_path = JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . 'original/' . $image['name'];
$new_image_path = JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . $image['name'];
if (!JFile::upload($image['tmp_name'], JPATH_ROOT . "/" . $new_ori_image_path) || !JUDirectoryHelper::renderImages(JPATH_ROOT . "/" . $new_ori_image_path, JPATH_ROOT . "/" . $new_image_path, "category_intro", true, $table->id)) {
unset($images['intro']);
} else {
$delete_old_intro_image = $data['images']['intro_image'] && $data['images']['intro_image'] !== $image['name'] ? true : false;
$data['images']['intro_image'] = $image['name'];
}
if ($delete_old_intro_image) {
if ($old_intro_image_path && JFile::exists(JPATH_ROOT . "/" . $old_intro_image_path)) {
JFile::delete(JPATH_ROOT . "/" . $old_ori_intro_image_path);
JFile::delete(JPATH_ROOT . "/" . $old_intro_image_path);
}
}
}
if ($key == 'detail') {
$new_ori_image_path = JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . 'original/' . $image['name'];
$new_image_path = JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . $image['name'];
if (!JFile::upload($image['tmp_name'], JPATH_ROOT . "/" . $new_ori_image_path) || !JUDirectoryHelper::renderImages(JPATH_ROOT . "/" . $new_ori_image_path, JPATH_ROOT . "/" . $new_image_path, "category_detail", true, $table->id)) {
unset($images['detail']);
} else {
if ($data['images']['detail_image'] && $data['images']['detail_image'] !== $image['name']) {
if ($old_detail_image_path && JFile::exists(JPATH_ROOT . "/" . $old_detail_image_path)) {
JFile::delete(JPATH_ROOT . "/" . $old_ori_detail_image_path);
JFile::delete(JPATH_ROOT . "/" . $old_detail_image_path);
}
}
$data['images']['detail_image'] = $image['name'];
}
}
}
}
if ($num_files_failed_mime_type) {
JError::raise(E_NOTICE, 500, JText::plural('COM_JUDIRECTORY_N_IMAGES_ARE_NOT_VALID_MIMETYPE', $num_files_failed_mime_type, implode(",", $mime_types)));
}
if ($app->input->post->get('use_detail_image', 0) == 1 && $data['images']['detail_image']) {
$old_ori_detail_image_path = JUDirectoryFrontHelper::getDirectory("category_detail_image_directory", "media/com_judirectory/images/category/detail/") . 'original/' . $data['images']['detail_image'];
$new_ori_intro_image_path = JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . 'original/' . $data['images']['detail_image'];
$new_image_path = JUDirectoryFrontHelper::getDirectory("category_intro_image_directory", "media/com_judirectory/images/category/intro/") . $data['images']['detail_image'];
if (JFile::copy(JPATH_ROOT . "/" . $old_ori_detail_image_path, JPATH_ROOT . "/" . $new_ori_intro_image_path) && JUDirectoryHelper::renderImages(JPATH_ROOT . "/" . $new_ori_intro_image_path, JPATH_ROOT . "/" . $new_image_path, 'category_intro', true, $table->id)) {
if ($data['images']['intro_image'] && $data['images']['intro_image'] !== $data['images']['detail_image']) {
if (JFile::exists(JPATH_ROOT . "/" . $old_ori_intro_image_path)) {
JFile::delete(JPATH_ROOT . "/" . $old_ori_intro_image_path);
}
if (JFile::exists(JPATH_ROOT . "/" . $old_intro_image_path)) {
JFile::delete(JPATH_ROOT . "/" . $old_intro_image_path);
}
}
$data['images']['intro_image'] = $data['images']['detail_image'];
}
}
if (!empty($data['images'])) {
$registry = new JRegistry();
$registry->loadArray($data['images']);
$table->images = (string) $registry;
$table->store();
}
}
示例4: resizeCollectionIcons
public function resizeCollectionIcons($limitStart, $limit)
{
$db = JFactory::getDbo();
$query = "SELECT icon FROM #__judirectory_collections WHERE icon != ''";
$db->setQuery($query, $limitStart, $limit);
$images = $db->loadObjectList();
if (count($images)) {
$collection_icon_path = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("collection_icon_directory", "media/com_judirectory/images/collection/");
foreach ($images as $image) {
$ori_image_path = $collection_icon_path . "original/" . $image->icon;
if (JFile::exists($ori_image_path)) {
$image_path = $collection_icon_path . $image->icon;
if (JFile::exists($image_path)) {
JFile::delete($image_path);
}
JUDirectoryHelper::renderImages($ori_image_path, $image_path, 'collection');
}
}
}
}
示例5: onSaveListing
public function onSaveListing($value = '')
{
$gallery = $value;
$date = JFactory::getDate();
$image_ordering = 0;
$configListingOriginalImageDirectory = JUDirectoryFrontHelper::getDirectory("listing_original_image_directory", "media/com_judirectory/images/gallery/original/");
$configListingSmallImageDirectory = JUDirectoryFrontHelper::getDirectory("listing_small_image_directory", "media/com_judirectory/images/gallery/small/");
$configListingBigImageDirectory = JUDirectoryFrontHelper::getDirectory("listing_big_image_directory", "media/com_judirectory/images/gallery/big/");
$listing_original_image_directory = JPATH_ROOT . "/" . $configListingOriginalImageDirectory . $this->listing_id . "/";
$listing_small_image_directory = JPATH_ROOT . "/" . $configListingSmallImageDirectory . $this->listing_id . "/";
$listing_big_image_directory = JPATH_ROOT . "/" . $configListingBigImageDirectory . $this->listing_id . "/";
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables', 'JUDirectoryTable');
$imageTable = JTable::getInstance('Image', 'JUDirectoryTable');
if (!$this->is_new) {
if (!empty($gallery['old'])) {
foreach ($gallery['old'] as $image) {
if ($imageTable->load($image['id'])) {
if ($image['remove'] == 1) {
if ($imageTable->delete()) {
JFile::delete($listing_original_image_directory . $image['file_name']);
JFile::delete($listing_small_image_directory . $image['file_name']);
JFile::delete($listing_big_image_directory . $image['file_name']);
}
} else {
$image_ordering++;
$_image = array();
$_image['title'] = $image['title'];
$_image['description'] = $image['description'];
$_image['published'] = $image['published'];
$_image['ordering'] = $image_ordering;
$imageTable->bind($_image);
$imageTable->check();
$imageTable->store();
}
}
}
}
}
if (!empty($gallery['new'])) {
if (!JFolder::exists($listing_original_image_directory)) {
$file_index = $listing_original_image_directory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($listing_small_image_directory)) {
$file_index = $listing_small_image_directory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($listing_big_image_directory)) {
$file_index = $listing_big_image_directory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
$countNewImage = 0;
foreach ($gallery['new'] as $image) {
$img_file_name = JUDirectoryHelper::generateImageNameByListing($this->listing_id, $image['name']);
if (!JFile::move($image['tmp_name'], $listing_original_image_directory . $img_file_name) || !JUDirectoryHelper::renderImages($listing_original_image_directory . $img_file_name, $listing_small_image_directory . $img_file_name, 'listing_small', true, null, $this->listing_id) || !JUDirectoryHelper::renderImages($listing_original_image_directory . $img_file_name, $listing_big_image_directory . $img_file_name, 'listing_big', true, null, $this->listing_id)) {
continue;
}
$imageTable->reset();
$dataImage = array('id' => 0, 'file_name' => $img_file_name, 'listing_id' => $this->listing_id, 'published' => 1, 'ordering' => ++$image_ordering, 'created' => $date->toSql());
$imageTable->bind($dataImage);
$imageTable->check();
$imageTable->store();
$countNewImage++;
}
}
return null;
}