Esempio n. 1
0
	public static function loadLanguageForTopLevelCat()
	{
		$app  = JFactory::getApplication();
		$view = $app->input->getString('view', '');
		$id   = $app->input->getInt('id', 0);

		if (isset($view))
		{
			switch ($view)
			{
				case 'category':
					$topLevelCats = JUDownloadHelper::getCatsByLevel(1, $id);
					break;

				case 'document':
					$catId        = JUDownloadFrontHelperCategory::getMainCategoryId($id);
					$topLevelCats = JUDownloadHelper::getCatsByLevel(1, $catId);
					break;
			}

			if (!empty($topLevelCats))
			{
				$topLevelCat = $topLevelCats[0];
				if ($view == 'category' || $view == 'document')
				{
					JUDownloadFrontHelperLanguage::loadLanguageFile('com_judownload_' . $topLevelCat->id, JPATH_SITE);
				}
			}
		}

		return;
	}
    public function getInput()
    {
        $categories = JUDownloadHelper::getCatsByLevel(1);
        $rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
        $document = JFactory::getDocument();
        $script = 'jQuery(document).ready(function($){
			$("#cat-' . $rootCategory->id . '").change(function(){
				if($(this).is(":checked")){
					$(this).parent().parent().find(".category-checkbox").attr("disabled", true).prop("checked", true);
				}else{
					$(this).parent().parent().find(".category-checkbox").attr("disabled", false).prop("checked", false);
				}
			});
		});';
        $document->addScriptDeclaration($script);
        $relCatIds = array();
        if ($this->form->getValue('id')) {
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
            $query->select('c.id');
            $query->from('#__judownload_categories AS c');
            $query->join('', '#__judownload_emails_xref AS exref ON (exref.cat_id = c.id)');
            $query->join('', '#__judownload_emails AS e ON (exref.email_id = e.id)');
            $query->where('exref.email_id = ' . $this->form->getValue('id'));
            $db->setQuery($query);
            $relCatIds = $db->loadColumn();
        }
        $html = '<div id="categoriestoassignemail" class="categoriestoassignemail">';
        $html .= '<ul id="' . $this->id . '" class="nav">';
        $html .= '<li>';
        $html .= '<input id="cat-' . $rootCategory->id . '" name="' . $this->name . '[]"  value = "' . $rootCategory->id . '" ' . (in_array($rootCategory->id, $relCatIds) ? 'checked="checked"' : '') . ' class="input" type="checkbox" />';
        $html .= '<label for="cat-' . $rootCategory->id . '">' . str_repeat('<span class="gi">|—</span>', $rootCategory->level) . $rootCategory->title . '</label>';
        $html .= '</li>';
        if ($categories) {
            foreach ($categories as $category) {
                $html .= '<li>';
                $attr = '';
                if (in_array($rootCategory->id, $relCatIds)) {
                    $attr = 'checked="checked" disabled="disabled"';
                } elseif (in_array($category->id, $relCatIds)) {
                    $attr = 'checked="checked"';
                }
                $html .= '<input id="cat-' . $category->id . '" class="input category-checkbox" type="checkbox" name="' . $this->name . '[]" value = "' . $category->id . '" ' . $attr . '/>';
                $html .= '<label for="cat-' . $category->id . '">' . str_repeat('<span class="gi">|—</span>', $category->level) . $category->title . '</label>';
                $html .= '</li>';
            }
        }
        $html .= '</ul></div>';
        return $html;
    }
Esempio n. 3
0
 protected function getOptions()
 {
     $options = array();
     foreach ($this->element->children() as $option) {
         if ($option->getName() != 'option') {
             continue;
         }
         $tmp = JHtml::_('select.option', (string) $option['value'], JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)), 'value', 'text', (string) $option['disabled'] == 'true');
         $tmp->class = (string) $option['class'];
         $tmp->onclick = (string) $option['onclick'];
         $options[] = $tmp;
     }
     reset($options);
     $categories = JUDownloadHelper::getCatsByLevel(1);
     if ($categories) {
         foreach ($categories as $category) {
             $options[] = JHtml::_('select.option', $category->id, $category->title);
         }
     }
     return $options;
 }
Esempio n. 4
0
	public function display($tpl = null)
	{
		$this->item = $this->get('Item');

		
		if (!JUDownloadFrontHelperPermission::canViewDocument($this->item->id))
		{
			$user = JFactory::getUser();
			if ($user->id)
			{
				return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
			}
			else
			{
				$uri      = JUri::getInstance();
				$loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false);
				$app      = JFactory::getApplication();
				$app->redirect($loginUrl, JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning');

				return false;
			}
		}

		
		$app          = JFactory::getApplication();
		$this->user   = JFactory::getUser();
		$this->print  = $app->input->getBool('print', false);
		$this->model  = $this->getModel();
		$this->state  = $this->get('State');
		$this->params = $this->state->get('params');

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

			return false;
		}

		$limitStart = $app->input->getUint('limitstart', 0);

		$config        = JFactory::getConfig();
		$cookie_domain = $config->get('cookie_domain', '');
		$cookie_path   = $config->get('cookie_path', '/');

		
		if (isset($_COOKIE['judl_recently_viewed_documents']))
		{
			$recently_viewed_doc_array = explode(',', $_COOKIE['judl_recently_viewed_documents']);
			$recently_viewed_doc_array = array_unique($recently_viewed_doc_array);
			$key                       = array_search($this->item->id, $recently_viewed_doc_array);
			if ($key !== false)
			{
				unset($recently_viewed_doc_array[$key]);
			}
			else
			{
				
				if ($limitStart == 0)
				{
					$this->model->updateHits($this->item->id);
				}
			}

			$maxDocuments = $this->params->get('max_recently_viewed_documents', 12);
			if (count($recently_viewed_doc_array) >= $maxDocuments)
			{
				$recently_viewed_doc_array = array_slice($recently_viewed_doc_array, 0, $maxDocuments - 1);
			}
			array_unshift($recently_viewed_doc_array, $this->item->id);
			$recently_viewed_doc_array = implode(',', $recently_viewed_doc_array);
			setcookie('judl_recently_viewed_documents', $recently_viewed_doc_array, time() + (3600 * 24 * 15), $cookie_path, $cookie_domain);
		}
		else
		{
			
			if ($limitStart == 0)
			{
				$this->model->updateHits($this->item->id);
			}

			setcookie('judl_recently_viewed_documents', $this->item->id, time() + (3600 * 24 * 15), $cookie_path, $cookie_domain);
		}

		
		$topLevelCats = JUDownloadHelper::getCatsByLevel(1, $this->item->cat_id);
		if ($topLevelCats)
		{
			$this->tl_catid = $topLevelCats[0]->id;
		}

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

		$this->item->class_sfx = htmlspecialchars($this->item->class_sfx);

		
		$this->collection_popup = false;
		if (JUDLPROVERSION && $this->user->id > 0)
		{
			$this->collection_popup = true;

			$this->collections = $this->model->getCollectionPopup($this->item->id);
		}

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

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

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

		$results                                = $dispatcher->trigger('onContentAfterDisplay', array($context, &$this->item, &$this->item->params, $limitStart));
		$this->item->event->afterDisplayContent = trim(implode("\n", $results));

		$results                                     = $dispatcher->trigger('onBeforeDisplayJUDLComment', array($context, &$this->item, &$this->item->params, $limitStart));
		$this->item->event->beforeDisplayJUDLComment = trim(implode("\n", $results));

		$results                                    = $dispatcher->trigger('onAfterDisplayJUDLComment', array($context, &$this->item, &$this->item->params, $limitStart));
		$this->item->event->afterDisplayJUDLComment = trim(implode("\n", $results));

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

		$this->_setBreadcrumb();

		parent::display($tpl);
	}
Esempio n. 5
0
	public static function getMenuItemIdArrayOfViewCategoryTreeLevel0And1()
	{
		$menuItemIdsOfViewCategoryTree = self::getMenuItemIdArrayOfViewCategoryTree();
		$menuItemIds                   = array();

		
		$categoryObjectListLevel1 = JUDownloadHelper::getCatsByLevel();

		if ($categoryObjectListLevel1)
		{
			foreach ($categoryObjectListLevel1 AS $categoryObjectLevel1)
			{
				if (isset($menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id]))
				{
					$menuItemIds[$categoryObjectLevel1->id] = $menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id];
				}
			}

			$categoryRoot = JUDownloadFrontHelperCategory::getRootCategory();

			if (isset($menuItemIdsOfViewCategoryTree[$categoryRoot->id]))
			{
				$menuItemIds[$categoryRoot->id] = $menuItemIdsOfViewCategoryTree[$categoryRoot->id];
			}
		}

		return $menuItemIds;
	}
Esempio n. 6
0
	public function display($tpl = null)
	{
		
		$model               = $this->getModel();
		$this->model         = $model;
		$this->state         = $this->get('State');
		$params              = $this->state->params;
		$this->params        = $params;
		$this->token         = JSession::getFormToken();
		$this->root_category = JUDownloadFrontHelperCategory::getRootCategory();
		$categoryId          = $this->state->get('category.id', $this->root_category->id);

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

			return false;
		}

		
		$error = array();
		if (!JUDownloadFrontHelperPermission::canDoCategory($categoryId, true, $error))
		{
			$user = JFactory::getUser();
			if ($user->id)
			{
				return JError::raiseError($error['code'], $error['message']);
			}
			else
			{
				$uri      = JUri::getInstance();
				$loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false);
				$app      = JFactory::getApplication();
				$app->redirect($loginUrl, JText::_('COM_JUDOWNLOAD_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning');

				return false;
			}
		}

		
		$topLevelCats = JUDownloadHelper::getCatsByLevel(1, $categoryId);
		if (is_array($topLevelCats) && count($topLevelCats) > 0)
		{
			$this->tl_catid = $topLevelCats[0]->id;
		}

		
		$this->category = JUDownloadFrontHelperCategory::getCategory($categoryId);

		
		$this->show_feed = JUDLPROVERSION ? $this->params->get('rss_display_icon', 1) : 0;
		$this->rss_link  = JRoute::_(JUDownloadHelperRoute::getCategoryRoute($this->category->id, null, true));

		
		if (isset($this->category->images) && !empty($this->category->images) && !empty($this->category->images->detail_image))
		{
			$this->category->images->detail_image_src = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judownload/images/category/detail/', true) . $this->category->images->detail_image;
		}
		$this->category->images->detail_image_width  = (int) $this->params->get('category_image_width', 200);
		$this->category->images->detail_image_height = (int) $this->params->get('category_image_height', 200);

		
		if ($this->params->get('category_show_description', 1))
		{
			$this->category->description = $this->category->introtext . $this->category->fulltext;
		}
		else
		{
			$this->category->description = $this->category->fulltext;
		}

		
		$categoryDescLimit = (int) $this->params->get('category_desc_limit', 0);
		if ($categoryDescLimit > 0)
		{
			$this->category->description = JUDownloadFrontHelperString::truncateHtml($this->category->description, $categoryDescLimit);
		}

		
		if ($this->params->get('plugin_support', 0))
		{
			$this->category->description = JHtml::_('content.prepare', $this->category->description, '', 'com_judownload.category');
		}

		
		$this->category->class_sfx = htmlspecialchars($this->category->class_sfx);

		
		$relatedCatOrdering  = $this->params->get('related_category_ordering', 'crel.ordering');
		$relatedCatDirection = $this->params->get('related_category_direction', 'ASC');
		$this->related_cats  = $model->getRelatedCategories($this->category->id, $relatedCatOrdering, $relatedCatDirection);

		if (is_array($this->related_cats) && count($this->related_cats) > 0)
		{
			foreach ($this->related_cats AS $relatedCategory)
			{
				if (isset($relatedCategory->images->intro_image) && !empty($relatedCategory->images->intro_image))
				{
					$relatedCategory->images->intro_image_src = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judownload/images/category/intro/', true) . $relatedCategory->images->intro_image;
				}
				$relatedCategory->images->intro_image_width  = (int) $this->params->get('related_category_intro_image_width', 200);
				$relatedCategory->images->intro_image_height = (int) $this->params->get('related_category_intro_image_height', 200);

				if ($this->params->get('related_category_show_introtext', 1))
				{
					$relatedCategoryDescLimit = (int) $this->params->get('related_category_introtext_character_limit', 500);
					if ($relatedCategoryDescLimit > 0)
					{
						$relatedCategory->introtext = JUDownloadFrontHelperString::truncateHtml($relatedCategory->introtext, $relatedCategoryDescLimit);
					}

					if ($params->get('plugin_support', 0))
					{
						$relatedCategory->introtext = JHtml::_('content.prepare', $relatedCategory->introtext, '', 'com_judownload.category');
					}
				}
				else
				{
					$relatedCategory->introtext = '';
				}
			}
		}

		
		$subCatOrdering      = $this->params->get('subcategory_ordering', 'title');
		$subCatDirection     = $this->params->get('subcategory_direction', 'ASC');
		$this->subcategories = $model->getSubCategories($this->category->id, $subCatOrdering, $subCatDirection);

		if (is_array($this->subcategories) && count($this->subcategories) > 0)
		{
			foreach ($this->subcategories AS $subCategory)
			{
				if (isset($subCategory->images->intro_image) && !empty($subCategory->images->intro_image))
				{
					$subCategory->images->intro_image_src = JUri::root(true) . '/' . JUDownloadFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judownload/images/category/intro/', true) . $subCategory->images->intro_image;
				}
				$subCategory->images->intro_image_width  = (int) $this->params->get('subcategory_intro_image_width', 200);
				$subCategory->images->intro_image_height = (int) $this->params->get('subcategory_intro_image_height', 200);

				if ($this->params->get('subcategory_show_introtext', 1))
				{
					$subCategoryDescLimit = (int) $this->params->get('subcategory_introtext_character_limit', 500);
					if ($subCategoryDescLimit > 0)
					{
						$subCategory->introtext = JUDownloadFrontHelperString::truncateHtml($subCategory->introtext, $subCategoryDescLimit);
					}
					if ($this->params->get('plugin_support', 0))
					{
						$subCategory->introtext = JHtml::_('content.prepare', $subCategory->introtext, '', 'com_judownload.category');
					}
				}
				else
				{
					$subCategory->introtext = '';
				}
			}
		}

		$this->category->can_submit_doc = JUDownloadFrontHelperPermission::canSubmitDocument($this->category->id);
		if ($this->category->can_submit_doc && $this->params->get('show_submit_document_btn_in_category', 1))
		{
			$this->category->submit_doc_link = JUDownloadFrontHelperDocument::getAddDocumentLink($this->category->id);
		}

		
		$this->items = array();

		
		if ($this->category->show_item)
		{
			$user        = JFactory::getUser();
			$uri         = JUri::getInstance();
			$this->items = $this->get('Items');
			foreach ($this->items as $item)
			{
				$documentItemid = JUDownloadHelperRoute::findItemIdOfDocument($item->id);

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

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

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

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

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

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

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

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

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

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

		
		$this->_prepareData();

		$this->_prepareDocument();

		$this->_setBreadcrumb();

		parent::display($tpl);
	}