Adds the content for the site map index file

@param \Aimeos\MW\Container\Iface $container File container object
@param array $files List of generated site map file names
162998
protected function createSitemapIndex( \Aimeos\MW\Container\Iface $container, array $files )
	{
		/** controller/jobs/catalog/export/sitemap/standard/template-index
		 * Relative path to the XML site map index template of the catalog site map job controller.
		 *
		 * The template file contains the XML code and processing instructions
		 * to generate the site map index files. The configuration string is the path
		 * to the template file relative to the templates directory (usually in
		 * controller/jobs/templates).
		 *
		 * You can overwrite the template file configuration in extensions and
		 * provide alternative templates. These alternative templates should be
		 * named like the default one but with the string "standard" replaced by
		 * an unique name. You may use the name of your project for this. If
		 * you've implemented an alternative client class as well, "standard"
		 * should be replaced by the name of the new class.
		 *
		 * @param string Relative path to the template creating XML code for the site map index
		 * @since 2019.02
		 * @category Developer
		 * @see controller/jobs/catalog/export/sitemap/standard/template-header
		 * @see controller/jobs/catalog/export/sitemap/standard/template-items
		 * @see controller/jobs/catalog/export/sitemap/standard/template-footer
		 */
		$tplconf = 'controller/jobs/catalog/export/sitemap/standard/template-index';
		$default = 'catalog/export/sitemap-index-standard';

		$context = $this->getContext();
		$view = $context->getView();

		$view->siteFiles = $files;

		$content = $container->create( 'aimeos-catalog-sitemap-index.xml' );
		$content->add( $view->render( $context->getConfig()->get( $tplconf, $default ) ) );
		$container->add( $content );
	}
1042735
private static function buildMap(array $files, array & $destination) : void
    {
        foreach ($files as $structure) {
            foreach ($structure as $key => $value) {
                $subFiles = [];
                foreach ($files as $uploadKey => $data) {
                    $subFiles[$uploadKey] = $data[$key];
                }

                if (is_array($value)) {
                    $destination[$key] = [];
                    self::buildMap($subFiles, $destination[$key]);
                } else {
                    $destination[$key] = UploadedFile::create($subFiles);
                }
            }

            // Only one of the entries was needed to get the structure.
            break;
        }
    }
226039
protected static function addAccess( \Aimeos\MW\View\Iface $view )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_access'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_view_access'] ) )
		) {
			return $fcn( $view );
		}

		if( TYPO3_MODE === 'BE' )
		{
			if( $GLOBALS['BE_USER']->isAdmin() === false )
			{
				$groups = array();
				foreach( (array) $GLOBALS['BE_USER']->userGroups as $entry ) {
					$groups[] = $entry['title'];
				}
				$helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $groups );
			}
			else
			{
				$helper = new \Aimeos\MW\View\Helper\Access\All( $view );
			}
		}
		else
		{
			if( $GLOBALS['TSFE']->loginUser == 1 ) {
				$helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $GLOBALS['TSFE']->fe_user->groupData['title'] );
			} else {
				$helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, array() );
			}
		}

		$view->addHelper( 'access', $helper );

		return $view;
	}
587639
protected function addProcess( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$config = $context->getConfig();
		$max = $config->get( 'pcntl_max', 4 );
		$prio = $config->get( 'pcntl_priority', 19 );

		$process = new \Aimeos\MW\Process\Pcntl( $max, $prio );
		$process = new \Aimeos\MW\Process\Decorator\Check( $process );

		return $context->setProcess( $process );
	}
1184707
private function writeToFiles(
        array $content,
        string $baseDir,
        ConfigCache $dump,
        SymfonyBuilder $container
    ): void {
        $rootCode = array_pop($content);
        assert(is_string($rootCode));

        $filesystem = new Filesystem();

        foreach ($content as $file => $code) {
            $filesystem->dumpFile($baseDir . $file, $code);
        }

        $dump->write($rootCode, $container->getResources());
    }
490250
public function setView( \Aimeos\MW\View\Iface $view )
	{
		parent::setView( $view );

		// set first to be able to show errors occuring afterwards
		$view->pageParams = $this->getClientParams();
		$context = $this->getContext();

		$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
		$langManager = \Aimeos\MShop::create( $context, 'locale/language' );
		$customerManager = \Aimeos\MShop::create( $context, 'customer' );

		$siteItem = $siteManager->findItem( $view->param( 'site', 'default' ) );

		try {
			$siteid = $customerManager->getItem( $context->getUserId() )->getSiteId() ?: $siteItem->getSiteId();
		} catch( \Exception $e ) {
			$siteid = $siteItem->getSiteId();
		}

		if( $view->access( ['admin', 'super'] ) ) {
			$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE;
		} else {
			$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE;
		}

		$sitePath = $siteManager->getPath( $siteid );

		$view->pageI18nList = $this->getAimeos()->getI18nList( 'admin' );
		$view->pageLangItems = $langManager->searchItems( $langManager->createSearch( true ) );
		$view->pageSiteTree = $siteManager->getTree( $siteid, [], $level );
		$view->pageSitePath = $sitePath;
		$view->pageSiteItem = $siteItem;

		if( $view->access( ['super'] ) )
		{
			$search = $siteManager->createSearch()->setSlice( 0, 1000 );
			$search->setSortations( [$search->sort( '+', 'locale.site.label')] );
			$search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) );

			$view->pageSiteList = $siteManager->searchItems( $search );

			if( ( $rootItem = reset( $sitePath ) ) !== false ) {
				$view->pageSiteTree = $siteManager->getTree( $rootItem->getId(), [], $level );
			}
		}
		else
		{
			$view->pageSiteList = [$view->pageSiteTree];
		}

		$this->getClient()->setView( $view );
		return $this;
	}
660081
protected function addMailer( \Aimeos\MShop\Context\Item\Iface $context )
	{
		$mail = new \Aimeos\MW\Mail\Swift( function() { return app( 'mailer' )->getSwiftMailer(); } );

		return $context->setMail( $mail );
	}
415442
protected static function addHasher( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_hasher'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_hasher'] ) )
		) {
			return $fcn( $context );
		}

		if( class_exists( '\TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory' ) ) // TYPO3 9+
		{
			$factory = GeneralUtility::makeInstance( 'TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory' );
			$context->setHasherTypo3( $factory->getDefaultHashInstance( 'FE' ) );
		}
		elseif( class_exists( '\TYPO3\CMS\Saltedpasswords\Salt\SaltFactory' ) ) // TYPO3 7/8
		{
			$context->setHasherTypo3( \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance() );
		}

		return $context;
	}
322861
public function run($files, $container_type = 'default', $container_id = null)
    {
        $file_add = new FileAdd($this->dic);
        $file_remove = new FileRemove($this->dic);

        $files_ids = [];
        $files_errors = [];

        if (!empty($files)) {
            foreach ($files as $file) {
                switch ($file['action']) {
                    case 'add':
                        $result = $file_add->run(
                            $file['file_id'],
                            $file['orig_name'],
                            $container_type,
                            $container_id
                        );

                        if (isset($result['errors'])) {
                            $files_errors[] = array_merge($file, $result);
                        } else {
                            $files_ids[] = $result['data']['id'];
                        }
                        break;

                    case 'remove':
                        $result = $file_remove->run($file['file_id']);

                        if (isset($result['errors'])) {
                            $files_ids[] = $file['file_id'];
                            $files_errors[] = array_merge($file, $result);
                        }
                        break;

                    default:
                        $files_ids[] = $file['file_id'];
                        break;
                }
            }
        }

        return [
            'ids'    => $files_ids,
            'errors' => $files_errors,
        ];
    }
1090458
protected function addItem( \Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Product\Item\Iface $item, $langid )
	{
		$listTypes = [];
		foreach( $item->getListItems( 'text' ) as $listItem ) {
			$listTypes[$listItem->getRefId()] = $listItem->getType();
		}

		foreach( $this->getTextTypes( 'product' ) as $textTypeItem )
		{
			$textItems = $item->getRefItems( 'text', $textTypeItem->getCode() );

			if( !empty( $textItems ) )
			{
				foreach( $textItems as $textItem )
				{
					$listType = ( isset( $listTypes[$textItem->getId()] ) ? $listTypes[$textItem->getId()] : '' );
					$items = array( $langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', '' );

					// use language of the text item because it may be null
					if( ( $textItem->getLanguageId() == $langid || is_null( $textItem->getLanguageId() ) )
						&& $textItem->getTypeId() == $textTypeItem->getId() )
					{
						$items[0] = $textItem->getLanguageId();
						$items[5] = $textItem->getId();
						$items[6] = $textItem->getContent();
					}

					$contentItem->add( $items );
				}
			}
			else
			{
				$items = array( $langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', '' );
				$contentItem->add( $items );
			}
		}
	}
866334
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], &$expire = null )
	{
		$context = $this->getContext();
		$config = $context->getConfig();

		/** client/html/catalog/count/tree/aggregate
		 * Enables or disables generating product counts for the category catalog filter
		 *
		 * This configuration option allows shop owners to enable or disable product counts
		 * for the tree section of the catalog filter HTML client.
		 *
		 * @param boolean Disabled if "0", enabled if "1"
		 * @since 2014.03
		 * @see client/html/catalog/count/limit
		 */
		if( $config->get( 'client/html/catalog/count/tree/aggregate', true ) == true )
		{
			/** client/html/catalog/count/limit
			 * @see client/html/catalog/count/tree/aggregate
			 */
			$limit = $config->get( 'client/html/catalog/count/limit', 10000 );
			$startid = $view->config( 'client/html/catalog/filter/tree/startid' );
			$level = $view->config( 'client/html/catalog/lists/levels', \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );

			$cntl = \Aimeos\Controller\Frontend::create( $context, 'catalog' )->root( $startid );
			$root = $cntl->getTree( \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE );

			if( ( $catId = $view->param( 'f_catid', $root->getId() ) ) != null && $catId != $root->getId() ) {
				$cntl->visible( array_keys( $cntl->getPath( $catId ) ) );
			} elseif( $level !== \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ) {
				$cntl->visible( [$root->getId()] );
			}

			$tree = $cntl->getTree();
			$view->treeCountList = \Aimeos\Controller\Frontend::create( $context, 'product' )
				->category( array_keys( $tree->toList() ) )->slice( 0, $limit )->sort()
				->aggregate( 'index.catalog.id' );

			if( $level === \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE ) {
				$view->treeCountList = $this->counts( $this->traverse( $tree, $view->treeCountList ) );
			}
		}

		return parent::addData( $view, $tags, $expire );
	}
433340
protected function addGroup( \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group )
	{
		$msg = 'Add "%1$s" group to user "%2$s" for site "%3$s"';
		$this->info( sprintf( $msg, $group, $user->getCode(), $this->argument( 'site' ) ) );

		$groupItem = $this->getGroupItem( $context, $group );
		$this->addListItem( $context, $user->getId(), $groupItem->getId() );
	}
866172
protected static function addCache( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_cache'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_cache'] ) )
		) {
			return $fcn( $context );
		}

		$cacheName = \Aimeos\Aimeos\Base::getExtConfig( 'cacheName', 'Typo3' );
		if ( isset( $GLOBALS['TSFE'] ) && $GLOBALS['TSFE']->headerNoCache() ) {
    			$cacheName = 'None';
		}

		switch( $cacheName )
		{
			case 'None':
				$context->getConfig()->set( 'client/html/basket/cache/enable', false );
				$cache = \Aimeos\MW\Cache\Factory::create( 'None', array(), null );
				break;

			case 'Typo3':
				$manager = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Cache\CacheManager::class );
				$cache = new \Aimeos\MAdmin\Cache\Proxy\Typo3( $context, $manager->getCache( 'aimeos' ) );
				break;

			default:
				$cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context );
		}

		return $context->setCache( $cache );
	}
1374913
protected function addViewData( \Aimeos\MW\View\Iface $view )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'media/property/type' );

		$search = $manager->createSearch( true )->setSlice( 0, 10000 );
		$search->setConditions( $search->compare( '==', 'media.property.type.domain', 'service' ) );
		$search->setSortations( [$search->sort( '+', 'media.property.type.position')] );

		$view->propertyTypes = $this->map( $manager->searchItems( $search ) );

		return $view;
	}
1245506
protected void addFiles(List<CmsFileInfo> fileInfos) {

        if (fileInfos != null) {
            for (CmsFileInfo file : fileInfos) {

                // store all files
                m_allFiles.put(file.getFileName(), file);

                // add those files to the list of files to upload that potential candidates
                if (!isTooLarge(file) && (file.getFileSize() != 0)) {
                    m_filesToUpload.put(file.getFileName(), file);
                }

                // remove those files from the list to upload that were previously unchecked by the user
                if ((m_listItems.get(file.getFileName()) != null)
                    && (m_listItems.get(file.getFileName()).getCheckBox() != null)
                    && !m_listItems.get(file.getFileName()).getCheckBox().isChecked()) {
                    m_filesToUpload.remove(file.getFileName());
                }
            }

            // now rebuild the list: handle all files
            m_fileList.clearList();
            List<String> sortedFileNames = new ArrayList<String>(m_allFiles.keySet());
            Collections.sort(sortedFileNames, String.CASE_INSENSITIVE_ORDER);
            for (String filename : sortedFileNames) {
                CmsFileInfo file = m_allFiles.get(filename);
                addFileToList(file, false, false, isTooLarge(file));
            }
            doResize();
        }
        loadAndShow();
    }
753589
protected function addCacheDirectory(ContainerInterface $container, SerializerBuilder $builder): void
    {
        $config = $container->get('config');
        $libraryConfig = $config[ConfigKey::PROJECT][ConfigKey::API_CLIENT] ?? [];
        $cacheDir = (string) ($libraryConfig[ConfigKey::CACHE_DIR] ?? '');

        if ($cacheDir !== '') {
            $builder->setCacheDir($cacheDir);
        }
    }
287856
final protected function addFilesToMultipartBuilder(Builder $builder, array $files = []): void
    {
        foreach ($files as $key => $file) {
            if (! \is_null($file)) {
                $builder->addResource($key, fopen($file, 'r'));
            }
        }
    }