本文整理汇总了PHP中FlexicontentFields::getFieldValsById方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::getFieldValsById方法的具体用法?PHP FlexicontentFields::getFieldValsById怎么用?PHP FlexicontentFields::getFieldValsById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::getFieldValsById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBeforeSaveField
//.........这里部分代码省略.........
// Handle uploading a new original file
$new_file = $err_code === 0;
$new_file_uploaded = null;
if ($new_file) {
$new_file_uploaded = $this->uploadOriginalFile($field, $v, $files[$n]);
} else {
if ($is_importcsv && $import_media_folder) {
$filename = basename($v['originalname']);
$sub_folder = dirname($v['originalname']);
$sub_folder = $sub_folder && $sub_folder != '.' ? DS . $sub_folder : '';
if ($image_source) {
$srcfilepath = JPath::clean($srcpath_original . $v['originalname']);
$destfilepath = JPath::clean($destpath_original . $filename);
if (JFile::exists($srcfilepath)) {
$result = JFile::copy($srcfilepath, $destfilepath);
if ($result && JPath::canChmod($destfilepath)) {
chmod($destfilepath, 0644);
}
}
$v['originalname'] = $filename;
// make sure filename is without subfolder
} else {
$fman = new FlexicontentControllerFilemanager();
JRequest::setVar('return-url', null, 'post');
JRequest::setVar('file-dir-path', DS . $import_media_folder . $sub_folder, 'post');
JRequest::setVar('file-filter-re', preg_quote($filename), 'post');
JRequest::setVar('secure', 1, 'post');
JRequest::setVar('keep', 1, 'post');
$file_ids = $fman->addlocal();
reset($file_ids);
// Reset array to point to first element
$v['originalname'] = key($file_ids);
// The (first) key of file_ids array is the cleaned up filename
}
}
}
// Defaut values for unset required properties of values
$v['originalname'] = isset($v['originalname']) ? $v['originalname'] : '';
$v['existingname'] = isset($v['existingname']) ? $v['existingname'] : '';
$v['remove'] = isset($v['remove']) ? $v['remove'] : false;
if ($v['originalname'] || $v['existingname']) {
//echo $v['originalname'] ." ". $v['existingname'] ."<br>";
// (c) Handle replacing image with a new existing image
if ($v['existingname']) {
$v['originalname'] = $v['existingname'];
$v['existingname'] = '';
} else {
if ($v['remove']) {
// Deleting or unloading current value: Skip current image row, but allow empty (null) placeholder value if in fieldgroup
$v = $use_ingroup ? null : false;
//$use_ingroup ? array('originalname'=>'') : null;
}
}
} else {
// No new file posted and no existing selected: Skip current image row, but allow empty (null) placeholder value if in fieldgroup
$v = $use_ingroup ? null : false;
//$use_ingroup ? array('originalname'=>'') : null;
}
// Add image entry to a new array skipping empty image entries
if ($v !== false) {
if ($v) {
$new_filenames[$v['originalname']] = 1;
}
$newpost[$new] = $v;
$new++;
}
}
$post = $newpost;
// Remove no longer used files, if limiting existing image list to current field, or if existing image list is hidden/disabled
if ($image_source && ($field->parameters->get('auto_delete_unused', 1) || !$field->parameters->get('list_all_media_files', 0) || !$field->parameters->get('existing_imgs', 1))) {
// Get existing field values,
if (!isset($item->fieldvalues)) {
$_fieldvalues = FlexicontentFields::getFieldValsById(null, array($item->id));
$item->fieldvalues = isset($_fieldvalues[$item->id]) ? $_fieldvalues[$item->id] : array();
}
$db_values = !empty($item->fieldvalues[$field->id]) ? $item->fieldvalues[$field->id] : array();
//echo "<pre>"; print_r($new_filenames); print_r($db_values);
// Remove unused files
foreach ($db_values as $i => $v) {
$fdata = unserialize($v);
$filename = isset($fdata['originalname']) ? $fdata['originalname'] : '';
//echo $filename."\n";
if ($filename && !isset($new_filenames[$filename])) {
$canDeleteImage = $this->canDeleteImage($field, $filename, $item);
// check if value is in use
if ($canDeleteImage) {
$this->removeOriginalFile($field, $filename);
//JFactory::getApplication()->enqueueMessage($field->label . ' ['.$n.'] : ' . 'Deleted image file: '.$filename.' from server storage');
}
}
}
}
// Serialize multi-property data before storing them into the DB,
// null indicates to increment valueorder without adding a value
foreach ($post as $i => $v) {
if ($v !== null) {
$post[$i] = serialize($v);
}
}
}