当前位置: 首页>>代码示例>>PHP>>正文


PHP JUDirectoryHelper::parseImageNameByTags方法代码示例

本文整理汇总了PHP中JUDirectoryHelper::parseImageNameByTags方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::parseImageNameByTags方法的具体用法?PHP JUDirectoryHelper::parseImageNameByTags怎么用?PHP JUDirectoryHelper::parseImageNameByTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUDirectoryHelper的用法示例。


在下文中一共展示了JUDirectoryHelper::parseImageNameByTags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateImageNameByListing

 public static function generateImageNameByListing($listing_id, $file_name)
 {
     if (!$listing_id || !$file_name) {
         return "";
     }
     $dir_listing_ori = JPATH_ROOT . "/" . JUDirectoryFrontHelper::getDirectory("listing_original_image_directory", "media/com_judirectory/images/gallery/original/") . $listing_id . "/";
     $info = pathinfo($file_name);
     $listing = JUDirectoryHelper::getListingById($listing_id);
     $replace = array('id' => $listing->id, 'category' => '', 'listing' => $listing->title, 'image_name' => $info['filename']);
     $base_file_name = JUDirectoryHelper::parseImageNameByTags($replace, 'listing', null, $listing->id) . "." . $info['extension'];
     $img_file_name = $base_file_name;
     $img_path_ori = $dir_listing_ori . $img_file_name;
     while (JFile::exists($img_path_ori)) {
         $img_file_name = JUDirectoryHelper::generateRandomString(3) . "-" . $base_file_name;
         $img_path_ori = $dir_listing_ori . $img_file_name;
     }
     return $img_file_name;
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:18,代码来源:judirectory.php

示例2: 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();
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:99,代码来源:category.php


注:本文中的JUDirectoryHelper::parseImageNameByTags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。