本文整理汇总了PHP中add_subtype函数的典型用法代码示例。如果您正苦于以下问题:PHP add_subtype函数的具体用法?PHP add_subtype怎么用?PHP add_subtype使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_subtype函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: questions_init
function questions_init()
{
elgg_register_library("elgg:questions", dirname(__FILE__) . "/lib/questions.php");
add_subtype("object", 'question', 'ElggQuestion');
update_subtype("object", 'question', 'ElggQuestion');
add_subtype("object", 'answer', 'ElggAnswer');
update_subtype("object", 'answer', 'ElggAnswer');
elgg_extend_view("css/elgg", "questions/css");
elgg_extend_view("js/elgg", "questions/js");
elgg_register_menu_item("site", array("name" => 'questions', "text" => elgg_echo('questions'), "href" => "/questions/all"));
elgg_register_entity_type("object", 'questions');
elgg_register_widget_type('questions', elgg_echo("widget:questions:title"), elgg_echo("widget:questions:description"));
$actions_base = dirname(__FILE__) . '/actions/object/question';
elgg_register_action("object/question/save", "{$actions_base}/save.php");
elgg_register_action("questions/delete", "{$actions_base}/delete.php");
$actions_base = dirname(__FILE__) . '/actions/object/answer';
elgg_register_action("object/answer/save", "{$actions_base}/save.php");
elgg_register_entity_url_handler('object', 'question', 'questions_url_handler');
$plugin_dir = dirname(__FILE__);
elgg_register_entity_url_handler('object', 'answer', 'answers_url');
elgg_register_page_handler('questions', 'questions_page_handler');
elgg_register_page_handler('answers', 'answers_page_handler');
$actions_base = "{$plugin_dir}/actions/object/answer";
elgg_register_action('object/answer/add', "{$actions_base}/save.php");
elgg_register_action('object/answer/edit', "{$actions_base}/save.php");
elgg_register_action('answers/delete', "{$actions_base}/delete.php");
elgg_register_plugin_hook_handler("register", "menu:owner_block", 'questions_owner_block_menu_handler');
elgg_register_plugin_hook_handler("register", "menu:user_hover", 'questions_user_hover_menu_handler');
elgg_register_plugin_hook_handler("register", 'menu:entity', 'questions_entity_menu_handler');
elgg_register_plugin_hook_handler("notify:entity:message", "object", 'questions_notify_message_handler');
add_group_tool_option('questions', elgg_echo("questions:enable"), true);
elgg_extend_view("groups/tool_latest", "questions/group_module");
elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'questions_container_permissions_check');
}
示例2: subsite_manager_runonce
function subsite_manager_runonce()
{
// register a new substype in the database and link it to the right classname
add_subtype("site", Subsite::SUBTYPE, "Subsite");
// Update the database with extra columns for multisite
run_sql_script(dirname(dirname(__FILE__)) . "/scripts/add_columns.sql");
}
示例3: upgrade_change_subtype
function upgrade_change_subtype($entity, $subtype)
{
$dbprefix = elgg_get_config('dbprefix');
$subtype_id = add_subtype('object', $subtype);
update_data("UPDATE {$dbprefix}entities set subtype={$subtype_id} WHERE guid={$entity->guid}");
return true;
}
示例4: testCanSaveNewObject
/**
* @group current
*/
public function testCanSaveNewObject()
{
$subtype = 'test_subtype';
$subtype_id = add_subtype('object', $subtype);
$user = $this->mocks()->getUser();
_elgg_services()->session->setLoggedInUser($user);
$object = new \ElggObject();
$object->subtype = $subtype;
$object->title = 'Foo';
$object->description = 'Bar';
$object->owner_guid = $user->guid;
$object->container_guid = $user->guid;
$object->access_id = ACCESS_LOGGED_IN;
$object->time_created = time();
$object->setCurrentTime();
// We should be able to match timestamps
$now = $object->getCurrentTime()->getTimestamp();
$guid = $object->save();
$this->assertNotFalse($guid);
$object = get_entity($guid);
$this->assertEquals('object', $object->type);
$this->assertEquals($subtype_id, $object->subtype);
$this->assertEquals('Foo', $object->title);
$this->assertEquals('Foo', $object->getDisplayName());
$this->assertEquals('Bar', $object->description);
$this->assertEquals($user->guid, $object->getOwnerGUID());
$this->assertEquals($user, $object->getOwnerEntity());
$this->assertEquals($user->guid, $object->getContainerGUID());
$this->assertEquals($user, $object->getContainerEntity());
$this->assertEquals(ACCESS_LOGGED_IN, $object->access_id);
_elgg_services()->session->removeLoggedInUser();
}
示例5: profile_manager_run_once
function profile_manager_run_once()
{
global $CONFIG;
// upgrade
$profile_field_class_name = "ProfileManagerCustomProfileField";
$group_field_class_name = "ProfileManagerCustomGroupField";
$field_type_class_name = "ProfileManagerCustomProfileType";
$field_category_class_name = "ProfileManagerCustomFieldCategory";
if ($id = get_subtype_id('object', ProfileManagerCustomProfileField::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$profile_field_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomProfileField::SUBTYPE, $profile_field_class_name);
}
if ($id = get_subtype_id('object', ProfileManagerCustomGroupField::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$group_field_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomGroupField::SUBTYPE, $group_field_class_name);
}
if ($id = get_subtype_id('object', ProfileManagerCustomProfileType::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_type_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomProfileType::SUBTYPE, $field_type_class_name);
}
if ($id = get_subtype_id('object', ProfileManagerCustomFieldCategory::SUBTYPE)) {
update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_category_class_name}' WHERE id={$id}");
} else {
add_subtype('object', ProfileManagerCustomFieldCategory::SUBTYPE, $field_category_class_name);
}
}
示例6: setGroupMailClassHandler
/**
* Set the correct class for the GroupMail subtype
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied object
*
* @return void
*/
public static function setGroupMailClassHandler($event, $type, $object)
{
if (get_subtype_id('object', \GroupMail::SUBTYPE)) {
update_subtype('object', \GroupMail::SUBTYPE, 'GroupMail');
} else {
add_subtype('object', \GroupMail::SUBTYPE, 'GroupMail');
}
}
示例7: setClassHandler
/**
* Listen to the upgrade event to set the correct class handler
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param null $object supplied param
*
* @return void
*/
public static function setClassHandler($event, $type, $object)
{
if (get_subtype_id('object', \CSVExport::SUBTYPE)) {
update_subtype('object', \CSVExport::SUBTYPE, 'CSVExport');
} else {
add_subtype('object', \CSVExport::SUBTYPE, 'CSVExport');
}
}
示例8: setClassHandler
/**
* Make sure the class handler for QuickLink is correct
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object misc params
*
* @return void
*/
public static function setClassHandler($event, $type, $object)
{
// set correct class handler for QuickLink
if (get_subtype_id('object', \QuickLink::SUBTYPE)) {
update_subtype('object', \QuickLink::SUBTYPE, 'QuickLink');
} else {
add_subtype('object', \QuickLink::SUBTYPE, 'QuickLink');
}
}
示例9: setClassHandler
/**
* Update the class for publication subtype
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied params
*
* @return void
*/
public static function setClassHandler($event, $type, $object)
{
// set correct class handler for Publication
if (get_subtype_id('object', \Publication::SUBTYPE)) {
update_subtype('object', \Publication::SUBTYPE, 'Publication');
} else {
add_subtype('object', \Publication::SUBTYPE, 'Publication');
}
}
示例10: event_manager_run_once_subtypes
function event_manager_run_once_subtypes()
{
add_subtype('object', Event::SUBTYPE, "Event");
add_subtype('object', EventDay::SUBTYPE, "EventDay");
add_subtype('object', EventSlot::SUBTYPE, "EventSlot");
add_subtype('object', EventRegistrationForm::SUBTYPE, "EventRegistrationForm");
add_subtype('object', EventRegistrationQuestion::SUBTYPE, "EventRegistrationQuestion");
add_subtype('object', EventRegistration::SUBTYPE, "EventRegistration");
}
示例11: upgrade_1395096061
function upgrade_1395096061()
{
$subtypes = array(HYPEGAMEMECHANICS_BADGE_SUBTYPE, HYPEGAMEMECHANICS_BADGERULE_SUBTYPE, HYPEGAMEMECHANICS_SCORE_SUBTYPE);
foreach ($subtypes as $subtype) {
if (get_subtype_id('object', $subtype)) {
update_subtype('object', $subtype);
} else {
add_subtype('object', $subtype);
}
}
}
示例12: haarlem_tangram_upgrade
/**
* Listen to the upgrade event
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied params
*/
function haarlem_tangram_upgrade($event, $type, $object)
{
// register correct class for future use
if (get_subtype_id('object', TangramVacancy::SUBTYPE)) {
update_subtype('object', TangramVacancy::SUBTYPE, 'TangramVacancy');
} else {
add_subtype('object', TangramVacancy::SUBTYPE, 'TangramVacancy');
}
// reset xml cache
haarlem_tangram_clear_cached_xml();
}
示例13: wizard_upgrade_system_handler
/**
* Listen to upgrade event
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied params
*
* @return void
*/
function wizard_upgrade_system_handler($event, $type, $object)
{
$id = get_subtype_id('object', Wizard::SUBTYPE);
if (empty($id)) {
// add subtype registration
add_subtype('object', Wizard::SUBTYPE, 'Wizard');
} elseif (get_subtype_class_from_id($id) !== 'Wizard') {
// update subtype registration
update_subtype('object', Wizard::SUBTYPE, 'Wizard');
}
}
示例14: checkClasses
/**
* Check the class assosiation
*
* @param string $event the name of the event
* @param string $type the type of the event
* @param mixed $object supplied params
*
* @return void
*/
public static function checkClasses($event, $type, $object)
{
if (get_subtype_id('object', \APIApplication::SUBTYPE)) {
update_subtype('object', \APIApplication::SUBTYPE, 'APIApplication');
} else {
add_subtype('object', \APIApplication::SUBTYPE, 'APIApplication');
}
if (get_subtype_id('object', \APIApplicationUserSetting::SUBTYPE)) {
update_subtype('object', \APIApplicationUserSetting::SUBTYPE, 'APIApplicationUserSetting');
} else {
add_subtype('object', \APIApplicationUserSetting::SUBTYPE, 'APIApplicationUserSetting');
}
}
示例15: 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");
}
}