本文整理汇总了PHP中elgg_get_excerpt函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_excerpt函数的具体用法?PHP elgg_get_excerpt怎么用?PHP elgg_get_excerpt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_excerpt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderURLHTML
public static function renderURLHTML($url)
{
$favicon = "http://g.etfv.co/{$url}";
if (class_exists('UFCOE\\Elgg\\Url')) {
$sniffer = new Url();
$guid = $sniffer->getGuid($url);
if ($entity = get_entity($guid)) {
$favicon = $entity->getIconURL('tiny');
if (elgg_instanceof($entity->user)) {
$text = "@{$entity->username}";
} else {
$text = isset($entity->name) ? $entity->name : $entity->title;
}
}
}
if (!$text) {
$embedder = new Embedder($url);
$meta = $embedder->extractMeta('oembed');
if ($meta->title) {
$text = $meta->title;
} else {
$text = elgg_get_excerpt($url, 35);
}
}
return elgg_view('output/url', array('text' => "<span class=\"favicon\" style=\"background-image:url({$favicon})\"></span><span class=\"link\">{$text}</span>", 'href' => $url, 'class' => 'extractor-link'));
}
示例2: generateTitle
public function generateTitle($river)
{
$subject = $river->getSubjectEntity();
$object = $river->getObjectEntity();
if ($object) {
$container = $object->getContainerEntity();
if ($object->title) {
$objectTitle = html_entity_decode($object->title, ENT_QUOTES);
} else {
$objectTitle = elgg_get_excerpt(html_entity_decode($object->description, ENT_QUOTES), 60);
}
}
switch ($river->action_type) {
case "create":
$title = $subject->name . " heeft " . $objectTitle . " geplaatst in " . $container->name;
break;
case "update":
$title = $subject->name . " heeft " . $objectTitle . " vernieuwd in " . $container->name;
break;
case "join":
$title = $subject->name . " is lid geworden van " . $objectTitle;
break;
case "reply":
$title = $subject->name . " heeft gereageerd op " . $objectTitle;
break;
default:
$title = "";
break;
}
return $title;
}
示例3: getExcerpt
/**
* Get the excerpt for this blog post
*
* @param int $length Length of the excerpt (optional)
* @return string
* @since 1.9.0
*/
public function getExcerpt($length = 250)
{
if ($this->excerpt) {
return $this->excerpt;
} else {
return elgg_get_excerpt($this->description, $length);
}
}
示例4: getURL
/**
* Get the URL for this entity
*
* @see ElggEntity::getURL()
*
* @return string
*/
public function getURL()
{
$title = $this->title;
if (strlen($title) > 50) {
$title = elgg_get_excerpt($title, 50);
}
$title = str_replace("...", "", $title);
return elgg_normalize_url("user_support/support_ticket/" . $this->getGUID() . "/" . elgg_get_friendly_title($title));
}
示例5: renderTable
protected function renderTable($limit, $offset = 0)
{
static $count;
static $iterator;
$options = ['query' => sanitize_string($this->option('keyword')), 'guids' => $this->option('guid') ?: ELGG_ENTITIES_ANY_VALUE, 'types' => $this->option('type') ?: 'object', 'subtypes' => $this->option('subtype') ?: ELGG_ENTITIES_ANY_VALUE, 'limit' => $limit, 'offset' => (int) $offset, 'order_by' => 'e.guid ASC'];
if ($this->option('keyword')) {
$results = elgg_trigger_plugin_hook('search', $this->option('type') ?: 'object', $options, []);
$count = $results['count'];
$batch = $results['entities'];
} else {
$options['count'] = true;
if (!$count) {
$count = elgg_get_entities($options);
}
unset($options['count']);
$batch = new ElggBatch('elgg_get_entities', $options);
}
if (!$count) {
$this->write('<comment>No entities to display</comment>');
return;
}
$headers = ['#', 'GUID', 'Type', 'Title/name', 'Description', 'Owner', 'Container', 'Access'];
if ($this->option('full-view')) {
$headers[] = 'Metadata';
}
$table = new Table($this->output);
$table->setHeaders($headers);
foreach ($batch as $entity) {
/* @var $entity \ElggEntity */
$row = [$iterator, $entity->guid, ($subtype = $entity->getSubtype()) ? elgg_echo("item:{$entity->type}:{$subtype}") : elgg_echo("item:{$entity->type}"), elgg_get_excerpt($entity->getDisplayName(), 25), elgg_get_excerpt($entity->description, 25), ($owner = $entity->getOwnerEntity()) ? '[' . $owner->guid . '] ' . elgg_get_excerpt($owner->getDisplayName(), 25) : '', ($container = $entity->getContainerEntity()) ? '[' . $container->guid . '] ' . elgg_get_excerpt($container->getDisplayName(), 25) : '', '[' . $entity->access_id . '] ' . elgg_get_excerpt(get_readable_access_level($entity->access_id), 25)];
if ($this->option('full-view')) {
$metadata = new \ElggBatch('elgg_get_metadata', ['guids' => $entity->guid, 'limit' => 0]);
$metatable = [];
foreach ($metadata as $md) {
$name = $md->name;
$values = (array) $md->value;
foreach ($values as $value) {
$metatable[] = "{$name}: {$value}";
}
}
$row[] = implode("\n", $metatable);
}
$table->addRow($row);
$table->addRow(new TableSeparator());
$iterator++;
}
$table->render();
if ($count > $limit + $offset) {
$helper = $this->getHelper('question');
$question = new ConfirmationQuestion('Load next batch [y,n]?', true);
if (!$helper->ask($this->input, $this->output, $question)) {
return;
}
$this->renderTable($limit, $limit + $offset);
}
}
示例6: getTargetName
/**
* Get display name of the notification target
*
* @return string $name Display name
*/
public function getTargetName()
{
$name = elgg_echo('unknown');
$target = $this->getTarget();
if (!$target) {
// This may happen if the target owner changes the ACL
// after the notification has already been created
return $name;
}
$name = $target->getDisplayName();
if (empty($name) && $target->description) {
$name = elgg_get_excerpt($target->description, 20);
}
return $name;
}
示例7: createPoll
/**
* Change the notification contents
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param \Elgg\Notifications\Notification $return_value current return value
* @param array $params supplied params
*
* @return void|\Elgg\Notifications\Notification
*/
public static function createPoll($hook, $type, $return_value, $params)
{
if (empty($params) || !is_array($params)) {
return;
}
$event = elgg_extract('event', $params);
if (!$event instanceof \Elgg\Notifications\Event) {
return;
}
$entity = $event->getObject();
$actor = $event->getActor();
$language = elgg_extract('language', $params);
$return_value->subject = elgg_echo('poll:notification:create:subject', [$entity->title], $language);
$return_value->summary = elgg_echo('poll:notification:create:summary', [$entity->title], $language);
$return_value->body = elgg_echo('poll:notification:create:body', [$actor->name, $entity->title, elgg_get_excerpt($entity->description), $entity->getURL()], $language);
return $return_value;
}
示例8: prepareCreateEventNotification
/**
* Prepare a notification message about a created event
*
* @param string $hook Hook name
* @param string $type Hook type
* @param Elgg_Notifications_Notification $notification The notification to prepare
* @param array $params Hook parameters
*
* @return Elgg_Notifications_Notification
*/
public static function prepareCreateEventNotification($hook, $type, $notification, $params)
{
$entity = $params['event']->getObject();
$owner = $params['event']->getActor();
$language = $params['language'];
$subject = elgg_echo('event_manager:notification:subject', [], $language);
$summary = elgg_echo('event_manager:notification:summary', [], $language);
$body = elgg_echo('event_manager:notification:body', [$owner->name, $entity->title], $language);
if ($description = $entity->description) {
$body .= PHP_EOL . PHP_EOL . elgg_get_excerpt($description);
}
$body .= PHP_EOL . PHP_EOL . $entity->getURL();
$notification->subject = $subject;
$notification->body = $body;
$notification->summary = $summary;
return $notification;
}
示例9: share_notify_user
/**
* Notify $user that $sharer shared his $entity.
*
* @param type $user
* @param type $sharer
* @param type $entity
*/
function share_notify_user(ElggUser $user, ElggUser $sharer, ElggEntity $entity)
{
if (!$user instanceof ElggUser) {
return false;
}
if (!$sharer instanceof ElggUser) {
return false;
}
if (!$entity instanceof ElggEntity) {
return false;
}
$title_str = $entity->title;
if (!$title_str) {
$title_str = elgg_get_excerpt($entity->description);
}
$site = get_config('site');
$subject = elgg_echo('share:notifications:subject', array($sharer->name, $title_str));
$body = elgg_echo('share:notifications:body', array($user->name, $sharer->name, $title_str, $site->name, $entity->getURL(), $sharer->getURL()));
notify_user($user->guid, $sharer->guid, $subject, $body);
}
示例10: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$entity_guid = (int) $params->guid;
//check to see if the user has already liked the item
if (elgg_annotation_exists($entity_guid, 'likes')) {
throw new GraphException(elgg_echo("likes:alreadyliked"), HttpResponse::HTTP_NOT_MODIFIED);
}
// Let's see if we can get an entity with the specified GUID
$entity = get_entity($entity_guid);
if (!$entity) {
throw new GraphException(elgg_echo("likes:notfound"), HttpResponse::HTTP_NOT_FOUND);
}
// limit likes through a plugin hook (to prevent liking your own content for example)
if (!$entity->canAnnotate(0, 'likes')) {
// plugins should register the error message to explain why liking isn't allowed
throw new GraphException(elgg_echo("likes:notallowed"), HttpResponse::HTTP_FORBIDDEN);
}
$user = elgg_get_logged_in_user_entity();
$annotation_id = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id);
// tell user annotation didn't work if that is the case
if (!$annotation_id) {
throw new GraphException(elgg_echo("likes:failure"));
}
// notify if poster wasn't owner
if ($entity->owner_guid != $user->guid) {
$owner = $entity->getOwnerEntity();
$annotation = elgg_get_annotation_from_id($annotation_id);
$title_str = $entity->getDisplayName();
if (!$title_str) {
$title_str = elgg_get_excerpt($entity->description);
}
$site = elgg_get_site_entity();
$subject = elgg_echo('likes:notifications:subject', array($user->name, $title_str), $owner->language);
$body = elgg_echo('likes:notifications:body', array($owner->name, $user->name, $title_str, $site->name, $entity->getURL(), $user->getURL()), $owner->language);
notify_user($entity->owner_guid, $user->guid, $subject, $body, array('action' => 'create', 'object' => $annotation));
}
return array('nodes' => array(elgg_get_annotation_from_id($annotation_id)));
}
示例11: elgg_tokeninput_export_entity
/**
* Get exportable entity values
*
* @param ElggEntity $entity
* @return array
*/
function elgg_tokeninput_export_entity($entity)
{
if (!elgg_instanceof($entity)) {
if ($entity_from_guid = get_entity($entity)) {
$entity = $entity_from_guid;
} else {
return elgg_tokeninput_export_metadata($entity);
}
}
$type = $entity->getType();
$subtype = $entity->getSubtype();
$icon = elgg_view_entity_icon($entity, 'small', array('use_hover' => false));
if (elgg_instanceof($entity, 'user')) {
$title = "{$entity->name} ({$entity->username})";
} else {
if (elgg_instanceof($entity, 'group')) {
$title = $entity->name;
} else {
$title = $entity->getDisplayName();
if (!$title) {
$title = elgg_echo('untitled');
}
$metadata[] = elgg_echo('byline', array($entity->getOwnerEntity()->name));
}
}
if ($entity->description) {
$metadata[] = elgg_get_excerpt(elgg_strip_tags($entity->description), 100);
}
if ($entity->location) {
$metadata[] = $entity->location;
}
$export = array('label' => $title, 'value' => $entity->guid, 'metadata' => $metadata ? implode('<br />', $metadata) : '', 'icon' => $icon, 'type' => $type, 'subtype' => $subtype, 'html_result' => elgg_view_exists("tokeninput/{$type}/{$subtype}") ? elgg_view("tokeninput/{$type}/{$subtype}", array('entity' => $entity, 'for' => 'result')) : null, 'html_token' => elgg_view_exists("tokeninput/{$type}/{$subtype}") ? elgg_view("tokeninput/{$type}/{$subtype}", array('entity' => $entity, 'for' => 'token')) : null);
$export = elgg_trigger_plugin_hook('tokeninput:entity:export', $type, array('entity' => $entity), $export);
array_walk_recursive($export, function (&$value) {
$value = is_string($value) ? html_entity_decode($value, ENT_QUOTES, 'UTF-8') : $value;
});
return $export;
}
示例12: elgg_view_image_block
{$anchor}
<div class="mbn">
\t{$menu}
\t{$commenter_link}
\t<span class="elgg-subtext">
\t\t{$friendlytime}
\t</span>
\t{$comment_text}
</div>
HTML;
if ($moderating) {
$html = elgg_view_image_block($commenter_icon, $body);
echo elgg_view_image_block($checkbox, $html, array('class' => 'moderated-comment'));
} else {
echo elgg_view_image_block($commenter_icon, $body);
}
} else {
// brief view
$excerpt = elgg_get_excerpt($comment->description, 80);
$posted = elgg_echo('generic_comment:on', array($commenter_link, $entity_link));
$body = <<<HTML
<span class="elgg-subtext">
\t{$posted} ({$friendlytime}): {$excerpt}
</span>
HTML;
if ($moderating) {
echo elgg_view_image_block($commenter_icon, $body, array('class' => 'moderated-comment'));
} else {
echo elgg_view_image_block($commenter_icon, $body);
}
}
示例13: elgg_echo
if ($blogs = elgg_get_entities($blog_options)) {
if ($vars['email']) {
$title = "<h2 class='email'>" . elgg_echo("blog:blogs") . "</h2>";
$title .= "<h5 class='email'>To view all site blogs visit " . elgg_get_site_url() . "blog/all?filter=newest </h5>";
$latest_blogs = "<div class='email-section'>";
foreach ($blogs as $blog) {
$latest_blogs .= "<div class='blog'>";
$latest_blogs .= "<h4 class='email'>" . $blog->title . "</h4>";
$latest_blogs .= "<p>" . elgg_get_excerpt($blog->description) . "</p>";
$latest_blogs .= "</div>";
}
$latest_blogs .= "</div>";
echo $title . $latest_blogs;
} else {
$title = elgg_echo("blog:blogs");
$title .= "<h5>To view all site blogs visit " . elgg_get_site_url() . "blog/all?filter=newest </h5>";
$latest_blogs = "";
foreach ($blogs as $blog) {
$latest_blogs .= "<div class='digest-blog'>";
if ($blog->icontime) {
$latest_blogs .= "<img src='" . $blog->getIconURL("medium") . "' />";
}
$latest_blogs .= "<span>";
$latest_blogs .= "<h4>" . $blog->title . "</h4>";
$latest_blogs .= elgg_get_excerpt($blog->description);
$latest_blogs .= "</span>";
$latest_blogs .= "</div>";
}
echo elgg_view_module("digest", $title, $latest_blogs);
}
}
示例14: elgg_push_context
<?php
elgg_push_context('activity');
$item = elgg_extract('item', $vars);
$subject = $item->getSubjectEntity();
$object = $item->getObjectEntity();
$subject_link = elgg_view('framework/bootstrap/user/elements/name', array('entity' => $subject));
$object_link = elgg_view('framework/bootstrap/object/elements/title', array('entity' => $object));
$breadcrumbs = elgg_view('framework/bootstrap/object/elements/breadcrumbs', array('entity' => $object));
if (!empty($breadcrumbs)) {
$breadcrumbs_link = elgg_echo('river:in:forum', array($breadcrumbs));
}
$key = "river:create:object:hjforum";
$summary = elgg_echo($key, array($subject_link, $object_link)) . $breadcrumbs_link;
echo elgg_view('river/item', array('item' => $item, 'message' => elgg_get_excerpt(strip_tags($object->description)), 'summary' => $summary));
elgg_pop_context();
示例15: elgg_view
<?php
/**
* Short summary of the action that occurred
*
* @vars['item'] ElggRiverItem
*/
$item = $vars['item'];
$subject = $item->getSubjectEntity();
$object = $item->getObjectEntity();
$target = $object->getContainerEntity();
$subject_link = elgg_view('output/url', array('href' => $subject->getURL(), 'text' => $subject->name, 'class' => 'elgg-river-subject', 'is_trusted' => true));
$object_text = $object->title ? $object->title : $object->name;
$object_link = elgg_view('output/url', array('href' => $object->getURL(), 'text' => elgg_get_excerpt($object_text, 100), 'class' => 'elgg-river-object', 'is_trusted' => true));
$action = $item->action_type;
$type = $item->type;
$subtype = $item->subtype ? $item->subtype : 'default';
$container = $object->getContainerEntity();
if ($container instanceof ElggGroup) {
$params = array('href' => $container->getURL(), 'text' => $container->name, 'is_trusted' => true);
$group_link = elgg_view('output/url', $params);
$group_string = elgg_echo('river:ingroup', array($group_link));
}
// check summary translation keys.
// will use the $type:$subtype if that's defined, otherwise just uses $type:default
$key = "river:{$action}:{$type}:{$subtype}";
$summary = elgg_echo($key, array($subject_link, $object_link));
if ($summary == $key) {
$key = "river:{$action}:{$type}:default";
$summary = elgg_echo($key, array($subject_link, $object_link));
}