当前位置: 首页>>代码示例>>PHP>>正文


PHP ElggEntity类代码示例

本文整理汇总了PHP中ElggEntity的典型用法代码示例。如果您正苦于以下问题:PHP ElggEntity类的具体用法?PHP ElggEntity怎么用?PHP ElggEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ElggEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: advanced_notifications_is_registered_notification_entity

/**
 * Checks if the given $entity is registered for notifications by
 * register_notification_object()
 *
 * @param ElggEntity $entity  the entity to check
 * @param bool       $subject return the subject string (default=false)
 *
 * @return bool|string
 */
function advanced_notifications_is_registered_notification_entity(ElggEntity $entity, $subject = false)
{
    $result = false;
    if (!empty($entity) && $entity instanceof ElggEntity) {
        $type = $entity->getType();
        if (empty($type)) {
            $type = "__BLANK__";
        }
        $subtype = $entity->getSubtype();
        if (empty($subtype)) {
            $subtype = "__BLANK__";
        }
        // get the registered entity -> type/subtype
        $notifications = elgg_get_config("register_objects");
        if (!empty($notifications) && is_array($notifications)) {
            if (isset($notifications[$type]) && isset($notifications[$type][$subtype])) {
                if ($subject) {
                    $result = $notifications[$type][$subtype];
                } else {
                    $result = true;
                }
            }
        }
    }
    return $result;
}
开发者ID:juliendangers,项目名称:advanced_notifications,代码行数:35,代码来源:functions.php

示例2: pages_register_navigation_tree

/**
 * Register the navigation menu
 * 
 * @param ElggEntity $container Container entity for the pages
 */
function pages_register_navigation_tree($container)
{
    if (!$container) {
        return;
    }
    $top_pages = elgg_get_entities(array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => 0));
    if (!$top_pages) {
        return;
    }
    foreach ($top_pages as $page) {
        elgg_register_menu_item('pages_nav', array('name' => $page->getGUID(), 'text' => $page->title, 'href' => $page->getURL()));
        $stack = array();
        array_push($stack, $page);
        while (count($stack) > 0) {
            $parent = array_pop($stack);
            $children = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => 0));
            if ($children) {
                foreach ($children as $child) {
                    elgg_register_menu_item('pages_nav', array('name' => $child->getGUID(), 'text' => $child->title, 'href' => $child->getURL(), 'parent_name' => $parent->getGUID()));
                    array_push($stack, $child);
                }
            }
        }
    }
}
开发者ID:nogsus,项目名称:Elgg,代码行数:30,代码来源:pages.php

示例3: questions_workflow_enabled

/**
 * This function checks if the questions workflow is enabled in the plugin settings and for the given container
 *
 * @return bool true is enabled, false otherwise
 */
function questions_workflow_enabled(ElggEntity $container = null)
{
    if ($container && $container instanceof ElggGroup) {
        return $container->getPrivateSetting('questions_workflow_enabled') == "yes";
    }
    return elgg_get_plugin_setting("workflow_enabled", "questions") == "yes";
}
开发者ID:Pleio,项目名称:questions,代码行数:12,代码来源:functions.php

示例4: pages_get_navigation_tree

/**
 * Produce the navigation tree
 * 
 * @param ElggEntity $container Container entity for the pages
 *
 * @return array
 */
function pages_get_navigation_tree($container)
{
    if (!$container) {
        return;
    }
    $top_pages = elgg_get_entities(array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => 0));
    if (!$top_pages) {
        return;
    }
    /* @var ElggObject[] $top_pages */
    $tree = array();
    $depths = array();
    foreach ($top_pages as $page) {
        $tree[] = array('guid' => $page->getGUID(), 'title' => $page->title, 'url' => $page->getURL(), 'depth' => 0);
        $depths[$page->guid] = 0;
        $stack = array();
        array_push($stack, $page);
        while (count($stack) > 0) {
            $parent = array_pop($stack);
            $children = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => 0));
            if ($children) {
                foreach ($children as $child) {
                    $tree[] = array('guid' => $child->getGUID(), 'title' => $child->title, 'url' => $child->getURL(), 'parent_guid' => $parent->getGUID(), 'depth' => $depths[$parent->guid] + 1);
                    $depths[$child->guid] = $depths[$parent->guid] + 1;
                    array_push($stack, $child);
                }
            }
        }
    }
    return $tree;
}
开发者ID:tjcaverly,项目名称:Elgg,代码行数:38,代码来源:pages.php

示例5: canReshareEntity

 /**
  * Check if resharing of this entity is allowed
  *
  * @param \ElggEntity $entity the entity to check
  *
  * @return bool
  */
 protected static function canReshareEntity(\ElggEntity $entity)
 {
     if (!$entity instanceof \ElggEntity) {
         return false;
     }
     // only allow objects and groups
     if (!$entity instanceof \ElggObject && !$entity instanceof \ElggGroup) {
         return false;
     }
     // comments and discussion replies are never allowed
     $blocked_subtypes = ['comment', 'discussion_reply'];
     if (in_array($entity->getSubtype(), $blocked_subtypes)) {
         return false;
     }
     // by default allow searchable entities
     $reshare_allowed = false;
     if ($entity instanceof \ElggGroup) {
         $reshare_allowed = true;
     } else {
         $searchable_entities = get_registered_entity_types($entity->getType());
         if (!empty($searchable_entities)) {
             $reshare_allowed = in_array($entity->getSubtype(), $searchable_entities);
         }
     }
     // trigger hook to allow others to change
     $params = ['entity' => $entity, 'user' => elgg_get_logged_in_user_entity()];
     return (bool) elgg_trigger_plugin_hook('reshare', $entity->getType(), $params, $reshare_allowed);
 }
开发者ID:coldtrick,项目名称:thewire_tools,代码行数:35,代码来源:Menus.php

示例6: actions_feature_is_allowed_type

/**
 * Check if entity type is registered for feature/unfeature
 *
 * @param ElggEntity $entity Entity to be featured
 * @return bool
 */
function actions_feature_is_allowed_type(ElggEntity $entity)
{
    $type = $entity->getType();
    $subtype = $entity->getSubtype();
    $hook_type = implode(':', array_filter([$type, $subtype]));
    return elgg_trigger_plugin_hook('feature', $hook_type, ['entity' => $entity], false);
}
开发者ID:hypeJunction,项目名称:Elgg-actions_feature,代码行数:13,代码来源:start.php

示例7: removeAdmin

 /**
  * listen to the remove admin event to unset the toggle admin flag
  *
  * @param string     $event  the event
  * @param string     $type   the type of the event
  * @param ElggEntity $entity the affected entity
  *
  * @return void
  */
 public static function removeAdmin($event, $type, $entity)
 {
     if (!$entity instanceof \ElggUser) {
         return;
     }
     elgg_unset_plugin_user_setting('switched_admin', $entity->getGUID(), 'admin_tools');
 }
开发者ID:coldtrick,项目名称:admin_tools,代码行数:16,代码来源:Admin.php

示例8: oddmetadata_to_elggextender

/**
 * Utility function used by import_extender_plugin_hook() to process
 * an ODDMetaData and add it to an entity. This function does not
 * hit ->save() on the entity (this lets you construct in memory)
 *
 * @param ElggEntity  $entity  The entity to add the data to.
 * @param ODDMetaData $element The OpenDD element
 *
 * @return bool
 * @access private
 */
function oddmetadata_to_elggextender(ElggEntity $entity, ODDMetaData $element)
{
    // Get the type of extender (metadata, type, attribute etc)
    $type = $element->getAttribute('type');
    $attr_name = $element->getAttribute('name');
    $attr_val = $element->getBody();
    switch ($type) {
        // Ignore volatile items
        case 'volatile':
            break;
        case 'annotation':
            $entity->annotate($attr_name, $attr_val);
            break;
        case 'metadata':
            $entity->setMetaData($attr_name, $attr_val, "", true);
            break;
        default:
            // Anything else assume attribute
            $entity->set($attr_name, $attr_val);
    }
    // Set time if appropriate
    $attr_time = $element->getAttribute('published');
    if ($attr_time) {
        $entity->set('time_updated', $attr_time);
    }
    return true;
}
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:38,代码来源:extender.php

示例9: thewire_tools_url_handler

/**
 * Custom URL handler for thewire objects
 *
 * @param ElggEntity $entity the entity to make the URL for
 *
 * @return string the URL
 */
function thewire_tools_url_handler(ElggEntity $entity)
{
    if ($entity->getContainerEntity() instanceof ElggGroup) {
        $entity_url = elgg_get_site_url() . "thewire/group/" . $entity->getContainer();
    } else {
        $entity_url = elgg_get_site_url() . "thewire/owner/" . $entity->getOwnerEntity()->username;
    }
    return $entity_url;
}
开发者ID:T4SG,项目名称:Bangalore-Team-5,代码行数:16,代码来源:start.php

示例10: getRowCells

 /**
  * Map column headers to a proper representation in the row cell
  * @param ElggEntity $entity
  * @param boolean $csv
  * @return array
  */
 public function getRowCells($entity)
 {
     $row = array();
     $headers = $this->getColumnHeaders();
     foreach ($headers as $header => $label) {
         $value = '';
         switch ($header) {
             default:
                 $value = $entity->{$header};
                 if (is_array($value)) {
                     $value = implode('; ', $value);
                 }
                 break;
             case 'guid':
                 $value = $entity->guid;
                 break;
             case 'icon':
                 $value = $entity->getIconURL();
                 if (!elgg_in_context('plaintext')) {
                     $value = elgg_view_entity_icon($entity, 'small');
                 }
                 break;
             case 'title':
                 $value = elgg_instanceof($entity, 'object') ? $entity->title : $entity->name;
                 if (!elgg_in_context('plaintext')) {
                     $value = elgg_view('output/url', array('text' => $value, 'href' => $entity->getURL()));
                 }
                 break;
             case 'time_created':
                 $value = date('M d, Y H:i', $entity->time_created);
                 break;
             case 'owner_guid':
                 $value = '';
                 $owner = $entity->getOwnerEntity();
                 if (elgg_instanceof($owner)) {
                     $value = $owner->guid;
                     if (!elgg_in_context('plaintext')) {
                         $value = elgg_view('output/url', array('text' => elgg_instanceof($owner, 'object') ? $owner->title : $owner->name, 'href' => $owner->getURL()));
                     }
                 }
                 break;
             case 'container_guid':
                 $value = '';
                 $container = $entity->getContainerEntity();
                 if (elgg_instanceof($container)) {
                     $value = $container->guid;
                     if (!elgg_in_context('plaintext')) {
                         $value = elgg_view('output/url', array('text' => elgg_instanceof($container, 'object') ? $container->title : $container->name, 'href' => $container->getURL()));
                     }
                 }
                 break;
         }
         $row[$header] = $value;
     }
     return elgg_trigger_plugin_hook('export:entity', 'table', array('headers' => $this->getColumnHeaders(), 'entity' => $entity), $row);
 }
开发者ID:Daltonmedia,项目名称:hypeLists,代码行数:62,代码来源:ElggTable.php

示例11: createRandomAnnotations

 /**
  * Creates random annotations on $entity
  *
  * @param \ElggEntity $entity
  * @param int        $max
  */
 protected function createRandomAnnotations($entity, $max = 1)
 {
     $annotations = array();
     for ($i = 0; $i < $max; $i++) {
         $name = 'test_annotation_name_' . rand();
         $value = rand();
         $id = create_annotation($entity->getGUID(), $name, $value, 'integer', $entity->getGUID());
         $annotations[] = elgg_get_annotation_from_id($id);
     }
     return $annotations;
 }
开发者ID:elgg,项目名称:elgg,代码行数:17,代码来源:ElggCoreGetEntitiesFromAnnotationsTest.php

示例12: Build

 /**
  * @param \ElggEntity $entity
  * @return bool|notification
  */
 public function Build($entity)
 {
     switch ($entity->getSubtype()) {
         case 'sub_comment_notification':
             return new \WizmassNotifier\Notifications\SubCommentNotification($entity);
         case 'rate_comment_notification':
             return new \WizmassNotifier\Notifications\RateCommentNotification($entity);
         default:
             return false;
     }
 }
开发者ID:roybirger,项目名称:elgg-wizmass-notifier,代码行数:15,代码来源:NotificationFactory.php

示例13: toGUID

 /**
  * Get guids from an entity attribute
  *
  * @param ElggEntity|int $entity Entity or GUID
  * @return int
  */
 protected function toGUID($entity = null)
 {
     if ($entity instanceof ElggEntity) {
         return (int) $entity->getGUID();
     } else {
         if ($this->exists($entity)) {
             return (int) $entity;
         }
     }
     return false;
 }
开发者ID:n8b,项目名称:VMN,代码行数:17,代码来源:ItemCollection.php

示例14: likes_count

/**
 * Count how many people have liked an entity.
 *
 * @param  ElggEntity $entity 
 *
 * @return int Number of likes
 */
function likes_count($entity)
{
    $type = $entity->getType();
    $params = array('entity' => $entity);
    $number = elgg_trigger_plugin_hook('likes:count', $type, $params, false);
    if ($number) {
        return $number;
    } else {
        return $entity->countAnnotations('likes');
    }
}
开发者ID:rasul,项目名称:Elgg,代码行数:18,代码来源:start.php

示例15: hj_framework_set_entity_priority

/**
 * Set priority of an element in a list
 *
 * @see ElggEntity::$priority
 *
 * @param ElggEntity $entity
 * @return bool
 */
function hj_framework_set_entity_priority($entity, $priority = null)
{
    if ($priority) {
        $entity->priority = $priority;
        return true;
    }
    $count = elgg_get_entities(array('type' => $entity->getType(), 'subtype' => $entity->getSubtype(), 'owner_guid' => $entity->owner_guid, 'container_guid' => $entity->container_guid, 'count' => true));
    if (!$entity->priority) {
        $entity->priority = $count + 1;
    }
    return true;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:20,代码来源:base.php


注:本文中的ElggEntity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。