Skip to content

Commit

Permalink
Update for new Craft 2.5 plugin functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
angrybrad committed Dec 21, 2015
1 parent 16cc169 commit 8bb6576
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 10 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ To install Category Sources, follow these steps:
1. Upload the categorysources/ folder to your craft/plugins/ folder.
2. Go to Settings > Plugins from your Craft control panel and enable the Category Sources plugin.
3. Click on “Category Sources” to go to the plugin’s settings page, and configure the plugin how you’d like.

## Changelog

### 1.1

- Updated to take advantage of new Craft 2.5 plugin features.

### 1.0

- Initial release
78 changes: 68 additions & 10 deletions categorysources/CategorySourcesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,73 @@

class CategorySourcesPlugin extends BasePlugin
{
function getName()
/**
* @return mixed
*/
public function getName()
{
return Craft::t('Category Sources');
}

function getVersion()
/**
* @return string
*/
public function getVersion()
{
return '1.0';
return '1.1';
}

function getDeveloper()
/**
* @return string
*/
public function getSchemaVersion()
{
return '1.0.0';
}

/**
* @return string
*/
public function getDeveloper()
{
return 'Pixel & Tonic';
}

function getDeveloperUrl()
/**
* @return string
*/
public function getDeveloperUrl()
{
return 'http://pixelandtonic.com';
}

protected function defineSettings()
/**
* @return string
*/
public function getPluginUrl()
{
return array(
'categoryGroups' => array(AttributeType::Mixed, 'default' => array()),
);
return 'https://github.com/pixelandtonic/CategorySources';
}

/**
* @return string
*/
public function getDocumentationUrl()
{
return $this->getPluginUrl().'/blob/master/README.md';
}

/**
* @return string
*/
public function getReleaseFeedUrl()
{
return 'https://raw.githubusercontent.com/pixelandtonic/CategorySources/master/releases.json';
}

/**
* @return mixed
*/
public function getSettingsHtml()
{
$groups = craft()->categories->getAllGroups();
Expand All @@ -53,6 +93,11 @@ public function getSettingsHtml()
));
}

/**
* @param $settings
*
* @return mixed
*/
public function prepSettings($settings)
{
if ($settings['categoryGroups'] == '*')
Expand All @@ -63,6 +108,10 @@ public function prepSettings($settings)
return $settings;
}

/**
* @param $sources
* @param $context
*/
public function modifyEntrySources(&$sources, $context)
{
$selectedGroups = $this->getSettings()->categoryGroups;
Expand Down Expand Up @@ -107,9 +156,18 @@ public function modifyEntrySources(&$sources, $context)
'criteria' => array('relatedTo' => array('targetElement' => $category->id))
);


$lastSourceByLevel[$l] = &$levelSources['cat:'.$category->id];
}
}
}

/**
* @return array
*/
protected function defineSettings()
{
return array(
'categoryGroups' => array(AttributeType::Mixed, 'default' => array()),
);
}
}
10 changes: 10 additions & 0 deletions releases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"version": "1.1",
"downloadUrl": "https://github.com/pixelandtonic/CategorySources/archive/1.1.zip",
"date": "2015-20-20T12:00:00-08:00",
"notes": [
"[Improved] Updated to take advantage of new Craft 2.5 plugin features."
]
}
]

0 comments on commit 8bb6576

Please sign in to comment.