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