Skip to content

Instantly share code, notes, and snippets.

@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>
@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 / routing.txt
Created June 12, 2012 19:38
Component routing
$this->_segment_map = array(
"items" => array(
"item" => array(
"layout" => array(
"new" => "new"
"edit" => "edit"
)
)
),
"item" => "items,
@rvsjoen
rvsjoen / rest.txt
Created March 6, 2012 15:49
REST interface
### General requirements
- Should return 405 method not supported if the components do not provide controllers in the specified format
- Should work with and without SEF enabled, with and without htaccess
- Preferably implemented in a plugin so it can be easily disabled
- Uses OAuth2 for security
- The REST trigger should be configurable via parameter
- The format of the returned document is controlled by the HTTP Accept header
### URLs
private function authenticate($username, $password = null, $valid = 86400)
{
// Get a database object
$db = JFactory::getDbo();
$db->setQuery($db->getQuery(true)
->select('id, password')
->from('#__users')
->where('username='.$db->q($username)));
$result = $db->loadObject();
function makeRequest($str){
return base64_encode(json_encode($str));
}
function doPost($str, $url = null){
$baseurl = "http://localhost/?format=json";
var_dump($baseurl.'&api='.$str);
return json_decode(file_get_contents($baseurl.'&api='.$str.$url));
}
@rvsjoen
rvsjoen / gist:1699501
Created January 29, 2012 16:24
Joomla! 1.7 to 2.5 upgrade issues
a. Copy the Joomla_2.5.0-Stable-Update_Package.zip to your root html folder.
b. Using the FTP File Manager, Unarchive this file. Check the Override Existing Files box.
c. After this completes, the site should load and should say 2.5.0 in the Site Information.
d. In the back end, go to Installation Manager: Database. It will likely show problems. Click Fix and it should fix the problems.
e. Go to Installation Manager: Discover and click Discover. It will likely show new extensions. Select them all and click Install. It should install the new 2.5 extensions.
f. At this point, everything should be OK except that it will still indicate that you need to update to 2.5.0 in the Update tab (even though you don't!). To fix this, you need to edit a row in the database.
g. Go to the phpMyAdmin and find the row in the #__extensions table where id=700. In the manifest_cache column, you will see the text:
"version":"1.7.3"
Change this to
"version":"2.5.0"
@rvsjoen
rvsjoen / gist:1440151
Created December 6, 2011 21:45
Loading jQuery in Joomla
$doc = JFactory::getDocument();
$doc->addScript('https://www.google.com/jsapi');
$doc->addScriptDeclaration('
google.load("jquery", "1.6.2", {uncompressed: true});
google.load("jqueryui", "1.8.15", {uncompressed:true});
');
$doc->addStyleSheet('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/themes/ui-lightness/jquery-ui.css');
public function __construct(&$subject, $config = array()){
parent::__construct($subject, $config);
$this->loadLanguage();
}
@rvsjoen
rvsjoen / gist:1355080
Created November 10, 2011 15:13
RFC violation
diff --git administrator/includes/framework.php administrator/includes/framework.php
index 0e2ec0e..a6d7274 100644
--- administrator/includes/framework.php
+++ administrator/includes/framework.php
@@ -21,7 +21,23 @@ defined('_JEXEC') or die;
* Installation check, and check on removal of the install directory.
*/
if (!file_exists(JPATH_CONFIGURATION.'/configuration.php') || (filesize(JPATH_CONFIGURATION.'/configuration.php') < 10) /*|| file_exists(JPATH_INSTALLATION.'/index.php')*/) {
- header('Location: ../installation/index.php');
+