Example #1
0
	public function filterField($value)
	{
		$return = parent::filterField($value);

		
		if ($this->params->get("strip_tags_before_save", 0))
		{
			$allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
			$allowable_tags = str_replace(' ', '', $allowable_tags);
			$allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
			$return         = strip_tags($return, $allowable_tags);
		}

		return $return;
	}
Example #2
0
	public function onSimpleSearch(&$query, &$where, $search)
	{
		
		$matched_options = array();
		$options         = $this->getPredefinedValues();
		foreach ($options AS $option)
		{
			if (strpos(mb_strtolower($search, 'UTF-8'), mb_strtolower($option->text, 'UTF-8')) !== false)
			{
				$matched_options[] = $option->value;
			}
		}
		
		parent::onSimpleSearch($query, $where, $matched_options);
	}
Example #3
0
	public function isPublished()
	{
		$storeId = md5(__METHOD__ . "::" . $this->id);
		if (!isset(self::$cache[$storeId]))
		{
			
			$app = JFactory::getApplication();
			if ($app->isAdmin())
			{
				self::$cache[$storeId] = false;

				return self::$cache[$storeId];
			}

			self::$cache[$storeId] = parent::isPublished();

			return self::$cache[$storeId];
		}

		return self::$cache[$storeId];
	}
Example #4
0
	public function canView($options = array())
	{
		$storeId = md5(__METHOD__ . "::" . $this->doc_id . "::" . $this->id . "::" . serialize($options));

		if (!isset(self::$cache[$storeId]))
		{
			if (!$this->isPublished())
			{
				self::$cache[$storeId] = false;

				return self::$cache[$storeId];
			}

			
			if (isset($this->doc) && $this->doc->cat_id)
			{
				$params = JUDownloadHelper::getParams($this->doc->cat_id);
			}
			else
			{
				$params = JUDownloadHelper::getParams(null, $this->doc_id);
			}

			$show_empty_field = $params->get('show_empty_field', 0);
			
			if ($this->doc_id && !$show_empty_field)
			{
				$app = JFactory::getApplication();
				if ($app->isSite())
				{
					if (!is_object($this->value) || !$this->value->published)
					{
						self::$cache[$storeId] = false;

						return self::$cache[$storeId];
					}
				}
				else
				{
					if (!is_object($this->value))
					{
						self::$cache[$storeId] = false;

						return self::$cache[$storeId];
					}
				}
			}

			self::$cache[$storeId] = parent::canView($options);

			return self::$cache[$storeId];
		}

		return self::$cache[$storeId];
	}
Example #5
0
	public function storeValue($value, $type = 'default', $inputData = null)
	{
		if ($type == 'migrate')
		{
			
			$iconKeyArray = $this->getId() . "_icon";
			$icon         = $inputData[$iconKeyArray];

			
			$mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp");
			if ($icon['name'])
			{
				if (in_array($icon['type'], $mime_types))
				{
					
					

					
					$iconDirectory  = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/");
					$icon_file_name = $this->doc_id . "_" . JUDownloadHelper::fileNameFilter($icon['name']);
					if (JFile::copy($icon['tmp_name'], $iconDirectory . "original/" . $icon_file_name)
						&& JUDownloadHelper::renderImages($iconDirectory . "original/" . $icon_file_name, $iconDirectory . $icon_file_name, 'doc_icon', true, null, $this->doc_id)
					)
					{
						$value = $icon_file_name;
						parent::storeValue($value, $type, $inputData);
					}
				}
			}
			elseif ($value == "" || strpos($value, 'default/') === 0)
			{
				if ($this->doc && $this->doc->icon && strpos($this->doc->icon, 'default/') === false)
				{
					$this->removeIcon();
				}
				parent::storeValue($value, $type, $inputData);
			}
		}
		else
		{
			$app = JFactory::getApplication();

			
			$icon = $app->input->files->get($this->getId() . "_icon");
			
			$mime_types = array("image/jpeg", "image/pjpeg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp");
			if ($icon['name'])
			{
				if (in_array($icon['type'], $mime_types))
				{
					
					$this->removeIcon();

					
					$iconDirectory  = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("document_icon_directory", "media/com_judownload/images/document/");
					$icon_file_name = $this->doc_id . "_" . JUDownloadHelper::fileNameFilter($icon['name']);
					if (JFile::upload($icon['tmp_name'], $iconDirectory . "original/" . $icon_file_name)
						&& JUDownloadHelper::renderImages($iconDirectory . "original/" . $icon_file_name, $iconDirectory . $icon_file_name, 'doc_icon', true, null, $this->doc_id)
					)
					{
						$value = $icon_file_name;
						parent::storeValue($value, $type, $inputData);
					}
				}
				else
				{
					JError::raise(
						E_NOTICE,
						500,
						JText::sprintf('COM_JUDOWNLOAD_ICON_IS_NOT_VALID_MIME_TYPE')
					);
				}
			}
			elseif ($value == "" || strpos($value, 'default/') === 0)
			{
				if ($this->doc && $this->doc->icon && strpos($this->doc->icon, 'default/') === false)
				{
					$this->removeIcon();
				}
				parent::storeValue($value, $type, $inputData);
			}
		}
	}
	public function canEdit($userID = null)
	{
		$app = JFactory::getApplication();
		if ($app->isSite())
		{
			return false;
		}
		else
		{
			return parent::canEdit($userID);
		}
	}
	public function getLabel($required = true)
	{
		parent::getLabel();

		return $this->fetch('label.php', __CLASS__);
	}
Example #8
0
	public function onSearch(&$query, &$where, $search)
	{
		if ($search !== "")
		{
			if ($this->params->get("tag_search", 0))
			{
				$search = explode(",", $search);
			}

			return parent::onSearch($query, $where, $search);
		}
	}
Example #9
0
	public function PHPValidate($values)
	{
		
		if (isset($this->doc) && $this->doc->cat_id)
		{
			$params = JUDownloadHelper::getParams($this->doc->cat_id);
		}
		else
		{
			$params = JUDownloadHelper::getParams(null, $this->doc_id);
		}

		$maxTags = $params->get("max_tags_per_doc", 10);
		if ($maxTags)
		{
			$values = str_replace("|", ",", $values);
			$tags   = explode(",", $values);

			if (count($tags) > $maxTags)
			{
				return JText::sprintf('COM_JUDOWNLOAD_TOTAL_TAGS_OVER_MAX_X_TAGS', $maxTags);
			}
		}

		return parent::PHPValidate($values);
	}