예제 #1
0
function createProductUrl($params, LiveCart $application)
{
    $product = $params['product'];
    $router = $application->getRouter();
    // use parent product data for child variations
    if (isset($product['Parent'])) {
        $product = $product['Parent'];
    }
    $handle = createHandleString($product['name_lang']);
    $urlParams = array('controller' => 'product', 'action' => 'index', 'producthandle' => $handle, 'id' => $product['ID']);
    if (isset($params['query'])) {
        $urlParams['query'] = $params['query'];
    }
    if (isset($params['context'])) {
        $urlParams['query'] .= (!empty($urlParams['query']) ? '&' : '') . $router->createUrlParamString($params['context']);
    }
    $url = $router->createUrl($urlParams, true);
    if (!empty($params['full'])) {
        $url = $router->createFullUrl($url);
    }
    if (!empty($params['filterChainHandle'])) {
        $url = $router->setUrlQueryParam($url, 'filters', $params['filterChainHandle']);
    }
    if (!empty($params['category']) && $params['category']['ID'] != $product['categoryID']) {
        $url = $router->setUrlQueryParam($url, 'category', $params['category']['ID']);
    }
    $router->setLangReplace($handle, 'name', $product);
    return $url;
}
예제 #2
0
 private function sendMessage(NewsletterSentMessage $sent, LiveCart $application)
 {
     $config = $application->getConfig();
     $email = new Email($application);
     $email->setTemplate('newsletter/template');
     $email->set('subject', $this->subject->get());
     $email->set('htmlMessage', $this->html->get());
     $email->set('text', $this->text->get());
     $email->set('email', $this->text->get());
     $email->setFrom($config->get('NEWSLETTER_EMAIL') ? $config->get('NEWSLETTER_EMAIL') : $config->get('MAIN_EMAIL'), $config->get('STORE_NAME'));
     if ($user = $sent->user->get()) {
         $email->setTo($user->email->get(), $user->getName());
         $email->set('email', $user->email->get());
     } else {
         if ($subscriber = $sent->subscriber->get()) {
             $email->setTo($subscriber->email->get());
             $email->set('email', $subscriber->email->get());
         }
     }
     //$sent->time->set(new ARExpressionHandle('NOW()'));
     $sent->save();
     if ($this->status->get() == self::STATUS_NOT_SENT) {
         $this->status->set(self::STATUS_PARTIALLY_SENT);
         $this->time->set(new ARExpressionHandle('NOW()'));
         $this->save();
     }
     return $email->send();
 }
예제 #3
0
파일: Email.php 프로젝트: saiber/www
 public function __construct(LiveCart $application)
 {
     $this->application = $application;
     $this->set('request', $application->getRequest()->toArray());
     $this->url = $this->application->router->createFullUrl('/', null, true);
     $config = $this->application->getConfig();
     ClassLoader::ignoreMissingClasses();
     if ('SMTP' == $config->get('EMAIL_METHOD')) {
         $server = $config->get('SMTP_SERVER');
         if (!$server) {
             $server = ini_get('SMTP');
         }
         $this->connection = Swift_SmtpTransport::newInstance($server, $config->get('SMTP_PORT'));
         if ($config->get('SMTP_USERNAME')) {
             $this->connection->setUsername($config->get('SMTP_USERNAME'));
             $this->connection->setPassword($config->get('SMTP_PASSWORD'));
         }
     } else {
         if ('FAKE' == $config->get('EMAIL_METHOD')) {
             $this->connection = Swift_Connection_Fake::newInstance();
         } else {
             $this->connection = Swift_MailTransport::newInstance();
         }
     }
     $this->swiftInstance = Swift_Mailer::newInstance($this->connection);
     $this->message = Swift_Message::newInstance();
     $this->setFrom($config->get('MAIN_EMAIL'), $config->get('STORE_NAME'));
     ClassLoader::ignoreMissingClasses(false);
 }
예제 #4
0
function createNewsPostUrl($params, LiveCart $application)
{
    $news = $params['news'];
    $urlParams = array('controller' => 'news', 'action' => 'view', 'handle' => createHandleString($news['title_lang']), 'id' => $news['ID']);
    $router = $application->getRouter();
    $url = $router->createUrl($urlParams, true);
    if (array_key_exists('full', $params) && $params['full'] == true) {
        $url = $router->createFullUrl($url);
    }
    return $url;
}
예제 #5
0
파일: ModuleRepo.php 프로젝트: saiber/www
 public static function getConfiguredRepos(LiveCart $application, $domain)
 {
     $k = 0;
     $repos = array();
     $config = $application->getConfig();
     while ($config->isValueSet('UPDATE_REPO_' . ++$k)) {
         $repo = $config->get('UPDATE_REPO_' . $k);
         if ($repo) {
             $repos[$repo] = new ModuleRepo($application, $repo, $domain);
         }
     }
     return $repos;
 }
예제 #6
0
 public static function getCacheMethods(LiveCart $application)
 {
     $ret = array();
     $tranlationHandler = $application->getLocale()->translationManager();
     foreach (new DirectoryIterator(dirname(__FILE__) . '/') as $method) {
         if (substr($method->getFileName(), 0, 1) != '.') {
             $class = substr($method->getFileName(), 0, -4);
             if ($class != __CLASS__ && file_exists($method->getPathname())) {
                 include_once $method->getPathname();
                 $tranlationHandler->setDefinition($class, call_user_func(array($class, 'getName')));
                 $ret[] = $class;
             }
         }
     }
     $ret = array_merge(array('FileCache'), array_diff($ret, array('FileCache')));
     return $ret;
 }
예제 #7
0
 protected function getPendingModuleUpdateStats(LiveCart $application)
 {
     $config = $application->getConfig();
     // modules needing update
     if (!$config->isValueSet('MODULE_STATS_UPDATED') || time() - $config->get('MODULE_STATS_UPDATED') > 3600) {
         $config->set('MODULE_STATS_UPDATED', time());
         $config->save();
         $controller = new ModuleController($this->application);
         $controller->initRepos();
         $updateResponse = $controller->index();
         $modules = $updateResponse->get('sortedModules');
         $config->set('MODULE_STATS_NEED_UPDATING', isset($modules['needUpdate']) ? count($modules['needUpdate']) : 0);
         $config->save();
         foreach ($this->getConfigFiles() as $file) {
             $this->loadLanguageFile($file);
         }
     }
 }
예제 #8
0
function createProductUrl($params, LiveCart $application)
{
    $product = $params['product'];
    // use parent product data for child variations
    if (isset($product['Parent'])) {
        $product = $product['Parent'];
    }
    //var_dump($product);
    $handle = !empty($product['URL']) ? createHandleString($product['URL']) : createHandleString($product['name_lang']);
    $urlParams = array('controller' => 'product', 'action' => 'index', 'producthandle' => $handle, 'id' => $product['ID']);
    $url = $application->getRouter()->createUrl($urlParams, true);
    if (!empty($params['full'])) {
        $url = $application->getRouter()->createFullUrl($url);
    }
    if (!empty($params['filterChainHandle'])) {
        $url = $application->getRouter()->setUrlQueryParam($url, 'filters', $params['filterChainHandle']);
    }
    $application->getRouter()->setLangReplace($handle, 'name', $product);
    return $url;
}
예제 #9
0
파일: index.php 프로젝트: GregerA/livecart
function runApp(LiveCart $app)
{
    static $attempts = 0;
    // check if we're not getting into an endless loop
    if (++$attempts > 5) {
        try {
            $app->run();
        } catch (Exception $e) {
            dump_livecart_trace($e);
            die('error');
        }
    }
    try {
        if ($app->isDevMode()) {
            try {
                $app->run();
            } catch (Exception $e) {
                if (!$e instanceof HTTPStatusException) {
                    dump_livecart_trace($e);
                } else {
                    throw $e;
                }
            }
        } else {
            $app->run();
        }
    } catch (HTTPStatusException $e) {
        if ($e->getController() instanceof BackendController) {
            $route = 'backend.err/redirect/' . $e->getStatusCode();
        } else {
            $route = 'err/redirect/' . $e->getStatusCode();
        }
        $app->getRouter()->setRequestedRoute($route);
        runApp($app);
    } catch (ARNotFoundException $e) {
        $app->getRouter()->setRequestedRoute('err/redirect/404');
        runApp($app);
    } catch (ControllerNotFoundException $e) {
        $app->getRouter()->setRequestedRoute('err/redirect/404');
        runApp($app);
    } catch (ActionNotFoundException $e) {
        $app->getRouter()->setRequestedRoute('err/redirect/404');
        runApp($app);
    } catch (UnsupportedBrowserException $e) {
        header('Location: ' . $app->getRouter()->createUrl(array('controller' => 'err', 'action' => 'backendBrowser')));
        exit;
    } catch (SQLException $e) {
        $_REQUEST['exception'] = $e;
        $app->getRouter()->setRequestedRoute('err/database');
        runApp($app);
    } catch (Exception $e) {
        $route = 'err/redirect/500';
        $app->getRouter()->setRequestedRoute($route);
        runApp($app);
    }
}
예제 #10
0
 public function toArray($amount = null)
 {
     $array = parent::toArray();
     if (!is_null($amount)) {
         $array['costAmount'] = $amount;
     }
     if (!$this->application) {
         $this->application = ActiveRecordModel::getApplication();
     }
     $amountCurrency = Currency::getInstanceById($array['costCurrency']);
     $currencies = $this->application->getCurrencySet();
     // get and format prices
     $prices = $formattedPrices = $taxPrices = $unformattedTaxPrices = array();
     foreach ($currencies as $id => $currency) {
         $prices[$id] = $currency->convertAmount($amountCurrency, $array['costAmount']);
         $formattedPrices[$id] = $currency->getFormattedPrice($prices[$id]);
         $unformattedTaxPrices[$id] = $currency->convertAmount($amountCurrency, $this->amountWithTax);
         $taxPrices[$id] = $currency->getFormattedPrice($unformattedTaxPrices[$id]);
         $withoutTaxPrices[$id] = $currency->convertAmount($amountCurrency, $this->amountWithoutTax);
         $formattedWithoutTaxPrices[$id] = $currency->getFormattedPrice($withoutTaxPrices[$id]);
     }
     $array['price'] = $prices;
     $array['priceWithTax'] = $unformattedTaxPrices;
     $array['formattedPrice'] = $formattedPrices;
     $array['taxPrice'] = $taxPrices;
     $array['priceWithoutTax'] = $withoutTaxPrices;
     $array['formattedPriceWithoutTax'] = $formattedWithoutTaxPrices;
     // shipping service name
     $id = $this->getServiceID();
     if (is_numeric($id)) {
         try {
             $service = ShippingService::getInstanceById($id, ShippingService::LOAD_DATA);
             $array['ShippingService'] = $service->toArray();
         } catch (ARNotFoundException $e) {
             return array();
         }
     } else {
         $array['ShippingService'] = array('name_lang' => $this->getServiceName(), 'provider' => $this->getProviderName());
     }
     return $array;
 }
예제 #11
0
파일: Controller.php 프로젝트: saiber/www
 /**
  * Adds a block to a controller layout
  *
  * Layout block is an atomic part of application which cannot be called directly
  * by a user. Block fills a layout which encapsulates currently executed action
  * (some kind of contextual menu or environment depending on application part)
  *
  * Usage (lets say it is a body of some controller action)
  * <code>
  *
  * // Generates output of newsListBlock() by using block/newList.tpl template (by default)
  * // and assigns an output to an APPLICATION_NAV template variable.
  *
  * $this->addBlock("APPLICATION_NAV", "newsList");
  *
  * // Lets say this is some other action
  * $this->removeBlock("newsList");
  *
  * </code>
  *
  * @param string $containerName Name of template variable to which content of this block will be assigned
  * @param string $blockName Name of block
  * @param string $viewName View name for block (without file extension)
  * @param bool $prepend Whether to add the block to the beginning of the current stack
  *
  * @see self::removeBlock()
  */
 public final function addBlock($containerName, $blockName, $viewName = null, $prepend = false)
 {
     if (!is_array($blockName)) {
         $blockName = array($this, $blockName);
     }
     $viewExt = $this->application->getRenderer()->getViewExtension();
     $blockMethodName = $blockName[1] . (substr($blockName[1], -5) == 'Block' ? '' : 'Block');
     if (empty($viewName)) {
         $viewName = "block" . DIRECTORY_SEPARATOR . $blockName[1] . "." . $viewExt;
     }
     $viewPath = $viewName . (substr($viewName, -1 * (strlen($viewExt) + 1)) == '.' . $viewExt ? '' : '.' . $viewExt);
     /*
     if (!method_exists($blockName[0], $blockMethodName))
     {
     	throw new ControllerException($this, "Block $blockName[1] not found!");
     }
     */
     $entry = array("container" => $containerName, "block" => $blockMethodName, "view" => $viewPath, 'call' => array($blockName[0], $blockMethodName));
     if ($prepend) {
         array_unshift($this->blockList, $entry);
     } else {
         $this->blockList[] = $entry;
     }
 }
예제 #12
0
function createCategoryUrl($params, LiveCart $application)
{
    static $simpleUrlTemplate = null;
    // create URL template
    $router = $application->getRouter();
    if (!$simpleUrlTemplate) {
        $simpleUrlTemplate = $router->createUrl(array('controller' => 'category', 'action' => 'index', 'cathandle' => '---', 'id' => 999));
        $simpleUrlTemplate = strtr($simpleUrlTemplate, array(999 => '#', '---' => '|'));
    }
    $category = $params['data'];
    if (!isset($category['ID'])) {
        $category['ID'] = 1;
    }
    $handle = isset($category['name_lang']) ? createHandleString($category['name_lang']) : '';
    // category names to use in other language links
    $router->setLangReplace($handle, 'name', $category);
    // no extra params, so we don't need to call the router to build the URL
    if (count($params) == 1) {
        return strtr($simpleUrlTemplate, array('#' => $category['ID'], '|' => $handle));
    }
    $filters = array();
    // remove filter (expand search)
    if (isset($params['removeFilter'])) {
        foreach ($params['filters'] as $key => $filter) {
            if ($filter['ID'] == $params['removeFilter']['ID']) {
                unset($params['filters'][$key]);
            }
        }
    }
    if (isset($params['removeFilters'])) {
        foreach ($params['removeFilters'] as $filter) {
            unset($params['filters'][$filter['ID']]);
        }
    }
    // get filters
    if (isset($params['filters'])) {
        foreach ($params['filters'] as $filter) {
            $filters[] = filterHandle($filter);
        }
    }
    // apply new filter (narrow search)
    if (!empty($params['addFilter'])) {
        $filters[] = filterHandle($params['addFilter']);
    }
    if (empty($handle)) {
        $handle = '-';
    }
    $urlParams = array('controller' => 'category', 'action' => empty($params['action']) ? 'index' : $params['action'], 'cathandle' => $handle, 'id' => $category['ID']);
    if (!empty($params['query'])) {
        $urlParams['query'] = $params['query'];
    }
    if (!empty($params['page'])) {
        $urlParams['page'] = $params['page'];
    }
    if ($filters) {
        $urlParams['filters'] = implode(',', $filters);
    }
    if ('index' != $urlParams['action']) {
        unset($urlParams['cathandle']);
        if (isset($urlParams['filters'])) {
            $urlParams['query'] = 'filters=' . $urlParams['filters'];
            unset($urlParams['filters']);
        }
    }
    $url = $application->getRouter()->createUrl($urlParams, true);
    if (!empty($params['full'])) {
        $url = $application->getRouter()->createFullUrl($url);
    }
    // remove empty search query parameter
    return preg_replace('/[\\?&]q=$/', '', $url);
}
예제 #13
0
파일: Country.php 프로젝트: saiber/www
 public function getCountryList(LiveCart $application)
 {
     $countries = $application->getEnabledCountries();
     asort($countries);
     return $countries;
 }
예제 #14
0
 public static function getSchemaColumns($schemaName, LiveCart $application, $customColumns = array())
 {
     $productSchema = ActiveRecordModel::getSchemaInstance($schemaName);
     $availableColumns = array();
     foreach ($productSchema->getFieldList() as $field) {
         $type = ActiveGrid::getFieldType($field);
         if (!$type && 'ID' != $field->getName()) {
             continue;
         }
         $availableColumns[$schemaName . '.' . $field->getName()] = $type;
     }
     $availableColumns = array_merge($availableColumns, $customColumns);
     foreach ($availableColumns as $column => $type) {
         $availableColumns[$column] = array('name' => $application->translate($column), 'type' => $type);
     }
     // specField columns
     if (self::isEav($schemaName)) {
         $fields = EavFieldManager::getClassFieldSet($schemaName);
         foreach ($fields as $field) {
             $fieldArray = $field->toArray();
             if ($field->isDate()) {
                 $type = 'date';
             } else {
                 $type = $field->isSimpleNumbers() ? 'numeric' : 'text';
             }
             $availableColumns['eavField.' . $field->getID()] = array('name' => $fieldArray['name_lang'], 'type' => $type);
         }
     }
     return $availableColumns;
 }
예제 #15
0
파일: cron.php 프로젝트: saiber/livecart
<?php

/**
 *  Front controller for LiveCart scheduled tasks
 *
 *  @author Integry Systems
 */
if (isset($_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = dirname($_SERVER['REQUEST_URI']) . '/';
} else {
    // retrieve base URL from configuration
    $url = (include dirname(__FILE__) . '/storage/configuration/url.php');
    $parsed = parse_url($url['url']);
    $_SERVER['HTTP_HOST'] = $parsed['host'];
    $_SERVER['REQUEST_URI'] = $parsed['path'];
    $_SERVER['REWRITE'] = $url['rewrite'];
}
if (isset($_SERVER['REWRITE']) && !$_SERVER['REWRITE']) {
    $this->request->set('noRewrite', true);
    //	$app->getRouter()->enableURLRewrite($_SERVER['rewrite']);
}
include dirname(__FILE__) . '/application/Initialize.php';
$app = new LiveCart();
if (isset($_SERVER['REWRITE'])) {
    //	$app->getRouter()->enableURLRewrite($_SERVER['rewrite']);
}
$app->getCron()->process();
예제 #16
0
파일: config.php 프로젝트: saiber/www
<?php

// to get LiveCart session (that uses custom session handler) need to initialize LiveCart.
error_reporting(A_ALL ^ E_STRICT);
ini_set('display_errors', 0);
include '../../../../application/Initialize.php';
ClassLoader::import('application.LiveCart');
ClassLoader::import('application.controller.BaseController');
$app = new LiveCart();
if (is_numeric($app->getSession()->get('User')) == false) {
    // no livecart session with loged in user (if getting controller will redirect)
    exit;
}
// consider user as admin if he can access:
$checkAgainst = array('backend.product' => array('create', 'update', 'delete'));
foreach ($checkAgainst as $controllerName => $actionNames) {
    foreach ($actionNames as $actionName) {
        $controller = $app->getControllerInstance($controllerName);
        $roles = $controller->getRoles();
        if ($controller->user->hasAccess($roles->getRole($actionName)) == false) {
            // cant access
            exit;
        }
    }
}
/**
 * sysem  config setting
 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
 * @link www.phpletter.com
 * @version 1.0
 * @since 22/April/2007
예제 #17
0
 public static function getAuthMethods(LiveCart $application)
 {
     return $application->getPluginClasses('application.model.datasync.api.auth');
 }
예제 #18
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 'On');
include '../application/Initialize.php';
ClassLoader::import('application.LiveCart');
$application = new LiveCart();
define('BUFFER', 50);
ClassLoader::import('application.model.product.Product');
$languages = $application->getLanguageArray();
$default = $application->getDefaultLanguageCode();
if (!$languages) {
    die('No additional languages enabled');
}
$count = ActiveRecordModel::getRecordCount('Product', new ARSelectFilter());
$parts = ceil($count / BUFFER);
$fields = array('name', 'shortDescription', 'longDescription');
ActiveRecordModel::beginTransaction();
for ($k = 0; $k < $parts; $k++) {
    $filter = new ARSelectFilter();
    $filter->setLimit(BUFFER, BUFFER * $k);
    $filter->setOrder(new ARFieldHandle('Product', 'ID'));
    $products = ActiveRecordModel::getRecordSet('Product', $filter);
    foreach ($products as $product) {
        foreach ($fields as $field) {
            if (!$product->getValueByLang($field, $default)) {
                foreach ($languages as $lang) {
                    if ($value = $product->getValueByLang($field, $lang)) {
                        $product->setValueByLang($field, $default, $value);
                        break;
                    }
예제 #19
0
 public function getVariationData(LiveCart $app)
 {
     $variations = $this->getVariationMatrix();
     if (!$variations) {
         return array();
     }
     $trackInventory = $app->getConfig()->get('INVENTORY_TRACKING') != 'DISABLE';
     foreach ($variations['products'] as $parentID => $products) {
         $variations['options'][$parentID] = array();
         // filter out unavailable products
         foreach ($variations['products'][$parentID] as $key => &$product) {
             if (!$product['isEnabled'] || $trackInventory && $product['stockCount'] <= 0) {
                 unset($variations['products'][$parentID][$key]);
             }
         }
         // get used variations
         $usedVariations = array();
         foreach ($variations['products'][$parentID] as $key => &$product) {
             $usedVariations = array_merge($usedVariations, explode('-', $key));
         }
         $usedVariations = array_flip($usedVariations);
         // prepare select options
         foreach ($variations['variations'][$parentID] as &$type) {
             $type['selectOptions'] = array();
             foreach ($type['variations'] as $variation) {
                 $var = $variation['Variation'];
                 if (isset($usedVariations[$var['ID']])) {
                     $type['selectOptions'][$var['ID']] = $var['name_lang'];
                 }
             }
             $variations['options'][$parentID] = $variations['options'][$parentID] + $type['selectOptions'];
         }
         // set used variation names
         foreach ($variations['products'][$parentID] as $key => &$product) {
             $product['variationNames'] = array_intersect_key($variations['options'][$parentID], array_flip(explode('-', $key)));
         }
     }
     return $variations;
 }