Примечание: Невозможно связать два свежесозданных объекта Active Record.
ModalAssets::register($this->getView());
в метод run();
public function init()
{
$this->sourcePath = __DIR__ . '/assets';
parent::init();
}
assets /* js and css */
view /* view widget */
ModalWidget.php
ModalAssets.php
public $js = [
'/js/modal.js'
]
$imapPath = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$username = 'login@gmail.com';
$password = 'password';
$inbox = imap_open($imapPath,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
// Тут главное действие, поиск в папке "Входящие"
$emails = imap_search($inbox,'TEXT "yii"'); // найти письма с текстом "yii"
// или
$emails = imap_search($inbox,'FROM "exsample@mail.com"'); // письма с определённым адресом
ALL - return all messages matching the rest of the criteria
ANSWERED - match messages with the \\ANSWERED flag set
BCC "string" - match messages with "string" in the Bcc: field
BEFORE "date" - match messages with Date: before "date"
BODY "string" - match messages with "string" in the body of the message
CC "string" - match messages with "string" in the Cc: field
DELETED - match deleted messages
FLAGGED - match messages with the \\FLAGGED (sometimes referred to as Important or Urgent) flag set
FROM "string" - match messages with "string" in the From: field
KEYWORD "string" - match messages with "string" as a keyword
NEW - match new messages
OLD - match old messages
ON "date" - match messages with Date: matching "date"
RECENT - match messages with the \\RECENT flag set
SEEN - match messages that have been read (the \\SEEN flag is set)
SINCE "date" - match messages with Date: after "date"
SUBJECT "string" - match messages with "string" in the Subject:
TEXT "string" - match messages with text "string"
TO "string" - match messages with "string" in the To:
UNANSWERED - match messages that have not been answered
UNDELETED - match messages that are not deleted
UNFLAGGED - match messages that are not flagged
UNKEYWORD "string" - match messages that do not have the keyword "string"
UNSEEN - match messages which have not been read yet
[
'class' => 'yii\grid\ActionColumn',
'buttons' => [
'update' => function($name, $model, $key){
return Html::a('<i class="fa fa-plus fa-lg" aria-hidden="true"></i>', ['update']);
}
]
]
php yii serve
Server started on http://localhost:8080/
Document root is "/home/slonik/localhost/www/test.loc/yii2_test/web"
Quit the server with CTRL-C or COMMAND-C.
http://localhost:8080/index-test.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'' => 'site/index',
'<_a:(contact|about)>' => 'site/<_a>',
'<_a:(login|logout|sign-up)>' => 'users/<_a>',
'<_c:[-\w]+>/<_a:[-\w]+>' => '<_c>/<_a>',
'<_c:[-\w]+>' => '<_c>/index',
'<_a:(offline)>' => 'offline/index',
],
],
'urlManager' => [
'showScriptName' => true,
],
<?php
yii\widgets\Pjax::begin(['id' => 'new_note', 'enablePushState' => false]) ?>
<?= Html::beginForm(['/system/system/fastsearch'], 'post', ['data-pjax' => '1','enctype' => 'multipart/form-data', 'class'=>'form-inline' ]) ?>
<?= Html::input('text', 'search', "", ['class' => "form-control form-control-sm ml-3 w-75"]) ?>
<?= Html::submitButton('<i class="glyphicon glyphicon-search"></i> Найти', ['class' => 'btn btn-default', 'id'=>'press_search'])?>
<?= Html::endForm() ?>
<div id="reload-pjax"><?= $search ?? null ?></div>
<?php Pjax::end();
?>
public function actionFastsearch()
{
if(Yii::$app->request->isAjax){
$search = Yii::$app->request->post('search');
return $this->render('index', ['search' => $search]);
}
}
<?php
Pjax::widget([
'id' => 'reload-pjax',
'enablePushState' => false,
'enableReplaceState' => false,
'formSelector' => '#options-form',
'submitEvent' => 'submit',])
?>
<?= Html::beginForm(['/site/fastsearch'],
'post',
[
'class'=>'form-inline',
'id' => 'options-form'
]) ?>
<?= Html::input('text', 'search', "", ['class' => "form-control form-control-sm ml-3 w-75"]) ?>
<?= Html::submitButton('<i class="glyphicon glyphicon-search"></i> Найти', ['class' => 'btn btn-default', 'id'=>'press_search'])?>
<?= Html::endForm() ?>
<div id="reload-pjax"></div>
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2-imap
sudo service apache2 restart
$imap = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', 'login', 'password');
$emails = imap_search($imap, 'ALL');
if($emails){
echo count($emails);
}
imap_close($imap);
$str = "IEEE 802.11a, IEEE 802.11ac, IEEE 802.11b, IEEE 802.11g, IEEE 802.11n";
preg_match_all('#([\d.]+)([a-z]{1,})#', $str, $matches);
array_multisort(array_map('strlen', $matches['2']), $matches['2']);
echo $matches['1']['0'] . implode('/', $matches['2']);
802.11a/b/g/n/ac
query = Yii::$app->db->createCommand("SELECT *, DATE_FORMAT(".Cars::tableName().".car_created_date,'%m') as mouth From `cars` WHERE `status` = 3 LIMIT 2")->queryAll();
Если провожу поиск, то контроллер закономерно ругается, что отсутствуют обязательные параметры: course_id.
Есть ли возможно сделать админа без заморочек
Как мне сделать, чтобы регулярка не игнорировала кириллицу?
$html = '<td>
<b>3. Первый тег B</b>
</td>
<td>
<a title="More..." href="/ссылка">
<b>текст Второй тег B</b>
</a>
</td>
<td align=right>
<b>VIP Третий тег B</b>
</td>';
$dom = new DomDocument();
$dom->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'.$html);
$finder = new DomXPath($dom);
$elements = $finder->query(".//b");
foreach($elements as $element){
//print_r($element);
echo PHP_EOL . $element->nodeValue;
}
3. Первый тег B
текст Второй тег B
VIP Третий тег B