Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions extension.driver.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
<?php
Class extension_backend_add_script extends Extension
{
/**
* About this extension:
*/
public function about()
{
return array(
'name' => 'Backend add script',
'version' => '1.2',
'release-date' => '2011-12-15',
'author' => array(
'name' => 'Twisted Interactive',
'website' => 'http://www.twisted.nl'),
'description' => 'Adds a hook to the backend so you can easily make JavaScript adjustments on certain pages'
);
}

/**
* Set the delegates
*/
Expand Down Expand Up @@ -47,18 +31,24 @@ public function addScriptToHead($context)
$idEntry= isset($callback['context']['entry_id']) ? '"'.$callback['context']['entry_id'].'"' : 'false';

// User information:
$javaScript.= "var user_id = ".Administration::instance()->Author->get('id').";\n";
$javaScript.= "var user_type = '".Administration::instance()->Author->get('user_type')."';\n";
$author = null;
if (is_callable(array('Symphony', 'Author'))) {
$author = Symphony::Author();
} else {
$author = Administration::instance()->Author;
}
$javaScript.= "var user_id = ".$author->get('id').";\n";
$javaScript.= "var user_type = '".$author->get('user_type')."';\n";
$javaScript.= "var driver = ".$driver.";\n";
$javaScript.= "var action = ".$action.";\n";
$javaScript.= "var section = ".$section.";\n";
$javaScript.= "var id_entry = ".$idEntry.";\n";

$tag = new XMLElement('script', $javaScript, array('type'=>'text/javascript'));

Administration::instance()->Page->addElementToHead($tag);
Administration::instance()->Page->addScriptToHead(URL.'/extensions/backend_add_script/assets/custom.js');
Administration::instance()->Page->addStylesheetToHead(URL.'/extensions/backend_add_script/assets/custom.css');
}
Administration::instance()->Page->addElementToHead($tag);
Administration::instance()->Page->addScriptToHead(URL.'/extensions/backend_add_script/assets/custom.js');
Administration::instance()->Page->addStylesheetToHead(URL.'/extensions/backend_add_script/assets/custom.css');
}
}
?>
13 changes: 8 additions & 5 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
<name>Backend Add Script</name>
<description>Adds a hook to the backend so you can easily make JavaScript and CSS adjustments on certain pages.</description>
<repo type="github">https://github.com/TwistedInteractive/backend_add_script</repo>
<types>
<type>Other</type>
<type>Workflow</type>
</types>
<types>
<type>Other</type>
<type>Workflow</type>
</types>
<authors>
<author>
<name github="TwistedInteractive">Twisted Interactive</name>
<website>http://www.twisted.nl</website>
</author>
</authors>
<releases>
<release version="1.3" date="2014-10-15" min="2.4.0" max="2.5.x">
- Compatibility with Symphony 2.5.x
</release>
<release version="1.2" date="2011-12-15" min="2.3"/>
<release version="1.1" date="2010-08-17" max="2.2.x"/>
<release version="1.1" date="2010-08-17" max="2.2.x"/>
</releases>
</extension>