Exemplo n.º 1
0
 /**
  * Register new shipping processor. All processors classes must be
  * derived from \XLite\Model\Shipping\Processor\AProcessor class
  *
  * @param string $processorClass Processor class
  *
  * @return void
  */
 public static function registerProcessor($processorClass)
 {
     if (!isset(static::$registeredProcessors[$processorClass]) && \XLite\Core\Operator::isClassExists($processorClass)) {
         static::$registeredProcessors[$processorClass] = new $processorClass();
         uasort(static::$registeredProcessors, array(\XLite\Model\Shipping::getInstance(), 'compareProcessors'));
     }
 }
Exemplo n.º 2
0
 /**
  * Find all active modifiers
  *
  * @return array
  */
 public function findActive()
 {
     $list = $this->createQueryBuilder()->getResult();
     $list = is_array($list) ? new \XLite\DataSet\Collection\OrderModifier($list) : null;
     if ($list) {
         foreach ($list as $i => $item) {
             if (!\XLite\Core\Operator::isClassExists($item->getClass())) {
                 unset($list[$i]);
             }
         }
     }
     return $list;
 }
Exemplo n.º 3
0
 /**
  * Get storage 
  * 
  * @return \XLite\Model\Base\Storage
  */
 protected function getStorage()
 {
     if (!isset($this->storage) || !is_object($this->storage) || !$this->storage instanceof \XLite\Model\Base\Storage) {
         $class = \XLite\Core\Request::getInstance()->storage;
         if (\XLite\Core\Operator::isClassExists($class)) {
             $id = \XLite\Core\Request::getInstance()->id;
             $this->storage = \XLite\Core\Database::getRepo($class)->find($id);
             if (!$this->storage->isFileExists()) {
                 $this->storage = null;
             }
         }
     }
     return $this->storage;
 }
Exemplo n.º 4
0
Arquivo: Main.php Projeto: kingsj/core
 /**
  * Returns repository class for model class of current node
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node Current node
  *
  * @return string
  */
 protected function getRepositoryClass(\Includes\Decorator\DataStructure\Graph\Classes $node)
 {
     $repositoryClass = null;
     if (!($node->isLowLevelNode() || $node->isTopLevelNode() || !$node->isDecorator())) {
         $children = $node->getChildren();
         $repositoryClass = isset($children[0]) ? $this->getRepositoryClass($children[0]) : $this->getDefaultRepositoryClass('');
     } else {
         $repositoryClass = \Includes\Utils\Converter::getPureClassName($node->getClass());
         $repositoryClass = \Includes\Utils\Converter::prepareClassName(str_replace('\\Model\\', '\\Model\\Repo\\', $repositoryClass), false);
         if (!\XLite\Core\Operator::isClassExists($repositoryClass)) {
             $repositoryClass = $this->getDefaultRepositoryClass($repositoryClass);
         }
     }
     return $repositoryClass;
 }
Exemplo n.º 5
0
 /**
  * Get storage by a link
  *
  * @return \XLite\Model\Base\Storage|\XLite\Module\XC\CanadaPost\Model\Base\Link|null
  */
 protected function getCapostStorageByLink()
 {
     if (!isset($this->storage) || !is_object($this->storage) || !$this->storage instanceof \XLite\Model\Base\Storage) {
         $class = \XLite\Core\Request::getInstance()->storage;
         if (\XLite\Core\Operator::isClassExists($class)) {
             $link = \XLite\Core\Database::getRepo($class)->find($this->getCapostLinkId());
             if (isset($link)) {
                 $this->storage = $link->getStorage();
                 if (!isset($this->storage) && $link->callApiGetArtifact(true)) {
                     // Download artifact
                     $this->storage = $link->getStorage();
                     if (!$this->storage->isFileExists()) {
                         $this->storage = null;
                     }
                 }
             }
         }
     }
     return $this->storage;
 }
Exemplo n.º 6
0
 /**
  * Get payment processor class
  *
  * @return string
  */
 public function getClass()
 {
     $class = parent::getClass();
     if (Paypal\Main::PP_METHOD_EC == $this->getServiceName()) {
         $className = 'XLite\\' . $class;
         /** @var \XLite\Model\Payment\Base\Processor $processor */
         $processor = \XLite\Core\Operator::isClassExists($className) ? $className::getInstance() : null;
         if ($this->isForceMerchantAPI($processor)) {
             $class = 'Module\\CDev\\Paypal\\Model\\Payment\\Processor\\ExpressCheckoutMerchantAPI';
         }
     }
     if (Paypal\Main::PP_METHOD_PC == $this->getServiceName()) {
         $className = 'XLite\\' . $class;
         /** @var \XLite\Model\Payment\Base\Processor $processor */
         $processor = \XLite\Core\Operator::isClassExists($className) ? $className::getInstance() : null;
         if ($this->getExpressCheckoutPaymentMethod()->isForceMerchantAPI($processor)) {
             $class = 'Module\\CDev\\Paypal\\Model\\Payment\\Processor\\PaypalCreditMerchantAPI';
         }
     }
     return $class;
 }
Exemplo n.º 7
0
 /**
  * Return controller for current page
  *
  * @param string $target Controller target
  * @param array  $params Controller params OPTIONAL
  *
  * @return \XLite\Core\WidgetDataTransport
  */
 public function getPageInstance($target, array $params = array())
 {
     $class = \XLite\Core\Converter::getControllerClass($target);
     return new \XLite\Core\WidgetDataTransport(\XLite\Core\Operator::isClassExists($class) ? new $class(array('target' => $target) + $params) : null);
 }
Exemplo n.º 8
0
 /**
  * Compose controller class name using target
  *
  * @param string $target Current target
  *
  * @return string
  */
 public static function getControllerClass($target)
 {
     $zone = 'Customer';
     if (\XLite\Core\Request::getInstance()->isCLI()) {
         $zone = 'Console';
     } elseif (\XLite::isAdminZone()) {
         $zone = 'Admin';
     }
     $target = static::convertToCamelCase($target);
     // Initialize cache
     if (null === static::$cacheControllers) {
         static::$cacheControllers = static::getSystemCacheDriver()->fetch('controllers');
         if (!is_array(static::$cacheControllers)) {
             static::$cacheControllers = array();
         }
     }
     // Check cache
     $class = isset(static::$cacheControllers[$zone . '.' . $target]) ? static::$cacheControllers[$zone . '.' . $target] : null;
     if (!$class) {
         // Detect
         $prefix = 'Controller\\' . $zone . '\\' . static::convertToCamelCase($target);
         $class = 'XLite\\' . $prefix;
         // If non core controller
         if (!\XLite\Core\Operator::isClassExists($class)) {
             $class = null;
             $base = LC_DIR_CACHE_CLASSES;
             $path = $base . 'XLite' . LC_DS . 'Module' . LC_DS . '*' . LC_DS . '*' . LC_DS . 'Controller' . LC_DS . $zone . LC_DS . $target . '.php';
             $list = glob($path);
             if ($list) {
                 $length = strlen(LC_DIR_CACHE_CLASSES);
                 foreach ($list as $path) {
                     $preclass = str_replace(LC_DS, '\\', substr($path, $length, -4));
                     $reflection = new \ReflectionClass($preclass);
                     // Check - decorator or not
                     if (!$reflection->isAbstract()) {
                         $class = $preclass;
                         break;
                     }
                 }
             }
         }
         if ($class) {
             static::$cacheControllers[$zone . '.' . $target] = $class;
             static::getSystemCacheDriver()->save('controllers', static::$cacheControllers);
         }
     }
     return $class;
 }
Exemplo n.º 9
0
 /**
  * Process steps
  *
  * @return void
  */
 protected function processSteps()
 {
     if ($this->getOptions()->include) {
         foreach ($this->steps as $i => $step) {
             if (!in_array($step, $this->getOptions()->include)) {
                 unset($this->steps[$i]);
             }
         }
     }
     foreach ($this->steps as $i => $step) {
         if (\XLite\Core\Operator::isClassExists($step)) {
             $this->steps[$i] = new $step($this);
         } else {
             unset($this->steps[$i]);
         }
     }
     $this->steps = array_values($this->steps);
 }
Exemplo n.º 10
0
 /**
  * Apply 
  * 
  * @param float                $value     Property value
  * @param \XLite\Model\AEntity $model     Model
  * @param string               $property  Model's property
  * @param array                $behaviors Behaviors
  * @param string               $purpose   Purpose
  *  
  * @return float
  */
 public function apply($value, \XLite\Model\AEntity $model, $property, array $behaviors, $purpose)
 {
     $class = $this->getClass();
     if (\XLite\Core\Operator::isClassExists($class)) {
         $validationMethod = $this->getValidator();
         $calculateMethod = $this->getModificator();
         if (!$validationMethod || $class::$validationMethod($model, $property, $behaviors, $purpose)) {
             $value = $class::$calculateMethod($value, $model, $property, $behaviors, $purpose);
         }
     }
     return $value;
 }
Exemplo n.º 11
0
 /**
  * Get query builder
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function getQueryBuilder()
 {
     if (null === $this->queryBuilderClass) {
         $this->queryBuilderClass = str_replace('\\Repo\\', '\\QueryBuilder\\', get_called_class());
         if (!\XLite\Core\Operator::isClassExists($this->queryBuilderClass)) {
             $this->queryBuilderClass = '\\XLite\\Model\\QueryBuilder\\Base\\Common';
         }
     }
     $class = $this->queryBuilderClass;
     return new $class($this->_em);
 }
Exemplo n.º 12
0
 /**
  * Display widget as Standalone-specific
  *
  * @return boolean
  */
 protected function isDisplayStandalone()
 {
     return (!\XLite\Core\Operator::isClassExists('\\XLite\\Module\\CDev\\DrupalConnector\\Handler') || !\XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS()) && \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics && \XLite\Core\Config::getInstance()->CDev->GoogleAnalytics->ga_account;
 }
Exemplo n.º 13
0
 /**
  * Check if wholesale prices are enabled for the specified product.
  * Return true if product is not on sale (Sale module)
  *
  * @return boolean
  */
 public function isWholesalePricesEnabled()
 {
     return !\XLite\Core\Operator::isClassExists('\\XLite\\Module\\CDev\\Sale\\Main') || !$this->getParticipateSale();
 }
Exemplo n.º 14
0
 /**
  * Return widget
  *
  * @param string  $class  Widget class name
  * @param array   $params Widget params OPTIONAL
  * @param integer $delta  Drupal-specific param - so called "delta" OPTIONAL
  *
  * @return \XLite\Core\WidgetDataTransport
  */
 public function getWidget($class, array $params = array(), $delta = 0)
 {
     return new \XLite\Core\WidgetDataTransport(\XLite\Core\Operator::isClassExists($class) ? $this->getViewer()->getWidget($params, $class) : null);
 }
Exemplo n.º 15
0
 /**
  * Detect custom repository class name by entity class name
  *
  * @param string $class Entity class name
  *
  * @return string
  */
 protected function detectCustomRepositoryClassName($class)
 {
     $class = \Includes\Utils\Converter::getPureClassName($class);
     $class = \Includes\Utils\Converter::prepareClassName(str_replace('\\Model\\', '\\Model\\Repo\\', $class), false);
     if (!\XLite\Core\Operator::isClassExists($class)) {
         $class = '\\XLite\\Model\\Repo\\Base\\' . (preg_match('/\\wTranslation$/Ss', $class) ? 'Translation' : 'Common');
     } elseif (\Includes\Pattern\Factory::getClassHandler($class)->isAbstract()) {
         $class = null;
     }
     return $class;
 }
Exemplo n.º 16
0
 /**
  * Build clean URL
  *
  * @param string  $target         Target
  * @param array   $params         Params OPTIONAL
  *
  * @return string
  */
 public function buildURL($target = '', array $params = array())
 {
     $result = null;
     if (\XLite\Core\Operator::isClassExists($target)) {
         $target = static::getEntityType($target);
     }
     $method = $target ? __FUNCTION__ . \XLite\Core\Converter::convertToCamelCase($target) : null;
     $data = method_exists($this, $method) ? $this->{$method}($params) : array();
     if ($data) {
         list($urlParts, $params) = $data;
         if ($urlParts) {
             list($urlParts, $params) = $this->prepareBuildURL($target, $params, $urlParts);
         }
         if ($urlParts) {
             unset($params['target']);
             $result = implode('/', array_reverse($urlParts));
             if (!empty($params)) {
                 $result .= '?' . http_build_query($params);
             }
         }
     }
     return $result;
 }
Exemplo n.º 17
0
Arquivo: core.php Projeto: kingsj/core
/**
 * Check class full name
 *
 * @param string &$class Class
 *
 * @return void
 * @see    ____func_see____
 * @since  1.0.18
 */
function macro_check_class(&$class)
{
    $class = ltrim($class, '\\');
    return \XLite\Core\Operator::isClassExists($class);
}
Exemplo n.º 18
0
 /**
  * Get controller
  *
  * @return \XLite\Controller\AController
  */
 public static function getController()
 {
     if (!isset(static::$controller)) {
         $class = static::getControllerClass();
         if (!\XLite\Core\Operator::isClassExists($class)) {
             \XLite\Core\Request::getInstance()->target = static::TARGET_DEFAULT;
             \XLite\Logger::getInstance()->log('Controller class ' . $class . ' not found!', LOG_ERR);
             \XLite\Core\Request::getInstance()->target = static::TARGET_404;
             $class = static::getControllerClass();
         }
         static::$controller = new $class(\XLite\Core\Request::getInstance()->getData());
         static::$controller->init();
     }
     return static::$controller;
 }
Exemplo n.º 19
0
 /**
  * Get owner instance
  *
  * @return \XLite\Core\Task\ATask
  */
 public function getOwnerInstance()
 {
     if (!isset($this->ownerInstance)) {
         $class = $this->getOwner();
         if (\XLite\Core\Operator::isClassExists($class)) {
             $this->ownerInstance = new $class($this);
             if (!$this->ownerInstance instanceof \XLite\Core\Task\ATask) {
                 $this->ownerInstance = false;
             }
         }
     }
     return $this->ownerInstance;
 }
Exemplo n.º 20
0
 /**
  * Process callback-based patch
  *
  * @param \XLite\Model\TemplatePatch $patch Patch record
  *
  * @return void
  */
 protected function processCustomPatch(\XLite\Model\TemplatePatch $patch)
 {
     list($class, $method) = explode('::', $patch->custom_callback, 2);
     if (\XLite\Core\Operator::isClassExists($class)) {
         $this->source = $class::$method($this->source);
     }
 }
Exemplo n.º 21
0
//If you set width or height to 0 the script calcolate automatically the other size
$image_resizing = false;
$image_width = 600;
$image_height = 0;
//Thumbnail Size//
$thumbnail_width = 122;
$thumbnail_height = 91;
//******************
//Permissions config
//******************
$delete_file = true;
$create_folder = true;
$delete_folder = true;
$upload_files = true;
$class = '\\XLite\\Module\\CDev\\DemoAdmin\\Main';
if (\XLite\Core\Operator::isClassExists($class) && class_exists($class)) {
    $delete_file = false;
    $create_folder = false;
    $delete_folder = false;
    $upload_files = false;
}
//**********************
//Allowed extensions
//**********************
$ext_img = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff');
//Images
$ext_video = array('mov', 'mpeg', 'mp4', 'avi', 'mpg', 'wma');
//Videos
$ext_music = array('mp3', 'm4a', 'ac3', 'aiff', 'mid');
//Music
$ext_other = array('pdf');
Exemplo n.º 22
0
 /**
  * Display widget as Standalone-specific
  *
  * @return boolean
  */
 protected function isIncludeController()
 {
     return \XLite\Core\Operator::isClassExists('\\XLite\\Module\\CDev\\DrupalConnector\\Handler') && \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && function_exists('googleanalytics_theme');
 }
Exemplo n.º 23
0
 /**
  * getFieldBySchema
  * TODO - should use the Factory class
  *
  * @param string $name Field name
  * @param array  $data Field description
  *
  * @return \XLite\View\FormField\AFormField
  */
 protected function getFieldBySchema($name, array $data)
 {
     $result = null;
     $class = $data[self::SCHEMA_CLASS];
     if (\XLite\Core\Operator::isClassExists($class)) {
         $method = 'prepareFieldParams' . \XLite\Core\Converter::convertToCamelCase($name);
         if (method_exists($this, $method)) {
             // Call the corresponded method
             $data = $this->{$method}($data);
         }
         $result = new $class($this->getFieldSchemaArgs($name, $data));
     }
     return $result;
 }
Exemplo n.º 24
0
 /**
  * Prepare processors
  *
  * @return void
  */
 protected function prepareProcessors()
 {
     foreach ($this->processors as $i => $processor) {
         if (\XLite\Core\Operator::isClassExists($processor)) {
             $this->processors[$i] = new $processor($this);
         } else {
             unset($this->processors[$i]);
         }
     }
     $this->processors = array_values($this->processors);
 }
Exemplo n.º 25
0
 /**
  * Get processor
  *
  * @return \XLite\Model\Payment\Base\Processor
  */
 public function getProcessor()
 {
     $class = '\\XLite\\' . $this->getClass();
     return \XLite\Core\Operator::isClassExists($class) ? $class::getInstance() : null;
 }
Exemplo n.º 26
0
 /**
  * Get modifier object
  *
  * @return \XLite\Logic\Order\Modifier\AModifier
  */
 public function getModifier()
 {
     if (!isset($this->modifier) && \XLite\Core\Operator::isClassExists($this->getClass())) {
         $class = $this->getClass();
         $this->modifier = new $class($this);
     }
     return $this->modifier;
 }
Exemplo n.º 27
0
 /**
  * Display widget as Drupal-specific
  *
  * @return boolean
  */
 protected function isDisplayDrupal()
 {
     return \XLite\Core\Operator::isClassExists('\\XLite\\Module\\CDev\\DrupalConnector\\Handler') && \XLite\Module\CDev\DrupalConnector\Handler::getInstance()->checkCurrentCMS() && function_exists('googleanalytics_help') && $this->getAccount();
 }
Exemplo n.º 28
0
 /**
  * Check if current page is accessible
  *
  * @return boolean
  */
 public function checkAccess()
 {
     return parent::checkAccess() && $this->checkRequest() && \XLite\Core\Operator::isClassExists($this->getClass());
 }
Exemplo n.º 29
0
$searchFields = macro_get_named_argument('search');
$pagination = !is_null(macro_get_named_argument('pagination'));
$sortFields = macro_get_named_argument('sort');
$createInline = !is_null(macro_get_named_argument('createInline'));
$menu = macro_get_named_argument('menu');
// {{{ Check arguments
// --entity
if (!$entityClass) {
    macro_error('Entity class (--entity) argument is empty');
} elseif (\Includes\Utils\FileManager::isExists($entityClass)) {
    $entityClassPath = realpath($entityClass);
    $entityClass = str_replace(LC_DS, '\\', substr($entityClassPath, strlen(LC_DIR_CLASSES)));
} elseif (\Includes\Utils\FileManager::isExists(LC_DIR_CLASSES . $entityClass)) {
    $entityClassPath = realpath(LC_DIR_CLASSES . $entityClass);
    $entityClass = str_replace(LC_DS, '\\', $entityClass);
} elseif (\XLite\Core\Operator::isClassExists($entityClass)) {
    $entityClass = ltrim($entityClass, '\\');
    $entityClassPath = LC_DIR_CLASSES . str_replace('\\', LC_DS, $entityClass);
} else {
    macro_error('Entity class (--entity) \'' . $entityClass . '\' not found');
}
if (!is_subclass_of($entityClass, 'XLite\\Model\\AEntity')) {
    macro_error('Class \'' . $entityClass . '\' is not child of XLite\\Model\\AEntity');
}
$entityRepoClass = str_replace('\\Model\\', '\\Model\\Repo\\', $entityClass);
preg_match('/\\\\Model\\\\(.+)$/Ss', $entityClass, $match);
$entityRelativeClass = $match[1];
$entityShortClass = macro_get_class_short_name($entityClass);
$moduleAuthor = null;
$moduleName = null;
if (preg_match('/XLite\\\\Module\\\\([a-z0-9]+)\\\\([a-z0-9]+)\\\\Model/iSs', $entityClass, $match)) {