コード例 #1
0
 public function test_characterLimiter()
 {
     $str = "This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is";
     $result = characterLimiter($str, 10);
     $expected = 'This is a...';
     $this->assertEquals($expected, $result);
 }
コード例 #2
0
ファイル: NewsSocials.php プロジェクト: mmorpg2015/ghtweb5
 public function init()
 {
     Yii::beginProfile(__CLASS__);
     $path = Yii::getPathOfAlias('app.widgets.NewsSocials.libs.share42');
     $assetsUrl = app()->getAssetManager()->publish($path, FALSE, -1, YII_DEBUG);
     js($assetsUrl . '/share42.js', CClientScript::POS_END);
     // Обрезаю description
     if (!empty($this->params['data-description'])) {
         $this->params['data-description'] = strip_tags($this->params['data-description']);
         if (mb_strlen($this->params['data-description']) > $this->charLimit) {
             $this->params['data-description'] = characterLimiter($this->params['data-description'], $this->charLimit, ' ...');
         }
     }
     echo CHtml::openTag('div', $this->params + array('class' => 'share42init')) . CHtml::closeTag('div');
     Yii::endProfile(__CLASS__);
 }
コード例 #3
0
ファイル: forum-threads.php プロジェクト: mmorpg2015/ghtweb5
    ?>
    <?php 
    echo $error;
} else {
    ?>
    
    <ul class="list-unstyled">
        <?php 
    foreach ($content as $row) {
        ?>
            <li>
                <a class="title" href="<?php 
        echo $row['theme_link'];
        ?>
" target="_blank"><?php 
        echo characterLimiter($row['title'], config('forum_threads.characters_limit'));
        ?>
</a>
                <span>Автор:</span> <a href="<?php 
        echo $row['user_link'];
        ?>
" target="_blank"><?php 
        echo e($row['starter_name']);
        ?>
</a>
                <span class="date"><span>Дата: </span><?php 
        echo $row['start_date'];
        ?>
</span><br>
            </li>
        <?php