Skip to content

Instantly share code, notes, and snippets.

@eddieajau
Created January 28, 2013 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eddieajau/4651967 to your computer and use it in GitHub Desktop.
Save eddieajau/4651967 to your computer and use it in GitHub Desktop.
Eclipse snippet category for backend component support code in Joomla 2.5 (all except CSS should be applicable for Joomla 3.0). Includes: Add submenu method for backend component helper, Add submenu call to master backend controller, Adds a call to JSubMenuHelper that will show a link to the categories view., Text prefix for item subcontroller, …
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1303255935762" initial_state="1" label="Backend Support" largeicon="" smallicon="">
<description><![CDATA[Additional snippets that support backend components.]]></description>
<item category="category_1303255935762" class="" editorclass="" id="item_1303256255316" label="Add submenu method for backend component helper" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet provides the addSubmenu method that should be added to the backend helper class (usually found in /com_{component}/helpers/{component}.php). One sub-menu entry is provided - copy and paste to suit the number of views that need to be supported. Remember to add the hook into the controller to invoke this method.]]></description>
<content><![CDATA[ /**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since ${SINCE}
*/
public static function addSubmenu($vName)
{
JSubMenuHelper::addEntry(
JText::_('COM_${NAME}_SUBMENU_${VIEW}'),
'index.php?option=com_${NAME}&view=${VIEW}',
$vName == '${VIEW}'
);
}
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the component (without com_).]]></description>
</variable>
<variable default="" id="name_2" name="VIEW">
<description><![CDATA[The lower case name of the first view to be supported.]]></description>
</variable>
<variable default="1.0" id="name_3" name="SINCE">
<description><![CDATA[The version this feature was added.]]></description>
</variable>
</item>
<item category="category_1303255935762" class="" editorclass="" id="item_1303256943112" label="Add submenu call to master backend controller" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[Adds the call to the components helpers addSubmenu in the master backend controler's display method. Place the snippet before the call to parent::display(). Remove the line assigning the $view variable if it has already been supplied.]]></description>
<content><![CDATA[ // Load the submenu.
$view = JRequest::getCmd('view', '${VIEW}');
${NAME}Helper::addSubmenu($view);
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The proper case name of the component (without com_).]]></description>
</variable>
<variable default="" id="name_2" name="VIEW">
<description><![CDATA[The lower case name of the deault view.]]></description>
</variable>
</item>
<item category="category_1303255935762" class="" editorclass="" id="item_1309324543415" label="Add submenu call for categories" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[Adds a call to JSubMenuHelper that will show a link to the categories view.]]></description>
<content><![CDATA[ JSubMenuHelper::addEntry(
JText::_('COM_${NAME}_SUBMENU_CATEGORIES'),
'index.php?option=com_categories&extension=com_${NAME}',
$vName == 'categories'
);
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the component (without com_).]]></description>
</variable>
</item>
<item category="category_1303255935762" class="" editorclass="" id="item_1303262746762" label="Text prefix for item subcontroller" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[A snippet to add to backend item subcontroller that defines the entire prefix for language strings relating to controller operations (like publishing). This is used in component with multiple list views (for example, like com_banners).]]></description>
<content><![CDATA[ /**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_${NAME}${STUB}';
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The upper case name of the component (without com_).]]></description>
</variable>
<variable default="" id="name_2" name="STUB">
<description><![CDATA[The upper case suffix to add to the component name to support an a view.]]></description>
</variable>
</item>
<item category="category_1303255935762" class="" editorclass="" id="item_1303282791392" label="Add item sub-controller methods for custom primary key name." largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[Snippet for adding override methods to the 'item' sub-controller where a primary key name other than "id" is used.]]></description>
<content><![CDATA[ /**
* Method to check if you can add a new record.
*
* Extended classes can override this if necessary.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since ${SINCE}
*/
protected function allowEdit($data = array(), $key = '${PK}')
{
return parent::allowEdit($data, $key);
}
/**
* Method to check if you can save a new or existing record.
*
* Extended classes can override this if necessary.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since ${SINCE}
*/
protected function allowSave($data, $key = '${PK}')
{
return allowSave($data, $key);
}
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return Boolean True if access level checks pass, false otherwise.
* @since ${SINCE}
*/
public function cancel($key = '${PK}')
{
return parent::cancel($key);
}
/**
* Method to edit an existing record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return Boolean True if access level check and checkout passes, false otherwise.
* @since ${SINCE}
*/
public function edit($key = '${PK}', $urlVar = null)
{
return parent::edit($key, $urlVar);
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return Boolean True if successful, false otherwise.
* @since ${SINCE}
*/
public function save($key = '${PK}', $urlVar = null)
{
return parent::save($key, $urlVar);
}]]></content>
<variable default="1.0" id="name_1" name="SINCE">
<description><![CDATA[The version this feature was added.]]></description>
</variable>
<variable default="id" id="name_2" name="PK">
<description><![CDATA[The name of the primary key in the database table.]]></description>
</variable>
</item>
<item category="category_1303255935762" class="" editorclass="" id="item_1311162993891" label="Basic component CSS file" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[A basic CSS file for styling component icon.]]></description>
<content><![CDATA[/* Toolbar */
.icon-48-hello {
background: url(../images/${NAME}_48x48.png) no-repeat left;
}
.icon-16-hello {
background: url(../images/${NAME}_48x48.png) no-repeat left;
}]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the component (without com_)]]></description>
</variable>
</item>
<item category="category_1303255935762" class="" editorclass="" id="item_1313818229859" label="Include component stylesheet." largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description/>
<content><![CDATA[JHtml::stylesheet('com_${NAME}/${STYLE}.css', null, true);
]]></content>
<variable default="" id="name_1" name="NAME">
<description><![CDATA[The lower case name of the component (without com_)]]></description>
</variable>
<variable default="" id="name_2" name="STYLE">
<description><![CDATA[The name of CSS file (without .css)]]></description>
</variable>
</item>
</category>
</snippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment