function approve($comment_ids) { if (!is_array($comment_ids) || empty($comment_ids)) { $this->setError('COM_JUDIRECTORY_NO_ITEM_SELECTED'); return false; } JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables'); $comment_table = JTable::getInstance("Comment", "JUDirectoryTable"); $count = 0; $comment_ids = (array) $comment_ids; $rootComment = JUDirectoryFrontHelperComment::getRootComment(); $listingIds = array(); foreach ($comment_ids as $comment_id) { $comment_table->reset(); if ($comment_table->load($comment_id) && $comment_table->parent_id == $rootComment->id && $comment_table->approved == 0) { $listingIds[$comment_table->listing_id] = $comment_table->listing_id; } $user = JFactory::getUser(); $date = JFactory::getDate(); $comment_table->approved = 1; $comment_table->published = 1; $comment_table->approved_by = $user->id; $comment_table->approved_time = $date->toSql(); $comment_table->store(); $count++; JUDirectoryFrontHelperMail::sendEmailByEvent('comment.approve', $comment_id); $logData = array('user_id' => $comment_table->user_id, 'event' => 'comment.approve', 'item_id' => $comment_id, 'listing_id' => $comment_table->listing_id, 'value' => 0, 'reference' => ''); JUDirectoryFrontHelperLog::addLog($logData); } foreach ($listingIds as $listingId) { JUDirectoryHelper::rebuildRating($listingId); } return $count; }
protected function getOptions() { $app = JFactory::getApplication(); $view = $app->input->getCmd('view', ''); $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; } JLoader::register('JUDirectoryHelper', JPATH_ADMINISTRATOR . '/components/com_judirectory/helpers/judirectory.php', false); $checkPublished = $this->element['checkpublished'] == 'true' || $this->element['checkpublished'] == '1' ? true : false; $getSelf = $this->element['fetchself'] == 'true' || $this->element['fetchself'] == '1' ? true : false; $parentId = $this->element['parentid'] ? $this->element['parentid'] : 1; $startLevel = $this->element['startlevel'] ? $this->element['startlevel'] : 0; $separation = $this->element['separation'] ? $this->element['separation'] : '|—'; $ignoreaddress = $this->element['ignoreaddress'] ? explode(',', $this->element['ignoreaddress']) : array(); if ($view == 'address') { $addressId = $app->input->get('id', 0); $ignoreaddress = $addressId ? array($addressId) : array(); $_options = JUDirectoryHelper::getAddressOptions($parentId, $getSelf, $checkPublished, $ignoreaddress, $startLevel, $separation); } else { $_options = JUDirectoryHelper::getAddressOptions($parentId, $getSelf, $checkPublished, $ignoreaddress, $startLevel, $separation); } reset($options); $options = array_merge($options, $_options); return $options; }
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) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory'); $this->addToolBar(); if (JUDirectoryHelper::isJoomla3x()) { $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); } $options = array(); $options[] = JHtml::_('select.option', '1', JText::_('J1')); $options[] = JHtml::_('select.option', '2', JText::_('J2')); $options[] = JHtml::_('select.option', '3', JText::_('J3')); $options[] = JHtml::_('select.option', '4', JText::_('J4')); $options[] = JHtml::_('select.option', '5', JText::_('J5')); $options[] = JHtml::_('select.option', '6', JText::_('J6')); $options[] = JHtml::_('select.option', '7', JText::_('J7')); $options[] = JHtml::_('select.option', '8', JText::_('J8')); $options[] = JHtml::_('select.option', '9', JText::_('J9')); $options[] = JHtml::_('select.option', '10', JText::_('J10')); $this->f_levels = $options; $optionsPublished = array(); $optionsPublished[] = JHtml::_('select.option', '1', JText::_('COM_JUDIRECTORY_PUBLISHED')); $optionsPublished[] = JHtml::_('select.option', '0', JText::_('COM_JUDIRECTORY_UNPUBLISHED')); $this->published_options = $optionsPublished; parent::display($tpl); $this->setDocument(); }
public function rebuildCommentTree() { $model = $this->getModel(); JUDirectoryHelper::obCleanData(); echo $model->rebuildCommentTree(); exit; }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->state = $this->get('State'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory'); $this->groupCanDoManage = JUDirectoryHelper::checkGroupPermission("comment.edit"); $this->groupCanDoDelete = JUDirectoryHelper::checkGroupPermission("comments.delete"); $this->rootComment = JUDirectoryFrontHelperComment::getRootComment(); foreach ($this->items as &$item) { $this->ordering[$item->parent_id][] = $item->id; } $this->addToolBar(); if (JUDirectoryHelper::isJoomla3x()) { $layout = JFactory::getApplication()->input->get('layout', ''); if ($layout != 'modal') { $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); } } parent::display($tpl); $this->setDocument(); }
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]; }
public function changeTemplateId() { $app = JFactory::getApplication(); $jInput = $app->input; $templateId = $jInput->post->getInt("value"); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('parent_id'); $query->from('#__judirectory_templates'); $query->where('id = ' . $templateId); $db->setQuery($query); $templateParentId = $db->loadResult(); $query = $db->getQuery(true); $query->select('*'); $query->select('title AS text'); $query->select('id AS value'); $query->from('#__judirectory_template_styles'); $query->where('template_id =' . $templateParentId); $query->order('lft ASC'); $db->setQuery($query); $styleObjectList = $db->loadObjectList(); $html = ""; $html .= "<option value=\"\">" . JText::_('COM_JUDIRECTORY_SELECT_PARENT_TEMPLATE') . "</option>"; if (!empty($styleObjectList)) { foreach ($styleObjectList as $styleObject) { $html .= "<option value=\"" . $styleObject->value . "\">" . $styleObject->text . "</option>"; } } JUDirectoryHelper::obCleanData(); echo $html; exit; }
public static function getCatPluginParamRecursive($pluginName, $catId, $param, $default = '', $inheritParam = '', $globalParam = '', $inherit = '-1', $global = '-2') { $inheritParam = $inheritParam ? $inheritParam : $param; $globalParam = $globalParam ? $globalParam : $param; $path = JUDirectoryHelper::getCategoryPath($catId); $rootCat = $path[0]; $plugin = JPluginHelper::getPlugin('judirectory', $pluginName); $pluginParamsStr = isset($plugin->params) ? $plugin->params : '{}'; $pluginParams = new JRegistry($pluginParamsStr); $pathCatToRoot = array_reverse($path); foreach ($pathCatToRoot as $category) { $plugin_params = $category->plugin_params; if ($plugin_params) { $plugins = new JRegistry($plugin_params); $pluginObject = $plugins->get($pluginName, ""); $pluginRegistry = new JRegistry($pluginObject); if ($pluginRegistry->get($inheritParam, '') !== $inherit) { if ($pluginRegistry->get($globalParam, '') === $global) { return $pluginParams->get($param, $default); } else { return $pluginRegistry->get($param, $default); } } else { if ($category->parent_id == $rootCat->id) { return $pluginParams->get($param, $default); } else { continue; } } } else { return $default; } } return $default; }
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; }
protected function getInput() { $language = JFactory::getLanguage(); $language->load('com_judirectory', JPATH_ADMINISTRATOR); $isJoomla3x = JUDirectoryHelper::isJoomla3x(); $fieldsGroup = JUDirectoryHelper::getAdvSearchFields(); $html = '<div id="judirectory-field" style="clear: both;">'; if ($isJoomla3x) { $html .= JHtml::_('bootstrap.startTabSet', 'search-form', array('active' => 'fieldgroup-1')); } else { $html .= JHtml::_('tabs.start', 'search-form'); } foreach ($fieldsGroup as $groupField) { if ($isJoomla3x) { $html .= JHtml::_('bootstrap.addTab', 'search-form', 'fieldgroup-' . $groupField->id, $groupField->name, true); } else { $html .= JHtml::_('tabs.panel', $groupField->name, 'fieldgroup-' . $groupField->id); } if (!$isJoomla3x) { $html .= '<fieldset class="adminform">'; $html .= '<ul class="adminformlist">'; } foreach ($groupField->fields as $field) { $value = isset($this->value[$field->id]) ? $this->value[$field->id] : ""; $fieldClass = JUDirectoryFrontHelperField::getField($field); if (JFactory::getApplication()->input->getCmd('view', '') == 'module') { $fieldClass->name = 'jform[params][fields][' . $fieldClass->id . ']'; } if ($isJoomla3x) { $html .= '<div class="control-group">'; $html .= '<div class="control-label">'; $html .= $fieldClass->getLabel(false); $html .= '</div>'; $html .= '<div class="controls">'; $html .= $fieldClass->getDisplayPrefixText() . $fieldClass->getSearchInput($value) . $fieldClass->getDisplaySuffixText(); $html .= "</div>"; $html .= "</div>"; } else { $html .= "<li>"; $html .= $fieldClass->getLabel(false); $html .= $fieldClass->getDisplayPrefixText() . $fieldClass->getSearchInput($value) . $fieldClass->getDisplaySuffixText(); $html .= "</li>"; } } if (!$isJoomla3x) { $html .= '</ul>'; $html .= '</fieldset>'; } if ($isJoomla3x) { $html .= JHtml::_('bootstrap.endTab'); } } if ($isJoomla3x) { $html .= JHtml::_('bootstrap.endTabSet'); } else { $html .= JHtml::_('tabs.end'); } $html .= '</div>'; return $html; }
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); } }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $app = JFactory::getApplication(); if ($app->input->get('layout') == null) { $app->redirect('index.php?option=com_judirectory&view=listcats'); } $this->items = $this->get('Items'); $this->state = $this->get('State'); $this->authors = $this->get('Authors'); $this->pagination = $this->get('Pagination'); if ($app->input->get('layout') == 'copy') { JToolBarHelper::title(JText::_('COM_JUDIRECTORY_COPY_LISTINGS'), 'copy-listings'); JToolBarHelper::apply('listings.copyListings', 'JTOOLBAR_APPLY'); JToolBarHelper::cancel('listing.cancel', 'JTOOLBAR_CANCEL'); } elseif ($app->input->get('layout') == 'move') { JToolBarHelper::title(JText::_('COM_JUDIRECTORY_MOVE_LISTINGS'), 'move-listings'); JToolBarHelper::apply('listings.moveListings', 'JTOOLBAR_APPLY'); JToolBarHelper::cancel('listing.cancel', 'JTOOLBAR_CANCEL'); } else { JToolBarHelper::title(JText::_('COM_JUDIRECTORY_LISTINGS'), 'listings'); $this->totalListings = $this->get('Total'); $this->setDocument(); } if (JUDirectoryHelper::isJoomla3x() && $app->input->get('layout') == 'modal') { $this->filterForm = $this->get('FilterForm'); $this->activeFilters = $this->get('ActiveFilters'); } parent::display($tpl); }
public function __set($name, $value) { switch ($name) { case 'height': case 'width': case 'assetField': case 'authorField': case 'asset': $this->{$name} = (string) $value; break; case 'buttons': $value = (string) $value; if ($value == 'true' || $value == 'yes' || $value == '1') { $this->buttons = true; } elseif ($value == 'false' || $value == 'no' || $value == '0') { $this->buttons = false; } else { $this->buttons = explode(',', $value); } break; case 'hide': $value = (string) $value; $this->hide = $value ? explode(',', $value) : array(); break; case 'editorType': $this->editorType = explode('|', trim((string) $value)); break; default: if (JUDirectoryHelper::isJoomla3x()) { parent::__set($name, $value); } else { $this->{$name} = $value; } } }
protected function addToolBar() { $app = JFactory::getApplication(); $app->input->set('hidemainmenu', true); $isNew = $this->item->id == 0; $canDo = JUDirectoryHelper::getActions('com_judirectory'); $user = JFactory::getUser(); $userId = $user->id; $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId); JToolBarHelper::title(JText::_('COM_JUDIRECTORY_PAGE_' . ($checkedOut ? 'VIEW_TEMPLATE_STYLE' : ($isNew ? 'ADD_TEMPLATE_STYLE' : 'EDIT_TEMPLATE_STYLE'))), 'style-add'); if ($isNew) { if ($canDo->get('core.create')) { JToolBarHelper::apply('style.apply', 'JTOOLBAR_APPLY'); JToolBarHelper::save('style.save2new', 'JTOOLBAR_SAVE_AND_NEW'); JToolBarHelper::save('style.save', 'JTOOLBAR_SAVE'); } JToolBarHelper::cancel('style.cancel', 'JTOOLBAR_CANCEL'); } else { if ($canDo->get('core.edit')) { JToolBarHelper::apply('style.apply', 'JTOOLBAR_APPLY'); if ($canDo->get('core.create')) { JToolBarHelper::save('style.save2new', 'JTOOLBAR_SAVE_AND_NEW'); } JToolBarHelper::save('style.save', 'JTOOLBAR_SAVE'); } JToolBarHelper::cancel('style.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); $bar = JToolBar::getInstance('toolbar'); $bar->addButtonPath(JPATH_ADMINISTRATOR . "/components/com_judirectory/helpers/button"); $bar->appendButton('JUHelp', 'help', JText::_('JTOOLBAR_HELP')); }
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); }
protected function getInput() { $html = ''; $db = JFactory::getDbo(); $options = JUDirectoryHelper::getFieldGroupOptions(); if ($this->element['usenone'] == 'true') { array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDIRECTORY_NONE'))); } if ($this->element['useinherit'] == 'true') { $appendInherit = ""; if ($this->form->getValue("id")) { $appendInherit = " ( " . JText::_('COM_JUDIRECTORY_NONE') . " )"; if ($this->form->getValue("id") > 0) { $catObj = JUDirectoryHelper::getCategoryById($this->form->getValue("parent_id")); if ($catObj->fieldgroup_id > 1) { $query = "SELECT name, published FROM #__judirectory_fields_groups WHERE id = " . (int) $catObj->fieldgroup_id . " AND id != 1"; $db->setQuery($query); $fieldgroup = $db->loadObject(); $groupName = $fieldgroup->published != 1 ? "[" . $fieldgroup->name . "]" : $fieldgroup->name; $appendInherit = "( " . $groupName . " )"; } } } array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDIRECTORY_INHERIT') . $appendInherit)); } else { array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDIRECTORY_SELECT_FIELD_GROUP'))); } $required_class = $this->element['required'] == 'true' ? 'required' : ''; $attributes = "class=\"inputbox {$required_class}\""; $html .= JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id); return $html; }
protected function addToolBar() { $app = JFactory::getApplication(); $app->input->set('hidemainmenu', true); $isNew = $this->item->id == 0; $user = JFactory::getUser(); $userId = $user->id; $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId); JToolBarHelper::title(JText::_('COM_JUDIRECTORY_PAGE_' . ($checkedOut ? 'VIEW_FIELD' : ($isNew ? 'ADD_FIELD' : 'EDIT_FIELD'))), 'field-add'); $canDo = JUDirectoryHelper::getActions('com_judirectory', 'field', $this->item->id); if ($isNew && $user->authorise('core.create', 'com_judirectory')) { JToolBarHelper::apply('field.apply'); JToolBarHelper::save('field.save'); JToolBarHelper::save2new('field.save2new'); JToolBarHelper::cancel('field.cancel'); } else { if (!$checkedOut) { if ($canDo->get('core.edit') || $canDo->get('core.edit.own') && $this->item->created_by == $userId) { JToolBarHelper::apply('field.apply'); JToolBarHelper::save('field.save'); if ($canDo->get('core.create')) { JToolBarHelper::save2new('field.save2new'); } } } JToolBarHelper::cancel('field.cancel', 'JTOOLBAR_CLOSE'); } JToolBarHelper::divider(); $bar = JToolBar::getInstance('toolbar'); $bar->addButtonPath(JPATH_ADMINISTRATOR . "/components/com_judirectory/helpers/button"); $bar->appendButton('JUHelp', 'help', JText::_('JTOOLBAR_HELP')); }
protected function getOptions() { $document = JFactory::getDocument(); if (JUDirectoryHelper::isJoomla3x()) { $triggerJqueryChosen = '$("#jform_parent_id").trigger("liszt:updated");'; } else { $triggerJqueryChosen = ''; } $script = ' jQuery(document).ready(function($){ $("#jform_template_id").change(function(){ var objData = {}; objData.value = $(this).val(); $.ajax({ type: "POST", url : "index.php?option=com_judirectory&task=style.changeTemplateId", data: objData }).done(function (data) { $("option","#jform_parent_id").remove(); $("#jform_parent_id").append(data); ' . $triggerJqueryChosen . ' }); }); }); '; $document->addScriptDeclaration($script); $db = JFactory::getDbo(); $options = array(); $styleId = $this->form->getValue('id'); if ($styleId) { $templateId = $this->form->getValue('template_id'); $query = $db->getQuery(true); $query->select('parent_id'); $query->from('#__judirectory_templates'); $query->where('id = ' . (int) $templateId); $db->setQuery($query); $templateParentId = $db->loadResult(); } else { $templateParentId = 0; } $query = $db->getQuery(true); $query->select('*'); $query->select('title AS text'); $query->select('id AS value'); $query->from('#__judirectory_template_styles'); $query->where('template_id = ' . (int) $templateParentId); $query->order('lft ASC'); $db->setQuery($query); try { $options = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); } for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text; } $options = array_merge(parent::getOptions(), $options); return $options; }
public function listingChangeCategory() { $model = $this->getModel(); $data = $model->listingChangeCategory(); JUDirectoryHelper::obCleanData(); echo $data; exit; }
public static function getCriteriaGroupIdByCategoryId($mainCatId) { $catObj = JUDirectoryHelper::getCategoryById($mainCatId); if ($catObj) { return $catObj->criteriagroup_id; } return null; }
public function listingChangeCategory() { require_once JPATH_ADMINISTRATOR . '/components/com_judirectory/models/category.php'; JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/models'); $backendCategoryModel = JModelLegacy::getInstance('Category', 'JUDirectoryModel'); $data = $backendCategoryModel->listingChangeCategory(); JUDirectoryHelper::obCleanData(); echo $data; exit; }
public function display($tpl = null) { JHtml::_('behavior.calendar'); $this->addToolBar(); $this->model = $this->getModel(); if ($this->getLayout() == "fields_mapping") { $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDIRECTORY_DEFAULT')); $this->fieldsOption[] = JHTML::_('select.option', 'ignore', JText::_("COM_JUDIRECTORY_IGNORE")); $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDIRECTORY_CORE_FIELDS')); $ignoredFields = array('asset_id', 'introtext', 'fulltext', 'comments'); $coreFields = $this->model->getCoreFields($ignoredFields); foreach ($coreFields as $field) { if (is_object($field)) { $value = $field->id; $label = ucfirst(JText::_($field->caption)); } else { $value = $field; $label = ucfirst(str_replace('_', ' ', $field)); } $this->fieldsOption[] = JHTML::_('select.option', $value, $label); } $extraFields = $this->model->getExtraFields(); foreach ($extraFields as $field) { if (isset($fieldGroups[$field->group_id])) { $fieldGroups[$field->group_id][] = $field; } else { $fieldGroups[$field->group_id] = array($field); } } foreach ($fieldGroups as $groupId => $fields) { $group = JUDirectoryFrontHelperField::getFieldGroupById($groupId); $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', $group->name); foreach ($fields as $field) { $label = ucfirst(JText::_($field->caption)); $this->fieldsOption[] = JHTML::_('select.option', $field->id, $label); } } $this->fieldsOption[] = JHTML::_('select.option', '<OPTGROUP>', JText::_('COM_JUDIRECTORY_OTHER_FIELDS')); $this->fieldsOption[] = JHTML::_('select.option', 'related_listings', JText::_('COM_JUDIRECTORY_FIELD_RELATED_LISTINGS')); } if ($this->getLayout() == 'config') { $this->form = $this->get('Form'); } if ($this->getLayout() == 'review') { if (isset($this->review['config']['default_icon'])) { $this->review['config']['default_icon'] = str_replace(array(JPATH_ROOT . '\\', "\\"), array(JUri::root(), '/'), $this->review['config']['default_icon']); } } $this->isJoomla3x = JUDirectoryHelper::isJoomla3x(); if ($this->getLayout() == "export") { $this->exportForm = $this->get("ExportForm"); } parent::display($tpl); $this->setDocument(); }
protected function loadFormData() { $data = JFactory::getApplication()->getUserState('com_judirectory.edit.tag.data', array()); if (empty($data)) { $data = $this->getItem(); } if (JUDirectoryHelper::isJoomla3x()) { $this->preprocessData('com_judirectory.tag', $data); } return $data; }
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; }
public function getChartData() { $app = JFactory::getApplication(); $type = $app->input->get('type'); $model = $this->getModel(); $data = $model->getSubmissionData($type); $app = JFactory::getApplication(); $app->setUserState('com_judirectory.dashboard.chart.type', $type); JUDirectoryHelper::obCleanData(); echo json_encode($data); exit; }
protected function calculatorInheritStyle($cat_id) { do { $category = JUDirectoryHelper::getCategoryById($cat_id); $style_id = $category->style_id; $cat_id = $category->parent_id; } while ($style_id == -1 && $cat_id != 0); if ($style_id == -2) { return $this->getStyle(); } else { return $this->getStyle($style_id); } }
public function display($tpl = null) { if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->canDo = JUDirectoryHelper::getActions('com_judirectory'); $this->addToolBar(); parent::display($tpl); $this->setDocument(); }
public function back() { $app = JFactory::getApplication(); $listing_id = $app->input->getInt('listing_id', 0); $cat_id = JUDirectoryFrontHelperCategory::getRootCategory()->id; if ($listing_id) { $listingObj = JUDirectoryHelper::getListingById($listing_id); if (isset($listingObj->cat_id) && $listingObj->cat_id) { $cat_id = $listingObj->cat_id; } } $this->setRedirect("index.php?option=com_judirectory&view=listcats&cat_id={$cat_id}"); }
protected function getInput() { $db = JFactory::getDbo(); $query = 'SELECT id AS value, name AS text, published FROM #__judirectory_criterias_groups '; $db->setQuery($query); $options = $db->loadObjectList(); $users = JFactory::getUser(); foreach ($options as $key => $option) { if ($option->published != 1) { $option->text = '[ ' . $option->text . ' ]'; } if (!$users->authorise('core.create', 'com_judirectory.criteriagroup.' . $option->value)) { unset($options[$key]); } } $required_class = $this->element['required'] == 'true' ? 'required' : ''; $class = $this->element['class']; if ($this->element['usenone'] == 'true') { array_unshift($options, array('value' => '0', 'text' => JText::_('COM_JUDIRECTORY_NONE'))); } if ($this->element['useinherit'] == 'true') { $appendInherit = ""; if ($this->form->getValue("id")) { if ($this->form->getValue("criteriagroup_id") > 0) { $appendInherit = $this->getCriteriaGroupName($this->form->getValue("criteriagroup_id")); } else { $category = JUDirectoryHelper::getCategoryById($this->form->getValue("id")); $parent = JUDirectoryHelper::getCategoryById($category->parent_id); $appendInherit = $this->getCriteriaGroupName($parent->criteriagroup_id); } } array_unshift($options, array('value' => '-1', 'text' => JText::_('COM_JUDIRECTORY_INHERIT') . $appendInherit)); } else { array_unshift($options, array('value' => '', 'text' => JText::_('COM_JUDIRECTORY_SELECT_CRITERIAL_GROUP'))); } $canChange = true; if ($this->form->getValue('id')) { $query = "SELECT COUNT(*) FROM #__judirectory_criterias_values WHERE criteria_id = " . $this->form->getValue('id'); $db->setQuery($query); $canChange = $db->loadResult() ? false : true; } if ($canChange) { $attributes = "class=\"inputbox {$class} {$required_class}\""; $html = JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id); } else { $attributes = "class=\"inputbox {$class}\" disabled"; $html = JHtml::_('select.genericlist', $options, "_" . $this->name, $attributes, 'value', 'text', $this->value, $this->id); $html .= "<input class=\"{$required_class}\" type=\"hidden\" value=\"" . $this->value . "\" name=\"" . $this->name . "\" />"; } return $html; }