本文整理汇总了PHP中Axis::app方法的典型用法代码示例。如果您正苦于以下问题:PHP Axis::app方法的具体用法?PHP Axis::app怎么用?PHP Axis::app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Axis
的用法示例。
在下文中一共展示了Axis::app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
if ($this->_resources = Axis::cache()->load('axis_acl_resources')) {
return;
}
foreach (Axis::app()->getModules() as $moduleName => $path) {
if ('Axis_Admin' === $moduleName) {
$path = $path . '/controllers';
} else {
$path = $path . '/controllers/Admin';
}
if (!is_dir($path)) {
continue;
}
foreach ($this->_scanDirectory($path) as $file) {
if (strstr($file, "Controller.php") == false) {
continue;
}
include_once $file;
}
}
$resource = 'admin';
$resources = array($resource);
$camelCaseToDash = new Zend_Filter_Word_CamelCaseToDash();
foreach (get_declared_classes() as $class) {
if (!is_subclass_of($class, 'Axis_Admin_Controller_Back')) {
continue;
}
list($module, $controller) = explode('Admin_', $class, 2);
$module = rtrim($module, '_');
if (empty($module)) {
$module = 'Axis_Core';
} elseif ('Axis' === $module) {
$module = 'Axis_Admin';
}
$module = strtolower($camelCaseToDash->filter($module));
list($namespace, $module) = explode('_', $module, 2);
$resource .= '/' . $namespace;
$resources[$resource] = $resource;
$resource .= '/' . $module;
$resources[$resource] = $resource;
$controller = substr($controller, 0, strpos($controller, "Controller"));
$controller = strtolower($camelCaseToDash->filter($controller));
$resource .= '/' . $controller;
$resources[$resource] = $resource;
foreach (get_class_methods($class) as $action) {
if (false == strstr($action, "Action")) {
continue;
}
$action = substr($action, 0, strpos($action, 'Action'));
$action = strtolower($camelCaseToDash->filter($action));
// $resources[$namespace][$module][$controller][] = $action;
$resources[$resource . '/' . $action] = $resource . '/' . $action;
}
$resource = 'admin';
}
asort($resources);
Axis::cache()->save($resources, 'axis_acl_resources', array('modules'));
$this->_resources = $resources;
}
示例2: getMethodNames
/**
* Retrieve the list of shipping methods of installed shipping modules
*
* @static
* @return array
*/
public static function getMethodNames()
{
if ($methods = Axis::cache()->load('shipping_methods_list')) {
return $methods;
}
$prefix = 'Shipping';
$modules = Axis::app()->getModules();
$methods = array();
foreach ($modules as $code => $path) {
list($namespace, $moduleName) = explode('_', $code);
if (substr($moduleName, 0, strlen($prefix)) != $prefix) {
continue;
}
$dir = opendir($path . '/Model');
while ($fname = readdir($dir)) {
if (!is_file("{$path}/Model/{$fname}")) {
continue;
}
list($methodName, $ext) = explode('.', $fname, 2);
if ($ext != 'php') {
continue;
}
$methods[$code . '/' . $methodName] = substr($moduleName, strlen($prefix)) . '_' . $methodName;
}
closedir($dir);
}
Axis::cache()->save($methods, 'shipping_methods_list', array('modules'));
return $methods;
}
示例3: __construct
/**
*
* @param string $charset
*/
public function __construct($charset = 'UTF-8')
{
parent::__construct($charset);
$this->view = Axis::app()->getBootstrap()->getResource('layout')->getView();
$this->view->addScriptPath(Axis::config('system/path') . '/app/design/mail');
$this->view->site = Axis::getSite()->name;
$this->view->company = Axis::single('core/site')->getCompanyInfo();
}
示例4: runSetExpressCheckout
public function runSetExpressCheckout()
{
$options = array();
$options['CURRENCY'] = $this->getBaseCurrencyCode();
$amount = $this->getAmountInBaseCurrency(Axis::single('checkout/checkout')->getTotal()->getTotal());
if (!$amount) {
$message = "\n\tFailure SetExpressCheckout. Total order null.\n";
$this->log($message);
Axis_Message::getInstance()->addError($message);
return false;
}
switch ($this->_config->paymentAction) {
case Axis_PaymentPaypal_Model_Option_Express_PaymentAction::ORDER:
$options['PAYMENTACTION'] = Axis_PaymentPaypal_Model_Option_Express_PaymentAction::ORDER;
break;
case Axis_PaymentPaypal_Model_Option_Express_PaymentAction::SALE:
$options['PAYMENTACTION'] = Axis_PaymentPaypal_Model_Option_Express_PaymentAction::SALE;
break;
default:
$options['PAYMENTACTION'] = Axis_PaymentPaypal_Model_Option_Express_PaymentAction::AUTHORIZATION;
break;
}
$view = Axis::app()->getBootstrap()->getResource('layout')->getView();
$returnUrl = $view->href('/paymentpaypal/express/details', true);
$cancelUrl = $view->href('/paymentpaypal/express/cancel', true);
$delivery = $this->getCheckout()->getDelivery();
if ($delivery instanceof Axis_Address) {
$options['ADDROVERRIDE'] = 1;
// set the address info
$options['SHIPTONAME'] = $delivery->firstname . ' ' . $delivery->lastname;
//$options['NAME'] = $delivery->firstname'] . ' ' . $delivery->lastname;
$options['SHIPTOSTREET'] = $delivery->street_address;
if (isset($delivery->suburb)) {
$options['SHIPTOSTREET2'] = $delivery->suburb;
}
$options['SHIPTOCITY'] = $delivery->city;
$options['SHIPTOSTATE'] = null !== $delivery->zone ? $delivery->zone['code'] : '';
$options['SHIPTOZIP'] = $delivery->postcode;
$options['SHIPTOCOUNTRYCODE'] = $delivery->country['iso_code_2'];
$options['PHONENUM'] = $delivery->phone;
}
if ($this->_config->confirmedAddress) {
$options['REQCONFIRMSHIPPING'] = 1;
}
$options['SOLUTIONTYPE'] = 'SOLE';
$response = $this->getApi()->SetExpressCheckout(number_format($amount, 2), $returnUrl, $cancelUrl, $options);
$this->log("\tRun SetExpressCheckout \n " . "\tAMT: " . number_format($amount, 2) . "\n" . "\tReturn URL : " . $returnUrl . "\n" . "\tCancel Url : " . $cancelUrl . "\n" . "\tOptions: " . Zend_Debug::dump($options, null, false) . "\n" . "\tResponse: " . Zend_Debug::dump($response, null, false));
if ($response['ACK'] != 'Success') {
$this->log("Response : " . Zend_Debug::dump($response, null, false));
foreach ($this->getMessages($response) as $severity => $messages) {
Axis::message()->batchAdd($messages, $severity);
}
return false;
}
$this->getStorage()->token = preg_replace('/[^0-9.A-Z\\-]/', '', urldecode($response['TOKEN']));
return $response;
}
示例5: errorAction
public function errorAction()
{
//error_log('errorAction');
$this->setCanonicalUrl(false);
$this->getResponse()->clearBody();
$errors = $this->_getParam('error_handler');
$exception = $errors->exception;
// log all kind of errors
try {
$log = new Zend_Log(new Zend_Log_Writer_Stream(Axis::config()->system->path . Axis::config()->log->main->php));
$log->debug($exception->getMessage() . "\n" . $exception->getTraceAsString());
} catch (Zend_Log_Exception $e) {
//who cares
}
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
return $this->_forward('not-found');
//return $this->notFoundAction();
//return $this->notFoundAction();
default:
// application error
$this->_helper->layout->setLayout('layout_error');
// hardcoded layout for application errors
$this->getResponse()->setHttpResponseCode(500);
$this->view->pageTitle = Axis::translate('core')->__('An error has occured processing your request');
$this->view->meta()->setTitle($this->view->pageTitle);
if (Axis::app()->getEnvironment() == 'development') {
// $traceAsString = preg_replace(
// '/(#\d+\s)(\/.*\/[^\/]+(?:\.php|\.phtml))/',
//// "<a onclick=\"window.open('file://$2');return false;\">$1$2</a>",
// "<a href=\"file://$2\">$1$2</a>",
// $exception->getTraceAsString()
// );
$this->view->error = str_replace(AXIS_ROOT . '/', '/', $exception->getMessage() . "\n<strong>" . Axis::translate('core')->__('Trace') . ":</strong>\n" . $this->view->escape($exception->getTraceAsString()));
}
break;
}
}
示例6: getMethodNames
/**
* Retrieve the list of paymetns methods of installed payment modules
* @return array
*/
public static function getMethodNames()
{
if ($methods = Axis::cache()->load('payment_methods_list')) {
return $methods;
}
$prefix = 'Payment';
$modules = Axis::app()->getModules();
$methods = array();
foreach ($modules as $code => $path) {
list($namespace, $moduleName) = explode('_', $code);
if (substr($moduleName, 0, strlen($prefix)) != $prefix) {
continue;
}
if (!is_dir($path . '/Model')) {
continue;
}
$dir = opendir($path . '/Model');
while ($fname = readdir($dir)) {
if (!is_file("{$path}/Model/{$fname}")) {
continue;
}
list($methodName, $ext) = explode('.', $fname, 2);
if ($ext != 'php' || $methodName == 'Abstract') {
continue;
}
$className = $code . '_Model_' . $methodName;
if (!in_array('Axis_Method_Payment_Model_Abstract', class_parents($className))) {
continue;
}
$methods[$code . '/' . $methodName] = substr($moduleName, strlen($prefix)) . '_' . $methodName;
}
closedir($dir);
}
Axis::cache()->save($methods, 'payment_methods_list', array('modules'));
return $methods;
}
示例7: getConfig
/**
* Retrieve the config of all modules, or one of module if required
*
* @param string $module [optional]
* @return mixed(array|boolean)
*/
public function getConfig($module = null)
{
if (null === $module) {
if (!($result = Axis::cache()->load('axis_modules_config'))) {
$modules = Axis::app()->getModules();
$result = array();
foreach ($modules as $moduleCode => $path) {
if (file_exists($path . '/etc/config.php') && is_readable($path . '/etc/config.php')) {
include_once $path . '/etc/config.php';
if (!isset($config)) {
continue;
}
$result += $config;
}
}
Axis::cache()->save($result, 'axis_modules_config', array('modules'));
}
$config = $result;
} else {
list($namespace, $module) = explode('_', $module, 2);
$configFile = Axis::config()->system->path . '/app/code/' . $namespace . '/' . $module . '/etc/config.php';
if (!is_file($configFile)) {
return false;
}
include $configFile;
if (!isset($config)) {
return false;
}
}
return $config;
}
示例8: postProcess
public function postProcess(Axis_Sales_Model_Order_Row $order)
{
$view = Axis::app()->getBootstrap()->getResource('layout')->getView();
$delivery = $order->getDelivery();
$formFields = array('business' => $this->_config->email, 'return' => $view->href('paymentpaypal/standard/success'), 'cancel_return' => $view->href('paymentpaypal/standard/cancel'), 'notify_url' => $view->href('paymentpaypal/standard/ipn'), 'invoice' => $order->id, 'address_override' => 1, 'first_name' => $delivery->getFirstname(), 'last_name' => $delivery->getLastname(), 'address1' => $delivery->getStreetAddress(), 'address2' => $delivery->getSuburb(), 'city' => $delivery->getCity(), 'state' => $delivery->getZone()->getCode(), 'country' => $delivery->getCountry()->getIsoCode2(), 'zip' => $delivery->getPostcode());
if ($this->_config->logo) {
$formFields['cpp_header_image'] = $this->_config->logo;
}
if ($this->_config->paymentAction) {
$formFields['paymentaction'] = strtolower($this->_config->paymentAction);
}
$transaciton_type = $this->_config->transactionType;
/*
O=aggregate cart amount to paypal
I=individual items to paypal
*/
if ($transaciton_type == 'Aggregate Cart') {
$businessName = $this->_config->name;
$formFields = array_merge($formFields, array('cmd' => '_ext-enter', 'redirect_cmd' => '_xclick', 'item_name' => $businessName ? $businessName : Axis::config()->core->store->name, 'currency_code' => $this->getBaseCurrencyCode(), 'amount' => sprintf('%.2f', $this->getAmountInBaseCurrency($order->getSubTotal(), $order->currency))));
$tax = $order->getTax();
$shippingTax = $order->getShippingTax();
$tax = sprintf('%.2f', $tax + $shippingTax);
if ($tax > 0) {
$formFields['tax'] = $tax;
}
} else {
$formFields = array_merge($formFields, array('cmd' => '_cart', 'upload' => '1'));
$products = $order->getProducts();
if ($products) {
$i = 1;
foreach ($products as $product) {
$formFields = array_merge($formFields, array('item_name_' . $i => $product['name'], 'item_number_' . $i => $product['sku'], 'quantity_' . $i => intval($product['quantity']), 'amount_' . $i => sprintf('%.2f', $product['final_price'])));
if ($product['tax'] > 0) {
$formFields = array_merge($formFields, array('tax_' . $i => sprintf('%.2f', $product['tax'])));
}
$i++;
}
}
}
$totals = $order->getTotals();
$shipping = sprintf('%.2f', $totals['shipping']['value']);
if ($shipping > 0) {
if ($transaciton_type == 'Aggregate Cart') {
$formFields['shipping'] = $shipping;
} else {
$shippingTax = $totals['shipping_tax']['value'];
$formFields = array_merge($formFields, array('item_name_' . $i => $order->shipping_method, 'quantity_' . $i => 1, 'amount_' . $i => $shipping, 'tax_' . $i => sprintf('%.2f', $shippingTax)));
$i++;
}
}
$sReq = '';
$rArr = array();
foreach ($formFields as $k => $v) {
/*
replacing & char with and. otherwise it will break the post
*/
$value = str_replace('&', 'and', $v);
$rArr[$k] = $value;
$sReq .= '&' . $k . '=' . $value;
}
$this->getStorage()->formFields = $rArr;
return array('redirect' => $view->href('paymentpaypal/standard/submit'));
}
示例9: __construct
public function __construct($config = array())
{
if (null === self::$_view) {
$this->setView(Axis_Layout::getMvcInstance()->getView());
}
list($namespace, $module, , $name) = explode('_', get_class($this));
$this->_enabled = in_array($namespace . '_' . $module, array_keys(Axis::app()->getModules()));
if (!$this->_enabled) {
return;
}
$this->_data = array('box_namespace' => $namespace, 'box_module' => $module, 'box_name' => $name);
$this->_enabled = $this->refresh()->setFromArray($config);
if (!isset($config['supress_init'])) {
// used at backend box configuration
$this->init();
}
}
示例10: firephp
/**
* Debug function
*
* @return Axis_Db_Table_Select Fluent
*/
public function firephp()
{
if ('development' === Axis::app()->getEnvironment()) {
Axis_FirePhp::log($this->__toString());
}
return $this;
}
示例11: up
public function up()
{
Axis::single('core/config_field')->add('gbase', 'Google Base', null, null, array('translation_module' => 'Axis_GoogleBase'))->add('gbase/main/payment', 'Google Base/General/Payment', 'Discover,American Express,Visa,MasterCard,Check', 'multiple', 'Let your customers buy with all major credit cards', array('config_options' => 'Discover,American Express,Visa,MasterCard,Wire transfer,Check,Cash'))->add('gbase/main/notes', 'Payment notes', 'Google Checkout', 'string')->add('gbase/main/application', 'Application', 'StoreArchitect-Axis-' . Axis::app()->getVersion(), 'string', 'Name of the application that last modified this item.\\r\\nAll applications should set this attribute whenever they insert or update an item. Recommended format : Organization-ApplicationName-Version')->add('gbase/main/dryRun', 'dryRun', '0', 'bool', "Set 'Yes' for testing, 'No' for production")->add('gbase/main/link', 'Link products to', 'Website', 'select', "If you want to use GoogleBase pages as landing page for your items, or you can't give the link to your webstore - select Google Base, otherwise - select Website.", array('config_options' => 'GoogleBase,Website'))->add('gbase/main/itemType', 'Item type', 'Products', 'string', 'Type of your products. Read this for more information http://code.google.com/apis/base/starting-out.html#ItemTypes')->add('gbase/auth/login', 'Login', '', 'handler', 'Your google account to submit products', array('model' => 'Crypt'))->add('gbase/auth/password', 'Password', '', 'handler', 'Password to google account', array('model' => 'Crypt'))->add('gbase/auth/connection', 'Connection type', 'AuthSub', 'select', 'Login type. For ClientLogin fill login and password fields. For AuthSub you will have to enter login and password manually', array('config_options' => 'ClientLogin,AuthSub'));
}
示例12: _initRouter
protected function _initRouter()
{
$this->bootstrap('FrontController');
$router = new Axis_Controller_Router_Rewrite();
// pre router config
$defaultLocale = Axis_Locale::getDefaultLocale();
$locales = Axis_Locale::getLocaleList(true);
Axis_Controller_Router_Route_Front::setDefaultLocale($defaultLocale);
Axis_Controller_Router_Route_Front::setLocales($locales);
// include routes files
$routeFiles = Axis::app()->getRoutes();
foreach ($routeFiles as $routeFile) {
if (!is_readable($routeFile)) {
continue;
}
include_once $routeFile;
}
$router->removeDefaultRoutes();
if (!$router instanceof Axis_Controller_Router_Rewrite) {
throw new Axis_Exception('Incorrect routes');
}
$front = $this->getResource('FrontController');
$front->setRouter($router);
$sslRedirectorActionHelper = new Axis_Controller_Action_Helper_SecureRedirector();
Zend_Controller_Action_HelperBroker::addHelper($sslRedirectorActionHelper);
return $router;
}
示例13: DoDirectPayment
/**
* DoDirectPayment
* Sends CC information to gateway for processing.
*
* Requires Website Payments Pro or Payflow Pro as merchant gateway.
*
* PAYMENTACTION = Authorization (auth/capt) or Sale (final)
*/
public function DoDirectPayment($amount, $cc, $cvv2 = '', $exp, $fname = null, $lname = null, $cc_type, $options = array(), $nvp = array())
{
$values = $options;
$values['AMT'] = $amount;
$values['ACCT'] = $cc;
if ($cvv2 != '') {
$values['CVV2'] = $cvv2;
}
if ($this->_mode == 'payflow') {
$values['EXPDATE'] = $exp;
$values['TENDER'] = 'C';
$values['TRXTYPE'] = $this->_trxtype;
$values['VERBOSITY'] = 'MEDIUM';
if (null !== $fname . $lname && !isset($values['NAME'])) {
$values['NAME'] = $fname . ' ' . $lname;
}
} elseif ($this->_mode == 'nvp') {
$values = array_merge($values, $nvp);
$values['CREDITCARDTYPE'] = $cc_type == 'American Express' ? 'Amex' : $cc_type;
$values['FIRSTNAME'] = $fname;
$values['LASTNAME'] = $lname;
$view = Axis::app()->getBootstrap()->getResource('layout')->getView();
$values['NOTIFYURL'] = urlencode($view->href('paymentpaypal/express'));
if (!isset($values['PAYMENTACTION'])) {
$values['PAYMENTACTION'] = $this->_trxtype == 'S' ? 'Sale' : 'Authorization';
}
if (isset($values['COUNTRY'])) {
unset($values['COUNTRY']);
}
if (isset($values['NAME'])) {
unset($values['NAME']);
}
if (isset($values['COMMENT1'])) {
unset($values['COMMENT1']);
}
if (isset($values['COMMENT2'])) {
unset($values['COMMENT2']);
}
if (isset($values['CUSTREF'])) {
unset($values['CUSTREF']);
}
}
ksort($values);
return $this->_request($values, 'DoDirectPayment');
}
示例14: createFromCheckout
/**
* Create order, and clears shopping cart after that
*
* @return Axis_Sales_Model_Order_Row
* @throws Axis_Exception
*/
public function createFromCheckout()
{
/**
* @var Axis_Checkout_Model_Checkout $checkout
*/
$checkout = Axis::single('checkout/checkout');
if (!$checkout->getCart()->validateContent()) {
throw new Axis_Exception();
}
$orderRow = $this->createRow();
$storage = $checkout->getStorage();
if ($customer = Axis::getCustomer()) {
$orderRow->customer_id = $customer->id;
$orderRow->customer_email = $customer->email;
} else {
$orderRow->customer_email = $checkout->getBilling()->email;
}
$orderRow->site_id = Axis::getSiteId();
$orderRow->payment_method = $checkout->payment()->getTitle();
$orderRow->payment_method_code = $checkout->payment()->getCode();
$orderRow->shipping_method = $checkout->shipping()->getTitle();
$orderRow->shipping_method_code = $checkout->shipping()->getCode();
$orderRow->date_purchased_on = Axis_Date::now()->toSQLString();
$orderRow->currency = Axis::single('locale/currency')->getCode();
$orderRow->currency_rate = Axis::single('locale/currency')->getData($orderRow->currency, 'rate');
$orderRow->order_total = $checkout->getTotal()->getTotal();
$orderRow->txn_id = 0;
//@todo
$orderRow->order_status_id = 0;
$orderRow->ip_address = $_SERVER['REMOTE_ADDR'];
$orderRow->customer_comment = $storage->customer_comment;
$orderRow->locale = Axis_Locale::getLocale()->toString();
/* build delivery & billing arrays */
$addressFormatId = Axis::config('core/store/addressFormat');
$delivery = $checkout->getDelivery()->toArray();
$delivery['country'] = isset($delivery['country']['name']) ? $delivery['country']['name'] : '';
if (isset($delivery['zone']['name'])) {
$delivery['state'] = $delivery['zone']['name'];
}
$delivery['address_format_id'] = $addressFormatId;
$billing = $checkout->getBilling()->toArray();
$billing['country'] = isset($billing['country']['name']) ? $billing['country']['name'] : '';
if (isset($billing['zone']['name'])) {
$billing['state'] = $billing['zone']['name'];
}
$billing['address_format_id'] = $addressFormatId;
unset($billing['id'], $delivery['id']);
foreach ($delivery as $key => $value) {
$delivery['delivery_' . $key] = $value;
}
foreach ($billing as $key => $value) {
$billing['billing_' . $key] = $value;
}
$orderRow->setFromArray($delivery);
$orderRow->setFromArray($billing);
/* Save order (auto generate number ) */
$orderRow->save();
/* Add products to order and change quantity */
$modelOrderProduct = Axis::single('sales/order_product');
foreach ($checkout->getCart()->getProducts() as $product) {
$modelOrderProduct->add($product, $orderRow->id);
}
/* Add total info */
$total = $checkout->getTotal();
$orderTotal = Axis::single('sales/order_total');
foreach ($total->getCollects() as $collect) {
$orderTotal->insert(array('order_id' => $orderRow->id, 'code' => $collect['code'], 'title' => $collect['title'], 'value' => $collect['total']));
}
// update product stock
$orderRow->setStatus('pending');
// Clear cart after checkout
if ('development' != Axis::app()->getEnvironment()) {
$checkout->getCart()->clear();
}
return $orderRow;
}
示例15: _isEnabled
/**
* @return boolean
*/
protected function _isEnabled()
{
if (null === $this->_enabled) {
$this->_enabled = in_array($this->getData('box_namespace') . '_' . $this->getData('box_module'), array_keys(Axis::app()->getModules()));
}
return $this->_enabled;
}