@param string $id
@param LayoutUpdateImport $import
@param array $prefixes

@return array
425030
protected function getAdditionalBlockPrefixes($id, LayoutUpdateImport $import, $prefixes = [])
    {
        $prefixes[] = sprintf(self::ADDITIONAL_BLOCK_PREFIX_PATTERN, $import->getId(), $id);
        if ($import->getParent()) {
            $prefixes = $this->getAdditionalBlockPrefixes($id, $import->getParent(), $prefixes);
        }
        return $prefixes;
    }
124100
protected function _prepareData(Import $import, array $headers, array $data) : array
    {
        $result = [];

        $options = $import->get('options');

        $flipped = array_flip($headers);

        foreach ($options['fields'] as $field => $params) {
            if (empty($params['column']) && empty($params['default'])) {
                continue;
            }

            if (array_key_exists($params['column'], $flipped)) {
                $value = $data[$flipped[$params['column']]];
                if (!empty($value)) {
                    $result[$field] = $value;
                    continue;
                }
            }

            if (!empty($params['default'])) {
                $result[$field] = $params['default'];
            }
        }

        return $result;
    }
844953
def transform_import(self, node, results):
        
        import_mod = results.get("module")
        pref = import_mod.prefix

        names = []

        # create a Node list of the replacement modules
        for name in MAPPING[import_mod.value][:-1]:
            names.extend([Name(name[0], prefix=pref), Comma()])
        names.append(Name(MAPPING[import_mod.value][-1][0], prefix=pref))
        import_mod.replace(names)
540106
public function importIssueFile($id, $oldId, $issue, $slug)
    {
        $this->consoleOutput->writeln("Reading issue file #" . $id . "... ", true);

        $issueFileSql = "SELECT * FROM issue_files WHERE file_id = :id LIMIT 1";
        $issueFileStatement = $this->dbalConnection->prepare($issueFileSql);
        $issueFileStatement->bindValue('id', $id);
        $issueFileStatement->execute();

        $galleysSql = "SELECT galley_id, issue_id, locale, label FROM issue_galleys " .
            "WHERE issue_id = :issue_id AND file_id = :id";
        $galleysStatement = $this->dbalConnection->prepare($galleysSql);
        $galleysStatement->bindValue('issue_id', $oldId);
        $galleysStatement->bindValue('id', $id);
        $galleysStatement->execute();

        $pkpIssueFile = $issueFileStatement->fetch();
        $pkpGalleys = $galleysStatement->fetchAll();

        foreach ($pkpGalleys as $galley) {
            $locale = !empty($galley['locale']) ? mb_substr($galley['locale'], 0, 2, 'UTF-8') : 'en';
            $label = !empty($galley['label']) ? $galley['label'] : '-';
            $filename = sprintf('imported/%s/%s.%s',
                $galley['issue_id'],
                $galley['galley_id'],
                FileHelper::$mimeToExtMap[$pkpIssueFile['file_type']]);

            $issueFile = new IssueFile();
            $issueFile->setFile($filename);
            $issueFile->setIssue($issue);
            $issueFile->setVersion(0);
            $issueFile->setType(0);

            // Fill translatable fields
            $issueFile->setCurrentLocale($locale);
            $issueFile->setTitle($label);
            $issueFile->setDescription('-');

            $history = $this->em->getRepository(FileHistory::class)->findOneBy(['fileName' => $filename]);

            if (!$history) {
                $history = new FileHistory();
                $history->setFileName($filename);
                $history->setOriginalName($pkpIssueFile['original_file_name']);
                $history->setType('issuefiles');
                $this->em->persist($history);
            }

            $source = sprintf('%s/issue/download/%s/%s', $slug, $galley['issue_id'], $galley['galley_id']);
            $target = sprintf('/../web/uploads/issuefiles/imported/%s/%s.%s',
                $galley['issue_id'],
                $galley['galley_id'],
                FileHelper::$mimeToExtMap[$pkpIssueFile['file_type']]);

            $pendingDownload = new PendingDownload();
            $pendingDownload->setSource($source);
            $pendingDownload->setTarget($target);

            $this->em->persist($pendingDownload);
            $this->em->persist($issueFile);
        }
    }
44173
public function loadLayoutBlockIds($layoutId, ?int $status = null): array
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('DISTINCT id')
            ->from('ngbm_block')
            ->where(
                $query->expr()->eq('layout_id', ':layout_id')
            )
            ->setParameter('layout_id', $layoutId, Type::INTEGER);

        if ($status !== null) {
            $this->applyStatusCondition($query, $status);
        }

        $result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

        return array_column($result, 'id');
    }
1028139
public function getImportsWithDependencies (array $imports)
    {
        $toLoad = [];

        foreach ($imports as $import)
        {
            $dependencies = $this->map[$import] ?? null;

            if (null !== $dependencies)
            {
                foreach ($dependencies as $dependency)
                {
                    $toLoad[$dependency] = true;
                }
            }
            else
            {
                $toLoad[$import] = true;
            }
        }

        return \array_keys($toLoad);
    }
362765
private CourierImportDeclarations addNthImport(CourierImportDeclaration importDecl) {
    CourierTopLevel root = getRoot();
    CourierImportDeclarations importDecls = root.getImportDeclarations();
    if (importDecl.getFullname() == null) {
      return importDecls;
    }

    boolean added = false;
    for (CourierImportDeclaration existing : importDecls.getImportDeclarationList()) {
      if (existing.getFullname() != null && importDecl.getFullname().toString().compareTo(existing.getFullname().toString()) < 0) {
        importDecls.addBefore(importDecl, existing);
        added = true;
        break;
      }
    }
    if (!added) {
      importDecls.add(importDecl);
    }
    return importDecls;
  }
542960
public function editAction(Request $request, $layoutId, $lang = null)
    {
        $layout= $this->get('doctrine.orm.entity_manager')->find('LexikMailerBundle:Layout', $layoutId);

        if (!$layout) {
            throw $this->createNotFoundException(sprintf('No layout found for id "%d".', $layoutId));
        }

        $handler = $this->get('lexik_mailer.form.handler.layout');
        $form = $handler->createForm($layout, $lang);

        if ($handler->processForm($form, $request)) {
            return $this->redirect($this->generateUrl('lexik_mailer.layout_edit', array(
                'layoutId' => $layout->getId(),
                'lang'     => $lang,
            )));
        }

        return $this->render('LexikMailerBundle:Layout:edit.html.twig', array_merge(array(
            'form'          => $form->createView(),
            'base_layout'   => $this->container->getParameter('lexik_mailer.base_layout'),
            'layout'        => $layout,
            'lang'          => $lang,
            'displayLang'   => \Locale::getDisplayLanguage($lang),
            'routePattern'  => urldecode($this->generateUrl('lexik_mailer.layout_edit', array('layoutId' => $layout->getId(), 'lang' => '%lang%'), true)),
        ), $this->getAdditionalParameters()));
    }
1036202
public function importAction($id)
    {
        /** @var \Thelia\Handler\Importhandler $importHandler */
        $importHandler = $this->container->get('thelia.import.handler');

        $import = $importHandler->getImport($id);
        if ($import === null) {
            return $this->pageNotFound();
        }

        $form = $this->createForm(AdminForm::IMPORT);

        try {
            $validatedForm = $this->validateForm($form);

            /** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
            $file = $validatedForm->get('file_upload')->getData();
            $file = $file->move(
                THELIA_CACHE_DIR . 'import' . DS . (new\DateTime)->format('Ymd'),
                uniqid() . '-' . $file->getClientOriginalName()
            );

            $lang = (new LangQuery)->findPk($validatedForm->get('language')->getData());

            $importEvent = $importHandler->import($import, $file, $lang);

            if (\count($importEvent->getErrors()) > 0) {
                $this->getSession()->getFlashBag()->add(
                    'thelia.import.error',
                    $this->getTranslator()->trans(
                        'Error(s) in import&nbsp;:<br />%errors',
                        [
                            '%errors' => implode('<br />', $importEvent->getErrors())
                        ]
                    )
                );
            }

            $this->getSession()->getFlashBag()->add(
                'thelia.import.success',
                $this->getTranslator()->trans(
                    'Import successfully done, %count row(s) have been changed',
                    [
                        '%count' => $importEvent->getImport()->getImportedRows()
                    ]
                )
            );

            return $this->generateRedirectFromRoute('import.view', [], ['id' => $id]);
        } catch (FormValidationException $e) {
            $form->setErrorMessage($this->createStandardFormValidationErrorMessage($e));
        } catch (\Exception $e) {
            $this->getParserContext()->setGeneralError($e->getMessage());
        }

        $this->getParserContext()
            ->addForm($form)
        ;

        return $this->configureAction($id);
    }
1302992
public function importUser($id, $flush = true)
    {
        $this->consoleOutput->writeln("Reading user #" . $id . "... ", true);

        $sql = "SELECT * FROM users WHERE users.user_id = :id " . ImportHelper::spamUsersFilterSql();
        $statement = $this->dbalConnection->prepare($sql);
        $statement->bindValue('id', $id);
        $statement->execute();

        $faker = Factory::create();
        $pkpUser = $statement->fetch();
        $user = null;

        if ($pkpUser) {
            if (!empty($pkpUser['username'])) {
                $user = $this->em->getRepository('VipaUserBundle:User')->findOneBy(['username' => $pkpUser['username']]);

                if (!$user) {
                    $user = $this->em->getRepository('VipaUserBundle:User')->findOneBy(['email' => $pkpUser['email']]);
                }
            }

            if (is_null($user)) {
                $user = new User();
                !empty($pkpUser['username']) ?
                    $user->setUsername($pkpUser['username']) :
                    $user->setUsername($faker->userName);

                !empty($pkpUser['email']) ?
                    $user->setEmail($pkpUser['email']) :
                    $user->setEmail($faker->companyEmail);

                !empty($pkpUser['disabled']) ?
                    $user->setEnabled(!$pkpUser['disabled']) :
                    $user->setEnabled(1);

                // Set a random password
                $password = mb_substr($this->tokenGenerator->generateToken(), 0, 8);
                $user->setPlainPassword($password);

                // Fields which can't be blank
                !empty($pkpUser['first_name']) ? $user->setFirstName($pkpUser['first_name']) : $user->setFirstName('Anonymous');
                !empty($pkpUser['last_name']) ? $user->setLastName($pkpUser['last_name']) : $user->setLastName('Anonymous');

                // Optional fields
                !empty($pkpUser['billing_address']) && $user->setBillingAddress($pkpUser['billing_address']);
                !empty($pkpUser['mailing_address']) && $user->setAddress($pkpUser['mailing_address']);
                !empty($pkpUser['gender']) && $user->setGender($pkpUser['gender']);
                !empty($pkpUser['phone']) && $user->setPhone($pkpUser['phone']);
                !empty($pkpUser['fax']) && $user->setFax($pkpUser['fax']);
                !empty($pkpUser['url']) && $user->setUrl($pkpUser['url']);
                
                $this->em->persist($user);

                if ($flush) {
                    $this->em->flush();
                }
            }

            return $user;
        }

        return null;
    }
738665
function layoutEditorUpdateData( divId, paramsObj ) {
	log( "layout-editor", "start '"+JSON.stringify(paramsObj)+"'");
	//alert(divId+": ... try to load "+paramsObj.rowId ); 
	if ( ( paramsObj != null ) && ( paramsObj.page_id != null ) ) {
		moduleConfig[ divId ].page_id = paramsObj.page_id;
	} else { 
		paramsObj = { "page_id":moduleConfig[ divId ].page_id };
	}
	pongLayoutBackendCall( "GET", divId, paramsObj, false );
	log( "layout-editor", "end.");
}
812547
public function importTables ($xml, $objArchive, $intThemeId, $arrMapper)
	{
		// Store the field names of the theme tables
		$arrDbFields = array
		(
			'tl_elements'	=> $this->Database->getFieldNames('tl_elements'),
			'tl_pattern'	=> $this->Database->getFieldNames('tl_pattern')
		);
			
		// Lock the tables
		$arrLocks = array
		(
			'tl_elements'	=> 'WRITE',
			'tl_pattern'	=> 'WRITE',
			'tl_files'		=> 'READ',
			'tl_theme'		=> 'READ'
		);

		// Load the DCAs of the locked tables (see #7345)
		foreach (array_keys($arrLocks) as $table)
		{
			$this->loadDataContainer($table);
		}

		$this->Database->lockTables($arrLocks);

		// Get the current auto_increment values
		$tl_elements = $this->Database->getNextId('tl_elements');
		$tl_pattern = $this->Database->getNextId('tl_pattern');

		
		$tables = $xml->getElementsByTagName('table');
		
		// Update the mapper data first
		for ($i=0; $i<$tables->length; $i++)
		{
			$rows = $tables->item($i)->childNodes;
			$table = $tables->item($i)->getAttribute('name');

			// Skip all other tables
			if (!in_array($table, array_keys($arrDbFields)))
			{
				continue;
			}

			// Loop through the rows
			for ($j=0; $j<$rows->length; $j++)
			{
				$fields = $rows->item($j)->childNodes;

				// Loop through the fields
				for ($k=0; $k<$fields->length; $k++)
				{
					// Increment the ID
					if ($fields->item($k)->getAttribute('name') == 'id')
					{
						$arrMapper[$table][$fields->item($k)->nodeValue] = ${$table}++;
						break;
					}
				}
			}
		}

		// Loop through the tables
		for ($i=0; $i<$tables->length; $i++)
		{
			$rows = $tables->item($i)->childNodes;
			$table = $tables->item($i)->getAttribute('name');

			// Skip invalid tables
			if (!in_array($table, array_keys($arrDbFields)))
			{
				continue;
			}

			// Get the order fields
			$objDcaExtractor = \DcaExtractor::getInstance($table);
			$arrOrder = $objDcaExtractor->getOrderFields();

			// Loop through the rows
			for ($j=0; $j<$rows->length; $j++)
			{
				$set = array();
				$fields = $rows->item($j)->childNodes;

				// Loop through the fields
				for ($k=0; $k<$fields->length; $k++)
				{
					$value = $fields->item($k)->nodeValue;
					$name = $fields->item($k)->getAttribute('name');

					// Skip NULL values
					if ($value == 'NULL')
					{
						continue;
					}

					// Increment the ID
					elseif ($name == 'id')
					{
						$value = $arrMapper[$table][$value];
					}

					// Increment the parent IDs
					elseif ($name == 'pid')
					{
						if ($table == 'tl_pattern')
						{
							$value = $arrMapper['tl_elements'][$value];
						}
						else
						{
							$value = $arrMapper['tl_theme'][$value];
						}
					}

					// Adjust element alias
					elseif ($table == 'tl_elements' && $name == 'alias')
					{
						$objName = $this->Database->prepare("SELECT name FROM tl_theme WHERE id=?")
												  ->limit(1)
												  ->execute($set['pid']);

						$value = \StringUtil::generateAlias($objName->name . '-' . $set['title']);			  
					}


					// Replace the file paths in singleSRC fields with their tl_files ID
					elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'fileTree' && !$GLOBALS['TL_DCA'][$table]['fields'][$name]['eval']['multiple'])
					{
						if (!$value)
						{
							$value = null; // Contao >= 3.2
						}
						else
						{
							// Do not use the FilesModel here - tables are locked!
							$objFile = $this->Database->prepare("SELECT uuid FROM tl_files WHERE path=?")
													  ->limit(1)
													  ->execute($this->customizeUploadPath($value));

							$value = $objFile->uuid;
						}
					}

					// Replace the file paths in multiSRC fields with their tl_files ID
					elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'fileTree' || in_array($name, $arrOrder))
					{
						$tmp = \StringUtil::deserialize($value);

						if (is_array($tmp))
						{
							foreach ($tmp as $kk=>$vv)
							{
								// Do not use the FilesModel here - tables are locked!
								$objFile = $this->Database->prepare("SELECT uuid FROM tl_files WHERE path=?")
														  ->limit(1)
														  ->execute($this->customizeUploadPath($vv));

								$tmp[$kk] = $objFile->uuid;
							}

							$value = serialize($tmp);
						}
					}

					// Adjust the imageSize widget data
					elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'imageSize')
					{
						$imageSizes = \StringUtil::deserialize($value, true);

						if (!empty($imageSizes))
						{
							if (is_numeric($imageSizes[2]))
							{
								$imageSizes[2] = $arrMapper['tl_image_size'][$imageSizes[2]];
							}
						}

						$value = serialize($imageSizes);
					}

					// Adjust the sizeList
					elseif ($table == 'tl_pattern' && $name == 'sizeList')
					{
						$imageSizes = \StringUtil::deserialize($value, true);

						if (!empty($imageSizes))
						{
							foreach ($imageSizes as $kk=>$vv)
							{
								$imageSizes[$kk] = $arrMapper['tl_image_size'][$vv];
								if (empty($imageSizes[$kk])) unset($imageSizes[$kk]); // Remove if no new size could be found
							}
						}
						
						$value = serialize($imageSizes);
					}

					$set[$name] = $value;
				}

				// Skip fields that are not in the database (e.g. because of missing extensions)
				foreach ($set as $k=>$v)
				{
					if (!in_array($k, $arrDbFields[$table]))
					{
						unset($set[$k]);
					}
				}
					
				// Insert into database
				$this->Database->prepare("INSERT INTO $table %s")->set($set)->execute();

			}
		}

		// Unlock the tables
		$this->Database->unlockTables();
	
		unset($tl_elements, $tl_pattern);
	}
956457
public function import($resource, $prefix = '/', $type = null)
    {
        /** @var RouteCollection[] $collections */
        $collections = $this->load($resource, $type);

        // create a builder from the RouteCollection
        $builder = $this->createBuilder();

        foreach ($collections as $collection) {
            if (null === $collection) {
                continue;
            }

            foreach ($collection->all() as $name => $route) {
                $builder->addRoute($route, $name);
            }

            foreach ($collection->getResources() as $resource) {
                $builder->addResource($resource);
            }
        }

        // mount into this builder
        $this->mount($prefix, $builder);

        return $builder;
    }
609510
protected void parseImports() {
    List<Element> imports = rootElement.elements("import");
    for (Element theImport : imports) {
      String importType = theImport.attribute("importType");
      XMLImporter importer = this.getImporter(importType, theImport);
      if (importer == null) {
        addError("Could not import item of type " + importType, theImport);
      } else {
        importer.importFrom(theImport, this);
      }
    }
  }
276285
private function initLayoutUpdates(ContextInterface $context)
    {
        $loadedLayoutUpdates = $this->loadLayoutUpdates($context);
        foreach ($loadedLayoutUpdates as $id => $layoutUpdates) {
            if (!is_string($id)) {
                throw new Exception\UnexpectedTypeException(
                    $id,
                    'string',
                    'layout item id'
                );
            }
            if (!is_array($layoutUpdates)) {
                throw new Exception\UnexpectedTypeException(
                    $layoutUpdates,
                    'array',
                    sprintf('layout updates for item "%s"', $id)
                );
            }
            foreach ($layoutUpdates as $layoutUpdate) {
                if (!$layoutUpdate instanceof LayoutUpdateInterface) {
                    throw new Exception\UnexpectedTypeException(
                        $layoutUpdate,
                        'Oro\Component\Layout\LayoutUpdateInterface'
                    );
                }
            }
        }
        $this->layoutUpdates = $loadedLayoutUpdates;
    }
265011
protected function addJsVendorImport( $directory, $import ) {
		$filepath = $this->path( $directory, 'resources', 'scripts', 'theme', 'vendor.js' );
		$statement = "import '$import';";

		$this->appendUniqueStatement( $filepath, $statement );
	}
1202462
function queryImport(styles) {
    if (styles.indexOf('@import') < 0) return []
    const arr = []
    const ast = csstree.parse(styles);
    csstree.walk(ast, {
        enter: function (node) {
            if (node.type === 'Atrule' && node.name === 'import') {
                const pat = node.prelude.children.head.data.value
                arr.push(pat.substring(1, pat.length - 1))
            }
        }
    })
    return arr
}