Skip to content

Commit

Permalink
Fixes #3194. Support for contibutors in manifest.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sem authored and ewinslow committed Aug 26, 2012
1 parent 1bd9dd1 commit b2487ac
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 1 deletion.
13 changes: 13 additions & 0 deletions documentation/info/manifest.xml
Expand Up @@ -29,6 +29,19 @@
<path>graphics/plugin_ss2.png</path>
</screenshot>

<contributor>
<name>Evan Winslow</name>
<email>evan@elgg.org</email>
<website>http://evanwinslow.com/</website>
<username>ewinslow</username> <!-- Elgg community username -->
<description>Description of Evan's role in the project</description>
</contributor>

<contributor>
<name>Cash Costello</name>
<email>cash@elgg.org</email>
<description>Description of Cash's role in the project</description>
</contributor>
<category>admin</category>
<category>api</category>

Expand Down
31 changes: 31 additions & 0 deletions engine/classes/ElggPluginManifest.php
Expand Up @@ -113,6 +113,17 @@ class ElggPluginManifest {
'description' => '',
'path' => ''
);

/**
* The expected structure of a contributor element
*/
private $contributorStruct = array(
'name' => '',
'email' => '',
'website' => '',
'username' => '',
'description' => '',
);

/**
* The API version of the manifest.
Expand Down Expand Up @@ -386,6 +397,26 @@ public function getScreenshots() {

return $normalized;
}

/**
* Return the contributors listed.
*
* @return array
*/
public function getContributors() {
$ss = $this->parser->getAttribute('contributor');

if (!$ss) {
$ss = array();
}

$normalized = array();
foreach ($ss as $s) {
$normalized[] = $this->buildStruct($this->contributorStruct, $s);
}

return $normalized;
}

/**
* Return the list of provides by this plugin.
Expand Down
3 changes: 2 additions & 1 deletion engine/classes/ElggPluginManifestParser18.php
Expand Up @@ -15,7 +15,7 @@ class ElggPluginManifestParser18 extends ElggPluginManifestParser {
protected $validAttributes = array(
'name', 'author', 'version', 'blurb', 'description', 'id',
'website', 'copyright', 'license', 'requires', 'suggests',
'screenshot', 'category', 'conflicts', 'provides',
'screenshot', 'contributor', 'category', 'conflicts', 'provides',
'activate_on_install'
);

Expand Down Expand Up @@ -60,6 +60,7 @@ public function parse() {

// 3d arrays
case 'screenshot':
case 'contributor':
case 'provides':
case 'conflicts':
case 'requires':
Expand Down
15 changes: 15 additions & 0 deletions engine/tests/ElggCorePluginsAPITest.php
Expand Up @@ -88,6 +88,11 @@ public function testElggPluginManifest18() {
array('description' => 'Fun things to do 1', 'path' => 'graphics/plugin_ss1.png'),
array('description' => 'Fun things to do 2', 'path' => 'graphics/plugin_ss2.png'),
),

'contributor' => array(
array('name' => 'Evan Winslow', 'email' => 'evan@elgg.org', 'website' => 'http://evanwinslow.com/', 'username' => 'ewinslow', 'description' => "Description of Evan's role in the project"),
array('name' => 'Cash Costello', 'email' => 'cash@elgg.org', 'description' => "Description of Cash's role in the project"),
),

'category' => array(
'Admin', 'ServiceAPI'
Expand Down Expand Up @@ -235,6 +240,16 @@ public function testElggPluginManifestGetScreenshots() {
$this->assertIdentical($this->package18->getManifest()->getScreenshots(), $screenshots);
$this->assertIdentical($this->package17->getManifest()->getScreenshots(), array());
}

public function testElggPluginManifestGetContributors() {
$contributors = array(
array('name' => 'Evan Winslow', 'email' => 'evan@elgg.org', 'website' => 'http://evanwinslow.com/', 'username' => 'ewinslow', 'description' => "Description of Evan's role in the project"),
array('name' => 'Cash Costello', 'email' => 'cash@elgg.org', 'website' => '', 'username' => '', 'description' => "Description of Cash's role in the project"),
);

$this->assertIdentical($this->package18->getManifest()->getContributors(), $contributors);
$this->assertIdentical($this->package17->getManifest()->getContributors(), array());
}

public function testElggPluginManifestGetProvides() {
$provides = array(
Expand Down
14 changes: 14 additions & 0 deletions engine/tests/test_files/plugin_18/manifest.xml
Expand Up @@ -30,6 +30,20 @@
<path>graphics/plugin_ss2.png</path>
</screenshot>

<contributor>
<name>Evan Winslow</name>
<email>evan@elgg.org</email>
<website>http://evanwinslow.com/</website>
<username>ewinslow</username> <!-- Elgg community username -->
<description>Description of Evan's role in the project</description>
</contributor>

<contributor>
<name>Cash Costello</name>
<email>cash@elgg.org</email>
<description>Description of Cash's role in the project</description>
</contributor>

<category>Admin</category>

<category>ServiceAPI</category>
Expand Down
1 change: 1 addition & 0 deletions languages/en.php
Expand Up @@ -693,6 +693,7 @@
'admin:plugins:label:moreinfo' => 'more info',
'admin:plugins:label:version' => 'Version',
'admin:plugins:label:location' => 'Location',
'admin:plugins:label:contributors' => 'Contributors',
'admin:plugins:label:dependencies' => 'Dependencies',

'admin:plugins:warning:elgg_version_unknown' => 'This plugin uses a legacy manifest file and does not specify a compatible Elgg version. It probably will not work!',
Expand Down
8 changes: 8 additions & 0 deletions views/default/css/admin.php
Expand Up @@ -1417,6 +1417,14 @@
.elgg-plugin-screenshot-lightbox h2 {
color: black;
}
.elgg-plugin-contributors {
list-style-position: inside;
list-style-type: circle;
}
.elgg-plugin-contributors li {
font-style: italic;
padding-left: 10px;
}
.elgg-plugin.elgg-state-active {
background: white;
}
Expand Down
43 changes: 43 additions & 0 deletions views/default/object/plugin/elements/contributors.php
@@ -0,0 +1,43 @@
<?php
/**
* Shows a list of contributors for ElggPlugin in $vars['plugin'].
*
* @package Elgg.Core
* @subpackage Admin.Plugins
*/

$plugin = elgg_extract('plugin', $vars, false);
$contributors = $plugin->getManifest()->getContributors();

echo '<ul class="elgg-plugin-contributors">';

foreach ($contributors as $contributor) {
echo "<li title=\"{$contributor['description']}\">";
echo $contributor['name'];

if ($contributor['email'] || $contributor['username'] || $contributor['website']) {
echo " - ";
}

if ($contributor['email']) {
echo "<a href=\"mailto:{$contributor['email']}\">&lt;{$contributor['email']}&gt;</a>";
}

if ($contributor['email'] && ($contributor['website'])) {
echo ", ";
}

if ($contributor['website']) {
echo "<a href=\"{$contributor['website']}\">{$contributor['website']}</a>";
}

if (($contributor['email'] || $contributor['website']) && $contributor['username']) {
echo ", ";
}

if ($contributor['username']) {
echo "<a href=\"http://community.elgg.org/profile/{$contributor['username']}\">@{$contributor['username']}</a>";
}
}

echo '</dl>';
5 changes: 5 additions & 0 deletions views/default/object/plugin/full.php
Expand Up @@ -276,6 +276,11 @@
<div><?php echo elgg_echo('admin:plugins:label:copyright') . ": " . $copyright; ?></div>
<div><?php echo elgg_echo('admin:plugins:label:licence') . ": " . $license; ?></div>
<div><?php echo elgg_echo('admin:plugins:label:location') . ": " . htmlspecialchars($plugin->getPath()) ?></div>
<div><?php echo elgg_echo('admin:plugins:label:contributors') ?>:
<?php
echo elgg_view('object/plugin/elements/contributors', array('plugin' => $plugin));
?>
</div>

<div><?php echo elgg_echo('admin:plugins:label:dependencies'); ?>:
<?php
Expand Down

0 comments on commit b2487ac

Please sign in to comment.