protected function getInput()
 {
     if ($this->form->getValue("id") && $this->form->getValue("plugin_id")) {
         $fieldObj = JUDownloadFrontHelperField::getField($this->form->getValue("id"));
         $html = $fieldObj->getPredefinedValuesHtml();
     } else {
         $html = '<span class="readonly">' . JText::_('COM_JUDOWNLOAD_NO_VALUE') . '</span>';
     }
     return $html;
 }
Exemplo n.º 2
0
 public function display($tpl = null)
 {
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->model = $this->getModel();
     $this->app = JFactory::getApplication();
     $cat_id = $this->item->cat_id ? $this->item->cat_id : $this->app->input->get('cat_id');
     $this->params = JUDownloadHelper::getParams(null, $this->item->id);
     if ($cat_id == JUDownloadFrontHelperCategory::getRootCategory()->id && !$this->params->get('allow_add_doc_to_root', 0)) {
         JError::raiseError(500, JText::_('COM_JUDOWNLOAD_CAN_NOT_ADD_DOCUMENT_TO_ROOT_CATEGORY'));
         return false;
     }
     if ($tempDocument = JUDownloadHelper::getTempDocument($this->item->id)) {
         $editPendingDocLink = '<a href="index.php?option=com_judownload&task=document.edit&approve=1&id=' . $tempDocument->id . '">' . $tempDocument->title . '</a>';
         JError::raiseNotice('', JText::sprintf('COM_JUDOWNLOAD_THIS_DOCUMENT_HAS_PENDING_DOCUMENT_X_PLEASE_APPROVE_PENDING_DOCUMENT_FIRST', $editPendingDocLink));
     }
     if ($this->item->approved < 0) {
         $oriDocId = abs($this->item->approved);
         $oriDocObj = JUDownloadHelper::getDocumentById($oriDocId);
         $editOriDocLink = '<a href="index.php?option=com_judownload&task=document.edit&id=' . $oriDocId . '">' . $oriDocObj->title . '</a>';
         JError::raiseNotice('', JText::sprintf('COM_JUDOWNLOAD_ORIGINAL_DOCUMENT_X', $editOriDocLink));
     }
     $this->script = $this->get('Script');
     $this->plugins = $this->get('Plugins');
     $this->fieldsetDetails = $this->model->getCoreFields('details');
     $this->fieldsetPublishing = $this->model->getCoreFields('publishing');
     $this->fieldsetTemplateStyleAndLayout = $this->model->getCoreFields('template_style');
     $this->fieldsetMetadata = $this->model->getCoreFields('metadata');
     $this->fieldCatid = JUDownloadFrontHelperField::getField('cat_id', $this->item);
     $this->fieldGallery = JUDownloadFrontHelperField::getField('gallery', $this->item);
     $this->files = $this->get('Files');
     $this->changeLogs = $this->get('ChangeLogs');
     $this->versions = $this->get('Versions');
     $this->extraFields = $this->get('ExtraFields');
     $this->fieldsData = $this->app->getUserState("com_judownload.edit.document.fieldsdata", array());
     $this->relatedDocuments = $this->get('RelatedDocuments');
     $this->canDo = JUDownloadHelper::getActions('com_judownload', 'category', $this->item->cat_id);
     $this->addToolBar();
     $this->setDocument();
     parent::display($tpl);
 }
Exemplo n.º 3
0
									<?php
									if ($commentObj->user_id > 0)
									{
										$userComment = JFactory::getUser($commentObj->user_id);
										echo $userComment->get('name');
									}
									else
									{
										echo $commentObj->guest_name;
									} ?>
									</span>
								</h3>
								<?php
								if ($commentObj->parent_id == $this->root_comment->id)
								{
									$fieldRating = JUDownloadFrontHelperField::getField('rating', $commentObj->doc_id);

									echo $fieldRating->getOutput(array('view' => 'details', 'template' => $this->template, 'type' => 'comment', 'comment_object' => $commentObj));
								} ?>
							</div>
							<!-- /.comment-user -->

							<div class="comment-text">
								<div class="judl-metadata clearfix">
									<h4 class="comment-title" itemprop="name"><?php echo $commentObj->title; ?></h4>

									<div itemprop="datePublished" class="comment-created">
										<?php echo JText::_('COM_JUDOWNLOAD_POST_ON') . " : " . $commentObj->createdAgo; ?>
									</div>

									<?php if ($commentObj->website != '')
Exemplo n.º 4
0
$doc_grid_col = $this->document_bootstrap_columns[$this->col_counter - 1];

// Get all list view fields, also add 'external_link', 'license_id', 'confirm_license'
$additionFields = array();
if (trim($this->item->external_link))
{
	$additionFields[] = 'external_link';
}

if ($this->item->license_id && $this->item->confirm_license)
{
	$additionFields[] = 'license_id';
	$additionFields[] = 'confirm_license';
}

$fields = JUDownloadFrontHelperField::getFields($this->item, 1, array(), array(), $additionFields);

// Ignore these fields from summary fields
$ignoredFields = array("title", "description", "icon", "publish_up", "created_by", "featured", "cat_id", "tags");
$summaryFields = array();
foreach ($fields AS $fieldKey => $field)
{
	if (!in_array($fieldKey, $ignoredFields) && is_object($field) && $field->canView(array("view" => "list")))
	{
		$summaryFields[] = $field;
	}
}
?>
	<div class="<?php echo $item_class; ?>" data-list-class="col-md-12" data-grid-class="col-md-<?php echo $doc_grid_col; ?>">
	<?php
	$iconField = isset($fields['icon']) ? $fields['icon'] : null;
Exemplo n.º 5
0
	public static function getDocumentsSearch($searchword, $state, $cat_id = null)
	{
		
		$searchword = trim($searchword);

		$app        = JFactory::getApplication();
		$user       = JFactory::getUser();
		$levels     = $user->getAuthorisedViewLevels();
		$levels_str = implode(',', $levels);
		$db         = JFactory::getDbo();
		$nullDate   = $db->getNullDate();
		$nowDate    = JFactory::getDate()->toSql();
		$query      = $db->getQuery(true);

		$listOrder = $state->get('list.ordering');
		$listDirn  = $state->get('list.direction');
		
		if ($app->isAdmin())
		{
			$query->SELECT('d.id, d.title, d.alias, d.published, d.publish_up, d.publish_down, d.checked_out, d.checked_out_time, d.featured, d.access, d.created_by, d.downloads, d.language');

			$query->SELECT('c.id AS category_id, c.title AS category_title');

			$where_str = $app->isSite() ? ' AND cm.published = 1' : '';
			$query->SELECT('(SELECT COUNT(*) FROM #__judownload_comments AS cm WHERE (cm.doc_id = d.id AND cm.approved = 1' . $where_str . ')) AS comments');

			$query->SELECT('(SELECT COUNT(*) FROM #__judownload_reports AS r WHERE r.item_id = d.id AND r.type="document") AS reports');

			$where_str = $app->isSite() ? ' AND s.published = 1' : '';
			$query->SELECT('(SELECT COUNT(*) FROM #__judownload_subscriptions AS s WHERE s.item_id = d.id AND s.type="document"' . $where_str . ') AS subscriptions');

			$query->SELECT('ua.name AS created_by_name');
			$query->JOIN("LEFT", "#__users AS ua ON d.created_by = ua.id");

			$query->SELECT('ua3.name AS checked_out_name');
			$query->JOIN("LEFT", "#__users AS ua3 ON d.checked_out = ua3.id");

			$query->SELECT("vl.title AS access_title");
			$query->JOIN("LEFT", "#__viewlevels AS vl ON d.access = vl.id");
		}
		
		else
		{
			$query->SELECT('d.*');
			if ($app->isSite())
			{
				JUDownloadFrontHelper::optimizeListDocumentQuery($query);
			}
		}

		$query->FROM('#__judownload_documents AS d');
		$query->JOIN('', '#__judownload_documents_xref AS dxref ON d.id = dxref.doc_id');
		$query->JOIN('', '#__judownload_categories AS c ON (c.id = dxref.cat_id)');

		
		$field_query = $db->getQuery(true);
		
		$field_query->select("field.*");
		$field_query->from("#__judownload_fields AS field");
		$field_query->select("plg.folder");
		$field_query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id");
		$field_query->join("", "#__judownload_fields_groups AS field_group ON field_group.id = field.group_id");
		$field_query->join("", "#__judownload_categories AS c2 ON (c2.fieldgroup_id = field_group.id OR field.group_id = 1)");
		if ($app->isSite())
		{
			if (is_array($cat_id))
			{
				$cat_id = (array) $cat_id;
				$field_query->where('(c2.id IN (' . implode(",", $cat_id) . ') OR field.group_id = 1)');
			}
			elseif ($cat_id)
			{
				$cat_id = (int) $cat_id;
				$field_query->where('(c2.id = ' . $cat_id . ' OR field.group_id = 1)');
			}
			$field_query->where('c2.published = 1');
			$field_query->where('c2.publish_up <= ' . $db->quote($nowDate));
			$field_query->where('(c2.publish_down = ' . $db->quote($nullDate) . ' OR c2.publish_down > ' . $db->quote($nowDate) . ')');
		}
		
		$field_query->where('field.simple_search = 1');
		$field_query->where('field.published = 1');
		$field_query->where('field.publish_up <= ' . $db->quote($nowDate));
		$field_query->where('(field.publish_down = ' . $db->quote($nullDate) . ' OR field.publish_down > ' . $db->quote($nowDate) . ')');
		$field_query->where('(field.field_name != "cat_id"');
		$field_query->where("field_group.published = 1)");
		$field_query->group('field.id');
		$db->setQuery($field_query);
		$fields = $db->loadObjectList();
		$where  = array();
		if ($fields)
		{
			foreach ($fields AS $field)
			{
				if ($searchword)
				{
					$fieldClass = JUDownloadFrontHelperField::getField($field);
					$fieldClass->onSimpleSearch($query, $where, $searchword);
				}
			}

			if (!empty($where))
			{
				$query->WHERE("(" . implode(" OR ", $where) . ")");
			}
		}

		$app = JFactory::getApplication();
		if ($app->isAdmin())
		{
			$published = $state->get('filter.state');
			if (is_numeric($published))
			{
				$query->WHERE('d.published = ' . (int) $published);
			}

			$cat_id = $state->get('filter.category');
			if (is_numeric($cat_id))
			{
				$query->WHERE('dxref.cat_id = ' . (int) $cat_id);
			}

			$access_level = $state->get('filter.access');
			if (is_numeric($access_level) && ($access_level != 0))
			{
				$query->WHERE('d.access = ' . (int) $access_level);
			}

			
			$language = $state->get('filter.language');
			if ($language)
			{
				$query->where('d.language = ' . $db->quote($language));
			}
		}
		else
		{
			$query->where('d.published = 1');
			if ($cat_id)
			{
				if (is_array($cat_id))
				{
					$cat_id = (array) $cat_id;
					$query->where('c.id IN (' . implode(",", $cat_id) . ')');
				}
				elseif ($cat_id)
				{
					$cat_id = (int) $cat_id;
					$query->where('c.id = ' . $cat_id);
				}
			}

			$query->where('d.publish_up <= ' . $db->quote($nowDate));
			$query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down > ' . $db->quote($nowDate) . ')');

			
			if ($user->get('guest'))
			{
				$query->where('d.access IN (' . $levels_str . ')');
			}
			else
			{
				$query->where('(d.access IN (' . $levels_str . ') OR (d.created_by = ' . $user->id . '))');
			}
		}

		$query->where('d.approved = 1');

		JUDownloadFrontHelperField::appendFieldOrderingPriority($query, null, $listOrder, $listDirn);

		
		$query->group('d.id');

		return $query;
	}
Exemplo n.º 6
0
 public function getGalleryField()
 {
     $app = JFactory::getApplication();
     $docId = $app->input->getInt('id', 0);
     $galleryField = JUDownloadFrontHelperField::getField('gallery', $docId);
     if ($this->getDocumentSubmitType($docId) == 'submit' && $galleryField->canSubmit() || $this->getDocumentSubmitType($docId) == 'edit' && $galleryField->canEdit()) {
         return $galleryField;
     }
     return null;
 }
Exemplo n.º 7
0
		<?php echo JText::_('COM_JUDOWNLOAD_DOWNLOAD'); ?>
	</th>
	<th style="width:5%" class="center">
		<?php echo JText::_('COM_JUDOWNLOAD_FIELD_ID'); ?>
	</th>
</tr>
</thead>

<tbody>
<?php
if (is_array($this->items) && count($this->items))
{
	foreach ($this->items AS $i => $item)
	{
		$this->item = $item;
		$fields = JUDownloadFrontHelperField::getFields($item, null);
		?>
		<tr>
		<td class="center">
			<input type="checkbox" class="judl-cb" name="cid[]" value="<?php echo $item->id; ?>"
			       id="judl-cb-<?php echo $i; ?>"/>
		</td>
		<td class="title">
			<div class="title-wrapper">
				<a href="<?php echo JRoute::_(JUDownloadHelperRoute::getDocumentRoute($item->id)); ?>"
				   title="<?php echo $item->title; ?>">
					<?php echo $item->title; ?>
				</a>
				<?php
				if ($item->label_unpublished)
				{
Exemplo n.º 8
0
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     $this->load($pk);
     $pk = is_null($pk) ? $this->id : $pk;
     $db = JFactory::getDbo();
     $fieldObj = JUDownloadFrontHelperField::getField($pk);
     $fieldObj->onDelete(true);
     $query = "DELETE FROM #__judownload_fields_ordering WHERE field_id = {$pk}";
     $db->setQuery($query);
     $db->execute();
     $query = "DELETE FROM #__judownload_fields_values WHERE field_id = {$pk}";
     $db->setQuery($query);
     $db->execute();
     return parent::delete($pk);
 }
Exemplo n.º 9
0
 public static function getAdvSearchFields()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $nullDate = $db->quote($db->getNullDate());
     $nowDate = $db->quote(JFactory::getDate()->toSql());
     $query = $db->getQuery(true);
     $query->select('plg.folder, field.*, field_group.name AS filed_group_name');
     $query->from('#__judownload_fields AS field');
     $query->join('', '#__judownload_plugins AS plg ON field.plugin_id = plg.id');
     $query->join('', '#__judownload_fields_groups AS field_group ON field.group_id = field_group.id');
     if ($app->isSite()) {
         $query->where('field.advanced_search = 1');
     }
     $query->where('field_group.published = 1');
     $query->where('field.published = 1');
     $query->where('field.field_name != "cat_id"');
     $query->where('field.publish_up <= ' . $nowDate);
     $query->where('(field.publish_down = ' . $nullDate . ' OR field.publish_down > ' . $nowDate . ')');
     $query->order('field.group_id');
     $db->setQuery($query);
     $fields = $db->loadObjectList();
     if ($fields) {
         $fieldGroups = array();
         foreach ($fields as $field) {
             if (!isset($fieldGroups[$field->group_id])) {
                 $fieldGroups[$field->group_id] = new stdClass();
                 $fieldGroups[$field->group_id]->name = $field->filed_group_name;
                 $fieldGroups[$field->group_id]->id = $field->group_id;
                 $fieldGroups[$field->group_id]->fields = array();
             }
             $fieldGroups[$field->group_id]->fields[] = JUDownloadFrontHelperField::getField($field);
         }
         return $fieldGroups;
     }
     return null;
 }
Exemplo n.º 10
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];
			}

			
			$app            = JFactory::getApplication();
			$languageFilter = $app->getLanguageFilter();
			if ($languageFilter)
			{
				$languageTag = JFactory::getLanguage()->getTag();
				if (($this->language != $languageTag && $this->language != '*' && $this->language != ''))
				{
					self::$cache[$storeId] = false;

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

			if ($this->doc_id)
			{
				$document_display_params = JUDownloadFrontHelperDocument::getDocumentDisplayParams($this->doc_id);
				$document_display_fields = $document_display_params->get('fields');
			}

			$options = (array) $options;

			$field_name = $this->field_name ? $this->field_name : $this->id;
			if ($this->isDetailsView($options))
			{
				
				if (isset($document_display_fields->$field_name) && isset($document_display_fields->$field_name->details_view))
				{
					if (!$document_display_fields->$field_name->details_view)
					{
						self::$cache[$storeId] = false;

						return self::$cache[$storeId];
					}
				}
				
				elseif (!$this->details_view)
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
			}
			else
			{
				
				if (isset($document_display_fields->$field_name) && isset($document_display_fields->$field_name->list_view))
				{
					if (!$document_display_fields->$field_name->list_view)
					{
						self::$cache[$storeId] = false;

						return self::$cache[$storeId];
					}
				}
				
				elseif (!$this->list_view)
				{
					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)
			{
				$field_value = $this->value;

				if (is_null($field_value))
				{
					self::$cache[$storeId] = false;

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

				if (is_string($field_value) && trim($field_value) === '')
				{
					self::$cache[$storeId] = false;

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

				if (is_array($field_value) && count($field_value) == 0)
				{
					self::$cache[$storeId] = false;

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

			$user = JFactory::getUser();
			if ($user)
			{
				$viewLevels    = JAccess::getAuthorisedViewLevels($user->id);
				$fieldGroupObj = JUDownloadFrontHelperField::getFieldGroupById($this->group_id);
				
				if (!in_array($fieldGroupObj->access, $viewLevels))
				{
					self::$cache[$storeId] = false;

					return self::$cache[$storeId];
				}
				else
				{
					if (in_array($this->access, $viewLevels))
					{
						self::$cache[$storeId] = true;

						return self::$cache[$storeId];
					}
					else
					{
						
						if ($this->doc_id && $this->who_can_download_can_access)
						{
							$canDownloadDocument = JUDownloadFrontHelperPermission::canDownloadDocument((int) $this->doc_id, true);

							return $canDownloadDocument;
						}
					}
				}
			}

			self::$cache[$storeId] = false;

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

		return self::$cache[$storeId];
	}
Exemplo n.º 11
0
	protected function getListQuery()
	{
		$app                    = JFactory::getApplication();
		$rootCategory           = JUDownloadFrontHelperCategory::getRootCategory();
		$categoryId             = $this->getState('category.id', $rootCategory->id);
		$getAllNestedCategories = $app->input->getInt('all', 0);

		$catFilter = true;
		
		if ($categoryId == 1 && $getAllNestedCategories == 1)
		{
			$catFilter = false;
		}

		if ($catFilter)
		{
			$categoryIdArray = array();
			if ($getAllNestedCategories == 1)
			{
				$nestedCategories = JUDownloadFrontHelperCategory::getCategoriesRecursive($categoryId, true, true);
				if (count($nestedCategories) > 0)
				{
					foreach ($nestedCategories AS $categoryObj)
					{
						$categoryIdArray[] = $categoryObj->id;
					}
				}
			}
			array_unshift($categoryIdArray, $categoryId);
			$categoryString = implode(",", $categoryIdArray);
		}

		$ordering  = $this->getState('list.ordering', '');
		$direction = $this->getState('list.direction', 'ASC');

		$user      = JFactory::getUser();
		$levels    = $user->getAuthorisedViewLevels();
		$levelsStr = implode(',', $levels);

		$db       = JFactory::getDbo();
		$nullDate = $db->getNullDate();
		$nowDate  = JFactory::getDate()->toSql();

		
		$query = $db->getQuery(true);
		$query->select('d.*');
		$query->from('#__judownload_documents AS d');

		JUDownloadFrontHelper::optimizeListDocumentQuery($query);

		if ($catFilter)
		{
			
			$query->join('', '#__judownload_documents_xref AS dxref ON d.id = dxref.doc_id');
			$query->join('', '#__judownload_categories AS c ON c.id = dxref.cat_id');

			
			$query->where('c.id IN(' . $categoryString . ')');

			
			$query->group('d.id');
		}

		
		$query->where('d.approved = 1');

		
		$query->where('d.published = 1');
		$query->where('(d.publish_up = ' . $db->quote($nullDate) . ' OR d.publish_up <= ' . $db->quote($nowDate) . ')');
		$query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down >= ' . $db->quote($nowDate) . ')');

		
		if ($user->get('guest'))
		{
			$query->where('d.access IN (' . $levelsStr . ')');
		}
		else
		{
			$query->where('(d.access IN (' . $levelsStr . ') OR (d.created_by = ' . $user->id . '))');
		}

		
		$query->where('d.featured = 1');


		
		$app = JFactory::getApplication();
		$tag = JFactory::getLanguage()->getTag();

		if ($app->getLanguageFilter())
		{
			$query->where('d.language IN (' . $db->quote($tag) . ',' . $db->quote('*') . ',' . $db->quote('') . ')');
		}

		
		$categoryRoot = JUDownloadFrontHelperCategory::getRootCategory();

		JUDownloadFrontHelperField::appendFieldOrderingPriority($query, $categoryRoot->id, $ordering, $direction);

		return $query;
	}
Exemplo n.º 12
0
 public function cancel($key = null)
 {
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     $doc_id = $app->input->getInt('id', 0);
     if ($doc_id) {
         $documentObject = JUDownloadHelper::getDocumentById($doc_id);
         $cat_id = $documentObject->cat_id;
     } else {
         $fieldCategory = JUDownloadFrontHelperField::getField('cat_id');
         $fieldData = $app->input->post->get('fields', array(), 'array');
         $cat_id = $fieldData[$fieldCategory->id]['main'];
     }
     if (!$cat_id) {
         $rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
         $cat_id = $rootCategory->id;
     }
     $files = $app->input->get("judlfiles", array(), 'array');
     $context = $this->option . ".edit." . $this->context;
     if (isset($files)) {
         $file_directory = JPATH_ROOT . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
         $file_directory_tmp = $file_directory . "tmp/";
         $files = array_values($files);
         foreach ($files as $file) {
             if (isset($file['file_name']) && $file['file_name']) {
                 $file_path = $file_directory_tmp . $file['file_name'];
                 if (JFile::exists($file_path)) {
                     JFile::delete($file_path);
                 }
             }
             if (isset($file['replace']) && $file['replace']) {
                 $file_path = $file_directory_tmp . $file['replace'];
                 if (JFile::exists($file_path)) {
                     JFile::delete($file_path);
                 }
             }
         }
     }
     $app->setUserState($context . '.data', null);
     $app->setUserState($context . '.fieldsdata', null);
     $app->setUserState($context . '.changelogs', null);
     $app->setUserState($context . '.versions', null);
     $app->setUserState($context . '.files', null);
     $app->setUserState($context . '.related_documents', null);
     if ($doc_id) {
         $db = JFactory::getDbo();
         $query = "SELECT cat_id FROM #__judownload_documents_xref WHERE doc_id = {$doc_id} AND main = 1";
         $db->setQuery($query);
         $cat_id = $db->loadResult();
     }
     parent::cancel($key = null);
     if ($this->view_list == "pendingdocuments") {
         $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
     } else {
         $this->setRedirect("index.php?option=com_judownload&view=listcats&cat_id={$cat_id}");
     }
 }
Exemplo n.º 13
0
 public function save($data)
 {
     if (!$data['id']) {
         return false;
     }
     $app = JFactory::getApplication();
     $jform = $app->input->post->get('jform', array(), 'array');
     $data['params'] = isset($jform['params']) ? $jform['params'] : null;
     $table = $this->getTable();
     if ($table->load($data['id']) && $table->plugin_id == $data['plugin_id']) {
         $fieldClass = JUDownloadFrontHelperField::getField($data['id']);
         $data = $fieldClass->onSave($data);
         $data['params'] = json_encode($data['params']);
     } else {
         $data['params'] = "";
     }
     if (parent::save($data)) {
         $table = $this->getTable();
         $table->reorder("group_id = " . (int) $data['group_id']);
         $table->repriority();
         $table->reblvorder();
         return true;
     }
     return false;
 }
Exemplo n.º 14
0
	public static function appendFieldOrderingPriority(&$query = null, $catIds = null, $ordering = null, $direction = null)
	{
		if (!$catIds)
		{
			$catIds = JUDownloadFrontHelperCategory::getRootCategory()->id;
		}

		$storeId = md5(__METHOD__ . "::" . serialize($catIds) . "::$ordering");
		if (!isset(self::$cache[$storeId]))
		{
			$db             = JFactory::getDbo();
			$nullDate       = $db->getNullDate();
			$nowDate        = JFactory::getDate()->toSql();
			$priority_query = $db->getQuery(true);
			$priority_query->select("field.*");
			$priority_query->from("#__judownload_fields AS field");
			$priority_query->select("plg.folder");
			$priority_query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id ");
			$priority_query->join("", "#__judownload_fields_groups AS field_group ON field.group_id = field_group.id");
			$priority_query->join("", "#__judownload_categories AS c ON (
																			(
																				c.fieldgroup_id = field_group.id AND
																				c.published = 1 AND
																				c.publish_up <= " . $db->quote($nowDate) . " AND
																				(c.publish_down = " . $db->quote($nullDate) . " OR c.publish_down > " . $db->quote($nowDate) . ")
																			) OR field.group_id = 1
																		 )");
			$where   = array();
			$where[] = 'field.published = 1';
			$where[] = 'field.publish_up <= ' . $db->quote($nowDate);
			$where[] = '(field.publish_down = ' . $db->quote($nullDate) . ' OR field.publish_down > ' . $db->quote($nowDate) . ')';

			if (is_array($catIds))
			{
				$where[] = "(c.id IN (" . implode(",", $catIds) . ") OR field.group_id = 1)";
			}
			else
			{
				$where[] = "(c.id = $catIds OR field.group_id = 1)";
			}

			$where[] = 'field.allow_priority = 1';
			$where[] = 'field_group.published = 1';

			
			$priority_query->where("(" . implode(" AND ", $where) . ")", "OR");

			if ($ordering)
			{
				$where   = array();
				$where[] = "(field.id = '$ordering' OR field.field_name = '$ordering')";
				$app     = JFactory::getApplication();
				if ($app->isSite())
				{
					$where[] = "field.frontend_ordering = 1";
				}
				else
				{
					$where[] = "field.backend_list_view >= 1";
				}
				$where[] = "field.published = 1";
				$where[] = "field.publish_up <= " . $db->quote($nowDate);
				$where[] = "(field.publish_down = " . $db->quote($nullDate) . " OR field.publish_down >= " . $db->quote($nowDate) . ")";
				$priority_query->where("(" . implode(" AND ", $where) . ")", "OR");
			}
			$priority_query->group('field.id');

			$priority_query->order('field.priority ASC');

			$db->setQuery($priority_query);

			self::$cache[$storeId] = $db->loadObjectList();
		}

		$priorityFields = self::$cache[$storeId];

		$priority_order = array();
		
		$_ordering = "";
		foreach ($priorityFields AS $priorityField)
		{
			$field = JUDownloadFrontHelperField::getField($priorityField);
			if ($field)
			{
				$priority = $field->orderingPriority($query);
				if ($priority)
				{
					$priority_order[] = $priority['ordering'] . ' ' . $priority['direction'];
				}

				if ($ordering && $field->id == $ordering && $priority)
				{
					$_ordering = $priority['ordering'];
				}
			}
		}

		$priority_str = "";
		if ($priority_order)
		{
			$priority_str = implode(", ", $priority_order);
		}

		if ($_ordering)
		{
			$ordering_str = $_ordering . " " . $direction;
			if ($priority_str)
			{
				$priority_str = $ordering_str . ", " . $priority_str;
			}
		}

		if ($priority_str)
		{
			$query->order($priority_str);
		}

		return $priority_str;
	}
Exemplo n.º 15
0
 public function saveCategoryPrepareFieldGroup($pk, $newParentObject, $table, &$data)
 {
     $app = JFactory::getApplication();
     if ($pk > 0) {
         if ($data['selected_fieldgroup'] == -1) {
             if ($table->selected_fieldgroup == -1) {
                 if ($table->parent_id == $data['parent_id']) {
                     $data['fieldgroup_id'] = $table->fieldgroup_id;
                 } else {
                     $newFieldGroupId = $newParentObject->fieldgroup_id;
                     if ($table->fieldgroup_id == $newFieldGroupId) {
                         $data['fieldgroup_id'] = $table->fieldgroup_id;
                     } else {
                         if ($data['changeFieldGroupAction'] == 1) {
                             $data['fieldgroup_id'] = $table->fieldgroup_id;
                             $data['selected_fieldgroup'] = $table->fieldgroup_id;
                             $fieldGroupObject = JUDownloadFrontHelperField::getFieldGroupById($table->fieldgroup_id);
                             $app->enqueueMessage(JText::sprintf('COM_JUDOWNLOAD_INHERITED_FIELD_GROUP_HAS_BEEN_CHANGED_TO_X', $fieldGroupObject->name ? $fieldGroupObject->name : JText::_("COM_JUDOWNLOAD_NONE")), 'Notice');
                         } else {
                             $data['fieldgroup_id'] = $newParentObject->fieldgroup_id;
                         }
                     }
                 }
             } else {
                 $data['fieldgroup_id'] = $newParentObject->fieldgroup_id;
             }
         } else {
             $data['fieldgroup_id'] = $data['selected_fieldgroup'];
         }
     } else {
         if ($data['selected_fieldgroup'] == -1) {
             $data['fieldgroup_id'] = $newParentObject->fieldgroup_id;
         } else {
             $data['fieldgroup_id'] = $data['selected_fieldgroup'];
         }
     }
 }
Exemplo n.º 16
0
 public function insertUpdateDocument($data, $isInsert = true)
 {
     $db = JFactory::getDbo();
     $iconDir = JPATH_ROOT . '/' . JUDownloadFrontHelper::getDirectory('document_icon_directory', 'media/com_judownload/images/document/');
     $originalDir = $iconDir . 'original/';
     $newMainCatId = $data['main_cat'];
     $gallery = $data['gallery'];
     $files = $data['files'];
     $fieldsData = $data['fieldsData'];
     $relatedDocs = $data['related_docs'];
     $data = $data['data'];
     $messages = array();
     if (!$isInsert) {
         $docObj = JUDownloadHelper::getDocumentById($data['id']);
         if ($docObj->cat_id != $newMainCatId) {
             $oldFieldGroup = JUDownloadHelper::getCategoryById($docObj->cat_id);
             $newFieldGroup = JUDownloadHelper::getCategoryById($newMainCatId);
             if ($oldFieldGroup->fieldgroup_id != $newFieldGroup->fieldgroup_id) {
                 $query = $db->getQuery(true);
                 $query->select("field.*");
                 $query->from("#__judownload_fields AS field");
                 $query->select("plg.folder");
                 $query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id");
                 $query->join("", "#__judownload_categories AS c ON (c.fieldgroup_id = field.group_id AND field.group_id != 1)");
                 $query->join("", "#__judownload_documents_xref AS dxref ON (dxref.cat_id = c.id AND dxref.main = 1)");
                 $query->join("", "#__judownload_documents AS d ON dxref.doc_id = d.id");
                 $query->where("d.id = " . $data['id']);
                 $query->group('field.id');
                 $query->order('field.ordering');
                 $db->setQuery($query);
                 $fields = $db->loadObjectList();
                 foreach ($fields as $field) {
                     $fieldObj = JUDownloadFrontHelperField::getField($field, $data['id']);
                     $fieldObj->onDelete();
                 }
             }
         }
     }
     $iconPath = '';
     $iconFieldId = $this->field_name_id_array['icon'];
     if (!empty($data['icon'])) {
         $iconPath = $data['icon'];
         unset($data['icon']);
     }
     if (!empty($fieldsData[$iconFieldId])) {
         $iconPath = $fieldsData[$iconFieldId];
         unset($fieldsData[$iconFieldId]);
     }
     $table = JTable::getInstance("Document", "JUDownloadTable");
     if (!$table->bind($data) || !$table->check() || !$table->store()) {
         return array('doc_id' => 0, 'messages' => $table->getErrors());
     }
     $docId = $table->id;
     $categoriesField = new JUDownloadFieldCore_categories(null, $docId);
     $categoriesField->is_new_doc = $isInsert;
     $result = $categoriesField->storeValue($fieldsData[$this->field_name_id_array['cat_id']]);
     if (!$result) {
         $table->delete($docId);
         return array('doc_id' => 0, 'messages' => $db->getErrorMsg());
     }
     $query = $db->getQuery(true);
     $query->select("field.*");
     $query->from("#__judownload_fields AS field");
     $query->select("plg.folder");
     $query->join("", "#__judownload_plugins AS plg ON field.plugin_id = plg.id");
     $query->join("", "#__judownload_categories AS c ON (c.fieldgroup_id = field.group_id OR field.group_id = 1)");
     $query->join("", "#__judownload_documents_xref AS dxref ON (dxref.cat_id = c.id AND dxref.main = 1)");
     $query->join("", "#__judownload_documents AS d ON dxref.doc_id = d.id");
     $query->where("d.id = {$docId}");
     $query->where("field.field_name != 'id'");
     $query->where("field.field_name != 'cat_id'");
     $query->group('field.id');
     $query->order('ordering ASC');
     $db->setQuery($query);
     $fields = $db->loadObjectList();
     $docObj = JUDownloadHelper::getDocumentById($docId);
     foreach ($fields as $field) {
         if (isset($fieldsData[$field->id])) {
             $fieldObj = JUDownloadFrontHelperField::getField($field, $docObj);
             $fieldObj->fields_data = $fieldsData;
             $fieldValue = $fieldsData[$field->id];
             $fieldObj->is_new_doc = $isInsert;
             $fieldValue = $fieldObj->onImportDocument($fieldValue);
             $fieldObj->storeValue($fieldValue);
         }
     }
     if ($iconPath) {
         $iconPath = JUDownloadHelper::getPhysicalPath($iconPath);
         if (!$iconPath) {
             $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_FILE_S_NOT_FOUND', $iconPath);
         } else {
             if ($data['id'] > 0) {
                 if ($table->icon) {
                     if (JFile::exists($iconDir . $table->icon)) {
                         JFile::delete($iconDir . $table->icon);
                         JFile::delete($originalDir . $table->icon);
                     }
                 }
             }
             $iconName = basename($iconPath);
             $iconName = $docId . "_" . JUDownloadHelper::fileNameFilter($iconName);
             if (JFile::copy($iconPath, $originalDir . $iconName) && JUDownloadHelper::renderImages($originalDir . $iconName, $iconDir . $iconName, 'document_icon', true, null, $data['id'])) {
                 $table->icon = $iconName;
                 $table->store();
             }
         }
     }
     $imageTable = JTable::getInstance("Image", "JUDownloadTable");
     if (!empty($gallery)) {
         $dir_document_ori = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("document_original_image_directory", "media/com_judownload/images/gallery/original/") . $docId . "/";
         $dir_document_small = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("document_small_image_directory", "media/com_judownload/images/gallery/small/") . $docId . "/";
         $dir_document_big = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("document_big_image_directory", "media/com_judownload/images/gallery/big/") . $docId . "/";
         if (!JFolder::exists($dir_document_ori)) {
             $file_index = $dir_document_ori . 'index.html';
             $buffer = "<!DOCTYPE html><title></title>";
             JFile::write($file_index, $buffer);
         }
         if (!JFolder::exists($dir_document_small)) {
             $file_index = $dir_document_small . 'index.html';
             $buffer = "<!DOCTYPE html><title></title>";
             JFile::write($file_index, $buffer);
         }
         if (!JFolder::exists($dir_document_big)) {
             $file_index = $dir_document_big . 'index.html';
             $buffer = "<!DOCTYPE html><title></title>";
             JFile::write($file_index, $buffer);
         }
         $image_ordering = 1;
         $date = JFactory::getDate();
         foreach ($gallery as $imagePath) {
             $imagePath = JUDownloadHelper::getPhysicalPath($imagePath);
             if (!$imagePath) {
                 $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_FILE_S_NOT_FOUND', $imagePath);
                 continue;
             }
             $imageName = basename($imagePath);
             $imageName = JUDownloadHelper::generateImageNameByDocument($docId, $imageName);
             if (JFile::copy($imagePath, $dir_document_ori . $imageName) && JUDownloadHelper::renderImages($dir_document_ori . $imageName, $dir_document_small . $imageName, 'document_small', true, null, $data['id']) && JUDownloadHelper::renderImages($dir_document_ori . $imageName, $dir_document_big . $imageName, 'document_big', true, null, $data['id'])) {
                 $imageObj = new stdClass();
                 $imageObj->id = 0;
                 $imageObj->file_name = $imageName;
                 $imageObj->doc_id = $docId;
                 $imageObj->ordering = $image_ordering;
                 $imageObj->created = $date->toSql();
                 $imageObj->published = 1;
                 if (!$imageTable->bind($imageObj) || !$imageTable->check() || !$imageTable->store()) {
                     $messages[] = implode(' | ', $imageTable->getErrors());
                     JFile::delete($dir_document_ori . $imageName);
                     JFile::delete($dir_document_small . $imageName);
                     JFile::delete($dir_document_big . $imageName);
                 } else {
                     $image_ordering++;
                 }
             } else {
                 $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_CAN_NOT_COPY_FILE_FROM_S_TO_S', $imagePath, $dir_document_ori . $imageName);
             }
         }
     }
     $fileTable = JTable::getInstance("File", "JUDownloadTable");
     if (!empty($files)) {
         $file_directory = JPATH_SITE . "/" . JUDownloadFrontHelper::getDirectory("file_directory", "media/com_judownload/files/");
         if (!JFolder::exists($file_directory . $docId . "/")) {
             $file_index = $file_directory . $docId . "/index.html";
             $buffer = "<!DOCTYPE html><title></title>";
             JFile::write($file_index, $buffer);
         }
         $file_ordering = 1;
         foreach ($files as $filePath) {
             $filePath = JUDownloadHelper::getPhysicalPath($filePath);
             if (!$filePath) {
                 $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_FILE_S_NOT_FOUND', $filePath);
                 continue;
             }
             $query = $db->getQuery(true);
             $query->select('COUNT(*)')->from('#__judownload_files')->where('doc_id = ' . $docId)->where('`rename` = ' . $db->quote(basename($filePath)));
             $db->setQuery($query);
             $count = $db->loadResult();
             if ($count) {
                 $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_EXISTED_FILE_S', $filePath);
                 continue;
             }
             $fileObject = array();
             $fileObject['id'] = 0;
             $fileObject['doc_id'] = $docId;
             $fileObject['ordering'] = $file_ordering;
             $fileObject['rename'] = basename($filePath);
             $fileObject['file_name'] = md5($fileObject['rename'] . JUDownloadHelper::generateRandomString(10)) . "." . JFile::getExt($fileObject['rename']);
             $fileObject['published'] = 1;
             $this->addFileInfo($fileObject, $filePath, $file_directory);
             $dest = $file_directory . $docId . "/" . $fileObject['file_name'];
             if ($fileTable->bind($fileObject) && $fileTable->check() && $fileTable->store()) {
                 if (!JFile::copy($filePath, $dest)) {
                     $fileTable->delete($fileTable->id);
                     $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_CAN_NOT_COPY_FILE_FROM_S_TO_S', $filePath, $dest);
                 }
                 $file_ordering++;
             } else {
                 $messages[] = implode(' | ', $fileTable->getErrors());
             }
         }
     }
     if (!empty($relatedDocs)) {
         $ordering = 1;
         foreach ($relatedDocs as $relatedDocId) {
             $document = JUDownloadHelper::getDocumentById($relatedDocId);
             if ($document) {
                 $relatedDocObj = new stdClass();
                 $relatedDocObj->id = 0;
                 $relatedDocObj->doc_id = $docId;
                 $relatedDocObj->doc_id_related = $relatedDocId;
                 $relatedDocObj->ordering = $ordering;
                 $query = $db->getQuery(true);
                 $query->select('id')->from('#__judownload_documents_relations')->where('doc_id = ' . $docId)->where('doc_id_related = ' . $relatedDocId);
                 $db->setQuery($query);
                 $existedId = $db->loadResult();
                 if ($existedId) {
                     $relatedDocObj->id = $existedId;
                     $db->updateObject('#__judownload_documents_relations', $relatedDocObj, 'id');
                 } else {
                     $db->insertObject('#__judownload_documents_relations', $relatedDocObj);
                 }
                 $relationId = $db->insertid();
                 if ($relationId > 0) {
                     $ordering++;
                 } else {
                     $messages[] = $db->getErrorMsg();
                 }
             } else {
                 $messages[] = JText::sprintf('COM_JUDOWNLOAD_CSV_PROCESS_INVALID_RELATED_DOCUMENT_N', $relatedDocId);
             }
         }
     }
     return array('doc_id' => $docId, 'messages' => $messages);
 }
Exemplo n.º 17
0
							<?php 
                break;
            case "published":
                if ($item->main) {
                    echo JHtml::_('jgrid.published', $item->published, $i, 'documents.', $canChange, 'doc', $item->publish_up, $item->publish_down);
                } else {
                    echo JHtml::_('jgrid.published', $item->published, $i, 'documents.', false, 'doc', $item->publish_up, $item->publish_down);
                }
                break;
            case "featured":
                if ($item->main) {
                    echo JHtml::_('judownloadadministrator.featured', $item->featured, $i, $canChange, 'documents', 'doc');
                } else {
                    echo JHtml::_('judownloadadministrator.featured', $item->featured, $i, false);
                }
                break;
            default:
                $field = JUDownloadFrontHelperField::getField($field, $item->id);
                echo $field->getBackendOutput();
                break;
        }
        echo '</td>';
    }
    ?>
			</tr>
		<?php 
}
?>
		</tbody>
	</table>
</div>
Exemplo n.º 18
0
	public function redirectUrl()
	{
		$app     = JFactory::getApplication();
		$fieldId = $app->input->getInt('field_id');
		$docId   = $app->input->getInt('doc_id');

		$field = JUDownloadFrontHelperField::getField($fieldId, $docId);
		$field->redirectUrl();
	}
Exemplo n.º 19
0
 protected function getListQuery()
 {
     $cat_id = $this->state->get('list.cat_id');
     $listOrder = $this->state->get('list.ordering');
     $listDirn = $this->state->get('list.direction');
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     if ($this->fields) {
         $query->SELECT('d.*');
         $query->FROM('#__judownload_documents AS d');
         $query->SELECT('dxref.main');
         $query->JOIN("", "#__judownload_documents_xref AS dxref ON d.id = dxref.doc_id");
         $query->JOIN("", "#__judownload_categories AS c ON c.id = dxref.cat_id");
         $query->SELECT('ua3.name AS checked_out_name');
         $query->JOIN("LEFT", "#__users AS ua3 ON d.checked_out = ua3.id");
         $search = $this->state->get('filter.search');
         if (!empty($search)) {
             $search = '%' . $db->escape($search, true) . '%';
             $where = "(dxref.cat_id = {$cat_id} AND d.title LIKE '{$search}')";
         } else {
             $where = "dxref.cat_id = {$cat_id}";
         }
         $query->WHERE($where);
         $query->WHERE('d.approved > 0');
         JUDownloadFrontHelperField::appendFieldOrderingPriority($query, $cat_id, $listOrder, $listDirn);
         $query->group('d.id');
         return $query;
     }
     return null;
 }
Exemplo n.º 20
0
$app  = JFactory::getApplication();
$task = $app->input->get('task');

switch ($task)
{
	case 'captcha':
		$namespace = $app->input->getString('captcha_namespace', '');
		JUDownloadFrontHelperCaptcha::captchaSecurityImages($namespace);
		exit;
		break;

	case 'rawdata':
		$field_id = $app->input->getInt('field_id', 0);
		$doc_id   = $app->input->getInt('doc_id', 0);
		$fieldObj = JUDownloadFrontHelperField::getField($field_id, $doc_id);
		JUDownloadHelper::obCleanData();
		$fieldObj->getRawData();
		exit;
		break;

	case 'cron':
		
		JUDownloadFrontHelperMail::sendMailq();
		exit;
		break;

	default:
		$controller = JControllerLegacy::getInstance('judownload');

		
Exemplo n.º 21
0
}
?>

            <?php 
$extraFields = $this->model->getFieldsHaveFieldClass('extra');
$fieldGroups = array();
foreach ($extraFields as $field) {
    if (isset($fieldGroups[$field->group_id])) {
        $fieldGroups[$field->group_id][] = $field;
    } else {
        $fieldGroups[$field->group_id] = array($field);
    }
}
if (!empty($fieldGroups)) {
    foreach ($fieldGroups as $groupId => $fields) {
        $group = JUDownloadFrontHelperField::getFieldGroupById($groupId);
        echo JHtml::_('bootstrap.addTab', 'csv-export', "fieldgroup-{$group->id}", $group->name);
        ?>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th width="1%">
                            <input type="checkbox" id="<?php 
        echo $group->id;
        ?>
" sub-checkbox="group_<?php 
        echo $group->id;
        ?>
" class="field"
                                   title="<?php 
        echo JText::_('COM_JUDOWNLOAD_CHECK_ALL');
Exemplo n.º 22
0
	protected function _prepareData()
	{
		
		$this->token = JSession::getFormToken();

		
		$this->session = JFactory::getSession();

		
		$this->item->changelogs = JUDownloadFrontHelper::getChangeLogField($this->item->id);

		
		$this->item->versions = $this->model->getVersions($this->item->id);

		
		$this->item->related_documents = $this->model->getRelatedDocuments($this->item->id);
		if (count($this->item->related_documents))
		{
			foreach ($this->item->related_documents AS $documentRelated)
			{
				$documentRelated->link = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($documentRelated->id));
				$documentRelated->icon = JUDownloadHelper::getDocumentIcon($documentRelated->icon);
			}
		}

		
		$this->item->files               = JUDownloadFrontHelperDocument::getFilesByDocumentId($this->item->id);
		$this->can_download_document     = JUDownloadFrontHelperPermission::canDownloadDocument($this->item->id, false);
		$this->display_download_rule_msg = $this->params->get('show_rule_messages', 'modal');

		
		$additionFields = array();
		if (trim($this->item->external_link))
		{
			$additionFields[] = 'external_link';
		}

		if ($this->item->license_id && $this->item->confirm_license)
		{
			$additionFields[] = 'license_id';
			$additionFields[] = 'confirm_license';
		}

		$this->item->fieldGallery = JUDownloadFrontHelperField::getField('gallery', $this->item);
		$this->item->fields       = JUDownloadFrontHelperField::getFields($this->item, 2, array(), array('gallery'), $additionFields);

		
		$this->item->license = JUDownloadFrontHelper::getLicense($this->item->license_id);

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

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

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

		
		if ($this->item->is_subscriber)
		{
			$this->item->unsubscribe_link = $this->model->getUnsubscribeLink($this->item->id);
		}
		else
		{
			$this->item->subscribe_link = $this->model->getSubscribeLink($this->item->id);
		}

		$this->item->contact_link = JRoute::_(JUDownloadHelperRoute::getContactRoute($this->item->id));

		$this->item->report_link = JRoute::_(JUDownloadHelperRoute::getReportDocumentRoute($this->item->id));

		$this->item->print_link = JRoute::_(JUDownloadHelperRoute::getDocumentRoute($this->item->id) . '&layout=print&tmpl=component&print=1');

		
		$this->item->comment = new stdClass();
		
		$this->item->comment->total_comments_no_filter = $this->model->getTotalCommentsOfDocument($this->item->id);

		
		$this->root_comment = JUDownloadFrontHelperComment::getRootComment();

		
		$langArray   = JHtml::_('contentlanguage.existing');
		$JAll        = new JObject();
		$JAll->text  = JText::_('JALL');
		$JAll->value = '*';
		array_unshift($langArray, $JAll);
		$this->langArray = $langArray;

		
		$this->item->comment->items = $this->get('Items');
		foreach ($this->item->comment->items AS $comment)
		{
			if (JUDownloadFrontHelperPermission::canCheckInComment($comment->id))
			{
				$uri                    = JUri::getInstance();
				$comment->checkout_link = 'index.php?option=com_judownload&task=modcomments.checkin&cid=' . $comment->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri));
			}
			else
			{
				$comment->checkout_link = '';
			}
		}

		$this->item->comment->pagination = $this->get('Pagination');

		
		$this->item->comment->total_comments = $this->get('Total');

		
		$this->item->comment->parent_id = $this->root_comment->id;

		
		$this->website_field_in_comment_form = $this->params->get('website_field_in_comment_form', 0);
		$this->min_comment_characters        = $this->params->get('min_comment_characters', 20);
		$this->max_comment_characters        = $this->params->get('max_comment_characters', 1000);

		
		$this->allow_vote_comment      = $this->params->get('allow_vote_comment', 1);
		$this->allow_vote_down_comment = $this->params->get('allow_vote_down_comment', 1);

		
		$this->order_comment_name_array = $this->model->getCommentOrderingOptions();

		
		$this->order_comment_dir_array = array(
			'ASC'  => JText::_('COM_JUDOWNLOAD_ASC'),
			'DESC' => JText::_('COM_JUDOWNLOAD_DESC')
		);

		
		$this->total_stars          = $this->params->get('number_rating_stars', 5);
		$this->filter_comment_stars = array('' => JText::_('COM_JUDOWNLOAD_ANY_STAR'));
		for ($i = 0; $i <= $this->total_stars; $i++)
		{

			$score                              = ($i == 0) ? 0 : round((($i - 1) * 10) / $this->total_stars, 5) . ',' . round(($i * 10) / $this->total_stars, 5);
			$this->filter_comment_stars[$score] = JText::plural('COM_JUDOWNLOAD_N_STAR', $i);
		}

		
		if ($this->params->get('filter_comment_language', 0))
		{
			$this->list_lang_comment = $this->escape($this->state->get('list.lang'));
		}
		$this->list_order_comment  = $this->escape($this->state->get('list.ordering'));
		$this->list_dir_comment    = $this->escape($this->state->get('list.direction'));
		$this->filter_comment_star = $this->state->get('list.star_filter', '');

		
		$this->website  = $this->title = $this->email = $this->comment = $this->name = '';
		$this->language = '*';
		$form           = $this->session->get('judownload_commentform_' . $this->item->id, null);
		$this->form     = $form;
		if (!empty($form) && $form['parent_id'] == $this->root_comment->id)
		{
			$this->title    = $form['title'];
			$this->name     = $form['guest_name'];
			$this->email    = $form['guest_email'];
			$this->comment  = $form['comment'];
			$this->website  = (isset($form['website'])) ? $form['website'] : '';
			$this->language = $form['comment_language'];
		}
	}
Exemplo n.º 23
0
	public static function canEditStateDocument($documentObject)
	{
		if (!is_object($documentObject))
		{
			return false;
		}
		$documentId = $documentObject->id;

		if (!isset($documentObject->cat_id))
		{
			$documentObject = JUDownloadHelper::getDocumentById($documentId);
		}

		$mainCatId = $documentObject->cat_id;

		
		$userCanDoCategory = JUDownloadFrontHelperPermission::canDoCategory($mainCatId);
		if (!$userCanDoCategory)
		{
			return false;
		}

		if ($documentObject->id)
		{
			
			$isDocumentOwner = JUDownloadFrontHelperPermission::isDocumentOwner($documentObject->id);
			if ($isDocumentOwner)
			{
				$params                    = JUDownloadHelper::getParams($mainCatId);
				$ownerCanEditStateDocument = $params->get('document_owner_can_edit_state_document', 0);
				if ($ownerCanEditStateDocument)
				{
					return true;
				}
			}
		}

		
		$isModerator = JUDownloadFrontHelperModerator::isModerator();
		if ($isModerator)
		{
			$modCanEditState = JUDownloadFrontHelperModerator::checkModeratorCanDoWithDocument($mainCatId, 'document_edit_state');
			if ($modCanEditState)
			{
				return true;
			}

			if ($documentObject->id && $documentObject->approved <= 0)
			{
				$modCanApprove = JUDownloadFrontHelperModerator::checkModeratorCanDoWithDocument($mainCatId, 'document_approve');
				if ($modCanApprove)
				{
					return true;
				}
			}
		}

		
		$user = JFactory::getUser();
		if (!$user->get('guest'))
		{
			$corePublished = JUDownloadFrontHelperField::getField('published', $documentObject);
			if ($corePublished)
			{
				if ($documentObject->approved <= 0)
				{
					if ($corePublished->canSubmit())
					{
						return true;
					}
				}
				elseif ($documentObject->approved == 1)
				{
					if ($corePublished->canEdit())
					{
						return true;
					}
				}
			}
		}

		return false;
	}
Exemplo n.º 24
0
	protected function _prepareData()
	{
		
		$this->order_name_array = JUDownloadFrontHelperField::getFrontEndOrdering();
		$this->order_dir_array  = JUDownloadFrontHelperField::getFrontEndDirection();
		$this->document_order   = $this->escape($this->state->get('list.ordering'));
		$this->document_dir     = $this->escape($this->state->get('list.direction'));

		$this->document_columns = (int) $this->params->get('view_search_columns', 2);
		if (!is_numeric($this->document_columns) || ($this->document_columns <= 0))
		{
			$this->document_columns = 1;
		}
		$this->document_bootstrap_columns = JUDownloadFrontHelper::getBootstrapColumns($this->document_columns);
		$this->document_row_class         = htmlspecialchars($this->params->get('view_search_add_rows_class'));
		$this->document_column_class      = htmlspecialchars($this->params->get('view_search_add_columns_class'));

		
		$this->display_download_rule_msg     = $this->params->get('show_rule_messages', 'modal');
		$this->external_download_link_target = $this->params->get('external_download_link_target', '_blank');

		
		$this->allow_user_select_view_mode = $this->params->get('allow_user_select_view_mode', 1);

		if ($this->allow_user_select_view_mode && isset($_COOKIE['judl-view-mode']) && !empty($_COOKIE['judl-view-mode']))
		{
			$viewMode = $_COOKIE['judl-view-mode'] == 'judl-view-grid' ? 2 : 1;
		}
		else
		{
			$viewMode = $this->params->get('default_view_mode', 2);
		}

		$this->view_mode = $viewMode;
	}
Exemplo n.º 25
0
	public static function getDocumentDisplayParams($doc_id)
	{
		if (!$doc_id)
		{
			return null;
		}

		$storeId = md5(__METHOD__ . "::$doc_id");
		if (!isset(self::$cache[$storeId]))
		{
			$params                         = JUDownloadHelper::getParams(null, $doc_id);
			$global_display_params          = $params->get('display_params');
			$global_document_display_object = isset($global_display_params->doc) ? $global_display_params->doc : array();
			$global_document_display_params = new JRegistry($global_document_display_object);

			$docObj          = JUDownloadHelper::getDocumentById($doc_id);
			$document_params = $docObj->params;
			if ($document_params)
			{
				$document_params         = json_decode($document_params);
				$document_display_params = $document_params->display_params;

				if ($document_display_params)
				{
					$global_document_display_params = JUDownloadFrontHelperField::mergeFieldOptions($global_document_display_params->toObject(), $document_display_params);
					unset($document_display_params->fields);

					foreach ($document_display_params AS $option => $value)
					{
						if ($value == '-2')
						{
							unset($document_display_params->$option);
						}
					}

					$global_document_display_params->loadObject($document_display_params);
				}
			}

			self::$cache[$storeId] = $global_document_display_params;
		}

		return self::$cache[$storeId];
	}
Exemplo n.º 26
0
	public function build(&$query)
	{
		$segments = array();

		
		$app   = JFactory::getApplication('site');
		$menus = $app->getMenu('site');
		
		$activeMenu = $menus->getActive();
		$params     = JUDownloadHelper::getParams();
		$homeItemId = JUDownloadHelperRoute::getHomeMenuItemId();

		
		if (empty($query['Itemid']) && isset($query['view']) && $query['view'] != 'category' && $query['view'] != 'document')
		{
			$query['Itemid'] = JUDownloadHelperRoute::findJUDownloadTreeItemId();
		}

		if (isset($query['view']))
		{
			$menuItem = $menus->getItem($query['Itemid']);

			
			if (isset($menuItem) && ($menuItem->component != 'com_judownload' && $menuItem->id != $homeItemId))
			{
				unset($query['Itemid']);
			}
		}

		if (!$query || (!isset($query['view']) && !isset($query['task'])))
		{
			
			if (isset($query['start']))
			{
				$sefPageConfig = JApplication::stringURLSafe('page');
				$pageX         = JUDownloadHelperRoute::getPage($query['start'], $activeMenu->query['view']);
				$segments[]    = $sefPageConfig . ':' . $pageX;

				unset($query['start']);
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			$total = count($segments);

			for ($i = 0; $i < $total; $i++)
			{
				$segments[$i] = str_replace(':', '-', $segments[$i]);
			}

			if (isset($query['limit']))
			{
				unset($query['limit']);
			}

			
			return $segments;
		}

		$hasActiveMenu = false;
		if (is_object($activeMenu) && isset($activeMenu->query))
		{
			if (isset($query['Itemid']) && ($query['Itemid'] == $activeMenu->id))
			{
				$hasActiveMenu = JUDownloadHelperRoute::compareQuery($activeMenu, $query);
			}
		}

		

		
		if (isset($query['view']) && $query['view'] == 'categories')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['id']))
				{
					if (isset($query['Itemid']))
					{
						if ($query['Itemid'] == $homeItemId)
						{
							
							$sefRootCategory = JApplication::stringURLSafe('root');
							$segments[]      = JApplication::stringURLSafe($sefRootCategory);
						}
					}

					
					$sefCategoriesConfig = JApplication::stringURLSafe('categories');
					$segments[]          = JApplication::stringURLSafe($sefCategoriesConfig);

					$categoryObject = JUDownloadHelper::getCategoryById($query['id']);

					$segments[] = $query['id'] . ":" . (isset($categoryObject->alias) ? $categoryObject->alias : '');

					unset($query['id']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'category')
		{
			if (!$hasActiveMenu)
			{
				$fullPathCategory = $params->get('sef_category_full_path', 0);
				if (isset($query['id']))
				{
					$segments = JUDownloadHelperRoute::getCategorySegment($query['id'], $query, $fullPathCategory);
					if ($segments !== false)
					{
						unset($query['id']);
					}
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'advsearch')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('advanced-search');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'collection')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']) && $query['id'])
				{
					if (isset($query['user_id']))
					{
						$user       = JFactory::getUser($query['user_id']);
						$userAlias  = JApplication::stringURLSafe($user->username);
						$segments[] = $query['user_id'] . ':' . $userAlias;
						unset($query['user_id']);
					}

					$segments[] = JApplication::stringURLSafe('collection');

					$collectionObject = JUDownloadFrontHelper::getCollectionById($query['id']);

					$segments[] = $query['id'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
					unset($query['id']);

					JUDownloadHelperRoute::seoLayout($query, $segments, $params);
				}
				else
				{
					$segments[] = JApplication::stringURLSafe('collection');

					$segments[] = JApplication::stringURLSafe('new-collection');

					JUDownloadHelperRoute::seoLayout($query, $segments, $params);

					if (isset($query['id']))
					{
						unset($query['id']);
					}
				}
			}
			else
			{
				if (isset($query['user_id']))
				{
					unset($query['user_id']);
				}

				if (isset($query['id']))
				{
					unset($query['id']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'collections')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']))
				{
					$user       = JFactory::getUser($query['id']);
					$userAlias  = JApplication::stringURLSafe($user->username);
					$segments[] = $query['id'] . ':' . $userAlias;
					unset($query['id']);
				}

				$segments[] = JApplication::stringURLSafe('collections');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'commenttree' && isset($query['id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('comment-tree');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['id'] . ':' . $commentAlias;

			if (isset($query['tmpl']))
			{
				$segments[] = JApplication::stringURLSafe('component');
				unset($query['tmpl']);
			}

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'contact' && isset($query['doc_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('contact');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['doc_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'dashboard')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			if (isset($query['id']))
			{
				$user       = JFactory::getUser($query['id']);
				$userAlias  = JApplication::stringURLSafe($user->username);
				$segments[] = $query['id'] . ':' . $userAlias;
				unset($query['id']);
			}

			$segments[] = JApplication::stringURLSafe('dashboard');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'document')
		{
			if (!$hasActiveMenu)
			{
				$seoLayout = true;
				if (isset($query['id']))
				{
					$segments = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
					unset($query['id']);
				}

				if (isset($query['print']))
				{
					$seoLayout  = false;
					$segments[] = JApplication::stringURLSafe('print');
					unset($query['print']);
					unset($query['layout']);
					unset($query['tmpl']);
				}

				if (isset($query['layout']) && $query['layout'] == 'changelogs')
				{
					$seoLayout  = false;
					$segments[] = JApplication::stringURLSafe('changelogs');
					unset($query['layout']);
				}

				if (isset($query['layout']) && $query['layout'] == 'versions')
				{
					$seoLayout  = false;
					$segments[] = JApplication::stringURLSafe('versions');
					unset($query['layout']);
				}

				if ($seoLayout)
				{
					JUDownloadHelperRoute::seoLayout($query, $segments, $params);
				}
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'documents')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('modal-documents');

			if (isset($query['tmpl']))
			{
				$segments[] = $query['tmpl'];
				unset($query['tmpl']);
			}

			if (isset($query['function']))
			{
				$segments[] = $query['function'];
				unset($query['function']);
			}

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		

		
		if (isset($query['view']) && $query['view'] == 'downloaderror')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('error-download');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			if (isset($query['return']))
			{
				$segments[] = $query['return'];
				unset($query['return']);
			}

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'featured')
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = JApplication::stringURLSafe('root');
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuFeatured = $menus->getItem($query['Itemid']);
						if ($assignMenuFeatured && isset($assignMenuFeatured->query) && $assignMenuFeatured->query['view'] == 'tree'
							&& isset($assignMenuFeatured->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuFeatured->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				$segments[] = JApplication::stringURLSafe('featured');

				if (isset($query['all']))
				{
					if ($query['all'] == 1)
					{
						$segments[] = JApplication::stringURLSafe('all');
					}
					unset($query['all']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['all']))
				{
					unset($query['all']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'form' && isset($query['layout']) && $query['layout'] == 'edit' && (!isset($query['id']) || (isset($query['id']) && !$query['id'])))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			if (isset($query['cat_id']))
			{
				$categoryObject = JUDownloadHelper::getCategoryById($query['cat_id']);
				$segments[]     = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
				unset($query['cat_id']);
			}
			else
			{
				$categoryRoot = JUDownloadFrontHelperCategory::getRootCategory();
				if (is_object($categoryRoot))
				{
					$segments[] = $categoryRoot->id . ':' . (isset($categoryRoot->alias) ? $categoryRoot->alias : '');
				}
			}

			$segments[] = JApplication::stringURLSafe('new-document');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'form' && isset($query['layout']) && $query['layout'] == 'edit' && isset($query['id']) && $query['id'])
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			if (isset($query['approve']) && $query['approve'] == 1)
			{
				$segments[] = JApplication::stringURLSafe('approve');
				unset($query['approve']);
			}

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'license' && isset($query['id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('license');

			$licenseObject = JUDownloadFrontHelper::getLicense($query['id']);

			$segments[] = $query['id'] . ':' . (isset($licenseObject->alias) ? $licenseObject->alias : '');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'listall')
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = JApplication::stringURLSafe('root');
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								unset($query['id']);
							}
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuListAll = $menus->getItem($query['Itemid']);
						if ($assignMenuListAll && isset($assignMenuListAll->query) && $assignMenuListAll->query['view'] == 'tree'
							&& isset($assignMenuListAll->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuListAll->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				$segments[] = JApplication::stringURLSafe('list-all');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'listalpha')
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = JApplication::stringURLSafe('root');
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuListAlpha = $menus->getItem($query['Itemid']);
						if ($assignMenuListAlpha && isset($assignMenuListAlpha->query) && $assignMenuListAlpha->query['view'] == 'tree'
							&& isset($assignMenuListAlpha->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuListAlpha->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				$segments[] = JApplication::stringURLSafe('list-alpha');

				if (isset($query['alpha']))
				{
					$segments[] = $query['alpha'];
					unset($query['alpha']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['alpha']))
				{
					unset($query['alpha']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			if (isset($query['format']))
			{
				$segments[] = JApplication::stringURLSafe('rss');
				unset($query['format']);
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'maintenance')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('maintenance');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modcomment' && isset($query['layout']) && $query['layout'] == 'edit' && isset($query['id']) && $query['id'])
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('mod-comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);
			if (is_object($commentObject))
			{
				$commentAlias = JApplication::stringURLSafe($commentObject->title);
				$segments[]   = $query['id'] . ':' . $commentAlias;
				unset($query['id']);
			}

			if (isset($query['approve']) && $query['approve'])
			{
				$segments[] = JApplication::stringURLSafe('approve');
				unset($query['approve']);
			}

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
			unset($query['layout']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modcomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'moddocuments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = JApplication::stringURLSafe('root');
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-documents');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpermission' && isset($query['id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = JApplication::stringURLSafe('root');
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('mod-permission');
			$segments[] = $query['id'];

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpermissions')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('mod-permissions');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpendingcomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-pending-comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'modpendingdocuments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('mod-pending-documents');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'profile')
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[] = JApplication::stringURLSafe('profile');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'report' && isset($query['doc_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('report');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['doc_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'report' && isset($query['comment_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments[]    = JApplication::stringURLSafe('comment');
			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['comment_id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['comment_id'] . ':' . $commentAlias;
			unset($query['comment_id']);

			$segments[] = JApplication::stringURLSafe('report');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['comment_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'search')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['cat_id']))
				{
					$categoryObject = JUDownloadHelper::getCategoryById($query['cat_id']);
					$segments[]     = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
					unset($query['cat_id']);
				}

				if (isset($query['sub_cat']))
				{
					$segments[] = JApplication::stringURLSafe('all');
					unset($query['sub_cat']);
				}

				$segments[] = JApplication::stringURLSafe('search');

				if (isset($query['searchword']))
				{
					$segments[] = $query['searchword'];
					unset($query['searchword']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['cat_id']))
				{
					unset($query['cat_id']);
				}

				if (isset($query['searchword']))
				{
					unset($query['searchword']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'searchby')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('search-by');

				if (isset($query['field_id']))
				{
					$fieldObject = JUDownloadFrontHelperField::getFieldById($query['field_id']);
					$segments[]  = $query['field_id'] . ':' . (isset($fieldObject->alias) ? $fieldObject->alias : '');
					unset($query['field_id']);
				}

				if (isset($query['value']))
				{
					$segments[] = $query['value'];
					unset($query['value']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['field_id']))
				{
					unset($query['field_id']);
				}

				if (isset($query['value']))
				{
					unset($query['value']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'subscribe' && isset($query['doc_id']))
		{
			if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
			{
				
				$sefRootCategory = 'root';
				$segments[]      = JApplication::stringURLSafe($sefRootCategory);
			}

			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('guest-subscribe');

			JUDownloadHelperRoute::seoLayout($query, $segments, $params);

			unset($query['doc_id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'tag' && isset($query['id']))
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('tag');

				$tagObject = JUDownloadFrontHelper::getTagById($query['id']);

				$segments[] = $query['id'] . ':' . (isset($tagObject->alias) ? $tagObject->alias : '');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'tags')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('tags');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'topcomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$segments[] = JApplication::stringURLSafe('top-comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'topdocuments')
		{
			$addCategoryToSegment = true;
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = 'root';
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuTopDocuments = $menus->getItem($query['Itemid']);
						if ($assignMenuTopDocuments && isset($assignMenuTopDocuments->query) && $assignMenuTopDocuments->query['view'] == 'tree'
							&& isset($assignMenuTopDocuments->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuTopDocuments->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
						unset($query['id']);
					}
				}

				if (isset($query['ordertype']))
				{
					switch ($query['ordertype'])
					{
						case 'new' :
							$segments[] = JApplication::stringURLSafe('latest-documents');
							break;
						case 'featured' :
							$segments[] = JApplication::stringURLSafe('top-featured-documents');
							break;
						case 'recent_modified' :
							$segments[] = JApplication::stringURLSafe('recent-modified-documents');
							break;
						case 'recent_updated' :
							$segments[] = JApplication::stringURLSafe('recent-updated-documents');
							break;
						case 'popular' :
							$segments[] = JApplication::stringURLSafe('popular-documents');
							break;
						case 'most_downloaded' :
							$segments[] = JApplication::stringURLSafe('most-downloaded-documents');
							break;
						case 'most_rated' :
							$segments[] = JApplication::stringURLSafe('most-rated-documents');
							break;
						case 'top_rated' :
							$segments[] = JApplication::stringURLSafe('top-rated-documents');
							break;
						case 'latest_rated' :
							$segments[] = JApplication::stringURLSafe('latest-rated-documents');
							break;
						case 'most_commented' :
							$segments[] = JApplication::stringURLSafe('most-commented-documents');
							break;
						case 'latest_commented' :
							$segments[] = JApplication::stringURLSafe('latest-commented-documents');
							break;
						case 'recently_viewed' :
							$segments[] = JApplication::stringURLSafe('recent-viewed-documents');
							break;
						case 'alpha_ordered' :
							$segments[] = JApplication::stringURLSafe('alpha-ordered-documents');
							break;
						case 'random' :
							$segments[] = JApplication::stringURLSafe('random-documents');
							break;
						case 'random_fast' :
							$segments[] = JApplication::stringURLSafe('random-fast-documents');
							break;
						case 'random_featured' :
							$segments[] = JApplication::stringURLSafe('random-featured-documents');
							break;
						default:
							$segments[] = JApplication::stringURLSafe('latest-documents');
					}
					unset($query['ordertype']);
				}

				if (isset($query['all']))
				{
					if ($query['all'] == 1)
					{
						$segments[] = JApplication::stringURLSafe('all');
					}

					unset($query['all']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['ordertype']))
				{
					unset($query['ordertype']);
				}

				if (isset($query['all']))
				{
					unset($query['all']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'tree' && isset($query['id']))
		{
			if (!$hasActiveMenu)
			{
				$addCategoryToSegment = true;
				if (isset($query['Itemid']))
				{
					if ($query['Itemid'] == $homeItemId)
					{
						
						$sefRootCategory = 'root';
						$segments[]      = JApplication::stringURLSafe($sefRootCategory);

						if (isset($query['id']))
						{
							$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
							if ($categoryObject->level > 0)
							{
								$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
							}
							unset($query['id']);
						}

						$addCategoryToSegment = false;
					}
					else
					{
						$assignMenuTree = $menus->getItem($query['Itemid']);
						if ($assignMenuTree && isset($assignMenuTree->query) && $assignMenuTree->query['view'] == 'tree'
							&& isset($assignMenuTree->query['id'])
						)
						{
							if (isset($query['id']))
							{
								$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
								if ($assignMenuTree->query['id'] != $categoryObject->id)
								{
									$segments[] = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
								}
								unset($query['id']);
							}

							$addCategoryToSegment = false;
						}
					}
				}

				$segments[] = 'tree';

				if ($addCategoryToSegment)
				{
					if (isset($query['id']))
					{
						$categoryObject = JUDownloadHelper::getCategoryById($query['id']);
						$segments[]     = $query['id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
					}
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['id']);
			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'usercomments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']))
				{
					$user       = JFactory::getUser($query['id']);
					$userAlias  = JApplication::stringURLSafe($user->username);
					$segments[] = $query['id'] . ':' . $userAlias;
					unset($query['id']);
				}
				$segments[] = JApplication::stringURLSafe('comments');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}
				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'userdocuments')
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				if (isset($query['id']))
				{
					$user       = JFactory::getUser($query['id']);
					$userAlias  = JApplication::stringURLSafe($user->username);
					$segments[] = $query['id'] . ':' . $userAlias;
					unset($query['id']);
				}

				$segments[] = JApplication::stringURLSafe('documents');

				if (isset($query['filter']))
				{
					if ($query['filter'] == 'pending')
					{
						$segments[] = JApplication::stringURLSafe('pending');
					}
					elseif ($query['filter'] == 'unpublished')
					{
						$segments[] = JApplication::stringURLSafe('unpublished');
					}
					else
					{
						$segments[] = JApplication::stringURLSafe('published');
					}
					unset($query['filter']);
				}

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if (isset($query['id']))
				{
					unset($query['id']);
				}

				if (isset($query['filter']))
				{
					unset($query['filter']);
				}

				if (isset($query['layout']))
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoFormat($query, $params, $segments);

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['view']);
		}

		
		if (isset($query['view']) && $query['view'] == 'usersubscriptions' && isset($query['id']))
		{
			if (!$hasActiveMenu)
			{
				if (isset($query['Itemid']) && $query['Itemid'] == $homeItemId)
				{
					
					$sefRootCategory = 'root';
					$segments[]      = JApplication::stringURLSafe($sefRootCategory);
				}

				$user       = JFactory::getUser($query['id']);
				$userAlias  = JApplication::stringURLSafe($user->username);
				$segments[] = $query['id'] . ':' . $userAlias;
				$segments[] = JApplication::stringURLSafe('user-subscriptions');

				JUDownloadHelperRoute::seoLayout($query, $segments, $params);
			}
			else
			{
				if ($query['layout'])
				{
					unset($query['layout']);
				}
			}

			JUDownloadHelperRoute::seoPagination($query, $params, $segments);

			unset($query['id']);
			unset($query['view']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'form.add')
		{
			if (isset($query['cat_id']))
			{
				$categoryObject = JUDownloadHelper::getCategoryById($query['cat_id']);
				if (is_object($categoryObject))
				{
					$segments[] = $query['cat_id'] . ':' . (isset($categoryObject->alias) ? $categoryObject->alias : '');
					unset($query['cat_id']);
				}
			}

			$segments[] = JApplication::stringURLSafe('add');
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'form.edit' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('edit');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'forms.delete' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('delete');

			unset($query['id']);
			unset($query['task']);
		}

		if (isset($query['task']) && $query['task'] == 'forms.checkin' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('checkin');

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'modpendingdocument.edit' && isset($query['id']))
		{
			$segments = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);

			if (isset($query['approve']))
			{
				$segments[] = JApplication::stringURLSafe('approve');
				unset($query['approve']);
			}

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'forms.unpublish' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('unpublish');

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'forms.publish' && isset($query['id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('publish');

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.save' && isset($query['doc_id']) && !isset($query['comment_id']))
		{
			$segments   = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
			$segments[] = JApplication::stringURLSafe('subscribe');

			unset($query['doc_id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'download.download' && isset($query['doc_id']))
		{
			$segments = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);

			if (isset($query['version']))
			{
				$segments[] = $query['version'];
				unset($query['version']);
			}
			else
			{
				$segments[] = JApplication::stringURLSafe('latest');
			}

			$segments[] = JApplication::stringURLSafe('download');

			unset($query['doc_id']);
			unset($query['task']);
		}

		if (isset($query['task']) && $query['task'] == 'download.download' && isset($query['file_id']))
		{
			$segments[] = JApplication::stringURLSafe('file');
			$fileObject = JUDownloadFrontHelper::getFileObject($query['file_id']);
			$fileAlias  = JApplication::stringURLSafe($fileObject->rename);
			$segments[] = $query['file_id'] . ':' . $fileAlias;

			if (isset($query['version']))
			{
				$segments[] = $query['version'];
				unset($query['version']);
			}
			else
			{
				$segments[] = JApplication::stringURLSafe('latest');
			}

			$segments[] = JApplication::stringURLSafe('download');

			unset($query['file_id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'document.redirecturl')
		{
			if (isset($query['doc_id']))
			{
				$segments = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
				unset($query['doc_id']);
			}

			if (isset($query['field_id']))
			{
				$fieldObject = JUDownloadFrontHelperField::getFieldById($query['field_id']);
				$segments[]  = $query['field_id'] . ':' . (isset($fieldObject->alias) ? $fieldObject->alias : '');
				unset($query['field_id']);
			}

			$segments[] = JApplication::stringURLSafe('redirect-url');

			unset($query['task']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'modcomment.edit' && isset($query['id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['id'] . ':' . $commentAlias;
			unset($query['id']);

			$segments[] = JApplication::stringURLSafe('edit');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'modpendingcomment.edit' && isset($query['id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['id'] . ':' . $commentAlias;
			unset($query['id']);

			$segments[] = JApplication::stringURLSafe('approve');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.save' && isset($query['comment_id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['comment_id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['comment_id'] . ':' . $commentAlias;
			unset($query['comment_id']);

			$segments[] = JApplication::stringURLSafe('subscribe');
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.remove' && isset($query['sub_id']))
		{
			$subscriptionObject = JUDownloadFrontHelper::getSubscriptionObject($query['sub_id']);
			if ($subscriptionObject->type == 'document')
			{
				$segments = JUDownloadHelperRoute::getDocumentSegment($subscriptionObject->item_id, $query, $params);

				$segments[] = JApplication::stringURLSafe('unsubscribe');

				$segments[] = $query['sub_id'];

				if ($query['code'])
				{
					$segments[] = $query['code'];
					unset($query['code']);
				}

				unset($query['doc_id']);
				unset($query['task']);

				unset($query['sub_id']);
				unset($query['task']);
			}
			elseif ($subscriptionObject->type == 'comment')
			{
				$segments[] = JApplication::stringURLSafe('comment');

				$commentObject = JUDownloadFrontHelperComment::getCommentObject($subscriptionObject->item_id);
				if (is_object($commentObject))
				{
					$commentAlias = JApplication::stringURLSafe($commentObject->title);
					$segments[]   = $commentObject->id . ':' . $commentAlias;
				}

				$segments[] = JApplication::stringURLSafe('unsubscribe');

				$segments[] = $query['sub_id'];

				if ($query['code'])
				{
					$segments[] = $query['code'];
					unset($query['code']);
				}

				unset($query['sub_id']);
				unset($query['task']);
			}
		}

		
		if (isset($query['task']) && $query['task'] == 'document.deleteComment' && isset($query['comment_id']))
		{
			$segments[] = JApplication::stringURLSafe('comment');

			$commentObject = JUDownloadFrontHelperComment::getCommentObject($query['comment_id']);

			$commentAlias = JApplication::stringURLSafe($commentObject->title);
			$segments[]   = $query['comment_id'] . ':' . $commentAlias;
			unset($query['comment_id']);

			$segments[] = JApplication::stringURLSafe('delete');
			unset($query['task']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'collection.add')
		{
			$segments[] = JApplication::stringURLSafe('collection');
			$segments[] = JApplication::stringURLSafe('add');

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'collection.edit' && isset($query['id']))
		{
			if (isset($query['user_id']))
			{
				$user       = JFactory::getUser($query['user_id']);
				$userAlias  = JApplication::stringURLSafe($user->username);
				$segments[] = $query['user_id'] . ':' . $userAlias;
				unset($query['user_id']);
			}

			$segments[] = JApplication::stringURLSafe('collection');

			$collectionObject = JUDownloadFrontHelper::getCollectionById($query['id']);

			$segments[] = $query['id'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
			unset($query['id']);

			$segments[] = JApplication::stringURLSafe('edit');

			if (isset($query['layout']))
			{
				unset($query['layout']);
			}

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'collections.delete' && isset($query['cid']))
		{
			$segments[] = JApplication::stringURLSafe('collection');

			$collectionObject = JUDownloadFrontHelper::getCollectionById($query['cid']);

			$segments[] = $query['cid'] . ':' . (isset($collectionObject->alias) ? $collectionObject->alias : '');
			unset($query['cid']);

			$segments[] = JApplication::stringURLSafe('delete');

			unset($query['task']);
		}

		

		
		if (isset($query['task']) && $query['task'] == 'usersubscriptions.unsubscribe' && isset($query['sub_id']))
		{
			$segments[] = JApplication::stringURLSafe('user-subscriptions');
			$segments[] = $query['sub_id'];
			$segments[] = JApplication::stringURLSafe('unsubscribe');

			unset($query['sub_id']);
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'rawdata')
		{
			if (isset($query['doc_id']))
			{
				$segments = JUDownloadHelperRoute::getDocumentSegment($query['doc_id'], $query, $params);
				unset($query['doc_id']);
			}

			if (isset($query['field_id']))
			{
				$fieldObject = JUDownloadFrontHelperField::getFieldById($query['field_id']);

				$segments[] = $query['field_id'] . ':' . (isset($fieldObject->alias) ? $fieldObject->alias : '');
				unset($query['field_id']);
			}

			$segments[] = JApplication::stringURLSafe('raw-data');
			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'subscribe.activate')
		{
			$segments[] = JApplication::stringURLSafe('activate-subscription');

			if ($query['id'])
			{
				$segments[] = $query['id'];
			}

			if (isset($query['code']))
			{
				$segments[] = $query['code'];
			}

			unset($query['task']);
		}

		
		if (isset($query['task']) && $query['task'] == 'email.downloadattachment')
		{
			$segments[] = JApplication::stringURLSafe('email');
			$segments[] = JApplication::stringURLSafe('download-attachment');

			if (isset($query['mail_id']))
			{
				$segments[] = $query['mail_id'];
				unset($query['mail_id']);
			}

			if (isset($query['file']))
			{
				$segments[] = $query['file'];
				unset($query['file']);
			}

			if (isset($query['code']))
			{
				$segments[] = $query['code'];
				unset($query['code']);
			}

			unset($query['task']);
		}

		$total = count($segments);

		for ($i = 0; $i < $total; $i++)
		{
			$segments[$i] = str_replace(':', '-', $segments[$i]);
		}

		if (isset($query['limit']))
		{
			unset($query['limit']);
		}

		return $segments;
	}
Exemplo n.º 27
0
	protected function getListQuery()
	{
		$tagId     = (int) $this->getState('tag.id');
		$ordering  = $this->getState('list.ordering', '');
		$direction = $this->getState('list.direction', 'ASC');

		$user      = JFactory::getUser();
		$levels    = $user->getAuthorisedViewLevels();
		$levelsStr = implode(',', $levels);

		$db       = JFactory::getDbo();
		$nullDate = $db->getNullDate();
		$nowDate  = JFactory::getDate()->toSql();

		
		$query = $db->getQuery(true);
		$query->select('d.*');
		$query->from('#__judownload_documents AS d');

		JUDownloadFrontHelper::optimizeListDocumentQuery($query);

		
		$query->join('', '#__judownload_tags_xref AS txref ON txref.doc_id = d.id');

		
		$query->where('d.approved = 1');

		
		$query->where('d.published = 1');
		$query->where('(d.publish_up = ' . $db->quote($nullDate) . ' OR d.publish_up <= ' . $db->quote($nowDate) . ')');
		$query->where('(d.publish_down = ' . $db->quote($nullDate) . ' OR d.publish_down >= ' . $db->quote($nowDate) . ')');

		
		if ($user->get('guest'))
		{
			$query->where('d.access IN (' . $levelsStr . ')');
		}
		else
		{
			$query->where('(d.access IN (' . $levelsStr . ') OR (d.created_by = ' . $user->id . '))');
		}

		
		$query->where('txref.tag_id=' . $tagId);

		
		$app         = JFactory::getApplication();
		$languageTag = JFactory::getLanguage()->getTag();
		if ($app->getLanguageFilter())
		{
			$query->where('d.language IN (' . $db->quote($languageTag) . ',' . $db->quote('*') . ',' . $db->quote('') . ')');
		}

		JUDownloadFrontHelperField::appendFieldOrderingPriority($query, null, $ordering, $direction);

		return $query;
	}
Exemplo n.º 28
0
					<p class="text-center"><?php echo JText::_("COM_JUDOWNLOAD_FIELD_CREATED"); ?></p>
				</th>
				<th class="center">
					<p class="text-center"><?php echo JText::_("COM_JUDOWNLOAD_REMOVE"); ?></p>
				</th>
			</tr>
			</thead>

			<tbody id="table-collection-items-tbody">
			<?php
			if (count($this->items))
			{
				$i = 0;
				foreach ($this->items AS $item)
				{
					$specialFields = JUDownloadFrontHelperField::getFields($item, null, array("description", "created", "title", "cat_id", "icon"));
					?>
					<tr id="coll-item-row-<?php echo $i; ?>">
						<td>
							<?php
							$iconField = $specialFields['icon'];
							if (isset($iconField) && $iconField->canView())
							{
								?>
								<div class="collection-item-icon">
									<?php echo $iconField->getOutput(array('view' => "list")); ?>
								</div>
							<?php
							}
							?>
							<?php
Exemplo n.º 29
0
}

// Get all list view fields, also add 'external_link', 'license_id', 'confirm_license'
$additionFields = array();
if (trim($this->item->external_link))
{
	$additionFields[] = 'external_link';
}

if ($this->item->license_id && $this->item->confirm_license)
{
	$additionFields[] = 'license_id';
	$additionFields[] = 'confirm_license';
}

$specialFields = JUDownloadFrontHelperField::getFields($this->item, null, array("created", "title", "version", "featured", "downloads"), array(), $additionFields);
?>

<tr class="<?php echo $item_class; ?>">
<?php
if ($this->params->get('allow_zip_file', 1) && $this->params->get('allow_download_multi_docs', 0))
{ ?>
	<td class="id">
		<?php
		if ($this->item->total_files > 0 || (isset($specialFields['external_link']) && !empty($specialFields['external_link'])))
		{
			$canDownloadDocument = JUDownloadFrontHelperPermission::canDownloadDocument($this->item->id, false);
			if (!$canDownloadDocument)
			{ ?>
				<input type="checkbox" name="doc_id[]" class="judl-cb-disabled" disabled
				       value="<?php echo $this->item->id; ?>" id="cb<?php echo $this->index; ?>"/>