Truncate() final public static method

Truncates the string to a given length, adding elipses (if needed).
final public static Truncate ( $strText, integer $intMaxLength, bololean $blnHtmlEntities = true ) : string
$intMaxLength integer the maximum possible length of the string to return (including length of the elipse)
$blnHtmlEntities bololean whether or not to escape the text with htmlentities first
return string the full string or the truncated string with eplise
Beispiel #1
0
<div class="<?php 
_p($_FORM->RenderTopicCss($_ITEM));
?>
" title="<?php 
_p($_ITEM->SidenavTitle);
?>
" onmouseover="topicOver(this);" onmouseout="topicOut(this);" onclick="document.location='<?php 
_p($_FORM->RenderTopicLink($_ITEM));
?>
'">
	<div class="title"><div style="width: 600px;">
		<a href="<?php 
_p($_FORM->RenderTopicLink($_ITEM));
?>
" title="<?php 
_p($_ITEM->SidenavTitle);
?>
"><?php 
_p(QString::Truncate($_ITEM->Name, 60), false);
?>
</a>
	</div></div>
	<div class="count"><?php 
_p($_ITEM->MessageCount);
?>
</div>
</div>
Beispiel #2
0
 public function RenderAnswer(SignupEntry $objSignupEntry, $intFormQuestionId, $intFormQuestionTypeId)
 {
     $objAnswer = FormAnswer::LoadBySignupEntryIdFormQuestionId($objSignupEntry->Id, $intFormQuestionId);
     if (!$objAnswer) {
         return;
     }
     switch ($intFormQuestionTypeId) {
         case FormQuestionType::YesNo:
             if ($objAnswer->BooleanValue) {
                 return 'Yes';
             }
             break;
         case FormQuestionType::SpouseName:
         case FormQuestionType::Address:
         case FormQuestionType::Gender:
         case FormQuestionType::Phone:
         case FormQuestionType::Email:
         case FormQuestionType::ShortText:
         case FormQuestionType::LongText:
         case FormQuestionType::SingleSelect:
         case FormQuestionType::MultipleSelect:
             return QString::Truncate(QApplication::HtmlEntities($objAnswer->TextValue), 50);
         case FormQuestionType::Number:
         case FormQuestionType::Age:
             return $objAnswer->IntegerValue;
         case FormQuestionType::DateofBirth:
             if ($objAnswer->DateValue) {
                 return $objAnswer->DateValue->ToString('MMM D YYYY');
             }
             break;
     }
 }
Beispiel #3
0
            $strImageHtml = '<img style="float: left; margin-top: 5px; margin-right: 5px;" src="' . $strUrl . '"/>';
        } else {
            $strImageHtml = null;
        }
        $strAuthor = null;
        // Try and deduce an author if applicable
        $arrMatches = array();
        if (preg_match('/([bByY][ A-Za-z\\-\']*)(\\[[A-Za-z0-9 \\/.,\\-_]*\\])/', $strDescription, $arrMatches)) {
            $strAuthor = trim($arrMatches[1]);
            $strDateTime = trim($arrMatches[2]);
            $strDescription = trim(substr($strDescription, strlen($arrMatches[0])));
        }
        if ($strAuthor) {
            $strHtml = sprintf('<div style="cursor: pointer;" onclick="document.location=&quot;%s&quot;;"><h1 style="font-size: 18px;">Featured Article</h1>%s<strong>%s</strong><br/><em>%s<br/>%s</em><br/>%s<br/><a href="%s" onclick="return false;">Read More</a></div>', QApplication::HtmlEntities($strLink), $strImageHtml, $strTitle, $strAuthor, $strDateTime, QString::Truncate($strDescription, 100), QApplication::HtmlEntities($strLink));
        } else {
            $strHtml = sprintf('<div style="cursor: pointer;" onclick="document.location=&quot;%s&quot;;"><h1 style="font-size: 18px;">Featured Article</h1>%s<strong>%s</strong><br/><em>%s</em><br/>%s<br/><a href="%s" onclick="return false;">Read More</a></div>', QApplication::HtmlEntities($strLink), $strImageHtml, $strTitle, $dttDateTime->ToString('MMMM D, YYYY'), QString::Truncate($strDescription, 100), QApplication::HtmlEntities($strLink));
        }
        $strHtmlArray[] = $strHtml;
    }
}
///////////////////////
// Setup the JS/HTML (if applicable)
///////////////////////
if (count($strHtmlArray)) {
    $strHtml = implode('<br/><br/>', $strHtmlArray);
    $strHtml = '<img src="/uploads/mediaHeader.png" title="Abundant Living Online" style="position: relative; top: -15px; left: -10px; cursor: pointer;" onclick="document.location=&quot;http://abundantliving.alcf.net/&quot;" /><br/>' . $strHtml;
    $strHtml = str_replace('"', '\\"', $strHtml);
    if (!is_dir(dirname(SYNDICATION_CACHE_PATH))) {
        QApplication::MakeDirectory(dirname(SYNDICATION_CACHE_PATH), 0777);
    }
    file_put_contents(SYNDICATION_CACHE_PATH, 'document.getElementById("syndicatedContent").innerHTML = "' . $strHtml . '";');
Beispiel #4
0
 public function RenderTitle(Issue $objIssue)
 {
     $strVersionInfoArray = array();
     if ($objFieldOption = $objIssue->GetFieldOptionForIssueField($this->objIssueFieldForQcodoVersion)) {
         $strVersionInfoArray[] = 'Qcodo ' . $objFieldOption->Name;
     }
     if ($objFieldOption = $objIssue->GetFieldOptionForIssueField($this->objIssueFieldForPhpVersion)) {
         $strVersionInfoArray[] = 'PHP ' . $objFieldOption->Name;
     }
     $strVersionInfo = '';
     if (count($strVersionInfoArray)) {
         $strVersionInfo = sprintf('<br/><em style="color: #777; font-size: 10px;">%s</em>', implode(', ', $strVersionInfoArray));
     }
     return sprintf('<a href="/issues/view.php/%s" style="font-weight: bold;">%s</a>%s', $objIssue->Id, QString::Truncate($objIssue->Title, 50, true), $strVersionInfo);
 }