コード例 #1
0
ファイル: PPAPIService.php プロジェクト: mayoalexander/fl-two
 public function makeRequest($apiMethod, $params, $apiUsername = null, $accessToken = null, $tokenSecret = null)
 {
     $config = PPConfigManager::getInstance();
     if (is_string($apiUsername) || is_null($apiUsername)) {
         // $apiUsername is optional, if null the default account in config file is taken
         $credMgr = PPCredentialManager::getInstance();
         $apiCredential = clone $credMgr->getCredentialObject($apiUsername);
     } else {
         $apiCredential = $apiUsername;
         //TODO: Aargh
     }
     if (isset($accessToken) && isset($tokenSecret)) {
         $apiCredential->setThirdPartyAuthorization(new PPTokenAuthorization($accessToken, $tokenSecret));
     }
     if ($this->serviceBinding == 'SOAP') {
         $url = $this->endpoint;
     } else {
         $url = $this->endpoint . $this->serviceName . '/' . $apiMethod;
     }
     $request = new PPRequest($params, $this->serviceBinding);
     $request->setCredential($apiCredential);
     $httpConfig = new PPHttpConfig($url, PPHttpConfig::HTTP_POST);
     $this->runHandlers($httpConfig, $request);
     $formatter = FormatterFactory::factory($this->serviceBinding);
     $payload = $formatter->toString($request);
     $connection = PPConnectionManager::getInstance()->getConnection($httpConfig);
     $this->logger->info("Request: {$payload}");
     $response = $connection->execute($payload);
     $this->logger->info("Response: {$response}");
     return array('request' => $payload, 'response' => $response);
 }
コード例 #2
0
 protected function formatSource($source)
 {
     /** @var ParentNode $node */
     $node = Parser::parseSource($source);
     $formatter = FormatterFactory::getDrupalFormatter();
     $formatter->format($node);
     return $node->getText();
 }
コード例 #3
0
ファイル: DocCommentTrait.php プロジェクト: kidaa30/redcat
 /**
  * @param DocCommentNode $comment
  * @return $this
  */
 public function setDocComment(DocCommentNode $comment)
 {
     if (isset($this->docComment)) {
         $this->docComment->remove();
     }
     $indent = $this->getIndent();
     $comment->setIndent($indent);
     $nl = FormatterFactory::getDefaultFormatter()->getConfig('nl');
     /** @var ParentNode $this */
     $this->firstChild()->before([$comment, WhitespaceNode::create($nl . $indent)]);
     $this->docComment = $comment;
     return $this;
 }
コード例 #4
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;
 }
コード例 #5
0
 /**
  * Execute an api call
  *
  * @param string $apiMethod	Name of the API operation (such as 'Pay')
  * @param PPRequest $params Request object
  * @return array containing request and response
  */
 public function makeRequest($apiMethod, $request)
 {
     $this->apiMethod = $apiMethod;
     $httpConfig = new PPHttpConfig(null, PPHttpConfig::HTTP_POST);
     if ($this->apiContext->getHttpHeaders() != null) {
         $httpConfig->setHeaders($this->apiContext->getHttpHeaders());
     }
     $this->runHandlers($httpConfig, $request);
     // Serialize request object to a string according to the binding configuration
     $formatter = FormatterFactory::factory($this->serviceBinding);
     $payload = $formatter->toString($request);
     // Execute HTTP call
     $connection = PPConnectionManager::getInstance()->getConnection($httpConfig, $this->apiContext->getConfig());
     $this->logger->info("Request: {$payload}");
     $response = $connection->execute($payload);
     $this->logger->info("Response: {$response}");
     return array('request' => $payload, 'response' => $response);
 }
コード例 #6
0
 /**
  * Execute an api call
  *
  * @param string $apiMethod	Name of the API operation (such as 'Pay')
  * @param PPRequest $params Request object
  * @return array containing request and response
  */
 public function makeRequest($apiMethod, $request)
 {
     $this->apiMethod = $apiMethod;
     $httpConfig = new PPHttpConfig(null, PPHttpConfig::HTTP_POST);
     if ($this->apiContext->getHttpHeaders() != null) {
         $httpConfig->setHeaders($this->apiContext->getHttpHeaders());
     }
     $this->runHandlers($httpConfig, $request);
     // Serialize request object to a string according to the binding configuration
     $formatter = FormatterFactory::factory($this->serviceBinding);
     $payload = $formatter->toString($request);
     //var_dump("<pre>", $payload); die();
     //requestEnvelope.errorLanguage=en_US&actionType=PAY&cancelUrl=http%3A%2F%2Fcusa-local%2Fsignup&currencyCode=USD&receiverList.receiver.amount=240&receiverList.receiver.email=JulianIWetmore%40armyspy.com&returnUrl=http%3A%2F%2Fcusa-local%2Fsignup-paypal-success%2F%3Fpay_chk%3D1799557580%26
     // Execute HTTP call
     $connection = PPConnectionManager::getInstance()->getConnection($httpConfig, $this->apiContext->getConfig());
     $this->logger->info("Request: {$payload}");
     $response = $connection->execute($payload);
     $this->logger->info("Response: {$response}");
     return array('request' => $payload, 'response' => $response);
 }
コード例 #7
0
 /**
  * @test
  */
 public function testInvalidBinding()
 {
     $this->setExpectedException('InvalidArgumentException');
     FormatterFactory::factory('Unknown');
 }
コード例 #8
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;
 }
コード例 #9
0
DISCLAIMED. IN NO EVENT SHALL ADRIAN KOSMACZEWSKI BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// The binary plist and the SOAP formatters require huge amounts of memory!
ini_set('memory_limit', '128M');
require_once 'data/database.php';
require_once 'formatters/formatterfactory.php';
// Get all the data from the database
$limit = $_GET["limit"];
if (!$limit) {
    $limit = "50";
}
// Before calling mysql_real_escape_string() you have to connect to the DB...!
$conn = new Connection();
$conn->open();
$query = "SELECT * FROM data ORDER BY RAND() LIMIT " . mysql_real_escape_string($limit);
$data = $conn->execute($query);
$conn->close();
// Depending the "format" parameter in the query string,
// output the data in different formats
$format = mysql_real_escape_string($_GET["format"]);
$formatter = FormatterFactory::createFormatter($format);
$formatter->setData($data);
header('Content-type: ' . $formatter->getContentType());
$output = $formatter->formatData();
echo $output;
コード例 #10
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
 }
コード例 #11
0
ファイル: get_url.php プロジェクト: BMLP/memoryhole-ansible
 * 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);
コード例 #12
0
ファイル: WhitespaceNode.php プロジェクト: kidaa30/redcat
 public function setText($text)
 {
     $nl = FormatterFactory::getDefaultFormatter()->getConfig('nl');
     $this->newlineCount = substr_count($text, $nl);
     return parent::setText($text);
 }
コード例 #13
0
 public function setUp()
 {
     $this->formatter = FormatterFactory::getPsr2Formatter();
 }