Beispiel #1
0
 /**
  * Get promotion message
  *
  * @return string
  */
 protected function getPromotionMessage()
 {
     $addons = $this->getAddons();
     $modules = array();
     $params = array('clearCnd' => 1);
     foreach ($addons as $addon => $title) {
         if (!\Includes\Utils\Operator::checkIfClassExists('\\XLite\\Module\\' . $addon . '\\Main')) {
             $match = explode('\\', $addon);
             $mainClassFile = LC_DIR_MODULES . str_replace('\\', '/', $addon) . '/Main.php';
             if (\Includes\Utils\FileManager::isExists($mainClassFile)) {
                 // Module is installed but not enabled
                 $limit = \XLite\View\Pager\Admin\Module\Manage::getInstance()->getItemsPerPage();
                 $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getInstalledPageId($match[0], $match[1], $limit);
                 $pageParam = 'page';
                 $target = 'addons_list_installed';
             } else {
                 // Module is not installed
                 list(, $limit) = $this->getWidget(array(), '\\XLite\\View\\Pager\\Admin\\Module\\Install')->getLimitCondition()->limit;
                 $pageId = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getMarketplacePageId($match[0], $match[1], $limit);
                 $pageParam = 'pageId';
                 $target = 'addons_list_marketplace';
             }
             if (0 < $pageId) {
                 $params[$pageParam] = $pageId;
             }
             $url = $this->buildURL($target, '', $params) . '#' . $match[1];
             $modules[] = '<a href="' . $url . '">' . $title . '</a>';
         }
     }
     return 0 < count($modules) ? static::t('Install additional modules to add more product sources', array('list' => implode(', ', $modules))) : '';
 }
Beispiel #2
0
 /**
  * doActionDelete
  *
  * @return void
  * @throws
  */
 protected function doActionDelete()
 {
     if (\Includes\Utils\FileManager::isExists($this->sqldumpFile) && !\Includes\Utils\FileManager::deleteFile($this->sqldumpFile)) {
         \XLite\Core\TopMessage::addError(static::t('Unable to delete file') . ' ' . $this->sqldumpFile);
     } else {
         \XLite\Core\TopMessage::addInfo('SQL file was deleted successfully');
     }
     $this->doRedirect();
 }
Beispiel #3
0
 /**
  * Constructor
  * Creates directory for locks if needed
  */
 public function __construct()
 {
     if (!\Includes\Utils\FileManager::isExists(rtrim(static::LOCK_DIR, LC_DS))) {
         \Includes\Utils\FileManager::mkdirRecursive(rtrim(static::LOCK_DIR, LC_DS));
     }
     if (!\Includes\Utils\FileManager::isReadable(static::LOCK_DIR) || !\Includes\Utils\FileManager::isWriteable(static::LOCK_DIR)) {
         \XLite\Logger::getInstance()->log('Cannot create lock for keys', LOG_DEBUG);
     }
     parent::__construct();
 }
Beispiel #4
0
 /**
  * Action 'import'
  *
  * @return void
  */
 protected function doActionImport()
 {
     $fileName = \XLite\Core\Session::getInstance()->language_import_file;
     if (\Includes\Utils\FileManager::isExists($fileName)) {
         $result = \XLite\Core\Database::getRepo('XLite\\Model\\Language')->parseImportFile($fileName, true);
         \XLite\Core\Session::getInstance()->language_import_result = $result;
     } else {
         \XLite\Core\Session::getInstance()->language_import_file = null;
         \XLite\Core\TopMessage::addError('File not found');
     }
     $this->setReturnURL($this->buildURL('languages'));
 }
Beispiel #5
0
 /**
  * Process item
  *
  * @param mixed $item Item
  *
  * @return boolean
  */
 protected function processItem($item)
 {
     $result = false;
     $path = tempnam(LC_DIR_TMP, 'migrate_file');
     file_put_contents($path, $item->getBody());
     if (\Includes\Utils\FileManager::isExists($path)) {
         $localPath = $item->isURL() ? null : $item->getStoragePath();
         $result = $item->loadFromLocalFile($path, $item->getFileName() ?: basename($item->getPath()));
         if ($result && $localPath && \Includes\Utils\FileManager::isExists($localPath)) {
             \Includes\Utils\FileManager::deleteFile($localPath);
         }
         \Includes\Utils\FileManager::deleteFile($path);
     }
     if (!$result) {
         if (!isset($this->record['s3_error_count'])) {
             $this->record['s3_error_count'] = 0;
         }
         $this->record['s3_error_count']++;
         \XLite\Logger::getInstance()->log('Couldn\'t move image ' . $item->getPath() . ' (local file system to Amazon S3)', LOG_ERR);
     }
     return true;
 }
Beispiel #6
0
 /**
  * Update custom images
  *
  * @return void
  */
 protected function updateCustomImages()
 {
     $dir = \XLite\Module\XC\ThemeTweaker\Main::getThemeDir() . 'images' . LC_DS;
     if ($_FILES && $_FILES['new_images'] && $_FILES['new_images']['name']) {
         if (!\Includes\Utils\FileManager::isExists($dir)) {
             \Includes\Utils\FileManager::mkdirRecursive($dir);
         }
         if (\Includes\Utils\FileManager::isDirWriteable($dir)) {
             foreach ($_FILES['new_images']['name'] as $i => $data) {
                 \Includes\Utils\FileManager::moveUploadedFileByMultiple('new_images', $i, $dir);
             }
         } else {
             \XLite\Core\TopMessage::addError('The directory {{dir}} does not exist or is not writable.', array('dir' => $dir));
         }
     }
     $delete = \XLite\Core\Request::getInstance()->delete;
     if ($delete && is_array($delete)) {
         foreach ($delete as $file => $del) {
             if ($del) {
                 \Includes\Utils\FileManager::deleteFile($dir . $file);
             }
         }
     }
 }
Beispiel #7
0
    /**
     * Get file pointer
     * This dedicates to greatest developer of all time, Maxim Shamaev. Because getFilename() is not enough for name combining.
     *
     * @return resource
     */
    protected function getFilePointer()
    {
        if (!isset($this->filePointer)) {
            $name = $this->getFilename();
            $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->generator->getOptions()->dir);
            if (is_writable($dir)) {
                if (!\Includes\Utils\FileManager::isExists($dir . LC_DS . '.htaccess')) {
                    // Try to create .htaccess file to protect directory
                    $out = <<<OUT
Options -Indexes

Deny from all

OUT;
                    \Includes\Utils\FileManager::write($dir . LC_DS . '.htaccess', $out);
                }
                $this->filePath = $dir . LC_DS . $name;
                $this->filePointer = @fopen($dir . LC_DS . $name, 'ab');
            } else {
                $this->generator->addError(static::t('Directory does not have permissions to write'), static::t('Directory X does not have permissions to write. Please set necessary permissions to directory X.', array('path' => $dir)));
            }
        }
        return $this->filePointer;
    }
Beispiel #8
0
 /**
  * Import action
  *
  * @return void
  */
 protected function doActionImport()
 {
     foreach (\XLite\Logic\Import\Importer::getImportOptionsList() as $key) {
         \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'Import', 'name' => $key, 'value' => isset(\XLite\Core\Request::getInstance()->options[$key]) ? \XLite\Core\Request::getInstance()->options[$key] : false));
     }
     \XLite\Core\Config::updateInstance();
     $dirTo = LC_DIR_VAR . \XLite\Logic\Import\Importer::getImportDir();
     if (!\Includes\Utils\FileManager::isExists($dirTo)) {
         \Includes\Utils\FileManager::mkdirRecursive($dirTo);
     }
     $filesToImport = array();
     if ($_FILES && isset($_FILES['files']) && $_FILES['files']['name'] && $_FILES['files']['name'][0] && \Includes\Utils\FileManager::isDirWriteable($dirTo)) {
         $list = glob($dirTo . LC_DS . '*');
         if ($list) {
             foreach ($list as $path) {
                 if (is_file($path)) {
                     \Includes\Utils\FileManager::deleteFile($path);
                 }
             }
         }
         $files = $_FILES['files'];
         foreach ($files['name'] as $key => $name) {
             $path = null;
             if ($name && UPLOAD_ERR_OK === $files['error'][$key]) {
                 $path = \Includes\Utils\FileManager::getUniquePath($dirTo, $name ?: $files['name'][$key]);
                 if (move_uploaded_file($files['tmp_name'][$key], $path)) {
                     if (\XLite\Core\Archive::getInstance()->isArchive($path) || 'csv' == substr(strrchr($path, '.'), 1)) {
                         $filesToImport[] = $path;
                     } else {
                         \XLite\Core\TopMessage::addError('The "{{file}}" is not CSV or archive', array('file' => $name));
                         \Includes\Utils\FileManager::deleteFile($path);
                     }
                 } else {
                     $path = null;
                 }
             }
             if (!$path) {
                 \XLite\Core\TopMessage::addError('The "{{file}}" file was not uploaded', array('file' => $name));
             }
         }
     }
     if ($filesToImport) {
         \XLite\Logic\Import\Importer::run(\XLite\Logic\Import\Importer::assembleImportOptions() + array('files' => $filesToImport));
     }
 }
Beispiel #9
0
 /**
  * Callback for a common operation for upgrade
  *
  * @param string  $path       File short path
  * @param boolean $isTestMode If in test mode
  *
  * @return void
  */
 protected function deleteFileCallback($path, $isTestMode)
 {
     if ($isTestMode) {
         if (!\Includes\Utils\FileManager::isDirWriteable($this->manageFile($path, 'getDir'))) {
             $this->addFileErrorMessage('File\'s directory is not writable', $path, false);
             $this->wrongPermissions[] = $this->manageFile($path, 'getDir');
         }
     } elseif ($this->manageFile($path, 'deleteFile')) {
         $this->addFileInfoMessage('File is deleted', $path, true);
         // Remove the parent directory if upgrade process removes all files in it
         $dir = dirname($path);
         if (\Includes\Utils\FileManager::isEmptyDir($dir)) {
             \Includes\Utils\FileManager::unlinkRecursive($dir);
             if (!\Includes\Utils\FileManager::isExists($dir)) {
                 $this->addFileInfoMessage('Directory is deleted', $dir, true);
             } else {
                 $this->addFileInfoMessage('Unable to delete directory', $dir, true);
             }
         }
     } else {
         $this->addFileErrorMessage('Unable to delete file', $path, true);
     }
 }
Beispiel #10
0
 /**
  * Load from local file
  *
  * @param string $path     Absolute path
  * @param string $basename File name OPTIONAL
  *
  * @return boolean
  */
 public function loadFromLocalFile($path, $basename = null)
 {
     $result = true;
     $basename = $basename ?: basename($path);
     if (\Includes\Utils\FileManager::isExists($path)) {
         foreach ($this->getAllowedFileSystemRoots() as $root) {
             if (\Includes\Utils\FileManager::getRelativePath($path, $root)) {
                 $local = true;
                 break;
             }
         }
         if (empty($local)) {
             $newPath = \Includes\Utils\FileManager::getUniquePath($this->getStoreFileSystemRoot(), $basename);
             if (\Includes\Utils\FileManager::copy($path, $newPath)) {
                 $path = $newPath;
                 $this->setStorageType(static::STORAGE_RELATIVE);
             } else {
                 \XLite\Logger::getInstance()->log('\'' . $path . '\' file could not be copied to a new location \'' . $newPath . '\'.', LOG_ERR);
                 $result = false;
             }
         } else {
             $this->setStorageType(static::STORAGE_ABSOLUTE);
         }
     } else {
         $result = false;
     }
     if ($result && $basename) {
         $this->setFileName($basename);
     }
     return $result && $this->savePath($path);
 }
Beispiel #11
0
 /**
  * Check if cache rebuild is needed
  *
  * @param string $step Current step name OPTIONAL
  *
  * @return boolean
  */
 public static function isRebuildNeeded($step = null)
 {
     if (!isset($step)) {
         $step = static::getCurrentStep();
     }
     return $step ? !\Includes\Utils\FileManager::isExists(static::getCacheStateIndicatorFileName($step)) : false;
 }
Beispiel #12
0
 /**
  * Get yaml files name to run common helper 'add_labels'
  *
  * @return string
  */
 protected function getCommonHelperAddLabelsFiles()
 {
     list($author, $name) = explode('\\', $this->getActualName());
     $result = array();
     $dir = \Includes\Utils\ModulesManager::getAbsoluteDir($author, $name);
     $file = $dir . 'install.yaml';
     if (\Includes\Utils\FileManager::isExists($file)) {
         $result[] = $file;
     }
     foreach ((array) glob($dir . 'install_*.yaml') as $translationFile) {
         if (\Includes\Utils\FileManager::isExists($translationFile)) {
             $result[] = $translationFile;
         }
     }
     return $result;
 }
Beispiel #13
0
 /**
  * Delete all files
  *
  * @return void
  */
 public function deleteAllFiles()
 {
     $dir = \Includes\Utils\FileManager::getRealPath(LC_DIR_VAR . $this->getOptions()->dir);
     if (!\Includes\Utils\FileManager::isExists($dir)) {
         \Includes\Utils\FileManager::mkdir($dir);
     }
     $list = glob($dir . LC_DS . '*');
     if ($list) {
         foreach ($list as $path) {
             if (is_file($path)) {
                 \Includes\Utils\FileManager::deleteFile($path);
             } else {
                 \Includes\Utils\FileManager::unlinkRecursive($path);
             }
         }
     }
 }
Beispiel #14
0
 /**
  * isFileExists
  *
  * @return boolean
  */
 public function isFileExists()
 {
     return \Includes\Utils\FileManager::isExists($this->sqldumpFile);
 }
Beispiel #15
0
 /**
  * Uninstall module
  *
  * @param \XLite\Model\Module $module    Module object
  * @param array               &$messages Messages list
  *
  * @return boolean
  */
 public function uninstallModule(\XLite\Model\Module $module, &$messages)
 {
     $result = false;
     // Get module pack
     $pack = new \XLite\Core\Pack\Module($module);
     $dirs = $pack->getDirs();
     $nonWritableDirs = array();
     // Check module directories permissions
     foreach ($dirs as $dir) {
         if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
             $nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
         }
     }
     $params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
     if (empty($nonWritableDirs)) {
         $yamlData = array();
         $yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
         foreach ($yamlFiles as $yamlFile) {
             $yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
         }
         if (!$module->checkModuleMainClass()) {
             $classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
             if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
                 require_once $classFile;
             }
         }
         // Call uninstall event method
         $r = $module->callModuleMethod('callUninstallEvent', 111);
         if (111 == $r) {
             \XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
         }
         // Remove from FS
         foreach ($dirs as $dir) {
             \Includes\Utils\FileManager::unlinkRecursive($dir);
         }
         \Includes\Utils\ModulesManager::disableModule($module->getActualName());
         \Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
         // Remove module from DB
         try {
             // Refresh module entity as it was changed by disableModule() method above
             $module = $this->find($module->getModuleID());
             $this->delete($module);
         } catch (\Exception $e) {
             $messages[] = $e->getMessage();
         }
         if ($module->getModuleID()) {
             $messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
         } else {
             if (!empty($yamlData)) {
                 foreach ($yamlData as $yaml) {
                     \XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
                 }
             }
             $messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
             $result = true;
         }
     } else {
         $messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
     }
     return $result;
 }
Beispiel #16
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;
 }
Beispiel #17
0
 /**
  * Get structures to save when module is disabled
  *
  * @param string $author Module author
  * @param string $name   Module name
  *
  * @return array
  */
 public static function getModuleProtectedStructures($author, $name)
 {
     $tables = array();
     $columns = array();
     $path = static::getAbsoluteDir($author, $name) . 'Model';
     if (\Includes\Utils\FileManager::isExists($path)) {
         $filter = new \Includes\Utils\FileFilter($path, '/.*\\.php$/Si');
         foreach ($filter->getIterator() as $path => $data) {
             // DO NOT call "getInterfaces()" after the "getFullClassName()"
             // DO NOT use reflection to get interfaces
             $interfaces = \Includes\Decorator\Utils\Tokenizer::getInterfaces($path);
             $class = \Includes\Decorator\Utils\Tokenizer::getFullClassName($path);
             // Do 'autoload' checking first since the class_exists tries to use autoloader
             // but fails into "cannot include file" warning when model class is not set to use (LC_Dependencies issue)
             if (\Includes\Autoloader::checkAutoload($class) && class_exists($class)) {
                 // $reflectionClass = new \ReflectionClass($class);
                 if ($class && is_subclass_of($class, '\\XLite\\Model\\AEntity')) {
                     $class = ltrim($class, '\\');
                     $len = strlen(\Includes\Utils\Database::getTablesPrefix());
                     // DO NOT remove leading backslash in interface name
                     if (in_array('\\XLite\\Base\\IDecorator', $interfaces)) {
                         $parent = \Includes\Decorator\Utils\Tokenizer::getParentClassName($path);
                         $parent = ltrim($parent, '\\');
                         $metadata = \XLite\Core\Database::getEM()->getClassMetadata($parent);
                         $table = substr($metadata->getTableName(), $len);
                         $tool = new \Doctrine\ORM\Tools\SchemaTool(\XLite\Core\Database::getEM());
                         $schema = $tool->getCreateSchemaSql(array($metadata));
                         foreach ((array) $metadata->reflFields as $field => $reflection) {
                             $pattern = '/(?:, |\\()(' . $field . ' .+)(?:, [A-Za-z]|\\) ENGINE)/USsi';
                             if ($reflection->class === $class && !empty($metadata->fieldMappings[$field]) && preg_match($pattern, $schema[0], $matches)) {
                                 $columns[$table][$field] = $matches[1];
                             }
                         }
                         foreach ($metadata->associationMappings as $mapping) {
                             if ($metadata->reflFields[$mapping['fieldName']]->class === $class) {
                                 if (isset($mapping['joinTable']) && $mapping['joinTable']) {
                                     $tables[] = substr($mapping['joinTable']['name'], $len);
                                 } elseif (isset($mapping['joinColumns']) && $mapping['joinColumns']) {
                                     foreach ($mapping['joinColumns'] as $col) {
                                         $pattern = '/(?:, |\\()(' . $col['name'] . ' .+)(?:, [A-Za-z]|\\) ENGINE)/USsi';
                                         if (preg_match($pattern, $schema[0], $matches)) {
                                             $columns[$table][$col['name']] = $matches[1];
                                         }
                                     }
                                 }
                             }
                         }
                     } elseif (\XLite\Core\Database::getRepo($class)->canDisableTable()) {
                         $tables[] = substr(\XLite\Core\Database::getEM()->getClassMetadata($class)->getTableName(), $len);
                         $metadata = \XLite\Core\Database::getEM()->getClassMetadata($class);
                         foreach ($metadata->associationMappings as $mapping) {
                             if (isset($mapping['joinTable']) && $mapping['joinTable']) {
                                 $tables[] = substr($mapping['joinTable']['name'], $len);
                             }
                         }
                     }
                 }
             }
         }
     }
     return array('tables' => $tables, 'columns' => $columns);
 }
Beispiel #18
0
 /**
  * Get file iterator
  *
  * @return \RecursiveIteratorIterator
  */
 protected function getFileIterator()
 {
     $dir = LC_DIR_VAR . $this->getOptions()->dir . LC_DS;
     if (!\Includes\Utils\FileManager::isExists($dir)) {
         \Includes\Utils\FileManager::mkdirRecursive($dir);
     }
     $dirIterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
     return new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::SELF_FIRST);
 }
Beispiel #19
0
 /**
  * Check if pack is already downloaded
  *
  * @return boolean
  */
 public function isDownloaded()
 {
     $path = $this->getRepositoryPath();
     return !empty($path) && \Includes\Utils\FileManager::isExists($path);
 }
Beispiel #20
0
 /**
  * Get yaml file name to run common helper 'add_labels'
  *
  * @return string
  */
 protected function getCommonHelperAddLabelsFiles()
 {
     $result = array();
     $files = array(LC_DIR_ROOT . 'sql' . LC_DS . 'xlite_data.yaml', LC_DIR_ROOT . 'sql' . LC_DS . 'xlite_data_lng.yaml');
     foreach ($files as $file) {
         if (\Includes\Utils\FileManager::isExists($file)) {
             $result[] = $file;
         }
     }
     return $result;
 }
Beispiel #21
0
 /**
  * Copy 
  * 
  * @param string $from        Full path
  * @param string $to          Short path
  * @param array  $httpHeaders HTTP headers OPTIONAL
  *  
  * @return boolean
  */
 public function copy($from, $to, array $httpHeaders = array())
 {
     $result = false;
     if (\Includes\Utils\FileManager::isExists($from)) {
         try {
             $result = $this->client->putObjectFile($from, \XLite\Core\Config::getInstance()->CDev->AmazonS3Images->bucket, $to, \S3::ACL_PUBLIC_READ, array(), $httpHeaders);
         } catch (\S3Exception $e) {
             $result = false;
             \XLite\Logger::getInstance()->registerException($e);
         }
     }
     return $result;
 }
Beispiel #22
0
 /**
  * Check if template is up-to-date
  *
  * @param string $original Original template
  * @param string $compiled Compiled one
  *
  * @return boolean
  */
 protected function isTemplateValid($original, $compiled)
 {
     return \Includes\Utils\FileManager::isExists($compiled) && (!$this->checkTemplateStatus || filemtime($compiled) == filemtime($original));
 }
Beispiel #23
0
 /**
  * Initialize write 
  * 
  * @return void
  */
 protected function initializeWrite()
 {
     if (!\Includes\Utils\FileManager::isExists(LC_DIR_DATA)) {
         \Includes\Utils\FileManager::mkdir(LC_DIR_DATA);
         if (!\Includes\Utils\FileManager::isExists(LC_DIR_DATA)) {
             \XLite\Logger::getInstance()->log('The directory ' . LC_DIR_DATA . ' can not be created.' . ' Check the permissions to create directories.', LOG_ERR);
         }
     }
     $this->fileIndex = null;
     $this->emptyFile = true;
 }
Beispiel #24
0
 *
 * @see   ____class_see____
 * @since 1.0.0
 */
class {$itemsListPanelClassShort} extends \\XLite\\View\\StickyPanel\\ItemsListForm
{
}
CODE;
    macro_file_put_contents($itemsListPanelPath, $string);
    echo 'done' . PHP_EOL;
}
// }}}
// {{{ Repository class
$entityRepoPath = macro_convert_class_name_to_path($entityRepoClass);
echo 'Build entity repository class ' . $entityRepoPath . ' ... ';
if (!\Includes\Utils\FileManager::isExists($entityRepoPath)) {
    // Create repository
    $entityRepoClassShort = macro_get_class_short_name($entityRepoClass);
    $entityRepoParentClass = is_subclass_of($entityClass, 'XLite\\Model\\Base\\I18n') ? '\\XLite\\Model\\Repo\\Base\\I18n' : '\\XLite\\Model\\Repo\\ARepo';
    $string = macro_get_class_repo_header($entityRepoPath) . <<<CODE
/**
 * {$targetHumanReadableName} repository
 *
 * @see   ____class_see____
 * @since 1.0.0
 */
class {$entityRepoClassShort} extends {$entityRepoParentClass}
{
}
CODE;
    macro_file_put_contents($entityRepoPath, $string);
Beispiel #25
0
 /**
  * Load from local file
  *
  * @param string $path     Absolute path
  * @param string $basename File name OPTIONAL
  *
  * @return boolean
  */
 public function loadFromLocalFile($path, $basename = null)
 {
     if (!$this->s3Forbid && $this->getS3()) {
         $result = false;
         if (\Includes\Utils\FileManager::isExists($path)) {
             $data = @getimagesize($path);
             if (is_array($data)) {
                 $basename = $basename ?: basename($path);
                 $s3Path = $this->generateS3Path($basename);
                 $s3Path = $this->getS3()->generateUniquePath($s3Path);
                 $headers = array('Content-Type' => $data['mime'], 'Content-Disposition' => 'inline; filename="' . $basename . '"');
                 if ($this->getS3()->copy($path, $s3Path, $headers)) {
                     $this->setStorageType(static::STORAGE_S3);
                     $this->setMime($data['mime']);
                     if ($this->savePath($s3Path)) {
                         $result = true;
                     }
                 } else {
                     \XLite\Logger::getInstance()->log('[Amazon S3] The file \'' . $path . '\' was not copyed to \'' . $s3Path . '\'', LOG_ERR);
                 }
             }
         }
     } else {
         $result = parent::loadFromLocalFile($path, $basename);
     }
     return $result;
 }