Example #1
0
 public static function replaceIgnore($search, $replace, $subject, $pos = 0)
 {
     if ($pos == 0) {
         $pos = strpos($subject, $search);
     } else {
         $pos = strpos($subject, $search, $pos);
     }
     $canReplace = true;
     $ignoredArr = array('href="', 'href=\'', 'src="', 'src=\'', 'alt="', 'alt=\'', 'data-mce-src="', 'data-mce-src=\'');
     foreach ($ignoredArr as $value) {
         $valueLength = strlen($value);
         $subStr = substr($subject, $pos - $valueLength, $valueLength);
         if ($subStr == $value) {
             $canReplace = false;
             break;
         }
     }
     if ($pos !== false && $pos < strlen($subject)) {
         if ($canReplace == true) {
             $subject = substr_replace($subject, $replace, $pos, strlen($search));
             $pos = $pos + strlen($replace);
         } else {
             $pos = $pos + strlen($search);
         }
         $subject = JUDirectoryFrontHelperString::replaceIgnore($search, $replace, $subject, $pos);
     }
     return $subject;
 }
Example #2
0
 public static function parseCommentText($str, $listingId = null)
 {
     $params = JUDirectoryHelper::getParams(null, $listingId);
     $auto_link_url_in_comment = $params->get('auto_link_url_in_comment', 1);
     $trim_long_url_in_comment = $params->get('trim_long_url_in_comment', 0);
     $front_portion_url_in_comment = $params->get('front_portion_url_in_comment', 0);
     $back_portion_url_in_comment = $params->get('back_portion_url_in_comment', 0);
     $str = JUDirectoryFrontHelperComment::autoLinkVideo($str, $listingId);
     if ($auto_link_url_in_comment) {
         if ($params->get('nofollow_link_in_comment', 1)) {
             $noFollow = 'rel="nofollow"';
         } else {
             $noFollow = '';
         }
         $regex = "#http(?:s)?:\\/\\/(?:www\\.)?[\\.0-9a-z]{1,255}(\\.[a-z]{2,4}){1,2}([\\/\\?][^\\s]{1,}){0,}[\\/]?#i";
         preg_match_all($regex, $str, $matches);
         $matches = array_unique($matches[0]);
         if (count($matches) > 0) {
             foreach ($matches as $url) {
                 $shortenUrl = urldecode($url);
                 if ($trim_long_url_in_comment > 0 && strlen($shortenUrl) > $trim_long_url_in_comment) {
                     if ($front_portion_url_in_comment > 0 || $back_portion_url_in_comment > 0) {
                         $frontStr = $front_portion_url_in_comment > 0 ? substr($shortenUrl, 0, $front_portion_url_in_comment) : "";
                         $backStr = $back_portion_url_in_comment > 0 ? substr($shortenUrl, (int) (0 - $back_portion_url_in_comment)) : "";
                         $shortenUrl = $frontStr . '...' . $backStr;
                     }
                     $shortenUrl = '<a ' . $noFollow . ' href="' . $url . '">' . $shortenUrl . '</a> ';
                     $str = str_replace(trim($url), $shortenUrl, $str);
                     $str = JUDirectoryFrontHelperString::replaceIgnore(trim($url), $shortenUrl, $str);
                 } else {
                     $str = JUDirectoryFrontHelperString::replaceIgnore($url, '<a ' . $noFollow . ' href="' . $url . '">' . trim($shortenUrl) . '</a> ', $str);
                 }
             }
         }
     }
     $forbidden_words = array_map('trim', explode(",", strtolower(str_replace("\n", ",", $params->get('forbidden_words', '')))));
     if (trim($params->get('forbidden_words', '')) && count($forbidden_words)) {
         $forbidden_words_replaced_by = $params->get('forbidden_words_replaced_by', '***');
         foreach ($forbidden_words as $val) {
             $str = preg_replace('#' . $val . '#ism', $forbidden_words_replaced_by, $str);
         }
     }
     return $str;
 }
 public function getOutput($options = array())
 {
     if (!$this->isPublished()) {
         return "";
     }
     if (!$this->value) {
         return "";
     }
     $options = (array) $options;
     if ($this->isDetailsView($options)) {
         if ($this->params->get("show_introtext_in_details_view", 1)) {
             $description = $this->value;
         } else {
             $description = $this->listing->fulltext;
         }
         if ($this->params->get("strip_tags_details_view", 0)) {
             $allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
             $allowable_tags = str_replace(' ', '', $allowable_tags);
             $allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
             $description = strip_tags($description, $allowable_tags);
         }
         if ($this->params->get("parse_plugin", 0)) {
             $description = JHtml::_('content.prepare', $description);
         }
         if ($this->params->get("auto_link", 1)) {
             $trim_long_url = $this->params->get('trim_long_url', 0);
             $front_portion_url = $this->params->get('front_portion_url', 0);
             $back_portion_url = $this->params->get('back_portion_url', 0);
             $regex = "#http(?:s)?:\\/\\/(?:www\\.)?[\\.0-9a-z]{1,255}(\\.[a-z]{2,4}){1,2}([\\/\\?][^\\s]{1,}){0,}[\\/]?#i";
             preg_match_all($regex, $description, $matches);
             $matches = array_unique($matches[0]);
             if (count($matches) > 0) {
                 foreach ($matches as $url) {
                     $shortenUrl = urldecode($url);
                     if ($trim_long_url > 0 && strlen($shortenUrl) > $trim_long_url) {
                         if ($front_portion_url > 0 || $back_portion_url > 0) {
                             $frontStr = $front_portion_url > 0 ? substr($shortenUrl, 0, $front_portion_url) : "";
                             $backStr = $back_portion_url > 0 ? substr($shortenUrl, (int) (0 - $back_portion_url)) : "";
                             $shortenUrl = $frontStr . '...' . $backStr;
                         }
                         $shortenUrl = '<a href="' . $url . '">' . $shortenUrl . '</a> ';
                         $description = str_replace(trim($url), $shortenUrl, $description);
                         $description = JUDirectoryFrontHelperString::replaceIgnore(trim($url), $shortenUrl, $description);
                     } else {
                         $description = JUDirectoryFrontHelperString::replaceIgnore($url, '<a href="' . $url . '">' . trim($shortenUrl) . '</a> ', $description);
                     }
                 }
             }
         }
         if ($this->params->get("nl2br_details_view", 0)) {
             $description = nl2br($description);
         }
     } else {
         $description = $this->listing->introtext;
         if ($this->params->get("strip_tags_list_view", 1)) {
             $allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
             $allowable_tags = str_replace(' ', '', $allowable_tags);
             $allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
             $description = strip_tags($description, $allowable_tags);
         }
         if ($this->params->get("use_html_entities", 0)) {
             $description = htmlentities($description);
         }
         $isTruncated = false;
         if ($this->params->get("truncate", 1)) {
             if ($this->params->get("limit_char_in_list_view", 200) < strlen($description)) {
                 $isTruncated = true;
             }
             $description = JUDirectoryFrontHelperString::truncateHtml($description, $this->params->get("limit_char_in_list_view", 200));
         }
         if ($this->params->get("parse_plugin", 0)) {
             $description = JHtml::_('content.prepare', $description);
         }
         if ($this->params->get("show_readmore", 0)) {
             if ($this->params->get("show_readmore_when", 1) == 2 || $this->params->get("show_readmore_when", 1) == 1 && $isTruncated) {
                 $description .= ' <a class="readmore" href="' . JRoute::_(JUDirectoryHelperRoute::getListingRoute($this->listing_id)) . '">' . $this->params->get("readmore_text", 'Read more...') . '</a>';
             }
         }
     }
     $this->setVariable('value', $description);
     return $this->fetch('output.php', __CLASS__);
 }
				<?php 
    $totalSubCats = JUDirectoryFrontHelper::getTotalInsideCategories($subcategory->id);
    $totalListings = JUDirectoryFrontHelper::getTotalListingInCategory($subcategory->id);
    ?>
				<span><?php 
    echo "(" . $totalSubCats . " Subcategory /" . $totalListings . " Listing)";
    ?>
</span>
			</div>

			<?php 
    if ($this->params->get('show_subcategories_introtext', 1)) {
        $cat_introtext_limit = (int) $this->params->get('categories_introtext_limit', 1);
        if ($cat_introtext_limit == 1) {
            $cat_introtext_limit_char = (int) $this->params->get('categories_introtext_limit_character', 1500);
            $cat_introtext = JUDirectoryFrontHelperString::truncateHtml($subcategory->introtext, $cat_introtext_limit_char);
        } else {
            $cat_introtext = $subcategory->introtext;
        }
        ?>
				<div class="subcat-desc">
					<?php 
        if ($this->params->get('plugin_support', 0)) {
            echo JHtml::_('content.prepare', $cat_introtext);
        } else {
            echo $cat_introtext;
        }
        ?>
				</div>
			<?php 
    }
Example #5
0
 public function getOutput($options = array())
 {
     if (!$this->isPublished()) {
         return "";
     }
     if (!$this->value) {
         return "";
     }
     $value = $this->value;
     if ($this->isDetailsView($options)) {
         if ($this->params->get("strip_tags_details_view", 0)) {
             $allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
             $allowable_tags = str_replace(' ', '', $allowable_tags);
             $allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
             $value = strip_tags($value, $allowable_tags);
         }
         if ($this->params->get("parse_plugin", 0)) {
             $value = JHtml::_('content.prepare', $value);
         }
         if ($this->params->get("nl2br_details_view", 0)) {
             $value = nl2br($value);
         }
         if ($this->params->get("auto_link", 1)) {
             $trim_long_url = $this->params->get('trim_long_url', 0);
             $front_portion_url = $this->params->get('front_portion_url', 0);
             $back_portion_url = $this->params->get('back_portion_url', 0);
             $regex = "#http(?:s)?:\\/\\/(?:www\\.)?[\\.0-9a-z]{1,255}(\\.[a-z]{2,4}){1,2}([\\/\\?][^\\s]{1,}){0,}[\\/]?#i";
             preg_match_all($regex, $value, $matches);
             $matches = array_unique($matches[0]);
             if (count($matches) > 0) {
                 if ($this->params->get('nofollow_link', 1)) {
                     $noFollow = 'rel="nofollow"';
                 } else {
                     $noFollow = '';
                 }
                 foreach ($matches as $url) {
                     $shortenUrl = urldecode($url);
                     if ($trim_long_url > 0 && strlen($shortenUrl) > $trim_long_url) {
                         if ($front_portion_url > 0 || $back_portion_url > 0) {
                             $frontStr = $front_portion_url > 0 ? substr($shortenUrl, 0, $front_portion_url) : "";
                             $backStr = $back_portion_url > 0 ? substr($shortenUrl, (int) (0 - $back_portion_url)) : "";
                             $shortenUrl = $frontStr . '...' . $backStr;
                         }
                         $shortenUrl = '<a ' . $noFollow . ' href="' . $url . '">' . $shortenUrl . '</a> ';
                         $value = str_replace(trim($url), $shortenUrl, $value);
                         $value = JUDirectoryFrontHelperString::replaceIgnore(trim($url), $shortenUrl, $value);
                     } else {
                         $value = JUDirectoryFrontHelperString::replaceIgnore($url, '<a ' . $noFollow . ' href="' . $url . '">' . trim($shortenUrl) . '</a> ', $value);
                     }
                 }
             }
         }
     } else {
         if ($this->params->get("strip_tags_list_view", 1)) {
             $allowable_tags = $this->params->get("allowable_tags", "u,b,i,a,ul,li,pre,blockquote,strong,em");
             $allowable_tags = str_replace(' ', '', $allowable_tags);
             $allowable_tags = "<" . str_replace(',', '><', $allowable_tags) . ">";
             $value = strip_tags($value, $allowable_tags);
         }
         if ($this->params->get("use_html_entities", 0)) {
             $value = htmlentities($value);
         }
         if ($this->params->get("truncate", 1)) {
             $value = JUDirectoryFrontHelperString::truncateHtml($value, $this->params->get("limit_char_in_list_view", 200));
         }
         if ($this->params->get("parse_plugin", 0)) {
             $value = JHtml::_('content.prepare', $value);
         }
     }
     $this->setVariable('value', $value);
     return $this->fetch('output.php', __CLASS__);
 }
Example #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);
 }