Example #1
0
 private function show_message_overview()
 {
     if (($message_count = $this->model->count_messages()) === false) {
         $this->output->add_tag("result", "Database error.");
         return false;
     }
     $paging = new pagination($this->output, "admin_forum", $this->settings->admin_page_size, $message_count);
     if (($messages = $this->model->get_messages($paging->offset, $paging->size)) === false) {
         $this->output->add_tag("result", "Database error.");
         return;
     }
     $this->output->open_tag("overview");
     $this->output->open_tag("messages");
     foreach ($messages as $message) {
         $message["content"] = truncate_text($message["content"], 400);
         $message["timestamp"] = date("j F Y, H:i", $message["timestamp"]);
         if ($message["author"] == "") {
             $message["author"] = $message["username"];
         }
         $this->output->record($message, "message");
     }
     $this->output->close_tag();
     $paging->show_browse_links();
     $this->output->close_tag();
 }
Example #2
0
 public function show_faq_overview()
 {
     if (($sections = $this->model->get_all_sections()) === false) {
         $this->output->add_tag("result", "Database error.");
         return;
     } else {
         if (($faqs = $this->model->get_all_faqs()) === false) {
             $this->output->add_tag("result", "Database error.");
             return;
         }
     }
     $this->output->open_tag("overview");
     $this->output->open_tag("sections");
     foreach ($sections as $section) {
         $this->output->add_tag("section", $section["label"], array("id" => $section["id"]));
     }
     $this->output->close_tag();
     $this->output->open_tag("faqs");
     foreach ($faqs as $faq) {
         $faq["question"] = truncate_text($faq["question"], 140);
         $this->output->record($faq, "faq");
     }
     $this->output->close_tag();
     $this->output->close_tag();
 }
Example #3
0
 public function execute()
 {
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         /* Delete message
          */
         if ($this->model->delete_message($_POST["id"])) {
             $this->user->log_action("guestbook entry %d deleted", $_POST["id"]);
         }
     }
     handle_table_sort("adminguestbook_order", array("author", "message", "timestamp", "ip_address"), array("timestamp", "author"));
     $paging = new pagination($this->output, "admin_guestbook", $this->settings->admin_page_size, $message_count);
     if (($guestbook = $this->model->get_messages($_SESSION["adminguestbook_order"], $paging->offset, $paging->size)) === false) {
         $this->output->add_tag("result", "Database error.");
         return;
     }
     $this->output->open_tag("guestbook");
     foreach ($guestbook as $item) {
         $item["message"] = truncate_text($item["message"], 45);
         if ($this->output->mobile) {
             $item["timestamp"] = date("Y-m-d", $item["timestamp"]);
         } else {
             $item["timestamp"] = date("j F Y, H:i", $item["timestamp"]);
         }
         $this->output->record($item, "item");
     }
     $paging->show_browse_links();
     $this->output->close_tag();
 }
 public static function extractSummaryArray($body, $min, $total)
 {
     //replace whitespaces with space
     $body = preg_replace("/(\\r?\\n[ \\t]*)+/", " ", $body);
     //find paragraphs
     $matches = array();
     preg_match_all("/<p>(.+)<\\/p>/isU", $body, $matches, PREG_SET_ORDER);
     //put paragraphs to a fresh array and calculate total length
     $total_length = 0;
     $paragraphs = array();
     foreach ($matches as $match) {
         $len = 0;
         if (($len = strlen($match[1])) > $min) {
             $paragraphs[] = $match[1];
             $total_length += strlen($match[1]);
         }
     }
     //chop paragraphs
     sfLoader::loadHelpers('Text');
     $final = array();
     for ($i = 0; $i < sizeof($paragraphs); $i++) {
         $share = (int) ($total * strlen($paragraphs[$i]) / $total_length);
         if ($share < $min) {
             $total_length -= strlen($paragraphs[$i]);
             continue;
         }
         $final[] = truncate_text($paragraphs[$i], $share, "", true);
     }
     return $final;
 }
Example #5
0
function truncate_description($description, $route, $length = 500, $has_abstract = false)
{
    if ($has_abstract) {
        $description = extract_abstract($description);
    }
    $more = '... <span class="more_text">' . link_to('[' . __('Read more') . ']', $route) . '</span>';
    return parse_links(parse_bbcode_simple(truncate_text($description, $length, $more)));
}
Example #6
0
 public function execute()
 {
     if ($this->user->logged_in == false) {
         unset($this->sections["mail"]);
     }
     if (isset($_SESSION["search"]) == false) {
         $_SESSION["search"] = array();
         foreach ($this->sections as $section => $label) {
             $_SESSION["search"][$section] = true;
         }
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $this->log_search_query($_POST["query"]);
         foreach ($this->sections as $section => $label) {
             $_SESSION["search"][$section] = is_true($_POST[$section]);
         }
     }
     $this->output->add_css("banshee/js_pagination.css");
     $this->output->add_javascript("banshee/pagination.js");
     $this->output->add_javascript("search.js");
     $this->output->run_javascript("document.getElementById('query').focus()");
     $this->output->add_tag("query", $_POST["query"]);
     $this->output->open_tag("sections");
     foreach ($this->sections as $section => $label) {
         $params = array("label" => $label, "checked" => show_boolean($_SESSION["search"][$section]));
         $this->output->add_tag("section", $section, $params);
     }
     $this->output->close_tag();
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (strlen(trim($_POST["query"])) < 3) {
             $this->output->add_tag("result", "Search query too short.");
         } else {
             if (($result = $this->model->search($_POST, $this->sections)) === false) {
                 /* Error
                  */
                 $this->output->add_tag("result", "Search error.");
             } else {
                 if (count($result) == 0) {
                     $this->output->add_tag("result", "No matches found.");
                 } else {
                     /* Results
                      */
                     foreach ($result as $section => $hits) {
                         $this->output->open_tag("section", array("section" => $section, "label" => $this->sections[$section]));
                         foreach ($hits as $hit) {
                             $hit["text"] = strip_tags($hit["text"]);
                             $hit["content"] = strip_tags($hit["content"]);
                             $hit["content"] = preg_replace('/\\[.*?\\]/', "", $hit["content"]);
                             $hit["content"] = truncate_text($hit["content"], 400);
                             $this->output->record($hit, "hit");
                         }
                         $this->output->close_tag();
                     }
                 }
             }
         }
     }
 }
/**
* creates a link to related schema property
*
* @return none
* @param  schemaproperty $property
*/
function link_to_related_property($property)
{
    $relPropertyId = $property->getIsSubpropertyOf();
    $relPropertyUri = $property->getParentUri();
    if ($relPropertyId) {
        //get the related concept
        $relProperty = SchemaPropertyPeer::retrieveByPK($relPropertyId);
        if ($relProperty) {
            return link_to($relProperty->getLabel(), 'schemaprop/show/?id=' . $relPropertyId, ['title' => $relPropertyUri]);
        }
    }
    //if all else fails we display a truncated = 30 value
    return truncate_text($property->getParentUri(), 30);
}
Example #8
0
 private function show_mails($mails, $column)
 {
     $this->output->open_tag("mailbox", array("column" => $column));
     foreach ($mails as $mail) {
         $mail["subject"] = truncate_text($mail["subject"], 55);
         if ($this->mobile) {
             $mail["timestamp"] = date_string("Y-m-d", $mail["timestamp"]);
         } else {
             $mail["timestamp"] = date_string("l, j F Y H:i:s", $mail["timestamp"]);
         }
         $mail["read"] = $mail["read"] == YES ? "read" : "unread";
         $this->output->record($mail, "mail");
     }
     $this->output->close_tag();
 }
 /**
  * generate Wildcard.. truncate if necessary, $pUrl is optional
  *
  * @param YiidActivity $pActivity
  * @return string
  */
 public function generateMessage($pActivity)
 {
     sfProjectConfiguration::getActive()->loadHelpers('Text');
     $lUrl = ShortUrlTable::shortenUrl($pActivity->generateUrlWithClickbackParam($this->onlineIdentity));
     $lMaxChars = 135;
     $lText = $lUrl;
     $lLengthOfText = strlen($lText);
     if ($pActivity->getComment()) {
         $lChars = $lMaxChars - $lLengthOfText;
         $lText = truncate_text($pActivity->getComment(), $lChars, '...') . " " . $lText;
     } elseif ($pActivity->getTitle()) {
         $lChars = $lMaxChars - $lLengthOfText;
         $lText = truncate_text($pActivity->getTitle(), $lChars, '...') . " " . $lText;
     }
     return array("status" => $lText);
 }
/**
 * creates a link to related concept
 *
 * @return none
 * @param  conceptproperty $property
 */
function link_to_related($property)
{
    $relConceptId = $property->getRelatedConceptId();
    if ($relConceptId) {
        //get the related concept
        $relConcept = ConceptPeer::retrieveByPK($relConceptId);
        if ($relConcept) {
            return link_to($relConcept->getPrefLabel(), 'concept/show/?id=' . $relConceptId);
        }
    }
    //If the skosProperty.objectType is resource then we display a truncated URI with a complete link_to
    if ($property->getProfileProperty()->getIsObjectProp()) {
        return link_to(truncate_text($property->getObject(), 30), $property->getObject());
    }
    //if all else fails we display a truncated = 30 value
    return truncate_text($property->getObject(), 30);
}
 public function summarize($body)
 {
     $matches = array();
     preg_match_all("/<p>(.+)<\\/p>/isU", $body, $matches, PREG_SET_ORDER);
     $paragraphs = array();
     foreach ($matches as $match) {
         $paragraphs[] = preg_replace("/(\\r?\\n[ \\t]*)+/", " ", strip_tags($match[1]));
     }
     $total = $this->total($paragraphs);
     foreach ($paragraphs as $i => $paragraph) {
         if (strlen($paragraph) / $total * 100 < $this->threshold) {
             unset($paragraphs[$i]);
         }
     }
     $total = $this->total($paragraphs);
     $spaces = count($paragraphs) - 1;
     foreach ($paragraphs as $i => $paragraph) {
         $paragraphs[$i] = truncate_text($paragraph, strlen($paragraph) / $total * ($this->max - $spaces), '...', true);
     }
     return implode(' ', $paragraphs);
 }
Example #12
0
 private function show_weblog_form($weblog)
 {
     $this->output->add_javascript("ckeditor/ckeditor.js");
     $this->output->add_javascript("banshee/start_ckeditor.js");
     $this->output->open_tag("edit");
     $weblog["visible"] = show_boolean($weblog["visible"]);
     $this->output->record($weblog, "weblog");
     /* Tags
      */
     $tagged = array();
     if (isset($weblog["tag"])) {
         $tagged = $weblog["tag"];
     } else {
         if (($weblog_tags = $this->model->get_weblog_tags($weblog["id"])) != false) {
             foreach ($weblog_tags as $tag) {
                 array_push($tagged, $tag["id"]);
             }
         }
     }
     $this->output->open_tag("tags");
     if (($tags = $this->model->get_tags()) != false) {
         foreach ($tags as $tag) {
             $this->output->add_tag("tag", $tag["tag"], array("id" => $tag["id"], "selected" => show_boolean(in_array($tag["id"], $tagged))));
         }
     }
     $this->output->close_tag();
     /* Comments
      */
     $this->output->open_tag("comments");
     if (($weblog_comments = $this->model->get_weblog_comments($weblog["id"])) != false) {
         foreach ($weblog_comments as $comment) {
             $comment["content"] = truncate_text($comment["content"], 100);
             $this->output->record($comment, "comment");
         }
     }
     $this->output->close_tag();
     $this->output->close_tag();
 }
Example #13
0
/**
 * Функция получения содержимого поля для обработки в шаблоне рубрики
 *
 * @param int $field_id	идентификатор поля, для [tag:fld:12] $field_id = 12
 * @param int $length	необязательный параметр,
 * 						количество возвращаемых символов содержимого поля.
 * 						если данный параметр указать со знаком минус
 * 						содержимое поля будет очищено от HTML-тегов.
 * @return string
 */
function document_get_field_value($field_id, $length = 0)
{
    if (!is_numeric($field_id)) {
        return '';
    }
    $document_fields = get_document_fields(get_current_document_id());
    $field_value = trim($document_fields[$field_id]['field_value']);
    if ($field_value != '') {
        $field_value = strip_tags($field_value, "<br /><strong><em><p><i>");
        if (is_numeric($length) && $length != 0) {
            if ($length < 0) {
                $field_value = strip_tags($field_value);
                $field_value = preg_replace('/  +/', ' ', $field_value);
                $field_value = trim($field_value);
                $length = abs($length);
            }
            $field_value = truncate_text($field_value, $length, '…', true);
        }
    }
    return $field_value;
}
  </thead>
  <tbody>
    <?php 
foreach ($pager->getResults() as $rt_comment) {
    ?>
    <tr>
      <td>
        <a href="<?php 
    echo url_for('rtCommentAdmin/edit?id=' . $rt_comment->getId());
    ?>
"><?php 
    echo $rt_comment->getAuthorName();
    ?>
</a>:<br />
        <?php 
    echo truncate_text(strip_tags($rt_comment->getContent()), 100);
    ?>
      </td>
      <td class="rt-admin-publish-toggle">
        <?php 
    echo rt_nice_boolean($rt_comment->getIsActive());
    ?>
        <div style="display:none;"><?php 
    echo $rt_comment->getId();
    ?>
</div>
      </td>
      <td><?php 
    echo $rt_comment->getCreatedAt();
    ?>
</td>
Example #15
0
<?php

echo truncate_text($event->getDescription(), 150);
Example #16
0
    <tr>
      <td><?php 
        $date = new DateTime($info['modification_date_time']);
        echo $date->format('d/m/Y H:i:s');
        ?>
</td>
      <td><?php 
        echo $info['referenced_relation'];
        ?>
</td>
      <td><?php 
        echo __($info['formattedStatus']);
        ?>
</td>
      <td><?php 
        echo truncate_text($info['comment'], 30);
        ?>
</td>
      <td>
        <?php 
        echo image_tag('info.png', 'class=more_comment');
        ?>
        <ul class="field_change">
            <?php 
        echo $info['comment'];
        ?>
        </ul>
        <?php 
        echo link_to(image_tag('blue_eyel.png'), $info->getLink('view'));
        ?>
        <?php 
<td><?php 
echo $nota->getIdNota();
?>
</td>
<td><?php 
$texto = truncate_text($nota->getTexto(), 50);
echo link_to($texto ? $texto : '-', 'notas/edit?id_usuario=' . $nota->getIdUsuario() . "&id_nota=" . $nota->getIdNota());
?>
</td>
<td><?php 
echo format_date($nota->getUpdatedAt(), 'f');
?>
</td>
Example #18
0
function generateTopGames($timeframe)
{
    if ($timeframe == 'day') {
        $topTenDivName = 'topTenElementForDay';
        $queryInterval = '1 DAY';
    } else {
        if ($timeframe == 'week') {
            $topTenDivName = 'topTenElementForWeek';
            $queryInterval = '7 DAY';
        } else {
            if ($timeframe == 'month') {
                $topTenDivName = 'topTenElementForMonth';
                $queryInterval = '1 MONTH';
            }
        }
    }
    /*
    else if ($timeframe == 'alltime')
    {
      $topTenDivName = 'topTenElementForAllTime';
      $queryInterval = '100 YEAR';
    }
    */
    $query = '
SELECT media.file_path as file_path, temp.game_id, temp.name, temp.description, temp.count FROM
(SELECT games.game_id, games.name, games.description, games.icon_media_id, COUNT(DISTINCT player_id) AS count
FROM games
INNER JOIN player_log ON games.game_id = player_log.game_id
WHERE player_log.timestamp BETWEEN DATE_SUB(NOW(), INTERVAL ' . $queryInterval . ') AND NOW()
GROUP BY games.game_id 
HAVING count > 1) as temp 
LEFT JOIN media ON temp.icon_media_id = media.media_id 
GROUP BY game_id
HAVING count > 1
ORDER BY count DESC
';
    //echo "<!-- ".$query." -->";
    $result = mysql_query($query);
    $counter = 0;
    echo "<div id=\"" . $topTenDivName . "\">\n";
    while ($game = mysql_fetch_object($result)) {
        $counter++;
        if ($counter > $GLOBALS['numTopGames']) {
            break;
        }
        $name = $game->name;
        $gameid = $game->game_id;
        $count = $game->count;
        $iconFileURL = $game->file_path;
        $description = truncate_text($game->description, 215);
        $query = "SELECT name FROM game_editors LEFT JOIN editors ON game_editors.editor_id = editors.editor_id WHERE game_editors.game_id = {$gameid}";
        $authorResult = mysql_query($query);
        $authors = array();
        while ($author = mysql_fetch_object($authorResult)) {
            $authors[] = $author;
        }
        echo "<div class=\"topTenElement\">\n";
        if ($iconFileURL) {
            $iconURL = 'http://www.arisgames.org/server/gamedata/' . $iconFileURL;
        } else {
            $iconURL = 'defaultLogo.png';
        }
        echo '<div class="topTenNumBox"><div class="topTenNum"><img class="topTenImg" alt="img" width="64" height="64" src="' . $iconURL . "\" /></div></div>\n";
        echo '<div class="topTenGameNameAndDesc"><p class="topTenName"><strong>' . $name . "</strong></p>\n";
        $editorString = '<p class="topTenAuthor">';
        foreach ($authors as $author) {
            $editorString = $editorString . $author->name . ", ";
        }
        $editorString = substr($editorString, 0, strlen($editorString) - 2);
        $editorString = $editorString . "</p>";
        echo $editorString;
        echo '<p class="topTenDescription">' . $description . "</p></div>\n";
        echo '<div class="topTenGameCount"><span class="topTenPlayerCount">' . $count . '</span><p class="topTenPlayerText">players</p></div>';
        /*
        	  // get the location (use the google maps api to get a name for the long/lat)
        
            $query2 = 'SELECT longitude, latitude FROM ' . $game->id . '_locations LIMIT 1';
            $result2 = mysql_query($query2);
            
            if (mysql_num_rows($result2) == 1)
            {
              $row = mysql_fetch_object($result2);
              
              if ($row->latitude != 0 && $row->longitude != 0)
              {      
                $toplat = $row->latitude;
                $toplong = $row->longitude;
              }
            }   
            
        	  echo '<div class="topTenLocation">';
        	  //echo '<script type="text/javascript">';
        	  //echo 'document.write(reverseLatLng(' . $toplat . ', ' . $toplong . '));</script>';
            //echo "</div>\n"; */
        echo "</div>\n";
    }
    echo "</div>\n";
}
<h1>Announcements</h1>
<?php 
echo image_tag('divider.png', 'class=divider');
if ($projectAnnouncementPager->getResults()) {
    ?>
<div id="announcements">
<?php 
    foreach ($projectAnnouncementPager->getResults() as $projectAnnouncement) {
        ?>
    <div>
        <h3><?php 
        echo $projectAnnouncement->getSubject();
        ?>
</h3>
        <p><?php 
        echo truncate_text($projectAnnouncement->getDetails(), 200);
        ?>
 <?php 
        echo link_to('more', 'project/showAnnouncement?id=' . $projectAnnouncement->getId());
        ?>
</p>
        <span class="date">Posted on <?php 
        echo $projectAnnouncement->getCreatedAt();
        ?>
</span>
    </div>
<?php 
    }
    ?>
</div>
<?php 
Example #20
0
		{
		echo '<div class="img-browser"><a href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.TB_FILENAME.': '.$file['name'][$i]
				.'&#13;&#10;'.TB_DIMENSIONS.': '.$file['width'][$i].' x '.$file['height'][$i]
				.'&#13;&#10;'.TB_DATE.': '.date($tinybrowser['dateformat'],$file['modified'][$i])
				.'&#13;&#10;'.TB_TYPE.': '.$file['type'][$i]
				.'&#13;&#10;'.TB_SIZE.': '.bytestostring($file['size'][$i],1)
				.'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i]
				.'"  /><div class="filename">'.$file['name'][$i].'</div></a></div>';
		}
	}
else
	{
	for($i=$showpage_start;$i<$showpage_end;$i++)
		{
		$alt = (IsOdd($i) ? 'r1' : 'r0');
		echo '<tr class="'.$alt.'">';
		if($typenow=='image') echo '<td><a class="imghover" href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.$file['name'][$i].'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i].'" alt="" />'.truncate_text($file['name'][$i],30).'</a></td>';
		else echo '<td><a href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.$file['name'][$i].'">'.truncate_text($file['name'][$i],30).'</a></td>';
		echo '<td>'.bytestostring($file['size'][$i],1).'</td>';
		if($typenow=='image') echo '<td>'.$file['width'][$i].' x '.$file['height'][$i].'</td>';
		echo '<td>'.$file['type'][$i].'</td>'
			.'<td>'.date($tinybrowser['dateformat'],$file['modified'][$i]).'</td></tr>'."\n";
		}
	echo '</table></div>';
	}
?>
</fieldset></div></div>
<form name="passform"><input name = "fileurl" type="hidden" value= "" /></form>
</body>
</html>
function update_event($event_obj, $post_id)
{
    // event_obj is one class from the mind-body feed
    log_it("updated event for mbid " . $event_obj->ID . " post_id is {$post_id}");
    // return "dummy";
    $post_data = array('ID' => $post_id, 'post_content' => $event_obj->ClassDescription->Description, 'post_title' => $event_obj->ClassDescription->Name, 'post_excerpt' => truncate_text($event_obj->ClassDescription->Description, 120));
    wp_update_post($post_data);
    $start_date = substr($event_obj->StartDateTime, 0, 10) . ' ' . substr($event_obj->StartDateTime, 11, 8);
    // more efficient than str_replace!
    $end_date = substr($event_obj->EndDateTime, 0, 10) . ' ' . substr($event_obj->EndDateTime, 11, 8);
    $duration = strtotime($end_date) - strtotime($start_date);
    $meta_arr = array('_EventStartDate' => $start_date, '_EventEndDate' => $end_date, '_EventStartDateUTC' => $start_date, '_EventEndDateUTC' => $end_date, '_EventDuration' => $duration);
    foreach ($meta_arr as $key => $val) {
        update_post_meta($post_id, $key, $val);
    }
}
Example #22
0
        ?>
  <?php 
        if ($parametro_def->getCampoNumero()) {
            ?>
    <td align="right"><?php 
            echo $parametro->getNumero() ? $parametro->getNumero() : "0";
            ?>
</td>
  <?php 
        }
        ?>
  <?php 
        if ($parametro_def->getCampoCadena1()) {
            ?>
    <td><?php 
            echo $parametro->getCadena1() ? truncate_text($parametro->getCadena1(), 50) : "&mdash;";
            ?>
</td>
  <?php 
        }
        ?>
  <?php 
        if ($parametro_def->getCampoSiNo()) {
            ?>
    <td><?php 
            echo $parametro->getSino() ? __('Si') : __('No');
            ?>
</td>
  <?php 
        }
        ?>
Example #23
0
<?php

use_helper('Text');
?>

<strong><?php 
echo link_to($sf_sympal_content_slot->getName(), '@sympal_content_slots_edit?id=' . $sf_sympal_content_slot->getId());
?>
</strong><br/>
<small><?php 
echo truncate_text(strip_tags($sf_sympal_content_slot->getValue()), 100);
?>
</small>
Example #24
0
use_helper('Text');
slot('content');
?>

<div id="analytics-bread">
  <ul class="bc-list clearfix">
    <li class="bc-first"></li>
    <li class="bc-gradient"><?php 
echo link_to(__('Deal Analytics'), 'deal_analytics/index');
?>
</li>
    <li class="bc-seperator"></li>
    <li class="bc-gradient"><strong><?php 
echo __('Overview for "%deal%"', array('%deal%' => truncate_text($pDeal->getName(), 50)));
?>
</strong></li>
    <li class="bc-last"></li>
  </ul>
</div>
<h2 class="sub_title"><?php 
echo __('All time overview for deal "%deal%"', array('%deal%' => truncate_text($pDeal->getName(), 50)));
?>
</h2>
<p><?php 
echo __("There are no stats yet, please come back later.");
?>
</p>

<?php 
end_slot();
include_partial('global/graybox');
Example #25
0
$text = str_repeat('A', 35);
$truncated = str_repeat('A', 27) . '...';
$t->is(truncate_text($text), $truncated, 'text_truncate() adds ... to truncated text');
$text = str_repeat('A', 35);
$truncated = str_repeat('A', 22) . '...';
$t->is(truncate_text($text, 25), $truncated, 'text_truncate() takes the max length as its second argument');
$text = str_repeat('A', 35);
$truncated = str_repeat('A', 21) . 'BBBB';
$t->is(truncate_text($text, 25, 'BBBB'), $truncated, 'text_truncate() takes the ... text as its third argument');
$text = str_repeat('A', 10) . str_repeat(' ', 10) . str_repeat('A', 10);
$truncated_true = str_repeat('A', 10) . '...';
$truncated_false = str_repeat('A', 10) . str_repeat(' ', 2) . '...';
$t->is(truncate_text($text, 15, '...', false), $truncated_false, 'text_truncate() accepts a truncate lastspace boolean as its fourth argument');
$t->is(truncate_text($text, 15, '...', true), $truncated_true, 'text_truncate() accepts a truncate lastspace boolean as its fourth argument');
if (extension_loaded('mbstring')) {
    $t->is(truncate_text('P?�li? ?lu?ou?k? k?? �p?l ?�belsk� �dy!', 11), 'P?�li? ?...', 'text_truncate() handles unicode characters using mbstring if available');
} else {
    $t->skip('mbstring extension is not enabled');
}
// highlight_text()
$t->diag('highlight_text()');
$t->is(highlight_text("This is a beautiful morning", "beautiful"), "This is a <strong class=\"highlight\">beautiful</strong> morning", 'text_highlighter() highlights a word given as its second argument');
$t->is(highlight_text("This is a beautiful morning, but also a beautiful day", "beautiful"), "This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day", 'text_highlighter() highlights all occurrences of a word given as its second argument');
$t->is(highlight_text("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\\1</b>'), "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day", 'text_highlighter() takes a pattern as its third argument');
$t->is(highlight_text('', 'beautiful'), '', 'text_highlighter() returns an empty string if input is empty');
$t->is(highlight_text('', ''), '', 'text_highlighter() returns an empty string if input is empty');
$t->is(highlight_text('foobar', 'beautiful'), 'foobar', 'text_highlighter() does nothing is string to highlight is not present');
$t->is(highlight_text('foobar', ''), 'foobar', 'text_highlighter() returns input if string to highlight is not present');
$t->is(highlight_text("This is a beautiful! morning", "beautiful!"), "This is a <strong class=\"highlight\">beautiful!</strong> morning", 'text_highlighter() escapes search string to be safe in a regex');
$t->is(highlight_text("This is a beautiful! morning", "beautiful! morning"), "This is a <strong class=\"highlight\">beautiful! morning</strong>", 'text_highlighter() escapes search string to be safe in a regex');
$t->is(highlight_text("This is a beautiful? morning", "beautiful? morning"), "This is a <strong class=\"highlight\">beautiful? morning</strong>", 'text_highlighter() escapes search string to be safe in a regex');
Example #26
0
        $isFirst = false;
        ?>
        <img src="<?php 
        echo $actu->getThumbnail();
        ?>
" width="100%" alt="">
        <div class="carousel-caption">
          <h4><a href="<?php 
        echo url_for('blog_view', $actu);
        ?>
"><?php 
        echo $actu->getTitle();
        ?>
</a></h4>
          <p><?php 
        echo truncate_text(strip_tags($actu->getContent(ESC_RAW)), 140, "...");
        ?>
</p>
        </div>
      </div>
      <?php 
    }
    ?>
    <?php 
}
?>
  </div>
  <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
  <a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div>
Example #27
0
        <td height="44" align="left" class="first">
          <div class="padleft" title="<?php 
        echo $url->getUrl();
        ?>
">
          	<?php 
        if (isset($pShowUrl) && $pShowUrl) {
            ?>
              <?php 
            echo range_sensitive_link_to(truncate_text($url->getUrl(), 80), 'analytics/url_detail', array('query_string' => 'domainid=' . $pDomainProfile->getId() . '&url=' . urlencode($url->getUrl())));
            ?>
            <?php 
        } else {
            ?>
            		<?php 
            echo truncate_text($url->getUrl(), 80);
            ?>
            <?php 
        }
        ?>
          </div>
        </td>
        <td align="center"><div><strong class="big-font blue"><?php 
        echo point_format($url->getLikes());
        ?>
</strong></div></td>
        <td align="center" valign="middle"><div><strong class="big-font blue"><?php 
        echo point_format($url->getMediaPenetration());
        ?>
</strong></div></td>
        <td align="center" valign="middle"><div><strong class="big-font blue"><?php 
Example #28
0
echo $pYiidMeta->getDescription();
?>
">
      <?php 
echo truncate_text($pYiidMeta->getDescription(), 150);
?>
    </p>
    <p><a href="<?php 
echo $pYiidMeta->getUrl();
?>
" target="_blank" title="<?php 
echo $pYiidMeta->getUrl();
?>
">
      <?php 
echo truncate_text($pYiidMeta->getUrl(), 50);
?>
</a></p>
  </div>
  <div class="clear"></div>
  <div class="pers_comments">
    <textarea id="texarea_count" rows="2" cols="20" name="like[comment]" placeholder="<?php 
echo __("add your comment (optional) ...");
?>
 <?php 
echo __('Feel free to add some hashtags, for example:');
?>
 #like"></textarea>
    <div class="clear"></div>
    <span id="chars_counter">0</span>
  </div>
Example #29
0
><?php 
echo TB_TYPE;
?>
</th>
<th class="nohover"><?php 
echo $actionhead;
?>
</th></tr>
<?php 
for ($i = $showpagestart; $i < $showpageend; $i++) {
    $alt = IsOdd($i) ? 'r1' : 'r0';
    echo '<tr class="' . $alt . '">';
    if ($typenow == 'image') {
        echo '<td><a class="imghover" href="#" onclick="return false;" title="' . $file['name'][$i] . '&#13;&#10;' . TB_DATE . ': ' . date($tinybrowser['dateformat'], $file['modified'][$i]) . '&#13;&#10;' . TB_DIMENSIONS . ': ' . $file['width'][$i] . ' x ' . $file['height'][$i] . '"><img src="' . $thumbpath . '_thumbs/_' . $file['name'][$i] . $imagerefresh . '" alt="" />' . truncate_text($file['name'][$i], 30) . '</a></td>';
    } else {
        echo '<td title="' . $file['name'][$i] . '&#13;&#10;' . TB_DATE . ': ' . date($tinybrowser['dateformat'], $file['modified'][$i]) . '">' . truncate_text($file['name'][$i], 30) . '</td>';
    }
    echo '<td>' . bytestostring($file['size'][$i], 1) . '</td><td>' . $file['type'][$i] . '</td>' . '<td>';
    form_hidden_input('actionfile[' . $i . ']', $file['name'][$i]);
    switch ($actionnow) {
        case 'delete':
            echo '<input class="del" type="checkbox" name="deletefile[' . $i . ']" value="1" />';
            break;
        case 'rename':
            $ext = '.' . end(explode('.', $file['name'][$i]));
            form_hidden_input('renameext[' . $i . ']', $ext);
            form_text_input('renamefile[' . $i . ']', false, basename($file['name'][$i], $ext), 30, 120);
            echo $ext;
            break;
        case 'resize':
            form_text_input('resizefile[' . $i . ']', false, '', 4, 4);
Example #30
0
            </a>													    
          </div>
          <div class="module-meta">
            <h5><?php 
        echo $article['name'];
        ?>
</h5>

            <?php 
        $longueur = '230';
        if (strlen($article['name']) > 30) {
            $longueur = '190';
        }
        ?>
            <?php 
        echo truncate_text(htmlspecialchars_decode($article['excerpt']), $longueur, '...', true);
        ?>
          </div>						
        </div>				
      </div>

    <?php 
    }
    ?>

    <br class="clear" />
    <hr />
  </div>
<?php 
}
?>