示例#1
0
 /**
  * DOCUMENT ME
  * @param mixed $areaname
  * @param mixed $word_limit
  * @return mixed
  */
 public function getAreaBasicHtml($areaname, $word_limit = false)
 {
     $slots = $this->getSlotsByAreaName($areaname);
     $text = '';
     foreach ($slots as $slot) {
         if (strlen($text)) {
             // div might not be permitted in a lot of 'basic html'
             // contexts, but we do need some vertical break between
             // two slots to reasonably reproduce what
             // Apostrophe does with them
             $text .= '<br />';
         }
         $text .= $slot->getBasicHtml();
     }
     if ($word_limit) {
         return aHtml::limitWords($text, $word_limit, array('append_ellipsis' => true));
     } else {
         return $text;
     }
 }
示例#2
0
 /**
  *
  * @param string $areas Array of areas to retrieve text for
  * @param int $limit Number of characters to restrict retrieval to
  * @return string
  */
 public function getRichTextForAreas($areas = array(), $limit = null)
 {
     $text = '';
     if (!is_array($areas)) {
         $areas = array($areas);
     }
     foreach ($areas as $area) {
         $text .= $this->Page->getAreaBasicHtml($area);
     }
     if (!is_null($limit)) {
         $text = aHtml::limitWords($text, $limit, array('append_ellipsis' => true));
     }
     return $text;
 }
 /**
  *
  * @param string $areas Array of areas to retrieve text for
  * @param int $limit Number of characters to restrict retrieval to
  * @return string
  */
 public function getRichTextForAreas($areas = array(), $limit = null)
 {
     $text = '';
     if (!is_array($areas)) {
         $areas = array($areas);
     }
     foreach ($areas as $area) {
         foreach ($this->Page->getArea($area) as $slot) {
             if ($slot['type'] == 'aRichText' || $slot['type'] == 'aText') {
                 $text .= $slot->getValue();
             }
         }
     }
     if (!is_null($limit)) {
         $text = aHtml::limitWords($text, $limit, array('append_ellipsis' => true));
     }
     return $text;
 }
示例#4
0
 /**
  * This is a quick and dirty implementation based on calling limitWords
  * with an optimistic guess and then backing off a few times if necessary
  * until we get under the byte limit. Note that limitBytes is designed
  * to fit things in buffers, not save screen space, so it does have to
  * make sure the result is not too big
  * @param mixed $string
  * @param mixed $byte_limit
  * @param mixed $options
  * @return mixed
  */
 public static function limitBytes($string, $byte_limit, $options = array())
 {
     $word_limit = (int) ($byte_limit / 8);
     while (true) {
         $s = aHtml::limitWords($string, $word_limit, $options);
         if (strlen($s) <= $byte_limit) {
             break;
         }
         $word_limit = (int) ($word_limit * 0.75);
     }
     return $s;
 }