本文整理汇总了PHP中JUDownloadHelper::generateImageNameByDocument方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::generateImageNameByDocument方法的具体用法?PHP JUDownloadHelper::generateImageNameByDocument怎么用?PHP JUDownloadHelper::generateImageNameByDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDownloadHelper
的用法示例。
在下文中一共展示了JUDownloadHelper::generateImageNameByDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertUpdateDocument
//.........这里部分代码省略.........
$table->store();
}
}
}
$imageTable = JTable::getInstance("Image", "JUDownloadTable");
if (!empty($gallery)) {
$dir_document_ori = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("document_original_image_directory", "media/com_judownload/images/gallery/original/") . $docId . "/";
$dir_document_small = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("document_small_image_directory", "media/com_judownload/images/gallery/small/") . $docId . "/";
$dir_document_big = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("document_big_image_directory", "media/com_judownload/images/gallery/big/") . $docId . "/";
if (!JFolder::exists($dir_document_ori)) {
$file_index = $dir_document_ori . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($dir_document_small)) {
$file_index = $dir_document_small . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($dir_document_big)) {
$file_index = $dir_document_big . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
$image_ordering = 1;
$date = JFactory::getDate();
foreach ($gallery as $imagePath) {
$imagePath = JUDownloadHelper::getPhysicalPath($imagePath);
if (!$imagePath) {
$messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_FILE_S_NOT_FOUND', $imagePath);
continue;
}
$imageName = basename($imagePath);
$imageName = JUDownloadHelper::generateImageNameByDocument($docId, $imageName);
if (JFile::copy($imagePath, $dir_document_ori . $imageName) && JUDownloadHelper::renderImages($dir_document_ori . $imageName, $dir_document_small . $imageName, 'document_small', true, null, $data['id']) && JUDownloadHelper::renderImages($dir_document_ori . $imageName, $dir_document_big . $imageName, 'document_big', true, null, $data['id'])) {
$imageObj = new stdClass();
$imageObj->id = 0;
$imageObj->file_name = $imageName;
$imageObj->doc_id = $docId;
$imageObj->ordering = $image_ordering;
$imageObj->created = $date->toSql();
$imageObj->published = 1;
if (!$imageTable->bind($imageObj) || !$imageTable->check() || !$imageTable->store()) {
$messages[] = implode(' | ', $imageTable->getErrors());
JFile::delete($dir_document_ori . $imageName);
JFile::delete($dir_document_small . $imageName);
JFile::delete($dir_document_big . $imageName);
} else {
$image_ordering++;
}
} else {
$messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_CAN_NOT_COPY_FILE_FROM_S_TO_S', $imagePath, $dir_document_ori . $imageName);
}
}
}
$fileTable = JTable::getInstance("File", "JUDownloadTable");
if (!empty($files)) {
$file_directory = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
if (!JFolder::exists($file_directory . $docId . "/")) {
$file_index = $file_directory . $docId . "/index.html";
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
$file_ordering = 1;
foreach ($files as $filePath) {
$filePath = JUDownloadHelper::getPhysicalPath($filePath);
示例2: storeValue
public function storeValue($value, $type = 'default', $inputData = null)
{
$gallery = $value;
$date = JFactory::getDate();
$image_ordering = 0;
$configDocumentOriginalImageDirectory = JUDownloadFrontHelper::getDirectory("document_original_image_directory", "media/com_judownload/images/gallery/original/");
$configDocumentSmallImageDirectory = JUDownloadFrontHelper::getDirectory("document_small_image_directory", "media/com_judownload/images/gallery/small/");
$configDocumentBigImageDirectory = JUDownloadFrontHelper::getDirectory("document_big_image_directory", "media/com_judownload/images/gallery/big/");
$document_original_image_directory = JPATH_ROOT . "/" . $configDocumentOriginalImageDirectory . $this->doc_id . "/";
$document_small_image_directory = JPATH_ROOT . "/" . $configDocumentSmallImageDirectory . $this->doc_id . "/";
$document_big_image_directory = JPATH_ROOT . "/" . $configDocumentBigImageDirectory . $this->doc_id . "/";
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judownload/tables', 'JUDownloadTable');
$imageTable = JTable::getInstance('Image', 'JUDownloadTable');
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($document_original_image_directory . $image['file_name']);
JFile::delete($document_small_image_directory . $image['file_name']);
JFile::delete($document_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 ($type == 'migrate')
{
$gallery['new'] = $inputData['new'];
if (!empty($gallery['new']))
{
if (!JFolder::exists($document_original_image_directory))
{
$file_index = $document_original_image_directory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($document_small_image_directory))
{
$file_index = $document_small_image_directory . 'index.html';
$buffer = "<!DOCTYPE html><title></title>";
JFile::write($file_index, $buffer);
}
if (!JFolder::exists($document_big_image_directory))
{
$file_index = $document_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 = JUDownloadHelper::generateImageNameByDocument($this->doc_id, $image['name']);
if (!JFile::copy($image['tmp_name'], $document_original_image_directory . $img_file_name)
|| !JUDownloadHelper::renderImages($document_original_image_directory . $img_file_name, $document_small_image_directory . $img_file_name, 'document_small', true, null, $this->doc_id)
|| !JUDownloadHelper::renderImages($document_original_image_directory . $img_file_name, $document_big_image_directory . $img_file_name, 'document_big', true, null, $this->doc_id)
)
//.........这里部分代码省略.........