public function getInput()
    {
        $categories = JUDirectoryHelper::getCatsByLevel(1);
        $rootCategory = JUDirectoryFrontHelperCategory::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('#__judirectory_categories AS c');
            $query->join('', '#__judirectory_emails_xref AS exref ON (exref.cat_id = c.id)');
            $query->join('', '#__judirectory_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;
    }
示例#2
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 = JUDirectoryHelper::getCatsByLevel(1);
     if ($categories) {
         foreach ($categories as $category) {
             $options[] = JHtml::_('select.option', $category->id, $category->title);
         }
     }
     return $options;
 }
示例#3
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 = JUDirectoryHelper::getCatsByLevel(1, $id);
                 break;
             case 'listing':
                 $catId = JUDirectoryFrontHelperCategory::getMainCategoryId($id);
                 $topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $catId);
                 break;
         }
         if (!empty($topLevelCats)) {
             $topLevelCat = $topLevelCats[0];
             if ($view == 'category' || $view == 'listing') {
                 JUDirectoryFrontHelperLanguage::loadLanguageFile('com_judirectory_' . $topLevelCat->id, JPATH_SITE);
             }
         }
     }
     return;
 }
示例#4
0
 public function display($tpl = null)
 {
     $this->item = $this->get('Item');
     if (!JUDirectoryFrontHelperPermission::canViewListing($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_JUDIRECTORY_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['judir_recently_viewed_listings'])) {
         $recently_viewed_listing_array = explode(',', $_COOKIE['judir_recently_viewed_listings']);
         $recently_viewed_listing_array = array_unique($recently_viewed_listing_array);
         $key = array_search($this->item->id, $recently_viewed_listing_array);
         if ($key !== false) {
             unset($recently_viewed_listing_array[$key]);
         } else {
             if ($limitStart == 0) {
                 $this->model->updateHits($this->item->id);
             }
         }
         $maxListings = $this->params->get('max_recently_viewed_listings', 12);
         if (count($recently_viewed_listing_array) >= $maxListings) {
             $recently_viewed_listing_array = array_slice($recently_viewed_listing_array, 0, $maxListings - 1);
         }
         array_unshift($recently_viewed_listing_array, $this->item->id);
         $recently_viewed_listing_array = implode(',', $recently_viewed_listing_array);
         setcookie('judir_recently_viewed_listings', $recently_viewed_listing_array, time() + 3600 * 24 * 15, $cookie_path, $cookie_domain);
     } else {
         if ($limitStart == 0) {
             $this->model->updateHits($this->item->id);
         }
         setcookie('judir_recently_viewed_listings', $this->item->id, time() + 3600 * 24 * 15, $cookie_path, $cookie_domain);
     }
     $topLevelCats = JUDirectoryHelper::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 (JUDIRPROVERSION && $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_judirectory.listing';
     $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('onBeforeDisplayJUDIRComment', array($context, &$this->item, &$this->item->params, $limitStart));
     $this->item->event->beforeDisplayJUDIRComment = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onAfterDisplayJUDIRComment', array($context, &$this->item, &$this->item->params, $limitStart));
     $this->item->event->afterDisplayJUDIRComment = trim(implode("\n", $results));
     $this->_prepareData();
     $this->_prepareDocument();
     $this->_setBreadcrumb();
     parent::display($tpl);
 }
示例#5
0
 public static function getMenuItemIdArrayOfViewCategoryTreeLevel0And1()
 {
     $menuItemIdsOfViewCategoryTree = self::getMenuItemIdArrayOfViewCategoryTree();
     $menuItemIds = array();
     $categoryObjectListLevel1 = JUDirectoryHelper::getCatsByLevel();
     if ($categoryObjectListLevel1) {
         foreach ($categoryObjectListLevel1 as $categoryObjectLevel1) {
             if (isset($menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id])) {
                 $menuItemIds[$categoryObjectLevel1->id] = $menuItemIdsOfViewCategoryTree[$categoryObjectLevel1->id];
             }
         }
         $categoryRoot = JUDirectoryFrontHelperCategory::getRootCategory();
         if (isset($menuItemIdsOfViewCategoryTree[$categoryRoot->id])) {
             $menuItemIds[$categoryRoot->id] = $menuItemIdsOfViewCategoryTree[$categoryRoot->id];
         }
     }
     return $menuItemIds;
 }
示例#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 = JUDirectoryFrontHelperCategory::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 (!JUDirectoryFrontHelperPermission::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_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_ACCESS_THIS_PAGE'), 'warning');
             return false;
         }
     }
     $topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $categoryId);
     if (is_array($topLevelCats) && count($topLevelCats) > 0) {
         $this->tl_catid = $topLevelCats[0]->id;
     }
     $this->category = JUDirectoryFrontHelperCategory::getCategory($categoryId);
     $this->show_feed = JUDIRPROVERSION ? $this->params->get('rss_display_icon', 1) : 0;
     $this->rss_link = JRoute::_(JUDirectoryHelperRoute::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) . '/' . JUDirectoryFrontHelper::getDirectory('category_detail_image_directory', 'media/com_judirectory/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 = JUDirectoryFrontHelperString::truncateHtml($this->category->description, $categoryDescLimit);
     }
     if ($this->params->get('plugin_support', 0)) {
         $this->category->description = JHtml::_('content.prepare', $this->category->description, '', 'com_judirectory.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) . '/' . JUDirectoryFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judirectory/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 = JUDirectoryFrontHelperString::truncateHtml($relatedCategory->introtext, $relatedCategoryDescLimit);
                 }
                 if ($params->get('plugin_support', 0)) {
                     $relatedCategory->introtext = JHtml::_('content.prepare', $relatedCategory->introtext, '', 'com_judirectory.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) . '/' . JUDirectoryFrontHelper::getDirectory('category_intro_image_directory', 'media/com_judirectory/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 = JUDirectoryFrontHelperString::truncateHtml($subCategory->introtext, $subCategoryDescLimit);
                 }
                 if ($this->params->get('plugin_support', 0)) {
                     $subCategory->introtext = JHtml::_('content.prepare', $subCategory->introtext, '', 'com_judirectory.category');
                 }
             } else {
                 $subCategory->introtext = '';
             }
         }
     }
     $this->category->can_submit_listing = JUDirectoryFrontHelperPermission::canSubmitListing($this->category->id);
     if ($this->category->can_submit_listing && $this->params->get('show_submit_listing_btn_in_category', 1)) {
         $this->category->submit_listing_link = JUDirectoryFrontHelperListing::getAddListingLink($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) {
             $item->report_link = JRoute::_(JUDirectoryHelperRoute::getReportListingRoute($item->id));
             $item->claim_link = JRoute::_(JUDirectoryHelperRoute::getClaimListingRoute($item->id));
             if ($item->checked_out > 0 && $item->checked_out != $user->get('id')) {
                 if (JUDirectoryFrontHelperPermission::canCheckInListing($item->id)) {
                     $item->checkin_link = JRoute::_('index.php?option=com_judirectory&task=forms.checkin&id=' . $item->id . '&' . JSession::getFormToken() . '=1' . '&return=' . base64_encode(urlencode($uri)));
                 }
             } else {
                 $item->edit_link = JRoute::_('index.php?option=com_judirectory&task=form.edit&id=' . $item->id . '&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
                 if ($item->published == 1) {
                     $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.unpublish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
                 } else {
                     $item->editstate_link = JRoute::_('index.php?option=com_judirectory&task=forms.publish&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
                 }
             }
             $item->delete_link = JRoute::_('index.php?option=com_judirectory&task=forms.delete&id=' . $item->id . '&return=' . base64_encode(urlencode($uri)) . '&' . JSession::getFormToken() . '=1&Itemid=' . JUDirectoryHelperRoute::findItemIdOfListing($item->id));
             $dispatcher = JDispatcher::getInstance();
             JPluginHelper::importPlugin('content');
             $item->event = new stdClass();
             $context = 'com_judirectory.listing_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');
         //print_r($this->pagination);
     }
     $this->locations = JUDirectoryFrontHelper::getLocations($this->items);
     //print_r($this->locations);
     $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx'));
     $this->_prepareData();
     $this->_prepareDocument();
     $this->_setBreadcrumb();
     parent::display($tpl);
 }