Пример #1
0
 /**
  * Get popup for sources
  *
  * @param array $shown_sources
  * @param mixed $module
  * @param mixed $smarty
  * @return string
  */
 private function getPopup(array $shown_sources, $module, $smarty)
 {
     global $app_strings;
     $code = '';
     $menuParams = 'var menuParams = "';
     $formatterCode = '';
     $sourcesDisplayed = 0;
     $singleIcon = '';
     foreach ($shown_sources as $id) {
         $formatter = FormatterFactory::getInstance($id);
         $formatter->setModule($module);
         $formatter->setSmarty($smarty);
         $buttonCode = $formatter->getDetailViewFormat();
         if (!empty($buttonCode)) {
             $sourcesDisplayed++;
             $singleIcon = $formatter->getIconFilePath();
             $source = SourceFactory::getSource($id);
             $config = $source->getConfig();
             $name = !empty($config['name']) ? $config['name'] : $id;
             //Create the menu item to call show_[source id] method in javascript
             $menuParams .= '<a href=\'#\' style=\'width:150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\\"yes\\");\'' . ' onmouseout=\'unhiliteItem(this);\' onclick=\'show_' . $id . '(event);\'>' . $name . '</a>';
             $formatterCode .= $buttonCode;
         }
     }
     //for
     if (!empty($formatterCode)) {
         if ($sourcesDisplayed > 1) {
             $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
             $code = '<!--not_in_theme!--><img id="dswidget_img" src="' . $dswidget_img . '" width="11" height="7" border="0" alt="' . $app_strings['LBL_CONNECTORS_POPUPS'] . '" onclick="return showConnectorMenu2(this);">';
         } else {
             $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
             $singleIcon = empty($singleIcon) ? $dswidget_img : $singleIcon;
             $code = '<!--not_in_theme!--><img id="dswidget_img" border="0" src="' . $singleIcon . '" alt="' . $app_strings['LBL_CONNECTORS_POPUPS'] . '" onclick="return showConnectorMenu2(this);">';
         }
         $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>\n";
         $code .= "<script type='text/javascript'>\n";
         $code .= "function showConnectorMenu2(el) {literal} { {/literal}\n";
         $menuParams .= '";';
         $code .= $menuParams . "\n";
         $code .= "return SUGAR.util.showHelpTips(el,menuParams);\n";
         $code .= "{literal} } {/literal}\n";
         $code .= "</script>\n";
         $code .= $formatterCode;
     }
     return $code;
 }
Пример #2
0
 /**
  * updateMetaDataFiles
  * This method updates the metadata files (detailviewdefs.php) according to the settings in display_config.php
  * @return $result boolean value indicating whether or not the method successfully completed.
  */
 public static function updateMetaDataFiles()
 {
     if (file_exists(CONNECTOR_DISPLAY_CONFIG_FILE)) {
         $modules_sources = array();
         require CONNECTOR_DISPLAY_CONFIG_FILE;
         $GLOBALS['log']->debug(var_export($modules_sources, true));
         if (!empty($modules_sources)) {
             foreach ($modules_sources as $module => $mapping) {
                 $metadata_file = file_exists("custom/modules/{$module}/metadata/detailviewdefs.php") ? "custom/modules/{$module}/metadata/detailviewdefs.php" : "modules/{$module}/metadata/detailviewdefs.php";
                 $viewdefs = array();
                 if (!file_exists($metadata_file)) {
                     $GLOBALS['log']->info("Unable to update metadata file for module: {$module}");
                     continue;
                 } else {
                     require $metadata_file;
                 }
                 $insertConnectorButton = true;
                 self::removeHoverField($viewdefs, $module);
                 //Insert the hover field if available
                 if (!empty($mapping)) {
                     require_once 'include/connectors/sources/SourceFactory.php';
                     require_once 'include/connectors/formatters/FormatterFactory.php';
                     $shown_formatters = array();
                     foreach ($mapping as $id) {
                         $source = SourceFactory::getSource($id, false);
                         if ($source->isEnabledInHover() && $source->isRequiredConfigFieldsForButtonSet()) {
                             $shown_formatters[$id] = FormatterFactory::getInstance($id);
                         }
                     }
                     //Now we have to decide which field to put it on... use the first one for now
                     if (!empty($shown_formatters)) {
                         foreach ($shown_formatters as $id => $formatter) {
                             $added_field = false;
                             $formatter_mapping = $formatter->getSourceMapping();
                             $source = $formatter->getComponent()->getSource();
                             //go through the mapping and add the hover to every field define in the mapping
                             //1) check for hover fields
                             $hover_fields = $source->getFieldsWithParams('hover', true);
                             foreach ($hover_fields as $key => $def) {
                                 if (!empty($formatter_mapping['beans'][$module][$key])) {
                                     $added_field = self::setHoverField($viewdefs, $module, $formatter_mapping['beans'][$module][$key], $id);
                                 }
                             }
                             //2) check for first mapping field
                             if (!$added_field && !empty($formatter_mapping['beans'][$module])) {
                                 foreach ($formatter_mapping['beans'][$module] as $key => $val) {
                                     $added_field = self::setHoverField($viewdefs, $module, $val, $id);
                                     if ($added_field) {
                                         break;
                                     }
                                 }
                             }
                         }
                         //foreach
                         //Log an error message
                         if (!$added_field) {
                             $GLOBALS['log']->fatal("Unable to place hover field link on metadata for module {$module}");
                         }
                     }
                 }
                 //Make the directory for the metadata file
                 if (!file_exists("custom/modules/{$module}/metadata")) {
                     mkdir_recursive("custom/modules/{$module}/metadata");
                 }
                 if (!write_array_to_file('viewdefs', $viewdefs, "custom/modules/{$module}/metadata/detailviewdefs.php")) {
                     $GLOBALS['log']->fatal("Cannot update file custom/modules/{$module}/metadata/detailviewdefs.php");
                     return false;
                 }
                 if (file_exists($cachedfile = sugar_cached("modules/{$module}/DetailView.tpl")) && !unlink($cachedfile)) {
                     $GLOBALS['log']->fatal("Cannot delete file {$cachedfile}");
                     return false;
                 }
             }
         }
     }
     return true;
 }
Пример #3
0
 /**
  * getConnectorButtonScript
  * This method builds the HTML code for the hover link field
  *
  * @param mixed $displayParams Array value of display parameters passed from the SugarField code
  * @param mixed $smarty The Smarty object from the calling smarty code
  * @return String $code The HTML code for the hover link
  */
 public static function getConnectorButtonScript($displayParams, $smarty)
 {
     $module = $displayParams['module'];
     require_once 'include/connectors/utils/ConnectorUtils.php';
     $modules_sources = self::getDisplayConfig();
     global $current_language, $app_strings;
     $mod_strings = return_module_language($current_language, 'Connectors');
     $menuParams = 'var menuParams = "';
     $shown_sources = array();
     if (!empty($module) && !empty($displayParams['connectors'])) {
         foreach ($displayParams['connectors'] as $id) {
             if (!empty($modules_sources[$module]) && in_array($id, $modules_sources[$module])) {
                 $shown_sources[] = $id;
             }
         }
         if (empty($shown_sources)) {
             return '';
         }
         require_once 'include/connectors/formatters/FormatterFactory.php';
         $code = '';
         //If there is only one source, just show the icon or some standalone view
         if (count($shown_sources) == 1) {
             $formatter = FormatterFactory::getInstance($shown_sources[0]);
             $formatter->setModule($module);
             $formatter->setSmarty($smarty);
             $formatter_code = $formatter->getDetailViewFormat();
             if (!empty($formatter_code)) {
                 $iconFilePath = $formatter->getIconFilePath();
                 $iconFilePath = empty($iconFilePath) ? 'themes/default/images/MoreDetail.png' : $iconFilePath;
                 $code = '<img id="dswidget_img" border="0" src="' . $iconFilePath . '" alt="' . $shown_sources[0] . '" onmouseover="show_' . $shown_sources[0] . '(event);">';
                 $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>";
                 $code .= $formatter->getDetailViewFormat();
                 $code .= $formatter_code;
             }
             return $code;
         } else {
             $formatterCode = '';
             $sourcesDisplayed = 0;
             $singleIcon = '';
             foreach ($shown_sources as $id) {
                 $formatter = FormatterFactory::getInstance($id);
                 $formatter->setModule($module);
                 $formatter->setSmarty($smarty);
                 $buttonCode = $formatter->getDetailViewFormat();
                 if (!empty($buttonCode)) {
                     $sourcesDisplayed++;
                     $singleIcon = $formatter->getIconFilePath();
                     $source = SourceFactory::getSource($id);
                     $config = $source->getConfig();
                     $name = !empty($config['name']) ? $config['name'] : $id;
                     //Create the menu item to call show_[source id] method in javascript
                     $menuParams .= '<a href=\'#\' style=\'width:150px\' class=\'menuItem\' onmouseover=\'hiliteItem(this,\\"yes\\");\' onmouseout=\'unhiliteItem(this);\' onclick=\'show_' . $id . '(event);\'>' . $name . '</a>';
                     $formatterCode .= $buttonCode;
                 }
             }
             //for
             if (!empty($formatterCode)) {
                 if ($sourcesDisplayed > 1) {
                     $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
                     $code = '<img id="dswidget_img" src="' . $dswidget_img . '" width="11" height="7" border="0" alt="connectors_popups" onmouseover="return showConnectorMenu2();" onmouseout="return nd(1000);">';
                 } else {
                     $dswidget_img = SugarThemeRegistry::current()->getImageURL('MoreDetail.png');
                     $singleIcon = empty($singleIcon) ? $dswidget_img : $singleIcon;
                     $code = '<img id="dswidget_img" border="0" src="' . $singleIcon . '" alt="connectors_popups" onmouseover="return showConnectorMenu2();" onmouseout="return nd(1000);">';
                 }
                 $code .= "{overlib_includes}\n";
                 $code .= "<script type='text/javascript' src='{sugar_getjspath file='include/connectors/formatters/default/company_detail.js'}'></script>\n";
                 $code .= "<script type='text/javascript'>\n";
                 $code .= "function showConnectorMenu2() {literal} { {/literal}\n";
                 $menuParams .= '";';
                 $code .= $menuParams . "\n";
                 $code .= "return overlib(menuParams, CENTER, STICKY, MOUSEOFF, 3000, WIDTH, 110, FGCLASS, 'olOptionsFgClass', CGCLASS, 'olOptionsCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olOptionsCapFontClass', CLOSEFONTCLASS, 'olOptionsCloseFontClass');\n";
                 $code .= "{literal} } {/literal}\n";
                 $code .= "</script>\n";
                 $code .= $formatterCode;
             }
             return $code;
         }
         //if-else
     }
     //if
 }
Пример #4
0
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 *
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 ********************************************************************************/
/**
 * Use this script to fetch linkedin js code.
 */
$url = '';
$type = !empty($_GET['type']) ? $_GET['type'] : '';
switch ($type) {
    case 'linkedin':
        require_once 'include/connectors/formatters/FormatterFactory.php';
        $formatter = FormatterFactory::getInstance('ext_rest_linkedin');
        $url = $formatter->getComponent()->getSource()->getConfig();
        $url = $url['properties']['company_url'];
        break;
}
if ($url == '') {
    return;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, '30');
curl_exec($ch);
curl_close($ch);