protected function getOptions()
 {
     $styleId = (int) $this->form->getValue('id');
     if ($styleId) {
         $styleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleObject($styleId);
         $defaultStyleObject = JUDirectoryFrontHelperTemplate::getDefaultTemplateStyle();
         if ($defaultStyleObject->template_id == $styleObject->template_id) {
             return array_merge(parent::getOptions(), JHtml::_('contentlanguage.existing'));
         } else {
             return parent::getOptions();
         }
     } else {
         return array_merge(parent::getOptions());
     }
 }
Example #2
0
 public function loadTemplate($tpl = null)
 {
     $this->_output = null;
     $app = JFactory::getApplication();
     $template = JFactory::getApplication()->getTemplate();
     if ($this->getName() == 'category' || $this->getName() == 'tree') {
         $layoutUrl = $app->input->getString('layout', '');
         if (isset($layoutUrl) && $layoutUrl != '') {
             $layout = $layoutUrl;
         } else {
             $layout = null;
         }
         $catId = $app->input->getInt('id', 1);
         $layout = JUDirectoryFrontHelperCategory::getCategoryViewLayout($layout, $catId);
         $this->setLayout($layout);
     } elseif ($this->getName() == 'listing') {
         $layoutUrl = $app->input->getString('layout', '');
         if (isset($layoutUrl) && $layoutUrl != '') {
             $layout = $layoutUrl;
         } else {
             $layout = null;
         }
         $listingId = $app->input->getInt('id', 0);
         if ($listingId > 0) {
             $layout = JUDirectoryFrontHelperListing::getListingViewLayout($layout, $listingId);
             $this->setLayout($layout);
         }
     }
     $layout = $this->getLayout();
     $layoutTemplate = $this->getLayoutTemplate();
     $file = isset($tpl) ? $layout . '_' . $tpl : $layout;
     $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $file);
     $tpl = isset($tpl) ? preg_replace('/[^A-Z0-9_\\.-]/i', '', $tpl) : $tpl;
     $lang = JFactory::getLanguage();
     $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) || $lang->load('tpl_' . $template, JPATH_THEMES . "/{$template}", null, false, false);
     $component = JApplicationHelper::getComponentName();
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
     $app = JFactory::getApplication();
     $id = $app->input->getInt('id', 0);
     $user = JFactory::getUser();
     if ($previewStyle = (int) $app->input->getInt('tplStyle', 0)) {
         if ($user->id == 0) {
             $uri = JUri::getInstance();
             $loginUrl = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($uri), false);
             $app->enqueueMessage(JText::_("COM_JUDIRECTORY_YOU_MUST_LOGIN_AS_SUPER_ADMIN_TO_PREVIEW_TEMPLATE_STYLE"), 'Notice');
             $app->redirect($loginUrl);
             return false;
         } else {
             if (!$user->authorise('core.admin', 'com_judirectory')) {
                 $app->enqueueMessage(JText::_("COM_JUDIRECTORY_YOU_MUST_LOGIN_AS_SUPER_ADMIN_TO_PREVIEW_TEMPLATE_STYLE"), 'Notice');
             }
         }
     }
     if ($user->authorise('core.admin', 'com_judirectory') && ($previewStyle = (int) $app->input->getInt('tplStyle', 0))) {
         $currentTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleObject($previewStyle);
     } else {
         $currentTemplateStyleObject = JUDirectoryFrontHelperTemplate::getCurrentTemplateStyle($this->getName(), $id);
     }
     $JUTemplate = trim($currentTemplateStyleObject->folder);
     $JUTemplate = strtolower($JUTemplate);
     $this->template_params = $currentTemplateStyleObject->params;
     if (!$JUTemplate) {
         $JUTemplate = 'default';
     }
     $this->template = $JUTemplate;
     $JUTemplatePath = JUDirectoryFrontHelperTemplate::getTemplatePathWithoutRoot($currentTemplateStyleObject->template_id);
     $topLevelTemplate = $JUTemplatePath[0]->folder ? $JUTemplatePath[0]->folder : 'default';
     $asset_file = JPATH_SITE . '/components/com_judirectory/templates/' . $topLevelTemplate . '/load_assets.php';
     if (JFile::exists($asset_file)) {
         include_once $asset_file;
     }
     $JUTemplatePathFull = array();
     $JUTemplatePathFull[] = $this->_basePath . '/templates/default/' . $this->getName();
     $JUTemplatePathFull[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . 'default' . '/' . $this->getName();
     $JUTemplatePath = array_reverse($JUTemplatePath);
     foreach ($JUTemplatePath as $JUTemplatePathItem) {
         $JUTemplatePathFull[] = $this->_basePath . '/templates/' . $JUTemplatePathItem->folder . '/' . $this->getName();
         $JUTemplatePathFull[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $JUTemplatePathItem->folder . '/' . $this->getName();
     }
     foreach ($JUTemplatePathFull as $item) {
         $this->_addPath('template', $item);
     }
     if (isset($layoutTemplate) && $layoutTemplate != '_' && $layoutTemplate != $template) {
         $this->_path['template'] = str_replace($template, $layoutTemplate, $this->_path['template']);
     }
     $jversion_arr = explode(".", JVERSION);
     $priVersion = $jversion_arr[0];
     $subVersion = $jversion_arr[1];
     $fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . $subVersion));
     $this->_template = JPath::find($this->_path['template'], $fileToFind);
     if ($this->_template == false) {
         $fileToFind = $this->_createFileName('template', array('name' => $file . '.j' . $priVersion . 'x'));
         $this->_template = JPath::find($this->_path['template'], $fileToFind);
     }
     if ($this->_template == false) {
         $fileToFind = $this->_createFileName('template', array('name' => $file));
         $this->_template = JPath::find($this->_path['template'], $fileToFind);
     }
     if ($this->_template == false) {
         $fallbackPaths = array();
         $fallbackPaths[] = $this->_basePath . '/templates/default/' . $this->getName();
         $fallbackPaths[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . 'default' . '/' . $this->getName();
         foreach ($fallbackPaths as $fallbackPath) {
             $fallbackPath = trim($fallbackPath);
             if (substr($fallbackPath, -1) != DIRECTORY_SEPARATOR) {
                 $fallbackPath .= DIRECTORY_SEPARATOR;
             }
             array_unshift($fallbackPaths, $fallbackPath);
         }
         $fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . $subVersion . (isset($tpl) ? '_' . $tpl : $tpl)));
         $this->_template = JPath::find($fallbackPaths, $fileToFind);
         if ($this->_template == false) {
             $fileToFind = $this->_createFileName('', array('name' => 'default.j' . $priVersion . 'x' . (isset($tpl) ? '_' . $tpl : $tpl)));
             $this->_template = JPath::find($fallbackPaths, $fileToFind);
         }
         if ($this->_template == false) {
             $fileToFind = $this->_createFileName('', array('name' => 'default' . (isset($tpl) ? '_' . $tpl : $tpl)));
             $this->_template = JPath::find($fallbackPaths, $fileToFind);
         }
     }
     if ($this->_template != false) {
         unset($tpl);
         unset($file);
         if (isset($this->this)) {
             unset($this->this);
         }
         ob_start();
         include $this->_template;
         $this->_output = ob_get_contents();
         ob_end_clean();
         return $this->_output;
     } else {
         return JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_LAYOUTFILE_NOT_FOUND', $file));
     }
 }
Example #3
0
 public static function getDefaultTemplateStyle($byUserLanguage = false)
 {
     $app = JFactory::getApplication();
     $storeId = md5(__METHOD__ . "::" . (int) $byUserLanguage);
     if (!isset(self::$cache[$storeId])) {
         if ($byUserLanguage) {
             $templateStyleObjectByLang = JUDirectoryFrontHelperTemplate::getHomeTemplateStyleByLanguage();
             $templateStyleObjectByHome = JUDirectoryFrontHelperTemplate::getHomeTemplateStyle();
             if (!is_object($templateStyleObjectByLang) || $templateStyleObjectByLang->template_id != $templateStyleObjectByHome->template_id) {
                 $templateStyleObject = $templateStyleObjectByHome;
             } else {
                 $templateStyleObject = $templateStyleObjectByLang;
             }
         } else {
             $templateStyleObject = JUDirectoryFrontHelperTemplate::getHomeTemplateStyle();
         }
         if ($app->isSite()) {
             if (!is_object($templateStyleObject)) {
                 $templateStyleObject = new stdClass();
             }
             if (!isset($templateStyleObject->folder) || !$templateStyleObject->folder) {
                 $templateStyleObject->folder = 'default';
             }
         }
         self::$cache[$storeId] = $templateStyleObject;
     }
     return self::$cache[$storeId];
 }
Example #4
0
 * @copyright      Copyright (C) 2010-2015 JoomUltra Co., Ltd. All Rights Reserved.
 * @license        GNU General Public License version 2 or later; see LICENSE.txt
 * @author         JoomUltra Co., Ltd
 * @website        http://www.joomultra.com
 * @----------------------------------------------------------------------@
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
require_once "template_helper.php";
$app = JFactory::getApplication();
$document = JFactory::getDocument();
// Name of current template that component using
//$this->template
// Name of this template
$self_template = basename(dirname(__FILE__));
$templateStyle = JUDirectoryFrontHelperTemplate::getCurrentTemplateStyle();
$templateParams = $templateStyle->params;
//Load font awesome icon
$document->addStyleSheet(JUri::root(true) . '/components/com_judirectory/assets/css/font-awesome.min.css');
JUDirectoryFrontHelper::loadjQuery();
JUDirectoryFrontHelper::loadBootstrap(3, $templateParams->get('load_bootstrap', '2'));
$JUDIRTemplateDefaultHelper = new JUDIRTemplateDefaultHelper($self_template);
$document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/assets/css/reset.css");
$document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/assets/css/core.css");
$document->addStyleSheet(JUri::root(true) . "/components/com_judirectory/templates/" . $self_template . "/assets/css/common.css");
// JText in core.js
JText::script('COM_JUDIRECTORY_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THESE_LISTINGS');
JText::script('COM_JUDIRECTORY_ARE_YOU_SURE_YOU_WANT_TO_PUBLISH_THESE_LISTINGS');
JText::script('COM_JUDIRECTORY_ARE_YOU_SURE_YOU_WANT_TO_UNPUBLISH_THESE_LISTINGS');
$view = $this->getName();
switch ($view) {
Example #5
0
 public function delete($pk = null)
 {
     $db = JFactory::getDbo();
     $k = $this->_tbl_key;
     $pk = is_null($pk) ? $this->{$k} : $pk;
     $this->load($pk);
     if ($this->home == 1 || $this->default == 1) {
         $this->setError(JText::_('COM_JUDIRECTORY_CAN_NOT_DELETE_DEFAULT_TEMPLATE_STYLE'));
         return false;
     }
     $defaultStyleObject = JUDirectoryFrontHelperTemplate::getDefaultTemplateStyle();
     $query = $db->getQuery(true);
     $query->update('#__judirectory_categories');
     $query->set('style_id = -2');
     if ($defaultStyleObject->template_id != $this->template_id) {
         $query->set('template_params = ""');
     }
     $query->where('parent_id = 0');
     $query->where('style_id = ' . $pk);
     $db->setQuery($query);
     $db->execute();
     $query = $db->getQuery(true);
     $query->select('id');
     $query->from('#__judirectory_categories');
     $query->where('style_id = ' . $pk);
     $db->setQuery($query);
     $categoryArrayAssignedToStyle = $db->loadColumn();
     $query = $db->getQuery(true);
     $query->update('#__judirectory_categories');
     $query->set('style_id = -1');
     $query->where('parent_id != 0');
     $query->where('style_id = ' . $pk);
     $db->setQuery($query);
     $db->execute();
     foreach ($categoryArrayAssignedToStyle as $categoryIdAssignedToStyle) {
         $styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($categoryIdAssignedToStyle);
         if ($styleObjectOfCategory->template_id != $this->template_id) {
             $query = $db->getQuery(true);
             $query->update('#__judirectory_categories');
             $query->set('template_params = ""');
             $query->where('id = ' . $categoryIdAssignedToStyle);
             $db->setQuery($query);
             $db->execute();
             $query = $db->getQuery(true);
             $query->update('#__judirectory_listings AS listing');
             $query->set('listing.template_params = ""');
             $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
             $query->where('listing.style_id = -1');
             $query->where('listingxref.cat_id = ' . $categoryIdAssignedToStyle);
             $db->setQuery($query);
             $db->execute();
             JUDirectoryFrontHelperTemplate::removeTemplateParamsOfInheritedStyleCatListing($categoryIdAssignedToStyle);
         }
     }
     $query = $db->getQuery(true);
     $query->select('listing.id');
     $query->select('listingxref.cat_id AS cat_id');
     $query->from('#__judirectory_listings AS listing');
     $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
     $query->where('listing.style_id = ' . $pk);
     $db->setQuery($query);
     $listingObjectListAssignedToStyle = $db->loadObjectList();
     $catArrayResetTemplateParams = array();
     foreach ($listingObjectListAssignedToStyle as $listingObject) {
         $styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($listingObject->cat_id);
         if ($styleObjectOfCategory->template_id != $this->template_id) {
             $catArrayResetTemplateParams[] = $listingObject->cat_id;
         }
     }
     $catArrayResetTemplateParams = array_unique($catArrayResetTemplateParams);
     if (is_array($catArrayResetTemplateParams) && count($catArrayResetTemplateParams)) {
         $query = $db->getQuery(true);
         $query->update('#__judirectory_listings AS listing');
         $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1');
         $query->set('listing.template_params = ""');
         $query->set('listing.style_id = -1');
         $query->where('listingxref.cat_id IN (' . implode(',', $catArrayResetTemplateParams) . ')');
         $query->where('listing.style_id = ' . $pk);
         $db->setQuery($query);
         $db->execute();
     }
     return parent::delete($pk);
 }
Example #6
0
 public function listingChangeCategory()
 {
     $app = JFactory::getApplication();
     if ($app->input->get('action', '') == 'update-maincat') {
         $ori_cat_id = $app->input->getInt('ori_cat_id', 0);
         $ori_cat = JUDirectoryHelper::getCategoryById($ori_cat_id);
         $data['ori_field_group_id'] = 0;
         $data['new_field_group_id'] = 0;
         $data['new_field_group_name'] = "";
         $data['path'] = "";
         if ($ori_cat) {
             $data['ori_field_group_id'] = $ori_cat->fieldgroup_id;
         }
         $new_cat_id = $app->input->getInt('new_cat_id', 0);
         $rootCat = JUDirectoryFrontHelperCategory::getRootCategory();
         $params = JUDirectoryHelper::getParams();
         if ($rootCat->id == $new_cat_id && !$params->get('allow_add_listing_to_root', 0)) {
             return "";
         }
         $new_cat = JUDirectoryHelper::getCategoryById($new_cat_id);
         if ($new_cat) {
             $db = JFactory::getDbo();
             $query = "SELECT id, name FROM #__judirectory_fields_groups WHERE id = " . $new_cat->fieldgroup_id . " AND published = 1";
             $db->setQuery($query);
             $fieldgroup = $db->loadObject();
             if ($fieldgroup) {
                 $data['new_field_group_id'] = $fieldgroup->id;
                 $data['new_field_group_name'] = $fieldgroup->name;
             }
             $data['path'] = JUDirectoryHelper::generateCategoryPath($new_cat_id);
         }
         if ($data['ori_field_group_id'] != $data['new_field_group_id']) {
             $data['msg_field_group'] = JText::_('COM_JUDIRECTORY_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_FIELD_GROUP_WARNING');
         }
         $listingId = $app->input->getInt('id', 0);
         $data['message_style'] = JText::_('COM_JUDIRECTORY_INHERIT');
         if ($listingId) {
             $listingObject = JUDirectoryHelper::getListingById($listingId);
             if ($listingObject->style_id == -1) {
                 $oldStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($listingId->cat_id);
                 $newStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id);
                 if ($oldStyleObject->template_id != $newStyleObject->template_id) {
                     $data['msg_style'] = JText::_('COM_JUDIRECTORY_CHANGE_MAIN_CATEGORY_CAUSE_CHANGE_TEMPLATE_WARNING');
                 }
             }
             $newTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($new_cat->id);
             $data['message_style'] = JText::_('COM_JUDIRECTORY_INHERIT') . ' (' . $newTemplateStyleObject->title . ' [' . $newTemplateStyleObject->template_title . ' ]' . ')';
         }
         return json_encode($data);
     } elseif ($app->input->getInt('action', '') == 'insert_secondary_cat') {
         $cat_id_str = $app->input->get('secondary_cat_id', '', 'string');
         $html = '';
         if (!empty($cat_id_str)) {
             $cat_id_arr = explode(",", $cat_id_str);
             foreach ($cat_id_arr as $key => $cat_id) {
                 $html .= "<li id=\"cat-" . $cat_id . "\"><a class=\"drag-icon\"></a><span>" . JUDirectoryHelper::generateCategoryPath($cat_id) . "</span><a href=\"#\" onclick=\"return false\" class=\"remove-secondary-cat\" ><i class=\"icon-minus fa fa-minus-circle\"></i> " . JText::_('COM_JUDIRECTORY_REMOVE') . "</a></li>";
             }
         }
         return $html;
     }
 }
Example #7
0
 protected function getTmplFile($file = 'output.php', $class = null)
 {
     if (is_null($class)) {
         $class = 'JUDirectoryFieldBase';
     }
     $folder = str_replace('judirectoryfield', '', strtolower($class));
     $templatePaths = array();
     $templatePaths[] = JPATH_SITE . '/components/com_judirectory/fields/' . $folder . '/tmpl/';
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $currentTemplateStyleObject = JUDirectoryFrontHelperTemplate::getCurrentTemplateStyle();
         $JUTemplatePath = JUDirectoryFrontHelperTemplate::getTemplatePathWithoutRoot($currentTemplateStyleObject->template_id);
         if ($JUTemplatePath) {
             foreach ($JUTemplatePath as $template) {
                 $templatePaths[] = JPATH_SITE . '/components/com_judirectory/templates/' . $template->folder . '/fields/' . $folder . '/';
                 $templatePaths[] = JPATH_THEMES . '/' . $app->getTemplate() . '/html/com_judirectory/' . $template->folder . '/fields/' . $folder . '/';
             }
         }
     }
     $templatePaths = array_reverse($templatePaths);
     foreach ($templatePaths as $templatePath) {
         $path = $templatePath . $file;
         if (JFile::exists($path)) {
             return $path;
         }
     }
     return $file;
 }
Example #8
0
 public function moveListings($listing_id_arr, $tocat_id, $move_option_arr = array())
 {
     $dispatcher = JDispatcher::getInstance();
     $user = JFactory::getUser();
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
     $catTable = JTable::getInstance("Category", "JUDirectoryTable");
     if ($tocat_id) {
         if (!$catTable->load($tocat_id)) {
             JError::raiseWarning(500, JText::_('COM_JUDIRECTORY_TARGET_CATEGORY_NOT_FOUND'));
             return false;
         }
         $table = $this->getTable();
         $db = JFactory::getDbo();
         $assetName = 'com_judirectory.category.' . (int) $tocat_id;
         $query = 'SELECT id FROM #__assets WHERE name="' . $assetName . '"';
         $db->setQuery($query);
         $tocat_asset_id = $db->loadResult();
         $canCreate = $user->authorise('judir.listing.create', $assetName);
         if (!$canCreate) {
             JError::raiseError(100, JText::sprintf('COM_JUDIRECTORY_CAN_NOT_CREATE_LISTING_IN_THIS_CATEGORY', $catTable->title));
             return false;
         }
     } else {
         JError::raiseWarning(500, JText::_('COM_JUDIRECTORY_NO_TARGET_CATEGORY_SELECTED'));
         return false;
     }
     if (empty($listing_id_arr)) {
         JError::raiseError(100, JText::_('COM_JUDIRECTORY_NO_ITEM_SELECTED'));
         return false;
     }
     set_time_limit(0);
     $moved_listings = array();
     foreach ($listing_id_arr as $listing_id) {
         if (!$table->load($listing_id)) {
             continue;
         }
         $assetName = 'com_judirectory.listing.' . (int) $listing_id;
         $canDoEdit = $user->authorise('judir.listing.edit', $assetName);
         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;
 }