Skip to content

Commit

Permalink
fix according to coding standards
Browse files Browse the repository at this point in the history
Paraview.sh to the rescue
  • Loading branch information
Gleek committed Aug 16, 2014
1 parent 31f3a3e commit d7d2b5c
Show file tree
Hide file tree
Showing 25 changed files with 89 additions and 93 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

8 changes: 4 additions & 4 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Rules Provided
###Action###
- **Add url along with tags** : Addition of URL to Pocket. Optionally you can also provide tags
- **Delete URL** : Deletion of URL from Pocket
- **Archive / Unarchive URL** : Two seperate actions are provided for archiving purpose.
- **Favorite / Unfavorite URL** : Two seperate actions are provided for favorite purpose
- **Archive / Unarchive URL** : Two separate actions are provided for archiving purpose.
- **Favorite / Unfavorite URL** : Two separate actions are provided for favorite purpose
- **Adding Tags** : Action Add tags to an entry in the already existing tags.
- **Replacing Tags** : Replace tags of an entry with new provided tags.
- **Clearing Tags**: Clear all tags of an entry
Expand Down Expand Up @@ -90,10 +90,10 @@ Rules Provided
- **Restrict by Type**: Article
**Action** (Add URL to pocket)
- **URL** : node:url
- **Tags** : \<Comma seperated tags, if any\>
- **Tags** : \<Comma separated tags, if any\>
- **Pocket Account** : \<Select your e-mail address\>

Similarly a rule can be added to delete or archive url in pocket everytime an Article is deleted on a drupal site.
Similarly a rule can be added to delete or archive url in pocket every time an Article is deleted on a drupal site.

####Tweeting about your favorite articles in Pocket (also involves fluxtwitter)####
**Event**
Expand Down
7 changes: 1 addition & 6 deletions fluxpocket.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@ package = fluxkraft
core = 7.x
php = 5.3
dependencies[] = fluxservice

; Information added by drupal.org packaging script on 2013-10-28
version = "7.x-1.x-dev"
core = "7.x"
project = "fluxlinkedin"
datestamp = "1382986365"
dependencies[] = rules_scheduler
2 changes: 1 addition & 1 deletion fluxpocket.module
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function fluxpocket_fluxservice_plugin_directory() {
* Implements hook_rules_category_info().
*/
function fluxpocket_rules_category_info() {
$info = array();
$info = array();
// Use the same icon as for the service plugin.
$info['fluxpocket'] = array(
'label' => t('Pocket'),
Expand Down
3 changes: 1 addition & 2 deletions lib/Drupal/fluxpocket/Plugin/Entity/PocketEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public static function getEntityPropertyInfo($entity_type, $entity_info) {
'type' => 'text',
);


$info['resolved_title'] = array(
'label' => t('Resolved Title'),
'description' => t('The Resolved Title for the entry by Pocket'),
Expand All @@ -95,7 +94,7 @@ public static function getEntityPropertyInfo($entity_type, $entity_info) {
$info['tags'] = array(
'label' => t('Tags'),
'description' => t('A collection of tags associated with the particular entry.'),
'type' => 'list<text>'
'type' => 'list<text>',
);

$info['favorite'] = array(
Expand Down
10 changes: 6 additions & 4 deletions lib/Drupal/fluxpocket/Plugin/Rules/Action/AddUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ public static function getInfo() {
*/
public function execute($page_url, $tags, PocketAccountInterface $account) {
$client = $account->client();
//Structuring the array of url to be added
//Getting Tag List
$tag_ar = explode(",",$tags);
//Trimming spaces from array list

// Structuring the array of url to be added.
// Getting Tag List.
$tag_ar = explode(",", $tags);

// Trimming spaces from array list.
$tag_ar = array_filter(array_map('trim', $tag_ar));
$link_info = array(
'url' => $page_url,
Expand Down
12 changes: 7 additions & 5 deletions lib/Drupal/fluxpocket/Plugin/Rules/Action/Addtag.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ public static function getInfo() {
*/
public function execute($page_url, $tags, PocketAccountInterface $account) {
$client = $account->client();
//Structuring the array of tags to be added
//Getting Tag List
$tag_ar = explode(",",$tags);
//Trimming spaces from array list

// Structuring the array of tags to be added.
// Getting Tag List.
$tag_ar = explode(",", $tags);

// Trimming spaces from array list.
$tag_ar = array_filter(array_map('trim', $tag_ar));

$item_id = RetrieveBase::getItemIdFromUrl($client, $page_url);

$tag_info = array(
'item_id' => $item_id,
'tags' => $tag_ar
'tags' => $tag_ar,
);

$pockpack_q = new PockpackQueue();
Expand Down
2 changes: 1 addition & 1 deletion lib/Drupal/fluxpocket/Plugin/Rules/Action/ArchiveUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @file
* Contains ArchiveUrl
* Contains ArchiveUrl.
*/

namespace Drupal\fluxpocket\Plugin\Rules\Action;
Expand Down
2 changes: 1 addition & 1 deletion lib/Drupal/fluxpocket/Plugin/Rules/Action/ClearTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static function getInfo() {
*/
public function execute($page_url, PocketAccountInterface $account) {
$client = $account->client();
//Structuring the array of url to be added

// Structuring the array of url to be added.
$item_id = RetrieveBase::getItemIdFromUrl($client, $page_url);

$pockpack_q = new PockpackQueue();
Expand Down
2 changes: 1 addition & 1 deletion lib/Drupal/fluxpocket/Plugin/Rules/Action/FavoriteUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Duellsy\Pockpack\PockpackQueue;

/**
* Action to add URL to favorites
* Action to add URL to favorites.
*/
class FavoriteUrl extends RetrieveBase {

Expand Down
11 changes: 6 additions & 5 deletions lib/Drupal/fluxpocket/Plugin/Rules/Action/RemoveTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ public static function getInfo() {
*/
public function execute($page_url, $tags, PocketAccountInterface $account) {
$client = $account->client();
//Structuring the array of tags to be added
//Getting Tag List
$tag_ar = explode(",",$tags);
//Trimming spaces from array list
// Structuring the array of tags to be added.
// Getting Tag List.
$tag_ar = explode(",", $tags);

// Trimming spaces from array list
$tag_ar = array_filter(array_map('trim', $tag_ar));

$item_id = RetrieveBase::getItemIdFromUrl($client, $page_url);

$tag_info = array(
'item_id' => $item_id,
'tags' => $tag_ar
'tags' => $tag_ar,
);

$pockpack_q = new PockpackQueue();
Expand Down
11 changes: 6 additions & 5 deletions lib/Drupal/fluxpocket/Plugin/Rules/Action/ReplaceTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,18 @@ public static function getInfo() {
*/
public function execute($page_url, $tags, PocketAccountInterface $account) {
$client = $account->client();
//Structuring the array of tags to be added
//Getting Tag List
$tag_ar = explode(",",$tags);
//Trimming spaces from array list
// Structuring the array of tags to be added.
// Getting Tag List.
$tag_ar = explode(",", $tags);

// Trimming spaces from array list.
$tag_ar = array_filter(array_map('trim', $tag_ar));

$item_id = RetrieveBase::getItemIdFromUrl($client, $page_url);

$tag_info = array(
'item_id' => $item_id,
'tags' => $tag_ar
'tags' => $tag_ar,
);

$pockpack_q = new PockpackQueue();
Expand Down
5 changes: 3 additions & 2 deletions lib/Drupal/fluxpocket/Plugin/Rules/Action/RetrieveBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
abstract class RetrieveBase extends RulesPluginHandlerBase implements \RulesActionHandlerInterface {

/**
* Convert page url to the item id stored in Pocket
* Convert page url to the item id stored in Pocket.
* @param object $client
* Object to connect to Pocket services.
* @param string|null $page_url
Expand All @@ -34,7 +34,8 @@ public function getItemIdFromUrl($client, $page_url = NULL) {
'detailType' => 'simple'
);
$list = $client->retrieve($options);
//Calculate the item_id for the url

// Calculate the item_id for the url.
$id = NULL;
foreach ($list->{'list'} as $index => $elements) {
if ($list->{'list'}->$index->{'given_url'} == $page_url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Duellsy\Pockpack\PockpackQueue;

/**
* Action for Unfavoriting Url
* Action for Unfavoriting Url.
*/
class UnfavoriteUrl extends RetrieveBase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Drupal\fluxpocket\Plugin\Service\PocketAccountInterface;

/**
* Event handler for addition of url to pocket
* Event handler for addition of url to pocket.
*/
class PocketEventEntriesHandler extends PocketEventHandlerBase {

Expand Down Expand Up @@ -43,7 +43,7 @@ public function summary() {
$account = entity_load_single('fluxservice_account', $settings['account']);
if ($settings['account'] && $account) {
return t('A new Entry appears on the Pocket of %account.', array(
'%account' => "{$account->label()}"
'%account' => "{$account->label()}",
));
}
return $this->eventInfo['label'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Drupal\fluxpocket\Plugin\Service\PocketAccountInterface;

/**
* Event handler for updation of url to pocket
* Event handler for updation of url to pocket.
*/
class PocketEventUpdateHandler extends PocketEventHandlerBase {

Expand Down Expand Up @@ -43,7 +43,7 @@ public function summary() {
$account = entity_load_single('fluxservice_account', $settings['account']);
if ($settings['account'] && $account) {
return t('A new Entry updated on the Pocket of %account.', array(
'%account' => "{$account->label()}"
'%account' => "{$account->label()}",
));
}
return $this->eventInfo['label'];
Expand Down
21 changes: 11 additions & 10 deletions lib/Drupal/fluxpocket/Plugin/Service/PocketAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* Contains PocketAccount.
*/


namespace Drupal\fluxpocket\Plugin\Service;

use Drupal\fluxpocket\Tasks\Exception;
Expand Down Expand Up @@ -41,19 +40,20 @@ public function prepareAccount() {
$store = fluxservice_tempstore("fluxservice.account.{$this->bundle()}");
$store->setIfNotExists($this->identifier(), $this);
$plugin = $this->identifier();
//Using API to request token

// Using API to request token.
$pock_auth = new PockpackAuth();
$request_token = $pock_auth->connect($key);
$_SESSION['fluxpocket-api'] = array(
'request_token' => $request_token,
'consumer_key' => $key
'consumer_key' => $key,
);
unset($_GET['destination']);
drupal_goto($path = "https://getpocket.com/auth/authorize?request_token={$request_token}&redirect_uri={$redirect}");
}

/**
* Loads Account for OAuth
* Loads Account for OAuth.
*
* @param string $key Consumer Key of the app
* @param $plugin Plugin for the particular service
Expand All @@ -66,10 +66,10 @@ public static function getAccountForOAuthCallback($key, $plugin) {
/**
* Builds the URL to redirect to after visiting pocket for authentication.
*
*
* @return string
* The URL to redirect to after visiting the pocket OAauth endpoint for
* requesting access privileges from a user.
*
*/
protected function getRedirectUrl() {
return url("fluxservice/oauth/{$this->bundle()}/{$this->identifier()}", array('absolute' => TRUE));
Expand All @@ -82,7 +82,7 @@ public function client() {
$service = $this->getService();
return PocketClient::factory(array(
'client_id' => $service->getConsumerKey(),
'access_token' => $this->getAccessToken()
'access_token' => $this->getAccessToken(),
));
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public function processOAuthCallback() {
$request_token = $_SESSION['fluxpocket-api']['request_token'];
$client = new PockPackAuth();
$data = $client->receiveTokenAndUsername($key, $request_token);
$this->data->set('access_token',$data['access_token']);
$this->data->set('access_token', $data['access_token']);
$_SESSION['fluxpocket-api']['access_token'] = $data['access_token'];
$this->processAuthorizedAccount($data);

Expand All @@ -132,11 +132,12 @@ protected function processAuthorizedAccount(array $response) {
}

/**
* Returns access token after authorization
* Returns access token after authorization.
*
* @return string Access token for the session
* @return string
* Access token for the session
*/
public function getAccessToken(){
public function getAccessToken() {
return $this->data->get('access_token');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Drupal/fluxpocket/Plugin/Service/PocketService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getDefaultSettings() {
}

/**
* Structure of form for the Pocket Service
* Structure of form for the Pocket Service.
*
* @param array $form_state
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Drupal/fluxpocket/PocketEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function loadFromService($ids, ServiceInterface $service, AccountInter
$client = $account->client();
$response = $client->retrieve(array(
'state' => 'all',
'detailType' => 'simple'
'detailType' => 'simple',
));
foreach ($ids as $id) {
$url = $response->{'list'}->$id->{'given_url'};
Expand Down
1 change: 1 addition & 0 deletions lib/Drupal/fluxpocket/PocketEntryEntityQueryDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function prepareExecute(\EntityFieldQuery $query) {
* Make a request.
*
* @return array
* The response received, containing the items in Pocket.
*/
protected function makeRequest() {
$response = $this->getAccount()->client()->retrieve($this->requestParameter);
Expand Down
Loading

0 comments on commit d7d2b5c

Please sign in to comment.