Dotclear 2.24
Loading...
Searching...
No Matches
dcFavorites Class Reference

Public Member Functions

 __construct ()
 
 setup ()
 
 getFavorite ($id)
 
 getFavorites (array $ids)
 
 getUserFavorites ()
 
 getFavoriteIDs (bool $global=false)
 
 setFavoriteIDs (array $ids, bool $global=false)
 
 getAvailableFavoritesIDs ()
 
 appendMenuTitle ($menu)
 
 appendMenu ($menu)
 
 appendDashboardIcons ($icons)
 
 register (string $favorite_id, array $favorite_data)
 
 registerMultiple (array $data)
 
 exists (string $id)
 

Protected Member Functions

 setUserPrefs ()
 
 migrateFavorites ()
 
 legacyFavorites ()
 

Protected Attributes

 $favorites
 
 $workspace
 
 $local_favorites_ids
 
 $global_favorites_ids
 
 $user_favorites
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Class constructor

References dcCore\app(), and migrateFavorites().

Member Function Documentation

◆ setup()

setup ( )

Sets up favorites, fetch user favorites (against his permissions) This method is to be called after loading plugins

References dcCore\app(), defaultFavorites\initDefaultFavorites(), legacyFavorites(), and setUserPrefs().

◆ getFavorite()

getFavorite (   $id)

Retrieves a favorite (complete description) from its id.

Parameters
string | array$idthe favorite id, or an array having 1 key 'name' set to id, their keys are merged to favorite.
Returns
array|bool array the favorite, false if not found (or not permitted)

References dcCore\app().

Referenced by getFavorites().

◆ getFavorites()

getFavorites ( array  $ids)

getFavorites - retrieves a list of favorites.

Parameters
array$idsan array of ids, as defined in getFavorite.
Returns
array array of favorites, can be empty if ids are not found (or not permitted)

References $favorites, and getFavorite().

Referenced by migrateFavorites(), and setUserPrefs().

◆ setUserPrefs()

setUserPrefs ( )
protected

Get user favorites from settings.

These are complete favorites, not ids only returned favorites are the first non-empty list from :

  • user-defined favorites
  • globally-defined favorites
  • a failback list "new post" (shall never be empty)

This method is called by setup()

References getFavorites().

Referenced by setup().

◆ migrateFavorites()

migrateFavorites ( )
protected

migrateFavorites - migrate dc < 2.6 favorites to new format

References dcCore\app(), and getFavorites().

Referenced by __construct().

◆ legacyFavorites()

legacyFavorites ( )
protected

legacyFavorites - handle legacy favorites using adminDashboardFavs behavior

References $favorites, and dcCore\app().

Referenced by setup().

◆ getUserFavorites()

getUserFavorites ( )

Returns favorites that correspond to current user (may be local, global, or failback favorites)

Returns
array array of favorites (enriched)

References $user_favorites.

◆ getFavoriteIDs()

getFavoriteIDs ( bool  $global = false)

Returns user-defined or global favorites ids list shall not be called outside preferences.php...

Parameters
boolean$globalif true, retrieve global favs, user favs otherwise
Returns
array array of favorites ids (only ids, not enriched)

References $local_favorites_ids.

◆ setFavoriteIDs()

setFavoriteIDs ( array  $ids,
bool  $global = false 
)

Stores user-defined or global favorites ids list shall not be called outside preferences.php...

Parameters
array$idslist of fav ids
boolean$globalif true, retrieve global favs, user favs otherwise

◆ getAvailableFavoritesIDs()

getAvailableFavoritesIDs ( )

Returns all available fav ids

Returns
array array of favorites ids (only ids, not enriched)

◆ appendMenuTitle()

appendMenuTitle (   $menu)

Adds favorites section title to sidebar menu shall not be called outside admin/prepend.php...

Parameters
array | ArrayObject$menuadmin menu

References dcAdmin\MENU_FAVORITES.

◆ appendMenu()

appendMenu (   $menu)

Adds favorites items title to sidebar menu shall not be called outside admin/prepend.php...

Parameters
array | ArrayObject$menuadmin menu

References dcAdmin\MENU_FAVORITES.

◆ appendDashboardIcons()

appendDashboardIcons (   $icons)

Adds favorites icons to index page shall not be called outside admin/index.php...

Parameters
array | arrayObject$iconsdashboard icon list to enrich

References dcCore\app().

◆ register()

register ( string  $favorite_id,
array  $favorite_data 
)

Registers a new favorite definition

Parameters
string$favorite_idfavorite id
array$favorite_datafavorite information. Array keys are : 'title' => favorite title (localized) 'url' => favorite URL, 'small-icon' => favorite small icon(s) (for menu) 'large-icon' => favorite large icon(s) (for dashboard) 'permissions' => (optional) comma-separated list of permissions for thie fav, if not set : no restriction 'dashboard_cb' => (optional) callback to modify title if dynamic, if not set : title is taken as is 'active_cb' => (optional) callback to tell whether current page matches favorite or not, for complex pages
Returns
dcFavorites instance

Referenced by dcMaintenanceAdmin\adminDashboardFavorites(), and tagsBehaviors\dashboardFavorites().

◆ registerMultiple()

registerMultiple ( array  $data)

Registers a list of favorites definition

Parameters
array$dataan array defining all favorites key is the id, value is the data. see register method for data format
Returns
dcFavorites instance

Referenced by defaultFavorites\initDefaultFavorites().

◆ exists()

exists ( string  $id)

exists - tells whether a fav definition exists or not

Parameters
string$id: the fav id to test
Returns
bool true if the fav definition exists, false otherwise

Field Documentation

◆ $favorites

$favorites
protected

Referenced by getFavorites(), and legacyFavorites().

◆ $workspace

$workspace
protected

◆ $local_favorites_ids

$local_favorites_ids
protected

Referenced by getFavoriteIDs().

◆ $global_favorites_ids

$global_favorites_ids
protected

◆ $user_favorites

$user_favorites
protected

Referenced by getUserFavorites().


The documentation for this class was generated from the following file: