本文整理汇总了PHP中JemHelper::delete_unused_image_files方法的典型用法代码示例。如果您正苦于以下问题:PHP JemHelper::delete_unused_image_files方法的具体用法?PHP JemHelper::delete_unused_image_files怎么用?PHP JemHelper::delete_unused_image_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JemHelper
的用法示例。
在下文中一共展示了JemHelper::delete_unused_image_files方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajaximageremove
/**
* Remove image
* @deprecated since version 1.9.7
*/
function ajaximageremove()
{
$id = JFactory::getApplication()->input->getInt('id', 0);
if (!$id) {
jexit();
}
$folder = JFactory::getApplication()->input->getString('type', '');
if ($folder == 'events') {
$getquery = ' SELECT datimage AS image FROM #__jem_events WHERE id = '.(int)$id;
$updatequery = ' UPDATE #__jem_events SET datimage=\'\' WHERE id = '.(int)$id;
} else if ($folder == 'venues') {
$getquery = ' SELECT locimage AS image FROM #__jem_venues WHERE id = '.(int)$id;
$updatequery = ' UPDATE #__jem_venues SET locimage=\'\' WHERE id = '.(int)$id;
} else {
jexit();
}
$db = JFactory::getDBO();
$db->setQuery($getquery);
if (!$image_obj = $db->loadObject()) {
jexit();
}
$image = $image_obj->image;
$fullPath = JPath::clean(JPATH_SITE.'/images/jem/'.$folder.'/'.$image);
if (is_file($fullPath)) {
$db->setQuery($updatequery);
if ($db->execute() === false) {
jexit();
}
JemHelper::delete_unused_image_files($folder, $image);
}
jexit();
}
示例2: store
/**
* Overloaded store method for the Venue table.
*/
public function store($updateNulls = false)
{
$date = JFactory::getDate();
$user = JemFactory::getUser();
$userid = $user->get('id');
$app = JFactory::getApplication();
$jinput = $app->input;
$jemsettings = JEMHelper::config();
// Check if we're in the front or back
if ($app->isAdmin())
$backend = true;
else
$backend = false;
if ($this->id) {
// Existing event
$this->modified = $date->toSql();
$this->modified_by = $userid;
}
else
{
// New event
if (!intval($this->created)){
$this->created = $date->toSql();
}
if (empty($this->created_by)){
$this->created_by = $userid;
}
}
// Check if image was selected
jimport('joomla.filesystem.file');
$image_dir = JPATH_SITE.'/images/jem/venues/';
$allowable = array ('gif', 'jpg', 'png');
$image_to_delete = false;
// get image (frontend) - allow "removal on save" (Hoffi, 2014-06-07)
if (!$backend) {
if (($jemsettings->imageenabled == 2 || $jemsettings->imageenabled == 1)) {
$file = $jinput->files->get('userfile', array(), 'array');
$removeimage = $jinput->getInt('removeimage', 0);
if (!empty($file['name'])) {
//check the image
$check = JEMImage::check($file, $jemsettings);
if ($check !== false) {
//sanitize the image filename
$filename = JEMImage::sanitize($image_dir, $file['name']);
$filepath = $image_dir . $filename;
if (JFile::upload($file['tmp_name'], $filepath)) {
$image_to_delete = $this->locimage; // delete previous image
$this->locimage = $filename;
}
}
} elseif (!empty($removeimage)) {
// if removeimage is non-zero remove image from venue
// (file will be deleted later (e.g. housekeeping) if unused)
$image_to_delete = $this->locimage;
$this->locimage = '';
}
} // end image if
} // if (!backend)
$format = JFile::getExt($image_dir . $this->locimage);
if (!in_array($format, $allowable))
{
$this->locimage = '';
}
if (!$backend) {
/* check if the user has the required rank for autopublish new venues */
if (!$this->id && !$user->can('publish', 'venue', $this->id, $this->created_by)) {
$this->published = 0;
}
}
// item must be stored BEFORE image deletion
$ret = parent::store($updateNulls);
if ($ret && $image_to_delete) {
JemHelper::delete_unused_image_files('venue', $image_to_delete);
}
return $ret;
}