当前位置: 首页>>代码示例>>PHP>>正文


PHP JUDownloadHelper::getCategoryByID方法代码示例

本文整理汇总了PHP中JUDownloadHelper::getCategoryByID方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::getCategoryByID方法的具体用法?PHP JUDownloadHelper::getCategoryByID怎么用?PHP JUDownloadHelper::getCategoryByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUDownloadHelper的用法示例。


在下文中一共展示了JUDownloadHelper::getCategoryByID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInput

    protected function getInput()
    {
        $document = JFactory::getDocument();
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select('cat_id_related');
        $query->from('#__judownload_categories_relations');
        $query->where('cat_id = ' . (int) $this->form->getValue('id'));
        $query->order("ordering ASC");
        $db->setQuery($query);
        $relcategories = $db->loadColumn();
        $script = '
		jQuery(document).ready(function($){
			$(".category_list").dragsort({ dragSelector: "li", dragEnd: saveOrder, placeHolderTemplate: "<li class=\'placeHolder\'></li>", dragSelectorExclude: "input, textarea, span, a.removeitem"});

            function saveOrder() {
                var data = $("#gallery li").map(function() { return $(this).data("itemid"); }).get();
            };

			$(".category_list").on("click","a.removeitem", function(event){
				event.preventDefault();
				$(this).closest("li").remove();
			});

			$(".browse_cat").bind("dblclick",function(){
				var id = $(this).find("option:selected").val();
				$.ajax({
			  		type: "POST",
			  		url:"index.php?option=com_judownload&task=categories.loadcategories",
			  		data: {id : id, type : "category"}
				}).done(function(data){
					data = $.parseJSON(data);
					$(".browse_cat").html(data.html);
					$(".active_pathway").html(data.path);
				});
			});

			$(".change_categories").click(function(){
				$(".category_selection").slideToggle(400);
			});

			$("#add_related_categories").click(function(event){
    			event.preventDefault();
    			var has_element = [];
				var current_cat = ' . JFactory::getApplication()->input->get('id', 0) . ';
				$.each( $("option:selected",".browse_cat"), function(key, value ) {
					if($(this).data("noselect")){
						return;
					}

					var selectedValue = $(this).val();
					var selectedText = $(this).text();

  					if(current_cat == selectedValue){
						alert("' . JText::_('COM_JUDOWNLOAD_CAN_NOT_ADD_CATEGORY_ITSELF_AS_RELATED_CATEGORY') . '");
						return;
					}
  					if($(".category_list > li[id=\'category-"+selectedValue+"\']").length <= 0){
  						var path = $(".active_pathway").text() + " > " + selectedText;
  						$("<li id=\\"category-"+selectedValue+"\\"><a class=\\"drag-icon\\"></a><span>"+path+"</span><input type=\\"hidden\\" name=\\"relcategories[]\\" value=\\""+selectedValue+"\\" /> <a href=\\"#\\" class=\\"removeitem\\" ><i class=\\"icon-minus\\"></i> ' . JText::_('COM_JUDOWNLOAD_REMOVE') . '</a></li>").appendTo(".category_list");
   					}else{
  						has_element.push(selectedText);
  					}
				});

                if(has_element.length == 1){
                    alert("' . JText::_('COM_JUDOWNLOAD_CATEGORY_X_ALREADY_EXISTED') . '".replace("%s", has_element[0]));
				}else if(has_element.length > 1){
				    alert("' . JText::_('COM_JUDOWNLOAD_CATEGORIES_X_ALREADY_EXISTED') . '".replace("%s", has_element.join(", ")));
				}
				return false;
			});
		});';
        $document->addScriptDeclaration($script);
        $html = "";
        $html .= "<div class=\"categories\">";
        $html .= "<ul class=\"category_list nav clearfix\">";
        if ($relcategories) {
            foreach ($relcategories as $key => $relcategory) {
                $path = JUDownloadHelper::generateCategoryPath($relcategory);
                $html .= '<li id="category-' . $relcategory . '">';
                $html .= '<a class="drag-icon"></a>';
                $html .= '<span>' . $path . '</span>';
                $html .= '<input type="hidden" name="relcategories[]" value="' . $relcategory . '" />';
                $html .= '<a class="removeitem" href="#"><i class="icon-minus"></i> ' . JText::_('COM_JUDOWNLOAD_REMOVE') . '</a>';
                $html .= "</li>";
            }
        }
        $html .= '</ul>';
        $catId = $this->form->getValue('id', 0);
        $catParentId = !$catId ? JUDownloadFrontHelperCategory::getRootCategory()->id : JUDownloadHelper::getCategoryByID($catId)->parent_id;
        $query = $db->getQuery(true);
        $query->SELECT('title, id, published, parent_id');
        $query->FROM('#__judownload_categories');
        $query->WHERE('parent_id = ' . $catParentId);
        $query->ORDER('lft');
        $db->setQuery($query);
        $categoryList = $db->loadObjectList();
        foreach ($categoryList as $key => $cat) {
            if ($cat->published != 1) {
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:categoriesrelated.php

示例2: moveCats

 public function moveCats($cat_id_arr, $tocat_id, $move_option_arr)
 {
     $tocat_id = (int) $tocat_id;
     $cat_id_arr = (array) $cat_id_arr;
     if (empty($cat_id_arr)) {
         JError::raiseWarning(100, JText::_('COM_JUDOWNLOAD_NO_SOURCE_CATEGORY_SELECTED'));
         return false;
     }
     if (empty($tocat_id)) {
         JError::raiseWarning(100, JText::_('COM_JUDOWNLOAD_NO_TARGET_CATEGORY_SELECTED'));
         return false;
     }
     $user = JFactory::getUser();
     $table = $this->getTable();
     if (!$table->load($tocat_id)) {
         JError::raiseWarning(500, JText::_('COM_JUDOWNLOAD_TARGET_CATEGORY_NOT_FOUND'));
         return false;
     }
     $assetName = 'com_judownload.category.' . (int) $tocat_id;
     $candoCreate = $user->authorise('judl.category.create', $assetName);
     if (!$candoCreate) {
         JError::raiseError(100, JText::sprintf('COM_JUDOWNLOAD_CAN_NOT_CREATE_CATEGORY_IN_CATEGORY_X', $table->title));
         return false;
     }
     set_time_limit(0);
     $total_moved_categories = 0;
     foreach ($cat_id_arr as $cat_id) {
         if (!$table->load($cat_id, true)) {
             continue;
         }
         $assetName = 'com_judownload.category.' . (int) $cat_id;
         $candoEdit = $user->authorise('judl.category.edit', $assetName);
         if (!$candoEdit) {
             JError::raiseWarning(100, JText::_('COM_JUDOWNLOAD_YOU_DONT_HAVE_PERMISSION_TO_EDIT_CAT'));
             continue;
         }
         if ($this->isChildCategory($cat_id, $tocat_id) || $tocat_id == $table->parent_id) {
             continue;
         }
         $table->setLocation($tocat_id, 'last-child');
         if (in_array('keep_extra_fields', $move_option_arr)) {
             if ($table->selected_fieldgroup == -1) {
                 $tocat_obj = JUDownloadHelper::getCategoryByID($tocat_id);
                 if ($table->fieldgroup_id != $tocat_obj->fieldgroup_id) {
                     $table->selected_fieldgroup = $table->fieldgroup_id;
                 }
             }
         } else {
             if ($table->fieldgroup_id != 0) {
                 JUDownloadHelper::changeInheritedFieldGroupId($table->id, 0);
                 $query = "DELETE FROM #__judownload_fields_ordering WHERE `item_id` = " . $table->id . " AND `type` = 'category'";
                 $db = JFactory::getDbo();
                 $db->setQuery($query);
                 $db->execute();
             }
             $table->selected_fieldgroup = $table->fieldgroup_id = 0;
         }
         if (in_array('keep_rates', $move_option_arr)) {
             if ($table->selected_criteriagroup == -1) {
                 $tocat_obj = JUDownloadHelper::getCategoryByID($tocat_id);
                 if ($table->criteriagroup_id != $tocat_obj->criteriagroup_id) {
                     $table->selected_criteriagroup = $table->criteriagroup_id;
                 }
             }
         } else {
             $table->selected_criteriagroup = $table->criteriagroup_id = 0;
             JUDownloadHelper::changeInheritedCriteriagroupId($table->id, $table->criteriagroup_id);
         }
         if ($table->style_id == -1) {
             if ($table->parent_id != $tocat_id) {
                 $oldTemplateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($table->id);
                 $newTemplateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($tocat_id);
                 if ($oldTemplateStyleObject->template_id != $newTemplateStyleObject->template_id) {
                     if (in_array('keep_template_params', $move_option_arr)) {
                         $table->style_id = $oldTemplateStyleObject->id;
                     } else {
                         $table->template_params = '';
                         JUDownloadFrontHelperTemplate::removeTemplateParamsOfInheritedStyleCatDoc($table->id);
                     }
                 }
             }
         }
         if ($table->store()) {
             $total_moved_categories++;
         }
     }
     return $total_moved_categories;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:88,代码来源:category.php

示例3: getChildCategoryOptions

	protected function getChildCategoryOptions($parentCatId)
	{
		$db    = JFactory::getDbo();
		$query = $db->getQuery(true);
		$query->select('title, id, published, parent_id');
		$query->from('#__judownload_categories');
		$query->where('parent_id = ' . (int) $parentCatId);
		$query->order('lft');
		$db->setQuery($query);
		$categoryObjectList = $db->loadObjectList();
		foreach ($categoryObjectList AS $key => $cat)
		{
			$canSubmitDocument = JUDownloadFrontHelperPermission::canSubmitDocument($cat->id);

			
			if (!$canSubmitDocument)
			{
				unset($categoryObjectList[$key]);
				continue;
			}

			
			if ($cat->published != 1)
			{
				$categoryObjectList[$key]->title = "[" . $cat->title . "]";
			}
		}

		$rootCat = JUDownloadFrontHelperCategory::getRootCategory();

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

		if ($parentCatId != 0 && ($parentCatId != $rootCat->id || ($parentCatId == $rootCat->id && $params->get('allow_add_doc_to_root', 0))))
		{
			$catParent = JUDownloadHelper::getCategoryByID($parentCatId);
			array_unshift($categoryObjectList, JHtml::_('select.option', $catParent->parent_id, JText::_('COM_JUDOWNLOAD_BACK_TO_PARENT_CATEGORY'), 'id', 'title'));
		}

		return $categoryObjectList;
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:48,代码来源:core_categories.php


注:本文中的JUDownloadHelper::getCategoryByID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。