Run the import

@return void
@throws \Luna\Importer\Exceptions\InvalidCsvLineException
@throws \Exception
765441
public function import()
    {
        DB::beginTransaction();

        try {
            $iteration = 0;

            while (! feof($this->file)) {
                $iteration++;

                $csvLine = str_getcsv(fgets($this->file), ';');
                $columnCount = count($csvLine);

                if ($columnCount === 1 && !$this->importer->validateLine($csvLine)) {
                    continue;
                } elseif ($this->importer->validateLine($csvLine)) {
                    $this->handleLine($csvLine);
                } else {
                    throw new InvalidCsvLineException($iteration);
                }
            }

            $this->lines = $this->importer->getModelInstance()->count();

            $this->removeStale();

            if (!$this->dryRun) {
                DB::commit();
            }

            event(new ImportSuccess($this, $this->importer));
        } catch (\Exception $e) {
            DB::rollBack();

            event(new ImportFailed($this, $this->importer, $e));

            // Re-throw the exception to catch it from outside
            throw $e;
        }
    }
314217
public function run()
    {
        $this->loader->parse();
        $files = $this->filesystem->getFiles();

        // Now we check all the files against the config
        while ($files->valid()) {
            /* @var SplFileInfo $file */
            $file = $files->current();

            // Skip symlinks as they are always 0777
            if ($file->isLink()) {
                $files->next();
                continue;
            }

            $filename = $this->getRelativeFilename($file);

            // Skip excluded files, of course.
            if ($this->isExcluded($filename)) {
                $files->next();
                continue;
            }

            $fileShouldBeExecutable = $this->shouldBeExecutable($filename);
            if (!$fileShouldBeExecutable && $file->isExecutable()) {
                $this->messageBag->addMessage($file->getPathname(), 'minx');
                $files->next();
                continue;
            }

            if ($fileShouldBeExecutable && !$file->isExecutable()) {
                $this->messageBag->addMessage($file->getPathname(), 'plusx');
                $files->next();
                continue;
            }

            $files->next();
        }
    }
1360004
public void run()
    {
        Record record = this.getMainRecord();
        String strFileName = this.getProperty("filename");
        String strImport = this.getProperty("import");
        if (strFileName == null)
            strFileName = strImport;
        String strExport = this.getProperty("export");
        if (strFileName == null)
            strFileName = strExport;
        m_bOverwriteDups = false;
        if ((DBConstants.TRUE.equalsIgnoreCase(this.getProperty("overwritedups")))
            || (DBConstants.YES.equalsIgnoreCase(this.getProperty("overwritedups"))))
                m_bOverwriteDups = true;
        boolean bSuccess = false;
        if (strImport != null)
            bSuccess = this.importXML(record.getTable(), strFileName, null);
        else
            bSuccess = this.exportXML(record.getTable(), strFileName);
        if (!bSuccess)
            System.exit(1);
    }
1227440
public function run()
    {
        $old = explode(' ', $this->parameters['previous']);
        $new = explode(' ', $this->parameters['current']);
        $out = $this->parameters['output'];
        
        $diff = new taoDevTools_models_RdfDiff();
        foreach ($old as $file) {
            $diff->removeRdf($file);
        }
        foreach ($new as $file) {
            $diff->addRdf($file);
        }
        file_put_contents($out, $diff->exportDiffToSql());
    }
336954
public function run()
    {
        $data = $this->getData();

        $defaultProperties = $data['defaults'];
        $areas = $data['areas'];

        foreach ($areas as $slug => $desc)
        {
            // Handle quick declaration style
            if ( !is_array($desc))
            {
                // $desc is actually the title, build an array
                $desc = array('name' => $desc);
            }

            // Set name and description if not specified
            if ( !isset($desc['name']))
            {
                $desc['name'] = Strings::labelizeSlug($slug);
            }
            if ( !isset($desc['description']))
            {
                $desc['description'] = '';
            }

            // Set the slug
            $desc['id'] = $slug;

            // Merge with our default and register
            $areaProperties = array_merge($defaultProperties, $desc);

            // Internationalize what has to be internationalized
            $areaProperties['name'] = Strings::translate($areaProperties['name']);
            $areaProperties['description'] = Strings::translate($areaProperties['description']);

            register_sidebar($areaProperties);
        }
    }
719007
public function run()
    {
        echo $this->renderWidget() . "\n";

        $containerID = $this->inline ? $this->containerOptions['id'] : $this->options['id'];
        $language = $this->language ? $this->language : Yii::$app->language;

        if (strncmp($this->dateFormat, 'php:', 4) === 0) {
            $this->clientOptions['dateFormat'] = FormatConverter::convertDatePhpToJui(substr($this->dateFormat, 4));
        } else {
            $this->clientOptions['dateFormat'] = FormatConverter::convertDateIcuToJui($this->dateFormat, 'date', $language);
        }

        if ($language !== 'en-US') {
            $view = $this->getView();
            $assetBundle = DatePickerLanguageAsset::register($view);
            $assetBundle->language = $language;
            $options = Json::htmlEncode($this->clientOptions);
            $language = Html::encode($language);
            $view->registerJs("jQuery('#{$containerID}').datepicker($.extend({}, $.datepicker.regional['{$language}'], $options));");
        } else {
            $this->registerClientOptions('datepicker', $containerID);
        }

        $this->registerClientEvents('datepicker', $containerID);
        JuiAsset::register($this->getView());
    }
1243947
public function run()
    {
        $vendorDir = dirname(dirname(__FILE__));
        $baseDir = dirname($vendorDir);
        spl_autoload_register(function ($className) use($baseDir) {
            if (file_exists($file = $baseDir . '/database/seeds/' . $className . '.php')) {
                include($file);
                return true;
            }
        });

        $this->call([
            ModulesTableSeeder::class,
            PrivilegesTableSeeder::class,
            SettingsTableSeeder::class,
        ]);
    }
409821
public function run()
    {
        $countryIDs = getRinvexCountryIDs();
        $translations = [];
        $countries = [];

        foreach ($countryIDs as $id) {
            $country = country($id);

            foreach (country($id)->getTranslations() as $key => $value) {
                $languageCode = HCLanguages::where('iso_639_2', $key)->first()['iso_639_1'];
                if (!$languageCode)
                    continue;

                if (!isset($translations[$languageCode]))
                    $translations[$languageCode] = [];

                $translations[$languageCode][$id] = $value['common'];
            }

            $flagLocation = base_path('/vendor/rinvex/country/resources/flags/' . strtolower($country->getIsoAlpha2()) . '.svg');
            $flagID = null;

            if (file_exists($flagLocation)) {
                $flagID = 'flag-' . strtolower($country->getIsoAlpha2());

                if (!HCResources::find($flagID))
                {
                    $flag = new HCUploadController(true);
                    $flag->downloadResource($flagLocation, true, $flagID, 'image/svg+xml');
                }
            }

            $countries[] =
                [
                    'id'                => $id,
                    'region_id'         => strtolower(array_keys($country->get('geo.continent'))[0]),
                    'common_name'       => $country->getName(),
                    'official_name'     => $country->getOfficialName(),
                    'translation_key'   => 'HCRegions::country_names.' . createTranslationKey($id),
                    'iso_3166_1_alpha2' => strtolower($country->getIsoAlpha2()),
                    'iso_3166_1_alpha3' => strtolower($country->getIsoAlpha3()),
                    'flag_id'           => $flagID,
                    'geo_data'          => File::get(base_path('/vendor/rinvex/country/resources/geodata/' . $id) . '.json'),
                    'created_at'        => date('Y-m-d H:i:s'),
                    'updated_at'        => date('Y-m-d H:i:s')
                ];
        }

        DB::beginTransaction();

        try {

            foreach ($countries as $country) {
                $existing = HCCountries::find($country['id']);

                if ($existing)
                    $existing->update($country);
                else
                    HCCountries::create($country);
            }

        } catch (\Exception $e) {

            DB::rollback();
            throw new \Exception($e);
        }

        DB::commit();

        foreach ($translations as $key => $value) {
            if (!file_exists(__DIR__ . '/../../resources/lang/' . $key))
                mkdir(__DIR__ . '/../../resources/lang/' . $key);

            $content = str_replace(');', '];', "<?php \r\n return " . str_replace('array (', '[', var_export($value, true)) . ';');
            file_put_contents(__DIR__ . '/../../resources/lang/' . $key . '/country_names.php', $content);
        }
    }
1293235
public function run()
    {
        $block = ob_get_clean();
        if ($this->renderInPlace) {
            throw new InvalidParamException("Not implemented yet ! ");
        }
        $block = trim($block);
        /*
        $jsBlockPattern  = '|^<script[^>]*>(.+?)</script>$|is';
        if(preg_match($jsBlockPattern,$block)){
            $block =  preg_replace ( $jsBlockPattern , '${1}'  , $block );
        }
        */
        $jsBlockPattern = '|^<script[^>]*>(?P<block_content>.+?)</script>$|is';
        if (preg_match($jsBlockPattern, $block, $matches)) {
            $block = $matches['block_content'];
        }

        $this->view->registerJs($block, $this->pos, $this->key);
    }
528404
public function run()
	{
		list($name,$id)=$this->resolveNameID();
		if(substr($name,-2)!=='[]')
			$name.='[]';
		if(isset($this->htmlOptions['id']))
			$id=$this->htmlOptions['id'];
		else
			$this->htmlOptions['id']=$id;
		$this->registerClientScript();
		echo CHtml::fileField($name,'',$this->htmlOptions);
	}
306360
public function run()
    {
        $this->controller->getSearchCriteria();
        $this->controller->dataProvider->pagination = false;
        $query = $this->controller->dataProvider->query;

        $config = new ExporterConfig();
        $exporter = new Exporter($config);
        $result = $query->asArray()->all();
        $fields = $this->fields;
        $values = array_map(function ($ar) use ($fields) {
        //$values = array_map(function () use ($fields) {
            $return = [];
            foreach($fields as $field) {
                $keyString = "['" . str_replace('.', "']['", $field) . "']"; 
                eval("\$return[] = \$ar".$keyString.";");
            }
            return $return;
        }, $result);
        if(isset($_GET['test'])) {
            return json_encode(array_merge([$this->fields], $values));
        } else {
            $this->setHttpHeaders('csv', $this->controller->getCompatibilityId(), 'text/plain');
            $exporter->export('php://output', array_merge([$this->fields], $values));
        }
    }
84756
public function run()
    {
        if (!App::environment('testing')) {
            DB::statement('SET FOREIGN_KEY_CHECKS=0');
        }
        DB::table(config('combine-core.tablePrefix', 'combine') . '_abilities')->truncate();
        DB::table(config('combine-core.tablePrefix', 'combine') . '_roles')->truncate();
        DB::table(config('combine-core.tablePrefix', 'combine') . '_teams')->truncate();
        DB::table('users')->truncate();
        if (!App::environment('testing')) {
            DB::statement('SET FOREIGN_KEY_CHECKS=1');
        }

        echo "Populating Roles ...\n";
        $this->roleModels = $this->populateRoles($this->roles);
        echo "Populating Abiltiies ...\n";
        $this->populateAbilities($this->abilities, $this->roleModels);
    }
530460
public function run()
    {
        // Setting up the styles
        echo '<style type="text/css">';
        echo '#bodydiv { font: 10px sans-serif;}';
        foreach ($this->styles as $class => $style) {
            echo '.', $class, ' { ';
            if ($style['font'] === 'dejavusans') {
                $style['font'] = $this->default_font;
            }
            echo 'font-family: ', $style['font'], '; ';
            echo 'font-size: ', $style['size'], 'pt; ';
            // Case-insensitive
            if (stripos($style['style'], 'B') !== false) {
                echo 'font-weight: bold; ';
            }
            if (stripos($style['style'], 'I') !== false) {
                echo 'font-style: italic; ';
            }
            if (stripos($style['style'], 'U') !== false) {
                echo 'text-decoration: underline; ';
            }
            if (stripos($style['style'], 'D') !== false) {
                echo 'text-decoration: line-through; ';
            }
            echo '}', PHP_EOL;
        }
        unset($class, $style);
        //-- header divider
        echo '</style>', PHP_EOL;
        echo '<div id="headermargin" style="position: relative; top: auto; height: ', $this->header_margin, 'pt; width: ', $this->noMarginWidth, 'pt;"></div>';
        echo '<div id="headerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;">';
        foreach ($this->headerElements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($this);
            } elseif ($element === 'footnotetexts') {
                $this->footnotes();
            } elseif ($element === 'addpage') {
                $this->addPage();
            }
        }
        //-- body
        echo '</div>';
        echo '<script>document.getElementById("headerdiv").style.height="', $this->top_margin - $this->header_margin - 6, 'pt";</script>';
        echo '<div id="bodydiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt; height: 100%;">';
        $this->Y    = 0;
        $this->maxY = 0;
        $this->runPageHeader();
        foreach ($this->bodyElements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($this);
            } elseif ($element === 'footnotetexts') {
                $this->footnotes();
            } elseif ($element === 'addpage') {
                $this->addPage();
            }
        }
        //-- footer
        echo '</div>';
        echo '<script>document.getElementById("bodydiv").style.height="', $this->maxY, 'pt";</script>';
        echo '<div id="bottommargin" style="position: relative; top: auto; height: ', $this->bottom_margin - $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
        echo '<div id="footerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;height:auto;">';
        $this->Y    = 0;
        $this->X    = 0;
        $this->maxY = 0;
        foreach ($this->footerElements as $element) {
            if ($element instanceof ReportBaseElement) {
                $element->render($this);
            } elseif ($element === 'footnotetexts') {
                $this->footnotes();
            } elseif ($element === 'addpage') {
                $this->addPage();
            }
        }
        echo '</div>';
        echo '<script>document.getElementById("footerdiv").style.height="', $this->maxY, 'pt";</script>';
        echo '<div id="footermargin" style="position: relative; top: auto; height: ', $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
    }
1641
public function run()
    {
        if(Schema::hasTable(strtolower($this->model)))
        {
            $tableName = strtolower($this->model);
        }elseif(Schema::hasTable(strtolower($this->model)."s")) {
            $tableName = strtolower($this->model."s");
        }else{
            $tableName = "";
        }

        $module  = camel_case($this->module);
        $model   = camel_case($this->model);

        $templatePath = $this->customTemplate ?: __DIR__."/template/model.blade.php";

        $view =  View::file($templatePath, [
            "group"         => $this->group,
            "module"        => $module,
            "model"         => $model,
            "tableName"     => $tableName,
            "primaryKey"    => "id"
        ]);

        $filePath = "Models/".ucfirst($model).".php";

        if(!is_dir(app_path("Models/")))
        {
            mkdir(app_path("Models/"));
        }

        if(!file_exists(app_path($filePath)))
        {
            file_put_contents(app_path($filePath), "<?php \n\n" . $view->render());
        }else{
            if($this->mode == "overwrite")
            {
                file_put_contents(app_path($filePath), "<?php \n\n" . $view->render());
            }
        }
    }
584727
public function run()
    {
        if(Schema::hasTable(strtolower($this->model)))
        {
            $tableName = strtolower($this->model);
        }elseif(Schema::hasTable(strtolower($this->model)."s")) {
            $tableName = strtolower($this->model."s");
        }else{
            $tableName = "";
        }

        $tableColumns = $tableName != "" ? Schema::getColumnListing($tableName) : [];

        $module  = camel_case($this->module);
        $model   = camel_case($this->model);

        $templatePath = $this->customTemplate ?: __DIR__."/template/repository.blade.php";

        $paramColumns = array_diff($tableColumns, ["id", "created_at", "updated_at"]);

        $paramStrings = collect($paramColumns)->map(function($item){
            return "$".lcfirst(camel_case($item));
        })->toArray();

        $view =  View::file($templatePath, [
            "group"         => $this->group,
            "module"        => $module,
            "model"         => $model,
            "paramStrings"  => $paramStrings,
            "tableColumns"  => $paramColumns
        ]);

        $filePath = "Repositories/".ucfirst($model)."Repository.php";

        if(!is_dir(app_path("Repositories/")))
        {
            mkdir(app_path("Repositories/"));
        }

        if(!file_exists(app_path($filePath)))
        {
            file_put_contents(app_path($filePath), "<?php \n\n" . $view->render());
        }else{
            if($this->mode == "overwrite")
            {
                file_put_contents(app_path($filePath), "<?php \n\n" . $view->render());
            }
        }
    }
78279
public function run() {
		$isPost = $_SERVER["REQUEST_METHOD"] == 'POST';
		$src    = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
		if ($isPost && !$src && $rawPostData = @file_get_contents('php://input')) {
			// for support IE XDomainRequest()
			$parts = explode('&', $rawPostData);
			foreach($parts as $part) {
				list($key, $value) = array_pad(explode('=', $part), 2, '');
				$src[$key] = rawurldecode($value);
			}
			$_POST = $this->input_filter($src);
			$_REQUEST = $this->input_filter(array_merge_recursive($src, $_REQUEST));
		}
		$cmd    = isset($src['cmd']) ? $src['cmd'] : '';
		$args   = array();
		
		if (!function_exists('json_encode')) {
			$error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON);
			$this->output(array('error' => '{"error":["'.implode('","', $error).'"]}', 'raw' => true));
		}
		
		if (!$this->elFinder->loaded()) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_VOL), 'debug' => $this->elFinder->mountErrors));
		}
		
		// telepat_mode: on
		if (!$cmd && $isPost) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UPLOAD, elFinder::ERROR_UPLOAD_TOTAL_SIZE), 'header' => 'Content-Type: text/html'));
		}
		// telepat_mode: off
		
		if (!$this->elFinder->commandExists($cmd)) {
			$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UNKNOWN_CMD)));
		}
		
		// collect required arguments to exec command
		foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
			$arg = $name == 'FILES' 
				? $_FILES 
				: (isset($src[$name]) ? $src[$name] : '');
				
			if (!is_array($arg)) {
				$arg = trim($arg);
			}
			if ($req && (!isset($arg) || $arg === '')) {
				$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)));
			}
			$args[$name] = $arg;
		}
		
		$args['debug'] = isset($src['debug']) ? !!$src['debug'] : false;
		
		$this->output($this->elFinder->exec($cmd, $this->input_filter($args)));
	}
658388
public function run()
	{
		$formatter=$this->getFormatter();
		if ($this->tagName!==null)
			echo CHtml::openTag($this->tagName,$this->htmlOptions);

		$i=0;
		$n=is_array($this->itemCssClass) ? count($this->itemCssClass) : 0;

		foreach($this->attributes as $attribute)
		{
			if(is_string($attribute))
			{
				if(!preg_match('/^([\w\.]+)(:(\w*))?(:(.*))?$/',$attribute,$matches))
					throw new CException(Yii::t('zii','The attribute must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'));
				$attribute=array(
					'name'=>$matches[1],
					'type'=>isset($matches[3]) ? $matches[3] : 'text',
				);
				if(isset($matches[5]))
					$attribute['label']=$matches[5];
			}

			if(isset($attribute['visible']) && !$attribute['visible'])
				continue;

			$tr=array('{label}'=>'', '{class}'=>$n ? $this->itemCssClass[$i%$n] : '');
			if(isset($attribute['cssClass']))
				$tr['{class}']=$attribute['cssClass'].' '.($n ? $tr['{class}'] : '');

			if(isset($attribute['label']))
				$tr['{label}']=$attribute['label'];
			elseif(isset($attribute['name']))
			{
				if($this->data instanceof CModel)
					$tr['{label}']=$this->data->getAttributeLabel($attribute['name']);
				else
					$tr['{label}']=ucwords(trim(strtolower(str_replace(array('-','_','.'),' ',preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $attribute['name'])))));
			}

			if(!isset($attribute['type']))
				$attribute['type']='text';
			if(isset($attribute['value']))
				$value=is_object($attribute['value']) && get_class($attribute['value']) === 'Closure' ? call_user_func($attribute['value'],$this->data) : $attribute['value'];
			elseif(isset($attribute['name']))
				$value=CHtml::value($this->data,$attribute['name']);
			else
				$value=null;

			$tr['{value}']=$value===null ? $this->nullDisplay : $formatter->format($value,$attribute['type']);

			$this->renderItem($attribute, $tr);

			$i++;
		}

		if ($this->tagName!==null)
			echo CHtml::closeTag($this->tagName);
	}