Exemplo n.º 1
0
 /**
  * Static templates compilation
  *
  * @return void
  */
 protected function createTemplatesCache()
 {
     $layout = \XLite\Core\Layout::getInstance();
     foreach ($this->getAnnotatedTemplates() as $data) {
         if (isset($data['zone'])) {
             switch ($data['zone']) {
                 case \XLite::ADMIN_INTERFACE:
                     $layout->setAdminSkin();
                     break;
                 case \XLite::CUSTOMER_INTERFACE:
                     $layout->setCustomerSkin();
                     break;
                 case \XLite::CONSOLE_INTERFACE:
                     $layout->setConsoleSkin();
                     break;
                 case \XLite::MAIL_INTERFACE:
                     $layout->setMailSkin();
                     break;
                 default:
                     break;
             }
         }
         \XLite\Singletons::$handler->flexy->prepare($data['path'], true);
     }
 }
Exemplo n.º 2
0
 /**
  * Returns an array of icons of all configured auth providers
  *
  * @return array
  */
 public function getIcons()
 {
     $authProviders = \XLite\Module\CDev\SocialLogin\Core\AuthManager::getAuthProviders();
     return array_filter(array_map(function ($p) {
         return \XLite\Core\Layout::getInstance()->getResourceWebPath($p->getSmallIconPath(), \XLite\Core\Layout::WEB_PATH_OUTPUT_URL);
     }, $authProviders));
 }
Exemplo n.º 3
0
 /**
  * Defines the LESS files to be part of the main LESS queue
  *
  * @param string $interface Interface to use: admin or customer values
  *
  * @return array
  */
 public function getLESSResources($interface)
 {
     $result = parent::getLESSResources($interface);
     if (\XLite::CUSTOMER_INTERFACE === $interface) {
         $result[] = 'modules/CDev/Paypal/style.less';
     }
     return $result;
 }
Exemplo n.º 4
0
 /**
  * Defines the Mobile skin specific JS files
  *
  * @param array $files
  *
  * @return array
  */
 protected function defineMobileJSResources($files)
 {
     $files = parent::defineMobileJSResources($files);
     if ('checkout' == \XLite\Core\Request::getInstance()->target) {
         $files[] = 'modules/XC/Stripe/payment.mobile.js';
         $files[] = array('url' => 'https://checkout.stripe.com/checkout.js');
     }
     return $files;
 }
Exemplo n.º 5
0
 /**
  * Preparing data for price param
  *
  * @param array $data Field description
  *
  * @return array 
  */
 protected function prepareFieldParamsPrice($data)
 {
     if ('product' == \XLite\Core\Request::getInstance()->target) {
         $data[self::SCHEMA_LINK_HREF] = $this->buildURL('product', '', array('product_id' => $this->getProductId(), 'page' => 'wholesale_pricing'));
         $data[self::SCHEMA_LINK_TEXT] = 'Wholesale pricing';
         $data[self::SCHEMA_LINK_IMG] = \XLite\Core\Layout::getInstance()->getResourceWebPath('modules/CDev/Wholesale/wp.svg');
     }
     return $data;
 }
Exemplo n.º 6
0
 /**
  * Returns current skin name
  *
  * @return string
  */
 protected function getCurrentSkinName()
 {
     $name = static::t('Standard');
     /** @var \XLite\Model\Module $module */
     $module = $this->getCurrentSkin();
     if ($module) {
         $name = \XLite\Core\Layout::getInstance()->getLayoutColorName() ?: $module->getModuleName();
     }
     return $name;
 }
Exemplo n.º 7
0
 /**
  * Define the LESS files structure
  *
  * @return array
  */
 protected static function getLESS($interface)
 {
     $list = \XLite\Core\Layout::getInstance()->getLESSResources($interface);
     $commonBootstrap = array('file' => \XLite\Core\Layout::getInstance()->getResourceFullPath('bootstrap/css/bootstrap.less', \XLite::COMMON_INTERFACE), 'media' => 'screen', 'weight' => 0, 'filelist' => array('bootstrap/css/bootstrap.less'), 'interface' => \XLite::COMMON_INTERFACE, 'original' => 'bootstrap/css/bootstrap.less', 'url' => \XLite\Core\Layout::getInstance()->getResourceWebPath('bootstrap/css/bootstrap.less', \XLite\Core\Layout::WEB_PATH_OUTPUT_SHORT, \XLite::COMMON_INTERFACE), 'less' => true);
     $result = array($commonBootstrap);
     foreach ($list as $less) {
         $result[] = array('file' => \XLite\Core\Layout::getInstance()->getResourceFullPath($less, $interface), 'media' => 'screen', 'merge' => 'bootstrap/css/bootstrap.less', 'filelist' => array($less), 'interface' => null, 'original' => $less, 'url' => \XLite\Core\Layout::getInstance()->getResourceWebPath($less, \XLite\Core\Layout::WEB_PATH_OUTPUT_SHORT, $interface), 'less' => true);
     }
     return $result;
 }
Exemplo n.º 8
0
 /**
  * Defines the specific image attributes
  *
  * @return array
  */
 protected function getImageAttributes()
 {
     $list = array();
     $list['type'] = 'image';
     $list['src'] = \XLite\Core\Layout::getInstance()->getResourceWebPath('images/spacer.gif', \XLite\Core\Layout::WEB_PATH_OUTPUT_URL);
     if (!isset($list['title'])) {
         $list['title'] = static::t($this->getButtonLabel());
     }
     $list['alt'] = $list['title'];
     return $list;
 }
Exemplo n.º 9
0
 /**
  * Define items
  *
  * @return array
  */
 protected function defineLanguageSelectorItems()
 {
     $items = array();
     $activeLanguages = $this->getActiveLanguages();
     if ($activeLanguages && count($activeLanguages) > 1) {
         $currentLanguage = $this->getCurrentLanguage();
         $items = array('lng_selector' => array(static::ITEM_TITLE => strtoupper($currentLanguage->getCode()), static::ITEM_WEIGHT => 50, static::ITEM_CHILDREN => array()));
         $weight = 1;
         foreach ($activeLanguages as $lng) {
             $items['lng_selector'][static::ITEM_CHILDREN][$lng->getCode()] = array(static::ITEM_TITLE => strtoupper($lng->getCode()), static::ITEM_LINK => $this->getChangeLanguageLink($lng), static::ITEM_WEIGHT => $weight++, static::ITEM_ICON_IMG => \XLite\Core\Layout::getInstance()->getResourceWebPath($lng->getFlagFile(), null, \XLite\Core\Layout::PATH_COMMON), static::ITEM_PUBLIC_ACCESS => true);
         }
     }
     return $items;
 }
Exemplo n.º 10
0
 /**
  * Retrieve property from the model object
  *
  * @param mixed $name Field/property name
  *
  * @return mixed
  */
 protected function getModelObjectValue($name)
 {
     $result = parent::getModelObjectValue($name);
     switch ($name) {
         case 'template':
             $module = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->findOneByModuleName('XC\\ColorSchemes');
             if ($result === $module->getModuleId()) {
                 $result = \XLite\Core\Layout::getInstance()->getLayoutColor() ?: \XLite\View\FormField\Select\Template::SKIN_STANDARD;
             }
             break;
         default:
     }
     return $result;
 }
Exemplo n.º 11
0
 /**
  * Retrieve property from the model object
  *
  * @param mixed $name Field/property name
  *
  * @return mixed
  */
 protected function getModelObjectValue($name)
 {
     switch ($name) {
         case 'template':
             $result = \XLite\View\FormField\Select\Template::SKIN_STANDARD;
             $currentModule = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getCurrentSkinModule();
             if ($currentModule) {
                 $currentColor = \XLite\Core\Layout::getInstance()->getLayoutColorName();
                 $result = $currentModule->getModuleId() . ($currentColor ? '_' . $currentColor : '');
             }
             break;
         default:
             $result = parent::getModelObjectValue($name);
     }
     return $result;
 }
Exemplo n.º 12
0
 /**
  * Return templates chain
  *
  * @return array
  */
 protected function getChain()
 {
     $result = array();
     /** @var \XLite\Core\Layout $layout */
     $layout = \XLite\Core\Layout::getInstance();
     $shortPath = $this->getValue();
     $files = array();
     foreach ($layout->getSkinPaths(\XLite::CUSTOMER_INTERFACE) as $path) {
         $fullPath = $path['fs'] . LC_DS . $shortPath;
         if (file_exists($fullPath) && is_file($fullPath)) {
             array_unshift($files, $fullPath);
         }
     }
     foreach ($files as $fullPath) {
         $result[substr($fullPath, strlen(LC_DIR_SKINS))] = htmlspecialchars(\Includes\Utils\FileManager::read($fullPath));
     }
     return $result;
 }
Exemplo n.º 13
0
 /**
  * Return structure of configuration for JS TinyMCE library
  *
  * @return array
  */
 protected function getTinyMCEConfiguration()
 {
     $layout = \XLite\Core\Layout::getInstance();
     $themeFiles = $this->getThemeFiles(false);
     $themeFiles = $themeFiles[static::RESOURCE_CSS];
     $themeFilesCSS = array();
     foreach ($themeFiles as $key => $file) {
         if (!is_array($file)) {
             $path = $layout->getResourceWebPath($file, \XLite\Core\Layout::WEB_PATH_OUTPUT_URL, \XLite::CUSTOMER_INTERFACE);
             if ($path) {
                 $themeFilesCSS[] = $this->getShopURL($path, null, array('t' => LC_START_TIME));
             }
         }
     }
     $contentCSS = implode(',', $themeFilesCSS);
     // Base is the web path to the tinymce library directory
     return array('contentCSS' => $contentCSS, 'shopURL' => \XLite\Core\URLManager::getShopURL(null, \XLite\Core\Request::getInstance()->isHTTPS(), array(), null, false), 'shopURLRoot' => \XLite\Model\Category::WEB_LC_ROOT, 'bodyClass' => $this->getParam(static::PARAM_STYLE), 'base' => dirname(\XLite\Singletons::$handler->layout->getResourceWebPath($this->getDir() . '/js/tinymce/tiny_mce.js', \XLite\Core\Layout::WEB_PATH_OUTPUT_URL)) . '/');
 }
Exemplo n.º 14
0
 /**
  * Get registered and prepared resources by type
  *
  * @param string $type Resource type
  *
  * @return array
  */
 public function getPreparedResourcesByType($type)
 {
     $resources = array_filter(\XLite\Core\Layout::getInstance()->getRegisteredResourcesByType($type), array($this, 'isValid' . strtoupper($type) . 'Resource'));
     $method = 'prepare' . strtoupper($type) . 'Resources';
     return $this->{$method}($resources);
 }
Exemplo n.º 15
0
 /**
  * Get logo
  *
  * @return string
  */
 public static function getSignUpLogo()
 {
     $logo = \XLite\Core\Layout::getInstance()->getResourceWebPath('modules/CDev/Paypal/signup_logo.png', \XLite\Core\Layout::WEB_PATH_OUTPUT_URL, \XLite::ADMIN_INTERFACE);
     return \XLite\Core\URLManager::getShopURL($logo, true, array(), \XLite\Core\URLManager::URL_OUTPUT_FULL, false);
 }
Exemplo n.º 16
0
 /**
  * Common management method to move/remove widgets
  *
  * @param string $getter        Getter routine
  * @param string $removeRoutine Method name of the layout to remove the widgets from lists
  * @param string $addRoutine    Method name of the layout to add the widgets to lists
  *
  * @return void
  */
 protected static function manageWidgets($getter, $removeRoutine, $addRoutine)
 {
     $layout = \XLite\Core\Layout::getInstance();
     foreach (call_user_func('static::' . $getter) as $name => $params) {
         $toSet = array();
         $fromSet = array();
         if (isset($params[static::TO_ADD]) || isset($params[static::TO_DELETE])) {
             $fromSet = isset($params[static::TO_DELETE]) ? $params[static::TO_DELETE] : array();
             $toSet = isset($params[static::TO_ADD]) ? $params[static::TO_ADD] : array();
         } elseif (count($params) === 1) {
             // Remove case
             $fromSet = array(is_array($params[0]) ? $params[0] : array($params[0]));
         } else {
             // Move widgets case
             $fromSet = array(is_array($params[0]) ? $params[0] : array($params[0]));
             $toSet = array(is_array($params[1]) ? $params[1] : array($params[1]));
         }
         foreach ($fromSet as $from) {
             $layout->{$removeRoutine}($name, $from[0], isset($from[1]) ? $from[1] : null);
         }
         foreach ($toSet as $to) {
             $toParams = array();
             if (isset($to[1])) {
                 $toParams['weight'] = $to[1];
             }
             if (isset($to[2])) {
                 $toParams['zone'] = $to[2];
             }
             $layout->{$addRoutine}($name, $to[0], $toParams);
         }
     }
 }
Exemplo n.º 17
0
 /**
  * Run application
  *
  * @param boolean $adminZone Admin interface flag OPTIONAL
  *
  * @return \XLite
  */
 public function run($adminZone = false)
 {
     // Set current area
     static::$adminZone = (bool) $adminZone;
     // Clear some data
     static::clearDataOnStartup();
     // Initialize logger
     \XLite\Logger::getInstance();
     // Initialize modules
     $this->initModules();
     if (\XLite\Core\Request::getInstance()->isCLI()) {
         // Set skin for console interface
         \XLite\Core\Layout::getInstance()->setConsoleSkin();
     } elseif (true === static::$adminZone) {
         // Set skin for admin interface
         \XLite\Core\Layout::getInstance()->setAdminSkin();
     }
     return $this;
 }
Exemplo n.º 18
0
 /**
  * Initialize all active modules
  *
  * @return void
  */
 public function initModules()
 {
     parent::initModules();
     \XLite\Core\Layout::getInstance()->addSkin('theme_tweaker/default', \XLite::CUSTOMER_INTERFACE);
 }
Exemplo n.º 19
0
 /**
  * Data for place order description
  *
  * @param array $packages
  *
  * @return array
  */
 protected function getOrderPackagingComment($packages)
 {
     // Switch interface to admin
     $layout = \XLite\Core\Layout::getInstance();
     $old_skin = $layout->getSkin();
     $old_interface = $layout->getInterface();
     $layout->setAdminSkin();
     // Get compiled widget content
     $widget = new \XLite\View\Order\Details\Admin\Packaging(array(\XLite\View\Order\Details\Admin\Packaging::PARAM_PACKAGES => $packages));
     $result = $widget->getContent();
     // Restore interface
     switch ($old_interface) {
         case \XLite::ADMIN_INTERFACE:
             $layout->setAdminSkin();
             break;
         case \XLite::CUSTOMER_INTERFACE:
             $layout->setCustomerSkin();
             break;
         case \XLite::CONSOLE_INTERFACE:
             $layout->setConsoleSkin();
             break;
         case \XLite::MAIL_INTERFACE:
             $layout->setMailSkin();
             break;
     }
     $layout->setSkin($old_skin);
     return $result;
 }
Exemplo n.º 20
0
 /**
  * Get payment method admin zone icon URL
  *
  * @return string
  */
 public function getAdminIconURL()
 {
     $url = $this->getProcessorObject() ? $this->getProcessorObject()->getAdminIconURL($this) : $this->getIconURL();
     if (true === $url || null === $url) {
         $module = $this->getProcessorModule();
         $url = $module ? \XLite\Core\Layout::getInstance()->getResourceWebPath('modules/' . $module->getAuthor() . '/' . $module->getName() . '/method_icon.jpg') : null;
     }
     return $url;
 }
Exemplo n.º 21
0
 /**
  * Defines if the current skin is the default one
  *
  * @return boolean
  */
 public static function isDefaultColorScheme()
 {
     return !\XLite\Core\Layout::getInstance()->getLayoutColor();
 }
Exemplo n.º 22
0
 /**
  * Returns current skin name
  *
  * @return string
  */
 protected function getCurrentSkinName()
 {
     return \XLite\Core\Layout::getInstance()->getLayoutColor() ? parent::getCurrentSkinName() : static::t('Standard');
 }
Exemplo n.º 23
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  * @see    ____func_see____
  * @since  1.0.0
  */
 protected function setUp()
 {
     set_time_limit(0);
     $request = $this->getRequest();
     // This data will be parsed by Reqest/Router transports
     $GLOBALS['_SERVER']['REQUEST_METHOD'] = $request['method'];
     if (!empty($request['data'])) {
         $GLOBALS['_' . $request['method']] = $request['data'];
     }
     if (!empty($request['cookies'])) {
         $GLOBALS['_COOKIE'] = $request['cookies'];
     }
     // Instantiate singltons
     if ($this->needAppInit($request)) {
         $this->app = \XLite::getInstance()->run($request['controller']);
     }
     // Set customer skin
     \XLite\Core\Layout::getInstance()->setCustomerSkin();
     // Clear and restart (if need) entity manager
     \XLite\Core\Database::getEM()->clear();
     $this->query('SET autocommit = 1');
     try {
         \XLite\Core\Database::getEM()->flush();
     } catch (\Doctrine\ORM\ORMException $e) {
         if ('The EntityManager is closed.' == $e->getMessage()) {
             \XLite\Core\Database::getInstance()->startEntityManager();
         } else {
             throw $e;
         }
     }
     \XLite\Core\Session::getInstance()->restart();
     // Memory usage
     $this->start['memory'] = memory_get_usage();
     $this->end['memory'] = 0;
     // Timing
     $this->start['time'] = microtime(true);
 }
Exemplo n.º 24
0
 /**
  * Get payment method admin zone icon URL
  *
  * @param \XLite\Model\Payment\Method $method Payment method
  *
  * @return string | boolean
  */
 public function getAdminIconURL(\XLite\Model\Payment\Method $method)
 {
     if (false !== strpos($method->getServiceName(), 'XPayments.Allowed')) {
         $name = $method->getServiceName();
     } else {
         $name = str_replace('XPayments', 'XPayments.Allowed', $method->getServiceName());
     }
     $file = 'modules/CDev/XPaymentsConnector/icons/' . $name . '.png';
     $filePath = LC_DIR_SKINS . 'admin' . LC_DS . 'en' . LC_DS . str_replace('/', LC_DS, $file);
     return \Includes\Utils\FileManager::isExists($filePath) ? \XLite\Core\Layout::getInstance()->getResourceWebPath($file) : true;
 }
Exemplo n.º 25
0
 /**
  * Return list of module directories which contain templates
  *
  * @return array
  */
 protected function getSkinDirs()
 {
     $result = array();
     foreach (\XLite\Core\Layout::getInstance()->getSkinsAll() as $interface => $tmp) {
         $result = array_merge($result, \XLite\Core\Layout::getInstance()->getSkinPaths($interface));
     }
     foreach ($result as $key => &$data) {
         $path = \Includes\Utils\ModulesManager::getRelativeDir($this->module->getAuthor(), $this->module->getName());
         $path = $data['fs'] . LC_DS . 'modules' . LC_DS . $path;
         if (\Includes\Utils\FileManager::isDirReadable($path)) {
             $data = $path;
         } else {
             unset($result[$key]);
         }
     }
     return array_values(array_unique($result));
 }
Exemplo n.º 26
0
 /**
  * Returns layout preview for given type
  *
  * @param string $value Layout type
  *
  * @return string
  */
 protected function getPreviewImage($value)
 {
     return \XLite\Core\Layout::getInstance()->getLayoutPreview(\XLite\Core\Database::getRepo('XLite\\Model\\Module')->getCurrentSkinModule(), \XLite\Core\Layout::getInstance()->getLayoutColor(), $value);
 }
Exemplo n.º 27
0
 /**
  * Returns option image
  *
  * @param array|string $module Module
  *
  * @return string
  */
 protected function getModuleImage($module)
 {
     if (static::SKIN_STANDARD === $module) {
         $result = \XLite\Core\Layout::getInstance()->getResourceWebPath('images/layout/preview_list.jpg');
     } else {
         $skinModule = $module['module'];
         $image = 'preview_list' . (isset($module['color']) ? '_' . $module['color'] : '') . '.jpg';
         $result = \XLite\Core\Layout::getInstance()->getResourceWebPath('modules/' . $skinModule->getAuthor() . '/' . $skinModule->getName() . '/' . $image);
     }
     return $result ?: \XLite\Core\Layout::getInstance()->getResourceWebPath('images/layout/preview_list_placeholder.jpg');
 }
Exemplo n.º 28
0
 /**
  * Get invoice logo
  *
  * @return string
  */
 public function getInvoiceLogo()
 {
     return \XLite\Core\Layout::getInstance()->getResourceWebPath('images/invoice_logo.png', \XLite\Core\Layout::WEB_PATH_OUTPUT_URL, \XLite::CUSTOMER_INTERFACE);
 }
Exemplo n.º 29
0
Arquivo: Main.php Projeto: kingsj/core
 /**
  * Method to initialize concrete module instance
  *
  * @return void
  * @access public
  * @since  1.0.0
  */
 public static function init()
 {
     \XLite\Core\Layout::getInstance()->addSkin('test');
 }
Exemplo n.º 30
0
 /**
  * Get image URL
  *
  * @return string
  */
 public function getURL()
 {
     $url = null;
     if ($this->getParam(self::PARAM_IMAGE) && $this->getParam(self::PARAM_IMAGE)->isExists()) {
         // Specified image
         $url = $this->getParam(self::PARAM_USE_CACHE) ? $this->resizedURL : $this->getParam(self::PARAM_IMAGE)->getFrontURL();
     }
     if (!$url && $this->getParam(self::PARAM_USE_DEFAULT_IMAGE)) {
         // Default image
         $url = \XLite::getInstance()->getOptions(array('images', 'default_image'));
         if (!\XLite\Core\Converter::isURL($url)) {
             $url = \XLite\Core\Layout::getInstance()->getResourceWebPath($url, \XLite\Core\Layout::WEB_PATH_OUTPUT_URL);
         }
     }
     return $url;
 }