protected function installFiles($value, $modelClass, $layout, $field, $toggle)
	{
		$value 	 = deserialize($value, true);
		$result  = $modelClass::findAll(array('limit' => '1', 'order' => 'sorting DESC'));
		$sorting = $result === null ? 0 : $result->sorting;
		$new 	 = array();

		foreach($value as $file)
		{
			if($file['file'] == '') {
				continue;
			}

			if(substr($file['file'], 0, 6) == 'assets') {
				$source = 'assets';
			}
			elseif(substr($file['file'], 0, 5) == 'files') {
				$source = 'files';
			}
			else {
				$source = 'system/modules';
			}

			/** @var \Model $model */
			$model = new $modelClass();
			$model->tstamp        = time();
			$model->pid           = $layout->pid;
			$model->type          = 'file';
			$model->file          = $file['file'];
			$model->filesource    = $source;
			$model->cc            = $file['conditional'];
			$model->asseticFilter = $file['asseticFilter'];
			$model->sorting       = ++$sorting;
			$model->save();

			$new[] = $model->id;
		}

		$new  = array_merge(deserialize($layout->$field, true), $new);
		$data = array(
			$field => $new,
			$toggle => ''
		);

		\Database::getInstance()
			->prepare('UPDATE tl_layout %s WHERE id=?')
			->set($data)
			->execute($layout->id);
	}
protected function installFiles($value, $modelClass, $layout, $field, $toggle)
	{
		$value 	 = deserialize($value, true);
		$result  = $modelClass::findAll(array('limit' => '1', 'order' => 'sorting DESC'));
		$sorting = $result === null ? 0 : $result->sorting;
		$new 	 = array();

		foreach($value as $file)
		{
			if($file['file'] == '') {
				continue;
			}

			if(substr($file['file'], 0, 6) == 'assets') {
				$source = 'assets';
			}
			elseif(substr($file['file'], 0, 5) == 'files') {
				$source = 'files';
			}
			else {
				$source = 'system/modules';
			}

			/** @var \Model $model */
			$model = new $modelClass();
			$model->tstamp        = time();
			$model->pid           = $layout->pid;
			$model->type          = 'file';
			$model->file          = $file['file'];
			$model->filesource    = $source;
			$model->cc            = $file['conditional'];
			$model->asseticFilter = $file['asseticFilter'];
			$model->sorting       = ++$sorting;
			$model->save();

			$new[] = $model->id;
		}

		$new  = array_merge(deserialize($layout->$field, true), $new);
		$data = array(
			$field => $new,
			$toggle => ''
		);

		\Database::getInstance()
			->prepare('UPDATE tl_layout %s WHERE id=?')
			->set($data)
			->execute($layout->id);
	}
protected function installFiles ( $ value , $ modelClass , $ layout , $ field , $ toggle ) { $ value = deserialize ( $ value , true ) ; $ result = $ modelClass :: findAll ( array ( 'limit' => '1' , 'order' => 'sorting DESC' ) ) ; $ sorting = $ result === null ? 0 : $ result -> sorting ; $ new = array ( ) ; foreach ( $ value as $ file ) { if ( $ file [ 'file' ] == '' ) { continue ; } if ( substr ( $ file [ 'file' ] , 0 , 6 ) == 'assets' ) { $ source = 'assets' ; } elseif ( substr ( $ file [ 'file' ] , 0 , 5 ) == 'files' ) { $ source = 'files' ; } else { $ source = 'system/modules' ; } /** @var \Model $model */ $ model = new $ modelClass ( ) ; $ model -> tstamp = time ( ) ; $ model -> pid = $ layout -> pid ; $ model -> type = 'file' ; $ model -> file = $ file [ 'file' ] ; $ model -> filesource = $ source ; $ model -> cc = $ file [ 'conditional' ] ; $ model -> asseticFilter = $ file [ 'asseticFilter' ] ; $ model -> sorting = ++ $ sorting ; $ model -> save ( ) ; $ new [ ] = $ model -> id ; } $ new = array_merge ( deserialize ( $ layout -> $ field , true ) , $ new ) ; $ data = array ( $ field => $ new , $ toggle => '' ) ; \ Database :: getInstance ( ) -> prepare ( 'UPDATE tl_layout %s WHERE id=?' ) -> set ( $ data ) -> execute ( $ layout -> id ) ; }
generic importer helper for asset files

@param array|string  $value
@param string        $modelClass
@param \Model|\Result $layout
@param string        $field      fieldname
@param string        $toggle     name of toggle field
generic importer helper for asset files