예제 #1
1
 protected function getInput()
 {
     $html = '';
     $db = JFactory::getDbo();
     $options = JUDownloadHelper::getFieldGroupOptions();
     if ($this->element['usenone'] == 'true') {
         array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
     }
     if ($this->element['useinherit'] == 'true') {
         $appendInherit = "";
         if ($this->form->getValue("id")) {
             $appendInherit = " ( " . JText::_('COM_JUDOWNLOAD_NONE') . " )";
             if ($this->form->getValue("id") > 0) {
                 $catObj = JUDownloadHelper::getCategoryById($this->form->getValue("parent_id"));
                 if ($catObj->fieldgroup_id > 1) {
                     $query = "SELECT name, published FROM #__judownload_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1";
                     $db->setQuery($query);
                     $fieldgroup = $db->loadObject();
                     $groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name;
                     $appendInherit = "( " . $groupName . " )";
                 }
             }
         }
         array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
     } else {
         array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_FIELD_GROUP')));
     }
     $required_class = $this->element['required'] == 'true' ? 'required' : '';
     $attributes = "class=\"inputbox {$required_class}\"";
     $html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
     return $html;
 }
예제 #2
0
 public function display($tpl = null)
 {
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->canDo = JUDownloadHelper::getActions('com_judownload');
     $this->addToolBar();
     if (JUDownloadHelper::isJoomla3x()) {
         $this->filterForm = $this->get('FilterForm');
         $this->activeFilters = $this->get('ActiveFilters');
     }
     $options = array();
     $options[] = JHtml::_('select.option', '1', JText::_('J1'));
     $options[] = JHtml::_('select.option', '2', JText::_('J2'));
     $options[] = JHtml::_('select.option', '3', JText::_('J3'));
     $options[] = JHtml::_('select.option', '4', JText::_('J4'));
     $options[] = JHtml::_('select.option', '5', JText::_('J5'));
     $options[] = JHtml::_('select.option', '6', JText::_('J6'));
     $options[] = JHtml::_('select.option', '7', JText::_('J7'));
     $options[] = JHtml::_('select.option', '8', JText::_('J8'));
     $options[] = JHtml::_('select.option', '9', JText::_('J9'));
     $options[] = JHtml::_('select.option', '10', JText::_('J10'));
     $this->f_levels = $options;
     $optionsPublished = array();
     $optionsPublished[] = JHtml::_('select.option', '1', JText::_('COM_JUDOWNLOAD_PUBLISHED'));
     $optionsPublished[] = JHtml::_('select.option', '0', JText::_('COM_JUDOWNLOAD_UNPUBLISHED'));
     $this->published_options = $optionsPublished;
     parent::display($tpl);
     $this->setDocument();
 }
예제 #3
0
	public function display($tpl = null)
	{
		$this->items      = $this->get('Items');
		$this->state      = $this->get('State');
		$this->pagination = $this->get('Pagination');
		$this->params     = JUDownloadHelper::getParams();

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

			return false;
		}

		$this->listOrder = $this->escape($this->state->get('list.ordering', 'tag.title'));
		$this->listDirn  = $this->escape($this->state->get('list.direction', 'DESC'));

		$this->order_name_array = array(
			'tag.id'       => JText::_('COM_JUDOWNLOAD_FIELD_ID'),
			'tag.title'    => JText::_('COM_JUDOWNLOAD_FIELD_TITLE'),
			'tag.created'  => JText::_('COM_JUDOWNLOAD_FIELD_CREATED'),
			'tag.ordering' => JText::_('COM_JUDOWNLOAD_FIELD_ORDERING')
		);

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

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

		parent::display($tpl);
	}
예제 #4
0
 protected function addToolBar()
 {
     $app = JFactory::getApplication();
     $app->input->set('hidemainmenu', true);
     $isNew = $this->item->id == 0;
     $canDo = JUDownloadHelper::getActions('com_judownload');
     $user = JFactory::getUser();
     $userId = $user->id;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     JToolBarHelper::title(JText::_('COM_JUDOWNLOAD_PAGE_' . ($checkedOut ? 'VIEW_TEMPLATE_STYLE' : ($isNew ? 'ADD_TEMPLATE_STYLE' : 'EDIT_TEMPLATE_STYLE'))), 'style-add');
     if ($isNew) {
         if ($canDo->get('core.create')) {
             JToolBarHelper::apply('style.apply', 'JTOOLBAR_APPLY');
             JToolBarHelper::save('style.save2new', 'JTOOLBAR_SAVE_AND_NEW');
             JToolBarHelper::save('style.save', 'JTOOLBAR_SAVE');
         }
         JToolBarHelper::cancel('style.cancel', 'JTOOLBAR_CANCEL');
     } else {
         if ($canDo->get('core.edit')) {
             JToolBarHelper::apply('style.apply', 'JTOOLBAR_APPLY');
             if ($canDo->get('core.create')) {
                 JToolBarHelper::save('style.save2new', 'JTOOLBAR_SAVE_AND_NEW');
             }
             JToolBarHelper::save('style.save', 'JTOOLBAR_SAVE');
         }
         JToolBarHelper::cancel('style.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolBarHelper::divider();
     $bar = JToolBar::getInstance('toolbar');
     $bar->addButtonPath(JPATH_ADMINISTRATOR . "/components/com_judownload/helpers/button");
     $bar->appendButton('JUHelp', 'help', JText::_('JTOOLBAR_HELP'));
 }
예제 #5
0
 protected function addToolBar()
 {
     $app = JFactory::getApplication();
     $app->input->set('hidemainmenu', true);
     $isNew = $this->item->id == 0;
     $user = JFactory::getUser();
     $userId = $user->id;
     $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
     JToolBarHelper::title(JText::_('COM_JUDOWNLOAD_PAGE_' . ($checkedOut ? 'VIEW_FIELD' : ($isNew ? 'ADD_FIELD' : 'EDIT_FIELD'))), 'field-add');
     $canDo = JUDownloadHelper::getActions('com_judownload', 'field', $this->item->id);
     if ($isNew && $user->authorise('core.create', 'com_judownload')) {
         JToolBarHelper::apply('field.apply');
         JToolBarHelper::save('field.save');
         JToolBarHelper::save2new('field.save2new');
         JToolBarHelper::cancel('field.cancel');
     } else {
         if (!$checkedOut) {
             if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) {
                 JToolBarHelper::apply('field.apply');
                 JToolBarHelper::save('field.save');
                 if ($canDo->get('core.create')) {
                     JToolBarHelper::save2new('field.save2new');
                 }
             }
         }
         JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE');
     }
     JToolBarHelper::divider();
     $bar = JToolBar::getInstance('toolbar');
     $bar->addButtonPath(JPATH_ADMINISTRATOR . "/components/com_judownload/helpers/button");
     $bar->appendButton('JUHelp', 'help', JText::_('JTOOLBAR_HELP'));
 }
예제 #6
0
 public function __set($name, $value)
 {
     switch ($name) {
         case 'height':
         case 'width':
         case 'assetField':
         case 'authorField':
         case 'asset':
             $this->{$name} = (string) $value;
             break;
         case 'buttons':
             $value = (string) $value;
             if ($value == 'true' || $value == 'yes' || $value == '1') {
                 $this->buttons = true;
             } elseif ($value == 'false' || $value == 'no' || $value == '0') {
                 $this->buttons = false;
             } else {
                 $this->buttons = explode(',', $value);
             }
             break;
         case 'hide':
             $value = (string) $value;
             $this->hide = $value ? explode(',', $value) : array();
             break;
         case 'editorType':
             $this->editorType = explode('|', trim((string) $value));
             break;
         default:
             if (JUDownloadHelper::isJoomla3x()) {
                 parent::__set($name, $value);
             } else {
                 $this->{$name} = $value;
             }
     }
 }
예제 #7
0
	protected function populateState($ordering = null, $direction = null)
	{
		
		$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '');
		$this->setState('filter.search', $search);

		$featured = $this->getUserStateFromRequest($this->context . '.filter.featured', 'filter_featured', '');
		$this->setState('filter.featured', $featured);

		$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_catid', '');
		$this->setState('filter.catid', $categoryId);

		$license = $this->getUserStateFromRequest($this->context . '.filter.license', 'filter_licenseid', '');
		$this->setState('filter.licenseid', $license);

		
		$params = JUDownloadHelper::getParams();
		$this->setState('params', $params);

		
		parent::populateState('d.title', 'asc');

		$field_display = $this->getUserStateFromRequest($this->context . '.field_display', 'field_display', array());
		$this->setState('field_display', $field_display);
	}
예제 #8
0
 public function display($tpl = null)
 {
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $app = JFactory::getApplication();
     if ($app->input->get('layout') == null) {
         $app->redirect('index.php?option=com_judownload&view=listcats');
     }
     $this->items = $this->get('Items');
     $this->state = $this->get('State');
     $this->authors = $this->get('Authors');
     $this->pagination = $this->get('Pagination');
     if ($app->input->get('layout') == 'copy') {
         JToolBarHelper::title(JText::_('COM_JUDOWNLOAD_COPY_DOCUMENTS'), 'copy-documents');
         JToolBarHelper::apply('documents.copyDocuments', 'JTOOLBAR_APPLY');
         JToolBarHelper::cancel('document.cancel', 'JTOOLBAR_CANCEL');
     } elseif ($app->input->get('layout') == 'move') {
         JToolBarHelper::title(JText::_('COM_JUDOWNLOAD_MOVE_DOCUMENTS'), 'move-documents');
         JToolBarHelper::apply('documents.moveDocuments', 'JTOOLBAR_APPLY');
         JToolBarHelper::cancel('document.cancel', 'JTOOLBAR_CANCEL');
     } else {
         JToolBarHelper::title(JText::_('COM_JUDOWNLOAD_DOCUMENTS'), 'documents');
         $this->totalDocs = $this->get('Total');
         $this->setDocument();
     }
     if (JUDownloadHelper::isJoomla3x() && $app->input->get('layout') == 'modal') {
         $this->filterForm = $this->get('FilterForm');
         $this->activeFilters = $this->get('ActiveFilters');
     }
     parent::display($tpl);
 }
예제 #9
0
 public function rebuildCommentTree()
 {
     $model = $this->getModel();
     JUDownloadHelper::obCleanData();
     echo $model->rebuildCommentTree();
     exit;
 }
예제 #10
0
 public function changeTemplateId()
 {
     $app = JFactory::getApplication();
     $jInput = $app->input;
     $templateId = $jInput->post->getInt("value");
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('parent_id');
     $query->from('#__judownload_templates');
     $query->where('id = ' . $templateId);
     $db->setQuery($query);
     $templateParentId = $db->loadResult();
     $query = $db->getQuery(true);
     $query->select('*');
     $query->select('title AS text');
     $query->select('id AS value');
     $query->from('#__judownload_template_styles');
     $query->where('template_id =' . $templateParentId);
     $query->order('lft ASC');
     $db->setQuery($query);
     $styleObjectList = $db->loadObjectList();
     $html = "";
     $html .= "<option value=\"\">" . JText::_('COM_JUDOWNLOAD_SELECT_PARENT_TEMPLATE') . "</option>";
     if (!empty($styleObjectList)) {
         foreach ($styleObjectList as $styleObject) {
             $html .= "<option value=\"" . $styleObject->value . "\">" . $styleObject->text . "</option>";
         }
     }
     JUDownloadHelper::obCleanData();
     echo $html;
     exit;
 }
예제 #11
0
	public function display($tpl = null)
	{
		$this->params = JUDownloadHelper::getParams();

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

			return false;
		}

		if (!$this->params->get('activate_maintenance', 0))
		{
			$app = JFactory::getApplication();
			$app->redirect(JUri::root());
		}

		$this->_prepareDocument();

		$this->_setBreadcrumb();

		
		parent::display($tpl);
	}
예제 #12
0
 function approve($comment_ids)
 {
     if (!is_array($comment_ids) || empty($comment_ids)) {
         $this->setError('COM_JUDOWNLOAD_NO_ITEM_SELECTED');
         return false;
     }
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judownload/tables');
     $comment_table = JTable::getInstance("Comment", "JUDownloadTable");
     $count = 0;
     $comment_ids = (array) $comment_ids;
     $rootComment = JUDownloadFrontHelperComment::getRootComment();
     $docIds = array();
     foreach ($comment_ids as $comment_id) {
         $comment_table->reset();
         if ($comment_table->load($comment_id) && $comment_table->parent_id == $rootComment->id && $comment_table->approved == 0) {
             $docIds[$comment_table->doc_id] = $comment_table->doc_id;
         }
         $user = JFactory::getUser();
         $date = JFactory::getDate();
         $comment_table->approved = 1;
         $comment_table->published = 1;
         $comment_table->approved_by = $user->id;
         $comment_table->approved_time = $date->toSql();
         $comment_table->store();
         $count++;
         JUDownloadFrontHelperMail::sendEmailByEvent('comment.approve', $comment_id);
         $logData = array('user_id' => $comment_table->user_id, 'event' => 'comment.approve', 'item_id' => $comment_id, 'doc_id' => $comment_table->doc_id, 'value' => 0, 'reference' => '');
         JUDownloadFrontHelperLog::addLog($logData);
     }
     foreach ($docIds as $docId) {
         JUDownloadHelper::rebuildRating($docId);
     }
     return $count;
 }
예제 #13
0
 public function display($tpl = null)
 {
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode('<br />', $errors));
         return false;
     }
     $this->items = $this->get('Items');
     $this->pagination = $this->get('Pagination');
     $this->state = $this->get('State');
     $this->canDo = JUDownloadHelper::getActions('com_judownload');
     $this->groupCanDoManage = JUDownloadHelper::checkGroupPermission("comment.edit");
     $this->groupCanDoDelete = JUDownloadHelper::checkGroupPermission("comments.delete");
     $this->rootComment = JUDownloadFrontHelperComment::getRootComment();
     foreach ($this->items as &$item) {
         $this->ordering[$item->parent_id][] = $item->id;
     }
     $this->addToolBar();
     if (JUDownloadHelper::isJoomla3x()) {
         $layout = JFactory::getApplication()->input->get('layout', '');
         if ($layout != 'modal') {
             $this->filterForm = $this->get('FilterForm');
             $this->activeFilters = $this->get('ActiveFilters');
         }
     }
     parent::display($tpl);
     $this->setDocument();
 }
예제 #14
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;
	}
예제 #15
0
    protected function getOptions()
    {
        $document = JFactory::getDocument();
        if (JUDownloadHelper::isJoomla3x()) {
            $triggerJqueryChosen = '$("#jform_parent_id").trigger("liszt:updated");';
        } else {
            $triggerJqueryChosen = '';
        }
        $script = '
			jQuery(document).ready(function($){
				$("#jform_template_id").change(function(){
					var objData = {};
					objData.value = $(this).val();
					$.ajax({
						type: "POST",
						url : "index.php?option=com_judownload&task=style.changeTemplateId",
						data: objData
					}).done(function (data) {
						$("option","#jform_parent_id").remove();
						$("#jform_parent_id").append(data);
						' . $triggerJqueryChosen . '
					});
				});
			});
		';
        $document->addScriptDeclaration($script);
        $db = JFactory::getDbo();
        $options = array();
        $styleId = $this->form->getValue('id');
        if ($styleId) {
            $templateId = $this->form->getValue('template_id');
            $query = $db->getQuery(true);
            $query->select('parent_id');
            $query->from('#__judownload_templates');
            $query->where('id = ' . (int) $templateId);
            $db->setQuery($query);
            $templateParentId = $db->loadResult();
        } else {
            $templateParentId = 0;
        }
        $query = $db->getQuery(true);
        $query->select('*');
        $query->select('title AS text');
        $query->select('id AS value');
        $query->from('#__judownload_template_styles');
        $query->where('template_id = ' . (int) $templateParentId);
        $query->order('lft ASC');
        $db->setQuery($query);
        try {
            $options = $db->loadObjectList();
        } catch (RuntimeException $e) {
            JError::raiseWarning(500, $e->getMessage());
        }
        for ($i = 0, $n = count($options); $i < $n; $i++) {
            $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
        }
        $options = array_merge(parent::getOptions(), $options);
        return $options;
    }
예제 #16
0
 public function docChangeCategory()
 {
     $model = $this->getModel();
     $data = $model->docChangeCategory();
     JUDownloadHelper::obCleanData();
     echo $data;
     exit;
 }
예제 #17
0
	protected function populateState($ordering = null, $direction = null)
	{
		
		$app = JFactory::getApplication();

		$catId  = $app->input->getInt('id', 1);
		$params = JUDownloadHelper::getParams($catId);
		$this->setState('params', $params);
	}
예제 #18
0
	public static function getCriteriaGroupIdByCategoryId($mainCatId)
	{
		$catObj = JUDownloadHelper::getCategoryById($mainCatId);
		if ($catObj)
		{
			return $catObj->criteriagroup_id;
		}

		return null;
	}
예제 #19
0
	public function docChangeCategory()
	{
		
		require_once JPATH_ADMINISTRATOR . '/components/com_judownload/models/category.php';
		JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judownload/models');
		$backendCategoryModel = JModelLegacy::getInstance('Category', 'JUDownloadModel');
		$data                 = $backendCategoryModel->docChangeCategory();
		JUDownloadHelper::obCleanData();
		echo $data;
		exit();
	}
예제 #20
0
 protected function loadFormData()
 {
     $data = JFactory::getApplication()->getUserState('com_judownload.edit.criteria.data', array());
     if (empty($data)) {
         $data = $this->getItem();
     }
     if (JUDownloadHelper::isJoomla3x()) {
         $this->preprocessData('com_judownload.criteria', $data);
     }
     return $data;
 }
예제 #21
0
	protected function populateState($ordering = null, $direction = null)
	{
		
		$app = JFactory::getApplication();

		$rootCategory = JUDownloadFrontHelperCategory::getRootCategory();
		$categoryId   = $app->input->getInt('id', $rootCategory->id);

		$this->setState('category.id', $categoryId);

		$params = JUDownloadHelper::getParams($categoryId);
		$this->setState('params', $params);

		
		if ($this->context)
		{
			$documentPagination = $params->get('document_pagination', 10);

			$limitArray = JUDownloadFrontHelper::customLimitBox();

			if (is_array($limitArray) && count($limitArray))
			{
				$limit = $app->input->getUint('limit', null);
				if (is_null($limit) || in_array($limit, $limitArray))
				{
					$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $documentPagination, 'uint');
				}
				else
				{
					$limit = $documentPagination;
				}
			}
			else
			{
				$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $documentPagination, 'uint');
			}

			$this->setState('list.limit', $limit);

			$this->setState('list.start', $app->input->getUint('limitstart', 0));

			$orderCol = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', '');
			$this->setState('list.ordering', $orderCol);

			$listOrder = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', 'ASC');
			$this->setState('list.direction', $listOrder);
		}
		else
		{
			$this->setState('list.start', 0);
			$this->state->set('list.limit', 0);
		}
	}
예제 #22
0
 public function getChartData()
 {
     $app = JFactory::getApplication();
     $type = $app->input->get('type');
     $model = $this->getModel();
     $data = $model->getUploadDownloadData($type);
     $app = JFactory::getApplication();
     $app->setUserState('com_judownload.dashboard.chart.type', $type);
     JUDownloadHelper::obCleanData();
     echo json_encode($data);
     exit;
 }
 protected function calculatorInheritStyle($cat_id)
 {
     do {
         $category = JUDownloadHelper::getCategoryById($cat_id);
         $style_id = $category->style_id;
         $cat_id = $category->parent_id;
     } while ($style_id == -1 && $cat_id != 0);
     if ($style_id == -2) {
         return $this->getStyle();
     } else {
         return $this->getStyle($style_id);
     }
 }
예제 #24
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->canDo = JUDownloadHelper::getActions('com_judownload');
     $this->addToolBar();
     parent::display($tpl);
     $this->setDocument();
 }
예제 #25
0
 public function back()
 {
     $app = JFactory::getApplication();
     $doc_id = $app->input->getInt('doc_id', 0);
     $cat_id = JUDownloadFrontHelperCategory::getRootCategory()->id;
     if ($doc_id) {
         $docObj = JUDownloadHelper::getDocumentById($doc_id);
         if (isset($docObj->cat_id) && $docObj->cat_id) {
             $cat_id = $docObj->cat_id;
         }
     }
     $this->setRedirect("index.php?option=com_judownload&view=listcats&cat_id={$cat_id}");
 }
예제 #26
0
 protected function getInput()
 {
     $db = JFactory::getDbo();
     $query = 'SELECT id AS value, name AS text, published FROM #__judownload_criterias_groups ';
     $db->setQuery($query);
     $options = $db->loadObjectList();
     $users = JFactory::getUser();
     foreach ($options as $key => $option) {
         if ($option->published != 1) {
             $option->text = '[ ' . $option->text . ' ]';
         }
         if (!$users->authorise('core.create', 'com_judownload.criteriagroup.' . $option->value)) {
             unset($options[$key]);
         }
     }
     $required_class = $this->element['required'] == 'true' ? 'required' : '';
     $class = $this->element['class'];
     if ($this->element['usenone'] == 'true') {
         array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDOWNLOAD_NONE')));
     }
     if ($this->element['useinherit'] == 'true') {
         $appendInherit = "";
         if ($this->form->getValue("id")) {
             if ($this->form->getValue("criteriagroup_id") > 0) {
                 $appendInherit = $this->getCriteriaGroupName($this->form->getValue("criteriagroup_id"));
             } else {
                 $category = JUDownloadHelper::getCategoryById($this->form->getValue("id"));
                 $parent = JUDownloadHelper::getCategoryById($category->parent_id);
                 $appendInherit = $this->getCriteriaGroupName($parent->criteriagroup_id);
             }
         }
         array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDOWNLOAD_INHERIT') . $appendInherit));
     } else {
         array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDOWNLOAD_SELECT_CRITERIAL_GROUP')));
     }
     $canChange = true;
     if ($this->form->getValue('id')) {
         $query = "SELECT COUNT(*) FROM #__judownload_criterias_values WHERE criteria_id = " . $this->form->getValue('id');
         $db->setQuery($query);
         $canChange = $db->loadResult() ? false : true;
     }
     if ($canChange) {
         $attributes = "class=\"inputbox {$class} {$required_class}\"";
         $html = JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
     } else {
         $attributes = "class=\"inputbox {$class}\" disabled";
         $html = JHtml::_('select.genericlist', $options, "_" . $this->name, $attributes, 'value', 'text', $this->value, $this->id);
         $html .= "<input class=\"{$required_class}\" type=\"hidden\" value=\"" . $this->value . "\" name=\"" . $this->name . "\" />";
     }
     return $html;
 }
예제 #27
0
 public function display($tpl = null)
 {
     JHtml::_('behavior.calendar');
     $this->addToolBar();
     $this->model = $this->getModel();
     if ($this->getLayout() == "fields_mapping") {
         $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDOWNLOAD_DEFAULT'));
         $this->fieldsOption[] = JHTML::_('select.option', 'ignore', JText::_("COM_JUDOWNLOAD_IGNORE"));
         $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDOWNLOAD_CORE_FIELDS'));
         $coreFieldsHaveFieldClass = $this->model->getFieldsHaveFieldClass('core');
         foreach ($coreFieldsHaveFieldClass as $field) {
             $this->fieldsOption[] = JHTML::_('select.option', $field->id, $field->caption);
         }
         $coreFieldsHaveNoFieldClass = $this->model->getDocumentTableFieldsName($coreFieldsHaveFieldClass);
         if (!empty($coreFieldsHaveNoFieldClass)) {
             foreach ($coreFieldsHaveNoFieldClass as $field) {
                 $this->fieldsOption[] = JHTML::_('select.option', $field, ucfirst(str_replace('_', ' ', $field)));
             }
         }
         $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDOWNLOAD_EXTRA_FIELDS'));
         $extraFields = $this->model->getFieldsHaveFieldClass('extra');
         foreach ($extraFields as $field) {
             $this->fieldsOption[] = JHTML::_('select.option', $field->id, $field->caption);
         }
         $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDOWNLOAD_OTHER_FIELDS'));
         $this->fieldsOption[] = JHTML::_('select.option', 'main_cat', JText::_('COM_JUDOWNLOAD_FIELD_MAIN_CATEGORY'));
         $this->fieldsOption[] = JHTML::_('select.option', 'secondary_cats', JText::_('COM_JUDOWNLOAD_FIELD_SECONDARY_CATEGORIES'));
         $this->fieldsOption[] = JHTML::_('select.option', 'gallery', JText::_('COM_JUDOWNLOAD_FIELD_GALLERY'));
         $this->fieldsOption[] = JHTML::_('select.option', 'files', JText::_('COM_JUDOWNLOAD_FIELD_FILES'));
         $this->fieldsOption[] = JHTML::_('select.option', 'related_docs', JText::_('COM_JUDOWNLOAD_FIELD_RELATED_DOCUMENTS'));
     }
     if ($this->getLayout() == 'config') {
         $this->form = $this->get('Form');
         $this->save = "<select id='save_options' name='save_options'>";
         $this->save .= "<option value='keep' selected>" . JText::_("COM_JUDOWNLOAD_KEEP_BOTH") . "</option>";
         $this->save .= "<option value='skip'>" . JText::_("COM_JUDOWNLOAD_SKIP_EXISTED_DOCUMENTS") . "</option>";
         $this->save .= "<option value='replace'>" . JText::_("COM_JUDOWNLOAD_REPLACE_EXISTED_DOCUMENTS") . "</option>";
         $this->save .= "</select>";
     }
     if ($this->getLayout() == 'review') {
         if (isset($this->review['config']['default_icon'])) {
             $this->review['config']['default_icon'] = str_replace(array(JPATH_ROOT . '\\', "\\"), array(JUri::root(), '/'), $this->review['config']['default_icon']);
         }
     }
     $this->isJoomla3x = JUDownloadHelper::isJoomla3x();
     if ($this->getLayout() == "export") {
         $this->exportForm = $this->get("ExportForm");
     }
     parent::display($tpl);
     $this->setDocument();
 }
예제 #28
0
 protected function getOptions()
 {
     $app = JFactory::getApplication();
     $view = $app->input->getCmd('view', '');
     $parentId = $app->input->getInt('parent_id', 1);
     $catId = $app->input->getInt('id', 0);
     $options = array();
     $_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;
     }
     JLoader::register('JUDownloadFrontHelperCategory', JPATH_SITE . '/components/com_judownload/helpers/category.php', false);
     JLoader::register('JUDownloadHelper', JPATH_ADMINISTRATOR . '/components/com_judownload/helpers/judownload.php', false);
     $checkPublished = $this->element['checkpublished'] == 'true' || $this->element['checkpublished'] == '1' ? true : false;
     $checkCreatePermission = false;
     if (isset($this->element['checkcreatepermissiononcat'])) {
         if ($this->element['checkcreatepermissiononcat'] == 'true' || $this->element['checkcreatepermissiononcat'] == '1') {
             $checkCreatePermission = 'category';
         }
     } else {
         if ($this->element['checkcreatepermissionondoc'] == 'true' || $this->element['checkcreatepermissionondoc'] == '1') {
             $checkCreatePermission = 'document';
         }
     }
     $getSelf = $this->element['fetchself'] == 'true' || $this->element['fetchself'] == '1' ? true : false;
     $startLevel = $this->element['startlevel'] ? $this->element['startlevel'] : 0;
     $separation = $this->element['separation'] ? $this->element['separation'] : '|—';
     $ignorecat = $this->element['ignorecat'] ? explode(',', $this->element['ignorecat']) : array();
     if ($view == 'category') {
         if ($catId) {
             $_options = JUDownloadHelper::getCategoryOptions(1, $getSelf, $checkCreatePermission, $checkPublished, array($catId), $startLevel, $separation);
         } elseif ($parentId) {
             $_options = JUDownloadHelper::getCategoryOptions(1, $getSelf, $checkCreatePermission, $checkPublished, $ignorecat, $startLevel, $separation);
             if ($this->value == "") {
                 $this->value = $parentId;
             }
         }
     } else {
         $_options = JUDownloadHelper::getCategoryOptions(1, $getSelf, $checkCreatePermission, $checkPublished, $ignorecat, $startLevel, $separation);
     }
     reset($options);
     $options = array_merge($options, $_options);
     return $options;
 }
예제 #29
0
 public function delete($pk = null)
 {
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     if (parent::delete($pk)) {
         $db = JFactory::getDbo();
         $query = "DELETE FROM #__judownload_criterias_values WHERE rating_id = {$pk}";
         $db->setQuery($query);
         $db->execute();
         JUDownloadHelper::deleteLogs('rating', $pk);
         return true;
     }
     return false;
 }
예제 #30
0
	public function populateState($ordering = null, $direction = null)
	{
		
		$app = JFactory::getApplication();

		$params = JUDownloadHelper::getParams();
		$this->setState('params', $params);

		
		if ($this->context)
		{
			$commentPagination = $params->get('comment_pagination', 10);

			$limitArray = JUDownloadFrontHelper::customLimitBox();

			if (is_array($limitArray) && count($limitArray))
			{
				$limit = $app->input->getUint('limit', null);
				if (is_null($limit) || in_array($limit, $limitArray))
				{
					$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $commentPagination, 'uint');
				}
				else
				{
					$limit = $commentPagination;
				}
			}
			else
			{
				$limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $commentPagination, 'uint');
			}

			$this->setState('list.limit', $limit);

			$this->setState('list.start', $app->input->get('limitstart', 0, 'uint'));

			$commentOrdering = $params->get('comment_ordering', 'cm.created');
			$orderCol        = $app->getUserStateFromRequest($this->context . '.list.ordering', 'filter_order', $commentOrdering);
			$this->setState('list.ordering', $orderCol);

			$commentDirection = $params->get('comment_direction', 'DESC');
			$listOrder        = $app->getUserStateFromRequest($this->context . '.list.direction', 'filter_order_Dir', $commentDirection);
			$this->setState('list.direction', $listOrder);
		}
		else
		{
			$this->setState('list.start', 0);
			$this->state->set('list.limit', 0);
		}
	}