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


PHP get_subtype_class函数代码示例

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


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

示例1: testSubtypeClasses

 /**
  * Test gallery entity classes have been registered correctly
  */
 public function testSubtypeClasses()
 {
     $album_class = get_subtype_class('object', hjAlbum::SUBTYPE);
     $image_class = get_subtype_class('object', hjAlbumImage::SUBTYPE);
     $this->assertEqual($album_class, get_class(new hjAlbum()));
     $this->assertEqual($image_class, get_class(new hjAlbumImage()));
 }
开发者ID:juho-jaakkola,项目名称:hypeGallery,代码行数:10,代码来源:entities.php

示例2: user_support_faq_class_update

/**
* This function adds a class handler to object->faq
* Since the old FAQ didn't had a class
*
* @return bool
*/
function user_support_faq_class_update()
{
    $class = get_subtype_class("object", UserSupportFAQ::SUBTYPE);
    if ($class != "UserSupportFAQ") {
        return update_subtype("object", UserSupportFAQ::SUBTYPE, "UserSupportFAQ");
    }
    return true;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:14,代码来源:run_once.php

示例3: fixClasses

 public static function fixClasses($event, $type, $object)
 {
     $classes = ['\\ColdTrick\\EventManager\\Event\\Day', '\\ColdTrick\\EventManager\\Event\\Slot'];
     foreach ($classes as $class) {
         if (get_subtype_class('object', $class::SUBTYPE) !== $class) {
             update_subtype('object', $class::SUBTYPE, $class);
         }
     }
 }
开发者ID:coldtrick,项目名称:event_manager,代码行数:9,代码来源:Upgrade.php

示例4: profile_manager_plugins_boot

/**
 * Performs class upgrade before init as classes are needed during init
 *
 * @return void
 */
function profile_manager_plugins_boot()
{
    $classes = ['\\ColdTrick\\ProfileManager\\CustomProfileField', '\\ColdTrick\\ProfileManager\\CustomGroupField', '\\ColdTrick\\ProfileManager\\CustomProfileType', '\\ColdTrick\\ProfileManager\\CustomFieldCategory'];
    foreach ($classes as $class) {
        $current_class = get_subtype_class('object', $class::SUBTYPE);
        if ($current_class !== $class) {
            update_subtype('object', $class::SUBTYPE, $class);
        }
    }
}
开发者ID:coldtrick,项目名称:profile_manager,代码行数:15,代码来源:start.php

示例5: save

 /**
  * Saves uploaded file to ElggFile with given attributes
  *
  * @param array  $attributes New file attributes and metadata
  * @apara string $prefix     Filestore prefix
  * @return \Upload
  */
 public function save(array $attributes = array(), $prefix = self::DEFAULT_FILESTORE_PREFIX)
 {
     $this->error_code = $this->error;
     $this->error = $this->getError();
     $this->filesize = $this->size;
     $this->path = $this->tmp_name;
     $this->mimetype = $this->detectMimeType();
     $this->simpletype = $this->parseSimpleType();
     if (!$this->isSuccessful()) {
         return $this;
     }
     $prefix = trim($prefix, '/');
     if (!$prefix) {
         $prefix = self::DEFAULT_FILESTORE_PREFIX;
     }
     $id = elgg_strtolower(time() . $this->name);
     $filename = implode('/', array($prefix, $id));
     $type = elgg_extract('type', $attributes, 'object');
     $subtype = elgg_extract('subtype', $attributes, 'file');
     $class = get_subtype_class($type, $subtype);
     if (!$class) {
         $class = '\\ElggFile';
     }
     try {
         $filehandler = new $class();
         foreach ($attributes as $key => $value) {
             $filehandler->{$key} = $value;
         }
         $filehandler->setFilename($filename);
         $filehandler->title = $this->name;
         $filehandler->originalfilename = $this->name;
         $filehandler->filesize = $this->size;
         $filehandler->mimetype = $this->mimetype;
         $filehandler->simpletype = $this->simpletype;
         $filehandler->open("write");
         $filehandler->close();
         if ($this->simpletype == 'image') {
             $img = new \hypeJunction\Files\Image($this->tmp_name);
             $img->save($filehandler->getFilenameOnFilestore(), hypeApps()->config->getSrcCompressionOpts());
         } else {
             move_uploaded_file($this->tmp_name, $filehandler->getFilenameOnFilestore());
         }
         if ($filehandler->save()) {
             $this->guid = $filehandler->getGUID();
             $this->file = $filehandler;
         }
     } catch (\Exception $ex) {
         elgg_log($ex->getMessage(), 'ERROR');
         $this->error = elgg_echo('upload:error:unknown');
     }
     return $this;
 }
开发者ID:n8b,项目名称:VMN,代码行数:59,代码来源:Upload.php

示例6: csv_exporter_get_exportable_values

/**
 * Get a list of all the exportable values for the given type/subtype
 *
 * @param string $type     the entity type
 * @param string $subtype  the entity subtype
 * @param bool   $readable readable values or just for processing (default: false)
 *
 * @return array
 */
function csv_exporter_get_exportable_values($type, $subtype = '', $readable = false)
{
    $result = [];
    if (empty($type)) {
        return $result;
    }
    if ($type == 'object' && empty($subtype)) {
        return $result;
    }
    $class = get_subtype_class($type, $subtype);
    if (!empty($class)) {
        $dummy = new $class();
    } else {
        switch ($type) {
            case 'object':
                $dummy = new ElggObject();
                break;
            case 'group':
                $dummy = new ElggGroup();
                break;
            case 'site':
                $dummy = new ElggSite();
                break;
            case 'user':
                $dummy = new ElggUser();
                break;
        }
    }
    $exports = (array) $dummy->toObject();
    $defaults = array_keys($exports);
    if ($readable) {
        $new_defaults = [];
        foreach ($defaults as $name) {
            if (elgg_language_key_exists($name)) {
                $lan = elgg_echo($name);
            } elseif (elgg_language_key_exists("csv_exporter:exportable_value:{$name}")) {
                $lan = elgg_echo("csv_exporter:exportable_value:{$name}");
            } else {
                $lan = $name;
            }
            $new_defaults[$lan] = $name;
        }
        $defaults = $new_defaults;
    }
    $params = ['type' => $type, 'subtype' => $subtype, 'readable' => $readable, 'defaults' => $defaults];
    $result = elgg_trigger_plugin_hook('get_exportable_values', 'csv_exporter', $params, $defaults);
    if (is_array($result)) {
        // prevent duplications
        $result = array_unique($result);
    }
    return $result;
}
开发者ID:coldtrick,项目名称:csv_exporter,代码行数:61,代码来源:functions.php

示例7: execute

 /**
  * {@inheritdoc}
  *
  * @tip: if you are extending the category form, use can access these values in the volatileData of the category
  */
 public function execute()
 {
     $nodes = array();
     $config = $this->input_categories;
     foreach ($config['hierarchy'] as $key => $node_id) {
         $node_id = (int) $node_id;
         $guid = (int) $config['guid'][$key];
         $title = $config['title'][$key];
         $desc = $config['description'][$key];
         $access_id = $config['access_id'][$key];
         $subtype = $config['subtype'][$key];
         $category = get_entity($guid);
         if (!$category) {
             $class = get_subtype_class('object', $subtype) ?: get_class(new ElggObject());
             $category = new $class();
             $category->subtype = $subtype ? $subtype : hypeCategories()->config->get('subtype');
             $category->owner_guid = elgg_get_logged_in_user_guid();
             $category->container_guid = $this->root_guid;
         }
         if (!$category) {
             $nodes[$node_id] = false;
             continue;
         }
         if (!$title) {
             $category->delete();
             $nodes[$node_id] = false;
             continue;
         } else {
             $category->title = $title;
             $category->description = $desc;
             $category->access_id = $access_id;
             $category->priority = $key + 1;
             // we don't want 0
             $form_values = array();
             foreach ($config as $param_name => $entity_params) {
                 $form_values[$param_name] = $entity_params[$key];
             }
             $category->setVolatileData('formValues', $form_values);
             $category->save();
         }
         if ($_FILES['categories']['error']['icon'][$key] == UPLOAD_ERR_OK) {
             hypeApps()->iconFactory->create($category, $_FILES['categories']['tmp_name']['icon'][$key]);
         }
         $nodes[$node_id] = $category;
     }
     $this->nodes = $nodes;
     foreach ($this->hierarchy as $key => $root) {
         $this->updateHierarchy((int) $root['id'], $root['children']);
     }
     $this->result->addMessage(elgg_echo('categories:manage:success'));
 }
开发者ID:hypejunction,项目名称:hypecategories,代码行数:56,代码来源:ManageCategories.php

示例8: widget_manager_init

function widget_manager_init()
{
    // check valid WidgetManagerWidget class
    if (get_subtype_class("object", "widget") == "ElggWidget") {
        update_subtype("object", "widget", "WidgetManagerWidget");
    }
    elgg_trigger_event("widgets_init", "widget_manager");
    if (elgg_is_active_plugin("groups") && elgg_get_plugin_setting("group_enable", "widget_manager") == "yes") {
        // add the widget manager tool option
        $group_option_enabled = false;
        if (elgg_get_plugin_setting("group_option_default_enabled", "widget_manager") == "yes") {
            $group_option_enabled = true;
        }
        if (elgg_get_plugin_setting("group_option_admin_only", "widget_manager") != "yes") {
            // add the tool option for group admins
            add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled);
        } elseif (elgg_is_admin_logged_in()) {
            add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled);
        } elseif ($group_option_enabled) {
            // register event to make sure newly created groups have the group option enabled
            elgg_register_event_handler("create", "group", "widget_manager_create_group_event_handler");
            elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'widget_manager_group_widgets_default_list');
        }
    }
    // extend CSS
    elgg_extend_view("css/elgg", "widget_manager/css/global");
    elgg_extend_view("css/admin", "widget_manager/css/global");
    elgg_extend_view("js/elgg", "widget_manager/js/site");
    elgg_extend_view("js/admin", "widget_manager/js/admin");
    // register a widget title url handler
    elgg_register_entity_url_handler("object", "widget", "widget_manager_widget_url_handler");
    // multi dashboard support
    add_subtype("object", MultiDashboard::SUBTYPE, "MultiDashboard");
    if (elgg_is_logged_in() && widget_manager_multi_dashboard_enabled()) {
        elgg_register_page_handler("multi_dashboard", "widget_manager_multi_dashboard_page_handler");
        $options = array("type" => "object", "subtype" => MultiDashboard::SUBTYPE, "owner_guid" => elgg_get_logged_in_user_guid(), "count" => true);
        $tab_count = elgg_get_entities($options);
        if ($tab_count < MULTI_DASHBOARD_MAX_TABS) {
            elgg_register_menu_item("extras", array("name" => "multi_dashboard", "text" => elgg_view_icon("home"), "href" => "multi_dashboard/edit/?internal_url=" . urlencode(current_page_url()), "title" => elgg_echo("widget_manager:multi_dashboard:extras"), "rel" => "nofollow", "id" => "widget-manager-multi_dashboard-extras"));
        }
        elgg_extend_view("page/elements/sidebar", "widget_manager/multi_dashboard/sidebar", 400);
        elgg_register_event_handler("create", "object", "widget_manager_create_object_handler");
        elgg_register_plugin_hook_handler("route", "dashboard", "widget_manager_dashboard_route_handler");
        elgg_register_plugin_hook_handler("action", "widgets/add", "widget_manager_widgets_add_action_handler");
        elgg_register_action("multi_dashboard/edit", dirname(__FILE__) . "/actions/multi_dashboard/edit.php");
        elgg_register_action("multi_dashboard/delete", dirname(__FILE__) . "/actions/multi_dashboard/delete.php");
        elgg_register_action("multi_dashboard/drop", dirname(__FILE__) . "/actions/multi_dashboard/drop.php");
        elgg_register_action("multi_dashboard/reorder", dirname(__FILE__) . "/actions/multi_dashboard/reorder.php");
    }
}
开发者ID:amcfarlane1251,项目名称:portal,代码行数:50,代码来源:start.php

示例9: csv_exporter_get_exportable_values

/**
 * Get a list of all the exportable values for the given type/subtype
 *
 * @param string $type     the entity type
 * @param string $subtype  the entity subtype
 * @param bool   $readable readable values or just for processing (default: false)
 *
 * @return array
 */
function csv_exporter_get_exportable_values($type, $subtype = "", $readable = false)
{
    $result = array();
    if (empty($type)) {
        return $result;
    }
    if ($type == "object" && empty($subtype)) {
        return $result;
    }
    $class = get_subtype_class($type, $subtype);
    if (!empty($class)) {
        $dummy = new $class();
    } else {
        switch ($type) {
            case "object":
                $dummy = new ElggObject();
                break;
            case "group":
                $dummy = new ElggGroup();
                break;
            case "site":
                $dummy = new ElggSite();
                break;
            case "user":
                $dummy = new ElggUser();
                break;
        }
    }
    $defaults = $dummy->getExportableValues();
    if ($readable) {
        $new_defaults = array();
        foreach ($defaults as $name) {
            if ($name != elgg_echo($name)) {
                $lan = elgg_echo($name);
            } else {
                $lan = elgg_echo("csv_exporter:exportable_value:" . $name);
            }
            $new_defaults[$lan] = $name;
        }
        $defaults = $new_defaults;
    }
    $params = array("type" => $type, "subtype" => $subtype, "readable" => $readable, "defaults" => $defaults);
    $result = elgg_trigger_plugin_hook("get_exportable_values", "csv_exporter", $params, $defaults);
    if (is_array($result)) {
        // prevent duplications
        $result = array_unique($result);
    }
    return $result;
}
开发者ID:pleio,项目名称:csv_exporter,代码行数:58,代码来源:functions.php

示例10: build

 /**
  * Builds an ElggEntity from a set of attributes
  *
  * @param mixed $attributes ElggEntity, GUID or entity attributes, including type and subtype
  * @return ElggEntity
  */
 public function build($attributes = null)
 {
     if ($attributes instanceof \ElggEntity) {
         return $attributes;
     }
     if (is_numeric($attributes)) {
         return $this->get($attributes);
     }
     $attributes = (array) $attributes;
     if (!empty($attributes['guid'])) {
         return $this->get($attributes['guid']);
     }
     $type = elgg_extract('type', $attributes, 'object');
     $subtype = elgg_extract('subtype', $attributes, ELGG_ENTITIES_ANY_VALUE);
     unset($attributes['type']);
     unset($attributes['subtype']);
     $class = get_subtype_class($type, $subtype);
     if (class_exists($class)) {
         $entity = new $class();
     } else {
         switch ($type) {
             case 'object':
                 $entity = new \ElggObject();
                 $entity->subtype = $subtype;
                 break;
             case 'user':
                 $entity = new \ElggUser();
                 $entity->subtype = $subtype;
                 break;
             case 'group':
                 $entity = new \ElggGroup();
                 $entity->subtype = $subtype;
                 break;
         }
     }
     foreach ($attributes as $key => $value) {
         if (in_array($key, $this->getAttributeNames($entity))) {
             $entity->{$key} = $value;
         }
     }
     return $entity;
 }
开发者ID:hypejunction,项目名称:hypeprototyper,代码行数:48,代码来源:EntityFactory.php

示例11: tidypics_is_upgrade_available

/**
 * Are there upgrade scripts to be run?
 *
 * @return bool
 */
function tidypics_is_upgrade_available()
{
    // sets $version based on code
    require_once elgg_get_plugins_path() . "tidypics/version.php";
    $local_version = elgg_get_plugin_setting('version', 'tidypics');
    if ($local_version === null) {
        // no version set so either new install or really old one
        if (!get_subtype_class('object', 'image') || !get_subtype_class('object', 'album')) {
            $local_version = 0;
        } else {
            // set initial version for new install
            elgg_set_plugin_setting('version', $version, 'tidypics');
            $local_version = $version;
        }
    } elseif ($local_version === '1.62') {
        // special work around to handle old upgrade system
        $local_version = 2010010101;
        elgg_set_plugin_setting('version', $local_version, 'tidypics');
    }
    if ($local_version == $version) {
        return false;
    } else {
        return true;
    }
}
开发者ID:iionly,项目名称:tidypics,代码行数:30,代码来源:tidypics.php

示例12: widget_manager_init

/**
 * Function that runs on system init. Used to perform initialization of the widget manager features.
 *
 * @return void
 */
function widget_manager_init()
{
    // check valid WidgetManagerWidget class
    if (get_subtype_class("object", "widget") == "ElggWidget") {
        update_subtype("object", "widget", "WidgetManagerWidget");
    }
    // loads the widgets
    widget_manager_widgets_init();
    elgg_register_plugin_hook_handler("widget_settings", "all", "widget_manager_all_widget_settings_hook_handler");
    $group_enable = elgg_get_plugin_setting("group_enable", "widget_manager");
    if (elgg_is_active_plugin("groups") && in_array($group_enable, array("yes", "forced"))) {
        // cleanup widgets in group context
        elgg_extend_view("page/layouts/widgets/add_panel", "widget_manager/group_tool_widgets", 400);
        if ($group_enable == "yes") {
            // add the widget manager tool option
            $group_option_enabled = false;
            if (elgg_get_plugin_setting("group_option_default_enabled", "widget_manager") == "yes") {
                $group_option_enabled = true;
            }
            if (elgg_get_plugin_setting("group_option_admin_only", "widget_manager") != "yes") {
                // add the tool option for group admins
                add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled);
            } elseif (elgg_is_admin_logged_in()) {
                add_group_tool_option('widget_manager', elgg_echo('widget_manager:groups:enable_widget_manager'), $group_option_enabled);
            } elseif ($group_option_enabled) {
                // register event to make sure newly created groups have the group option enabled
                elgg_register_event_handler("create", "group", "widget_manager_create_group_event_handler");
            }
        }
        // register event to make sure all groups have the group option enabled if forces
        // and configure tool enabled widgets
        elgg_register_event_handler("update", "group", "widget_manager_update_group_event_handler");
        // make default widget management available
        elgg_register_plugin_hook_handler('get_list', 'default_widgets', 'widget_manager_group_widgets_default_list');
    }
    // extend CSS
    elgg_extend_view("css/elgg", "css/widget_manager/site");
    elgg_extend_view("css/elgg", "css/widget_manager/global");
    elgg_extend_view("css/admin", "css/widget_manager/admin");
    elgg_extend_view("css/admin", "css/widget_manager/global");
    elgg_extend_view("js/elgg", "js/widget_manager/site");
    elgg_extend_view("js/admin", "js/widget_manager/admin");
    elgg_register_plugin_hook_handler("format", "friendly:time", "widget_manager_friendly_time_hook");
    // register a widget title url handler
    // core widgets
    elgg_register_plugin_hook_handler("entity:url", "object", "widget_manager_widgets_url");
    // widget manager widgets
    elgg_register_plugin_hook_handler("entity:url", "object", "widget_manager_widgets_url_hook_handler");
    // cacheable widget handlers
    elgg_register_plugin_hook_handler("cacheable_handlers", "widget_manager", "widget_manager_cacheable_handlers_hook_handler");
    // index page
    elgg_register_plugin_hook_handler("route", "all", "widget_manager_route_index_handler");
    // add extra widget pages
    $extra_contexts = elgg_get_plugin_setting("extra_contexts", "widget_manager");
    if ($extra_contexts) {
        $contexts = string_to_tag_array($extra_contexts);
        if ($contexts) {
            foreach ($contexts as $context) {
                elgg_register_page_handler($context, "widget_manager_extra_contexts_page_handler");
            }
        }
    }
    elgg_register_plugin_hook_handler("action", "plugins/settings/save", "widget_manager_plugins_settings_save_hook_handler");
    elgg_register_plugin_hook_handler("action", "widgets/add", "widget_manager_widgets_action_hook_handler");
    elgg_register_plugin_hook_handler("action", "widgets/move", "widget_manager_widgets_action_hook_handler");
    elgg_register_plugin_hook_handler("permissions_check", "object", "widget_manager_permissions_check_object_hook_handler");
    elgg_register_event_handler("create", "object", "widget_manager_create_object_handler");
    // multi dashboard support
    add_subtype("object", MultiDashboard::SUBTYPE, "MultiDashboard");
    if (elgg_is_logged_in() && widget_manager_multi_dashboard_enabled()) {
        elgg_register_page_handler("multi_dashboard", "widget_manager_multi_dashboard_page_handler");
        elgg_register_plugin_hook_handler('register', 'menu:extras', 'widget_manager_register_extras_menu');
        // add js initialisation view
        elgg_extend_view("page/elements/sidebar", "widget_manager/multi_dashboard/sidebar", 400);
        elgg_register_plugin_hook_handler("route", "dashboard", "widget_manager_dashboard_route_handler");
        elgg_register_plugin_hook_handler("action", "widgets/add", "widget_manager_widgets_add_action_handler");
        elgg_register_action("multi_dashboard/edit", dirname(__FILE__) . "/actions/multi_dashboard/edit.php");
        elgg_register_action("multi_dashboard/delete", dirname(__FILE__) . "/actions/multi_dashboard/delete.php");
        elgg_register_action("multi_dashboard/drop", dirname(__FILE__) . "/actions/multi_dashboard/drop.php");
        elgg_register_action("multi_dashboard/reorder", dirname(__FILE__) . "/actions/multi_dashboard/reorder.php");
    }
    elgg_register_ajax_view("widget_manager/widgets/settings");
    elgg_register_ajax_view("widgets/user_search/content");
    // register actions
    elgg_register_action("widget_manager/manage", dirname(__FILE__) . "/actions/manage.php", "admin");
    elgg_register_action("widget_manager/widgets/toggle_fix", dirname(__FILE__) . "/actions/widgets/toggle_fix.php", "admin");
    elgg_register_action("widget_manager/force_tool_widgets", dirname(__FILE__) . "/actions/force_tool_widgets.php", "admin");
    elgg_register_action("widget_manager/widgets/toggle_collapse", dirname(__FILE__) . "/actions/widgets/toggle_collapse.php");
}
开发者ID:n8b,项目名称:VMN,代码行数:94,代码来源:start.php

示例13: crud_register_subtype

/**
 * Register a crud subtype class into elgg engine
 */
function crud_register_subtype($name, $class_name = NULL)
{
    if (empty($class_name)) {
        $class_name = "CrudObject";
    }
    if (get_subtype_id('object', $name)) {
        if (get_subtype_class('object', $name) != $class_name) {
            update_subtype('object', $name, $class_name);
        }
    } else {
        add_subtype('object', $name, $class_name);
    }
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:16,代码来源:start.php

示例14: user_support_init

/**
 * Gets called during system init
 *
 * @return void
 */
function user_support_init()
{
    // extend css
    elgg_extend_view("css/elgg", "css/user_support/site");
    elgg_extend_view("css/admin", "css/user_support/admin");
    elgg_extend_view("js/elgg", "js/user_support/site");
    elgg_extend_view("page/elements/footer", "user_support/button");
    elgg_extend_view("forms/comment/save", "user_support/support_ticket/comment");
    // register page handler for nice URL's
    elgg_register_page_handler("user_support", "user_support_page_handler");
    // register subtype handlers
    add_subtype("object", UserSupportFAQ::SUBTYPE, "UserSupportFAQ");
    add_subtype("object", UserSupportHelp::SUBTYPE, "UserSupportHelp");
    add_subtype("object", UserSupportTicket::SUBTYPE, "UserSupportTicket");
    // register subtypes for search
    elgg_register_entity_type("object", UserSupportFAQ::SUBTYPE);
    elgg_register_entity_type("object", UserSupportHelp::SUBTYPE);
    // register notifications
    elgg_register_notification_event("object", "comment");
    elgg_register_plugin_hook_handler("get", "subscriptions", "user_support_get_subscriptions_support_ticket_comment_hook");
    elgg_register_plugin_hook_handler("prepare", "notification:create:object:comment", "user_support_prepare_support_ticket_comment_message_hook");
    elgg_register_notification_event("object", UserSupportTicket::SUBTYPE);
    elgg_register_plugin_hook_handler("get", "subscriptions", "user_support_get_subscriptions_support_ticket_hook");
    elgg_register_plugin_hook_handler("prepare", "notification:create:object:" . UserSupportTicket::SUBTYPE, "user_support_prepare_support_ticket_message_hook");
    // update class for FAQ, since user_support v1.0
    if (!get_subtype_class("object", UserSupportFAQ::SUBTYPE)) {
        run_function_once("user_support_faq_class_update");
    }
    // add a group tool option for FAQ
    add_group_tool_option("faq", elgg_echo("user_support:group:tool_option"), false);
    elgg_extend_view("groups/tool_latest", "user_support/faq/group_module");
    // register widgets
    elgg_register_widget_type("faq", elgg_echo("user_support:widgets:faq:title"), elgg_echo("user_support:widgets:faq:description"), array("groups"));
    elgg_register_widget_type("support_ticket", elgg_echo("user_support:widgets:support_ticket:title"), elgg_echo("user_support:widgets:support_ticket:description"), array("dashboard"), true);
    if (user_support_staff_gatekeeper(false)) {
        elgg_register_widget_type("support_staff", elgg_echo("user_support:widgets:support_staff:title"), elgg_echo("user_support:widgets:support_staff:description"), array("dashboard", "admin"));
    }
    // register events
    elgg_register_event_handler("create", "object", "user_support_create_comment_event");
    // plugin hooks
    elgg_register_plugin_hook_handler("register", "menu:entity", "user_support_entity_menu_hook", 550);
    elgg_register_plugin_hook_handler("register", "menu:owner_block", "user_support_owner_block_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:title", "user_support_title_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:site", "user_support_site_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:page", "user_support_page_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:footer", "user_support_footer_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:user_hover", "user_support_user_hover_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:user_support", "user_support_user_support_menu_hook");
    elgg_register_plugin_hook_handler("register", "menu:annotation", "user_support_annotation_menu_hook");
    elgg_register_plugin_hook_handler("widget_url", "widget_manager", "user_support_widget_url_hook");
    elgg_register_plugin_hook_handler("permissions_check", "object", "user_support_permissions_check_hook");
    // register actions
    elgg_register_action("user_support/help/edit", dirname(__FILE__) . "/actions/help/edit.php", "admin");
    elgg_register_action("user_support/help/delete", dirname(__FILE__) . "/actions/help/delete.php", "admin");
    elgg_register_action("user_support/support_ticket/edit", dirname(__FILE__) . "/actions/ticket/edit.php");
    elgg_register_action("user_support/support_ticket/delete", dirname(__FILE__) . "/actions/ticket/delete.php");
    elgg_register_action("user_support/support_ticket/close", dirname(__FILE__) . "/actions/ticket/close.php");
    elgg_register_action("user_support/support_ticket/reopen", dirname(__FILE__) . "/actions/ticket/reopen.php");
    elgg_register_action("user_support/faq/edit", dirname(__FILE__) . "/actions/faq/edit.php");
    elgg_register_action("user_support/faq/delete", dirname(__FILE__) . "/actions/faq/delete.php");
    elgg_register_action("user_support/support_staff", dirname(__FILE__) . "/actions/support_staff.php", "admin");
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:67,代码来源:start.php

示例15: saveUploadedFiles

 /**
  * Save uploaded files
  *
  * @param string $input_name Form input name
  * @param array  $attributes File attributes
  * @return ElggFile[]
  */
 protected function saveUploadedFiles($input_name, array $attributes = [])
 {
     $files = [];
     $uploaded_files = $this->getUploadedFiles($input_name);
     $subtype = elgg_extract('subtype', $attributes, 'file', false);
     unset($attributes['subtype']);
     $class = get_subtype_class('object', $subtype);
     if (!$class || !class_exists($class) || !is_subclass_of($class, ElggFile::class)) {
         $class = ElggFile::class;
     }
     foreach ($uploaded_files as $upload) {
         if (!$upload->isValid()) {
             $error = new \stdClass();
             $error->error = elgg_get_friendly_upload_error($upload->getError());
             $files[] = $error;
             continue;
         }
         $file = new $class();
         $file->subtype = $subtype;
         foreach ($attributes as $key => $value) {
             $file->{$key} = $value;
         }
         $old_filestorename = '';
         if ($file->exists()) {
             $old_filestorename = $file->getFilenameOnFilestore();
         }
         $originalfilename = $upload->getClientOriginalName();
         $file->originalfilename = $originalfilename;
         if (empty($file->title)) {
             $file->title = htmlspecialchars($file->originalfilename, ENT_QUOTES, 'UTF-8');
         }
         $file->upload_time = time();
         $prefix = $file->filestore_prefix ?: 'file';
         $prefix = trim($prefix, '/');
         $filename = elgg_strtolower("{$prefix}/{$file->upload_time}{$file->originalfilename}");
         $file->setFilename($filename);
         $file->filestore_prefix = $prefix;
         $hook_params = ['file' => $file, 'upload' => $upload];
         $uploaded = _elgg_services()->hooks->trigger('upload', 'file', $hook_params);
         if ($uploaded !== true && $uploaded !== false) {
             $filestorename = $file->getFilenameOnFilestore();
             try {
                 $uploaded = $upload->move(pathinfo($filestorename, PATHINFO_DIRNAME), pathinfo($filestorename, PATHINFO_BASENAME));
             } catch (FileException $ex) {
                 elgg_log($ex->getMessage(), 'ERROR');
                 $uploaded = false;
             }
         }
         if (!$uploaded) {
             $error = new \stdClass();
             $error->error = elgg_echo('dropzone:file_not_entity');
             $files[] = $error;
             continue;
         }
         if ($old_filestorename && $old_filestorename != $file->getFilenameOnFilestore()) {
             // remove old file
             unlink($old_filestorename);
         }
         $mime_type = $file->detectMimeType(null, $upload->getClientMimeType());
         $file->setMimeType($mime_type);
         $file->simpletype = elgg_get_file_simple_type($mime_type);
         _elgg_services()->events->triggerAfter('upload', 'file', $file);
         if (!$file->save() || !$file->exists()) {
             $file->delete();
             $error = new \stdClass();
             $error->error = elgg_echo('dropzone:file_not_entity');
             $files[] = $error;
             continue;
         }
         if ($file->saveIconFromElggFile($file)) {
             $file->thumbnail = $file->getIcon('small')->getFilename();
             $file->smallthumb = $file->getIcon('medium')->getFilename();
             $file->largethumb = $file->getIcon('large')->getFilename();
         }
         $success = new \stdClass();
         $success->file = $file;
         $files[] = $success;
     }
     return $files;
 }
开发者ID:hypejunction,项目名称:hypedropzone,代码行数:87,代码来源:DropzoneService.php


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