コード例 #1
1
ファイル: Page.php プロジェクト: rocketyang/hasscms-app
 public function getMetaData()
 {
     $model = $this->getMetaModel();
     $title = $model->title ?: $this->title;
     $description = $model->description ?: StringHelper::truncate(strip_tags($this->content), 200);
     return [$title, $description, $model->keywords];
 }
コード例 #2
0
 /**
  * @inheritDoc
  */
 public function formatConversation($model)
 {
     $model = parent::formatConversation($model);
     $model['date'] = DateHelper::formatConversationDate($model['created_at']);
     $model['text'] = StringHelper::truncate($model['text'], 20);
     return $model;
 }
コード例 #3
0
 private function checkForNews()
 {
     try {
         $response = (new Client())->createRequest()->setUrl($this->getCurrentFeed()->url)->send();
         if (!$response->isOk) {
             throw new \Exception();
         }
         $rss = simplexml_load_string($response->getContent());
         $newItemsCount = 0;
         foreach ($rss->channel->item as $item) {
             if (!NewModel::findOne(['feed' => $this->getCurrentFeed()->id, 'url' => (string) $item->link])) {
                 $new = new NewModel();
                 $new->feed = $this->getCurrentFeed()->id;
                 $new->published_at = date_create_from_format(\DateTime::RSS, (string) $item->pubDate)->format('Y-m-d H:i:s');
                 $new->title = (string) $item->title;
                 if (isset($item->description)) {
                     $new->short_text = StringHelper::truncate(strip_tags((string) $item->description), 250);
                 }
                 $new->url = (string) $item->link;
                 if ($new->save()) {
                     $newItemsCount++;
                 }
             }
         }
         if ($newItemsCount > 0) {
             \Yii::$app->session->addFlash('info', \Yii::t('user', 'Get news: ') . $newItemsCount);
             $this->clearOldNewsIfNeed();
             \Yii::$app->cache->delete($this->getNewsCacheKey());
             \Yii::$app->cache->delete($this->getFeedsCacheKey());
         }
     } catch (Exception $e) {
         \Yii::$app->session->addFlash('danger', \Yii::t('user', 'Get news error'));
     }
 }
コード例 #4
0
ファイル: Posts.php プロジェクト: developer-av/yii2-blog
 public static function Preview($models)
 {
     foreach ($models as $key => $model) {
         $models[$key]['text'] = StringHelper::truncate(strip_tags($model['text']), 400);
     }
     return $models;
 }
コード例 #5
0
ファイル: TopMenu.php プロジェクト: kangqf/kblog_with_yii2
 /**
  * @return array
  * 构建登录栏数据
  */
 private function userInfo()
 {
     if (Yii::$app->getUser()->isGuest) {
         $userInfo = [['label' => '登录', 'url' => $user = Yii::$app->getUser()->loginUrl], ['label' => '注册', 'url' => Yii::$app->params['registerUrl']]];
     } else {
         $userInfo = [['label' => StringHelper::truncate(Yii::$app->user->identity->username, 5), 'active' => false, 'url' => ['/'], 'items' => [['label' => '个人资料', 'url' => '#'], ['label' => '退出', 'url' => ['/signout']]]]];
     }
     return $userInfo;
 }
コード例 #6
0
ファイル: Upload.php プロジェクト: radiegtya/easyii
 static function getFileName($fileInstanse, $namePostfix = true)
 {
     $baseName = str_ireplace('.' . $fileInstanse->extension, '', $fileInstanse->name);
     $fileName = StringHelper::truncate(Inflector::slug($baseName), 32, '');
     if ($namePostfix || !$fileName) {
         $fileName .= ($fileName ? '-' : '') . substr(uniqid(md5(rand()), true), 0, 10);
     }
     $fileName .= '.' . $fileInstanse->extension;
     return $fileName;
 }
コード例 #7
0
 /**
  * @inheritDoc
  */
 public function fields()
 {
     return ['lastMessage' => function ($model) {
         return ['text' => StringHelper::truncate($model['lastMessage']['text'], 20), 'date' => static::formatDate($model['lastMessage']['created_at']), 'senderId' => $model['lastMessage']['sender_id']];
     }, 'newMessages' => function ($model) {
         return ['count' => count($model['newMessages'])];
     }, 'contact' => function ($model) {
         return $model['contact'];
     }, 'loadUrl', 'sendUrl', 'deleteUrl', 'readUrl', 'unreadUrl'];
 }
コード例 #8
0
ファイル: News.php プロジェクト: radiegtya/easyii
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $settings = Yii::$app->getModule('admin')->activeModules['news']->settings;
         if ($this->short && $settings['enableShort']) {
             $this->short = StringHelper::truncate($this->short, $settings['shortMaxLength']);
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #9
0
ファイル: Post.php プロジェクト: rocketyang/hasscms-app
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert == true) {
             $this->status = StatusEnum::STATUS_ON;
         }
         $this->updateRevision();
         $this->short = StringHelper::truncate(empty($this->short) ? strip_tags($this->content) : $this->short, 200);
         return true;
     } else {
         return false;
     }
 }
コード例 #10
0
ファイル: Item.php プロジェクト: DenisCherniatev/easyii
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $settings = Yii::$app->getModule('admin')->activeModules['article']->settings;
         $this->short = StringHelper::truncate($settings['enableShort'] ? $this->short : strip_tags($this->text), $settings['shortMaxLength']);
         if (!$insert && $this->image != $this->oldAttributes['image'] && $this->oldAttributes['image']) {
             @unlink(Yii::getAlias('@webroot') . $this->oldAttributes['image']);
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #11
0
 /**
  * @inheritDoc
  */
 public function formatConversation($model)
 {
     $model['date'] = DateHelper::formatConversationDate($model['created_at']);
     $model['text'] = StringHelper::truncate($model['text'], 20);
     $model['new_messages'] = ArrayHelper::getValue($model, 'newMessages.count', 0);
     $model['contact'] = ArrayHelper::merge($model['contact'], $model['contact']['profile']);
     $model['deleteUrl'] = Url::to(['/' . $this->uniqueId . '/delete-conversation', 'contactId' => $model['contact']['id']]);
     $model['readUrl'] = Url::to(['/' . $this->uniqueId . '/mark-conversation-as-read', 'contactId' => $model['contact']['id']]);
     $model['unreadUrl'] = Url::to(['/' . $this->uniqueId . '/mark-conversation-as-unread', 'contactId' => $model['contact']['id']]);
     $model['loadUrl'] = Url::to(['/' . $this->uniqueId . '/messages', 'contactId' => $model['contact']['id']]);
     $model['sendUrl'] = Url::to(['/' . $this->uniqueId . '/create-message', 'contactId' => $model['contact']['id']]);
     ArrayHelper::remove($model, 'contact.profile');
     ArrayHelper::remove($model, 'newMessages');
     return $model;
 }
コード例 #12
0
ファイル: Item.php プロジェクト: radiegtya/easyii
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $settings = Yii::$app->getModule('admin')->activeModules['article']->settings;
         if ($this->short && $settings['enableShort']) {
             $this->short = StringHelper::truncate($this->short, $settings['shortMaxLength']);
         }
         if (!$this->isNewRecord && $this->thumb != $this->oldAttributes['thumb']) {
             @unlink(Yii::getAlias('@webroot') . $this->oldAttributes['thumb']);
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #13
0
ファイル: ApiIndexer.php プロジェクト: wangdimeng/yii2-apidoc
 /**
  * @param string $file
  * @param string $contents
  * @param string $basePath
  * @param string $baseUrl
  * @return array
  */
 protected function generateFileInfo($file, $contents, $basePath, $baseUrl)
 {
     // create file entry
     if (preg_match('~<h1>(.*?)</h1>~s', $contents, $matches)) {
         $title = str_replace('&para;', '', strip_tags($matches[1]));
     } elseif (preg_match('~<title>(.*?)</title>~s', $contents, $matches)) {
         $title = strip_tags($matches[1]);
     } else {
         $title = '<i>No title</i>';
     }
     if (preg_match('~<div id="classDescription">\\s*<strong>(.*?)</strong>~s', $contents, $matches)) {
         $description = strip_tags($matches[1]);
     } elseif (preg_match('~<p>(.*?)</p>~s', $contents, $matches)) {
         $description = StringHelper::truncate(strip_tags($matches[1]), 1000, '...', 'UTF-8');
     } else {
         $description = '';
     }
     return ['u' => $baseUrl . str_replace('\\', '/', substr($file, strlen(rtrim($basePath, '\\/')))), 't' => $title, 'd' => $description];
 }
コード例 #14
0
ファイル: SeoHelper.php プロジェクト: kotmonstr/kotmonstr
    public static function getMeta($arr = null)
    {
        if ($arr) {
            ?>
            <title><?php 
            echo Html::encode($arr->title);
            ?>
| kotmonstr.com | артефакты прошлого</title>
            <meta name="description"
                  content="<?php 
            echo Html::encode(StringHelper::truncate(isset($arr->content) ? $arr->content : $arr->title, 200));
            ?>
">
            <meta name="keywords"
                  content="Артефакты прошлого , альтернативная история , ведическая культура , ведическая библиотека">
        <?php 
        } else {
            $module = Yii::$app->controller->module->id;
            $controller = Yii::$app->controller->id;
            $action = Yii::$app->controller->action->id;
            $url = $module . '/' . $controller . '/' . $action;
            $meta = Seo::getPageMeta($url);
            //vd($meta);
            ?>
            <title><?php 
            echo $meta ? Html::encode($meta->title) : '| kotmonstr.com | артефакты прошлого<';
            ?>
</title>
            <meta name="description"
                  content="<?php 
            echo is_object($meta) ? Html::encode($meta->description) : 'kotmonstr.com | артефакты прошлого';
            ?>
">
            <meta name="keywords"
                  content="<?php 
            echo is_object($meta) ? Html::encode($meta->keywords) : 'kotmonstr.com | артефакты прошлого | альтернативная история | ведическая культура русов';
            ?>
">
            <?php 
        }
    }
コード例 #15
0
ファイル: FeedController.php プロジェクト: rocketyang/admap
 public function getFeed($mode)
 {
     $feedMethod = 'rss';
     if ($mode == self::RSS) {
         $feedMethod = 'rss';
     } elseif ($mode == self::ATOM) {
         $feedMethod = 'atom';
     }
     $feed = new \Zend\Feed\Writer\Feed();
     $feed->setTitle(Yii::t('app', 'Introduce business'));
     $feed->setDescription(Yii::t('app', 'Introduce business'));
     $feed->setLink(Yii::$app->getRequest()->getHostInfo());
     $feed->setFeedLink(Yii::$app->getRequest()->getAbsoluteUrl(), $feedMethod);
     $feed->setGenerator('Admap', Yii::$app->version, Yii::$app->getRequest()->getHostInfo());
     $feed->addAuthor(['name' => 'Jafaripur', 'email' => '*****@*****.**', 'uri' => 'http://www.jafaripur.ir']);
     $feed->setDateModified(time());
     //$feed->addHub('http://pubsubhubbub.appspot.com/');
     foreach ($this->getModel(50) as $adver) {
         $entry = $feed->createEntry();
         $entry->setId($adver['id']);
         $entry->setTitle(Html::encode($adver['title']));
         $entry->addCategory(['term' => Html::encode($adver['category']['name']), 'label' => Html::encode($adver['category']['name'])]);
         $entry->setLink(urldecode(Adver::generateLink($adver['id'], $adver['title'], $adver['category']['name'], $adver['country']['name'], $adver['province']['name'], $adver['city']['name'], $adver['address'], $adver['lang'], true)));
         /*$entry->addAuthor(array(
         			'name'  => 'Paddy',
         			'email' => '*****@*****.**',
         			'uri'   => 'http://www.example.com',
         		));*/
         $entry->setDateModified((int) $adver['updated_at']);
         $entry->setDateCreated((int) $adver['created_at']);
         $entry->setDescription(\yii\helpers\StringHelper::truncate(strip_tags($adver['description']), 140));
         //$entry->setContent ($description);
         $feed->addEntry($entry);
     }
     return $feed->export($feedMethod);
 }
コード例 #16
0
ファイル: view.php プロジェクト: jorry2008/turen
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\helpers\StringHelper;
/* @var $this yii\web\View */
/* @var $model common\models\cms\Img */
$length = Yii::$app->params['config']['config_site_title_length'];
$this->title = StringHelper::truncate($model->title, $length - 5);
$this->params['breadcrumbs'][] = ['label' => Yii::t('cms', 'Img List'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="row">
    <div class="col-md-12">
        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li data-original-title="<?php 
echo Yii::t('common', 'Click') . '(' . Yii::t('common', 'Index') . ')';
?>
" data-toggle="tooltip">
                    <?php 
echo Html::a(Yii::t('common', 'Index'), ['index']);
?>
               </li>
               <li data-original-title="<?php 
echo Yii::t('common', 'Click') . '(' . Yii::t('common', 'Create') . ')';
?>
" data-toggle="tooltip">
                    <?php 
echo Html::a(Yii::t('common', 'Create'), ['create']);
コード例 #17
0
 /**
  * @param \yii\base\Event $event
  * @return string
  */
 protected function getValue($event)
 {
     $stripped = strip_tags($this->owner->{$this->contentCompiled});
     return StringHelper::truncate($stripped, $this->length, '...', null, true);
 }
コード例 #18
0
ファイル: index.php プロジェクト: phplego/easyii
        }
        ?>
                <td>
                    <?php 
        if ($item->new) {
            ?>
                        <span class="label label-warning">NEW</span>
                    <?php 
        }
        ?>
                    <a href="<?php 
        echo Url::to(['/admin/' . $module . '/a/view', 'id' => $item->primaryKey]);
        ?>
">
                        <?php 
        echo $item->title != '' ? $item->title : StringHelper::truncate($item->text, 120, '...');
        ?>
                    </a>
                </td>
                <td><?php 
        echo Yii::$app->formatter->asDatetime($item->time, 'short');
        ?>
</td>
                <td>
                    <?php 
        if ($item->answer != '') {
            ?>
                        <span class="text-success"><?php 
            echo Yii::t('easyii', 'Yes');
            ?>
</span>
コード例 #19
0
ファイル: index.php プロジェクト: kotmonstr/gitar
            <div class="row">
<div class="review-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Создать отзыв', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'message', 'format' => 'html', 'value' => function ($dataProvider) {
    return StringHelper::truncate($dataProvider->message, 50);
}], ['attribute' => 'created_at', 'format' => 'html', 'value' => function ($dataProvider) {
    return date("d.m.Y H:i:s", $dataProvider->created_at);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
</div>
</div>
</div>
</div>
コード例 #20
0
ファイル: _item.php プロジェクト: rocketyang/yii2-starter-kit
        <div class="article-meta">
            <span class="article-date">
                <?php 
echo Yii::$app->formatter->asDatetime($model->created_at);
?>
            </span>,
            <span class="article-category">
                <?php 
echo Html::a($model->category->title, ['index', 'ArticleSearch[category_id]' => $model->category_id]);
?>
            </span>
        </div>
        <div class="article-content">
            <?php 
if ($model->thumbnail_path) {
    ?>
                <?php 
    echo Html::img(Yii::$app->glide->createSignedUrl(['glide/index', 'path' => $model->thumbnail_path, 'w' => 100], true), ['class' => 'article-thumb img-rounded pull-left']);
    ?>
            <?php 
}
?>
            <div class="article-text">
                <?php 
echo \yii\helpers\StringHelper::truncate($model->body, 150, '...', null, true);
?>
            </div>
        </div>
    </div>
</div>
コード例 #21
0
ファイル: index.php プロジェクト: jorry2008/turen
?>
                        
                    <!-- 
                        <p>
                            <?php 
echo Html::a(Yii::t('cms', 'Create Ad'), ['create'], ['class' => 'btn btn-success']);
?>
                        </p>
                     -->
            		<?php 
Pjax::begin();
?>
					<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'options' => ['class' => 'grid-view box-body table-responsive no-padding'], 'tableOptions' => ['class' => 'table table-hover table-striped table-bordered'], 'headerRowOptions' => [], 'footerRowOptions' => [], 'showHeader' => true, 'showFooter' => false, 'layout' => "{summary}\n{errors}\n{items}\n{pager}", 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'format' => 'raw', 'value' => function ($model) {
    $length = Yii::$app->params['config']['config_site_title_length'];
    $title = StringHelper::truncate($model->title, $length);
    return Html::a($title, ['update', 'id' => $model->id], ['data-pjax' => '0']);
}], 'short_code', ['attribute' => 'ad_type_id', 'filter' => ArrayHelper::map(AdType::find()->alive()->all(), 'id', 'name'), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    return $model->adType->name;
}], ['attribute' => 'mode', 'format' => 'raw', 'filter' => Ad::getAdMode(), 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $modes = Ad::getAdMode();
    return empty($modes[$model->mode]) ? '' : $modes[$model->mode];
}], ['attribute' => 'order', 'format' => 'raw', 'value' => function ($model) {
    return Html::activeTextInput($model, 'order', ['style' => 'width:50px', 'data-id' => $model->id, 'id' => '', 'class' => 'cms-order']);
}], ['attribute' => 'status', 'format' => 'html', 'filter' => [Ad::STATUS_YES => Yii::t('cms', 'Yes'), Ad::STATUS_NO => Yii::t('cms', 'No')], 'filterInputOptions' => ['class' => 'form-control', 'id' => null, 'prompt' => Yii::t('common', 'All')], 'value' => function ($model) {
    $on = Html::a('<small class="label bg-green">' . Yii::t('common', 'Yes') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    $off = Html::a('<small class="label bg-red">' . Yii::t('common', 'No') . '</small>', ['switch-status', 'id' => $model->id], ['title' => Yii::t('cms', 'Update Status'), 'data-pjax' => '0']);
    return $model->status ? $on : $off;
}], 'created_at:datetime', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'header' => Yii::t('common', 'Opration')]]]);
?>
					<?php 
コード例 #22
0
ファイル: _item.php プロジェクト: jorry2008/turen
    Html::addCssStyle($options, ['color' => $model->colorval, 'font-weight' => $model->boldval]);
}
?>
    	<?php 
echo Html::a(StringHelper::truncate($model->title, $length), ['/site/post/view', 'id' => $model->id], ['class' => 'title', 'title' => $model->title, 'style' => $options['style']]);
?>
        
        <div class="cont">
        	<?php 
if (empty($model->description)) {
    $des = $model->content;
    //去除图片链接
} else {
    $des = $model->description;
}
echo StringHelper::truncate(strip_tags($des), $dlength);
?>
            <?php 
echo Html::a('详情', ['/site/post/view', 'id' => $model->id], ['rel' => 'nofollow']);
?>
        </div>
        
        <div class="ft clearfix">
            <span class="fl">[<?php 
echo Html::encode($columnModel->name);
?>
]</span>
            <div class="fr">
                <span class="date"><?php 
echo Yii::$app->getFormatter()->asDate($model->publish_at);
?>
コード例 #23
0
ファイル: usageOverview.php プロジェクト: czechcamus/dasport
<div class="row">
	<?php 
$device = $periodModel->device;
for ($i = Yii::$app->formatter->asTimestamp($periodModel->firstDate); $i <= Yii::$app->formatter->asTimestamp($periodModel->lastDate); $i += 86400) {
    if ($plan = Plan::find()->where(['device_id' => $device->id])->andWhere(['<=', 'date_from', date('Y-m-d', $i)])->andWhere(['>=', 'date_to', date('Y-m-d', $i)])->one()) {
        if ($day = Day::find()->where(['plan_id' => $plan->id])->andWhere(['day_nr' => date('N', $i)])->one()) {
            if ($day->is_open == 1) {
                echo '<div class="col-xs-6 col-md-4 col-lg-3"><table class="table table-bordered table-striped table-condensed">';
                echo '<tr><th colspan="3">' . $day->getDayName() . ' ' . date('d.m.Y', $i) . '</th></tr>';
                for ($j = strtotime(date('Y-m-d', $i) . ' ' . $plan->time_from), $k = 1; $j < strtotime(date('Y-m-d', $i) . ' ' . $plan->time_to); $j += $plan->hour_length * 60) {
                    if (date('H:i', $j) >= date('H:i', strtotime($day->time_from)) && date('H:i', $j) < date('H:i', strtotime($day->time_to))) {
                        $usage = Usage::find()->where(['device_id' => $device->id])->andWhere(['date' => date('Y-m-d', $i)])->andWhere(['hour_nr' => $k])->one();
                        echo '<tr' . ($usage ? ' class="used"' : '') . '>';
                        echo '<td style="width: 3em;">' . date('H:i', $j) . '</td>';
                        echo '<td>' . ($usage ? Html::tag('span', StringHelper::truncate($usage->subject->name, 12), ['data' => ['toggle' => 'tooltip', 'placement' => 'top', 'html' => true, 'title' => $usage->subject->name . '<br />' . $usage->subject->email . '<br />' . $usage->subject->phone]]) : '&nbsp;') . '</td>';
                        echo '<td style="text-align: center; width: 4em;">';
                        if ($usage) {
                            echo Html::a('<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>', ['/reservation/usage/update', 'plan_id' => $plan->id, 'id' => $usage->id], ['title' => Module::t('res', 'Update usage'), 'class' => 'btn btn-link', 'style' => 'padding: 0;']);
                            echo Html::a('<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>', ['/reservation/usage/delete', 'plan_id' => $plan->id, 'id' => $usage->id], ['title' => Module::t('res', 'Delete usage'), 'class' => 'btn btn-link', 'style' => 'padding: 0;', 'data-confirm' => Module::t('res', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
                        } else {
                            echo Html::a('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>', ['/reservation/usage/create', 'plan_id' => $plan->id, 'date' => date('Y-m-d', $i), 'hour_nr' => $k], ['title' => Module::t('res', 'Add usage'), 'class' => 'btn btn-link', 'style' => 'padding: 0;']);
                        }
                        echo '</td>';
                        echo '</tr>';
                    } else {
                        echo '<tr><td colspan="3" style="text-align: center;"><span class="glyphicon glyphicon-minus btn" aria-hidden="true" style="padding: 0; cursor: default;"></span></td></tr>';
                    }
                    ++$k;
                }
                echo '</table></div>';
コード例 #24
0
ファイル: cities.php プロジェクト: HAJIOM/yii2
    ?>
<div class="container-fluid row bg-info show-grid">
    <a href="<?php 
    echo Yii::$app->urlManager->createUrl(['site/city', 'city' => $city->id]);
    ?>
"><img class="img-thumbnail left" width="100" src="./image/city/<?php 
    echo Html::encode("{$city->img}");
    ?>
" alt=""></a>
                    <a href="<?php 
    echo Yii::$app->urlManager->createUrl(['site/city', 'city' => $city->id]);
    ?>
"><h1><?php 
    echo Html::encode("{$city->title}");
    ?>
</h1></a>
                    <p><?php 
    echo StringHelper::truncate(Html::encode("{$city->about}"), 400, '...');
    ?>
</p>
                    <p class="right"><b>Просмотров: <?php 
    echo $city->views;
    ?>
</b></p>
    </div>
    <?php 
}
echo LinkPager::widget(['pagination' => $pagination]);
?>

コード例 #25
0
ファイル: Client.php プロジェクト: yiisoft/yii2-httpclient
 /**
  * Composes the log/profiling message token for the given HTTP request parameters.
  * This method should be used by transports during request sending logging.
  * @param string $method request method name.
  * @param string $url request URL.
  * @param array $headers request headers.
  * @param string $content request content.
  * @return string log token.
  */
 public function createRequestLogToken($method, $url, $headers, $content)
 {
     $token = strtoupper($method) . ' ' . $url;
     if (!empty($headers)) {
         $token .= "\n" . implode("\n", $headers);
     }
     if ($content !== null) {
         $token .= "\n\n" . StringHelper::truncate($content, $this->contentLoggingMaxSize);
     }
     return $token;
 }
コード例 #26
0
ファイル: OpenUser.php プロジェクト: kangqf/kblog_with_yii2
 /**
  * 名称存在则将名称加上openid
  */
 protected function checkUserName()
 {
     if (User::findByUsername($this->username)) {
         $this->username .= StringHelper::truncate($this->openId, 5);
     }
 }
コード例 #27
0
ファイル: index.php プロジェクト: black-lamp/yii2-articles
                                <td>
                                    <?php 
        if (!empty($article->category)) {
            ?>
                                        <?php 
            echo Html::a($article->category->translation->name, ['/articles/category/save', 'categoryId' => $article->category->id, 'languageId' => Language::getCurrent()->id]);
            ?>
                                    <?php 
        }
        ?>
                                </td>

                                <td>
                                    <?php 
        echo StringHelper::truncate(strip_tags($article->translation->short_text), 30, '...');
        ?>
                                </td>

                                <td>
                                    <?php 
        if (count($languages) > 1) {
            ?>
                                        <?php 
            $translations = ArrayHelper::index($article->translations, 'language_id');
            ?>
  
                                        <?php 
            foreach ($languages as $language) {
                ?>
                                            <a href="<?php 
コード例 #28
0
ファイル: _best.php プロジェクト: kotmonstr/full-shop
                            <div class="productinfo text-center">
                                <img src="<?php 
        echo '/upload/goods/' . $best->image;
        ?>
" alt="<?php 
        echo $best->item;
        ?>
"/>

                                <h2>$<?php 
        echo $best->price;
        ?>
</h2>

                                <p><?php 
        echo StringHelper::truncate($best->item, 20);
        ?>
</p>
                                <a href="javascript:void(0);" onclick="addToCart(<?php 
        echo $best->id;
        ?>
)" class="btn btn-default add-to-cart"><i
                                        class="fa fa-shopping-cart"></i>В корзину</a>
                            </div>

                        </div>
                    </div>
                </div>

            <?php 
    }
コード例 #29
0
ファイル: view.php プロジェクト: knyazushka/z34lot.new
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\admin\Module;
use yii\bootstrap\Tabs;
use yii\helpers\StringHelper;
use app\modules\admin\components\widgets\AdminBoxWidget;
/* @var $this yii\web\View */
/* @var $model app\modules\main\models\Article */
$this->title = StringHelper::truncate($model->title, 50);
$this->params['breadcrumbs'][] = ['label' => Module::t('app', 'ADMIN'), 'url' => ['default/index']];
$this->params['breadcrumbs'][] = ['label' => Module::t('app', 'ADMIN_ARTICLE'), 'url' => ['index']];
$this->params['breadcrumbs'][] = StringHelper::truncate($model->title, 20);
?>
<div class="article-view">

    <?php 
AdminBoxWidget::begin(['type' => AdminBoxWidget::TYPE_PRIMARY, 'title' => Html::a('<i class="fa fa-pencil-square-o"></i>' . ' ' . Module::t('app', 'BUTTON_UPDATE'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary btn-xs']) . ' ' . Html::a('<i class="fa fa-trash-o"></i>' . ' ' . Module::t('app', 'BUTTON_DELETE'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger btn-xs', 'data' => ['confirm' => Module::t('app', 'CONFIRM_DELETE'), 'method' => 'post']]), 'left_tools' => 'Количество просмотров статьи: <strong>' . $model->click . '</strong>', 'footer' => '<strong>Статья созана:</strong> ' . Yii::$app->formatter->asDatetime($model->created_at) . '<br/>' . '<strong>Статья обновлена:</strong> ' . Yii::$app->formatter->asDatetime($model->updated_at) . '<br/>' . '<i class="fa fa-link"></i>&nbsp;<code>' . Yii::$app->urlManager->createAbsoluteUrl(['main/default/view', 'alt_title' => $model->alt_title]) . '</code>']);
?>

    <?php 
echo Tabs::widget(['items' => [['label' => 'Основная информация', 'content' => DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'category_id', 'format' => 'html', 'value' => Html::a($model->category->title, ['category/view', 'id' => $model->category->id], ['target' => 'blank'])], 'title', ['attribute' => 'alt_title', 'format' => 'html', 'value' => Html::decode('<strong>' . $model->alt_title . '</strong>') . '<br/>' . $model->getArticleUrl()], ['attribute' => 'author_id', 'format' => 'html', 'value' => Html::a($model->author->username, ['user/view', 'id' => $model->author->id], ['target' => 'blank'])], ['attribute' => 'status', 'format' => 'html', 'value' => $model->getArticleStatusSwitch()], 'tags', ['attribute' => 'anons_img', 'format' => 'html', 'value' => Html::img(Yii::$app->request->baseUrl . $model->anons_img, ['class' => 'img-responsive'])], 'anons:ntext', 'post:ntext']]), 'active' => true], ['label' => 'Рендер статьи', 'content' => $this->render('_article', ['model' => $model])]]]);
?>

    <?php 
AdminBoxWidget::end();
?>

</div>
コード例 #30
0
 public function actionEdit()
 {
     $id = (int) \Yii::$app->request->get('id');
     $link_info = FriendLink::find()->select(['id', 'link_name', 'link_url', 'link_logo', 'show_order'])->where('id=' . $id)->asArray()->one();
     //标记是图片还是文字连接
     if (!empty($link_info['link_logo'])) {
         $type = 'img';
         $link_logo = $link_info['link_logo'];
     } else {
         $type = 'chara';
         $link_logo = '';
     }
     $link_info['link_name'] = StringHelper::truncate($link_info['link_name'], 250, '');
     return $this->render('friend_info', ['action' => 'edit', 'form_act' => 'update', 'type' => $type, 'link_logo' => $link_logo, 'arrLink' => $link_info]);
 }