当前位置: 首页>>代码示例>>PHP>>正文


PHP Formatter::convertLineBreaks方法代码示例

本文整理汇总了PHP中Formatter::convertLineBreaks方法的典型用法代码示例。如果您正苦于以下问题:PHP Formatter::convertLineBreaks方法的具体用法?PHP Formatter::convertLineBreaks怎么用?PHP Formatter::convertLineBreaks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Formatter的用法示例。


在下文中一共展示了Formatter::convertLineBreaks方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getText


//.........这里部分代码省略.........
         case 'workflow_revert':
             $action = X2Model::model('Actions')->findByPk($this->associationId);
             if (isset($action)) {
                 $record = X2Model::model(ucfirst($action->associationType))->findByPk($action->associationId);
                 if (isset($record)) {
                     $stages = Workflow::getStages($action->workflowId);
                     $text = $authorText . Yii::t('app', 'reverted the process stage "{stageName}" for the {modelName} {modelLink}', array('{stageName}' => $stages[$action->stageNumber - 1], '{modelName}' => Events::parseModelName($action->associationType), '{modelLink}' => X2Model::getModelLink($action->associationId, $action->associationType)));
                 } else {
                     $text = $authorText . Yii::t('app', "reverted a process stage, but the associated {modelName} was not found.", array('{modelName}' => Events::parseModelName($action->associationType)));
                 }
             } else {
                 $text = $authorText . Yii::t('app', "reverted a process stage, but the process record could not be found.");
             }
             break;
         case 'feed':
             if (Yii::app()->user->getName() == $this->user) {
                 $author = CHtml::link(Yii::t('app', 'You'), Yii::app()->controller->createAbsoluteUrl('/profile/view', array('id' => Yii::app()->user->getId())), $htmlOptions) . " ";
             } else {
                 $author = User::getUserLinks($this->user);
             }
             $recipUser = Yii::app()->db->createCommand()->select('username')->from('x2_users')->where('id=:id', array(':id' => $this->associationId))->queryScalar();
             $modifier = '';
             $recipient = '';
             if ($this->user != $recipUser && $this->associationId != 0) {
                 if (Yii::app()->user->getId() == $this->associationId) {
                     $recipient = Yii::t('app', 'You');
                 } else {
                     $recipient = User::getUserLinks($recipUser);
                 }
                 if (!empty($recipient)) {
                     $modifier = ' » ';
                 }
             }
             $text = $author . $modifier . $recipient . ": " . ($truncated ? strip_tags(Formatter::convertLineBreaks(x2base::convertUrls($this->text), true, true), '<a></a>') : $this->text);
             break;
         case 'email_sent':
             if (class_exists($this->associationType)) {
                 $model = X2Model::model($this->associationType)->findByPk($this->associationId);
                 if (!empty($model)) {
                     switch ($this->subtype) {
                         case 'quote':
                             $text = $authorText . Yii::t('app', "issued the {transModelName} \"{modelLink}\" via email", array('{transModelName}' => Yii::t('quotes', 'quote'), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                         case 'invoice':
                             $text = $authorText . Yii::t('app', "issued the {transModelName} \"{modelLink}\" via email", array('{transModelName}' => Yii::t('quotes', 'invoice'), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                         default:
                             $text = $authorText . Yii::t('app', "sent an email to the {transModelName} {modelLink}", array('{transModelName}' => Events::parseModelName($this->associationType), '{modelLink}' => X2Model::getModelLink($this->associationId, $this->associationType)));
                             break;
                     }
                 } else {
                     $deletionEvent = X2Model::model('Events')->findByAttributes(array('type' => 'record_deleted', 'associationType' => $this->associationType, 'associationId' => $this->associationId));
                     switch ($this->subtype) {
                         case 'quote':
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "issued a quote by email, but that record has been deleted.");
                             } else {
                                 $text = $authorText . Yii::t('app', "issued a quote by email, but that record could not be found.");
                             }
                             break;
                         case 'invoice':
                             if (isset($deletionEvent)) {
                                 $text = $authorText . Yii::t('app', "issued an invoice by email, but that record has been deleted.");
                             } else {
                                 $text = $authorText . Yii::t('app', "issued an invoice by email, but that record could not be found.");
                             }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:67,代码来源:Events.php

示例2: array

        <div class='stacked-icon'></div>
    </div>
    <div class="event-text-box">
        <div class="deleteButton">
            <?php 
if ($data->type == 'feed' && ($data->user == Yii::app()->user->getName() || Yii::app()->params->isAdmin)) {
    echo CHtml::link('', array('/profile/updatePost', 'id' => $data->id, 'profileId' => $profileId), array('class' => 'fa fa-edit')) . " ";
}
if (($data->user == Yii::app()->user->getName() || $data->associationId == Yii::app()->user->getId()) && $data->type == 'feed' || Yii::app()->params->isAdmin) {
    echo CHtml::link('', '#', array('class' => 'fa fa-close delete-link', 'id' => $data->id . '-delete'));
}
?>
        </div>
        <span class="event-text">
            <?php 
echo Formatter::convertLineBreaks(x2base::convertUrls($data->getText()));
?>
        </span>
        <div class='event-bottom-row'>
            <span class="comment-age x2-hint" id="<?php 
echo $data->id . "-" . $data->timestamp;
?>
" 
                  style="<?php 
echo $style;
?>
"
                  title="<?php 
echo Formatter::formatFeedTimestamp($data->timestamp);
?>
">
开发者ID:keyeMyria,项目名称:CRM,代码行数:31,代码来源:_viewEvent.php

示例3: getSignature

 public function getSignature($html = false)
 {
     $adminRule = Yii::app()->settings->emailUseSignature;
     $userRule = $this->emailUseSignature;
     $signature = '';
     switch ($adminRule) {
         case 'admin':
             $signature = Yii::app()->settings->emailSignature;
             break;
         case 'user':
             switch ($userRule) {
                 case 'user':
                     $signature = $signature = $this->emailSignature;
                     break;
                 case 'admin':
                     Yii::app()->settings->emailSignature;
                     break;
                 case 'group':
                     $signature == '';
                     break;
                 default:
                     $signature == '';
             }
             break;
         case 'group':
             $signature == '';
             break;
         default:
             $signature == '';
     }
     $signature = preg_replace(array('/\\{first\\}/', '/\\{last\\}/', '/\\{phone\\}/', '/\\{group\\}/', '/\\{email\\}/'), array($this->user->firstName, $this->user->lastName, $this->officePhone, '', $html ? CHtml::mailto($this->emailAddress) : $this->emailAddress), $signature);
     if ($html) {
         $signature = Formatter::convertLineBreaks($signature);
     }
     return $signature;
 }
开发者ID:keyeMyria,项目名称:CRM,代码行数:36,代码来源:Profile.php

示例4: convertUrls

 /**
  * Replaces any URL in text with an html link (supports mailto links)
  *
  * @todo refactor this out of controllers
  * @param string $text Text to be converted
  * @param boolean $convertLineBreaks
  */
 public static function convertUrls($text, $convertLineBreaks = true)
 {
     /* $text = preg_replace(
        array(
        '/(?(?=<a[^>]*>.+<\/a>)(?:<a[^>]*>.+<\/a>)|([^="\']?)((?:https?|ftp|bf2|):\/\/[^<> \n\r]+))/iex',
        '/<a([^>]*)target="?[^"\']+"?/i',
        '/<a([^>]+)>/i',
        '/(^|\s|>)(www.[^<> \n\r]+)/iex',
        '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/iex'
        ),
        array(
        "stripslashes((strlen('\\2')>0?'\\1<a href=\"\\2\">\\2</a>\\3':'\\0'))",
        '<a\\1',
        '<a\\1 target="_blank">',
        "stripslashes((strlen('\\2')>0?'\\1<a href=\"http://\\2\">\\2</a>\\3':'\\0'))",
        "stripslashes((strlen('\\2')>0?'<a href=\"mailto:\\0\">\\0</a>':'\\0'))"
        ),
        $text
        ); */
     /* URL matching regex from the interwebs:
      * http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/
      */
     $url_pattern = '/\\b(?:(?:https?|ftp|file):\\/\\/|www\\.|ftp\\.)(?:\\([-A-Z0-9+&@#\\/%=~_|$?!:,.]*\\)|[-A-Z0-9+&@#\\/%=~_|$?!:,.])*(?:\\([-A-Z0-9+&@#\\/%=~_|$?!:,.]*\\)|[A-Z0-9+&@#\\/%=~_|$])/i';
     $email_pattern = '/(([_A-Za-z0-9-]+)(\\.[_A-Za-z0-9-]+)*@([A-Za-z0-9-]+)(\\.[A-Za-z0-9-]+)*)/i';
     /* First break the text into two arrays, one containing <a> tags and the like
      * which should not have any replacements, and another with all the text that
      * should have URLs activated.  Each piece of each array has its offset from
      * original string so we can piece it back together later
      */
     //add any additional tags to be passed over here
     $tags_with_urls = "/(<a[^>]*>.*<\\/a>)|(<img[^>]*>)|(<iframe[^>]*>.*<\\/iframe>)|(<script[^>]*>.*<\\/script>)/i";
     $text_to_add_links = preg_split($tags_with_urls, $text, NULL, PREG_SPLIT_OFFSET_CAPTURE);
     $matches = array();
     preg_match_all($tags_with_urls, $text, $matches, PREG_OFFSET_CAPTURE);
     $text_to_leave = $matches[0];
     // Convert all URLs into html links
     foreach ($text_to_add_links as $i => $value) {
         $text_to_add_links[$i][0] = preg_replace(array($url_pattern, $email_pattern), array("<a href=\"\\0\">\\0</a>", "<a href=\"mailto:\\0\">\\0</a>"), $text_to_add_links[$i][0]);
     }
     // Merge the arrays and sort to be in the original order
     $all_text_chunks = array_merge($text_to_add_links, $text_to_leave);
     usort($all_text_chunks, 'x2base::compareChunks');
     $new_text = "";
     foreach ($all_text_chunks as $chunk) {
         $new_text = $new_text . $chunk[0];
     }
     $text = $new_text;
     // Make sure all links open in new window, and have http:// if missing
     $text = preg_replace(array('/<a([^>]+)target=("[^"]+"|\'[^\']\'|[^\\s]+)([^>]+)/i', '/<a([^>]+href="?\'?)(www\\.|ftp\\.)/i'), array('<a\\1 target=\\2\\3', '<a\\1http://\\2'), $text);
     //convert any tags into links
     $matches = array();
     // avoid matches that end with </span></a>, like other record links
     preg_match('/(^|[>\\s\\.])(#\\w\\w+)(?!.*<\\/span><\\/a>)/u', $text, $matches);
     $tags = Yii::app()->cache->get('x2_taglinks');
     if ($tags === false) {
         $dependency = new CDbCacheDependency('SELECT MAX(timestamp) FROM x2_tags');
         $tags = Yii::app()->db->createCommand()->selectDistinct('tag')->from('x2_tags')->queryColumn();
         // cache either 10min or until a new tag is added
         Yii::app()->cache->set('x2_taglinks', $tags, 600, $dependency);
     }
     if (sizeof($matches) > 1 && $matches[2] !== null && array_search($matches[2], $tags) !== false) {
         $template = "\\1<a href=" . Yii::app()->createUrl('/search/search') . '?term=%23\\2' . ">#\\2</a>";
         //$text = preg_replace('/(^|[>\s\.])#(\w\w+)($|[<\s\.])/u',$template,$text);
         $text = preg_replace('/(^|[>\\s\\.])#(\\w\\w+)/u', $template, $text);
     }
     //TODO: separate convertUrl and convertLineBreak concerns
     if ($convertLineBreaks) {
         return Formatter::convertLineBreaks($text, true, false);
     } else {
         return $text;
     }
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:79,代码来源:x2base.php

示例5: elseif

echo $form->labelEx($model, 'priority');
echo $form->dropDownList($model, 'priority', $model->priorityLabels);
echo "</span></span>";
echo "<span class='field-value'>";
if (!empty($model->subject)) {
    echo "<b>" . $model->renderAttribute('subject', false) . "</b><br><br>";
} elseif (!empty($model->type)) {
    echo "<b>" . ucfirst($model->type) . "</b><br><br>";
}
echo "</span>";
echo "<span class='hidden-frame-form' style='display: none;'>";
echo $form->labelEx($model, 'actionDescription');
echo $form->textArea($model, 'actionDescription', array('class' => 'x2-xxwide-input', 'rows' => 6));
echo "</span>";
echo "<span class='field-value'>";
echo Formatter::convertLineBreaks($model->actionDescription);
echo "</span>";
echo '<div>';
echo CHtml::ajaxSubmitButton(Yii::t('app', 'Submit'), 'update?id=' . $model->id, array(), array('id' => 'action-edit-submit-button', 'style' => 'display:none;float:left;', 'class' => 'hidden-frame-form x2-button highlight'));
echo CHtml::link(Yii::t('actions', 'View Full Edit Page'), array('update', 'id' => $model->id), array('style' => 'float:right;display:none;', 'target' => '_parent', 'class' => 'x2-button hidden-frame-form'));
echo '</div>';
?>
            </div>
            </div>
                <?php 
$this->endWidget();
?>
                <?php 
if (!empty($model->associationType) && is_numeric($model->associationId) && !is_null(X2Model::getAssociationModel($model->associationType, $model->associationId)) && ($publisher == 'false' || !$publisher)) {
    ?>
                <div id="recordBody" class="form">
开发者ID:dsyman2,项目名称:X2CRM,代码行数:31,代码来源:_viewFrame.php

示例6: array

            </div>
            <div class="img-box user-avatar">
                <?php 
echo Profile::renderFullSizeAvatar($data->getAuthorId(), 45);
?>
            </div>
        </div>
        <div class='topic-text'>
            <div class='topic-timestamp-text'>
                <?php 
echo Yii::t('topics', 'Posted {datetime}.', array('{datetime}' => Formatter::formatDateTime($data->createDate, 'medium')));
?>
            </div>
            <br>
            <?php 
echo Formatter::convertLineBreaks(x2base::convertUrls($data->text));
?>
            <div class='topic-timestamp-text'>
                <br>
                <?php 
if ($data->isEdited()) {
    echo Yii::t('topics', 'Edited by {user} - {datetime}.', array('{user}' => User::getUserLinks($data->updatedBy, false, true), '{datetime}' => Formatter::formatDateTime($data->lastUpdated, 'medium')));
}
?>
            </div>
        </div>

    </div>
    <div class='topic-footer'>
            <?php 
if (count($data->attachments) > 0) {
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:_viewTopicReply.php


注:本文中的Formatter::convertLineBreaks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。