Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Mar 10, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
72 changes: 72 additions & 0 deletions 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;
}

}
2 changes: 1 addition & 1 deletion utilities/master.xsl
Expand Up @@ -12,7 +12,7 @@
encoding="UTF-8" encoding="UTF-8"
indent="yes" /> 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="/"> <xsl:template match="/">


Expand Down
9 changes: 6 additions & 3 deletions utilities/navigation.xsl
Expand Up @@ -4,10 +4,13 @@
<xsl:template match="navigation"> <xsl:template match="navigation">
<ul id="menu"> <ul id="menu">
<xsl:apply-templates select="page[not(types/type = 'hidden') and not(types/type = 'admin')]"/> <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}/drafts/">Drafts</a></li>
<li><a href="{$root}/symphony/">Admin</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> </xsl:if>
</ul> </ul>
</xsl:template> </xsl:template>
Expand All @@ -23,4 +26,4 @@
</li> </li>
</xsl:template> </xsl:template>


</xsl:stylesheet> </xsl:stylesheet>