Пример #1
0
	public function display($tpl = null)
	{
		
		$this->state  = $this->get('State');
		$this->token  = JSession::getFormToken();
		$this->params = $this->state->params;

		
		$app = JFactory::getApplication();

		$submit_simple_search = $app->input->getString('submit_simple_search', '');
		if (isset($submit_simple_search) && $submit_simple_search == "search")
		{
			$model = $this->getModel();
			$model->resetState();
		}
		$this->model = $this->getModel();
		$user        = JFactory::getUser();
		$uri         = JUri::getInstance();
		$this->items = $this->get('Items');
		foreach ($this->items as $item)
		{
			$item->report_link = JRoute::_(JUDownloadHelperRoute::getReportDocumentRoute($item->id));

			
			if ($item->checked_out > 0 && $item->checked_out != $user->get('id'))
			{
				if (JUDownloadFrontHelperPermission::canCheckInDocument($item->id))
				{
					$item->checkin_link = JRoute::_('index.php?option=com_judownload&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri)));
				}
			}
			else
			{
				$item->edit_link = JRoute::_('index.php?option=com_judownload&task=form.edit&id=' . $item->id . '&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id));

				if ($item->published == 1)
				{
					$item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id));
				}
				else
				{
					$item->editstate_link = JRoute::_('index.php?option=com_judownload&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id));
				}
			}

			$item->delete_link = JRoute::_('index.php?option=com_judownload&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDownloadHelperRoute::findItemIdOfDocument($item->id));

			$dispatcher = JDispatcher::getInstance();
			JPluginHelper::importPlugin('content');
			$item->event = new stdClass();
			$context     = 'com_judownload.document_list';

			$results                        = $dispatcher->trigger('onContentAfterTitle', array($context, &$item, &$item->params, 0));
			$item->event->afterDisplayTitle = trim(implode("\n", $results));

			$results                           = $dispatcher->trigger('onContentBeforeDisplay', array($context, &$item, &$item->params, 0));
			$item->event->beforeDisplayContent = trim(implode("\n", $results));

			$results                          = $dispatcher->trigger('onContentAfterDisplay', array($context, &$item, &$item->params, 0));
			$item->event->afterDisplayContent = trim(implode("\n", $results));
		}
		$this->pagination = $this->get('Pagination');
		$this->searchword = trim($app->input->getString('searchword', ''));

		
		$this->searchword = JUDownloadFrontHelper::UrlDecode($this->searchword);

		$this->cat_id  = $app->input->getInt('cat_id', 0);
		$this->sub_cat = $app->input->getInt('sub_cat', 0);

		
		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode("\n", $errors));

			return false;
		}

		$nestedCategories = JUDownloadFrontHelperCategory::getCategoriesRecursive(1, false, false, true);
		$options          = array();

		$parent_cat_level = 0;
		foreach ($nestedCategories AS $key => $categoryObj)
		{
			if ($key == 0)
			{
				$parent_cat_level = $categoryObj->level;
			}
			$options[] = JHtml::_('select.option', $categoryObj->id, str_repeat('-.', ($categoryObj->level - $parent_cat_level)) . $categoryObj->title);
		}
		$this->cat_select_list = JHtml::_('select.genericList', $options, 'cat_id', '', 'value', 'text', $this->cat_id);

		
		$this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));

		$this->_prepareData();
		$this->_prepareDocument();
		$this->_setBreadcrumb();

		parent::display($tpl);
	}
Пример #2
0
	public function onTagSearch(&$query, &$where, $tag = null)
	{
		
		if (!$this->params->get("tag_search", 0))
		{
			return false;
		}

		if (is_null($tag))
		{
			$app = JFactory::getApplication();
			$tag = $app->input->get("tag", "", "string");
		}

		if (!$this->isCore())
		{
			$query->join('', '#__judownload_fields_values AS field_values_' . $this->id . ' ON (d.id = field_values_' . $this->id . '.doc_id AND field_values_' . $this->id . '.field_id = ' . $this->id . ')');
		}

		if ($tag !== "")
		{
			
			$tag = JUDownloadFrontHelper::UrlDecode($tag);

			
			$db = JFactory::getDbo();
			
			$_where = "(( " . $this->fieldvalue_column . " = " . $db->quote($tag) .
				" OR " . $this->fieldvalue_column . " LIKE '" . $db->escape($tag, true) . "|%'" .
				" OR " . $this->fieldvalue_column . " LIKE '%|" . $db->escape($tag, true) . "|%'" .
				" OR " . $this->fieldvalue_column . " LIKE '%|" . $db->escape($tag, true) . "' )";
			$_where .= " OR ( " . $this->fieldvalue_column . " LIKE '" . $db->escape($tag, true) . ",%'" .
				" OR " . $this->fieldvalue_column . " LIKE '%," . $db->escape($tag, true) . ",%'" .
				" OR " . $this->fieldvalue_column . " LIKE '%," . $db->escape($tag, true) . "' ))";
			$where[] = $_where;
		}
	}