Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add `Logged in Author ds` (replace login info event). #9

Merged
merged 1 commit into from

2 participants

@alpacaaa

No description provided.

@allen allen merged commit 73e0ff8 into symphonycms:integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 10, 2012
  1. Add `Logged in Author ds` (replace login info event).

    Marco Sampellegrini authored
This page is out of date. Refresh to see the latest.
View
72 data-sources/data.logged_in_author.php
@@ -0,0 +1,72 @@
+<?php
+
+ require_once(TOOLKIT . '/class.datasource.php');
+
+ Class datasourcelogged_in_author extends Datasource{
+
+ public $dsParamROOTELEMENT = 'logged-in-author';
+ public $dsParamORDER = 'desc';
+ public $dsParamREDIRECTONEMPTY = 'no';
+ public $dsParamSORT = 'id';
+
+
+ public $dsParamFILTERS = array(
+ 'username' => '{$cookie-username:0}',
+ );
+
+
+ public $dsParamINCLUDEDELEMENTS = array(
+ 'username'
+ );
+
+
+ public function __construct(&$parent, $env=NULL, $process_params=true){
+ parent::__construct($parent, $env, $process_params);
+ $this->_dependencies = array();
+ }
+
+ public function about(){
+ return array(
+ 'name' => 'Logged in Author',
+ 'author' => array(
+ 'name' => 'Symphony Team',
+ 'website' => 'http://symphony-cms.com',
+ 'email' => 'team@symphony-cms.com'),
+ 'version' => '1.0',
+ 'release-date' => '2012-03-10'
+ );
+ }
+
+ public function getSource(){
+ return 'authors';
+ }
+
+ public function allowEditorToParse(){
+ return true;
+ }
+
+ public function grab(&$param_pool=NULL){
+ $result = new XMLElement($this->dsParamROOTELEMENT);
+
+ try{
+
+ include(TOOLKIT . '/data-sources/datasource.author.php');
+ }
+ catch(FrontendPageNotFoundException $e){
+ // Work around. This ensures the 404 page is displayed and
+ // is not picked up by the default catch() statement below
+ FrontendPageNotFoundExceptionHandler::render($e);
+ }
+ catch(Exception $e){
+ $result->appendChild(new XMLElement('error', $e->getMessage()));
+ return $result;
+ }
+
+ if($this->_force_empty_result) $result = $this->emptyXMLSet();
+
+
+
+ return $result;
+ }
+
+ }
View
2  utilities/master.xsl
@@ -12,7 +12,7 @@
encoding="UTF-8"
indent="yes" />
-<xsl:variable name="is-logged-in" select="/data/events/login-info/@logged-in"/>
+<xsl:variable name="is-logged-in" select="/data/logged-in-author/author"/>
<xsl:template match="/">
View
9 utilities/navigation.xsl
@@ -4,10 +4,13 @@
<xsl:template match="navigation">
<ul id="menu">
<xsl:apply-templates select="page[not(types/type = 'hidden') and not(types/type = 'admin')]"/>
- <xsl:if test="/data/events/login-info/@logged-in = 'true'">
+ <xsl:if test="$is-logged-in">
<li><a href="{$root}/drafts/">Drafts</a></li>
<li><a href="{$root}/symphony/">Admin</a></li>
- <li><a href="?debug">Debug</a></li>
+
+ <xsl:if test="/data/logged-in-author/author[@user-type = 'developer']">
+ <li><a href="?debug">Debug</a></li>
+ </xsl:if>
</xsl:if>
</ul>
</xsl:template>
@@ -23,4 +26,4 @@
</li>
</xsl:template>
-</xsl:stylesheet>
+</xsl:stylesheet>
Something went wrong with that request. Please try again.