Beispiel #1
0
 public static function loadLanguageForTopLevelCat()
 {
     $app = JFactory::getApplication();
     $view = $app->input->getString('view', '');
     $id = $app->input->getInt('id', 0);
     if (isset($view)) {
         switch ($view) {
             case 'category':
                 $topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $id);
                 break;
             case 'listing':
                 $catId = JUDirectoryFrontHelperCategory::getMainCategoryId($id);
                 $topLevelCats = JUDirectoryHelper::getCatsByLevel(1, $catId);
                 break;
         }
         if (!empty($topLevelCats)) {
             $topLevelCat = $topLevelCats[0];
             if ($view == 'category' || $view == 'listing') {
                 JUDirectoryFrontHelperLanguage::loadLanguageFile('com_judirectory_' . $topLevelCat->id, JPATH_SITE);
             }
         }
     }
     return;
 }
Beispiel #2
0
 public function getForm($data = array(), $loadData = true)
 {
     if ($data) {
         $data = (object) $data;
     } else {
         $data = $this->getItem();
     }
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $category_xml_path = JPath::find(JForm::addFormPath(), 'category.xml');
     $category_xml = JFactory::getXML($category_xml_path, true);
     if ($data->id) {
         $templateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($data->id);
         $templateFolder = trim($templateStyleObject->folder);
         if ($templateFolder) {
             $template_path = JPATH_SITE . "/components/com_judirectory/templates/" . $templateFolder . "/" . $templateFolder . '.xml';
             if (JFile::exists($template_path)) {
                 $template_xml = JFactory::getXML($template_path, true);
                 if ($template_xml->cat_config) {
                     foreach ($template_xml->cat_config->children() as $child) {
                         $template_params_xpath = $category_xml->xpath('//fieldset[@name="template_params"]');
                         JUDirectoryHelper::appendXML($template_params_xpath[0], $child);
                     }
                     if ($template_xml->languages->count()) {
                         foreach ($template_xml->languages->children() as $language) {
                             $languageFile = (string) $language;
                             $first_pos = strpos($languageFile, '.');
                             $last_pos = strrpos($languageFile, '.');
                             $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
                             $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
                             $path = isset($client->path) ? $client->path : JPATH_BASE;
                             JUDirectoryFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
                         }
                     }
                 }
             }
         }
     }
     $globalconfig_path = JPath::find(JForm::addFormPath(), 'globalconfig.xml');
     $globalconfig_xml = JFactory::getXML($globalconfig_path, true);
     if ($globalconfig_xml) {
         foreach ($globalconfig_xml->children() as $child) {
             $config_params_xpath = $category_xml->xpath('//fields[@name="config_params"]');
             if (isset($config_params_xpath[0])) {
                 JUDirectoryHelper::appendXML($config_params_xpath[0], $child, true);
             }
         }
     }
     $display_params_fields_xpath = $globalconfig_xml->xpath('//fields[@name="display_params"]/fields[@name="cat"]');
     $display_params_xml = $display_params_fields_xpath[0];
     if ($display_params_xml) {
         foreach ($display_params_xml->children() as $child) {
             $display_params_xpath = $category_xml->xpath('//fields[@name="display_params"]');
             JUDirectoryHelper::appendXML($display_params_xpath[0], $child, false, true);
         }
     }
     $plugin_dir = JPATH_SITE . "/plugins/judirectory/";
     $db = JFactory::getDbo();
     $query = "SELECT * FROM #__extensions WHERE type = 'plugin' AND folder = 'judirectory' AND enabled = 1 ORDER BY ordering ASC";
     $db->setQuery($query);
     $elements = $db->loadObjectList();
     if ($elements) {
         foreach ($elements as $index => $element) {
             $folder = $element->element;
             $file_path = $plugin_dir . $folder . "/{$folder}.xml";
             if (JFile::exists($file_path) && JUDirectoryHelper::canEditJUDirectoryPluginParams($folder, $index) === true) {
                 $xml = JFactory::getXML($file_path, true);
                 if ($xml->cat_config) {
                     $ruleXml = new SimpleXMLElement('<fields name="' . $folder . '"></fields>');
                     $plugin_params_xpath = $category_xml->xpath('//fields[@name="plugin_params"]');
                     JUDirectoryHelper::appendXML($plugin_params_xpath[0], $ruleXml);
                     $total_fieldsets = 0;
                     foreach ($xml->cat_config->children() as $child) {
                         $total_fieldsets++;
                         $child->addAttribute('plugin_name', $folder);
                         $jplugin_xpath = $category_xml->xpath('//fields[@name="' . $folder . '"]');
                         JUDirectoryHelper::appendXML($jplugin_xpath[0], $child);
                     }
                     if ($total_fieldsets) {
                         $pluginLabel = $xml->cat_config->attributes()->label ? $xml->cat_config->attributes()->label : $element->name;
                         $this->pluginsCanEdit[$folder] = array('label' => $pluginLabel, 'total_fieldsets' => $total_fieldsets);
                     }
                     if (isset($xml->languages)) {
                         JUDirectoryFrontHelperLanguage::loadLanguageFile($xml->languages, JPATH_ADMINISTRATOR);
                     }
                 }
             }
         }
     }
     $form = $this->loadForm('com_judirectory.category', $category_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     if (!$this->canEditState($data)) {
         $form->setFieldAttribute('featured', 'disabled', 'true');
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('published', 'disabled', 'true');
         $form->setFieldAttribute('publish_up', 'disabled', 'true');
         $form->setFieldAttribute('publish_down', 'disabled', 'true');
         $form->setFieldAttribute('featured', 'filter', 'unset');
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('published', 'filter', 'unset');
         $form->setFieldAttribute('publish_up', 'filter', 'unset');
         $form->setFieldAttribute('publish_down', 'filter', 'unset');
     }
     return $form;
 }
Beispiel #3
0
 public function loadLanguage($fieldFolder)
 {
     $storeId = md5(__METHOD__ . "::" . $fieldFolder);
     if (!isset(self::$cache[$storeId])) {
         $fieldXmlPath = JPATH_SITE . '/components/com_judirectory/fields/' . $fieldFolder . '/' . $fieldFolder . '.xml';
         if (JFile::exists($fieldXmlPath)) {
             $field_xml = JFactory::getXML($fieldXmlPath, true);
             if ($field_xml->languages->count()) {
                 foreach ($field_xml->languages->children() as $language) {
                     $languageFile = (string) $language;
                     $first_pos = strpos($languageFile, '.');
                     $last_pos = strrpos($languageFile, '.');
                     $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
                     $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
                     $path = isset($client->path) ? $client->path : JPATH_BASE;
                     JUDirectoryFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
                 }
             }
         }
         self::$cache[$storeId] = true;
         return self::$cache[$storeId];
     }
     return self::$cache[$storeId];
 }
JLoader::register('JUDirectoryFrontHelperPluginParams', JPATH_SITE . '/components/com_judirectory/helpers/pluginparams.php');
JLoader::register('JUDirectoryFrontHelperRating', JPATH_SITE . '/components/com_judirectory/helpers/rating.php');
JLoader::register('JUDirectoryFrontHelperSeo', JPATH_SITE . '/components/com_judirectory/helpers/seo.php');
JLoader::register('JUDirectoryFrontHelperString', JPATH_SITE . '/components/com_judirectory/helpers/string.php');
JLoader::register('JUDirectoryFrontHelperTemplate', JPATH_SITE . '/components/com_judirectory/helpers/template.php');
JLoader::register('JUDirectoryHelperRoute', JPATH_SITE . '/components/com_judirectory/helpers/route.php');
JLoader::register('JUDirectoryHelper', JPATH_ADMINISTRATOR . '/components/com_judirectory/helpers/judirectory.php');
JLoader::register('JUTimThumb', JPATH_ADMINISTRATOR . '/components/com_judirectory/timthumb/timthumb.php');
JLoader::register('Watermark', JPATH_ADMINISTRATOR . '/components/com_judirectory/helpers/watermark.class.php');
JLoader::register('JUDIRView', JPATH_SITE . '/components/com_judirectory/helpers/judirview.php');
JLoader::register('JUDIRPagination', JPATH_SITE . '/components/com_judirectory/helpers/judirpagination.php');
JLoader::register('JUDIRModelList', JPATH_SITE . '/components/com_judirectory/helpers/judirmodellist.php');
JLoader::register('JUDirectorySearchHelper', JPATH_SITE . '/components/com_judirectory/helpers/search.php');
spl_autoload_register(array('JUDirectoryHelper', 'autoLoadFieldClass'));
JUDirectoryFrontHelperLanguage::loadLanguageForTopLevelCat();
JUDirectoryFrontHelperLanguage::loadLanguageFile("com_judirectory.custom");
if (JUDirectoryHelper::isJoomla3x()) {
    JHtml::_('script', 'system/core.js', false, true);
}
$app = JFactory::getApplication();
$task = $app->input->get('task');
switch ($task) {
    case 'captcha':
        $namespace = $app->input->getString('captcha_namespace', '');
        JUDirectoryFrontHelperCaptcha::captchaSecurityImages($namespace);
        exit;
        break;
    case 'rawdata':
        $field_id = $app->input->getInt('field_id', 0);
        $listing_id = $app->input->getInt('listing_id', 0);
        $fieldObj = JUDirectoryFrontHelperField::getField($field_id, $listing_id);
Beispiel #5
0
 public function getForm($data = array(), $loadData = true)
 {
     $storeId = md5(__METHOD__ . "::" . serialize($data) . "::" . (int) $loadData);
     if (!isset($this->cache[$storeId])) {
         if ($data) {
             $data = (object) $data;
         } else {
             $data = $this->getItem();
         }
         JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_judirectory/models/forms');
         JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_judirectory/models/fields');
         $listing_xml_path = JPath::find(JForm::addFormPath(), 'listing.xml');
         $listing_xml = JFactory::getXML($listing_xml_path, true);
         if ($data->id) {
             $templateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfListing($data->id);
             $templateFolder = trim($templateStyleObject->folder);
             if ($templateFolder) {
                 $template_path = JPATH_SITE . "/components/com_judirectory/templates/" . $templateFolder . "/" . $templateFolder . '.xml';
                 if (JFile::exists($template_path)) {
                     $template_xml = JFactory::getXML($template_path, true);
                     if ($template_xml->listing_config) {
                         foreach ($template_xml->listing_config->children() as $child) {
                             $template_params_xpath = $listing_xml->xpath('//fieldset[@name="template_params"]');
                             JUDirectoryHelper::appendXML($template_params_xpath[0], $child);
                         }
                     }
                     if ($template_xml->languages->count()) {
                         foreach ($template_xml->languages->children() as $language) {
                             $languageFile = (string) $language;
                             $first_pos = strpos($languageFile, '.');
                             $last_pos = strrpos($languageFile, '.');
                             $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
                             $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
                             $path = isset($client->path) ? $client->path : JPATH_BASE;
                             JUDirectoryFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
                         }
                     }
                 }
             }
         }
         $globalconfig_path = JPath::find(JForm::addFormPath(), 'globalconfig.xml');
         $globalconfig_xml = JFactory::getXML($globalconfig_path, true);
         $display_params_fields_xpath = $globalconfig_xml->xpath('//fields[@name="display_params"]/fields[@name="listing"]');
         $display_params_xml = $display_params_fields_xpath[0];
         if ($display_params_xml) {
             foreach ($display_params_xml->children() as $child) {
                 $display_params_xpath = $listing_xml->xpath('//fields[@name="display_params"]');
                 JUDirectoryHelper::appendXML($display_params_xpath[0], $child, false, true);
             }
         }
         $plugin_dir = JPATH_SITE . "/plugins/judirectory/";
         $db = JFactory::getDbo();
         $query = "SELECT * FROM #__extensions WHERE type = 'plugin' AND folder = 'judirectory' AND enabled = 1 ORDER BY ordering ASC";
         $db->setQuery($query);
         $elements = $db->loadObjectList();
         if ($elements) {
             foreach ($elements as $index => $element) {
                 $folder = $element->element;
                 $file_path = $plugin_dir . $folder . "/{$folder}.xml";
                 if (JFile::exists($file_path) && JUDirectoryHelper::canEditJUDirectoryPluginParams($folder, $index) === true) {
                     $xml = JFactory::getXML($file_path, true);
                     if ($xml->listing_config) {
                         $ruleXml = new SimpleXMLElement('<fields name="' . $folder . '"></fields>');
                         $plugin_params_xpath = $listing_xml->xpath('//fields[@name="plugin_params"]');
                         JUDirectoryHelper::appendXML($plugin_params_xpath[0], $ruleXml);
                         $total_fieldsets = 0;
                         foreach ($xml->listing_config->children() as $child) {
                             $total_fieldsets++;
                             $child->addAttribute('plugin_name', $folder);
                             $jplugin_xpath = $listing_xml->xpath('//fields[@name="' . $folder . '"]');
                             JUDirectoryHelper::appendXML($jplugin_xpath[0], $child);
                         }
                         if ($total_fieldsets) {
                             $pluginLabel = $xml->listing_config->attributes()->label ? $xml->listing_config->attributes()->label : $element->name;
                             $this->pluginsCanEdit[$folder] = array('label' => $pluginLabel, 'total_fieldsets' => $total_fieldsets);
                         }
                         if (isset($xml->languages)) {
                             JUDirectoryFrontHelperLanguage::loadLanguageFile($xml->languages, JPATH_ADMINISTRATOR);
                         }
                     }
                 }
             }
         }
         $form = $this->loadForm('com_judirectory.listing', $listing_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData));
         if (!$loadData) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select("field.field_name");
             $query->from("#__judirectory_fields AS field");
             $query->join("LEFT", "#__judirectory_plugins AS plg ON field.plugin_id = plg.id");
             $query->where("field.group_id = 1 AND field.field_name != ''");
             $db->setQuery($query);
             $fieldNames = $db->loadColumn();
             foreach ($fieldNames as $fieldName) {
                 $form->removeField($fieldName);
             }
         }
         if (empty($form)) {
             $this->cache[$storeId] = false;
         }
         $this->cache[$storeId] = $form;
     }
     return $this->cache[$storeId];
 }
Beispiel #6
-1
 public function getForm($data = array(), $loadData = true)
 {
     if ($data) {
         $data = (object) $data;
     } else {
         $data = $this->getItem();
     }
     JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
     JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
     $field_xml_path = JPath::find(JForm::addFormPath(), 'field.xml');
     $field_xml = JFactory::getXML($field_xml_path, true);
     if ($data->plugin_id) {
         $db = JFactory::getDbo();
         $query = 'SELECT folder, type' . ' FROM #__judirectory_plugins' . ' WHERE (id =' . $data->plugin_id . ')';
         $db->setQuery($query);
         $pluginObj = $db->loadObject();
         if ($pluginObj && $pluginObj->folder) {
             $folder = strtolower(str_replace(' ', '', $pluginObj->folder));
             $xml_file = JPATH_SITE . "/components/com_judirectory/fields/" . $folder . "/" . $folder . '.xml';
             if (JFile::exists($xml_file)) {
                 $field_plugin_xml = JFactory::getXML($xml_file);
                 if ($field_plugin_xml->config) {
                     foreach ($field_plugin_xml->config->children() as $child) {
                         $field_params_xpath = $field_xml->xpath('//fieldset[@name="params"]');
                         JUDirectoryHelper::appendXML($field_params_xpath[0], $child);
                     }
                     if ($field_plugin_xml->languages->count()) {
                         foreach ($field_plugin_xml->languages->children() as $language) {
                             $languageFile = (string) $language;
                             $first_pos = strpos($languageFile, '.');
                             $last_pos = strrpos($languageFile, '.');
                             $languageExtName = substr($languageFile, $first_pos + 1, $last_pos - $first_pos - 1);
                             $client = JApplicationHelper::getClientInfo((string) $language->attributes()->client, true);
                             $path = isset($client->path) ? $client->path : JPATH_BASE;
                             JUDirectoryFrontHelperLanguage::loadLanguageFile($languageExtName, $path);
                         }
                     }
                 }
             }
         }
     }
     $form = $this->loadForm('com_judirectory.field', $field_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData));
     if (empty($form)) {
         return false;
     }
     $ignored_options = explode(",", $data->ignored_options);
     foreach ($ignored_options as $ignored_option) {
         $form->setFieldAttribute($ignored_option, 'disabled', 'true');
         $form->setFieldAttribute($ignored_option, 'filter', 'unset');
     }
     if (!$this->canEditState($data)) {
         $form->setFieldAttribute('ordering', 'disabled', 'true');
         $form->setFieldAttribute('published', 'disabled', 'true');
         $form->setFieldAttribute('ordering', 'filter', 'unset');
         $form->setFieldAttribute('published', 'filter', 'unset');
     }
     return $form;
 }