本文整理汇总了PHP中Gateway类的典型用法代码示例。如果您正苦于以下问题:PHP Gateway类的具体用法?PHP Gateway怎么用?PHP Gateway使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gateway类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
public function createAction()
{
if (isset($_POST['ajax']) && isset($_POST['getgateways'])) {
$gatewayModel = new Gateway();
$gateways = $gatewayModel->getGateways();
AF::setJsonHeaders('json');
Message::echoJsonSuccess(array('message' => $gateways));
}
$model = new CampaignGateway();
$this->performAjaxValidation($model);
if (isset($_POST['model']) && $_POST['model'] == 'Campgate') {
$model->fillFromArray($_POST);
if (isset($_POST['ajax'])) {
if ($model->addGatewayById()) {
$link = AF::link(array('campgate' => 'view'), array('campaign_id' => $model->campaign_id));
Message::echoJson('success', array('redirect' => $link));
} else {
Message::echoJsonError(__('campgate_not_created') . ' ' . $model->errors2string);
}
die;
}
$model->addGatewayById();
$this->redirect();
}
$this->addToPageTitle('Create Campaign Gateway');
$this->render('create', array('model' => $model));
}
示例2: commit
function commit()
{
if (!parent::commit()) {
return false;
}
$id = $this->get('id');
if ($id === false) {
return false;
}
$fields = array();
$fields['field_id'] = $id;
$fields['default_location'] = $this->get('default_location');
if (!$fields['default_location']) {
$fields['default_location'] = 'Brisbane, Australia';
}
include_once TOOLKIT . '/class.gateway.php';
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', 'http://maps.google.com/maps/geo?q=' . urlencode($fields['default_location']) . '&output=xml&key=' . $this->_engine->Configuration->get('google-api-key', 'map-location-field'));
$response = $ch->exec();
if (!preg_match('/<Placemark/i', $response)) {
$fields['default_location'] = 'Brisbane, Australia';
$fields['default_location_coords'] = '-27.46, 153.025';
} else {
$xml = new SimpleXMLElement($response);
$coords = preg_split('/,/', $xml->Response->Placemark[0]->Point->coordinates, -1, PREG_SPLIT_NO_EMPTY);
$fields['default_location_coords'] = $coords[1] . ',' . $coords[0];
}
$this->_engine->Database->query("DELETE FROM `tbl_fields_" . $this->handle() . "` WHERE `field_id` = '{$id}' LIMIT 1");
return $this->_engine->Database->insert($fields, 'tbl_fields_' . $this->handle());
}
示例3: create
public function create($aData)
{
$oConnection = Propel::getConnection(GatewayPeer::DATABASE_NAME);
try {
$sGatewayUID = G::generateUniqueID();
$aData['GAT_UID'] = $sGatewayUID;
$oGateway = new Gateway();
$oGateway->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($oGateway->validate()) {
$oConnection->begin();
$iResult = $oGateway->save();
$oConnection->commit();
return $sGatewayUID;
} else {
$sMessage = '';
$aValidationFailures = $oGateway->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw new Exception('The registry cannot be created!<br />' . $sMessage);
}
} catch (Exception $oError) {
$oConnection->rollback();
throw $oError;
}
}
示例4: __geocodeAddress
private function __geocodeAddress($address, $can_return_default = true)
{
$coordinates = null;
$cache_id = md5('maplocationfield_' . $address);
$cache = new Cacheable(Symphony::Database());
$cachedData = $cache->check($cache_id);
// no data has been cached
if (!$cachedData) {
include_once TOOLKIT . '/class.gateway.php';
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', '//maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false&v=3.13');
$response = json_decode($ch->exec());
$coordinates = $response->results[0]->geometry->location;
if ($coordinates && is_object($coordinates)) {
$cache->write($cache_id, $coordinates->lat . ', ' . $coordinates->lng, $this->_geocode_cache_expire);
// cache lifetime in minutes
}
} else {
$coordinates = $cachedData['data'];
}
// coordinates is an array, split and return
if ($coordinates && is_object($coordinates)) {
return $coordinates->lat . ', ' . $coordinates->lng;
} elseif ($coordinates) {
return $coordinates;
} elseif ($return_default) {
return $this->_default_coordinates;
}
}
示例5: search
private function search()
{
$results = array();
$url = "http://symphonyextensions.com/api/extensions/?keywords={$this->query}&type=&compatible-with={$this->compatibleVersion}&sort=updated&order=desc";
// create the Gateway object
$gateway = new Gateway();
// set our url
$gateway->init($url);
// get the raw response, ignore errors
$response = @$gateway->exec();
if (!$response) {
throw new Exception(__("Could not read from %s", array($url)));
}
// parse xml
$xml = @simplexml_load_string($response);
if (!$xml) {
throw new Exception(__("Could not parse xml from %s", array($url)));
}
$extensions = $xml->xpath('/response/extensions/extension');
foreach ($extensions as $index => $ext) {
$name = $ext->xpath('name');
$id = $ext->xpath('@id');
$developer = $ext->xpath('developer/name');
$version = $ext->xpath('version');
$status = $ext->xpath('status');
$compatible = $ext->xpath("compatibility/symphony[@version='{$this->version}']");
$res = array('handle' => (string) $id[0], 'name' => (string) $name[0], 'by' => (string) $developer[0], 'version' => (string) $version[0], 'status' => (string) $status[0], 'compatible' => $compatible != null);
$results[] = $res;
}
// set results array
$this->_Result['results'] = $results;
}
示例6: getValuesFromXML
function getValuesFromXML()
{
$xml_location = $this->get('xml_location');
$cache_life = (int) $this->get('cache');
require TOOLKIT . '/util.validators.php';
// allow use of choice params in URL
$xml_location = preg_replace('/{\\$root}/', URL, $xml_location);
$xml_location = preg_replace('/{\\$workspace}/', WORKSPACE, $xml_location);
$doc = new DOMDocument();
if (preg_match($validators['URI'], $xml_location)) {
// is a URL, check cache
$cache_id = md5('xml_selectbox_' . $xml_location);
$cache = new Cacheable($this->_Parent->_Parent->Database);
$cachedData = $cache->check($cache_id);
if (!$cachedData) {
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', $xml_location);
$ch->setopt('TIMEOUT', 6);
$xml = $ch->exec();
$writeToCache = true;
$cache->write($cache_id, $xml, $cache_life);
// Cache life is in minutes not seconds e.g. 2 = 2 minutes
$xml = trim($xml);
if (empty($xml) && $cachedData) {
$xml = $cachedData['data'];
}
} else {
$xml = $cachedData['data'];
}
$doc->loadXML($xml);
} elseif (substr($xml_location, 0, 1) == '/') {
// relative to DOCROOT
$doc->load(DOCROOT . $this->get('xml_location'));
} else {
// in extension's /xml folder
$doc->load(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
}
$xpath = new DOMXPath($doc);
$options = array();
foreach ($xpath->query($this->get('item_xpath')) as $item) {
$option = array();
$option['text'] = $this->run($xpath, $item, $this->get('text_xpath'));
$option['value'] = $this->run($xpath, $item, $this->get('value_xpath'));
if (is_null($option['value'])) {
$option['value'] = $option['text'];
}
$options[] = $option;
if ($item->hasChildNodes()) {
foreach ($xpath->query('*', $item) as $child) {
$text = $this->run($xpath, $child, $this->get('text_xpath'));
$value = $this->run($xpath, $child, $this->get('value_xpath'));
$options[] = array('text' => $option['text'] . " / " . $text, 'value' => $option['value'] . "-" . (!is_null($value) ? $value : $text));
}
}
}
return $options;
}
示例7: getValuesFromXML
function getValuesFromXML()
{
$xml_location = $this->get('xml_location');
$cache_life = (int) $this->get('cache');
require TOOLKIT . '/util.validators.php';
// allow use of choice params in URL
$xml_location = preg_replace('/{\\$root}/', URL, $xml_location);
$xml_location = preg_replace('/{\\$workspace}/', WORKSPACE, $xml_location);
if (preg_match($validators['URI'], $xml_location)) {
// is a URL, check cache
$cache_id = md5('xml_selectbox_' . $xml_location);
$cache = new Cacheable($this->_Parent->_Parent->Database);
$cachedData = $cache->check($cache_id);
if (!$cachedData) {
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', $xml_location);
$ch->setopt('TIMEOUT', 6);
$xml = $ch->exec();
$writeToCache = true;
$cache->write($cache_id, $xml, $cache_life);
// Cache life is in minutes not seconds e.g. 2 = 2 minutes
$xml = trim($xml);
if (empty($xml) && $cachedData) {
$xml = $cachedData['data'];
}
} else {
$xml = $cachedData['data'];
}
$xml = simplexml_load_string($xml);
} elseif (substr($xml_location, 0, 1) == '/') {
// relative to DOCROOT
$xml = simplexml_load_file(DOCROOT . $this->get('xml_location'));
} else {
// in extension's /xml folder
$xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
}
$options = array();
if (!$xml) {
return $options;
}
$items = $xml->xpath($this->get('item_xpath'));
foreach ($items as $item) {
$option = array();
$text_xpath = $item->xpath($this->get('text_xpath'));
$option['text'] = General::sanitize((string) $text_xpath[0]);
if ($this->get('value_xpath') != '') {
$value_xpath = $item->xpath($this->get('value_xpath'));
$option['value'] = General::sanitize((string) $value_xpath[0]);
}
if ((string) $option['value'] == '') {
$option['value'] = $option['text'];
}
$options[] = $option;
}
return $options;
}
示例8: getValuesFromXML
function getValuesFromXML()
{
$xml_location = $this->get('xml_location');
if (General::validateURL($xml_location) != '') {
// is a URL, check cache
$cache_id = md5($xml_location);
$cache = new Cacheable($this->_Parent->_Parent->Database);
$cachedData = $cache->check($cache_id);
$creation = DateTimeObj::get('c');
if (!$cachedData || time() - $cachedData['creation'] > 5 * 60) {
if (Mutex::acquire($cache_id, 6, TMP)) {
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', $xml_location);
$ch->setopt('TIMEOUT', 6);
$xml = $ch->exec();
$writeToCache = true;
Mutex::release($cache_id, TMP);
$xml = trim($xml);
if (empty($xml) && $cachedData) {
$xml = $cachedData['data'];
}
} elseif ($cachedData) {
$xml = $cachedData['data'];
}
} else {
$xml = $cachedData['data'];
}
$xml = simplexml_load_string($xml);
} elseif (substr($xml_location, 0, 1) == '/') {
// relative to DOCROOT
$xml = simplexml_load_file(DOCROOT . $this->get('xml_location'));
} else {
// in extension's /xml folder
$xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
}
if (!$xml) {
return;
}
$items = $xml->xpath($this->get('item_xpath'));
$options = array();
foreach ($items as $item) {
$option = array();
$text_xpath = $item->xpath($this->get('text_xpath'));
$option['text'] = General::sanitize((string) $text_xpath[0]);
if ($this->get('value_xpath') != '') {
$value_xpath = $item->xpath($this->get('value_xpath'));
$option['value'] = General::sanitize((string) $value_xpath[0]);
}
if ((string) $option['value'] == '') {
$option['value'] = $option['text'];
}
$options[] = $option;
}
return $options;
}
示例9: log
public function log($item_type, $item_id, $action_type, $user_id, $timestamp)
{
/**
* Build author string for the fallback username. If we've got
* a valid author, grab the full name. Otherwise, determine
* whether it's an anonymous front-end user or a potentially
* malicious person trying to access the back end. In the latter
* case, output the IP or email we captured for reference.
*/
$author = AuthorManager::fetchByID($user_id);
$members = $_SESSION['sym-members'];
if ($author instanceof Author) {
$username = $author->getFullName();
} else {
if (!empty($members)) {
if ($members['members-section-id'] && $members['id']) {
$members_section = SectionManager::fetch($members['members-section-id'])->get('handle');
$members_link = SYMPHONY_URL . '/publish/' . $members_section . '/edit/' . $members['id'] . '/';
$username = __('The front-end member %s', array('<a href="' . $members_link . '">' . $members['username'] . '</a>'));
} else {
$username = __('The front-end member %s', array($members['username']));
}
} else {
if (is_numeric($item_type)) {
$username = __('A front-end user');
} else {
$username = __('An unidentified user (%s)', array($item_id));
}
}
}
// Build the $data array for our table columns
$data = array('item_type' => $item_type, 'item_id' => $item_id, 'action_type' => $action_type, 'user_id' => $user_id, 'timestamp' => $timestamp, 'fallback_username' => $username);
/**
* Build the fallback description. Used if the item gets deleted.
* If the item type is numeric, we're dealing with an entry,
* otherwise it's some other system element. They're formatted
* differently.
*/
if (is_numeric($item_type)) {
$data['fallback_description'] = Tracker::formatEntryItem($data, TRUE);
} else {
$data['fallback_description'] = Tracker::formatElementItem($data, TRUE);
}
// Push it into the DB.
Symphony::Database()->insert($data, 'tbl_tracker_activity');
// Send the event to the URL if specificed
$notify_url = Symphony::Configuration()->get('notify_url', 'tracker');
$notify_urls_array = preg_split('/[\\s,]+/', $notify_url);
foreach ($notify_urls_array as $url) {
$gateway = new Gateway();
$gateway->init($url . "?" . http_build_query($data));
$gateway->exec();
}
}
示例10: notify
function notify($context)
{
var_dump($context);
include_once TOOLKIT . '/class.gateway.php';
$ch = new Gateway();
$ch->init();
$ch->setopt('URL', 'http://rpc.pingomatic.com/');
$ch->setopt('POST', 1);
$ch->setopt('CONTENTTYPE', 'text/xml');
$ch->setopt('HTTPVERSION', '1.0');
##Create the XML request
$xml = new XMLElement('methodCall');
$xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
$params = new XMLElement('params');
$param = new XMLElement('param');
$param->appendChild(new XMLElement('value', $this->_Parent->Configuration->get('sitename', 'general')));
$params->appendChild($param);
$param = new XMLElement('param');
$param->appendChild(new XMLElement('value', URL));
$params->appendChild($param);
$xml->appendChild($params);
####
$ch->setopt('POSTFIELDS', $xml->generate(true, 0));
//Attempt the ping
$ch->exec(GATEWAY_FORCE_SOCKET);
}
示例11: __actionIndex
public function __actionIndex()
{
// Use external data:
if ($this->_fields['source']) {
$gateway = new Gateway();
$gateway->init();
$gateway->setopt('URL', $this->_fields['source']);
$gateway->setopt('TIMEOUT', 6);
// Validate data:
$this->_status = $this->_importer->validate($gateway->exec());
if ($this->_status == Importer::__OK__) {
$this->_importer->commit();
}
}
}
示例12: __construct
public function __construct($controller, $name, $order)
{
/* Store Settings Object */
$conf = StoreSettings::get_settings();
/* Comments Box, if enabled */
if ($conf->CheckoutSettings_OrderComments) {
$comments = TextareaField::create("CustomerComments", "Order Comments");
$comments->setRightTitle("These comments will be seen by staff.");
} else {
$comments = HiddenField::create("CustomerComments", "");
}
/* Terms and Conditions, if enabled */
if ($conf->CheckoutSettings_TermsAndConditions) {
$terms = CheckboxField::create("Terms", "I agree to " . $conf->StoreSettings_StoreName . "'s " . "<a href=" . DataObject::get_by_id("SiteTree", $conf->CheckoutSettings_TermsAndConditionsSiteTree)->URLSegment . ">" . "Terms & Conditions</a>.");
} else {
$terms = HiddenField::create("Terms", "");
}
/* Fields */
$fields = FieldList::create($comments, OptionsetField::create("PaymentMethod", "Payment Method", Gateway::create()->getGateways($order)), $terms ? HeaderField::create("Terms and Conditions", 5) : HiddenField::create("TermsHeaderField", ""), $terms);
/* Actions */
$actions = FieldList::create(FormAction::create('payment', 'Place Order & Continue to Payment'));
/* Required Fields */
$required = new RequiredFields(array("PaymentMethod", $terms ? "Terms" : null));
/*
* Now we create the actual form with our fields and actions defined
* within this class.
*/
return parent::__construct($controller, $name, $fields, $actions, $required);
}
示例13: create
/**
* Creates a new customer transaction.
*
* @param Model_Customer_Paymentmethod $payment_method The payment method.
* @param string $amount The amount to transact.
* @param array $data Optional data.
*
* @return Model_Customer_Transaction
*/
public static function create(Model_Customer_Paymentmethod $payment_method, $amount, array $data = array())
{
$gateway_instance = Gateway::instance($payment_method->gateway, $payment_method->customer);
if ($gateway_instance) {
$external_id = $gateway_instance->transaction()->create(array('payment_method' => $payment_method, 'amount' => $amount));
if (!$external_id) {
return false;
}
} else {
$external_id = null;
}
$transaction = Model_Customer_Transaction::forge();
$transaction->customer = $payment_method->customer;
$transaction->gateway = $payment_method->gateway;
$transaction->external_id = $external_id;
$transaction->type = $payment_method->gateway->type;
$transaction->provider = $payment_method->provider;
$transaction->account = $payment_method->account;
$transaction->amount = $amount;
try {
$transaction->save();
} catch (FuelException $e) {
Log::error($e);
return false;
}
Service_Event::trigger('customer.transaction.create', $transaction->customer->seller, $transaction->to_array());
return $transaction;
}
示例14: donations
function donations()
{
$donations = Donation::where('amount', '>=', '10')->orderBy('amount', 'desc')->lists('name');
$gateways = Gateway::orderBy('name')->get();
$this->stylesheet('assets/stylesheets/donations.css');
$this->autoRender(compact('donations', 'gateways'), 'Donations');
}
示例15: run
public function run()
{
$newGateways = Gateway::getNewGatewayEuisFromInflux();
foreach ($newGateways as $newGateway) {
$newGateway->save();
}
$lastEntry = Gateway::getLastEntry();
Gateway::updateGatewayStatusFromInflux($lastEntry->last_seen);
}