forked from joomla/Component-Builder
Update on v5.0.4-alpha3 (changes towards the next release)
Here's an update on the current version, which includes changes towards the next release still in development.
This commit is contained in:
parent
36647fca80
commit
147f2f4cb7
@ -148,7 +148,7 @@ TODO
|
|||||||
+ *Version*: 5.0.4-alpha3
|
+ *Version*: 5.0.4-alpha3
|
||||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
+ *Line count*: **871753**
|
+ *Line count*: **871857**
|
||||||
+ *Field count*: **2104**
|
+ *Field count*: **2104**
|
||||||
+ *File count*: **6028**
|
+ *File count*: **6028**
|
||||||
+ *Folder count*: **633**
|
+ *Folder count*: **633**
|
||||||
|
@ -148,7 +148,7 @@ TODO
|
|||||||
+ *Version*: 5.0.4-alpha3
|
+ *Version*: 5.0.4-alpha3
|
||||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
+ *Line count*: **871753**
|
+ *Line count*: **871857**
|
||||||
+ *Field count*: **2104**
|
+ *Field count*: **2104**
|
||||||
+ *File count*: **6028**
|
+ *File count*: **6028**
|
||||||
+ *Folder count*: **633**
|
+ *Folder count*: **633**
|
||||||
|
@ -167,10 +167,9 @@ $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=jooml
|
|||||||
<?php if ($canDo->get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?>
|
<?php if ($canDo->get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?>
|
||||||
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&id=<?php echo $id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&id=<?php echo $id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
||||||
<?php elseif ($canDo->get($_button['view'].'.create')): ?>
|
<?php elseif ($canDo->get($_button['view'].'.create')): ?>
|
||||||
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&field=joomla_component&field_id=<?php echo $item->id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&ref=joomla_component&refid=<?php echo $item->id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="hidden-phone">
|
<td class="hidden-phone">
|
||||||
@ -182,7 +181,7 @@ $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=jooml
|
|||||||
<?php if ($canDo->get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?>
|
<?php if ($canDo->get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?>
|
||||||
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&id=<?php echo $id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&id=<?php echo $id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
||||||
<?php elseif ($canDo->get($_button['view'].'.create')): ?>
|
<?php elseif ($canDo->get($_button['view'].'.create')): ?>
|
||||||
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&field=joomla_component&field_id=<?php echo $item->id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&ref=joomla_component&refid=<?php echo $item->id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
@ -196,7 +195,7 @@ $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=jooml
|
|||||||
<?php if ($canDo->get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?>
|
<?php if ($canDo->get($_button['view'].'.edit') && ($id = GetHelper::var($_button['view'], $item->id, 'joomla_component', 'id')) !== false): ?>
|
||||||
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&id=<?php echo $id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&id=<?php echo $id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
||||||
<?php elseif ($canDo->get($_button['view'].'.create')): ?>
|
<?php elseif ($canDo->get($_button['view'].'.create')): ?>
|
||||||
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&field=joomla_component&field_id=<?php echo $item->id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
<a class="hasTooltip btn btn-mini" href="index.php?option=com_componentbuilder&view=<?php echo $_button['views'] ?>&task=<?php echo $_button['view'] ?>.edit&ref=joomla_component&refid=<?php echo $item->id; ?>&return=<?php echo $this->return_here; ?>" title="<?php echo $_button['title']; ?>" ><span class="icon-<?php echo $_button['icon']; ?>"></span></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -34,6 +34,7 @@ final class Importer
|
|||||||
*
|
*
|
||||||
* @return \Generator A generator that yields each row as an array.
|
* @return \Generator A generator that yields each row as an array.
|
||||||
* @throws \InvalidArgumentException If the file does not exist.
|
* @throws \InvalidArgumentException If the file does not exist.
|
||||||
|
* @throws \OutOfRangeException If the start row is beyond the highest row, no rows can be processed.
|
||||||
* @throws ReaderException If there is an error identifying or reading the file.
|
* @throws ReaderException If there is an error identifying or reading the file.
|
||||||
* @throws SpreadsheetException If there is an error working with the spreadsheet.
|
* @throws SpreadsheetException If there is an error working with the spreadsheet.
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
@ -47,23 +48,43 @@ final class Importer
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Identify file type and create reader
|
||||||
|
$inputFileType = IOFactory::identify($filePath);
|
||||||
|
$reader = IOFactory::createReader($inputFileType);
|
||||||
|
$reader->setReadDataOnly(true);
|
||||||
|
|
||||||
|
// Load the entire spreadsheet to determine the highest row
|
||||||
|
$spreadsheet = $reader->load($filePath);
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
$highestRow = $worksheet->getHighestRow(); // Get the highest row number in the sheet
|
||||||
|
|
||||||
|
// Disconnect and free memory after fetching the highest row
|
||||||
|
$spreadsheet->disconnectWorksheets();
|
||||||
|
unset($spreadsheet);
|
||||||
|
|
||||||
|
// If the start row is beyond the highest row, no rows can be processed
|
||||||
|
if ($startRow > $highestRow)
|
||||||
|
{
|
||||||
|
throw new \OutOfRangeException("Start row ($startRow) is beyond highest row ($highestRow)");
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize variables for row processing
|
// Initialize variables for row processing
|
||||||
$totalRows = $startRow;
|
$totalRows = $startRow;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// Set up a new chunk filter for the current chunk
|
// Calculate the last row in the current chunk
|
||||||
$chunkFilter = new ChunkReadFilter($totalRows, $chunkSize);
|
$endRow = min($totalRows + $chunkSize - 1, $highestRow);
|
||||||
$inputFileType = IOFactory::identify($filePath);
|
|
||||||
$reader = IOFactory::createReader($inputFileType);
|
|
||||||
$reader->setReadFilter($chunkFilter);
|
|
||||||
$reader->setReadDataOnly(true);
|
|
||||||
|
|
||||||
// Load the chunk into the spreadsheet
|
// Set up a new chunk filter for the current chunk
|
||||||
|
$chunkFilter = new ChunkReadFilter($totalRows, $endRow);
|
||||||
|
$reader->setReadFilter($chunkFilter);
|
||||||
|
|
||||||
|
// Reload the chunk into the spreadsheet
|
||||||
$spreadsheet = $reader->load($filePath);
|
$spreadsheet = $reader->load($filePath);
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
// Iterate through the rows in the current chunk
|
// Iterate through the rows in the current chunk
|
||||||
foreach ($worksheet->getRowIterator($totalRows) as $row)
|
foreach ($worksheet->getRowIterator($totalRows, $endRow) as $row)
|
||||||
{
|
{
|
||||||
$rowIndex = $row->getRowIndex();
|
$rowIndex = $row->getRowIndex();
|
||||||
$rowData = [];
|
$rowData = [];
|
||||||
@ -87,7 +108,7 @@ final class Importer
|
|||||||
$spreadsheet->disconnectWorksheets();
|
$spreadsheet->disconnectWorksheets();
|
||||||
unset($spreadsheet);
|
unset($spreadsheet);
|
||||||
|
|
||||||
} while (!empty($rowData)); // Continue reading until no more rows are available
|
} while ($totalRows <= $highestRow); // Continue reading while within the row limit
|
||||||
|
|
||||||
} catch (ReaderException $e) {
|
} catch (ReaderException $e) {
|
||||||
throw new ReaderException("Error reading the file: " . $e->getMessage(), $e->getCode(), $e);
|
throw new ReaderException("Error reading the file: " . $e->getMessage(), $e->getCode(), $e);
|
||||||
|
Loading…
Reference in New Issue
Block a user