wsDocument::cleanSVG($test, true);
}
+ public function addSearch() {
+ global $core;
+ $r = $core->con->select('SELECT book_id, parametres FROM books WHERE book_id');
+ $reset = [];
+ $error = [];
+ $skip = [];
+ while ($r->fetch()) {
+ /** @var wsBookParametres $parametres */
+ try {
+ $former =
+ $parametres = unserialize($r->parametres);
+ $order = explode(',', $parametres->navOrder);
+ $former = $parametres->navOrder;
+ $order = array_map('trim', $order);
+ if (in_array('search', $order)) {
+ $skip[] = $r->book_id;
+ continue;
+ }
+
+ $searchLocation = 0;
+ $chaptersLocation = array_search('chapters', $order);
+ if ($chaptersLocation !== false) {
+ $searchLocation = $chaptersLocation + 1;
+ } else {
+ $indexLocation = array_search('index', $order);
+ if ($indexLocation !== false) {
+ $searchLocation = $indexLocation + 1;
+ }
+ }
+ array_splice($order, $searchLocation, 0, 'search');
+
+ $newOrder = join(', ' , $order);
+
+ $c = $core->con->openCursor('books');
+ $parametres->navOrder=$newOrder;
+ $c->parametres = serialize($parametres);
+ $c->changedate = TIME;
+ $c->update('WHERE book_id=' . $r->book_id);
+ $reset[] = $r->book_id . ' : ' . $former . ' -> ' . $newOrder;
+ } catch (Exception $e) {
+ $error[] = $r->book_id;
+ }
+ }
+
+ echo 'reset : ' . implode('<br />', $reset) . '<br />';
+ echo 'skip : ' . implode(', ', $skip) . '<br />';
+ echo 'error : ' . implode(', ', $error) . '<br />';
+
+ }
+
}