本文整理汇总了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;
}