Beispiel #1
1
 public function run()
 {
     if ($this->encode) {
         $this->text = Html::encode($this->text);
     }
     if (!$this->minimal) {
         $maxOembedCount = 3;
         // Maximum OEmbeds
         $oembedCount = 0;
         // OEmbeds used
         $this->text = preg_replace_callback('/(https?:\\/\\/.*?)(\\s|$)/i', function ($match) use(&$oembedCount, &$maxOembedCount) {
             // Try use oembed
             if ($maxOembedCount > $oembedCount) {
                 $oembed = UrlOembed::GetOembed($match[0]);
                 if ($oembed) {
                     $oembedCount++;
                     return $oembed;
                 }
             }
             return Html::a($match[1], Html::decode($match[1]), array('target' => '_blank')) . $match[2];
         }, $this->text);
     }
     // get user and space details from guids
     $this->text = self::translateMentioning($this->text, $this->minimal ? false : true);
     // create image tag for emojis
     $this->text = self::translateEmojis($this->text, $this->minimal ? false : true);
     if ($this->maxLength != 0) {
         $this->text = \humhub\libs\Helpers::truncateText($this->text, $this->maxLength);
     }
     return nl2br($this->text);
 }
 public function run()
 {
     if ($this->encode) {
         $this->text = Html::encode($this->text);
     }
     if (!$this->minimal) {
         $maxOembedCount = 3;
         // Maximum OEmbeds
         $oembedCount = 0;
         // OEmbeds used
         $that = $this;
         $this->text = preg_replace_callback('/(https?:\\/\\/.*?)(\\s|$)/i', function ($match) use(&$oembedCount, &$maxOembedCount, &$that) {
             if ($that->edit) {
                 return Html::a($match[0], Html::decode($match[0]), array('target' => '_blank'));
             }
             // Try use oembed
             if ($maxOembedCount > $oembedCount) {
                 $oembed = UrlOembed::GetOembed($match[0]);
                 if ($oembed) {
                     $oembedCount++;
                     return $oembed;
                 }
             }
             return Html::a($match[1], Html::decode($match[1]), array('target' => '_blank')) . $match[2];
         }, $this->text);
         // mark emails
         $this->text = preg_replace_callback('/[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,3})/', function ($match) {
             return Html::mailto($match[0]);
         }, $this->text);
     }
     // get user and space details from guids
     $this->text = self::translateMentioning($this->text, $this->minimal ? false : true);
     // create image tag for emojis
     $this->text = self::translateEmojis($this->text, $this->minimal ? false : true);
     if ($this->maxLength != 0) {
         $this->text = \humhub\libs\Helpers::truncateText($this->text, $this->maxLength);
     }
     $output = nl2br($this->text);
     $this->trigger(self::EVENT_BEFORE_OUTPUT, new ParameterEvent(['output' => &$output]));
     return $output;
 }
Beispiel #3
0
</strong>
                                    <?php 
    if ($newItems != 0) {
        ?>
                                        <div class="badge badge-space pull-right"
                                             style="display:none"><?php 
        echo $newItems;
        ?>
</div>
                                    <?php 
    }
    ?>
                                    <br>

                                    <p><?php 
    echo Html::encode(Helpers::truncateText($membership->space->description, 60));
    ?>
</p>
                                </div>
                            </div>
                        </a>
                    </li>
                <?php 
}
?>

            </ul>
        </li>
        <?php 
if ($canCreateSpace) {
    ?>
                <img class="media-object img-rounded pull-left" data-src="holder.js/32x32" alt="32x32" style="width: 32px; height: 32px;" src="<?php 
    echo $message->getLastEntry()->user->getProfileImage()->getUrl();
    ?>
">
                <div class="media-body">
                    <h4 class="media-heading"><?php 
    echo Html::encode($message->getLastEntry()->user->displayName);
    ?>
 <small><?php 
    echo TimeAgo::widget(['timestamp' => $message->updated_at]);
    ?>
</small></h4>
                    <h5><?php 
    echo Html::encode(Helpers::truncateText($message->title, 75));
    ?>
</h5>
                    <?php 
    echo Helpers::truncateText(MarkdownView::widget(['markdown' => $message->getLastEntry()->content, 'parserClass' => '\\humhub\\libs\\MarkdownPreview', 'returnPlain' => true]), 200);
    ?>
                    <?php 
    // show the new badge, if this message is still unread
    if ($message->updated_at > $userMessage->last_viewed && $message->getLastEntry()->user->id != Yii::$app->user->id) {
        echo '<span class="label label-danger">' . Yii::t('MailModule.views_mail_index', 'New') . '</span>';
    }
    ?>
                </div>
            </div>
        </a>
    </li>
<?php 
}
Beispiel #5
0
<?php

use yii\helpers\Html;
use humhub\libs\Helpers;
use humhub\modules\content\components\ContentContainerController;
if (!Yii::$app->controller instanceof ContentContainerController) {
    echo Yii::t('ActivityModule.views_activities_ActivitySpaceMemberAdded', "%displayName% joined the space %spaceName%", array('%displayName%' => '<strong>' . Html::encode($originator->displayName) . '</strong>', '%spaceName%' => '<strong>' . Html::encode(Helpers::truncateText($source->name, 40)) . '</strong>'));
} else {
    echo Yii::t('ActivityModule.views_activities_ActivitySpaceMemberAdded', "%displayName% joined this space.", array('%displayName%' => '<strong>' . Html::encode($originator->displayName) . '</strong>'));
}
<?php

use yii\helpers\Html;
use humhub\libs\Helpers;
echo strip_tags(Yii::t('ActivityModule.views_activities_ActivitySpaceCreated', "%displayName% created the new space %spaceName%", array('%displayName%' => Html::encode($originator->displayName), '%spaceName%' => '"' . Html::encode(Helpers::truncateText($source->name, 25)) . '"')));
Beispiel #7
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use humhub\libs\Helpers;
?>
<div class="notes-sticker">
    <div class="notes-stripe"></div>

    <div class="note_snippet">
        <?php 
foreach (array_slice(explode("\n", $note->getPadContent()), 0, 4) as $line) {
    echo Html::encode(Helpers::truncateText($line, 75));
}
?>
    </div>
</div>


<br/>
<a href="<?php 
echo $note->content->container->createUrl('/notes/note/open', ['id' => $note->id]);
?>
"
   class="btn btn-primary"><?php 
echo Yii::t('NotesModule.widgets_views_entry', 'Open note');
?>
</a>
Beispiel #8
0
                        <div class="media well well-small ">
                            <img class="media-object img-rounded pull-left" data-src="holder.js/64x64" alt="64x64"
                                 style="width: 64px; height: 64px;"
                                 src="<?php 
    echo $module->getContentContainerImage($space);
    ?>
">

                            <div class="media-body">
                                <h4 class="media-heading"><?php 
    echo $module->getContentContainerName($space);
    ?>
                                </h4>

                                <p style="height: 35px;"><?php 
    echo \humhub\libs\Helpers::truncateText($module->getContentContainerDescription($space), 75);
    ?>
</p>

                                <?php 
    $enable = "";
    $disable = "hidden";
    if ($space->isModuleEnabled($moduleId)) {
        $enable = "hidden";
        if (!$space->canDisableModule($moduleId)) {
            $disable = "disabled";
        } else {
            $disable = "";
        }
    }
    ?>
<?php

use yii\helpers\Html;
use humhub\libs\Helpers;
echo strip_tags(Yii::t('ActivityModule.views_activities_ActivitySpaceMemberRemoved', "%displayName% left the space %spaceName%", array('%displayName%' => Html::encode($originator->displayName), '%spaceName%' => '"' . Html::encode(Helpers::truncateText($source->name, 40)) . '"')));
<?php

use humhub\libs\Helpers;
use humhub\widgets\MarkdownView;
?>
<div class="media meeting">
    <div class="media-body">
        <h4 class="media-heading"><a href="<?php 
echo $wiki->getUrl();
?>
"><?php 
echo $wiki->title;
?>
</a></h4>
        <div class="markdown-render">
            <?php 
echo MarkdownView::widget(['markdown' => Helpers::truncateText($content, 500), 'parserClass' => "humhub\\modules\\wiki\\Markdown"]);
?>
        </div>

        <a href="<?php 
echo $wiki->getUrl();
?>
"><?php 
echo Yii::t('WikiModule.widgets_views_wallentry', 'Open wiki page...');
?>
</a>
    </div>
</div>
<div class="media">
    <div class="media-body">
        <h4 class="media-heading"><a href="<?php 
echo $page->getUrl();
?>
"><?php 
echo $page->title;
?>
</a></h4>

        <?php 
if ($page->type == ContainerPage::TYPE_MARKDOWN) {
    ?>
            <div class="markdown-render">
                <?php 
    echo MarkdownView::widget(['markdown' => Helpers::truncateText($page->page_content, 500)]);
    ?>
            </div>
        <?php 
}
?>

        <a href="<?php 
echo $page->getUrl();
?>
"><?php 
echo Yii::t('CustomPagesModule.widgets_views_wallentry', 'Open page...');
?>
</a>
    </div>
</div>
Beispiel #12
-1
    public function run()
    {
        if ($this->encode) {
            $this->text = Html::encode($this->text);
        }
        if (!$this->minimal) {
            $maxOembedCount = 3;
            // Maximum OEmbeds
            $oembedCount = 0;
            // OEmbeds used
            $that = $this;
            $pattern = <<<REGEXP
                    /(?(R) # in case of recursion match parentheses
\t\t\t\t \\(((?>[^\\s()]+)|(?R))*\\)
\t\t\t|      # else match a link with title
\t\t\t\t(https?|ftp):\\/\\/(([^\\s()]+)|(?R))+(?<![\\.,:;\\'"!\\?\\s])
\t\t\t)/x
REGEXP;
            $this->text = preg_replace_callback($pattern, function ($match) use(&$oembedCount, &$maxOembedCount, &$that) {
                // Try use oembed
                if ($maxOembedCount > $oembedCount) {
                    $oembed = UrlOembed::GetOembed($match[0]);
                    if ($oembed) {
                        $oembedCount++;
                        return $oembed;
                    }
                }
                return Html::a($match[0], Html::decode($match[0]), array('target' => '_blank'));
            }, $this->text);
            // mark emails
            $this->text = preg_replace_callback('/[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,3})/', function ($match) {
                return Html::mailto($match[0]);
            }, $this->text);
        }
        // get user and space details from guids
        $this->text = self::translateMentioning($this->text, $this->minimal ? false : true);
        // create image tag for emojis
        $this->text = self::translateEmojis($this->text, $this->minimal ? false : true);
        if ($this->maxLength != 0) {
            $this->text = \humhub\libs\Helpers::truncateText($this->text, $this->maxLength);
        }
        $this->text = trim($this->text);
        if (!$this->minimal) {
            $output = nl2br($this->text);
        } else {
            $output = $this->text;
        }
        // replace leading spaces with no break spaces to keep the text format
        $output = preg_replace_callback('/^( +)/m', function ($m) {
            return str_repeat("&nbsp;", strlen($m[1]));
        }, $output);
        $this->trigger(self::EVENT_BEFORE_OUTPUT, new ParameterEvent(['output' => &$output]));
        return trim($output);
    }