コード例 #1
1
ファイル: RichText.php プロジェクト: alefernie/intranet
 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);
 }
コード例 #2
0
 private function checkPasswordResetToken($user, $token)
 {
     // Saved token - Format: randomToken.generationTime
     $savedTokenInfo = Yii::$app->getModule('user')->settings->contentContainer($user)->get('passwordRecoveryToken');
     if ($savedTokenInfo !== "") {
         list($generatedToken, $generationTime) = explode('.', $savedTokenInfo);
         if (\humhub\libs\Helpers::same($generatedToken, $token)) {
             // Check token generation time
             if ($generationTime + 24 * 60 * 60 >= time()) {
                 return true;
             }
         }
     }
     return false;
 }
コード例 #3
0
ファイル: BaseType.php プロジェクト: kreativmind/humhub
 /**
  * Returns an array of instances of all available field types.
  *
  * @return Array
  */
 public function getTypeInstances($profileField = null)
 {
     $types = array();
     foreach ($this->getFieldTypes() as $className => $title) {
         if (\humhub\libs\Helpers::CheckClassType($className, self::className())) {
             $instance = new $className();
             if ($profileField != null) {
                 $instance->profileField = $profileField;
                 // Seems current type, so try load data
                 if ($profileField->field_type_class == $className) {
                     $instance->loadFieldConfig();
                 }
             }
             $types[] = $instance;
         }
     }
     return $types;
 }
コード例 #4
0
 /**
  * Action which handles file uploads
  *
  * The result is an json array of all uploaded files.
  */
 public function actionUpload()
 {
     Yii::$app->response->format = 'json';
     // Object which the uploaded file(s) belongs to (optional)
     $object = null;
     $objectModel = Yii::$app->request->get('objectModel');
     $objectId = Yii::$app->request->get('objectId');
     if ($objectModel != "" && $objectId != "" && \humhub\libs\Helpers::CheckClassType($objectModel, \yii\db\ActiveRecord::className())) {
         $givenObject = $objectModel::findOne(['id' => $objectId]);
         // Check if given object is HActiveRecordContent or HActiveRecordContentAddon and can be written by the current user
         if ($givenObject !== null && ($givenObject instanceof ContentActiveRecord || $givenObject instanceof ContentAddonActiveRecord) && $givenObject->content->canWrite()) {
             $object = $givenObject;
         }
     }
     $files = array();
     foreach (UploadedFile::getInstancesByName('files') as $cFile) {
         $files[] = $this->handleFileUpload($cFile, $object);
     }
     return ['files' => $files];
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 /**
  * Loads Content Addon
  * We also validates that the content addon corresponds to the loaded content.
  *
  * @param string $className
  * @param int $pk
  */
 public function loadContentAddon($className, $pk)
 {
     if (!\humhub\libs\Helpers::CheckClassType($className, ContentAddonActiveRecord::className())) {
         throw new \yii\base\Exception("Given className is not a content addon model!");
     }
     $target = $className::findOne(['id' => $pk]);
     if ($target === null) {
         throw new HttpException(500, 'Could not find content addon record!');
     }
     if ($target->object_model != get_class($this->parentContent) && $target->object_id != $this->parentContent->getPrimaryKey()) {
         throw new HttpException(500, 'Content addon not belongs to given content record!');
     }
     $this->contentAddon = $target;
 }
コード例 #7
0
ファイル: ProfileField.php プロジェクト: SimonBaeumer/humhub
 /**
  * Returns the ProfileFieldType Class for this Profile Field
  *
  * @return ProfileFieldType
  */
 public function getFieldType()
 {
     if ($this->_fieldType != null) {
         return $this->_fieldType;
     }
     if ($this->field_type_class != "" && \humhub\libs\Helpers::CheckClassType($this->field_type_class, fieldtype\BaseType::className())) {
         $type = $this->field_type_class;
         $this->_fieldType = new $type();
         $this->_fieldType->setProfileField($this);
         return $this->_fieldType;
     }
     return null;
 }
コード例 #8
0
ファイル: memberAdded.php プロジェクト: SimonBaeumer/humhub
<?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>'));
}
コード例 #9
0
<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>
コード例 #10
0
ファイル: showFiles.php プロジェクト: VasileGabriel/humhub
        ?>
            <?php 
        if ($file->getMimeBaseType() == "image" && $hideImageFileInfo) {
            continue;
        }
        ?>
            <li class="mime <?php 
        echo \humhub\libs\MimeHelper::getMimeIconClassByExtension($file->getExtension());
        ?>
"><a
                    href="<?php 
        echo $file->getUrl();
        ?>
" target="_blank"><span
                        class="filename"><?php 
        echo Html::encode(Helpers::trimText($file->file_name, 40));
        ?>
</span></a>
                <span class="time" style="padding-right: 20px;"> - <?php 
        echo Yii::$app->formatter->asShortSize($file->size, $decimals = 1);
        ?>
</span>

                <?php 
        if ($file->getExtension() == "mp3") {
            ?>
                    <!-- Integrate jPlayer -->
                    <?php 
            echo xj\jplayer\AudioWidget::widget(array('id' => $file->id, 'mediaOptions' => ['mp3' => $file->getUrl()], 'jsOptions' => ['smoothPlayBar' => true]));
            ?>
                <?php 
コード例 #11
0
<?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>
コード例 #12
0
ファイル: MarkdownView.php プロジェクト: SimonBaeumer/humhub
 public function init()
 {
     if (!\humhub\libs\Helpers::CheckClassType($this->parserClass, "cebe\\markdown\\Parser")) {
         throw new Exception("Invalid markdown parser class given!");
     }
 }
コード例 #13
0
<?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)) . '"')));
コード例 #14
0
 /**
  * File Settings
  */
 public function actionFile()
 {
     $form = new \humhub\modules\admin\models\forms\FileSettingsForm();
     if ($form->load(Yii::$app->request->post()) && $form->validate() && $form->save()) {
         Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
         return $this->redirect(['/admin/setting/file']);
     }
     // Determine PHP Upload Max FileSize
     $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('upload_max_filesize'));
     if ($maxUploadSize > \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'))) {
         $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'));
     }
     $maxUploadSize = floor($maxUploadSize / 1024 / 1024);
     // Determine currently used ImageLibary
     $currentImageLibary = 'GD';
     if (Yii::$app->getModule('file')->settings->get('imageMagickPath')) {
         $currentImageLibary = 'ImageMagick';
     }
     return $this->render('file', array('model' => $form, 'maxUploadSize' => $maxUploadSize, 'currentImageLibary' => $currentImageLibary));
 }
コード例 #15
0
<?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)) . '"')));
コード例 #16
0
ファイル: entry.php プロジェクト: thurti/humhub-modules-notes
<?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>
コード例 #17
0
ファイル: modules.php プロジェクト: SimonBaeumer/humhub
                        <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 = "";
        }
    }
    ?>
コード例 #18
0
ファイル: spaceChooser.php プロジェクト: SimonBaeumer/humhub
</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) {
    ?>
コード例 #19
0
                <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 
}
コード例 #20
0
 /**
  * File Settings
  */
 public function actionFile()
 {
     $form = new \humhub\modules\admin\models\forms\FileSettingsForm();
     $form->imageMagickPath = Setting::Get('imageMagickPath', 'file');
     $form->maxFileSize = Setting::Get('maxFileSize', 'file') / 1024 / 1024;
     $form->maxPreviewImageWidth = Setting::Get('maxPreviewImageWidth', 'file');
     $form->maxPreviewImageHeight = Setting::Get('maxPreviewImageHeight', 'file');
     $form->hideImageFileInfo = Setting::Get('hideImageFileInfo', 'file');
     $form->useXSendfile = Setting::Get('useXSendfile', 'file');
     $form->allowedExtensions = Setting::GetText('allowedExtensions', 'file');
     $form->showFilesWidgetBlacklist = Setting::GetText('showFilesWidgetBlacklist', 'file');
     if ($form->load(Yii::$app->request->post()) && $form->validate()) {
         $new = $form->maxFileSize * 1024 * 1024;
         Setting::Set('imageMagickPath', $form->imageMagickPath, 'file');
         Setting::Set('maxFileSize', $new, 'file');
         Setting::Set('maxPreviewImageWidth', $form->maxPreviewImageWidth, 'file');
         Setting::Set('maxPreviewImageHeight', $form->maxPreviewImageHeight, 'file');
         Setting::Set('hideImageFileInfo', $form->hideImageFileInfo, 'file');
         Setting::Set('useXSendfile', $form->useXSendfile, 'file');
         Setting::SetText('allowedExtensions', strtolower($form->allowedExtensions), 'file');
         Setting::SetText('showFilesWidgetBlacklist', $form->showFilesWidgetBlacklist, 'file');
         // set flash message
         Yii::$app->getSession()->setFlash('data-saved', Yii::t('AdminModule.controllers_SettingController', 'Saved'));
         return Yii::$app->response->redirect(Url::toRoute('/admin/setting/file'));
     }
     // Determine PHP Upload Max FileSize
     $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('upload_max_filesize'));
     if ($maxUploadSize > \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'))) {
         $maxUploadSize = \humhub\libs\Helpers::GetBytesOfPHPIniValue(ini_get('post_max_size'));
     }
     $maxUploadSize = floor($maxUploadSize / 1024 / 1024);
     // Determine currently used ImageLibary
     $currentImageLibary = 'GD';
     if (Setting::Get('imageMagickPath', 'file')) {
         $currentImageLibary = 'ImageMagick';
     }
     return $this->render('file', array('model' => $form, 'maxUploadSize' => $maxUploadSize, 'currentImageLibary' => $currentImageLibary));
 }
コード例 #21
0
ファイル: showFiles.php プロジェクト: SimonBaeumer/humhub
        ?>
            <?php 
        if ($file->getMimeBaseType() == "image" && $hideImageFileInfo) {
            continue;
        }
        ?>
            <li class="mime <?php 
        echo \humhub\libs\MimeHelper::getMimeIconClassByExtension($file->getExtension());
        ?>
"><a
                    href="<?php 
        echo $file->getUrl();
        ?>
" target="_blank"><span
                        class="filename"><?php 
        echo Helpers::trimText($file->file_name, 40);
        ?>
</span></a>
                <span class="time" style="padding-right: 20px;"> - <?php 
        echo Yii::$app->formatter->asSize($file->size);
        ?>
</span>

                <?php 
        if ($file->getExtension() == "mp3") {
            ?>
                    <!-- Integrate jPlayer -->
                    <?php 
            echo xj\jplayer\AudioWidget::widget(array('id' => $file->id, 'mediaOptions' => ['mp3' => $file->getUrl()], 'jsOptions' => ['smoothPlayBar' => true]));
            ?>
                <?php 
コード例 #22
-1
ファイル: RichText.php プロジェクト: VasileGabriel/humhub
    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);
    }