-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[HelloAssoBridge] Create bridge #4558
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
class HelloAssoBridge extends BridgeAbstract | ||
{ | ||
const NAME = 'HelloAsso'; | ||
const URI = 'https://www.helloasso.com'; | ||
const DESCRIPTION = 'Generates feed of fundraising forms listed on a given HelloAsso organization page'; | ||
const MAINTAINER = 'No maintainer'; | ||
|
||
const PARAMETERS = [[ | ||
'slug' => [ | ||
'name' => 'Organization slug', | ||
'type' => 'text', | ||
'required' => true, | ||
'title' => 'Insert Organization short name (found in the URL)', | ||
'exampleValue' => 'ligue-contre-le-cancer-comite-essonne' | ||
] | ||
]]; | ||
|
||
private $orgname; | ||
|
||
public function getURI() | ||
{ | ||
$slug = $this->getInput('slug') ?: ''; | ||
return static::URI . '/associations/' . $slug; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->orgname ? $this->orgname . ' - ' . static::NAME : static::NAME; | ||
} | ||
|
||
public function getDescription() | ||
{ | ||
if (!is_null($this->getInput('search'))) { | ||
return 'Latest torrents for "' . $this->getInput('search') . '"'; | ||
|
||
} | ||
return parent::getDescription(); | ||
} | ||
|
||
public function collectData() | ||
{ | ||
$html = getSimpleHTMLDOM($this->getURI()); | ||
$html = defaultLinkTo($html, $this->getURI()); | ||
|
||
$orgname = $html->find('[class~="Intro--Name"]', 0) | ||
or returnServerError('Could not find org name!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function has been renamed |
||
$this->orgname = $orgname->plaintext; | ||
|
||
foreach ($html->find('ul[class~="ActionList"] li') as $element) { | ||
$uri = $element->find('.ActionWrapper a', 0) | ||
or returnServerError('Could not find action uri!'); | ||
|
||
$title = $element->find('.ActionContent--Text h3', 0); | ||
|
||
$date = $element->find('[class~="Number-Date"]', 0); | ||
$address = $element->find('[class~="Data-AddressName"]', 0); | ||
|
||
$item = []; | ||
$item['uri'] = $uri->href; | ||
$item['title'] = $title->plaintext ?? ''; | ||
$item['content'] = ($date->plaintext ?? '') | ||
. ('<br>' . $address->plaintext ?? ''); | ||
|
||
$this->items[] = $item; | ||
} | ||
} | ||
} |
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.
New code files MUST have
declare(strict_types=1);
at the top of file