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 = JUDownloadHelper::getCatsByLevel(1, $id); break; case 'document': $catId = JUDownloadFrontHelperCategory::getMainCategoryId($id); $topLevelCats = JUDownloadHelper::getCatsByLevel(1, $catId); break; } if (!empty($topLevelCats)) { $topLevelCat = $topLevelCats[0]; if ($view == 'category' || $view == 'document') { JUDownloadFrontHelperLanguage::loadLanguageFile('com_judownload_' . $topLevelCat->id, JPATH_SITE); } } } return; }
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 #__judownload_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_judownload/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"]'); JUDownloadHelper::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; JUDownloadFrontHelperLanguage::loadLanguageFile($languageExtName, $path); } } } } } } $form = $this->loadForm('com_judownload.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; }
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'); $style_xml_path = JPath::find(JForm::addFormPath(), strtolower('style') . '.xml'); $style_xml = JFactory::getXML($style_xml_path, true); if (isset($data->template_id) && $data->template_id) { $styleObject = JUDownloadFrontHelperTemplate::getTemplateStyleObject($data->id); $folder = $styleObject->folder; $folder = strtolower(str_replace(' ', '', $folder)); if ($folder) { $xml_file = JPath::clean(JPATH_SITE . "/components/com_judownload/templates/" . $folder . "/" . $folder . '.xml'); if (JFile::exists($xml_file)) { $xml = JFactory::getXML($xml_file); if ($xml->config) { foreach ($xml->config->children() as $child) { $style_params_xpath = $style_xml->xpath('//fieldset[@name="params"]'); JUDownloadHelper::appendXML($style_params_xpath[0], $child); } if ($xml->languages->count()) { foreach ($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; JUDownloadFrontHelperLanguage::loadLanguageFile($languageExtName, $path); } } } } } } $form = $this->loadForm('com_judownload.style', $style_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData)); if (empty($form)) { return false; } $app = JFactory::getApplication(); $id = $app->input->get('id', 0); if ($id) { $form->setFieldAttribute('template_id', 'disabled', 'true'); $form->setFieldAttribute('template_id', 'filter', 'unset'); if (isset($data->home) && $data->home == 1) { $form->setFieldAttribute('home', 'disabled', 'true'); } } return $form; }
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_judownload/models/forms'); JForm::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_judownload/models/fields'); $document_xml_path = JPath::find(JForm::addFormPath(), 'document.xml'); $document_xml = JFactory::getXML($document_xml_path, true); if ($data->id) { $templateStyleObject = JUDownloadFrontHelperTemplate::getTemplateStyleOfDocument($data->id); $templateFolder = trim($templateStyleObject->folder); if ($templateFolder) { $template_path = JPATH_SITE . "/components/com_judownload/templates/" . $templateFolder . "/" . $templateFolder . '.xml'; if (JFile::exists($template_path)) { $template_xml = JFactory::getXML($template_path, true); if ($template_xml->doc_config) { foreach ($template_xml->doc_config->children() as $child) { $template_params_xpath = $document_xml->xpath('//fieldset[@name="template_params"]'); JUDownloadHelper::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; JUDownloadFrontHelperLanguage::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="doc"]'); $display_params_xml = $display_params_fields_xpath[0]; if ($display_params_xml) { foreach ($display_params_xml->children() as $child) { $display_params_xpath = $document_xml->xpath('//fields[@name="display_params"]'); JUDownloadHelper::appendXML($display_params_xpath[0], $child, false, true); } } $plugin_dir = JPATH_SITE . "/plugins/judownload/"; $db = JFactory::getDbo(); $query = "SELECT * FROM #__extensions WHERE type = 'plugin' AND folder = 'judownload' 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) && JUDownloadHelper::canEditJUDownloadPluginParams($folder, $index) === true) { $xml = JFactory::getXML($file_path, true); if ($xml->doc_config) { $ruleXml = new SimpleXMLElement('<fields name="' . $folder . '"></fields>'); $plugin_params_xpath = $document_xml->xpath('//fields[@name="plugin_params"]'); JUDownloadHelper::appendXML($plugin_params_xpath[0], $ruleXml); $total_fieldsets = 0; foreach ($xml->doc_config->children() as $child) { $total_fieldsets++; $child->addAttribute('plugin_name', $folder); $jplugin_xpath = $document_xml->xpath('//fields[@name="' . $folder . '"]'); JUDownloadHelper::appendXML($jplugin_xpath[0], $child); } if ($total_fieldsets) { $pluginLabel = $xml->doc_config->attributes()->label ? $xml->doc_config->attributes()->label : $element->name; $this->pluginsCanEdit[$folder] = array('label' => $pluginLabel, 'total_fieldsets' => $total_fieldsets); } if (isset($xml->languages)) { JUDownloadFrontHelperLanguage::loadLanguageFile($xml->languages, JPATH_ADMINISTRATOR); } } } } } $form = $this->loadForm('com_judownload.document', $document_xml->asXML(), array('control' => 'jform', 'load_data' => $loadData)); if (!$loadData) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select("field.field_name"); $query->from("#__judownload_fields AS field"); $query->join("LEFT", "#__judownload_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]; }
JLoader::register('JUDownloadHelper', JPATH_ADMINISTRATOR . '/components/com_judownload/helpers/judownload.php'); JLoader::register('JUTimThumb', JPATH_ADMINISTRATOR . '/components/com_judownload/timthumb/timthumb.php'); JLoader::register('Watermark', JPATH_ADMINISTRATOR . '/components/com_judownload/helpers/watermark.class.php'); JLoader::register('JUDLView', JPATH_SITE . '/components/com_judownload/helpers/judlview.php'); JLoader::register('JUDLPagination', JPATH_SITE . '/components/com_judownload/helpers/judlpagination.php'); JLoader::register('JUDLModelList', JPATH_SITE . '/components/com_judownload/helpers/judlmodellist.php'); JLoader::register('JUDownloadSearchHelper', JPATH_SITE . '/components/com_judownload/helpers/search.php'); spl_autoload_register(array('JUDownloadHelper', 'autoLoadFieldClass')); JUDownloadFrontHelperLanguage::loadLanguageForTopLevelCat(); JUDownloadFrontHelperLanguage::loadLanguageFile("com_judownload.custom"); if (JUDownloadHelper::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', ''); JUDownloadFrontHelperCaptcha::captchaSecurityImages($namespace); exit;
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 = JUDownloadFrontHelperTemplate::getTemplateStyleOfCategory($data->id); $templateFolder = trim($templateStyleObject->folder); if ($templateFolder) { $template_path = JPATH_SITE . "/components/com_judownload/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"]'); JUDownloadHelper::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; JUDownloadFrontHelperLanguage::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])) { JUDownloadHelper::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"]'); JUDownloadHelper::appendXML($display_params_xpath[0], $child, false, true); } } $plugin_dir = JPATH_SITE . "/plugins/judownload/"; $db = JFactory::getDbo(); $query = "SELECT * FROM #__extensions WHERE type = 'plugin' AND folder = 'judownload' 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) && JUDownloadHelper::canEditJUDownloadPluginParams($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"]'); JUDownloadHelper::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 . '"]'); JUDownloadHelper::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)) { JUDownloadFrontHelperLanguage::loadLanguageFile($xml->languages, JPATH_ADMINISTRATOR); } } } } } $form = $this->loadForm('com_judownload.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; }
public function loadLanguage($fieldFolder) { $storeId = md5(__METHOD__ . "::" . $fieldFolder); if (!isset(self::$cache[$storeId])) { $fieldXmlPath = JPATH_SITE . '/components/com_judownload/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; JUDownloadFrontHelperLanguage::loadLanguageFile($languageExtName, $path); } } } self::$cache[$storeId] = true; return self::$cache[$storeId]; } return self::$cache[$storeId]; }