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


PHP JemHelper::delete_unused_image_files方法代码示例

本文整理汇总了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();
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:43,代码来源:controller.php

示例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;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:92,代码来源:venue.php


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