Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

generate_dash_tile_toolbar()

Description

Generate HTML and JavaScript for the dashboard tile toolbar.

This function renders a toolbar for a dashboard tile, providing options to delete or edit the tile,
based on the user's permissions. The toolbar appears on hover and includes JavaScript functionality
to manage tile interactions, including preventing accidental clicks on the tile itself when using the toolbar.

- 'ref' (int): Tile reference ID.
- 'all_users' (int): Flag indicating if the tile is accessible by all users.
- 'no_edit' (bool): Flag indicating if the tile is non-editable.
- 'url' (string|null): Optional URL for the tile's link.

Parameters

ColumnTypeDefaultDescription
$tile array An associative array containing information about the dashboard tile, including:
$tile_id string The unique HTML ID of the tile used for identifying elements in the toolbar.

Return

void Outputs HTML and JavaScript directly to the page for the tile toolbar.

Location

include/dash_functions.php lines 1811 to 1910

Definition

 
function generate_dash_tile_toolbar(array $tile$tile_id)
    {
    global 
$baseurl_short$lang$managed_home_dash;
    
$editlink $baseurl_short "pages/dash_tile.php?edit=" $tile['ref'];
    if(!
$managed_home_dash && (checkPermission_dashadmin() || checkPermission_dashuser()))
        {
        
?>
        <div id="DashTileActions_ echo substr($tile_id18); ?>" class="DashTileActions"  style="display:none;">
        <div class="tool dash-delete_ echo substr($tile_id18); ?>">
            <a href="#">
                <span> echo LINK_CARET ?> echo escape($lang['action-delete']); ?></span>
            </a>
        </div>
        
        
if((checkPermission_dashadmin() || (isset($tile['all_users']) && $tile['all_users'] == 0)) && !(isset($tile['no_edit']) && $tile['no_edit']))
            {
            
?>
            <div class="tool edit">
                <a href=" echo $editlink ?>" onClick="return CentralSpaceLoad(this,true);">
                    <span> echo LINK_CARET ?> echo escape($lang['action-edit']); ?></span>
                </a>
            </div>
            
            
}
        
?>
        </div>
          
        
}
        
?>

    <script>
    jQuery(document).ready(function ()
        {
        if (pagename == "home")
        {
            var tileid = " echo $tile["ref"]; ?>"; //Needs to be set for delete functionality
            var usertileid = " echo escape(substr($tile_id18)); ?>" //Needs to be set for delete functionality
            var usertileidname = "# echo escape(substr($tile_id9)); ?>";
            var dashtileactionsid = "#DashTileActions_" + usertileid;
            var deletetileid = ".dash-delete_" + usertileid;
            var editlink = " echo isset($tile["url"]) ? $tile["url"] : ""?>";
            var tilehref; //Used to switch off and on tile link to stop issue clicking on tool bar but opening tile link
            var tileonclick; //Used to switch off and on tile link to stop issue clicking on tool bar but opening tile link
    
            jQuery(usertileidname).hover(
            function(e)
                {
                jQuery(dashtileactionsid).stop(true, true).slideDown();
                },
            function(e)
                {
                jQuery(dashtileactionsid).stop(true, true).slideUp();
                });
    
            jQuery(dashtileactionsid).hover(
            function(e)
                {
                tilehref = jQuery(usertileidname).attr("href");
                tileonclick = jQuery(usertileidname).attr("onclick");
                jQuery(usertileidname).attr("href", "#");
                jQuery(usertileidname).attr("onclick", "return false;");
                },
            function(e)
                {
                jQuery(usertileidname).attr("href", tilehref);
                jQuery(usertileidname).attr("onclick", tileonclick);
                tilehref = '';
                tileonclick = '';
                });
    
        jQuery(deletetileid).click(
                function(event,ui) {
                
                
if(checkPermission_dashadmin())
                    {
                    
?>
                    if(jQuery(usertileidname).hasClass("allUsers")) {
                        // This tile is set for all users so provide extra options
                         render_delete_dialog_JS(true); ?>
                    }
                    else {
                        //This tile belongs to this user only
                         render_delete_dialog_JS(false); ?>
                    }
                
                    
}
                else 
#Only show dialog to delete for this user
                    
?>
                    var dialog =  render_delete_dialog_JS(false); 
                    } 
?>
                })
            }
            else
            {
            jQuery("#DashTileActions_").remove();
            }
        });
    </script>
      
    
}

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 13th November 2024 15:50 Europe/London time.