本文整理汇总了PHP中ConnectorUtils类的典型用法代码示例。如果您正苦于以下问题:PHP ConnectorUtils类的具体用法?PHP ConnectorUtils怎么用?PHP ConnectorUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectorUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConnectorFailsNullGracefully
function testConnectorFailsNullGracefully()
{
//now write a connector file with missing array info instead of an array for the connector var
file_put_contents($this->custom_path . '/connectors.php', "<?php\n ");
//create the connector and call getConnectors
$cu = new ConnectorUtils();
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $cu->getConnectors(true), 'ConnectorsUtils::getConnectors() failed to return an array when connectors array was missing. ');
}
示例2: filterAPIList
/**
* Filter the list of APIs, removing disabled ones
* @param array $apiFullList
* @return array Filtered list
*/
public static function filterAPIList($apiFullList)
{
$filteredList = array();
foreach ($apiFullList as $name => $data) {
if (isset($data['connector'])) {
if (ConnectorUtils::eapmEnabled($data['connector'])) {
if (isset($data['authMethod']) && $data['authMethod'] == 'oauth') {
$connector = SourceFactory::getSource($data['connector'], false);
if (!empty($connector) && $connector->propertyExists('oauth_consumer_key') && $connector->isRequiredConfigFieldsSet()) {
$filteredList[$name] = $data;
}
} elseif (isset($data['authMethod']) && $data['authMethod'] == 'oauth2') {
$connector = SourceFactory::getSource($data['connector'], false);
if (!empty($connector) && $connector->isRequiredConfigFieldsSet()) {
$filteredList[$name] = $data;
}
} else {
$filteredList[$name] = $data;
}
}
} else {
$filteredList[$name] = $data;
}
}
return $filteredList;
}
示例3: filterAPIList
/**
* Filter the list of APIs, removing disabled ones
* @param array $apiFullList
* @return array Filtered list
*/
public static function filterAPIList($apiFullList)
{
$filteredList = array();
foreach ($apiFullList as $name => $data) {
if (isset($data['connector'])) {
if (ConnectorUtils::eapmEnabled($data['connector'])) {
if (isset($data['authMethod']) && $data['authMethod'] == 'oauth') {
$connector = SourceFactory::getSource($data['connector'], false);
if (!empty($connector)) {
$key = $connector->getProperty('oauth_consumer_key');
$secret = $connector->getProperty('oauth_consumer_secret');
if (!empty($key) && !empty($secret)) {
$filteredList[$name] = $data;
}
}
} else {
$filteredList[$name] = $data;
}
}
} else {
$filteredList[$name] = $data;
}
}
return $filteredList;
}
示例4: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings;
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
$this->ss->assign('mod', $mod_strings);
$this->ss->assign('APP', $app_strings);
$connectors = ConnectorUtils::getConnectors(true);
$required_fields = array();
//Get required fields for first connector only
$connectorsToShow = $connectors;
foreach ($connectors as $id => $entry) {
$s = SourceFactory::getSource($id);
$connector_strings = ConnectorUtils::getConnectorStrings($id);
$fields = $s->getRequiredConfigFields();
if (!$s->isEnabledInAdminProperties() || empty($fields)) {
unset($connectorsToShow[$id]);
} else {
if (empty($required_fields)) {
foreach ($fields as $field_id) {
$label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id;
$required_fields[$id][$field_id] = $label;
}
}
}
}
$this->ss->assign('SOURCES', $connectorsToShow);
$this->ss->assign('REQUIRED_FIELDS', $required_fields);
// Handle active tab selection
$active_tab = isset($_REQUEST['active_tab']) ? $_REQUEST['active_tab'] : null;
$this->ss->assign('ACTIVE_TAB', $active_tab);
echo $this->getModuleTitle(false);
$this->ss->display($this->getCustomFilePathIfExists('modules/Connectors/tpls/modify_properties.tpl'));
}
示例5: display
public function display()
{
global $sugar_config;
require_once 'include/connectors/sources/SourceFactory.php';
require_once 'include/connectors/utils/ConnectorUtils.php';
$source_id = $_REQUEST['source_id'];
$connector_language = ConnectorUtils::getConnectorStrings($source_id);
$source = SourceFactory::getSource($source_id);
$properties = $source->getProperties();
$required_fields = array();
$config_fields = $source->getRequiredConfigFields();
$fields = $source->getRequiredConfigFields();
foreach ($fields as $field_id) {
$label = isset($connector_language[$field_id]) ? $connector_language[$field_id] : $field_id;
$required_fields[$field_id] = $label;
}
// treat string as a template (the string resource plugin is unavailable in the current Smarty version)
if (isset($connector_language['LBL_LICENSING_INFO'])) {
$siteUrl = rtrim($sugar_config['site_url'], '/');
$connector_language['LBL_LICENSING_INFO'] = str_replace('{$SITE_URL}', $siteUrl, $connector_language['LBL_LICENSING_INFO']);
}
$this->ss->assign('required_properties', $required_fields);
$this->ss->assign('source_id', $source_id);
$this->ss->assign('properties', $properties);
$this->ss->assign('mod', $GLOBALS['mod_strings']);
$this->ss->assign('app', $GLOBALS['app_strings']);
$this->ss->assign('connector_language', $connector_language);
$this->ss->assign('hasTestingEnabled', $source->hasTestingEnabled());
echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/source_properties.tpl'));
}
示例6: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings;
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
$this->ss->assign('mod', $mod_strings);
$this->ss->assign('APP', $app_strings);
$connectors = ConnectorUtils::getConnectors(true);
$required_fields = array();
//Get required fields for first connector only
$connectorsToShow = $connectors;
foreach ($connectors as $id => $entry) {
$s = SourceFactory::getSource($id);
$connector_strings = ConnectorUtils::getConnectorStrings($id);
$fields = $s->getRequiredConfigFields();
if (empty($fields)) {
unset($connectorsToShow[$id]);
} else {
if (empty($required_fields)) {
foreach ($fields as $field_id) {
$label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id;
$required_fields[$id][$field_id] = $label;
}
}
}
}
$this->ss->assign('SOURCES', $connectorsToShow);
$this->ss->assign('REQUIRED_FIELDS', $required_fields);
echo $this->getModuleTitle();
$this->ss->display('modules/Connectors/tpls/modify_properties.tpl');
}
示例7: display
function display()
{
global $mod_strings, $app_strings;
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
$sugar_smarty = new Sugar_Smarty();
$sugar_smarty->assign('mod', $mod_strings);
$sugar_smarty->assign('APP', $app_strings);
$connectors = ConnectorUtils::getConnectors(true);
$required_fields = array();
//Get required fields for first connector only
foreach ($connectors as $id => $entry) {
$s = SourceFactory::getSource($id);
$connector_strings = ConnectorUtils::getConnectorStrings($id);
$fields = $s->getRequiredConfigFields();
foreach ($fields as $field_id) {
$label = isset($connector_strings[$field_id]) ? $connector_strings[$field_id] : $field_id;
$required_fields[$id][$field_id] = $label;
}
break;
}
$sugar_smarty->assign('SOURCES', $connectors);
$sugar_smarty->assign('REQUIRED_FIELDS', $required_fields);
echo get_module_title('Connectors', $mod_strings['LBL_MODIFY_PROPERTIES_PAGE_TITLE'], true);
$sugar_smarty->display('modules/Connectors/tpls/modify_properties.tpl');
}
示例8: display
/**
* @see SugarView::display()
*/
public function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
$source = $_REQUEST['source_id'];
$sources = ConnectorUtils::getConnectors();
$modules_sources = ConnectorUtils::getDisplayConfig();
//$json = getJSONobj();
$enabled_modules = array();
$disabled_modules = array();
//Find all modules this source has been enabled for
foreach ($modules_sources as $module => $mapping) {
foreach ($modules_sources[$module] as $entry) {
if ($entry == $source) {
$enabled_modules[$module] = $module;
}
}
}
global $moduleList, $beanList;
//Do filtering here?
$count = 0;
global $current_user;
$access = $current_user->getDeveloperModules();
$d = dir('modules');
while ($e = $d->read()) {
if (substr($e, 0, 1) == '.' || !is_dir('modules/' . $e)) {
continue;
}
if (empty($enabled_modules[$e]) && file_exists('modules/' . $e . '/metadata/studio.php') && file_exists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) {
$disabled_modules[$e] = $e;
}
}
$s = SourceFactory::getSource($source);
// Not all sources can be connected to all modules
$enabled_modules = $s->filterAllowedModules($enabled_modules);
$disabled_modules = $s->filterAllowedModules($disabled_modules);
asort($enabled_modules);
asort($disabled_modules);
//$enabled = $json->encode($enabled_modules);
//$disabled = $json->encode($disabled_modules);
//$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n";
//$this->ss->assign('new_modules_sources', $modules_sources);
//$this->ss->assign('dynamic_script', $script);
$this->ss->assign('enabled_modules', $enabled_modules);
$this->ss->assign('disabled_modules', $disabled_modules);
$this->ss->assign('source_id', $source);
$this->ss->assign('mod', $GLOBALS['mod_strings']);
$this->ss->assign('APP', $GLOBALS['app_strings']);
$this->ss->assign('theme', $GLOBALS['theme']);
$this->ss->assign('external', !empty($sources[$source]['eapm']));
$this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only']));
// We don't want to tell the user to set the properties of the connector if there aren't any
$fields = $s->getRequiredConfigFields();
$this->ss->assign('externalHasProperties', !empty($fields));
$this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : "");
echo $this->ss->fetch('modules/Connectors/tpls/display_properties.tpl');
}
示例9: display
function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
$sources = ConnectorUtils::getConnectors();
$this->ss->assign('SOURCES', $sources);
$this->ss->assign('mod', $GLOBALS['mod_strings']);
$this->ss->assign('APP', $GLOBALS['app_strings']);
$this->ss->assign('theme', $GLOBALS['theme']);
echo get_module_title('Connectors', $GLOBALS['mod_strings']['LBL_MODIFY_DISPLAY_PAGE_TITLE'], true);
$this->ss->display('modules/Connectors/tpls/modify_display.tpl');
}
示例10: run
public function run()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
if (!ConnectorUtils::updateMetaDataFiles()) {
$this->log('Cannot update metadata files for connectors');
}
//Delete the custom connectors.php file if it exists so that it may be properly rebuilt
if (file_exists('custom/modules/Connectors/metadata/connectors.php')) {
unlink('custom/modules/Connectors/metadata/connectors.php');
}
}
示例11: smarty_function_sugarvar_connector
function smarty_function_sugarvar_connector($params, &$smarty)
{
$displayParams = $smarty->get_template_vars('displayParams');
if (!isset($displayParams['module'])) {
$smarty->trigger_error("sugarvar_connector: missing 'module' parameter");
$GLOBALS['log']->error("sugarvar_connector: missing 'module' parameter");
return;
}
require_once 'include/connectors/utils/ConnectorUtils.php';
echo ConnectorUtils::getConnectorButtonScript($displayParams, $smarty);
}
示例12: display
/**
* @see SugarView::display()
*/
public function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
$sources = ConnectorUtils::getConnectors();
$this->ss->assign('SOURCES', $sources);
$this->ss->assign('mod', $GLOBALS['mod_strings']);
$this->ss->assign('APP', $GLOBALS['app_strings']);
$this->ss->assign('theme', $GLOBALS['theme']);
echo $this->getModuleTitle();
$this->ss->display('modules/Connectors/tpls/modify_display.tpl');
}
示例13: display
/**
* @see SugarView::display()
*/
public function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
global $mod_strings, $app_strings;
$this->ss->assign('mod', $mod_strings);
$this->ss->assign('APP', $app_strings);
$connectors = ConnectorUtils::getConnectors(true);
$this->ss->assign('SOURCES', $connectors);
echo $this->getModuleTitle();
$this->ss->display('modules/Connectors/tpls/modify_mapping.tpl');
}
示例14: display
/**
* @see SugarView::display()
*/
public function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
$source = $_REQUEST['source_id'];
$sources = ConnectorUtils::getConnectors();
$modules_sources = ConnectorUtils::getDisplayConfig();
$enabled_modules = array();
$disabled_modules = array();
//Find all modules this source has been enabled for
foreach ($modules_sources as $module => $mapping) {
foreach ($modules_sources[$module] as $entry) {
if ($entry == $source) {
$enabled_modules[$module] = isset($GLOBALS['app_list_strings']['moduleList'][$module]) ? $GLOBALS['app_list_strings']['moduleList'][$module] : $module;
}
}
}
global $moduleList, $beanList;
//Do filtering here?
$count = 0;
global $current_user;
$access = $current_user->getDeveloperModules();
foreach (SugarAutoLoader::getDirFiles("modules", true) as $e) {
//Strip the 'modules/' portion out from beginning of $e
$e = substr($e, 8);
if (empty($enabled_modules[$e]) && SugarAutoLoader::existingCustomOne("modules/{$e}/metadata/studio.php") && SugarAutoLoader::fileExists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS['beanList'][$e]) && (in_array($e, $access) || is_admin($current_user))) {
$disabled_modules[$e] = isset($GLOBALS['app_list_strings']['moduleList'][$e]) ? $GLOBALS['app_list_strings']['moduleList'][$e] : $e;
}
}
$s = SourceFactory::getSource($source);
// Not all sources can be connected to all modules
$enabled_modules = $s->filterAllowedModules($enabled_modules);
$disabled_modules = $s->filterAllowedModules($disabled_modules);
asort($enabled_modules);
asort($disabled_modules);
//$enabled = $json->encode($enabled_modules);
//$disabled = $json->encode($disabled_modules);
//$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n";
//$this->ss->assign('new_modules_sources', $modules_sources);
//$this->ss->assign('dynamic_script', $script);
$this->ss->assign('enabled_modules', $enabled_modules);
$this->ss->assign('disabled_modules', $disabled_modules);
$this->ss->assign('source_id', $source);
$this->ss->assign('mod', $GLOBALS['mod_strings']);
$this->ss->assign('APP', $GLOBALS['app_strings']);
$this->ss->assign('theme', $GLOBALS['theme']);
$this->ss->assign('external', !empty($sources[$source]['eapm']));
$this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only']));
// We don't want to tell the user to set the properties of the connector if there aren't any
$fields = $s->getRequiredConfigFields();
$this->ss->assign('externalHasProperties', !empty($fields));
$this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled']) ? " checked" : "");
echo $this->ss->fetch($this->getCustomFilePathIfExists('modules/Connectors/tpls/display_properties.tpl'));
}
示例15: display
function display()
{
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
global $mod_strings, $app_strings;
$sugar_smarty = new Sugar_Smarty();
$sugar_smarty->assign('mod', $mod_strings);
$sugar_smarty->assign('APP', $app_strings);
$connectors = ConnectorUtils::getConnectors(true);
$sugar_smarty->assign('SOURCES', $connectors);
echo get_module_title('Connectors', $mod_strings['LBL_MODIFY_MAPPING_PAGE_TITLE'], true);
$sugar_smarty->display('modules/Connectors/tpls/modify_mapping.tpl');
}