Skip to content

Instantly share code, notes, and snippets.

@rvsjoen
rvsjoen / access.xml
Created June 21, 2012 13:26
ACL Actions with inheritance
<?xml version="1.0" encoding="utf-8"?>
<access component="com_test">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="test.manage" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" inherit="core.delete"/>
</section>
@rvsjoen
rvsjoen / default.php
Created June 26, 2012 23:23
Frontend toolbar in Joomla!
<form method="post" action="index.php" id="adminForm">
<div id="toolbar-box"><?php echo $this->toolbar->render(); ?></div>
<input type="hidden" name="option" value="com_foo" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="id" value="<?php echo $this->item->id; ?>" />
<?php echo JHtml::_('form.token'); ?>
</form>
<?php
class BaseController extends JControllerForm
{
public function delete()
{
// Do shit
$this->setRedirect(JRoute::_($this->getRedirectToList(), false));
}
<script>
function destroyLessCache(pathToCss) { // e.g. '/css/' or '/stylesheets/'
if (!window.localStorage || !less || less.env !== 'development') {
// return;
}
var host = window.location.host;
var protocol = window.location.protocol;
var keyPrefix = protocol + '//' + host + pathToCss;
for (var key in window.localStorage) {
if (key.indexOf(keyPrefix) === 0) {
class ... extends JControllerForm
{
public function save($key = null, $urlVar = null)
{
$result = parent::save($key, $urlVar);
$model = $this->getModel();
$state = $model->getState();
if($result){
$link = JRoute::_($this->getRedirectToItem().'&id='.$state->get('item.id'), false);
$this->setRedirect($link);
<?php
foreach ($form->getFieldsets() as $group => $fieldset) {
foreach ($form->getFieldset($group) as $field) {
$form->removeField($field->fieldname); // This will remove only the fields outside <fields> elements
// $form->removeField($field->fieldname, $group); // This will remove only the fields inside the <fields> element
}
}
?>
@rvsjoen
rvsjoen / gist:3077007
Created July 9, 2012 14:56
Joomla! CMS File system structure
+-- administrator // This is where the administrator application lives
¦ +-- cache
¦ +-- components // Components specific to administrator
¦ +-- help // Help files for administrator
¦ +-- includes
¦ +-- language // Administrator language files
¦ +-- manifests // Installation manifests
¦ +-- modules // Administrator modules
¦ +-- templates // Administrator templates
+-- cache
<?php
class DonkeyController extends JController
{
public function doshit()
{
$model = $this->getModel();
$model->setState('foo', 'bar');
$model->foo = 'bar';
$this->setRedirect('index.php?option=com_donkey&view=shit');
<?php defined('_JEXEC') or die;
jimport('joomla.application.component.view');
abstract class HelloWorldViewBase extends JView {
public function __construct($config = array()) {
parent::__construct($config);
// Using addTemplatePath will give this a high priority, so we push instead
array_push($this->_path['template'], JPATH_COMPONENT . '/views/base/tmpl');
@rvsjoen
rvsjoen / gist:3177753
Created July 25, 2012 18:33
Setting up PHPUnit for Joomla Platform!
sudo pear install --alldeps phpunit/PHPUnit
sudo pear install phpunit/PHPUnit_MockObject
sudo pear install phpunit/DBUnit