use App\Fluidbook\Compiler\Compiler;
use App\Models\FluidbookDocument;
+use App\Models\FluidbookPublication;
use Cubist\Util\Gzip;
use Cubist\Util\PHP;
}
/**
- * @param $compiler Compiler
+ * @param $compiler Compiler|FluidbookPublication
* @return array
*/
public static function makeHighlightIndex($compiler): array
{
+
+ if ($compiler instanceof Compiler) {
+ $pages = $compiler->pages;
+ $fluidbook = $compiler->getFluidbook();
+ } else if ($compiler instanceof FluidbookPublication) {
+ $fluidbook = $compiler;
+ $pages = $fluidbook->getComposition();
+ }else{
+ return [];
+ }
+
$res = [];
- foreach ($compiler->pages as $page => $infos) {
- $fby = $compiler->getFluidbook()->getHightlightFile($page);
+ foreach ($pages as $page => $infos) {
+ $fby = $fluidbook->getHightlightFile($page);
$words = json_decode(Gzip::file_get_contents($fby), true);
if (is_array($words)) {
// __('!!Paramètres des fluidbooks')
+use App\Fluidbook\Compiler\Compiler;
use App\Fluidbook\Link\LinksData;
use App\Http\Middleware\VerifyCsrfToken;
use App\Models\FluidbookPublication;
$target = '_blank';
$toPrefix = '';
$toSuffix = '';
+ $skipFirst = true;
+ $vPadding = 0;
+ $hPadding = 0;
switch ($rules) {
case 'cart':
$type = \Fluidbook\Tools\Links\Link::CART;
case 'steelite':
$toSuffix = '?embed';
$target = '_popupiframe';
+ $hPadding = 2;
+ $vPadding = 4;
case 'web':
default:
break;
}
ExcelToArray::setCache(Files::mkdir('/tmp/exceltoarray'));
- $excel = ExcelToArray::excelToAssoc($uploadedFile->getPathname());
- dd($type, $target, $toSuffix, $excel);
+ $excel = ExcelToArray::excelToArrayKeyVal($uploadedFile->getPathname());
+ /** @var FluidbookPublication $fluidbook */
+ $fluidbook = FluidbookPublication::withoutGlobalScopes()->find($fluidbook_id);
+ $highlights = $fluidbook->getHightlightData();
+ $links = [];
+
+ foreach ($excel as $search => $url) {
+ if ($skipFirst) {
+ $skipFirst = false;
+ continue;
+ }
+
+ $search = mb_strtolower($search);
+
+ if (isset($highlights[$search])) {
+ foreach ($highlights[$search] as $o) {
+ $uid = LinksData::generateUID();
+ $links[$uid] = [
+ 'uid' => $uid,
+ 'page' => $o['page'],
+ 'left' => $o['x'] - $hPadding,
+ 'top' => $o['y'] - $o['height'] - $vPadding,
+ 'width' => $o['width'] + $hPadding * 2,
+ 'height' => $o['height'] + $vPadding * 2,
+ 'type' => $type,
+ 'target' => $target,
+ 'to' => $toPrefix . $url . $toSuffix,
+ ];
+ }
+ }
+ }
- LinksData::saveLinksInFile($fluidbook_id, backpack_user()->id, __("Ajouter des liens automatiques à partir du fichier :file", ['file' => $uploadedFile->getClientOriginalName()]) . ' ', $links, $rulers, [], []);
+ LinksData::saveLinksInFile($fluidbook_id, backpack_user()->id, __("Ajouter des liens automatiques à partir du fichier :file (règles :rule)", ['file' => $uploadedFile->getClientOriginalName(),'rule'=>$rules]) . ' ', $links, $rulers, [], []);
return response()->json(['success' => 'ok']);
}
use App\Fluidbook\Link\Link;
use App\Fluidbook\Link\LinksData;
use App\Fluidbook\Region;
+use App\Fluidbook\SearchIndex;
use App\Http\Controllers\Admin\Operations\ChangeownerOperation;
use App\Http\Controllers\Admin\Operations\ChangestatusOperation;
use App\Http\Controllers\Admin\Operations\FluidbookPublication\AuditOperation;
return self::_getDocument($compo[0])->getTextFile($compo[1], $type, $mode ?? $this->search_mode ?: 'standard', $this->textExtraction, $this->ignoreSearchSeparators);
}
+ public function getHightlightData(): array
+ {
+ return SearchIndex::makeHighlightIndex($this);
+ }
+
public function getHightlightFile($page)
{
$compo = $this->getComposition()[$page];