public static function getCaptcha($hiddenCaptcha = false, $captchaNameSpaceValue = null, $label = true, $name = "security_code", $id = "security_code", $captchaNameSpaceName = "captcha_namespace") { $document = JFactory::getDocument(); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/captcha.js"); $params = JUDirectoryHelper::getParams(); $captchaNameSpaceValue = !$captchaNameSpaceValue ? md5(time()) : $captchaNameSpaceValue; $html = ''; if ($label) { $html .= '<div class="control-group">'; $html .= '<label class="control-label" for="' . $id . '">' . JText::_('COM_JUDIRECTORY_CAPTCHA') . '<span class="required" style="color: red">*</span></label>'; $html .= '<div class="controls">'; } $html .= '<div class="judir-captcha pull-left">'; $html .= '<div class="clearfix">'; if ($hiddenCaptcha == false) { $html .= '<img class="captcha-image" alt="' . JText::_('COM_JUDIRECTORY_CAPTCHA') . '" src="' . JUri::root(true) . '/index.php?option=com_judirectory&task=captcha&captcha_namespace=' . $captchaNameSpaceValue . '&tmpl=component" width="' . $params->get('captcha_width', '155') . 'px" height="' . $params->get('captcha_height', '50') . 'px"/>'; } else { $html .= '<img class="captcha-image" alt="' . JText::_('COM_JUDIRECTORY_CAPTCHA') . '" src="" width="' . $params->get('captcha_width', '155') . 'px" height="' . $params->get('captcha_height', '50') . 'px"/>'; } $html .= '<input type="hidden" class="captcha-namespace" name="' . $captchaNameSpaceName . '" value="' . $captchaNameSpaceValue . '" />'; $html .= '</div>'; $html .= '<div class="input-group input-group-sm">'; $html .= '<input type="text" id="' . $id . '" name="' . $name . '" class="security_code form-control required" autocomplete="off"/>'; $html .= '<span class="input-group-addon btn btn-default reload-captcha" title="' . JText::_('COM_JUDIRECTORY_RELOAD_CAPTCHA') . '"><i class="fa fa-refresh" ></i></span>'; $html .= '</div>'; $html .= '</div>'; if ($label) { $html .= '</div>'; $html .= '</div>'; } return $html; }
public function canView($options = array()) { $storeId = md5(__METHOD__ . "::" . $this->listing_id . "::" . $this->id . "::" . serialize($options)); if (!isset(self::$cache[$storeId])) { if (!$this->isPublished()) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } if (isset($this->listing) && $this->listing->cat_id) { $params = JUDirectoryHelper::getParams($this->listing->cat_id); } else { $params = JUDirectoryHelper::getParams(null, $this->listing_id); } $show_empty_field = $params->get('show_empty_field', 0); if ($this->listing_id && !$show_empty_field) { if (intval($this->value) == 0) { self::$cache[$storeId] = false; return self::$cache[$storeId]; } } self::$cache[$storeId] = parent::canView($options); return self::$cache[$storeId]; } return self::$cache[$storeId]; }
protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $pk = $app->input->getInt('id', 0); $this->setState('tag.id', $pk); $params = JUDirectoryHelper::getParams(); $this->setState('params', $params); if ($this->context) { $listingPagination = $params->get('listing_pagination', 10); $limitArray = JUDirectoryFrontHelper::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', $listingPagination, 'uint'); } else { $limit = $listingPagination; } } else { $limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $listingPagination, '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); } }
protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $catId = $app->input->getInt('id', 1); $params = JUDirectoryHelper::getParams($catId); $this->setState('params', $params); }
public function display($tpl = null) { $this->user = JFactory::getUser(); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->authors = $this->get('Authors'); $this->params = JUDirectoryHelper::getParams(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $levelOptions = array(); $levelOptions[] = JHtml::_('select.option', 5, 5); $levelOptions[] = JHtml::_('select.option', 10, 10); $levelOptions[] = JHtml::_('select.option', 15, 15); $levelOptions[] = JHtml::_('select.option', 20, 20); $levelOptions[] = JHtml::_('select.option', 25, 25); $levelOptions[] = JHtml::_('select.option', 30, 30); $this->levelOptions = $levelOptions; $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $app = JFactory::getApplication(); $this->function = $app->input->get('function', 'jSelectListing'); $this->totalListings = $this->get('Total'); $this->_prepareDocument(); parent::display($tpl); }
public static function getDefaultAvatar($params = null) { if (!$params) { $params = JUDirectoryHelper::getParams(); } $linkAvatar = $src = JUri::root(true) . "/" . JUDirectoryFrontHelper::getDirectory("avatar_directory", "media/com_judirectory/images/avatar/", true) . "default/" . $params->get('default_avatar', 'default-avatar.png'); $avatar_source = $params->get('avatar_source', 'juavatar'); if ($avatar_source == 'gavatar') { $linkAvatar = self::getGAvatar(); } return $linkAvatar; }
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); $params = JUDirectoryHelper::getParams(); $this->setState('params', $params); parent::populateState('listing.title', 'asc'); $field_display = $this->getUserStateFromRequest($this->context . '.field_display', 'field_display', array()); $this->setState('field_display', $field_display); }
public function display($tpl = null) { $this->params = JUDirectoryHelper::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); }
protected function getInput() { $params = JUDirectoryHelper::getParams(); $max_upload = ini_get('upload_max_filesize'); $src = JUri::root() . JUDirectoryFrontHelper::getDirectory("collection_icon_directory", "media/com_judirectory/images/collection/", true) . $this->value; $html = "<div class=\"avatar\" style=\"float: left;\">"; if ($this->value) { $html .= "<div class=\"clearfix\"><img src=\"" . $src . "\" width=\"" . $params->get('collection_icon_width', 100) . "px\" height=\"" . $params->get('collection_icon_height', 100) . "px\" /></div>"; $html .= "<label><input type=\"checkbox\" name=\"remove_icon\" value=\"1\" /> " . JText::_('COM_JUDIRECTORY_REMOVE_ICON') . "</label>"; } $html .= "<div class=\"clearfix\"><input type=\"file\" name=\"collection_icon\" id=\"" . $this->id . "\" />"; $html .= "<input type=\"hidden\" name=\"" . $this->name . "\" value=\"" . $this->value . "\" /></div>"; $html .= "<div class=\"clearfix\"><i>" . JText::_('COM_JUDIRECTORY_MAX_UPLOAD_FILESIZE') . " <strong>" . JUDirectoryHelper::formatBytes($this->convertBytes($max_upload)) . "</strong></i></div>"; $html .= "</div>"; return $html; }
public static function getWysibbEditor($jQuerySelector = '.wysibb', $returnJS = false, $readmore = false) { $params = JUDirectoryHelper::getParams(); $wysibbButtons['bold,'] = $params->get('bb_bold_tag', 'Bold'); $wysibbButtons['italic,'] = $params->get('bb_italic_tag', 'Italic'); $wysibbButtons['underline,'] = $params->get('bb_underline_tag', 'Underline'); $wysibbButtons['img,'] = $params->get('bb_img_tag', 'Picture'); $wysibbButtons['link,'] = $params->get('bb_link_tag', 'Link'); $wysibbButtons['video,'] = $params->get('bb_video_tag', 'Video'); $wysibbButtons['smilebox,'] = $params->get('bb_smilebox_tag', 'Smilebox'); $wysibbButtons['fontcolor,'] = $params->get('bb_color_tag', 'Colors'); $wysibbButtons['fontsize,'] = $params->get('bb_fontsize_tag', 'Fontsize'); $wysibbButtons['justifyleft,'] = $params->get('bb_align_left', 'alignleft'); $wysibbButtons['justifycenter,'] = $params->get('bb_align_center', 'aligncenter'); $wysibbButtons['justifyright,'] = $params->get('bb_align_right', 'alignright'); $wysibbButtons['bullist,'] = $params->get('bb_bulleted_list', 'Bulleted-list'); $wysibbButtons['numlist,'] = $params->get('bb_numeric_list', 'Numeric-list'); $wysibbButtons['quote,'] = $params->get('bb_quote_tag', 'Quotes'); if ($readmore == true) { $wysibbButtons['readmore,'] = $params->get('bb_readmore_tag', 'Readmore'); } $buttons = ''; $i = 0; foreach ($wysibbButtons as $key => $value) { if ($i % 3 == 0) { $buttons .= "|,"; } if ($value) { $buttons .= $key; } $i++; } $script = " jQuery(document).ready(function(\$){\n\t\t\t\t\t\tjudirWbbOpt.minCommentChar = " . (int) $params->get('min_comment_characters', 20) . ";\n\t\t\t\t\t\tjudirWbbOpt.maxCommentChar = " . (int) $params->get('max_comment_characters', 1000) . ";\n\t\t\t\t\t\tjudirWbbOpt.buttons = '{$buttons}';\n\t\t\t\t\t\tjudirWbbOpt.lang = 'en';\n\n\t\t\t\t\t\t\$('{$jQuerySelector}').wysibb(judirWbbOpt);\n\t\t\t\t\t}); "; if ($returnJS == true) { return '<script type="text/javascript">' . $script . '</script>'; } else { JText::script('COM_JUDIRECTORY_READMORE_WYSIBB_ALREADY_EXISTS'); JText::script('COM_JUDIRECTORY_PLEASE_ENTER_AT_LEAST_N_CHARACTERS'); JText::script('COM_JUDIRECTORY_CONTENT_LENGTH_REACH_MAX_N_CHARACTERS'); $document = JFactory::getDocument(); $document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/assets/wysibb/theme/default/wbbtheme.css"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/wysibb/jquery.wysibb.js"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/wysibb/override.jquery.wysibb.js"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/wysibb/preset/phpbb3.js"); $document->addScriptDeclaration($script); } }
protected function getValue() { $app = JFactory::getApplication(); if ($app->isSite() && isset($this->listing->total_comments) && !is_null($this->listing->total_comments)) { return $this->listing->total_comments; } $user = JFactory::getUser(); $db = JFactory::getDbo(); if ($app->isSite()) { $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judirectory_comments AS cm'); $query->where('listing_id =' . $this->listing_id); $query->where('level = 1'); $query->where('approved = 1'); $moderator = JUDirectoryFrontHelperModerator::getModerator($this->listing->cat_id); $getAll = false; if ($user->authorise('core.admin', 'com_judirectory')) { $getAll = true; } if (is_object($moderator)) { if ($moderator->comment_edit || $moderator->comment_edit_state || $moderator->comment_delete) { $getAll = true; } } if (!$getAll) { $query->where('published = 1'); $params = JUDirectoryHelper::getParams(null, $this->listing_id); $negative_vote_comment = $params->get('negative_vote_comment'); if (is_numeric($negative_vote_comment) && $negative_vote_comment > 0) { $query->where('(total_votes - helpful_votes) <' . $negative_vote_comment); } } } else { $query = $db->getQuery(true); $query->select('COUNT(*)'); $query->from('#__judirectory_comments AS cm'); $query->where('listing_id =' . $this->listing_id); $query->where('level = 1'); $query->where('approved = 1'); } $db->setQuery($query); $totalComments = $db->loadResult(); return $totalComments; }
public function display($tpl = null) { $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->params = JUDirectoryHelper::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_JUDIRECTORY_FIELD_ID'), 'tag.title' => JText::_('COM_JUDIRECTORY_FIELD_TITLE'), 'tag.created' => JText::_('COM_JUDIRECTORY_FIELD_CREATED'), 'tag.ordering' => JText::_('COM_JUDIRECTORY_FIELD_ORDERING')); $this->order_dir_array = array('ASC' => JText::_('COM_JUDIRECTORY_ASC'), 'DESC' => JText::_('COM_JUDIRECTORY_DESC')); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
public function display($tpl = null) { $this->items = $this->get('Items'); $this->params = JUDirectoryHelper::getParams(); $this->state = $this->get('State'); $this->pagination = $this->get('Pagination'); $this->root_comment = JUDirectoryFrontHelperComment::getRootComment(); if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->order_name_array = array('cm.title' => JText::_('COM_JUDIRECTORY_FIELD_TITLE'), 'cm.created' => JText::_('COM_JUDIRECTORY_FIELD_CREATED'), 'r.score' => JText::_('COM_JUDIRECTORY_FIELD_RATING_SCORE'), 'cm.helpful_votes' => JText::_('COM_JUDIRECTORY_FIELD_HELPFUL_VOTES'), 'cm.total_votes' => JText::_('COM_JUDIRECTORY_FIELD_TOTAL_VOTES')); $this->order_dir_array = array('ASC' => JText::_('COM_JUDIRECTORY_ASC'), 'DESC' => JText::_('COM_JUDIRECTORY_DESC')); $this->listOrder = $this->escape($this->state->get('list.ordering')); $this->listDirn = $this->escape($this->state->get('list.direction')); $this->_prepareDocument(); $this->_setBreadcrumb(); parent::display($tpl); }
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->model = $this->getModel(); $this->app = JFactory::getApplication(); $cat_id = $this->item->cat_id ? $this->item->cat_id : $this->app->input->get('cat_id'); $this->params = JUDirectoryHelper::getParams(null, $this->item->id); if ($cat_id == JUDirectoryFrontHelperCategory::getRootCategory()->id && !$this->params->get('allow_add_listing_to_root', 0)) { JError::raiseError(500, JText::_('COM_JUDIRECTORY_CAN_NOT_ADD_LISTING_TO_ROOT_CATEGORY')); return false; } if ($tempListing = JUDirectoryHelper::getTempListing($this->item->id)) { $editPendingListingLink = '<a href="index.php?option=com_judirectory&task=document.edit&approve=1&id=' . $tempListing->id . '">' . $tempListing->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDIRECTORY_THIS_LISTING_HAS_PENDING_LISTING_X_PLEASE_APPROVE_PENDING_LISTING_FIRST', $editPendingListingLink)); } if ($this->item->approved < 0) { $oriListingId = abs($this->item->approved); $oriListingObj = JUDirectoryHelper::getListingById($oriListingId); $editOriDocLink = '<a href="index.php?option=com_judirectory&task=document.edit&id=' . $oriListingId . '">' . $oriListingObj->title . '</a>'; JError::raiseNotice('', JText::sprintf('COM_JUDIRECTORY_ORIGINAL_LISTING_X', $editOriDocLink)); } $this->script = $this->get('Script'); $this->plugins = $this->get('Plugins'); $this->fieldLocations = $this->get('FieldLocations'); $this->fieldsetDetails = $this->model->getCoreFields('details'); $this->fieldsetPublishing = $this->model->getCoreFields('publishing'); $this->fieldsetTemplateStyleAndLayout = $this->model->getCoreFields('template_style'); $this->fieldsetMetadata = $this->model->getCoreFields('metadata'); $this->fieldCatid = JUDirectoryFrontHelperField::getField('cat_id', $this->item); $this->fieldGallery = $this->get('GalleryField'); $this->extraFields = $this->get('ExtraFields'); $this->fieldsData = $this->app->getUserState("com_judirectory.edit.listing.fieldsdata", array()); $this->relatedListings = $this->get('RelatedListings'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory', 'category', $this->item->cat_id); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
protected function getInput() { $params = JUDirectoryHelper::getParams(); $max_upload = ini_get('upload_max_filesize'); if ($this->value) { $src = JUri::root(true) . "/" . JUDirectoryFrontHelper::getDirectory("avatar_directory", "media/com_judirectory/images/avatar/", true) . $this->value; } else { $src = JUri::root(true) . "/" . JUDirectoryFrontHelper::getDirectory("avatar_directory", "media/com_judirectory/images/avatar/", true) . "default/" . $params->get('default_avatar', 'default-avatar.png'); } $html = '<div class="avatar" style="float: left;">'; $html .= '<div class="clearfix"><img src="' . $src . '" alt="Avatar" style="width:' . $params->get("avatar_width", 120) . 'px; height:' . $params->get("avatar_height", 120) . 'px;" /></div>'; if ($this->value) { $html .= '<label for="remove-avatar">' . JText::_("COM_JUDIRECTORY_REMOVE_AVATAR") . ' <input id="remove-avatar" type="checkbox" name="remove_avatar" value="1" /></label>'; } $html .= '<div class="clearfix"><input type="file" name="avatar" id="' . $this->id . '" />'; $html .= '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" /></div>'; $html .= '<div class="clearfix"><i>' . JText::_("COM_JUDIRECTORY_MAX_UPLOAD_FILESIZE") . ' <strong>' . JUDirectoryHelper::formatBytes($this->convertBytes($max_upload)) . '</strong></i></div>'; $html .= '</div>'; return $html; }
protected function populateState($ordering = null, $direction = null) { $app = JFactory::getApplication(); $params = JUDirectoryHelper::getParams(); if ($layout = $app->input->get('layout')) { $this->context .= '.' . $layout; } if ($this->context) { $listingPagination = $params->get('listing_pagination', 10); $limitArray = JUDirectoryFrontHelper::customLimitBox(); if (is_array($limitArray) && count($limitArray)) { $limit = $app->input->getInt('limit', 0); if (in_array($limit, $limitArray)) { $limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $listingPagination, 'uint'); } else { $limit = $listingPagination; } } else { $limit = $app->getUserStateFromRequest($this->context . '.list.limit', 'limit', $listingPagination, '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); $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); $category = $this->getUserStateFromRequest($this->context . '.filter.category', 'filter_catid'); $this->setState('filter.catid', $category); $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); $this->setState('filter.access', $access); $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published'); $this->setState('filter.published', $published); $featured = $this->getUserStateFromRequest($this->context . '.filter.featured', 'filter_featured'); $this->setState('filter.featured', $featured); } else { $this->setState('list.start', 0); $this->state->set('list.limit', 0); } }
public function display($cachable = false, $urlparams = false) { $app = JFactory::getApplication(); $cachable = true; $id = $app->input->getInt('id', 0); $vName = $app->input->getCmd('view', 'categories'); $app->input->set('view', $vName); $user = JFactory::getUser(); if ($user->get('id') || $_SERVER['REQUEST_METHOD'] == 'POST' && ($vName == 'category' && $app->input->get('layout') != 'blog' || $vName == 'archive')) { $cachable = false; } $safeurlparams = array('catid' => 'INT', 'id' => 'INT', 'cid' => 'ARRAY', 'year' => 'INT', 'month' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT', 'showall' => 'INT', 'return' => 'BASE64', 'filter' => 'STRING', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'filter-search' => 'STRING', 'print' => 'BOOLEAN', 'lang' => 'CMD', 'Itemid' => 'INT'); $params = JUDirectoryHelper::getParams(); if (!$user->authorise('core.admin', 'com_judirectory') && $params->get('activate_maintenance', 0) && $app->input->getString('view', '') != 'maintenance') { $this->setRedirect(JUDirectoryHelperRoute::getMaintenanceRoute()); } if ($vName == 'form' && $id > 0 && !$this->checkEditId('com_judirectory.edit.listing', $id)) { return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); } parent::display($cachable, $safeurlparams); return $this; }
protected function getInput() { $params = JUDirectoryHelper::getParams($this->form->getValue('id')); if ($this->element['directory'] == "intro") { $path = $params->get('category_intro_image_directory', 'media/com_judirectory/images/category/intro/'); $document = JFactory::getDocument(); $script = 'jQuery(document).ready(function($){ $("#use-detail-image").change(function(){ if($(this).is(":checked")){ $(this).parent().parent().find("input[type=\'file\']").attr("disabled", true); $(this).parent().parent().find("#remove-image-intro").prop("checked", false).attr("disabled", true); }else{ $(this).parent().parent().find("input[type=\'file\']").attr("disabled", false); $(this).parent().parent().find("#remove-image-intro").prop("checked", true).attr("disabled", false); } }); });'; $document->addScriptDeclaration($script); $html = '<input type="file" name="images[intro]" class="validate-images" />'; } else { $html = '<input type="file" name="images[detail]" class="validate-images" />'; $path = $params->get('category_detail_image_directory', 'media/com_judirectory/images/category/detail/'); } $html .= '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '" />'; if (!empty($this->value)) { $src = JUri::root() . $path . $this->value; $html .= '<label></label><img style="border: 5px solid #c0c0c0; max-width:100px; max-height:100px;" src="' . $src . '" />'; $html .= '<div><input id="remove-image-' . $this->element['directory'] . '" type="checkbox" name="remove_' . $this->id . '" value="1" style="float: left; margin-right: 5px;"/>'; $html .= '<label for="remove-image-' . $this->element['directory'] . '" >' . JText::_('COM_JUDIRECTORY_REMOVE_THIS_IMAGE') . '</label></div>'; } if ($this->element['directory'] == "intro") { $html .= '<div><input id="use-detail-image" type="checkbox" name="use_detail_image" value="1" style="float: left; margin-right: 5px;"/>'; $html .= '<label class="hasTip" title="' . JText::_('COM_JUDIRECTORY_USE_DETAIL_IMAGE_AS_INTRO_IMAGE') . '::' . JText::_('COM_JUDIRECTORY_USE_DETAIL_IMAGE_AS_INTRO_IMAGE_DESC') . '" for="use-detail-image">'; $html .= JText::_('COM_JUDIRECTORY_USE_DETAIL_IMAGE_AS_INTRO_IMAGE'); $html .= '</label></div>'; } return $html; }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $app = JFactory::getApplication(); $rootCat = JUDirectoryFrontHelperCategory::getRootCategory(); $fastAddError = $app->getUserState('com_judirectory.categories.fastadderror'); $fastAddSuccess = $app->getUserState('com_judirectory.categories.fastaddsuccess'); $this->cat_id = $app->input->getInt('cat_id', $rootCat->id); $this->params = JUDirectoryHelper::getParams($this->cat_id); $this->canDoCat = JUDirectoryHelper::getActions('com_judirectory', 'category', $this->cat_id); $this->rootCat = JUDirectoryFrontHelperCategory::getRootCategory(); $this->allowAddListing = $this->params->get('allow_add_listing_to_root', 0) && $this->cat_id == $this->rootCat->id || $this->cat_id != $this->rootCat->id; $this->listingGroupCanDoManage = $this->groupCanDoCatManage = JUDirectoryHelper::checkGroupPermission("listing.edit"); $this->listingGroupCanDoDelete = $this->groupCanDoCatDelete = JUDirectoryHelper::checkGroupPermission("listings.delete"); $this->catGroupCanDoManage = $this->groupCanDoCatManage = JUDirectoryHelper::checkGroupPermission("category.edit"); $this->catGroupCanDoDelete = $this->groupCanDoCatDelete = JUDirectoryHelper::checkGroupPermission("categories.delete"); // if ($fastAddSuccess) { $app->enqueueMessage($fastAddSuccess); $app->setUserState('com_judirectory.categories.fastaddsuccess', ''); } if ($fastAddError) { $app->enqueueMessage($fastAddError, 'error'); $app->setUserState('com_judirectory.categories.fastadderror', ''); } $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->model = $this->getModel(); $this->addToolBar(); $this->setDocument(); parent::display($tpl); }
public static function getAddListingLink($categoryId = null, $xhtml = true) { $app = JFactory::getApplication(); $menus = $app->getMenu('site'); $params = JUDirectoryHelper::getParams($categoryId); $itemId = 0; $assignItemId = $params->get('assign_itemid_to_submit_link', 'currentItemid'); switch (strtolower($assignItemId)) { default: case "currentitemid": $itemId = $app->input->getInt('Itemid', 0); break; case "listingsubmitmenuitemid": $component = JComponentHelper::getComponent('com_judirectory'); $menuItems = $menus->getItems('component_id', $component->id); foreach ($menuItems as $menuItem) { if (isset($menuItem->query) && $menuItem->query['view'] == 'form') { $itemId = $menuItem->id; break; } } break; case "predefineditemid": $predefinedItemId = (int) $params->get('predefined_itemid_for_submit_link', 0); if (is_object($menus->getItem($predefinedItemId))) { $itemId = $predefinedItemId; } else { $itemId = $app->input->getInt('Itemid', 0); } break; } $submitListingLink = 'index.php?option=com_judirectory&task=form.add'; if ($categoryId) { $submitListingLink .= '&cat_id=' . $categoryId; } if ($itemId) { $submitListingLink .= '&Itemid=' . $itemId; } return JRoute::_($submitListingLink, $xhtml); }
public static function canUploadTemplateFile($file, $err = '') { $params = JUDirectoryHelper::getParams(); if (empty($file['name'])) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_ERROR_UPLOAD_INPUT'), 'error'); return false; } $executable = array('exe', 'phtml', 'java', 'perl', 'py', 'asp', 'dll', 'go', 'jar', 'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp', 'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb', 'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh'); $explodedFileName = explode('.', $file['name']); if (count($explodedFileName > 2)) { foreach ($executable as $extensionName) { if (in_array($extensionName, $explodedFileName)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_ERROR_EXECUTABLE'), 'error'); return false; } } } jimport('joomla.filesystem.file'); if ($file['name'] !== JFile::makeSafe($file['name']) || preg_match('/\\s/', JFile::makeSafe($file['name']))) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_ERROR_WARNFILENAME'), 'error'); return false; } $format = strtolower(JFile::getExt($file['name'])); $imageTypes = explode(',', $params->get('template_image_formats', 'gif,bmp,jpg,jpeg,png')); $sourceTypes = explode(',', $params->get('template_source_formats', 'txt,less,ini,xml,js,php,css')); $fontTypes = explode(',', $params->get('template_font_formats', 'woff,ttf,otf')); $archiveTypes = explode(',', $params->get('template_compressed_formats', 'zip')); $allowable = array_merge($imageTypes, $sourceTypes, $fontTypes, $archiveTypes); if ($format == '' || $format == false || !in_array($format, $allowable)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_ERROR_WARNFILETYPE'), 'error'); return false; } if (in_array($format, $archiveTypes)) { $zip = new ZipArchive(); if ($zip->open($file['tmp_name']) === true) { for ($i = 0; $i < $zip->numFiles; $i++) { $entry = $zip->getNameIndex($i); $endString = substr($entry, -1); if ($endString != DIRECTORY_SEPARATOR) { $explodeArray = explode('.', $entry); $ext = end($explodeArray); if (!in_array($ext, $allowable)) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_FILE_UNSUPPORTED_ARCHIVE'), 'error'); return false; } } } } else { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_FILE_ARCHIVE_OPEN_FAIL'), 'error'); return false; } } $maxSize = (int) ($params->get('template_upload_limit', 2) * 1024 * 1024); if ($maxSize > 0 && (int) $file['size'] > $maxSize) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_ERROR_WARNFILETOOLARGE'), 'error'); return false; } $xss_check = file_get_contents($file['tmp_name'], false, null, -1, 256); $html_tags = array('abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', 'blockquote', 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', 'link', 'listing', 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', 'ol', 'optgroup', 'option', 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', 'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var', 'wbr', 'xml', 'xmp', '!DOCTYPE', '!--'); foreach ($html_tags as $tag) { if (stristr($xss_check, '<' . $tag . ' ') || stristr($xss_check, '<' . $tag . '>')) { $app = JFactory::getApplication(); $app->enqueueMessage(JText::_('COM_JUDIRECTORY_ERROR_WARNIEXSS'), 'error'); return false; } } return true; }
public static function getAllRatingScoresOfListing($listingId) { $params = JUDirectoryHelper::getParams(null, $listingId); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('r.score'); $query->from('#__judirectory_rating AS r'); $query->where('r.listing_id = ' . $listingId); $query->join('LEFT', '#__judirectory_comments AS cm ON r.id = cm.rating_id'); $query->where('(cm.approved = 1 OR cm.approved IS NULL)'); $query->where('r.user_id > 0'); if ($params->get('only_calculate_last_rating', 0)) { $subQuery = '(SELECT MAX(lastrated_tbl.created) FROM #__judirectory_rating AS lastrated_tbl WHERE r.user_id = lastrated_tbl.user_id)'; $query->where('(r.created = ' . $subQuery . ')'); $query->group('r.user_id, r.created'); } $db->setQuery($query); $userRating = $db->loadObjectList(); if (!is_array($userRating)) { $userRating = array(); } $query = $db->getQuery(true); $query->select('r.score'); $query->from('#__judirectory_rating AS r'); $query->where('r.listing_id = ' . $listingId); $query->join('LEFT', '#__judirectory_comments AS cm ON r.id = cm.rating_id'); $query->where('(cm.approved = 1 OR cm.approved IS NULL)'); $query->where('r.user_id = 0'); $db->setQuery($query); $guestRating = $db->loadObjectList(); if (!is_array($guestRating)) { $guestRating = array(); } $listingRatings = array_merge($userRating, $guestRating); return $listingRatings; }
public function getOutput($options = array()) { $this->loadDefaultAssets(); $document = JFactory::getDocument(); $value = $this->value ? addslashes(json_encode($this->value)) : ''; $app = JFactory::getApplication(); $params = JUDirectoryHelper::getParams(null, $this->listing_id); $isSite = $app->isSite() ? 'true' : 'false'; $view = $app->input->get('view'); $center = $params->get('map_center', '62.323907,-150.109291'); $center = explode(',', $center); $zoom = $params->get('map_zoom', '2'); $fitBoundMaxZoom = $params->get('map_fitbound_maxzoom', '13'); $script = 'jQuery(document).ready(function($){ $("#julocation-' . $this->listing_id . '").judirlocation({ id: ' . $this->id . ', data: "' . $value . '", isSite: ' . $isSite . ', view: "' . $view . '", JUriRoot: "' . JUri::root(true) . '", mapOptions: { zoom: ' . $zoom . ', center: {lat: ' . $center[0] . ', lng: ' . $center[1] . '}, fitBoundMaxZoom: ' . $fitBoundMaxZoom . ' }, markerUrl: "' . JUri::root(true) . '/media/com_judirectory/images/marker/" }); });'; $document->addScriptDeclaration($script); return $this->fetch('output.php', __CLASS__); }
protected function getLayout($items, $layout = null) { if ($layout == null) { $params = JUDirectoryHelper::getParams($this->form->getValue('id')); $layout = $params->get("layout_category", '_:default'); } if ($layout) { $layout = explode(":", $layout); if ($layout[0] == "_") { return "(Component > " . $items['_'][$layout[1]] . ")"; } else { return "({$layout['0']} > " . $items[$layout[0]][$layout[1]] . ")"; } } }
public function getInput($fieldValue = null) { if (!$this->isPublished()) { return ""; } $app = JFactory::getApplication(); if (isset($this->listing) && $this->listing->cat_id) { $params = JUDirectoryHelper::getParams($this->listing->cat_id); } else { $params = JUDirectoryHelper::getParams(null, $this->listing_id); } $document = JFactory::getDocument(); JUDirectoryFrontHelper::loadjQueryUI(); $document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/assets/css/tagit-style.css"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/tagit.js"); if ($app->isAdmin()) { $maxTags = "undefined"; } else { $maxTags = $params->get("max_tags_per_listing", 10) == 0 ? "undefined" : $params->get("max_tags_per_listing", 10); } if ($this->params->get("sortable", "handle") == "handle") { $sortable = '"handle"'; } else { $sortable = $this->params->get("sortable", "handle"); } $tagScript = ' jQuery(document).ready(function($){ $("#' . $this->getId() . '_tags").tagit({ tagSource:' . $this->getTags() . ', initialTags: ' . $this->getInitialTags($fieldValue) . ', tagsChanged: function(){ getTags($("#' . $this->getId() . '_tags").tagit("tags")); }, triggerKeys:["enter", "comma", "tab"], minLength: ' . $this->params->get("tag_min_length", 3) . ', maxLength: ' . $this->params->get("tag_max_length", 50) . ', maxTags: ' . $maxTags . ', sortable: ' . $sortable . ', placeholder: " ' . $this->params->get("sortable", "") . ' " }); function getTags(tags) { var newtags = []; for (var i in tags){ if (tags[i].label != undefined ){ var tagvalue = tags[i].value.replace("|", ""); newtags.push(tagvalue); $(tags[i].element[0]).find(".tagit-label").text(tagvalue); } } var newtags_str = newtags.join(","); $("#' . $this->getId() . '").val(newtags_str); } }); '; $document->addScriptDeclaration($tagScript); $tag_name_arr = array(); $value = ''; if (is_null($fieldValue)) { $tags = $this->value; if ($tags) { foreach ($tags as $tag) { $tag_name_arr[] = $tag->title; } $value = implode(',', $tag_name_arr); } } else { $value = $fieldValue; } $this->setVariable('value', $value); return $this->fetch('input.php', __CLASS__); }
public function check() { $app = JFactory::getApplication(); if ($app->isSite()) { $params = JUDirectoryHelper::getParams(null, $this->listing_id); $this->_comment_interval = $params->get('comment_interval', 60); if ($this->_comment_interval > 0) { $this->_comment_latest = strtotime($this->getLatestCommentTime()); } $this->_comment_interval_same_listing = $params->get('comment_interval_in_same_listing', 60); if ($this->_comment_interval_same_listing > 0) { $this->_comment_latest_same_listing = strtotime($this->getLatestCommentTime($this->listing_id)); } } if (!parent::check()) { $this->setError(JText::_('COM_JUDIRECTORY_COMMENT_FAILED')); return false; } return true; }
public function validateCriteria($data) { $listingId = $data['listing_id']; $params = JUDirectoryHelper::getParams(null, $listingId); $dataValid = array(); $canRateListing = JUDirectoryFrontHelperPermission::canRateListing($listingId); if ($canRateListing && $params->get('enable_listing_rate_in_comment_form', 1)) { $mainCatId = JUDirectoryFrontHelperCategory::getMainCategoryId($listingId); $criteriaArray = JUDirectoryFrontHelperCriteria::getCriteriasByCatId($mainCatId); $postCriteria = $data['criteria']; if (count($criteriaArray) > 0) { foreach ($criteriaArray as $key => $criteria) { if ($criteria->required) { if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) { $criteria->value = $postCriteria[$criteria->id]; } else { echo JText::_('Invalid Field ' . $criteria->title); exit; } } else { if (isset($postCriteria[$criteria->id]) && $postCriteria[$criteria->id] > 0 && $postCriteria[$criteria->id] <= 10) { $criteria->value = $postCriteria[$criteria->id]; } else { unset($criteriaArray[$key]); } } } $dataValid['criteria_array'] = $criteriaArray; } else { if ($params->get('require_listing_rate_in_comment_form', 1)) { if ($data['judir_comment_rating_single'] <= 0 && $data['judir_comment_rating_single'] > 10) { return false; } $dataValid['ratingValue'] = $data['judir_comment_rating_single']; } } } return $dataValid; }
public function canView($options = array()) { $params = JUDirectoryHelper::getParams(null, $this->listing_id); $default_image = JUDirectoryHelper::getDefaultListingImage(); if ($this->value == "" && $default_image) { $this->value = "default/" . $params->get('listing_default_image', 'default-listing.png'); } return parent::canView($options); }
protected static function autoLinkVideo($text, $listingId = null) { $params = JUDirectoryHelper::getParams(null, $listingId); $auto_embed_youtube_in_comment = $params->get('auto_embed_youtube_in_comment', 0); $auto_embed_vimeo_in_comment = $params->get('auto_embed_vimeo_in_comment', 0); $video_width_in_comment = $params->get('video_width_in_comment', 360); $video_height_in_comment = $params->get('video_height_in_comment', 240); $regexYoutube = "#(?:http(?:s)?:\\/\\/)?(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/(?:(?:watch)?\\?(?:.*&)?v(?:i)?=|(?:v|vi|user)\\/))([^\\?&\"'<>\\/\\s]+)(?:\$|\\/|\\?|\\&)?#i"; preg_match_all($regexYoutube, $text, $matchesYoutube); if ($auto_embed_youtube_in_comment && count($matchesYoutube[0])) { foreach ($matchesYoutube[0] as $key => $match) { $youtube_html = JUDirectoryFrontHelperComment::parseVideo($match, $video_width_in_comment, $video_height_in_comment); $text = str_replace($matchesYoutube[0][$key], $youtube_html . '<br/>', $text); } } $regexVimeo = "#(?:http(?:s)?:\\/\\/)?(?:www\\.)?vimeo.com\\/(\\d+)(?:\$|\\/|\\?)?#"; preg_match_all($regexVimeo, $text, $matchesVimeo); if ($auto_embed_vimeo_in_comment && count($matchesVimeo[0])) { $arrIdVimeo = array_unique($matchesVimeo[0]); foreach ($arrIdVimeo as $key => $match) { $vimeo_html = JUDirectoryFrontHelperComment::parseVideo($match, $video_width_in_comment, $video_height_in_comment); $text = str_replace($matchesVimeo[0][$key], $vimeo_html, $text); } } return $text; }
case 'category': // Load primary stylesheet $document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/templates/" . $self_template . "/assets/css/view.category.css"); // Load primary javascript $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/core.js"); $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/compare.js"); if ($this->getLayout() != 'list') { $document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/templates/" . $self_template . "/assets/css/view.listing-list.css"); $JUDIRTemplateDefaultHelper->loadTooltipster(); // Load switch mode view if ($this->allow_user_select_view_mode) { $document->addScript(JUri::root(true) . "/components/com_judirectory/assets/js/switch.js"); } } if ($this->params->get('category_show_map', 1) && $this->locations) { $params = JUDirectoryHelper::getParams($this->category->id); $zoom = $params->get('map_zoom', '2'); $center = $params->get('map_center', '62.323907,-150.109291'); $center = array_map('trim', explode(',', $center)); $fitBoundMaxZoom = $params->get('map_fitbound_maxzoom', '13'); $data = addslashes(json_encode($this->locations)); $script = 'jQuery(document).ready(function($){ $("#julocation").mapbrowse({ data: \'' . $data . '\', mapOptions:{ zoom: ' . $zoom . ', center: {lat: ' . $center[0] . ', lng: ' . $center[1] . '}, fitBoundMaxZoom: ' . $fitBoundMaxZoom . ' }, markerUrl : \'' . JUri::root(true) . '/media/com_judirectory/images/marker/\', JUriRoot: \'' . JUri::root(true) . '\'