/** * Read custom params from XML file and render them **/ public function _buildFieldParams($type, $params = '') { $xmlPath = JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'fields' . DS . $type . '.xml'; $html = ''; if (JFile::exists($xmlPath)) { $params = new CParameter($params, $xmlPath); $html = $params->render(); } return $html; }
/** * Ajax method to display the application settings * * @params $id Int Application id. * @params $appName String Application element **/ public function ajaxShowSettings($id, $appName) { $filter = JFilterInput::getInstance(); $id = $filter->clean($id, 'int'); $appName = $filter->clean($appName, 'string'); // Check permissions $my =& JFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $objResponse = new JAXResponse(); $appsModel = CFactory::getModel('apps'); $lang =& JFactory::getLanguage(); $lang->load('com_community'); $lang->load('plg_' . JString::strtolower($appName)); $lang->load('plg_' . JString::strtolower($appName), JPATH_ROOT . DS . 'administrator'); $xmlPath = CPluginHelper::getPluginPath('community', $appName) . DS . $appName . DS . 'config.xml'; jimport('joomla.filesystem.file'); $actions = ''; if (JFile::exists($xmlPath)) { $paramStr = $appsModel->getUserAppParams($id); $params = new CParameter($paramStr, $xmlPath); //$paramData = (isset($params->_xml['_default']->param)) ? $params->_xml['_default']->param : array(); $paramData = $params->getParams(); $html = '<form method="POST" action="" name="appSetting" id="appSetting">'; $html .= $params->render(); $html .= '<input type="hidden" value="' . $id . '" name="appid"/>'; $html .= '<input type="hidden" value="' . $appName . '" name="appname"/>'; $html .= '</form>'; if (!empty($paramData) && $paramData !== false) { $actions = '<input onclick="joms.apps.saveSettings()" type="submit" value="' . JText::_('COM_COMMUNITY_APPS_SAVE_BUTTON') . '" class="button" name="Submit"/>'; } } else { $html = '<div class-"ajax-notice-apps-configure">' . JText::_('COM_COMMUNITY_APPS_AJAX_NO_CONFIG') . '</div>'; } $objResponse->addScriptCall('cWindowAddContent', $html, $actions); $objResponse->addAssign('cwin_logo', 'innerHTML', JText::_('COM_COMMUNITY_APPS_SETTINGS_TITLE')); return $objResponse->sendResponse(); }
/** * Ajax method to display the application settings * * @params $id Int Application id. * @params $appName String Application element **/ public function ajaxShowSettings($id, $appName) { $filter = JFilterInput::getInstance(); $id = $filter->clean($id, 'int'); $appName = $filter->clean($appName, 'string'); // Check permissions $my = CFactory::getUser(); if ($my->id == 0) { return $this->ajaxBlockUnregister(); } $json = array(); $appsModel = CFactory::getModel('apps'); $lang = JFactory::getLanguage(); $lang->load('com_community'); $lang->load('plg_community_' . JString::strtolower($appName)); $lang->load('plg_community_' . JString::strtolower($appName), JPATH_ROOT . '/administrator'); $xmlPath = CPluginHelper::getPluginPath('community', $appName) . '/config.xml'; jimport('joomla.filesystem.file'); $actions = ''; if (JFile::exists($xmlPath)) { $paramStr = $appsModel->getUserAppParams($id); $params = new CParameter($paramStr, $xmlPath); //$paramData = (isset($params->_xml['_default']->param)) ? $params->_xml['_default']->param : array(); //$paramData = $params->getParams(); $html = '<form method="POST" action="" name="appSetting" id="appSetting" class="reset-gap">'; $html .= $params->render(); $html .= '<input type="hidden" value="' . $id . '" name="appid"/>'; $html .= '<input type="hidden" value="' . $appName . '" name="appname"/>'; $html .= '</form>'; $actions = '<input onclick="joms.apps.saveSettings()" type="submit" value="' . JText::_('COM_COMMUNITY_APPS_SAVE_BUTTON') . '" class="joms-button--primary joms-button--full-small" name="Submit"/>'; $json['html'] = $html; $json['btnSave'] = JText::_('COM_COMMUNITY_APPS_SAVE_BUTTON'); } else { $html = '<div class-"ajax-notice-apps-configure">' . JText::_('COM_COMMUNITY_APPS_AJAX_NO_CONFIG') . '</div>'; $json['html'] = $html; } $json['title'] = JText::_('COM_COMMUNITY_APPS_SETTINGS_TITLE'); $json['paramStr'] = isset($paramStr) ? $paramStr : ''; $json['xmlPath'] = $xmlPath; die(json_encode($json)); }