Integrate to File Manager

Plesk File Manager is a part of user interface that allows administrator, reseller, or customer to manage domain's files and directories and provides a set of useful features, for example, a visual HTML editor and a file permissions manager. Starting from Plesk 11.5, you can create extensions that add functionality to Plesk File Manager.

To add an item to the context menu of the File Manager:

  1. Create the file /plib/library/FileManager/Action.php in your extension directory.
  2. Create the class Modules_MyModule_FileManager_Action that extends the pm_FileManager_Action class in this file. MyModule here is your extension's ID.

    The following methods are used:

class Modules_CodeEditor_FileManager_Action extends pm_FileManager_Action
    {
    	/**
    	* Retrieve title for action
    	*/
    	public function getTitle()
    	{
    		pm_Context::init('code-editor');
     
    		return $this->lmsg('actionTitle');
    	}
     
    	/**
    	* Retrieve name for action
    	* by default name is camelCase module ID
    	*/
    	public function getName()
    	{
    		return parent::getName();
    	}
     
		    /**
    	* Retrieve URL for action
    	*/
    	public function getHref()
    	{
    		pm_Context::init('code-editor');
     
    		$params = array(
    		'currentDir=' . urlencode($this->_item['currentDir']),
    		'file=' . urlencode($this->_item['name']),
    		);
    		return pm_Context::getBaseUrl() . '?' . implode('&', $params);
    	}
     
    	/**
    	* Checks if action is available for a file
    	*/
    	public function isActive()
    	{
    		if ($this->_item['isDirectory']) {
    			return false;
    		}
     
    		return true;
    	}
     
    	/**
    	* Checks if action is default for a file
    	*/
    	public function isDefault()
    	{
    		return false;
    	}
    }

The variable $this->_item contains an array with the information about the file or a directory on which the menu is shown:

array (
    'name' => 'hello.txt',
    'modificationTimestamp' => '1380276799',
    'modificationDate' => 'Sep 27, 2013 05:13 PM',
    'size' => '8192',
    'formatedSize' => '8.0 KB',
    'user' => 'user_ifvbjsgcdk',
    'group' => 'psacln',
    'filePerms' => 'rw- r-- r-- ',
    'isDirectory' => false,
    'icon' => '/theme/icons/16/plesk/file-txt.png',
    'isReadonly' => false,
    'currentDir' => '/httpdocs',
)

As a result of adding such an extension, a new item will be available in the File Manager context menu:

FileManager

 

Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.