本文整理匯總了PHP中Foundry::string方法的典型用法代碼示例。如果您正苦於以下問題:PHP Foundry::string方法的具體用法?PHP Foundry::string怎麽用?PHP Foundry::string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Foundry
的用法示例。
在下文中一共展示了Foundry::string方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
*
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function execute($item)
{
// Get comment participants
$model = FD::model('Comments');
$users = $model->getParticipants($item->uid, $item->context_type);
// Include the actor of the stream item as the recipient
// Exclude myself from the list of users.
// Ensure that the values are unique
$users[] = $item->actor_id;
$users = array_values(array_unique(array_diff($users, array(Foundry::user()->id))));
// Convert the names to stream-ish
$names = Foundry::string()->namesToNotifications($users);
$plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
// By default content is always empty;
$content = '';
// Only show the content when there is only 1 item
if (count($users) == 1 && !empty($item->content)) {
$content = JString::substr(strip_tags($item->content), 0, 30);
if (JString::strlen($item->content) > 30) {
$content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
}
}
// Load the milestone
$milestone = FD::table('Milestone');
$state = $milestone->load($item->uid);
if (!$state) {
return;
}
// We need to generate the notification message differently for the author of the item and the recipients of the item.
if ($milestone->owner_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
$item->title = JText::sprintf('APP_GROUP_TASKS_USER_COMMENTED_ON_YOUR_MILESTONE', $names);
return $item;
}
if ($milestone->owner_id == $item->actor_id && count($users) == 1) {
$item->title = JText::sprintf('APP_GROUP_TASKS_USER_COMMENTED_ON_THEIR_MILESTONE', $names);
return $item;
}
// This is for 3rd party viewers
$item->title = JText::sprintf('APP_GROUP_TASKS_USER_COMMENTED_ON_USERS_MILESTONE', $names, Foundry::user($milestone->owner_id)->getName());
return $item;
}
示例2: pluralize
/**
* Pluralize the string if necessary.
*
* @since 1.2
* @access public
* @param string
* @return
*/
public static function pluralize($languageKey, $count)
{
return Foundry::string()->computeNoun($languageKey, $count);
}