Exports content files in container.

@param stdClass $params Object containing the properties, e.g. the list of catalog IDs
16105
public function exportFile( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );
		$context = $this->_getContext();

		$items = (array) $params->items;
		$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : array();

		$config = $context->getConfig();

		/** controller/extjs/catalog/export/text/default/exportdir
		 * Directory where exported files of catalog texts are stored
		 *
		 * All exported files are stored in this file system directory directory.
		 *
		 * The export directory must be relative to the "basedir" configuration
		 * option. If
		 *
		 *  /var/www/test
		 *
		 * is the configured base directory and the export directory should be
		 * located in
		 *
		 *  /var/www/test/htdocs/files/exports
		 *
		 * then the configuration for the export directory must be
		 *
		 *  htdocs/files/exports
		 *
		 * Avoid leading and trailing slashes for the export directory string!
		 *
		 * @param string Relative path in the file system
		 * @since 2014.03
		 * @category Developer
		 * @see controller/extjs/media/default/basedir
		 */
		$dir = $config->get( 'controller/extjs/catalog/export/text/default/exportdir', 'uploads' );

		/** controller/extjs/catalog/export/text/default/dirperms
		 * Directory permissions used when creating the directory if it doesn't exist
		 *
		 * The representation of the permissions is in octal notation (using 0-7)
		 * with a leading zero. The first number after the leading zero are the
		 * permissions for the web server creating the directory, the second is
		 * for the primary group of the web server and the last number represents
		 * the permissions for everyone else.
		 *
		 * You should use 0700 for the permissions as the web server needs
		 * to write into the new directory but the files shouldn't be publicall
		 * available. The group permissions are only important if you plan to
		 * retrieve the files directly via FTP or by other means because then
		 * you need to be able to read and manage those files. In this case use
		 * 0770 as permissions.
		 *
		 * A more detailed description of the meaning of the Unix file permission
		 * bits can be found in the Wikipedia article about
		 * {@link https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation file system permissions}
		 *
		 * @param integer Octal Unix permission representation
		 * @since 2014.03
		 * @category Developer
		 * @category User
		 */
		$perms = $config->get( 'controller/extjs/catalog/export/text/default/dirperms', 0700 );

		/** controller/extjs/catalog/export/text/default/downloaddir
		 * Directory where the exported files can be found through the web
		 *
		 * The exported files are stored in this directory directory.
		 *
		 * The download directory must be relative to the document root of your
		 * virtual host. If the document root is
		 *
		 *  /var/www/test/htdocs
		 *
		 * and the exported files will be in
		 *
		 *  /var/www/test/htdocs/files/exports
		 *
		 * then the configuration for the download directory must be
		 *
		 *  files/exports
		 *
		 * Avoid leading and trailing slashes for the export directory string!
		 *
		 * @param string Relative path in the URL
		 * @since 2014.03
		 * @category Developer
		 */
		$downloaddir = $config->get( 'controller/extjs/catalog/export/text/default/downloaddir', 'uploads' );

		$foldername = 'catalog-text-export_' . date('Y-m-d_H:i:s') . '_' . md5( time() . getmypid() );
		$tmpfolder = $dir . DIRECTORY_SEPARATOR . $foldername;

		if( is_dir( $dir ) === false && mkdir( $dir, $perms, true ) === false ) {
			throw new Controller_ExtJS_Exception( sprintf( 'Couldn\'t create directory "%1$s" with permissions "%2$o"', $dir, $perms ) );
		}

		$context->getLogger()->log( sprintf( 'Create export directory for catalog IDs: %1$s', implode( ',', $items ) ), MW_Logger_Abstract::DEBUG );

		$filename = $this->_exportData( $items, $lang, $tmpfolder );
		$downloadFile = $downloaddir . DIRECTORY_SEPARATOR . basename( $filename );

		return array(
			'file' => '<a href="'.$downloadFile.'">'.$context->getI18n()->dt( 'controller/extjs', 'Download' ).'</a>',
		);
	}
689383
public function uploadFile( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site' ) );
		$this->setLocale( $params->site );

		$clientFilename = '';
		$context = $this->getContext();

		$request = $context->getView()->request();
		$dest = $this->storeFile( $request, $clientFilename );

		$result = (object) array(
			'site' => $params->site,
			'items' => array(
				(object) array(
					'job.label' => 'Product text import: ' . $clientFilename,
					'job.method' => 'Product_Import_Text.importFile',
					'job.parameter' => array(
						'site' => $params->site,
						'items' => $dest,
					),
					'job.status' => 1,
				),
			),
		);

		$jobController = \Aimeos\Controller\ExtJS\Factory::createController( $context, 'admin/job' );
		$jobController->saveItems( $result );

		return array(
			'items' => $dest,
			'success' => true,
		);
	}
259091
public function action_class( $params ) 
	{	
		$options = \CCDataObject::assign( $params );
		
		$name = $options->get( 0, null );
		
		// get name if we dont have one
		while( !$name ) 
		{
			$name = $this->read( 'Please enter the class name: ' );
		}
		
		// try to resolve the path
		if ( !$path = \CCPath::classes( str_replace( '_', '/', $name ), EXT ) )
		{
			$this->error( 'Could not resolve the path. Check if the namespace is registered.' ); return;
		}
		
		// create the class
		$class = \CCShipyard::create( 'class', $name, $options->get( 'extends', null ), explode( ',', $options->get( 'implements', null ) ) );
		
		// add static init
		if ( !$options->get( 'no-init', false ) )
		{
			$class->add( 'function', '_init', 'public static', '//', "static class initialisation\n@return void" );
		}
				
		// check for overwrite
		if ( file_exists( $path ) )
		{
			if ( !$this->confirm( "The class already exists. Do you wish to overwrite it?", true ) ) 
			{
				return;
			}
		}
		
		// write file
		\CCFile::write( $path, $class->output() );
	}
1107116
public function run(&$params)
    {
        $common_dir = dirname(dirname(__DIR__)) . DS . 'common';
        if (is_dir($common_dir)) {
            foreach (scandir($common_dir) as $file) {
                if ($file == '.' || $file == '..') {
                    continue;
                } else {
                    is_file($common_dir . DS . $file) && require_once ($common_dir . DS . $file);
                }
            }
        }
    }
579154
public function importFile( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site', 'items' ) );
		$this->_setLocale( $params->site );

		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $path )
		{
			/** controller/extjs/catalog/import/text/default/container/type
			 * Container file type storing all language files of the texts to import
			 *
			 * When exporting texts, one file or content object is created per
			 * language. All those files or content objects are put into one container
			 * file so editors don't have to download one file for each language.
			 *
			 * The container file types that are supported by default are:
			 * * Zip
			 *
			 * Extensions implement other container types like spread sheets, XMLs or
			 * more advanced ways of handling the exported data.
			 *
			 * @param string Container file type
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/catalog/import/text/default/container/format
			 */

			/** controller/extjs/catalog/import/text/default/container/format
			 * Format of the language files for the texts to import
			 *
			 * The exported texts are stored in one file or content object per
			 * language. The format of that file or content object can be configured
			 * with this option but most formats are bound to a specific container
			 * type.
			 *
			 * The formats that are supported by default are:
			 * * CSV (requires container type "Zip")
			 *
			 * Extensions implement other container types like spread sheets, XMLs or
			 * more advanced ways of handling the exported data.
			 *
			 * @param string Content file type
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/catalog/import/text/default/container/type
			 * @see controller/extjs/catalog/import/text/default/container/options
			 */

			/** controller/extjs/catalog/import/text/default/container/options
			 * Options changing the expected format for the texts to import
			 *
			 * Each content format may support some configuration options to change
			 * the output for that content type.
			 *
			 * The options for the CSV content format are:
			 * * csv-separator, default ','
			 * * csv-enclosure, default '"'
			 * * csv-escape, default '"'
			 * * csv-lineend, default '\n'
			 *
			 * For format options provided by other container types implemented by
			 * extensions, please have a look into the extension documentation.
			 *
			 * @param array Associative list of options with the name as key and its value
			 * @since 2014.03
			 * @category Developer
			 * @category User
			 * @see controller/extjs/catalog/import/text/default/container/format
			 */
			$container = $this->_createContainer( $path, 'controller/extjs/catalog/import/text/default/container' );

			$textTypeMap = array();
			foreach( $this->_getTextTypes( 'catalog' ) as $item ) {
				$textTypeMap[ $item->getCode() ] = $item->getId();
			}

			foreach( $container as $content ) {
				$this->_importTextsFromContent( $content, $textTypeMap, 'catalog' );
			}

			unlink( $path );
		}

		return array(
			'success' => true,
		);
	}
1336277
public function flush( stdClass $params )
	{
		$this->_checkParams( $params, array( 'site' ) );
		$this->_setLocale( $params->site );

		$this->_getContext()->getCache()->flush();

		return array(
			'success' => true,
		);
	}
1002431
protected function export()
    {
        $filesystem = new Filesystem();
        $handle = fopen($this->config['path'] . $this->prefix, "w");

        $checkPermissions = true;
        if (PHP_SAPI == 'cli') {
            $checkPermissions = false;
        }

        if (!$this->export->Init(
            $handle,
            $this->config["id"],
            false,
            true,
            $this->session["work_dir"],
            $this->session["file_dir"],
            $checkPermissions
        )
        ) {
            throw new ExportException('Failed to initialize export');
        }

        $this->export->DoNotDownloadCloudFiles();
        $this->export->StartExport();

        $this->export->StartExportMetadata();
        $this->export->ExportProperties($this->session["property_map"]);
        $this->export->ExportSections(
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            $this->config["sections"],
            $this->session["property_map"]
        );
        $this->export->EndExportMetadata();

        $this->export->StartExportCatalog();
        $this->export->ExportElements(
            $this->session["property_map"],
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            0,
            $this->config["elements"]
        );
        $this->export->EndExportCatalog();

        $this->export->ExportProductSets();
        $this->export->EndExport();

        fclose($handle);
        $filesystem->remove($this->config['path']);
        $filesystem->rename($this->config['path'] . $this->prefix, $this->config['path'], true);
    }
568466
public function export()
    {
        $result = new \stdClass;
        $class  = new \ReflectionClass(get_class($this));
        $plist  = $class->getProperties(\ReflectionProperty::IS_PUBLIC);
        foreach ($plist as $property) {
            $result->{$property->getName()} = $this->{$property->getName()};
        }
        return $result;
    }
1217471
public function searchItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site' ) );
		$this->setLocale( $params->site );

		$totalList = 0;
		$search = $this->initCriteria( $this->getManager()->createSearch(), $params );
		$result = $this->getManager()->searchItems( $search, [], $totalList );

		$idLists = [];
		$listItems = [];

		foreach( $result as $item )
		{
			if( ( $domain = $item->getDomain() ) != '' ) {
				$idLists[$domain][] = $item->getRefId();
			}
			$listItems[] = (object) $item->toArray( true );
		}

		return array(
			'items' => $listItems,
			'total' => $totalList,
			'graph' => $this->getDomainItems( $idLists ),
			'success' => true,
		);
	}
181260
public function insertItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'items' ) );

		$manager = $this->getManager();

		$refId = ( isset( $params->refid ) ? $params->refid : null );
		$parentId = ( ( isset( $params->parentid ) && $params->parentid !== 'root' ) ? $params->parentid : null );
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$item = $manager->createItem();
			$item->fromArray( (array) $this->transformValues( $entry ) );
			$manager->insertItem( $item, $parentId, $refId );

			$entry->{'locale.site.id'} = $item->getId();
		}

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
			'success' => true,
		);
	}
15670
public function deleteItems( \stdClass $params )
	{
		$this->checkParams( $params, array( 'items' ) );

		foreach( (array) $params->items as $id ) {
			$this->getManager()->deleteItem( $id );
		}

		return array(
			'success' => true,
		);
	}
101258
public function load(ServiceContainer $container, array $params)
    {
        $container->define(
            'ecomdev.phpspec.magento_di_adapter.vfs',
            $this->vfsFactory()
        );

        $container->define(
            'ecomdev.phpspec.magento_di_adapter.code_generator.io',
            $this->ioFactory()
        );

        $container->define(
            'ecomdev.phpspec.magento_di_adapter.code_generator.defined_classes',
            $this->simplifiedDefinedClassesFactory()
        );

        $container->define(
            'ecomdev.phpspec.magento_di_adapter.parameter_validator',
            $this->parameterValidatorFactory()
        );

        $container->define(
            'runner.maintainers.ecomdev_magento_collaborator',
            $this->collaboratorMaintainerFactory(),
            ['runner.maintainers']
        );
    }
1168313
public function searchItems( \stdClass $params )
	{
		$manager = $this->getManager();

		$total = 0;
		$search = $manager->createSearch();

		if( isset( $params->options->showall ) && $params->options->showall == false )
		{
			$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $this->getContext() );

			$langids = [];
			foreach( $localeManager->searchItems( $localeManager->createSearch() ) as $item ) {
				$langids[] = $item->getLanguageId();
			}

			if( !empty( $langids ) ) {
				$search->setConditions( $search->compare( '==', 'locale.language.id', $langids ) );
			}
		}

		$search = $this->initCriteria( $search, $params );

		$sort = $search->getSortations();
		$sort[] = $search->sort( '+', 'locale.language.label' );
		$search->setSortations( $sort );

		$items = $this->getManager()->searchItems( $search, [], $total );

		return array(
			'items' => $this->toArray( $items ),
			'total' => $total,
			'success' => true,
		);
	}
403182
public function connect(\stdClass $params): QueryBuilderInterface
	{
		list($dsn, $dbtype, $params, $options) = $this->parseParams($params);

		$dbtype = ucfirst($dbtype);
		$driver = "\\Query\\Drivers\\{$dbtype}\\Driver";

		// Create the database connection
		$db =  ! empty($params->user)
			? new $driver($dsn, $params->user, $params->pass, $options)
			: new $driver($dsn, '', '', $options);

		// Set the table prefix, if it exists
		if (isset($params->prefix))
		{
			$db->setTablePrefix($params->prefix);
		}

		// Create Query Builder object
		$conn = new QueryBuilder($db, new QueryParser($db));


		// Save it for later
		if (isset($params->alias))
		{
			$this->connections[$params->alias] = $conn;
		}
		else
		{
			$this->connections[] = $conn;
		}

		return $conn;
	}
447491
public function getTree( stdClass $params )
	{
		$this->_checkParams( $params, array( 'items' ) );

		$manager = $this->_getManager();

		$result = array();
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			if( $entry == 'root' )
			{
				$search = $this->_manager->createSearch();
				$search->setConditions( $search->compare( '==', 'locale.site.level', 0 ) );

				$item = $this->_manager->createItem();
				$item->setLabel( 'Root' );

				foreach( $this->_manager->searchItems( $search ) as $siteItem ) {
					$item->addChild( $siteItem );
				}
			}
			else
			{
				$item = $manager->getTree( $entry, array(), MW_Tree_Manager_Abstract::LEVEL_LIST );
			}

			$result[] = $this->_createNodeArray( $item );
		}

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $result ) : $result ),
			'success' => true,
		);
	}
747498
public function importFile( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site', 'parentid', 'items' ) );
		$this->setLocale( $params->site );

		/** controller/extjs/coupon/code/standard/container/type
		 * Container file type storing all coupon code files to import
		 *
		 * All coupon code files or content objects must be put into one
		 * container file so editors don't have to upload one file for each
		 * coupon code file.
		 *
		 * The container file types that are supported by default are:
		 * * Zip
		 *
		 * Extensions implement other container types like spread sheets, XMLs or
		 * more advanced ways of handling the exported data.
		 *
		 * @param string Container file type
		 * @since 2014.09
		 * @category Developer
		 * @category User
		 * @see controller/extjs/coupon/code/standard/container/format
		 */

		/** controller/extjs/coupon/code/standard/container/format
		 * Format of the coupon code files to import
		 *
		 * The coupon codes are stored in one or more files or content
		 * objects. The format of that file or content object can be configured
		 * with this option but most formats are bound to a specific container
		 * type.
		 *
		 * The formats that are supported by default are:
		 * * CSV (requires container type "Zip")
		 *
		 * Extensions implement other container types like spread sheets, XMLs or
		 * more advanced ways of handling the exported data.
		 *
		 * @param string Content file type
		 * @since 2014.09
		 * @category Developer
		 * @category User
		 * @see controller/extjs/coupon/code/standard/container/type
		 * @see controller/extjs/coupon/code/standard/container/options
		 */

		/** controller/extjs/coupon/code/standard/container/options
		 * Options changing the expected format of the coupon codes to import
		 *
		 * Each content format may support some configuration options to change
		 * the output for that content type.
		 *
		 * The options for the CSV content format are:
		 * * csv-separator, default ','
		 * * csv-enclosure, default '"'
		 * * csv-escape, default '"'
		 * * csv-lineend, default '\n'
		 *
		 * For format options provided by other container types implemented by
		 * extensions, please have a look into the extension documentation.
		 *
		 * @param array Associative list of options with the name as key and its value
		 * @since 2014.09
		 * @category Developer
		 * @category User
		 * @see controller/extjs/coupon/code/standard/container/format
		 */

		$config = $this->getContext()->getConfig();

		$type = $config->get( 'controller/extjs/coupon/code/standard/container/type', 'Zip' );
		$format = $config->get( 'controller/extjs/coupon/code/standard/container/format', 'CSV' );
		$options = $config->get( 'controller/extjs/coupon/code/standard/container/options', [] );

		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $path )
		{
			$container = \Aimeos\MW\Container\Factory::getContainer( $path, $type, $format, $options );

			foreach( $container as $content ) {
				$this->importContent( $content, $params->parentid );
			}

			unlink( $path );
		}

		return array(
			'success' => true,
		);
	}
287202
public function getTree( \stdClass $params )
	{
		$this->checkParams( $params, array( 'site', 'items' ) );
		$this->setLocale( $params->site );

		$manager = $this->getManager();

		$result = [];
		$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );

		foreach( $items as $entry )
		{
			$entry = ( $entry != 'root' ? $entry : null );
			$item = $manager->getTree( $entry, [], \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST );
			$result[] = $this->createNodeArray( $item );
		}

		return array(
			'items' => ( !is_array( $params->items ) ? reset( $result ) : $result ),
			'success' => true,
		);
	}