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


PHP JRegistry::getProperties方法代码示例

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


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

示例1: createImages

 /**
  * @param $element
  * @param $field
  * @param $_data
  *
  * @return JRegistry|null
  */
 protected function createImages($element, $field, $_data)
 {
     jimport('joomla.filesystem.file');
     $app = JFactory::getApplication();
     if (($image = $_data->get('image')) && file_exists(JPath::clean(JPATH_ROOT . '/' . $image))) {
         $_data = new JRegistry($_data->getProperties(true));
         $scaleImage = (int) $field->params->def('type.scale', $this->params->get('scale', 0));
         $createThumb = (bool) $field->params->get('type.create_thumb');
         $scaleThumb = (int) $field->params->def('type.scale_thumb', $this->params->get('scale_thumb', 0));
         if ($scaleImage || $createThumb && $scaleThumb) {
             $isCreated = true;
             $isCreatedThumb = true;
             $folder = FieldsandfiltersImage::getCacheFolder() . '/' . $field->id . '/';
             $imageInfo = $this->prepareImageInfo($field, $element, $image, false, $scaleImage);
             if ($scaleImage) {
                 $src = JPath::clean($folder . $imageInfo->name);
                 $srcOld = $_data->get('src', false);
                 if ($src != $srcOld || !file_exists(JPath::clean(JPATH_ROOT . '/' . $src))) {
                     try {
                         if ($srcOld && file_exists($srcOld = JPath::clean(JPATH_ROOT . '/' . $srcOld))) {
                             JFile::delete($srcOld);
                         }
                         if ($src = FieldsandfiltersImage::createImage($field->name, $imageInfo)) {
                             $_data->set('src', $src);
                             $app->enqueueMessage(JText::sprintf('COM_FIELDSANDFILTERS_SUCCESS_CREATE_IMAGE', $field->name));
                         } else {
                             throw new RuntimeException(JText::sprintf('COM_FIELDSANDFILTERS_ERROR_NOT_CREATE_IMAGE', $field->name));
                         }
                     } catch (Exception $e) {
                         $isCreated = false;
                         $_data->set('src', '');
                         $app->enqueueMessage($e->getMessage(), 'error');
                     }
                 }
             }
             if ($createThumb && $scaleThumb) {
                 $src = JPath::clean($folder . 'thumbs/' . $imageInfo->name);
                 $srcOld = $_data->get('src_thumb', false);
                 if ($scaleThumb && ($src != $srcOld || !file_exists(JPath::clean(JPATH_ROOT . '/' . $src)))) {
                     $imageInfo = $this->prepareImageInfo($field, $element, $image, $imageInfo->name, $scaleThumb, 'thumb');
                     try {
                         if ($srcOld && file_exists($srcOld = JPath::clean(JPATH_ROOT . '/' . $srcOld))) {
                             JFile::delete($srcOld);
                         }
                         if ($src = FieldsandfiltersImage::createImage($field->name . ' Thumbs', $imageInfo)) {
                             $_data->set('src_thumb', $src);
                             $app->enqueueMessage(JText::sprintf('COM_FIELDSANDFILTERS_SUCCESS_CREATE_IMAGE', $field->name . ' Thumb'));
                         } else {
                             throw new RuntimeException(JText::sprintf('COM_FIELDSANDFILTERS_ERROR_NOT_CREATE_IMAGE', $field->name . ' Thumb'));
                         }
                     } catch (Exception $e) {
                         $isCreatedThumb = false;
                         $_data->set('src_thumb', '');
                         $app->enqueueMessage($e->getMessage(), 'error');
                     }
                 }
             }
             if (!$isCreated && !($createThumb && $isCreatedThumb)) {
                 $_data = null;
             }
         }
         unset($imageInfo);
     } else {
         if (($src = $_data->get('src')) && file_exists(JPath::clean(JPATH_ROOT . '/' . $src))) {
             // delete image
             if (!JFile::delete(JPATH_ROOT . '/' . $src)) {
                 $app->enqueueMessage(JText::sprintf('PLG_FAF_TS_IE_SUCCESS_DELETE_IMAGE', $field->name, $src), 'error');
             }
         }
         if (($src = $_data->get('src_thumb')) && file_exists(JPath::clean(JPATH_ROOT . '/' . $src))) {
             // delete thumb
             if (!JFile::delete(JPATH_ROOT . '/' . $src)) {
                 $app->enqueueMessage(JText::sprintf('PLG_FAF_TS_IE_SUCCESS_DELETE_IMAGE', $field->name . ' Thumb', $src), 'error');
             }
         }
         $_data = null;
     }
     return $_data;
 }
开发者ID:fields-and-filters,项目名称:fields-and-filters,代码行数:86,代码来源:image.php


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