Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@obfuscode
Last active April 29, 2020 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obfuscode/77d0135970c9ce8bc84139c127507bb1 to your computer and use it in GitHub Desktop.
Save obfuscode/77d0135970c9ce8bc84139c127507bb1 to your computer and use it in GitHub Desktop.
Sample Assets Jump File
<?php
/**
* Jump Menu for Assets
*
* This file must be in your /system/user/addons/assets directory of your ExpressionEngine installation
*
* @package Assets
* @author EEHarbor <help@eeharbor.com>
* @copyright Copyright (c) 2020 EEHarbor
* @link http://eeharbor.com/assets
*/
use EllisLab\ExpressionEngine\Service\JumpMenu\AbstractJumpMenu;
require_once PATH_THIRD . 'assets/addon.setup.php';
require_once PATH_THIRD . 'assets/mcp.assets.php';
class Assets_jump extends AbstractJumpMenu
{
private static $source_map = array('s3' => 'Amazon S3', 'rs' => 'Rackspace Cloud Files', 'gc' => 'Google Cloud Storage');
protected static $items = array(
'folders' => array(
'icon' => 'fa-file',
'command' => 'view folders',
'command_title' => 'View <b>Folders</b>',
'dynamic' => false,
'requires_keyword' => false,
'target' => ''
),
'updateIndexes' => array(
'icon' => 'fa-cog',
'command' => 'update indexes',
'command_title' => '<b>Update Indexes</b>',
'dynamic' => false,
'requires_keyword' => false,
'target' => 'update_indexes'
),
'editExternalSource' => array(
'icon' => 'fa-cog',
'command' => 'edit external source titled',
'command_title' => 'Edit <b>External Source</b> titled <i>[source]</i>',
'dynamic' => true,
'requires_keyword' => false,
'target' => 'editExternalSource'
),
'createExternalSource' => array(
'icon' => 'fa-plus',
'command' => 'create external source',
'command_title' => 'Create <b>External Source</b>',
'dynamic' => false,
'requires_keyword' => false,
'target' => 'edit_source'
),
'license' => array(
'icon' => 'fa-lock',
'command' => 'license',
'command_title' => '<b>License</b>',
'dynamic' => false,
'requires_keyword' => false,
'target' => 'license'
)
);
public function editExternalSource($searchKeywords = array())
{
$sourceItems = array();
$sourcesQuery = ee()->db->select('source_id, source_type, name');
if (!empty($searchKeywords)) {
foreach ($searchKeywords as $searchKeyword) {
$sourcesQuery->like('name', $searchKeyword);
}
}
$sources = $sourcesQuery->order_by('name', 'ASC')->get('assets_sources')->result();
foreach ($sources as $source) {
$sourceItems['source_' . $source->source_id] = array(
'icon' => 'fa-pencil-alt',
'command' => $source->name,
'command_title' => $source->name,
'command_context' => self::$source_map[$source->source_type],
'dynamic' => false,
'requires_keyword' => false,
'target' => 'edit_source&source_id=' . $source->source_id
);
}
return $sourceItems;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment