本文整理汇总了PHP中ActiveRecordModel::getApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::getApplication方法的具体用法?PHP ActiveRecordModel::getApplication怎么用?PHP ActiveRecordModel::getApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::getApplication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrl
public function getUrl()
{
$params = array();
// user name
$params['merchant'] = $this->getConfigValue('merchant');
if ($this->getConfigValue('test')) {
$params['test'] = 'yes';
}
// A seller reference number for a transaction
$params['orderid'] = $this->details->invoiceID->get();
$params['uniqueoid'] = $this->details->invoiceID->get();
// The payment amount
$params['amount'] = $this->details->amount->get() * 100;
// The currency code of the payment amount.
$params['currency'] = $this->getCurrency($this->details->currency->get());
//$this->notifyUrl = preg_replace('/currency\=[A-Z]{3}/', '', $this->notifyUrl);
$params['callbackurl'] = $this->notifyUrl;
$params['accepturl'] = $this->returnUrl;
$params['cancelurl'] = $this->siteUrl;
$params['lang'] = ActiveRecordModel::getApplication()->getLocaleCode();
$params['skiplastpage'] = 1;
$params['md5key'] = $this->getMd5Key($params);
$pairs = array();
foreach ($params as $key => $value) {
$pairs[] = $key . '=' . urlencode($value);
}
return 'https://payment.architrade.com/paymentweb/start.action?' . implode('&', $pairs);
}
示例2: getActiveProductManufacturers
/**
*
* @return array('manufacturers'=> array of manufacturers, 'counts'=> manufacturer product count, 'count'=> count of manufacturers)
*/
public static function getActiveProductManufacturers($context)
{
$context = $context + array('startingWith' => null, 'currentPage' => 1);
extract($context);
// creates $startingWith and $currentPage
$config = ActiveRecordModel::getApplication()->getConfig();
$listStyle = $config->get('MANUFACTURER_PAGE_LIST_STYLE');
$perPage = $config->get('MANUFACTURER_PAGE_PER_PAGE');
// get filter to select manufacturers of active products only
$f = new ARSelectFilter();
$ids = $counts = $letters = array();
$sql = !self::getApplication()->getConfig()->get('MANUFACTURER_PAGE_DISPLAY_ACTIVE') ? 'SELECT DISTINCT(ID) as manufacturerID, 1 AS cnt FROM Manufacturer ' . $f->createString() . ' GROUP BY manufacturerID' : 'SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID';
foreach (ActiveRecordModel::getDataBySQL($sql) as $row) {
$ids[] = $row['manufacturerID'];
$counts[$row['manufacturerID']] = $row['cnt'];
}
$f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids));
$f->addField('UPPER(LEFT(TRIM(Manufacturer.name),1))', '', 'FirstLetter');
$f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
if ($startingWith) {
$f->mergeCondition(new LikeCond(new ARFieldHandle('Manufacturer', 'name'), $startingWith . '%'));
}
$f->setOrder(new ARFieldHandle('Manufacturer', 'name'));
if ($perPage > 0) {
$offsetStart = ($currentPage - 1) * $perPage + 1;
$offsetEnd = $currentPage * $perPage;
$f->setLimit($perPage, $offsetStart - 1);
}
$manufacturers = ActiveRecordModel::getRecordSetArray(__CLASS__, $f);
foreach ($manufacturers as $item) {
$letters[$item['FirstLetter']] = $item['FirstLetter'];
}
return array('manufacturers' => $manufacturers, 'counts' => $counts, 'count' => ActiveRecordModel::getRecordCount(__CLASS__, $f));
}
示例3: getNumber
public function getNumber()
{
$config = ActiveRecordModel::getApplication()->getConfig();
$startAt = $config->get('SequentialInvoiceNumber_START_AT');
$prefix = $config->get('SequentialInvoiceNumber_PREFIX');
$suffix = $config->get('SequentialInvoiceNumber_SUFFIX');
// get last finalized order
$last = array_pop(ActiveRecord::getRecordSetArray('CustomerOrder', $this->getSelectFilter()));
$lastNumber = $last ? $last['invoiceNumber'] : $startAt;
if (substr($lastNumber, 0, strlen($prefix)) == $prefix) {
$lastNumber = substr($lastNumber, strlen($prefix));
}
if (substr($lastNumber, -1 * strlen($suffix)) == $suffix) {
$lastNumber = substr($lastNumber, 0, -1 * strlen($suffix));
}
preg_match('/[0-9]+/', $lastNumber, $matches);
$lastNumber = array_shift($matches);
if ($lastNumber < $startAt) {
$lastNumber = $startAt;
}
// avoid selecting the same order if the invoice number is already taken
$this->getSelectFilter()->mergeCondition(neq('CustomerOrder.ID', $last['ID']));
$lastNumber += max($config->get('SequentialInvoiceNumber_STEP'), 1);
$lastNumber = str_pad($lastNumber, $config->get('SequentialInvoiceNumber_MIN_LENGTH'), '0', STR_PAD_LEFT);
$lastNumber = $prefix . $lastNumber . $suffix;
return $lastNumber;
}
示例4: getLanguageIDs
private function getLanguageIDs()
{
if (!$this->langIDs) {
$this->langIDs = ActiveRecordModel::getApplication()->getLanguageArray(true);
}
return $this->langIDs;
}
示例5: setUp
public function setUp()
{
ActiveRecordModel::getApplication()->clearCachedVars();
ActiveRecordModel::beginTransaction();
if (empty($this->autoincrements)) {
foreach ($this->getUsedSchemas() as $table) {
$res = $this->db->executeQuery("SHOW TABLE STATUS LIKE '{$table}'");
$res->next();
$this->autoincrements[$table] = (int) $res->getInt("Auto_increment");
}
}
if ($this instanceof BackendControllerTestCase) {
ClassLoader::import('application.model.user.SessionUser');
ClassLoader::import('application.model.user.UserGroup');
// set up user
$group = UserGroup::getNewInstance('Unit tester');
$group->save();
$group->setAllRoles();
$group->save();
$user = User::getNewInstance('unittest@test.com', null, $group);
$user->save();
SessionUser::setUser($user);
}
if ($this instanceof ControllerTestCase) {
$this->request = self::getApplication()->getRequest();
}
}
示例6: getSelectFilter
public function getSelectFilter($disableFilters = false)
{
$selectFilter = $this->category->getProductsFilter($this, false);
$selectFilter->merge($this->productFilter);
$cond = null;
if ($disableFilters == false) {
$list = array();
// group filters by class
foreach ($this->filters as $filter) {
$id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : '';
$list[get_class($filter) . '_' . $id][] = $filter->getCondition();
$filter->defineJoin($selectFilter);
}
// convert filter group to OrChainCondition
foreach ($list as &$filterGroup) {
$filterGroup = new OrChainCondition($filterGroup);
}
if ($fCond = $selectFilter->getCondition()) {
$list[] = $fCond;
}
$selectFilter->setCondition(new AndChainCondition($list));
// all merged with and
}
ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter);
return $selectFilter;
}
示例7: getCondition
public function getCondition()
{
// analyze search query
// find exact phrases first
$query = $this->query;
preg_match_all('/"(.*)"/sU', $query, $matches);
$phrases = array();
if ($matches[1]) {
$phrases = $matches[1];
}
$query = $this->getCleanedQuery($query);
$phrases = array_merge($phrases, explode(' ', $query));
$searchFields = array('name', 'keywords', 'shortDescription', 'longDescription', 'sku');
$conditions = array();
foreach ($phrases as $phrase) {
$searchCond = null;
foreach ($searchFields as $field) {
$cond = new LikeCond(new ARFieldHandle('Product', $field), '%' . $phrase . '%');
if (!$searchCond) {
$searchCond = $cond;
} else {
$searchCond->addOr($cond);
}
}
$conditions[] = $searchCond;
}
$condition = new AndChainCondition($conditions);
$vc = new IsNotNullCond(f('Product.parentID'));
$vc->addAND(new LikeCond(new ARExpressionHandle('(SELECT name FROM Product as searchvar WHERE Product.parentID=searchvar.ID)'), '%' . $phrase . '%'));
ActiveRecordModel::getApplication()->variationCond = $vc;
ActiveRecordModel::getApplication()->processInstancePlugins('searchFilter', $condition);
return $condition;
}
示例8: testApply
public function testApply()
{
$livecart = ActiveRecordModel::getApplication();
$compat = new GodaddySharedHostingCompat($livecart);
$compat->apply();
$this->assertEqual($livecart->getConfig()->get('PROXY_HOST'), 'proxy.shr.secureserver.net');
$this->assertEqual($livecart->getConfig()->get('PROXY_PORT'), 3128);
}
示例9: toArray
public function toArray()
{
$arr = array();
$arr['class'] = $this->getClassName();
$arr['template'] = 'custom:search/block/result_' . $arr['class'] . '.tpl';
$arr['name'] = ActiveRecordModel::getApplication()->translate($arr['class']);
return $arr;
}
示例10: destroy
public static function destroy()
{
$app = ActiveRecordModel::getApplication();
$app->processRuntimePlugins('session/before-logout');
$session = new Session();
$session->unsetValue('User');
$session->unsetValue('CustomerOrder');
$app->processRuntimePlugins('session/logout');
}
示例11: applyToOrder
public function applyToOrder(CustomerOrder $order)
{
$taxClassID = $this->getFieldValue('taxClassID', -1);
if ($taxClassID > 0) {
ActiveRecordModel::getApplication()->getConfig()->setRuntime('DELIVERY_TAX_CLASS', $taxClassID);
} else {
ActiveRecordModel::getApplication()->getConfig()->resetRuntime('DELIVERY_TAX_CLASS');
}
}
示例12: delete
public function delete()
{
if (ActiveRecordModel::getApplication()->getConfig()->get('CLONE_STORE_TYPE') == 'CLONE_STORE_MASTER') {
return parent::delete();
} else {
ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0');
ActiveRecordModel::executeUpdate('UPDATE ' . __CLASS__ . ' SET productID=NULL, variationID=NULL, protectedFields="|productID||variationID|" WHERE ID=' . $this->getID());
}
}
示例13: getPastOrders
public function getPastOrders()
{
if (!is_null($this->pastOrders)) {
return $this->pastOrders;
}
if (!$this->user) {
return array();
}
$sessionUser = SessionUser::getUser();
if ($this->isSessionCacheUsable()) {
$session = new Session();
$sessionHandler = ActiveRecordModel::getApplication()->getSessionHandler();
$pastOrders = $session->get('pastOrders');
if (!$pastOrders || $pastOrders['cacheUpdated'] != $sessionHandler->getCacheUpdateTime()) {
unset($pastOrders);
}
}
if (empty($pastOrders)) {
$f = select(eq('CustomerOrder.userID', $this->user->getID()), eq('CustomerOrder.isFinalized', true), eq('CustomerOrder.isCancelled', 0), eq('CustomerOrder.isPaid', true));
$f->setOrder(f('OrderedItem.customerOrderID'), 'DESC');
$records = ActiveRecordModel::getRecordSetArray('OrderedItem', $f, array('CustomerOrder', 'Product'));
// load variation parent products separately
$parentIDs = array();
foreach ($records as $record) {
if ($record['Product']['parentID']) {
//$parentIDs[$record['Product']['parentID']] = true;
}
}
if ($parentIDs) {
$parents = array();
foreach (ActiveRecordModel::getRecordSetArray('Product', select(in('Product.ID', array_keys($parentIDs)))) as $parent) {
$parents[$parent['ID']] = $parent;
}
foreach ($records as &$record) {
if ($record['Product']['parentID']) {
$record['Product']['Parent'] = $parents[$record['Product']['parentID']];
}
}
}
// split records by orders
$orders = array();
foreach ($records as $record) {
$orders[$record['customerOrderID']][] = $record;
}
$pastOrders = array();
foreach ($orders as $order) {
$pastOrders[] = new RuleOrderContainer($order);
}
$pastOrders = array('cacheUpdated' => time(), 'orders' => $pastOrders);
}
if ($this->isSessionCacheUsable()) {
$session->set('pastOrders', $pastOrders);
$sessionHandler->updateCacheTimestamp();
}
$this->pastOrders = $pastOrders;
return $this->pastOrders;
}
示例14: getGeneratorFiles
private static function getGeneratorFiles()
{
$files = array();
foreach (ActiveRecordModel::getApplication()->getConfigContainer()->getDirectoriesByMountPath('application.model.order.invoiceNumber') as $dir) {
foreach (glob($dir . '/*.php') as $file) {
$files[basename($file, '.php')] = $file;
}
}
return $files;
}
示例15: createFromArray
public static function createFromArray(array $array)
{
ActiveRecordModel::getApplication()->loadPluginClass('application.model.businessrule.action', $array['actionClass']);
$inst = new $array['actionClass']();
if (!empty($array['condition'])) {
$condition = isset($array['instance']) ? $array['instance'] : RuleCondition::createFromArray($array['condition'], true);
$inst->setCondition($condition);
}
unset($array['condition']);
$inst->setParams($array);
return $inst;
}