本文整理汇总了PHP中Transaction::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::getInstance方法的具体用法?PHP Transaction::getInstance怎么用?PHP Transaction::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
/**
* This method is called before the first test is executed.
*/
public static function setUpBeforeClass()
{
$transaction = \Transaction::getInstance();
$user = new \User();
$user->setTimezone("Europe/Paris");
$transaction->setUser($user);
}
示例2: startExperiment
/**
* Initialize the experiment and set all required tracking things
*
* @param string $experimentName
* @param array $experimentConfig
*/
private static function startExperiment($experimentName, array $experimentConfig)
{
wfDebug(sprintf("%s[%s] using %s class with %s params\n", __METHOD__, $experimentName, $experimentConfig['handler'], json_encode($experimentConfig['params'])));
new $experimentConfig['handler']($experimentConfig['params'] ?: []);
// mark a transaction with an experiment name
\Transaction::getInstance()->set(\Transaction::PARAM_AB_PERFORMANCE_TEST, $experimentName);
// set a global JS variable with an experiment name
global $wgHooks;
$wgHooks['WikiaSkinTopScripts'][] = function (array &$vars, &$scripts) use($experimentName) {
$vars['wgABPerformanceTest'] = $experimentName;
return true;
};
/*
* Start the session to bypass CDN cache
*
* We don't want to polute the CDN cache with the A/B performance testing tracking data.
* As the test are run for only a small subset of the traffic, start the session for client
* that are in the test groups to bypass the CDN cache.
*/
if (session_id() == '') {
wfSetupSession();
wfDebug(__METHOD__ . " - session started\n");
// log started sessions
global $wgUser;
WikiaLogger::instance()->info(__METHOD__, ['experiment' => $experimentName, 'session_id' => session_id(), 'is_anon' => $wgUser->isAnon()]);
}
}
示例3: getInstance
/**
* Returns the formatter instance. Creates a new one if doesn't exist yet.
* Uses the timezone of the user of the current transaction.
*
* @return Formatter
*/
public static function getInstance()
{
if (!self::$theInstance) {
$user = Transaction::getInstance()->getUser();
self::$theInstance = new Formatter($user->getTimezone(), $user->getLocale());
}
return self::$theInstance;
}
示例4: setUpBeforeClass
/**
* This method is called before the first test is executed.
*/
public static function setUpBeforeClass()
{
$transaction = \Transaction::getInstance();
$user = new \User();
$user->setTimezone("Europe/Paris");
$transaction->setUser($user);
$zend_locale = new \Zend_Locale("en_US");
\Zend_Registry::set('Zend_Locale', $zend_locale);
}
示例5: getInstance
/**
* Returns the DataConverter instance. Creates a new one if doesn't exist yet.
* Uses the timezone of the user of the current transaction.
* @return DataConverter
*/
public static function getInstance()
{
if (!self::$theInstance) {
$timezone = Transaction::getInstance()->getUser()->getTimezone();
$locale = Transaction::getInstance()->getUser()->getLocale();
self::$theInstance = new DataConverter($timezone, $locale);
}
return self::$theInstance;
}
示例6: setUpBeforeClass
public static function setUpBeforeClass()
{
$transaction = \Transaction::getInstance();
$user = new \User();
$user->setTimezone("America/Los_Angeles");
$user->setLocale("en_US");
$user->setIsAdmin(true);
$transaction->setUser($user);
}
示例7: getItems
public function getItems()
{
$user = Transaction::getInstance()->getUser();
$items = array();
foreach ($this->xml->item as $element) {
$item = new MenuItem($this, $element);
if ($item->getId() == $this->mainMenuId) {
$item->setSelected(true);
}
if (!$item->isAdminOnly() || $user->isAdmin()) {
$items[] = $item;
}
}
return $items;
}
示例8: service
public function service()
{
try {
session_name($this->sessionName);
Zend_Session::start();
$transaction = Transaction::getInstance();
$transaction->setUser($this->getContext()->getUser());
self::initTranslator($this->getContext()->getUser()->getLocale());
$this->validate();
$this->invokeControllerMethod();
} catch (Exception $e) {
$this->handleException($e);
}
$logTimeEnabled = Config::getInstance()->getBoolean('webapp/logging/timeLog/enabled', false);
if ($logTimeEnabled) {
$this->timeLogger->end();
}
}
示例9: escapeString
public static function escapeString($str, $withQuotes = true)
{
if ($str === null) {
return "null";
}
$db = Transaction::getInstance()->getDB();
$escaped = '';
if (method_exists($db, 'getDB')) {
$caller = self::getCallerFunction();
Logger::warning("Depracated: Avoid SQLUtils::escapeString. Use prepared statement. Called by: {$caller}");
$escaped = $db->getDB()->real_escape_string($str);
} else {
$escaped = mysql_real_escape_string($str);
}
if ($withQuotes) {
$escaped = "'" . $escaped . "'";
}
return $escaped;
}
示例10: convert
/**
* Get the unit from the form. If it's defined and different than the
* display unit, convert the value and set it back into this control's value.
* Then, format with proper number of digits.
*
* Do not call this method more than once!
*/
protected function convert()
{
$user = Transaction::getInstance()->getUser();
if ($this->getValue() !== null && Zend_Locale_Format::isNumber($this->getValue(), array("locale" => $user->getLocale()))) {
$form = $this->getForm();
// Get the 'hidden' value, which indicates the unit of the current value.
$unit = $form->getValue($this->getUnitFieldName());
// If the unit is different, convert
if ($unit && $unit != $this->displayUnit) {
$measure = MeasureUtils::newMeasure($unit, $this->getValue(), $user->getLocale());
$unitInfo = MeasureUtils::getUnitInfo($this->displayUnit);
$measure->setType($unitInfo['constantName']);
// Sets the new value without rounding and without formatting
$this->setValue($measure->getValue(-1, $user->getLocale()));
}
$format = Formatter::getInstance();
// Format and round the value
$this->setValue($format->number($format->getNumber($this->getValue()), $this->decimalDigits));
}
}
示例11: makeDateFromTimestamp
/**
* Create a new DateTime object representing the current date/time in the
* given timezone.
*
* @param $timezone (String) the timezone to evaluate the given time in. If
* null, the current user's account's timezone will be used.
* @return DateTime
*/
public static function makeDateFromTimestamp($timestamp, $timezone = null)
{
if (!$timezone) {
$timezone = Transaction::getInstance()->getUser()->getTimezone();
}
$date = new DateTime("@{$timestamp}");
$tz = new DateTimeZone($timezone);
$date->setTimezone($tz);
return $date;
}
示例12: startTransaction
private function startTransaction()
{
$transaction = Transaction::getInstance();
$user = new User();
$timezone = Config::getInstance()->getString("properties/anonymousUserTimezone");
$user->setTimezone($timezone);
// TODO: set id to root.
$user->setId(1);
$transaction->setUser($user);
}
示例13: define
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
require_once '../../core.php';
//change to your gateway's name
define('GWNAME', 'othertestgateway');
define('INVOICE', (int) $_REQUEST['inv']);
define('AMOUNT', (int) $_REQUEST['received']);
define('KEY', $_REQUEST['secretkey']);
define('COMMENT', '');
$gm = GatewayModule::getInstance();
$curr = Currency::getInstance();
$service = Service::getInstance();
$invoice = Invoice::getInstance();
$tr = Transaction::getInstance();
//finding ID for this gateway
$gwid = $gm->GetID(GWNAME);
if (!$gwid) {
die("This gateway is not activated and configured to accept payments");
}
$gmdata = $gm->FetchData($gwid);
$invdata = $invoice->FetchData(INVOICE);
$currency = $curr->FetchData($curr->GetID($gmdata['currency'], 'name'));
//$currency = $curr->GetCurrency('',$gmdata['currency']);
$gateway_data = unserialize($gmdata['data']);
if ($invdata['amount'] > AMOUNT * $currency['rate']) {
echo "Received amount is not enough for this invoice";
//send some notifications
exit;
} elseif ($gateway_data['key'] != KEY) {
示例14: ManageTrans
public static function ManageTrans()
{
$xtpl = self::$xtpl;
$user = User::getInstance();
$gm = GatewayModule::getInstance();
if (!is_numeric(self::$page)) {
$page = 1;
} else {
$page = self::$page;
}
$xtpl->assign('FINCURR', 'current');
$xtpl->assign('MANAGETRANS', 'current');
$trans = Transaction::getInstance();
$transbutch = $trans->GetButch(self::$per_page, 1, 'id', 'DESC', self::$per_page * $page - self::$per_page);
if (count($transbutch) > 0) {
for ($i = 0; $i < count($transbutch); $i++) {
$username = '';
$gatewayname = '';
if (!is_numeric($transbutch[$i]['customerid']) || !is_string($username = $user->GetUsername($transbutch[$i]['customerid']))) {
self::add_message($xtpl, 'attention', 'User #' . $transbutch[$i]['customerid'] . ' not found for transaction #' . $transbutch[$i]['id']);
} else {
$xtpl->assign('USERNAME', $username);
}
if (!is_numeric($transbutch[$i]['gatewayid']) || !is_string($gatewayname = $gm->GetName($transbutch[$i]['gatewayid']))) {
self::add_message($xtpl, 'attention', 'Payment gateway #' . $transbutch[$i]['gatewayid'] . ' not found for transaction #' . $transbutch[$i]['id']);
} else {
$xtpl->assign('GATEWAYNAME', $gatewayname);
}
$xtpl->assign('TRANS', $transbutch[$i]);
$xtpl->parse('main.managetrans.transtable.transrow');
}
for ($i = 1; $i <= self::count_pages($trans->Calculate()); $i++) {
if ($page == $i) {
$xtpl->assign('CURRENT', 'current');
} else {
$xtpl->assign('CURRENT', '');
}
$xtpl->assign('NUM', $i);
if (preg_match('/page=[0-9]+/', self::$request_uri)) {
$link = preg_replace('/page=[0-9]+/', 'page=' . $i, self::$request_uri);
} else {
$link = self::$request_uri . '&page=' . $i;
}
$xtpl->assign('LINK', $link);
$xtpl->parse('main.managetrans.transtable.page');
}
$xtpl->parse('main.managetrans.transtable');
} else {
$xtpl->parse('main.managetrans.transinfo');
}
$xtpl->parse('main.managetrans');
$xtpl->parse('main');
$xtpl->out('main');
}
示例15: getDatePickerLocalization
/**
* Localization array for the Jquery UI date time picker.
* @return array
*/
private function getDatePickerLocalization()
{
$daysArr = Zend_Locale_Data::getList(Transaction::getInstance()->getUser()->getLocale(), "days");
$weekArr = Zend_Locale_Data::getList(Transaction::getInstance()->getUser()->getLocale(), "week");
$firstDay = $daysArr['format']['narrow'][$weekArr["firstDay"]] - 1;
$tr = Application::getTranslator();
// Most i18n values come from dedicated jquery.ui.datepicker-<LANG>.js
// Make sure to include this file on all pages.
// The fields defined here are the ones used by the datetimepicker extension.
$regional = array("closeText" => $tr->_('Done'), "dateFormat" => $tr->_('m/dd/yy'), "firstDay" => $firstDay, "isRTL" => false, "showMonthAfterYear" => false, "yearSuffix" => '');
if ($this->showTime) {
$regional["currentText"] = $tr->_('Now');
$regional["amNames"] = array('AM', 'A');
$regional["pmNames"] = array('PM', 'P');
// Important: timeFormat must be compatible with pattern used by Formatter::datetime for each locale
$regional["timeFormat"] = $tr->_('h:mm TT');
$regional["timeSuffix"] = '';
$regional["timeOnlyTitle"] = $tr->_('Choose Time');
$regional["timeText"] = $tr->_('Time');
$regional["hourText"] = $tr->_('Hour');
$regional["minuteText"] = $tr->_('Minute');
$regional["secondText"] = $tr->_('Second');
$regional["millisecText"] = $tr->_('Millisecond');
$regional["timezoneText"] = $tr->_('Time Zone');
}
return $regional;
}