protected function getInput()
 {
     $app = JFactory::getApplication();
     $modId = $app->input->getInt('id', 0);
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('user_id');
     $query->from('#__judirectory_moderators');
     $query->where('id =' . $modId);
     $db->setQuery($query);
     $query = $db->getQuery(true);
     $query->select('cat_id');
     $query->from('#__judirectory_moderators_xref');
     $query->where('mod_id = ' . $modId);
     $db->setQuery($query);
     $categoryIdsAssignedMod = $db->loadColumn();
     $html = "<div id=\"moderator-assign\" class=\"moderator-assign pull-left\">";
     $select_cat_class = 'select-cat';
     $html .= '<div class="btn-group pull-left">';
     $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', !jQuery(this).is(\':checked\')); });">' . JText::_('JGLOBAL_SELECTION_INVERT') . '</button>';
     $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', false); });">' . JText::_('JGLOBAL_SELECTION_NONE') . '</button>';
     $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', true); });">' . JText::_('JGLOBAL_SELECTION_ALL') . '</button>';
     $html .= '</div>';
     $categoryTree = JUDirectoryHelper::getCategoryTree();
     $html .= "<ul id=\"" . $this->id . "\" class=\"nav\">";
     foreach ($categoryTree as $category) {
         $html .= "<li>";
         if (in_array($category->id, $categoryIdsAssignedMod)) {
             if (!in_array($category->id, $categoryIdsAssignedMod)) {
                 $html .= "<input id=\"catid-" . $category->id . "\" disabled type=\"checkbox\" value=\"" . $category->id . "\" name=\"jform[assigntocats][]\"/>";
             } else {
                 $html .= "<input id=\"catid-" . $category->id . "\" class=\"" . $select_cat_class . "\" checked type=\"checkbox\" value=\"" . $category->id . "\" name=\"jform[assigntocats][]\"/>";
             }
         } else {
             $html .= "<input id=\"catid-" . $category->id . "\" class=\"" . $select_cat_class . "\" type=\"checkbox\" value=\"" . $category->id . "\" name=\"jform[assigntocats][]\"/>";
         }
         $html .= "<label for=\"catid-" . $category->id . "\">" . str_repeat('<span class="gi">|—</span>', $category->level) . "<a href='index.php?option=com_judirectory&task=category.edit&id=" . $category->id . "'>" . $category->title . "</a></label>";
         $html .= "</li>";
     }
     $html .= "</ul>";
     $html .= "</div>";
     if ($modId != 0) {
         return $html;
     } else {
         $html = "<div id=\"moderator-assign\" class=\"moderator-assign pull-left\">";
         $html .= JText::_('COM_JUDIRECTORY_PLEASE_SELECT_USER_BEFORE_SELECT_CATEGORY');
         $html .= "</div>";
         return $html;
     }
 }
 protected function getInput()
 {
     $fieldgroup_id = $this->form->getValue('id');
     $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory();
     $categoryTree = JUDirectoryHelper::getCategoryTree($rootCategory->id);
     $html = "<div id=\"categoriestoassignfieldgroup\" class=\"categoriestoassignfieldgroup\">";
     if ($this->form->getValue('id') == 1) {
         $html .= '<input type="text" class="readonly" readonly="readonly" value="' . JText::_('JALL') . '"/>';
     } else {
         $select_cat_class = 'select-cat';
         $html .= '<div class="btn-group pull-left">';
         $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', !jQuery(this).is(\':checked\')); });">' . JText::_('JGLOBAL_SELECTION_INVERT') . '</button>';
         $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', false); });">' . JText::_('JGLOBAL_SELECTION_NONE') . '</button>';
         $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) {  jQuery(this).prop(\'checked\', true); });">' . JText::_('JGLOBAL_SELECTION_ALL') . '</button>';
         $html .= '</div>';
         $html .= "<ul id=\"" . $this->id . "\" class=\"nav\">";
         $html .= "<li>";
         $html .= "<input id=\"catid-" . $rootCategory->id . "\" type=\"checkbox\" value=\"" . $rootCategory->id . "\" disabled=\"true\" />";
         $html .= "<label for=\"catid-" . $rootCategory->id . "\">" . str_repeat('<span class="gi">|—</span>', $rootCategory->level) . $rootCategory->title . "</label>";
         $html .= "</li>";
         foreach ($categoryTree as $category) {
             if ($category->id == $rootCategory->id) {
                 continue;
             }
             $link_edit_fieldgroup = '';
             $html .= "<li>";
             if ($category->selected_fieldgroup == -1 && $category->fieldgroup_id > 0) {
                 $html .= "<span class=\"inherited-value\"  title=\"" . JText::_("COM_JUDIRECTORY_INHERIT") . "\">" . JText::_('COM_JUDIRECTORY_INHERIT') . "</span>";
             } elseif ($category->fieldgroup_id == $fieldgroup_id) {
                 $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type=\"checkbox\" value=\"" . $category->id . "\" checked=\"checked\" name=\"" . $this->name . "[]\"/>";
             } elseif ($category->fieldgroup_id > 0) {
                 $link_edit_fieldgroup = "<span><a href=\"index.php?option=com_judirectory&task=fieldgroup.edit&id=" . $category->fieldgroup_id . "\" title=\"" . $this->getFieldGroupName($category->fieldgroup_id) . "\" >[" . $this->getFieldGroupName($category->fieldgroup_id) . "]</a></span>";
                 $html .= "<input id=\"catid-" . $category->id . "\" type=\"checkbox\" checked=\"checked\" value=\"" . $category->id . "\" disabled=\"true\" />";
             } else {
                 $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type=\"checkbox\" value=\"" . $category->id . "\" name=\"" . $this->name . "[]\"/>";
             }
             $html .= "<label for=\"catid-" . $category->id . "\">" . str_repeat('<span class="gi">|—</span>', $category->level) . $category->title . "</label>";
             $html .= $link_edit_fieldgroup;
             $html .= "</li>";
         }
         $html .= "</ul>";
     }
     $html .= "</div>";
     return $html;
 }
 protected function getInput()
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $style_id = $app->input->getInt('id', 0);
     $db->setQuery("SELECT id FROM #__judirectory_categories WHERE style_id = " . $style_id);
     $catIds = $db->loadColumn();
     $rootCategory = JUDirectoryFrontHelperCategory::getRootCategory();
     $categoryTree = JUDirectoryHelper::getCategoryTree($rootCategory->id);
     $html = "<div id=\"categoriestoassignstyle\" class=\"categoriestoassignstyle\">";
     $select_cat_class = 'select-cat';
     $html .= '<div class="btn-group pull-left">';
     $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', !jQuery(this).is(\':checked\')); });">' . JText::_('JGLOBAL_SELECTION_INVERT') . '</button>';
     $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) { jQuery(this).prop(\'checked\', false); });">' . JText::_('JGLOBAL_SELECTION_NONE') . '</button>';
     $html .= '<button type="button" class="btn btn-mini" onclick="jQuery(\'.' . $select_cat_class . '\').each(function(el) {  jQuery(this).prop(\'checked\', true); });">' . JText::_('JGLOBAL_SELECTION_ALL') . '</button>';
     $html .= '</div>';
     $html .= "<ul class=\"nav\" id=\"" . $this->id . "\">";
     foreach ($categoryTree as $category) {
         $html .= "<li>";
         $cat_style_id = "";
         if ($category->id == 1) {
             $cat_style_id = $category->style_id;
             $inherit = "";
         } elseif ($category->style_id == $style_id) {
             $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "' checked>";
             $cat_style_id = $style_id;
             $inherit = "";
         } elseif ($category->style_id == -1) {
             $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "'";
             $db->setQuery("SELECT id FROM #__judirectory_categories WHERE lft <" . $category->lft . " AND rgt > " . $category->rgt);
             $parentCatIds = $db->loadColumn();
             $parentCatIds = array_reverse($parentCatIds);
             if (is_array($catIds) && !empty($catIds)) {
                 foreach ($parentCatIds as $parentCatId) {
                     if (in_array($parentCatId, $catIds)) {
                         $html .= " checked";
                     }
                 }
             }
             $html .= ">";
             foreach ($parentCatIds as $parentCatId) {
                 $styleId = $this->getStyleIdByCategoryId($parentCatId);
                 if ($styleId > -1 || $styleId == -2) {
                     $cat_style_id = $styleId;
                     break;
                 }
             }
             $inherit = "<span class=\"inherited-value\" title=\"" . JText::_("COM_JUDIRECTORY_INHERIT") . "\">" . JText::_("COM_JUDIRECTORY_INHERIT") . "</span>";
         } elseif ($category->style_id == -2) {
             $html .= "<input type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "'>";
             $inherit = "";
             $db->setQuery("SELECT id FROM #__judirectory_template_styles WHERE home = 1");
             $cat_style_id = $db->loadResult();
         } else {
             $html .= "<input class =\"" . $select_cat_class . "\" id=\"catid-" . $category->id . "\" type='checkbox' name='" . $this->name . "[]' value = '" . $category->id . "' />";
             $inherit = "";
             $cat_style_id = $category->style_id;
         }
         if ($cat_style_id == -2) {
             $style_title = $this->getStyleTitle(0, true);
         } else {
             $style_title = $this->getStyleTitle($cat_style_id);
         }
         $style_title = $style_title ? " [" . $style_title . "] " : "";
         $html .= "<label for=\"catid-" . $category->id . "\">" . str_repeat('<span class="gi">|—</span>', $category->level);
         if ($category->id == 1) {
             $html .= $category->title;
         } else {
             $html .= "<a href=\"" . JRoute::_('index.php?option=com_judirectory&task=category.edit&id=' . $category->id) . "\">" . $category->title . "</a>";
         }
         $html .= " <span class=\"style-title\">" . $style_title . "</span>" . $inherit . "</label>";
         $html .= "</li>";
     }
     $html .= "</ul>";
     $html .= "</div>";
     return $html;
 }
示例#4
0
 public static function getFieldGroupsByCatIds($catIds, $search_sub_categories = false)
 {
     if (!$catIds) {
         return null;
     }
     $field_groups = array();
     foreach ($catIds as $catId) {
         if ($search_sub_categories) {
             $categoryTree = JUDirectoryHelper::getCategoryTree($catId, true, true);
             foreach ($categoryTree as $sub_category) {
                 if ($sub_category->fieldgroup_id > 0) {
                     $field_groups[] = $sub_category->fieldgroup_id;
                 }
             }
         } else {
             $catObj = JUDirectoryHelper::getCategoryById($catId);
             $field_groups[] = $catObj->fieldgroup_id ? $catObj->fieldgroup_id : 1;
         }
     }
     $field_groups = array_unique($field_groups);
     if ($field_groups) {
         return implode(",", $field_groups);
     } else {
         return null;
     }
 }