Esempio n. 1
0
 public function onAfterReply($message)
 {
     if (\Joomla\String\String::strlen($message->message) > $this->params->get('activity_points_limit', 0)) {
         CFactory::load('libraries', 'userpoints');
         CUserPoints::assignPoint('com_kunena.thread.reply');
     }
     // Get users who have subscribed to the topic, excluding current user.
     $acl = KunenaAccess::getInstance();
     $subscribers = $acl->getSubscribers($message->catid, $message->thread, KunenaAccess::TOPIC_SUBSCRIPTION, false, false, array($message->userid));
     foreach ($subscribers as $userid) {
         $actor = CFactory::getUser($message->userid);
         $target = CFactory::getUser($userid);
         $params = new CParameter('');
         $params->set('actorName', $actor->getDisplayName());
         $params->set('recipientName', $target->getDisplayName());
         $params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null));
         // {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification
         $params->set('title', $message->displayField('subject'));
         // (title) tag in language file
         $params->set('title_url', $message->getPermaUrl());
         // Make the title in notification - linkable
         $params->set('message', $message->displayField('message'));
         // (message) tag in language file
         $params->set('actor', $actor->getDisplayName());
         // Actor in the stream
         $params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id);
         // Actor Link
         // Finally, send notifications
         CNotificationLibrary::add('kunena_reply', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TEXT'), '', $params);
     }
     // Activity stream
     $act = new stdClass();
     $act->cmd = 'wall.write';
     $act->actor = $message->userid;
     $act->target = 0;
     // no target
     $act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>'));
     $act->content = $this->buildContent($message);
     $act->app = 'kunena.thread.reply';
     $act->cid = $message->thread;
     $act->access = $this->getAccess($message->getCategory());
     // Comments and like support
     $act->comment_id = $message->thread;
     $act->comment_type = 'kunena.thread.reply';
     $act->like_id = $message->thread;
     $act->like_type = 'kunena.thread.reply';
     // Do not add private activities
     if ($act->access > 20) {
         return;
     }
     CFactory::load('libraries', 'activities');
     $table = CActivityStream::add($act);
     if (is_object($table)) {
         $table->like_id = $table->id;
         $table->store();
     }
 }
Esempio n. 2
0
 /**
  * Validates the value.
  *
  * @param   scalar  $value  The value to validate.
  *
  * @return  boolean
  *
  * @since   1.0
  */
 protected function doIsValid($value)
 {
     $min = $this->getOption('min');
     $max = $this->getOption('max');
     if ($min && String::strlen($value) < $min) {
         $this->addError(self::TOO_SHORT);
         return false;
     }
     if ($max && String::strlen($value) > $max) {
         $this->addError(self::TOO_LONG);
         return false;
     }
     return true;
 }
 /**
  * Returns an array of options
  *
  * @param   string   $sql  	SQL with 'ordering' AS value and 'name field' AS text
  * @param   integer  $chop  The length of the truncated headline
  *
  * @return  array  An array of objects formatted for JHtml list processing
  *
  * @since   11.1
  */
 public static function genericordering($sql, $chop = 30)
 {
     $db = Factory::getDbo();
     $options = array();
     $db->setQuery($sql);
     $items = $db->loadObjectList();
     if (empty($items)) {
         $options[] = Html::_('select.option', 1, Text::_('JOPTION_ORDER_FIRST'));
         return $options;
     }
     $options[] = Html::_('select.option', 0, '0 ' . Text::_('JOPTION_ORDER_FIRST'));
     for ($i = 0, $n = count($items); $i < $n; $i++) {
         $items[$i]->text = Text::_($items[$i]->text);
         if (String::strlen($items[$i]->text) > $chop) {
             $text = String::substr($items[$i]->text, 0, $chop) . "...";
         } else {
             $text = $items[$i]->text;
         }
         $options[] = Html::_('select.option', $items[$i]->value, $items[$i]->value . '. ' . $text);
     }
     $options[] = Html::_('select.option', $items[$i - 1]->value + 1, $items[$i - 1]->value + 1 . ' ' . Text::_('JOPTION_ORDER_LAST'));
     return $options;
 }
Esempio n. 4
0
										<div>
											<textarea id="user-signature" class="input-xxlarge" name="signature" cols="4" rows="6"
												><?php 
echo $this->escape($this->user->signature);
?>
</textarea>
										</div>
										<div>
											<label><input type="checkbox" value="1" name="deleteSig" /> <?php 
echo JText::_('COM_KUNENA_DELSIG');
?>
											</label>
										</div>
										<div>
											<?php 
echo JText::sprintf('COM_KUNENA_SIGNATURE_LENGTH_COUNTER', intval($this->config->maxsig), '<input id="current_count" class="span1" readonly="readonly" type="text" name="current_count" value="' . (intval($this->config->maxsig) - \Joomla\String\String::strlen($this->user->signature)) . '" />');
?>
										</div>
									</fieldset>
								</div>
								<?php 
/*
	<div class="tab-pane" id="tab2">
		<fieldset>
		<table class="table table-striped">
			<tr>
				<td>Personal Text</td>
				<td><input type="text" maxlength="50" name="personaltext" value="" /></td>
			</tr>
			<tr>
				<td>Birthdate</td>
Esempio n. 5
0
 /**
  * Takes a long string and breaks it into natural chunks and returns an array with the chunks
  * - The method will attempt to break on certain html tags first, then sentence structures and finally spaces if possible
  * - If $string is shorter than $maxChunkLength an array with one entry is returned
  *
  * @param string $string         String to chunk
  * @param int    $maxChunkLength Maximum chunk length
  *
  * @return array
  */
 public static function chunkHTMLString($string, $maxChunkLength)
 {
     $chunks = array();
     //If the given string can fit in the first chunk then just return that
     if (\Joomla\String\String::strlen($string) < $maxChunkLength) {
         $chunks[] = $string;
         return $chunks;
     }
     $cutStrings = array();
     $cutStrings[] = '</div>';
     $cutStrings[] = '</p>';
     $cutStrings[] = '</ul>';
     $cutStrings[] = '</table>';
     $cutStrings[] = '</a>';
     $cutStrings[] = '. ';
     while (\Joomla\String\String::strlen($string) > $maxChunkLength) {
         //Look for the breakpoint that is located last in the substring that is less than max
         $potentialCutPoints = array();
         foreach ($cutStrings as $key => $cutString) {
             $position = strripos(substr($string, 0, $maxChunkLength), $cutString);
             if ($position !== false) {
                 $potentialCutPoints[$position] = $cutString;
             }
         }
         //Select the right most breakpoint
         if (count($potentialCutPoints)) {
             $selectedBreakPoint = max(array_keys($potentialCutPoints));
             $selectedBreakPointString = $potentialCutPoints[$selectedBreakPoint];
             $breakPoint = $selectedBreakPoint + utf8_strlen($selectedBreakPointString);
             //Add the chunk
             $chunks[] = \Joomla\String\String::substr($string, 0, $breakPoint);
         } else {
             //Unable to find a breakpoint, use wordwrap
             $wordWrappedString = wordwrap($string, $maxChunkLength, '|||---NENO---|||', true);
             $wordWrappedArray = explode('|||---NENO---|||', $wordWrappedString);
             $chunks[] = $wordWrappedArray[0];
             $breakPoint = \Joomla\String\String::strlen($wordWrappedArray[0]) + 3;
         }
         //Reduce the string
         $string = \Joomla\String\String::substr($string, $breakPoint);
     }
     //Add the remainder to the last chunk
     $chunks[] = $string;
     return $chunks;
 }
 /**
  * Abridges text strings over the specified character limit. The
  * behavior will insert an ellipsis into the text replacing a section
  * of variable size to ensure the string does not exceed the defined
  * maximum length. This method is UTF-8 safe.
  *
  * For example, it transforms "Really long title" to "Really...title".
  *
  * Note that this method does not scan for HTML tags so will potentially break them.
  *
  * @param   string   $text    The text to abridge.
  * @param   integer  $length  The maximum length of the text (default is 50).
  * @param   integer  $intro   The maximum length of the intro text (default is 30).
  *
  * @return  string   The abridged text.
  *
  * @since   11.1
  */
 public static function abridge($text, $length = 50, $intro = 30)
 {
     // Abridge the item text if it is too long.
     if (StringString::strlen($text) > $length) {
         // Determine the remaining text length.
         $remainder = $length - ($intro + 3);
         // Extract the beginning and ending text sections.
         $beg = StringString::substr($text, 0, $intro);
         $end = StringString::substr($text, StringString::strlen($text) - $remainder);
         // Build the resulting string.
         $text = $beg . '...' . $end;
     }
     return $text;
 }