<?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;
}
<?php
if (count($recipients)) {
$this->connection->table('mail_queue_recipient')->insert(array_map(function ($email) use ($queueRow) {
return [
'mail_queue_id' => $queueRow->id,
'email' => $email,
];
}, $recipients));
}
<!-- 1. Automatic init function calls -->
<div x-data="{
init() {
console.log('Here we go!')
}
}"></div>
<!-- 2. Clean up after yourself with destroy -->
<div x-data="{
init() {
carouselLibrary.create();
},
destroy() {
carouselLibrary.delete();
}
}"></div>
<!-- 3. Interact with global stores from external JavaScript -->
Alpine.store('counter', {
count: 0
})
// In a different file or area.
Alpine.store('counter').count += 1
<!-- 4. Independent x-init directives -->
<div x-data>
<p x-init="console.log('I am ready!')"></p>
</div>
<img src="..." x-init="doSomeMagicHere()">
<!-- 5. Unfurl / unwrap Proxy with Alpine.raw -->
<div x-data="{ user: { name: 'Ryan' } }" x-init="console.log(user)">
<!-- This produces a `Proxy` in the console -->
</div>
<div x-data="{ user: { name: 'Ryan' } }" x-init="console.log(Alpine.raw(user))">
<!-- This produces the "real" `user` object in the console -->
</div>
{var $mailData = $control->lookup('App\FrontModule\Components\MailTemplateWrapper')->template}
{var $settings = $presenter->getContext()->getByType(App\EshopModule\Model\Settings::class)->getSetting()}