The Hubzilla
 All Classes Namespaces Files Functions Variables Pages
plugin.php File Reference

Some functions to handle addons and themes. More...

Functions

 unload_plugin ($plugin)
 Unloads an addon. More...
 
 uninstall_plugin ($plugin)
 Uninstalls an addon. More...
 
 install_plugin ($plugin)
 installs an addon. More...
 
 load_plugin ($plugin)
 loads an addon by it's name. More...
 
 plugin_is_installed ($name)
 Check if addon is installed. More...
 
 reload_plugins ()
 Reload all updated plugins. More...
 
 visible_plugin_list ()
 Get a list of non hidden addons. More...
 
 register_hook ($hook, $file, $function, $priority=0)
 registers a hook. More...
 
 unregister_hook ($hook, $file, $function)
 unregisters a hook. More...
 
 load_hooks ()
 
 insert_hook ($hook, $fn, $version=0, $priority=0)
 Inserts a hook into a page request. More...
 
 call_hooks ($name, &$data=null)
 Calls a hook. More...
 
 get_plugin_info ($plugin)
 Parse plugin comment in search of plugin infos. More...
 
 check_plugin_versions ($info)
 
 get_theme_info ($theme)
 Parse theme comment in search of theme infos. More...
 
 get_theme_screenshot ($theme)
 Returns the theme's screenshot. More...
 
 head_add_css ($src, $media= 'screen')
 add CSS to <head> More...
 
 head_remove_css ($src, $media= 'screen')
 
 head_get_css ()
 
 head_add_link ($arr)
 
 head_get_links ()
 
 format_css_if_exists ($source)
 
 script_path ()
 
 head_add_js ($src, $priority=0)
 
 head_remove_js ($src, $priority=0)
 
 head_get_js ()
 
 head_get_main_js ()
 
 format_js_if_exists ($source)
 
 theme_include ($file, $root= '')
 
 get_intltext_template ($s, $root= '')
 
 get_markup_template ($s, $root= '')
 
 folder_exists ($folder)
 

Detailed Description

Some functions to handle addons and themes.

Function Documentation

call_hooks (   $name,
$data = null 
)

Calls a hook.

Use this function when you want to be able to allow a hook to manipulate the provided data.

Parameters
string$nameof the hook to call
[in,out]string | array&$datato transmit to the callback handler

Referenced by Zotlabs\Web\Router\__construct(), anon_identity_init(), api_login(), api_perm_is_allowed(), atom_author(), atom_entry(), atom_render_author(), attach_store(), authenticate_success(), author_is_pmable(), bb_to_markdown(), bb_translate_video(), bbcode(), Zotlabs\Access\Permissions\BlockedAnonPerms(), App\build_pagehead(), can_comment_on_post(), change_channel(), channel_apps(), channel_remove(), check_account_email(), check_account_invite(), check_account_password(), check_channelallowed(), check_location_move(), check_siteallowed(), construct_page(), contact_block(), contact_remove(), contact_select(), conversation(), create_account(), create_identity(), crypto_methods(), delivery_report_is_storable(), discover_by_webbie(), Zotlabs\Web\Router\Dispatch(), downgrade_accounts(), drop_item(), event_store_event(), event_store_item(), Zotlabs\Web\Session\extend_cookie(), feature_enabled(), gender_selector(), gender_selector_min(), generate_map(), generate_named_map(), Zotlabs\Module\Linkinfo\get(), Zotlabs\Module\Like\get(), Zotlabs\Module\Subthread\get(), Zotlabs\Module\Display\get(), Zotlabs\Module\Siteinfo\get(), Zotlabs\Module\Network\get(), Zotlabs\Module\Settings\Featured\get(), Zotlabs\Module\Home\get(), Zotlabs\Module\Directory\get(), Zotlabs\Module\Channel\get(), Zotlabs\Module\Profile\get(), Zotlabs\Module\Connect\get(), Zotlabs\Module\Settings\Account\get(), Zotlabs\Module\Settings\Display\get(), Zotlabs\Module\Defperms\get(), Zotlabs\Module\Cover_photo\get(), Zotlabs\Module\Profile_photo\get(), Zotlabs\Module\Settings\Channel\get(), Zotlabs\Module\Connedit\get(), Zotlabs\Module\Photos\get(), Zotlabs\Module\Profiles\get(), get_all_api_perms(), get_all_perms(), get_atom_elements(), get_best_language(), Zotlabs\Lib\ThreadItem\get_comment_box(), get_default_export_sections(), get_features(), get_feed_for(), get_mood_verbs(), get_poke_verbs(), Zotlabs\Lib\ThreadItem\get_template_data(), Zotlabs\Lib\System\get_zot_revision(), group_select(), html2bb_video(), html2bbcode(), identity_basic_export(), Zotlabs\Module\Import\import_account(), import_author_unknown(), import_author_xchan(), import_directory_profile(), import_xchan(), Zotlabs\Module\Well_known\init(), Zotlabs\Module\Hostxrd\init(), Zotlabs\Module\Notify\init(), Zotlabs\Module\Api\init(), Zotlabs\Module\Magic\init(), Zotlabs\Module\Xrd\init(), Zotlabs\Module\Wfinger\init(), Zotlabs\Module\Home\init(), Zotlabs\Module\Photo\init(), Zotlabs\Module\Mood\init(), Zotlabs\Module\Ping\init(), item_store(), item_store_update(), legal_webbie(), legal_webbie_text(), list_smilies(), load_pdl(), Zotlabs\Lib\Permcat\load_permcats(), local_dir_update(), logger(), login(), mail_store(), marital_selector(), marital_selector_min(), markdown_to_bb(), Zotlabs\Lib\Chatroom\message(), nav(), network_to_name(), new_contact(), Zotlabs\Web\Session\new_cookie(), obj_verbs(), oembed_action(), oembed_fetch_url(), other_encapsulate(), other_unencapsulate(), owt_init(), pdl_selector(), perm_is_allowed(), Zotlabs\Access\Permissions\Perms(), photo_upload(), Zotlabs\Module\Settings\Account\post(), Zotlabs\Module\Settings\Featured\post(), Zotlabs\Module\Settings\Channel\post(), Zotlabs\Module\Settings\Display\post(), Zotlabs\Module\Rmagic\post(), Zotlabs\Module\Item\post(), Zotlabs\Module\Chatsvc\post(), Zotlabs\Module\Connedit\post(), Zotlabs\Module\Profiles\post(), post_activity_item(), prepare_body(), proc_run(), process_channel_sync_delivery(), process_delivery(), profile_sidebar(), queue_deliver(), replace_macros(), Zotlabs\Access\PermissionRoles\role_perms(), Zotlabs\Daemon\Cron_daily\run(), Zotlabs\Daemon\Cron_weekly\run(), Zotlabs\Daemon\Cronhooks\run(), Zotlabs\Web\WebServer\run(), Zotlabs\Daemon\Thumbnail\run(), Zotlabs\Daemon\Addon\run(), Zotlabs\Daemon\Deliver_hooks\run(), Zotlabs\Daemon\Externals\run(), Zotlabs\Daemon\Notifier\run(), Zotlabs\Lib\Enotify\send(), service_plink(), sexpref_selector(), sexpref_selector_min(), signing_methods(), Zotlabs\Lib\Enotify\submit(), sys_boot(), tag_deliver(), text_highlight(), thread_action_menu(), thread_author_menu(), validate_channelname(), Zotlabs\Zot\Auth\Verify(), Zotlabs\Widget\Admin\widget(), Zotlabs\Widget\Affinity\widget(), Zotlabs\Widget\Activity\widget(), z_mail(), zid(), zid_init(), zot_best_algorithm(), and zotinfo().

folder_exists (   $folder)
Parameters
string$folder
Returns
boolean|string
format_css_if_exists (   $source)

Referenced by head_get_css().

format_js_if_exists (   $source)

Referenced by head_get_js(), and head_get_main_js().

get_markup_template (   $s,
  $root = '' 
)

Referenced by Zotlabs\Web\Router\__construct(), Zotlabs\Module\Admin\admin_page_summary(), advanced_profile(), alt_pager(), Zotlabs\Lib\Apps\app_render(), articlecategories_widget(), App\build_pagehead(), cardcategories_widget(), categories_widget(), channel_apps(), Zotlabs\Module\Setup\check_php(), common_friends_visitor_widget(), construct_page(), contact_block(), conversation(), Zotlabs\Module\Cover_photo\cover_photo_crop_ui_head(), Zotlabs\Widget\Wiki_pages\create_missing_page(), datetimesel(), design_tools(), dir_sort_links(), dob(), Zotlabs\Module\Embedphotos\embedphotos_widget_album(), fileas_widget(), findpeople_widget(), Zotlabs\Theme\RedbasicConfig\form(), format_categories(), format_event_obj(), format_filer(), Zotlabs\Module\Dreport\get(), Zotlabs\Module\Achievements\get(), Zotlabs\Module\Manage\get(), Zotlabs\Module\Chanview\get(), Zotlabs\Module\Notifications\get(), Zotlabs\Module\Apps\get(), Zotlabs\Module\Pubstream\get(), Zotlabs\Module\Article_edit\get(), Zotlabs\Module\Card_edit\get(), Zotlabs\Module\Admin\Queue\get(), Zotlabs\Module\Editpost\get(), Zotlabs\Module\Filer\get(), Zotlabs\Module\Admin\Dbsync\get(), Zotlabs\Module\Apporder\get(), Zotlabs\Module\Search\get(), Zotlabs\Module\Display\get(), Zotlabs\Module\Sharedwithme\get(), Zotlabs\Module\Siteinfo\get(), Zotlabs\Module\Fbrowser\get(), Zotlabs\Module\Help\get(), Zotlabs\Module\Viewconnections\get(), Zotlabs\Module\Articles\get(), Zotlabs\Module\Cards\get(), Zotlabs\Module\Connections\get(), Zotlabs\Module\Suggest\get(), Zotlabs\Module\Pdledit\get(), Zotlabs\Module\Common\get(), Zotlabs\Module\Editblock\get(), Zotlabs\Module\Editlayout\get(), Zotlabs\Module\Layouts\get(), Zotlabs\Module\Editwebpage\get(), Zotlabs\Module\Settings\Features\get(), Zotlabs\Module\Api\get(), Zotlabs\Module\Blocks\get(), Zotlabs\Module\Webpages\get(), Zotlabs\Module\Network\get(), Zotlabs\Module\Rpost\get(), Zotlabs\Module\Hq\get(), Zotlabs\Module\Settings\Featured\get(), Zotlabs\Module\Notify\get(), Zotlabs\Module\Wiki\get(), Zotlabs\Module\Admin\Logs\get(), Zotlabs\Module\Admin\Themes\get(), Zotlabs\Module\Admin\Features\get(), Zotlabs\Module\Settings\Permcats\get(), Zotlabs\Module\Removeaccount\get(), Zotlabs\Module\Filestorage\get(), Zotlabs\Module\Removeme\get(), Zotlabs\Module\Cal\get(), Zotlabs\Module\Uexport\get(), Zotlabs\Module\Rbmark\get(), Zotlabs\Module\Admin\Security\get(), Zotlabs\Module\Admin\Account_edit\get(), Zotlabs\Module\Admin\Profs\get(), Zotlabs\Module\Admin\Channels\get(), Zotlabs\Module\Lostpass\get(), Zotlabs\Module\Directory\get(), Zotlabs\Module\Changeaddr\get(), Zotlabs\Module\Channel\get(), Zotlabs\Module\Group\get(), Zotlabs\Module\Menu\get(), Zotlabs\Module\Admin\Accounts\get(), Zotlabs\Module\Sources\get(), Zotlabs\Module\Rmagic\get(), Zotlabs\Module\Ratings\get(), Zotlabs\Module\Settings\Oauth\get(), Zotlabs\Module\Connect\get(), Zotlabs\Module\Settings\Tokens\get(), Zotlabs\Module\Appman\get(), Zotlabs\Module\Locs\get(), Zotlabs\Module\Chat\get(), Zotlabs\Module\Invite\get(), Zotlabs\Module\Settings\Account\get(), Zotlabs\Module\Mitem\get(), Zotlabs\Module\New_channel\get(), Zotlabs\Module\Settings\Display\get(), Zotlabs\Module\Rate\get(), Zotlabs\Module\Mood\get(), Zotlabs\Module\Import_items\get(), Zotlabs\Module\Mail\get(), Zotlabs\Module\Poke\get(), Zotlabs\Module\Admin\Site\get(), Zotlabs\Module\Setup\get(), Zotlabs\Module\Defperms\get(), Zotlabs\Module\Register\get(), Zotlabs\Module\Thing\get(), Zotlabs\Module\Events\get(), Zotlabs\Module\Admin\Plugins\get(), Zotlabs\Module\Cover_photo\get(), Zotlabs\Module\Profile_photo\get(), Zotlabs\Module\Settings\Channel\get(), Zotlabs\Module\Connedit\get(), Zotlabs\Module\Import\get(), Zotlabs\Module\Photos\get(), Zotlabs\Module\Profiles\get(), Zotlabs\Lib\ThreadItem\get_comment_box(), get_feed_for(), get_help_content(), get_zcard(), get_zcard_embed(), group_side(), identity_selector(), Zotlabs\Module\Hostxrd\init(), Zotlabs\Module\Oexchange\init(), Zotlabs\Module\Xrd\init(), lang_selector(), layout_select(), login(), mail_prepare_binary(), menu_render(), micropro(), mimetype_select(), mini_group_select(), nav(), oembed_format_object(), photos_album_widget(), poco(), populate_acl(), prepare_binary(), Zotlabs\Module\Profile_photo\profile_photo_crop_ui_head(), profile_sidebar(), remote_login(), Zotlabs\Lib\NativeWikiPage\render_page_history(), search(), searchbox(), Zotlabs\Lib\Enotify\submit(), theme_attachments(), vcard_from_xchan(), website_portation_tools(), Zotlabs\Widget\Wiki_page_history\widget(), Zotlabs\Widget\Wiki_list\widget(), Zotlabs\Widget\Mailmenu\widget(), Zotlabs\Widget\Notifications\widget(), Zotlabs\Widget\Hq_controls\widget(), Zotlabs\Widget\Savedsearch\widget(), Zotlabs\Widget\Settings_menu\widget(), Zotlabs\Widget\Cover_photo\widget(), Zotlabs\Widget\Suggestedchats\widget(), Zotlabs\Widget\Notes\widget(), Zotlabs\Widget\Conversations\widget(), Zotlabs\Widget\Bookmarkedchats\widget(), Zotlabs\Widget\Chatroom_list\widget(), Zotlabs\Widget\Eventstools\widget(), Zotlabs\Widget\Appcategories\widget(), Zotlabs\Widget\Affinity\widget(), Zotlabs\Widget\Admin\widget(), Zotlabs\Widget\Archive\widget(), Zotlabs\Widget\Sitesearch\widget(), Zotlabs\Widget\Follow\widget(), Zotlabs\Widget\Cdav\widget(), Zotlabs\Widget\Filer\widget(), Zotlabs\Widget\Album\widget(), Zotlabs\Widget\Portfolio\widget(), Zotlabs\Widget\Chatroom_members\widget(), Zotlabs\Widget\Suggestions\widget(), and Zotlabs\Widget\Wiki_pages\widget().

get_plugin_info (   $plugin)

Parse plugin comment in search of plugin infos.

like

* Name: Plugin
* Description: A plugin which plugs in
* Version: 1.2.3
* Author: John <profile url>
* Author: Jane <email>
*
Parameters
string$pluginthe name of the plugin
Returns
array with the plugin information

Referenced by Zotlabs\Module\Admin\Plugins\get().

get_theme_info (   $theme)

Parse theme comment in search of theme infos.

like

* Name: My Theme
* Description: My Cool Theme
* Version: 1.2.3
* Author: John <profile url>
* Maintainer: Jane <profile url>
* Compat: Friendica [(version)], Red [(version)]
*
Parameters
string$themethe name of the theme
Returns
array

Referenced by Zotlabs\Render\Theme\current(), Zotlabs\Module\Theme_info\get(), Zotlabs\Module\Admin\Themes\get(), Zotlabs\Module\Settings\Display\get(), Zotlabs\Module\Admin\Site\get(), and Zotlabs\Module\Pretheme\init().

get_theme_screenshot (   $theme)

Returns the theme's screenshot.

The screenshot is expected as view/theme/$theme/img/screenshot.[png|jpg].

Parameters
string$themeThe name of the theme
Returns
string

Referenced by Zotlabs\Module\Theme_info\get(), Zotlabs\Module\Admin\Themes\get(), and Zotlabs\Module\Pretheme\init().

head_add_css (   $src,
  $media = 'screen' 
)

add CSS to <head>

Parameters
string$src
string$mediachange media attribute (default to 'screen')

Referenced by construct_page(), Zotlabs\Module\Cdav\get(), and nav().

head_add_js (   $src,
  $priority = 0 
)
head_get_css ( )

Referenced by App\build_pagehead().

head_get_js ( )

We should probably try to register main.js with a high priority, but currently we handle it separately and put it at the end of the html head block in case any other javascript is added outside the head_add_js construct.

Returns
string

Referenced by App\build_pagehead().

head_get_links ( )

Referenced by App\build_pagehead().

head_get_main_js ( )

Referenced by App\build_pagehead().

head_remove_css (   $src,
  $media = 'screen' 
)
head_remove_js (   $src,
  $priority = 0 
)
insert_hook (   $hook,
  $fn,
  $version = 0,
  $priority = 0 
)

Inserts a hook into a page request.

Insert a short-lived hook into the running page request. Hooks are normally persistent so that they can be called across asynchronous processes such as delivery and poll processes.

insert_hook lets you attach a hook callback immediately which will not persist beyond the life of this page request or the current process.

Parameters
string$hookname of hook to attach callback
string$fnfunction name of callback handler
int$version(optional) default 0
int$priority(optional) default 0
install_plugin (   $plugin)

installs an addon.

Parameters
string$pluginname of the addon
Returns
bool

Referenced by Zotlabs\Module\Admin\Plugins\get().

load_hooks ( )

Referenced by check_config(), and sys_boot().

load_plugin (   $plugin)

loads an addon by it's name.

Parameters
string$pluginname of the addon
Returns
bool

Referenced by check_config(), and install_plugin().

plugin_is_installed (   $name)

Check if addon is installed.

Parameters
string$name
Returns
boolean

Referenced by Zotlabs\Lib\Apps\app_render(), and Zotlabs\Lib\Apps\get_system_apps().

register_hook (   $hook,
  $file,
  $function,
  $priority = 0 
)

registers a hook.

Parameters
string$hookthe name of the hook
string$filethe name of the file that hooks into
string$functionthe name of the function that the hook will call
int$priorityA priority (defaults to 0)
Returns
mixed|bool
reload_plugins ( )

Reload all updated plugins.

Referenced by Zotlabs\Daemon\Cron\run(), and Zotlabs\Daemon\Poller\run().

script_path ( )

This basically calculates the baseurl. We have other functions to do that, but there was an issue with script paths and mixed-content whose details are arcane and perhaps lost in the message archives. The short answer is that we're ignoring the URL which we are "supposed" to use, and generating script paths relative to the URL which we are currently using; in order to ensure they are found and aren't blocked due to mixed content issues.

Returns
string

Referenced by format_css_if_exists(), and format_js_if_exists().

uninstall_plugin (   $plugin)

Uninstalls an addon.

Parameters
string$pluginname of the addon
Returns
boolean

Referenced by Zotlabs\Module\Admin\Plugins\get().

unload_plugin (   $plugin)

Unloads an addon.

Parameters
string$pluginname of the addon

Referenced by check_config(), and uninstall_plugin().

unregister_hook (   $hook,
  $file,
  $function 
)

unregisters a hook.

Parameters
string$hookthe name of the hook
string$filethe name of the file that hooks into
string$functionthe name of the function that the hook called
Returns
array
visible_plugin_list ( )

Get a list of non hidden addons.

Returns
array

Referenced by get_site_info().