<!--
@sources
https://play.tailwindcss.com/om6YbfPx0J
https://www.setrimsmalinou.cz/
-->
<!-- FROM LEFT TO RIGHT -->
<div class="relative h-[500px] border-2 border-black">
<!-- image -->
<div class="absolute inset-y-0 w-1/2 bg-red-300">
<img src="https://picsum.photos/id/237/1500/1500" class="h-full w-full object-cover object-center" alt="" />
</div>
<!-- container -->
<div class="mx-auto flex h-full max-w-6xl justify-end border-2 border-green-500">
<div class="w-1/2">Content ...</div>
</div>
</div>
<!-- FROM RIGHT TO LEFT -->
<div class="relative h-[500px] border-2 border-black">
<!-- image -->
<div class="absolute inset-y-0 right-0 w-1/2 bg-red-300">
<img src="https://picsum.photos/id/237/1500/1500" class="h-full w-full object-cover object-center" alt="" />
</div>
<!-- container -->
<div class="mx-auto flex h-full max-w-6xl justify-start border-2 border-green-500">
<div class="w-1/2">Content ...</div>
</div>
</div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li id="selected">6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ul>
<?php
// https://blog.martinhujer.cz/clever-way-to-sort-php-arrays-by-multiple-values/
// https://stackoverflow.com/questions/2699086/how-to-sort-a-multi-dimensional-array-by-value
// COMPLEX: https://stackoverflow.com/questions/17364127/how-can-i-sort-arrays-and-data-in-php
// https://stackoverflow.com/questions/44309585/properly-sorting-multidimensional-array-using-usort-and-spaceship-operator/44309755#44309755
// 1)
// order products by: price ASC, inStock DESC, isRecommended DESC, name ASC
usort($products, function (Product $a, Product $b): int {
return
($a->getPrice() <=> $b->getPrice()) * 1000 + // price ASC
($b->isInStock() <=> $a->isInStock()) * 100 + // inStock DESC
($b->isRecommended() <=> $a->isRecommended()) * 10 + // isRecommended DESC
($a->getName() <=> $b->getName()); // name ASC
});
// 2)
// order products by: price ASC, inStock DESC, isRecommended DESC, name ASC
usort($products, fn (Product $a, Product $b): int =>
($a->getPrice() <=> $b->getPrice()) * 1000 + // price ASC
($b->isInStock() <=> $a->isInStock()) * 100 + // inStock DESC
($b->isRecommended() <=> $a->isRecommended()) * 10 + // isRecommended DESC
($a->getName() <=> $b->getName()) // name ASC
);
// 3)
usort($products, fn (Product $a, Product $b): int =>
[$a->getPrice(), $b->isInStock(), $b->isRecommended(), $a->getName()]
<=>
[$b->getPrice(), $a->isInStock(), $a->isRecommended(), $b->getName()]
);
usort($myArray, function($a, $b) {
$retval = $a['order'] <=> $b['order'];
if ($retval == 0) {
$retval = $a['suborder'] <=> $b['suborder'];
if ($retval == 0) {
$retval = $a['details']['subsuborder'] <=> $b['details']['subsuborder'];
}
}
return $retval;
});
<?php
// https://stackoverflow.com/questions/173868/how-to-get-a-files-extension-in-php
$ext = end(explode('.', $filename));
$ext = substr(strrchr($filename, '.'), 1);
$ext = substr($filename, strrpos($filename, '.') + 1);
$ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filename);
$ext = strrchr($filename, '.');
$ext = pathinfo($filename, PATHINFO_EXTENSION)['extension'];
$ext = (new SplFileInfo($path))->getExtension();
$exts = split("[/\\.]", $filename);
$n = count($exts)-1;
$ext = $exts[$n];
<?php
$states = ['Přijatá', 'Nová', 'K zaplacení', 'Zaplaceno', 'Expedováno', 'Doručeno'];
$currentState = isset($_GET['state']) ? $_GET['state'] : 'K zaplacení';
$totalStates = count($states);
$currentIndex = array_search($currentState, $states);
$prev = null;
$next = null;
$prevAll = [];
$nextAll = [];
foreach ($states as $index => $state) {
if ($index < $currentIndex) {
$prev = $state;
$prevAll[] = $state;
}
if ($index > $currentIndex && $next === null) {
$next = $state;
}
if ($index > $currentIndex) {
$nextAll[] = $state;
}
}
$meta = [
'prev' => $prev, // predchozi stav vuci aktualnimu ...
'prevAll' => $prevAll, // vsechny predchozi vuci aktualnimu ...
'next' => $next, // nasledujici stav vuci aktualnimu
'nextAll' => $nextAll, // vsechny nasledujici po aktualnim
'currentStateNumber' => $currentIndex, // aktualni cislo stavu, K zaplaceni => 2, Doručeno => 6 atd.
'totalStates' => $totalStates, // celkovy pocet stavu, tj. 6
];
echo '<pre>';
print_r($meta);
<?php
$states = ['Přijatá', 'Nová', 'K zaplacení', 'Zaplaceno', 'Expedováno', 'Doručeno'];
$currentState = isset($_GET['state']) ? $_GET['state'] : 'K zaplacení';
$totalStates = count($states);
$currentIndex = array_search($currentState, $states);
$prev = null;
$next = null;
$prevAll = [];
$nextAll = [];
foreach ($states as $index => $state) {
if ($index < $currentIndex) {
$prev = $state;
$prevAll[] = $state;
}
if ($index > $currentIndex && $next === null) {
$next = $state;
}
if ($index > $currentIndex) {
$nextAll[] = $state;
}
}
$meta = [
'prev' => $prev, // predchozi stav vuci aktualnimu ...
'prevAll' => $prevAll, // vsechny predchozi vuci aktualnimu ...
'next' => $next, // nasledujici stav vuci aktualnimu
'nextAll' => $nextAll, // vsechny nasledujici po aktualnim
'currentStateNumber' => $currentIndex, // aktualni cislo stavu, K zaplaceni => 2, Doručeno => 6 atd.
'totalStates' => $totalStates, // celkovy pocet stavu, tj. 6
];
echo '<pre>';
print_r($meta);
/*!
* getUniqueClass - v1.1 - 2/13/2010
* http://benalman.com/projects/jquery-misc-plugins/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// For when you really need a unique classname, (like when you're cloning a
// whole bunch of elements and don't exactly know where they're going, but need
// to do something with them after they've gotten there).
jQuery.getUniqueClass = function() {
var name, i = 0;
while ( jQuery('.' + (name = 'BA-' + (+new Date) + (i++))).length ) { };
return name;
};
// 2 my
let s = '.test'
let name, i = ''
while (document.querySelector(name = s + i)) {
i += 0
i++
}
document.write(name)
<?php
// 1
do {
$name = time() . rand(1,10);
$name = "scr_" . substr(md5($name),0,8);
$path = "images/screenshots/fullsize/" . $name . ".jpg";
} while (file_exists($path));
// 2
while ($parent = $node->getParent()) {
array_unshift($parents, $parent);
$node = $parent;
}
$arr = ['name', 'name0', 'name1', 'name2'];
// 3
$i = 0;
$name = 'name';
while (in_array($newName = $name. $i++, $arr)) {
}
echo $newName;
<?php
public function createComponentOrderReview()
{
return $this->getPresenter()->getControlFactory()->create($this, 'orderReview', [
'order' => $this->getOrder()
]);
}
// from same category
public function createComponentSameCategoryProducts()
{
$config = $this->getCurrentConfig();
$product = $this->getProduct();
$component = parent::createComponent($config['category_list_component']);
$component->setConfig([
'except_ids' => [
$product::INHERITED ? $product->product_id : $product->id,
$product->item__product_id,
$product->inherit__product_id
],
'navigation_id' => $product->getMainCat()->id,
'default_filter' => []
]);
return $component;
}