Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
4b030206
Commit
4b030206
authored
11 years ago
by
totten
Browse files
Options
Downloads
Patches
Plain Diff
CRM_Dashlet_Page_Blog - Get feed URL from settings
parent
d33e9a42
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Dashlet/Page/Blog.php
+18
-3
18 additions, 3 deletions
CRM/Dashlet/Page/Blog.php
settings/Core.setting.php
+22
-0
22 additions, 0 deletions
settings/Core.setting.php
with
40 additions
and
3 deletions
CRM/Dashlet/Page/Blog.php
+
18
−
3
View file @
4b030206
...
...
@@ -42,6 +42,21 @@ class CRM_Dashlet_Page_Blog extends CRM_Core_Page {
const
CACHE_DAYS
=
1
;
const
BLOG_URL
=
'https://civicrm.org/blog/feed'
;
/**
* Get the final, usable URL string (after interpolating any variables)
*
* @return FALSE|string
*/
public
function
getBlogUrl
()
{
// Note: We use "*default*" as the default (rather than self::BLOG_URL) so that future
// developers can change BLOG_URL without needing to update {civicrm_setting}.
$url
=
CRM_Core_BAO_Setting
::
getItem
(
CRM_Core_BAO_Setting
::
SYSTEM_PREFERENCES_NAME
,
'blogUrl'
,
NULL
,
'*default*'
);
if
(
$url
===
'*default*'
)
{
$url
=
self
::
BLOG_URL
;
}
return
CRM_Utils_System
::
evalUrl
(
$url
);
}
/**
* List blog articles as dashlet
*
...
...
@@ -72,7 +87,7 @@ class CRM_Dashlet_Page_Blog extends CRM_Core_Page {
$expire
=
time
()
-
(
60
*
60
*
24
*
self
::
CACHE_DAYS
);
// Refresh data after CACHE_DAYS
if
(
strtotime
(
$cache
->
created_date
)
<
$expire
)
{
$new_data
=
$this
->
_getFeed
();
$new_data
=
$this
->
_getFeed
(
$this
->
getBlogUrl
()
);
// If fetching the new rss feed was successful, return it
// Otherwise use the old cached data - it's better than nothing
if
(
$new_data
)
{
...
...
@@ -81,7 +96,7 @@ class CRM_Dashlet_Page_Blog extends CRM_Core_Page {
}
return
unserialize
(
$cache
->
data
);
}
return
$this
->
_getFeed
();
return
$this
->
_getFeed
(
$this
->
getBlogUrl
()
);
}
/**
...
...
@@ -91,7 +106,7 @@ class CRM_Dashlet_Page_Blog extends CRM_Core_Page {
*
* @access public
*/
public
function
_getFeed
(
$url
=
self
::
BLOG_URL
)
{
public
function
_getFeed
(
$url
)
{
$httpClient
=
new
CRM_Utils_HttpClient
(
self
::
CHECK_TIMEOUT
);
list
(
$status
,
$rawFeed
)
=
$httpClient
->
get
(
$url
);
if
(
$status
!==
CRM_Utils_HttpClient
::
STATUS_OK
)
{
...
...
This diff is collapsed.
Click to expand it.
settings/Core.setting.php
+
22
−
0
View file @
4b030206
...
...
@@ -516,6 +516,28 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl
'description'
=>
null
,
'help_text'
=>
null
,
),
'blogUrl'
=>
array
(
'group_name'
=>
'CiviCRM Preferences'
,
'group'
=>
'core'
,
'name'
=>
'blogUrl'
,
'prefetch'
=>
0
,
'config_only'
=>
0
,
'type'
=>
'String'
,
'quick_form_type'
=>
'Element'
,
'html_type'
=>
'text'
,
'html_attributes'
=>
array
(
'size'
=>
64
,
'maxlength'
=>
128
,
),
'html_type'
=>
'Text'
,
'default'
=>
'*default*'
,
'add'
=>
'4.3'
,
'title'
=>
'Blog Feed URL'
,
'is_domain'
=>
1
,
'is_contact'
=>
0
,
'description'
=>
'Blog feed URL used by the blog dashlet'
,
'help_text'
=>
'Use "*default*" for the system default or override with a custom URL'
,
),
'communityMessagesUrl'
=>
array
(
'group_name'
=>
'CiviCRM Preferences'
,
'group'
=>
'core'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment