-
Notifications
You must be signed in to change notification settings - Fork 8
Fixed an issue from PR #93 #100
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
Open
BR0kEN-
wants to merge
9
commits into
drupal-ukraine:master
Choose a base branch
from
BR0kEN-:issue-93
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
21c9acc
Added PPGetStatHTML class
BR0kEN- 07528e3
Added PPGetStatHTML class
BR0kEN- 0ebfc8e
Managed constants, added functions: ppgetstat_stats_period(), ppgetst…
BR0kEN- 10c5114
Fixed comment and GH username scanning
BR0kEN- 23e5f7a
Fixed comment scanning
BR0kEN- f006df3
Merge origin/master into BR0kEN-/issue-93
BR0kEN- 1682b8d
Merge origin/master into BR0kEN-/issue-93 (#2)
BR0kEN- e1abfc5
Fixed an issue with division by zero
BR0kEN- 6ce10cb
Merge with upstream
BR0kEN- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 13 additions & 16 deletions
29
docroot/sites/all/modules/custom/pp_frontpage/plugins/content_types/members_by_country.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,37 @@ | ||
| <?php | ||
| /** | ||
| * @file | ||
| * Individual members by country. | ||
| */ | ||
|
|
||
| $plugin = array( | ||
| 'title' => t('Association individual memebers by country stat'), | ||
| 'title' => t('Association individual members by country'), | ||
| 'single' => TRUE, | ||
| 'category' => t('PP'), | ||
| ); | ||
|
|
||
| /** | ||
| * Render global individual members statistics. | ||
| */ | ||
| function pp_frontpage_members_by_country_content_type_render($subtype, $conf, $panel_args, $context) { | ||
| function pp_frontpage_members_by_country_content_type_render() { | ||
| $block = new stdClass(); | ||
| $block->module = 'pp_frontpage'; | ||
| $block->title = t('Drupal Association individual members by country statistics'); | ||
|
|
||
| // Getting info for showing count of individual members at this country. | ||
| $members_stat = _ppgetstat_get_individual_members(); | ||
| $i = 1; $rows = array(); | ||
| $rows = array(); | ||
| $i = 1; | ||
|
|
||
| foreach ($members_stat['members_country_count'] as $country => $count) { | ||
| $rows[] = array( | ||
| $i, | ||
| $country, | ||
| $count | ||
| ); | ||
| $i++; | ||
| $rows[] = array($i++, $country, $count); | ||
| } | ||
|
|
||
| $block->content = array( | ||
| '#theme' => 'table', | ||
| '#header' => array( | ||
| t('Position'), | ||
| t('Country'), | ||
| t('Count of members') | ||
| ), | ||
| '#rows' => $rows | ||
| '#header' => array(t('Position'), t('Country'), t('Count of members')), | ||
| '#rows' => $rows, | ||
| ); | ||
|
|
||
| return $block; | ||
| } | ||
| } |
115 changes: 115 additions & 0 deletions
115
docroot/sites/all/modules/custom/ppgetstat/includes/ppgetstat.api.inc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| <?php | ||
| /** | ||
| * @file | ||
| * API requests. | ||
| */ | ||
|
|
||
| /** | ||
| * Class APICall. | ||
| */ | ||
| class APICall { | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| private $url = ''; | ||
| /** | ||
| * @var array | ||
| */ | ||
| private $query = array(); | ||
| /** | ||
| * @var stdClass | ||
| */ | ||
| private $result; | ||
|
|
||
| /** | ||
| * APICall constructor. | ||
| * | ||
| * @param string $base | ||
| * An URL with API. | ||
| */ | ||
| public function __construct($base = 'https://www.drupal.org') { | ||
| $this->url = rtrim($base, '/'); | ||
| } | ||
|
|
||
| /** | ||
| * Specify resource of the API. | ||
| * | ||
| * @param string $resource | ||
| * API resource. | ||
| * | ||
| * @return $this | ||
| * APICall instance. | ||
| */ | ||
| public function resource($resource) { | ||
| $this->url .= "/$resource"; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Configure query. | ||
| * | ||
| * @param array $variables | ||
| * Query parameters. | ||
| * | ||
| * @return $this | ||
| * APICall instance. | ||
| */ | ||
| public function query(array $variables) { | ||
| $this->query = array_merge($this->query, $variables); | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Get a page of results. | ||
| * | ||
| * @param int $page | ||
| * Page number. | ||
| * | ||
| * @return $this | ||
| * APICall instance. | ||
| */ | ||
| public function page($page = 0) { | ||
| if ($page > 0) { | ||
| $this->query['page'] = $page; | ||
| } | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Perform a request to an API. | ||
| * | ||
| * @param array $options | ||
| * Additional options for drupal_http_request(). | ||
| * | ||
| * @return stdClass|bool | ||
| * Query result or FALSE. | ||
| */ | ||
| public function execute($options = array()) { | ||
| if (!empty($this->query)) { | ||
| $this->url .= '?' . http_build_query($this->query); | ||
| } | ||
|
|
||
| $this->result = drupal_http_request($this->url, array_merge(array('timeout' => 3000), $options)); | ||
|
|
||
| return 200 == $this->result->code ? json_decode($this->result->data) : FALSE; | ||
| } | ||
|
|
||
| /** | ||
| * Get waw results of a query. | ||
| * | ||
| * @return stdClass | ||
| * Query result. | ||
| */ | ||
| public function getRawResult() { | ||
| if (empty($this->result)) { | ||
| throw new \RuntimeException('You must call the "execute" method firstly.'); | ||
| } | ||
|
|
||
| return $this->result; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevented division by zero (when no users in DB).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx.