本文整理汇总了PHP中JUDirectoryHelper::getCategoryById方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::getCategoryById方法的具体用法?PHP JUDirectoryHelper::getCategoryById怎么用?PHP JUDirectoryHelper::getCategoryById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::getCategoryById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
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;
}
示例2: getCriteriaGroupIdByCategoryId
public static function getCriteriaGroupIdByCategoryId($mainCatId)
{
$catObj = JUDirectoryHelper::getCategoryById($mainCatId);
if ($catObj) {
return $catObj->criteriagroup_id;
}
return null;
}
示例3: calculatorInheritStyle
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);
}
}
示例4: getInput
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;
}
示例5: getInput
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();
if (!empty($options)) {
foreach ($options as $option) {
if ($option->published != 1) {
$option->text = "[" . $option->text . "]";
}
}
}
$users = JFactory::getUser();
$required_class = $this->element['required'] == 'true' ? 'required' : '';
$class = $this->element['class'];
$attributes = "class=\"inputbox {$class} {$required_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')));
}
$html = JHtml::_('select.genericlist', $options, $this->name, $attributes, 'value', 'text', $this->value, $this->id);
return $html;
}
示例6: optimizeListListingQuery
public static function optimizeListListingQuery(&$query, $massSelect = false)
{
$user = JFactory::getUser();
$query->select('cmain.id AS cat_id');
$query->join('', '#__judirectory_listings_xref AS listingxmain ON listing.id = listingxmain.listing_id AND listingxmain.main = 1');
$query->join('', '#__judirectory_categories AS cmain ON cmain.id = listingxmain.cat_id');
$categoryIdArrayCanAccess = JUDirectoryFrontHelperPermission::getAccessibleCategoryIds();
if (is_array($categoryIdArrayCanAccess) && count($categoryIdArrayCanAccess) > 0) {
$query->where('cmain.id IN(' . implode(",", $categoryIdArrayCanAccess) . ')');
} else {
$query->where('cmain.id IN("")');
}
if ($massSelect) {
$commentsField = new JUDirectoryFieldCore_comments();
if ($commentsField->canView(array("view" => "list"))) {
$isModerator = JUDirectoryFrontHelperModerator::isModerator();
if (!$isModerator && !$user->authorise('core.admin', 'com_judirectory')) {
$params = JUDirectoryHelper::getParams();
$negative_vote_comment = $params->get('negative_vote_comment');
if (is_numeric($negative_vote_comment) && $negative_vote_comment > 0) {
$query->select('(SELECT COUNT(*) FROM #__judirectory_comments AS cm WHERE cm.listing_id = listing.id AND cm.approved = 1 AND cm.published = 1 AND cm.level = 1
AND (cm.total_votes - cm.helpful_votes) < ' . $negative_vote_comment . ' ) AS total_comments');
} else {
$query->select('(SELECT COUNT(*) FROM #__judirectory_comments AS cm WHERE cm.listing_id = listing.id AND cm.approved = 1 AND cm.published = 1 AND cm.level = 1) AS total_comments');
}
}
}
$subscriptionsField = new JUDirectoryFieldCore_subscriptions();
if ($subscriptionsField->canView(array("view" => "list"))) {
$query->select('(SELECT COUNT(*) FROM #__judirectory_subscriptions AS sub WHERE sub.item_id = listing.id AND sub.type = "listing" AND sub.published = 1) AS total_subscriptions');
}
$reportsField = new JUDirectoryFieldCore_reports();
if ($reportsField->canView(array("view" => "list"))) {
$query->select('(SELECT COUNT(*) FROM #__judirectory_reports AS r WHERE r.item_id = listing.id AND r.type = "listing") AS total_reports');
}
$categoriesField = new JUDirectoryFieldCore_categories();
if ($categoriesField->canView(array("view" => "list"))) {
$query->select('(SELECT GROUP_CONCAT(catids.id ORDER BY listingx_catids.main DESC, listingx_catids.ordering ASC SEPARATOR ",") FROM (#__judirectory_categories AS catids JOIN #__judirectory_listings_xref AS listingx_catids ON catids.id = listingx_catids.cat_id) WHERE listing.id = listingx_catids.listing_id GROUP BY listing.id) AS cat_ids');
$query->select('(SELECT GROUP_CONCAT(cattitles.title ORDER BY listingx_cattitles.main DESC, listingx_cattitles.ordering ASC SEPARATOR "|||") FROM (#__judirectory_categories AS cattitles JOIN #__judirectory_listings_xref AS listingx_cattitles ON cattitles.id = listingx_cattitles.cat_id) WHERE listing.id = listingx_cattitles.listing_id GROUP BY listing.id) AS cat_titles');
}
$tagsField = new JUDirectoryFieldCore_tags();
if ($tagsField->canView(array("view" => "list"))) {
$query->select('IFNULL ((SELECT GROUP_CONCAT(tagids.id ORDER BY tx_tagids.ordering ASC SEPARATOR ",") FROM (#__judirectory_tags AS tagids JOIN #__judirectory_tags_xref AS tx_tagids ON tagids.id = tx_tagids.tag_id) WHERE listing.id = tx_tagids.listing_id GROUP BY listing.id), "") AS tag_ids');
$query->select('IFNULL ((SELECT GROUP_CONCAT(tagtitles.title ORDER BY tx_tagtitles.ordering ASC SEPARATOR "|||") FROM (#__judirectory_tags AS tagtitles JOIN #__judirectory_tags_xref AS tx_tagtitles ON tagtitles.id = tx_tagtitles.tag_id) WHERE listing.id = tx_tagtitles.listing_id GROUP BY listing.id), "") AS tag_titles');
}
$app = JFactory::getApplication();
$accessLevel = implode(',', $user->getAuthorisedViewLevels());
$db = JFactory::getDbo();
$date = JFactory::getDate();
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote($date->toSql());
$fieldQuery = $db->getQuery(true);
$fieldQuery->select('field.id');
$fieldQuery->from('#__judirectory_fields AS field');
$fieldQuery->where('field.field_name = ""');
$fieldQuery->where('field.list_view = 1');
$fieldQuery->where('field.published = 1');
$fieldQuery->where('field.publish_up <= ' . $nowDate);
$fieldQuery->where('(field.publish_down = ' . $nullDate . ' OR field.publish_down > ' . $nowDate . ')');
$fieldQuery->where('field.access IN (' . $accessLevel . ')');
$view = $app->input->get('view', '');
if ($view == 'category' || $view == 'tree') {
$cat_id = $app->input->getInt('id', 0);
$category = JUDirectoryHelper::getCategoryById($cat_id);
if (is_object($category)) {
$fieldQuery->where('field.group_id = ' . $category->fieldgroup_id);
}
} else {
$fieldQuery->join('', '#__judirectory_categories AS c ON (field.group_id = c.fieldgroup_id OR field.group_id = 1)');
if (is_array($categoryIdArrayCanAccess) && count($categoryIdArrayCanAccess) > 0) {
$fieldQuery->where('c.id IN(' . implode(",", $categoryIdArrayCanAccess) . ')');
} else {
$fieldQuery->where('c.id IN("")');
}
}
$fieldQuery->join('', '#__judirectory_fields_groups AS field_group ON field.group_id = field_group.id');
$fieldQuery->where('field_group.published = 1');
$fieldQuery->where('field_group.access IN (' . $accessLevel . ')');
$fieldQuery->group('field.id');
$db->setQuery($fieldQuery);
$fields = $db->loadObjectList();
foreach ($fields as $field) {
$query->select('IFNULL (fields_values_' . $field->id . '.value, "") AS field_values_' . $field->id);
$query->join('LEFT', '#__judirectory_fields_values AS fields_values_' . $field->id . ' ON fields_values_' . $field->id . '.listing_id = listing.id AND fields_values_' . $field->id . '.field_id = ' . $field->id);
}
}
}
示例7: getCategoryDisplayParams
public static function getCategoryDisplayParams($cat_id)
{
if (!$cat_id) {
return false;
}
$params = JUDirectoryHelper::getParams($cat_id);
$global_display_params = new JRegistry(isset($params->get('display_params')->cat) ? $params->get('display_params')->cat : array());
$catObj = JUDirectoryHelper::getCategoryById($cat_id);
$category_params = $catObj->params;
if ($category_params) {
$category_params = json_decode($category_params);
$category_display_params = $category_params->display_params;
if ($category_display_params) {
foreach ($category_display_params as $option => $value) {
if ($value == -2) {
unset($category_display_params->{$option});
}
}
$global_display_params->loadObject($category_display_params);
}
}
return $global_display_params;
}
示例8: getFieldGroupsByCatIds
public static function getFieldGroupsByCatIds($catIds, $search_sub_categories = false)
{
if (!$catIds) {
return null;
}
$field_groups = array();
foreach ($catIds as $catId) {
if ($search_sub_categories) {
$categoryTree = JUDirectoryHelper::getCategoryTree($catId, true, true);
foreach ($categoryTree as $sub_category) {
if ($sub_category->fieldgroup_id > 0) {
$field_groups[] = $sub_category->fieldgroup_id;
}
}
} else {
$catObj = JUDirectoryHelper::getCategoryById($catId);
$field_groups[] = $catObj->fieldgroup_id ? $catObj->fieldgroup_id : 1;
}
}
$field_groups = array_unique($field_groups);
if ($field_groups) {
return implode(",", $field_groups);
} else {
return null;
}
}
示例9: array
JHtml::_('behavior.multiselect');
if (JUDirectoryHelper::isJoomla3x()) {
$classTooltip = "hasTooltip";
$separator = "<br/>";
JHtml::_('bootstrap.tooltip');
} else {
JHtml::_('behavior.tooltip');
$separator = "::";
$classTooltip = "hasTip";
}
$session = JFactory::getSession();
$ignored_cat_id = $session->get('moved_cat_id_arr');
$move_cat_id_arr = $session->get('moved_cat_id_arr');
$categories = array();
foreach ($move_cat_id_arr as $cat_id) {
$categories[] = JUDirectoryHelper::getCategoryById($cat_id);
}
?>
<div class="jubootstrap">
<div id="iframe-help"></div>
<form action="<?php
echo JRoute::_('index.php?option=com_judirectory&view=listings');
?>
" method="post" name="adminForm" id="adminForm">
<fieldset class="adminform">
<legend><?php
echo JText::_('COM_JUDIRECTORY_MOVE_CATEGORIES');
?>
示例10: parse
//.........这里部分代码省略.........
$vars['format'] = 'feed';
if ($indexLastSegment == 0) {
if (is_object($activeMenu) && $activeMenu->component == 'com_judirectory') {
$vars = $activeMenu->query;
$vars['format'] = 'feed';
return $vars;
}
}
$previousIndexSegment -= 1;
}
}
if (isset($segments[$previousIndexSegment])) {
$isLayout = JUDirectoryHelperRoute::parseLayout($segments[$previousIndexSegment], $vars, $params);
if ($isLayout) {
$previousIndexSegment -= 1;
}
}
if (!empty($segments)) {
$reverseSegments = array_reverse($segments);
foreach ($reverseSegments as $segmentItemKey => $segmentItem) {
if (preg_match('/^\\d+\\-.+/', $segmentItem)) {
$indexAlias = $indexLastSegment - $segmentItemKey;
break;
}
}
if (isset($indexAlias) && isset($segments[$indexAlias])) {
if (strpos($segments[$indexAlias], '-') === false) {
$itemId = (int) $segments[$indexAlias];
$itemAlias = substr($segments[$indexAlias], strlen($itemId) + 1);
} else {
list($itemId, $itemAlias) = explode('-', $segments[$indexAlias], 2);
}
if (is_numeric($itemId)) {
$categoryObject = JUDirectoryHelper::getCategoryById($itemId);
if (is_object($categoryObject) && isset($categoryObject->alias) && $categoryObject->alias == $itemAlias) {
$vars['view'] = 'category';
$vars['id'] = $itemId;
JUDirectoryHelperRoute::parsePagination($vars, $segments, $params);
return $vars;
}
$listingObject = JUDirectoryHelper::getListingById($itemId);
if (is_object($listingObject) && isset($listingObject->alias) && $listingObject->alias == $itemAlias) {
$vars['id'] = $itemId;
if (isset($vars['layout'])) {
if ($vars['layout'] == 'edit') {
$vars['view'] = 'form';
} else {
$vars['view'] = 'listing';
}
}
if (!isset($vars['view'])) {
$vars['view'] = 'listing';
}
if ($vars['view'] == 'listing') {
if (isset($segments[$indexAlias + 1])) {
if ($segments[$indexAlias + 1] == JApplication::stringURLSafe('print')) {
$vars['print'] = 1;
$vars['tmpl'] = 'component';
$vars['layout'] = 'print';
}
}
}
JUDirectoryHelperRoute::parsePagination($vars, $segments, $params);
return $vars;
}
if (is_object($categoryObject) && isset($categoryObject->id) && $categoryObject->id) {
示例11: PHPValidate
public function PHPValidate($values)
{
$rootCat = JUDirectoryFrontHelperCategory::getRootCategory();
// getParams by cat_id if possible
if (isset($this->listing) && $this->listing->cat_id) {
$params = JUDirectoryHelper::getParams($this->listing->cat_id);
} else {
$params = JUDirectoryHelper::getParams(null, $this->listing_id);
}
$mainCatId = $values['main'];
$secondaryCatIds = array_filter(explode(",", $values['secondary']));
if (!$mainCatId) {
return JText::_("COM_JUDIRECTORY_PLEASE_SELECT_A_CATEGORY");
}
if ($mainCatId == $rootCat->id && !$params->get('allow_add_listing_to_root', 0)) {
return JText::_("COM_JUDIRECTORY_CAN_NOT_ADD_LISTING_TO_ROOT_CATEGORY");
}
if (!JUDirectoryHelper::getCategoryById($mainCatId)) {
return JText::_("COM_JUDIRECTORY_INVALID_CATEGORY");
}
if ($params->get('max_cats_per_listing', 0) && count($secondaryCatIds) + 1 > $params->get('max_cats_per_listing', 0)) {
return JText::sprintf("COM_JUDIRECTORY_NUMBER_OF_CATEGORY_OVER_MAX_N_CATEGORIES", $params->get('max_cats_per_listing', 0));
}
if (!$this->listing_id) {
// If has not permission to submit in this main category
if (!JUDirectoryFrontHelperPermission::canSubmitListing($mainCatId)) {
$category = JUDirectoryHelper::getCategoryById($mainCatId);
return JText::sprintf("COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_SUBMIT_LISTING_TO_THIS_CATEGORY", $category->title);
}
} else {
$mainCatIdDB = JUDirectoryFrontHelperCategory::getMainCategoryId($this->listing_id);
// Change category -> check submit permission in new cat
if ($mainCatId != $mainCatIdDB) {
// If has not permission to submit in this main category
if (!JUDirectoryFrontHelperPermission::canSubmitListing($mainCatId)) {
$category = JUDirectoryHelper::getCategoryById($mainCatId);
return JText::sprintf("COM_JUDIRECTORY_YOU_ARE_NOT_AUTHORIZED_TO_SUBMIT_LISTING_TO_THIS_CATEGORY", $category->title);
}
}
$app = JFactory::getApplication();
// Front-end
if ($app->isSite()) {
// Can not change main cat when edit listing
if ($mainCatId != $mainCatIdDB) {
if (!$params->get('can_change_main_category', 1)) {
return false;
}
}
// Can not change secondary cats when edit listing
if (!$params->get('can_change_secondary_categories', 1)) {
$secondaryCatIdsDB = $this->getSecondaryCategoryIds($this->listing_id);
if (count($secondaryCatIds) && count($secondaryCatIdsDB)) {
if (array_diff($secondaryCatIds, $secondaryCatIdsDB) || array_diff($secondaryCatIdsDB, $secondaryCatIds)) {
return false;
}
}
}
}
}
return true;
}
示例12: edit
public function edit($key = null, $urlVar = null)
{
$app = JFactory::getApplication();
$cat_id = $app->input->getInt('id', 0);
$category = JUDirectoryHelper::getCategoryById($cat_id);
if ($category->parent_id == 0) {
$this->setRedirect("index.php?option=com_judirectory&view=listcats", JText::_('COM_JUDIRECTORY_YOU_CAN_NOT_EDIT_ROOT_CATEGORY'), "error");
} else {
parent::edit($key = null, $urlVar = null);
}
}
示例13: moveListings
//.........这里部分代码省略.........
if (!$canDoEdit) {
if (!$user->id) {
JError::raiseWarning(100, JText::sprintf('COM_JUDIRECTORY_YOU_DONT_HAVE_PERMISSION_TO_ACCESS_LISTING', $table->title));
continue;
} else {
if ($user->id == $table->created_by) {
$canDoEditOwn = $user->authorise('judir.listing.edit.own', $assetName);
if (!$canDoEditOwn) {
JError::raiseWarning(100, JText::sprintf('COM_JUDIRECTORY_YOU_DONT_HAVE_PERMISSION_TO_ACCESS_LISTING', $table->title));
continue;
}
}
}
}
$query = "SELECT cat_id FROM #__judirectory_listings_xref WHERE listing_id = " . $listing_id . " AND main=1";
$db->setQuery($query);
$cat_id = $db->loadResult();
if ($tocat_id == $cat_id) {
continue;
}
$result = $dispatcher->trigger($this->onContentBeforeMove, array($this->option . '.' . $this->name, $table, $tocat_id, $move_option_arr));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
if ($table->style_id == -1) {
$oldTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($cat_id);
$newTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($tocat_id);
if ($oldTemplateStyleObject->template_id != $newTemplateStyleObject->template_id) {
if (in_array('keep_template_params', $move_option_arr)) {
$table->style_id = $oldTemplateStyleObject->id;
} else {
$query = "UPDATE #__judirectory_listings SET template_params = '' WHERE id=" . $listing_id;
$db->setQuery($query);
$db->execute();
}
}
}
$query = "SELECT COUNT(*) FROM #__judirectory_listings_xref WHERE cat_id=" . $tocat_id . " AND listing_id=" . $listing_id . " AND main=0";
$db->setQuery($query);
$is_secondary_cat = $db->loadResult();
if ($is_secondary_cat) {
$query = "DELETE FROM #__judirectory_listings_xref WHERE listing_id=" . $listing_id . " AND main=1";
$db->setQuery($query);
$db->execute();
$query = "UPDATE #__judirectory_listings_xref SET main=1 WHERE cat_id=" . $tocat_id . " AND listing_id=" . $listing_id;
$db->setQuery($query);
$db->execute();
} else {
$query = "UPDATE #__judirectory_listings_xref SET cat_id=" . $tocat_id . " WHERE listing_id=" . $listing_id . " AND main=1";
$db->setQuery($query);
$db->execute();
}
if (in_array('keep_permission', $move_option_arr)) {
$query = 'UPDATE #__assets SET `parent_id` = ' . $tocat_asset_id . ' WHERE name="com_judirectory.listing.' . $listing_id . '"';
$db->setQuery($query);
$db->execute();
} else {
$query = 'UPDATE #__assets SET `parent_id` = ' . $tocat_asset_id . ', `rules` = "{}" WHERE name="com_judirectory.listing.' . $listing_id . '"';
$db->setQuery($query);
$db->execute();
}
$moved_listings[] = $listing_id;
$this->cleanCache();
$dispatcher->trigger($this->onContentAfterMove, array($this->option . '.' . $this->name, $table, $tocat_id, $move_option_arr));
}
$total_moved_listings = count($moved_listings);
if ($total_moved_listings) {
$old_field_groupid = JUDirectoryHelper::getCategoryById($cat_id)->fieldgroup_id;
$new_field_groupid = JUDirectoryHelper::getCategoryById($tocat_id)->fieldgroup_id;
$keep_extra_fields = in_array("keep_extra_fields", $move_option_arr);
if ($keep_extra_fields) {
$keep_extra_fields = $old_field_groupid == $new_field_groupid ? true : false;
}
if (!$keep_extra_fields) {
foreach ($moved_listings as $listing_id) {
JUDirectoryHelper::deleteFieldValuesOfListing($listing_id);
}
}
$old_criteria_groupid = JUDirectoryHelper::getCategoryById($cat_id)->criteriagroup_id;
$new_criteria_groupid = JUDirectoryHelper::getCategoryById($tocat_id)->criteriagroup_id;
$keep_rates = in_array("keep_rates", $move_option_arr);
if ($keep_rates) {
$keep_rates = $old_criteria_groupid == $new_criteria_groupid ? true : false;
}
if (!$keep_rates) {
JTable::addIncludePath(JPATH_ADMINISTRATOR . "/components/com_judirectory/tables");
$ratingTable = JTable::getInstance("Rating", "JUDirectoryTable");
foreach ($moved_listings as $listing_id) {
$query = "SELECT id FROM #__judirectory_rating WHERE listing_id = " . $listing_id;
$db->setQuery($query);
$ratingIds = $db->loadColumn();
foreach ($ratingIds as $ratingId) {
$ratingTable->delete($ratingId);
}
}
}
}
return $total_moved_listings;
}
示例14: getAllChildCats
public function getAllChildCats($catArr)
{
$childCatIds = array();
$db = JFactory::getDbo();
foreach ($catArr as $catId) {
$catObject = JUDirectoryHelper::getCategoryById($catId);
$query = $db->getQuery(true);
$query->select('id')->from('#__judirectory_categories')->where('lft >= ' . $catObject->lft)->where('rgt <= ' . $catObject->rgt);
$db->setQuery($query);
$childCatIdArr = $db->loadColumn();
$childCatIds = array_merge($childCatIds, $childCatIdArr);
}
$childCatIdStr = implode(',', $childCatIds);
return $childCatIdStr;
}
示例15: getCategorySegment
public static function getCategorySegment($categoryId, &$query, $fullPath = 0)
{
if (isset($query['Itemid'])) {
unset($query['Itemid']);
}
$segments = array();
$params = JUDirectoryHelper::getParams();
$rootCategory = JUDirectoryFrontHelperCategory::getRootCategory();
$categoryObject = JUDirectoryHelper::getCategoryById($categoryId);
if (!is_object($categoryObject)) {
return false;
}
if ($categoryObject->level == 0) {
$itemIdTreeRoot = JUDirectoryHelperRoute::getMenuItemIdOfViewCategoryTreeRoot();
if ($itemIdTreeRoot > 0) {
$query['Itemid'] = $itemIdTreeRoot;
return $segments;
}
$query['Itemid'] = JUDirectoryHelperRoute::getHomeMenuItemId();
$sefRootCategory = $rootCategory->id . ':' . $params->get('sef_root_cat', 'root');
$segments[] = JApplication::stringURLSafe($sefRootCategory);
return $segments;
} elseif ($categoryObject->level == 1) {
$menuItemIdsOfViewCategoryTreeLevel1 = JUDirectoryHelperRoute::getMenuItemIdArrayOfViewCategoryTreeLevel1();
if (isset($menuItemIdsOfViewCategoryTreeLevel1[$categoryObject->id])) {
$query['Itemid'] = $menuItemIdsOfViewCategoryTreeLevel1[$categoryObject->id];
return $segments;
}
$itemIdTreeRoot = JUDirectoryHelperRoute::getMenuItemIdOfViewCategoryTreeRoot();
if ($itemIdTreeRoot > 0) {
$query['Itemid'] = $itemIdTreeRoot;
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
$query['Itemid'] = JUDirectoryHelperRoute::getHomeMenuItemId();
$sefRootCategory = $params->get('sef_root_cat', 'root');
$segments[] = JApplication::stringURLSafe($sefRootCategory);
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
} else {
$levelCats = JUDirectoryHelper::getCatsByLevel(1, $categoryObject->id);
if (is_array($levelCats) && count($levelCats)) {
$categoryIdAncestorLevel1 = $levelCats[0]->id;
}
$menuItemIdsOfViewCategoryTreeLevel1 = JUDirectoryHelperRoute::getMenuItemIdArrayOfViewCategoryTreeLevel1();
if (isset($menuItemIdsOfViewCategoryTreeLevel1[$categoryIdAncestorLevel1])) {
$query['Itemid'] = $menuItemIdsOfViewCategoryTreeLevel1[$categoryIdAncestorLevel1];
if ($fullPath) {
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
if (is_array($categoryPath) && count($categoryPath)) {
foreach ($categoryPath as $categoryPathValue) {
if ($categoryPathValue->level > 1 && $categoryPathValue->id != $categoryObject->id) {
$segments[] = $categoryPathValue->alias;
}
}
}
}
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
$itemIdTreeRoot = JUDirectoryHelperRoute::getMenuItemIdOfViewCategoryTreeRoot();
if ($itemIdTreeRoot > 0) {
$query['Itemid'] = $itemIdTreeRoot;
if ($fullPath) {
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
if (is_array($categoryPath) && count($categoryPath)) {
foreach ($categoryPath as $categoryPathValue) {
if ($categoryPathValue->level > 0 && $categoryPathValue->id != $categoryObject->id) {
$segments[] = $categoryPathValue->alias;
}
}
}
}
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
$query['Itemid'] = JUDirectoryHelperRoute::getHomeMenuItemId();
if ($fullPath) {
$sefRootCategory = $params->get('sef_root_cat', 'root');
$segments[] = JApplication::stringURLSafe($sefRootCategory);
$categoryPath = JUDirectoryHelper::getCategoryPath($categoryId);
if (is_array($categoryPath) && count($categoryPath)) {
foreach ($categoryPath as $categoryPathValue) {
if ($categoryPathValue->level > 0 && $categoryPathValue->id != $categoryObject->id) {
$segments[] = $categoryPathValue->alias;
}
}
}
}
$segments[] = $categoryObject->id . ":" . $categoryObject->alias;
return $segments;
}
return $segments;
}