本文整理汇总了PHP中JUDirectoryHelper::generateImageNameByListing方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::generateImageNameByListing方法的具体用法?PHP JUDirectoryHelper::generateImageNameByListing怎么用?PHP JUDirectoryHelper::generateImageNameByListing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::generateImageNameByListing方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}