[InstructablesBridge] Fix after layout changes
This commit is contained in:
parent
d324aa5da1
commit
60c1339612
1 changed files with 38 additions and 33 deletions
|
@ -215,7 +215,7 @@ class InstructablesBridge extends BridgeAbstract {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'title' => 'Select your category (required)',
|
'title' => 'Select your category (required)',
|
||||||
'defaultValue' => 'Technology'
|
'defaultValue' => 'Circuits'
|
||||||
),
|
),
|
||||||
'filter' => array(
|
'filter' => array(
|
||||||
'name' => 'Filter',
|
'name' => 'Filter',
|
||||||
|
@ -233,65 +233,70 @@ class InstructablesBridge extends BridgeAbstract {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
private $uri;
|
|
||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
// Enable the following line to get the category list (dev mode)
|
// Enable the following line to get the category list (dev mode)
|
||||||
// $this->listCategories();
|
// $this->listCategories();
|
||||||
|
|
||||||
$this->uri = static::URI;
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
|
or returnServerError('Error loading category ' . $this->getURI());
|
||||||
|
$html = defaultLinkTo($html, $this->getURI());
|
||||||
|
|
||||||
switch($this->queriedContext) {
|
$covers = $html->find('
|
||||||
case 'Category': $this->uri .= $this->getInput('category') . $this->getInput('filter');
|
.category-projects-list > div,
|
||||||
}
|
.category-landing-projects-list > div,
|
||||||
|
');
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($this->uri)
|
foreach($covers as $cover) {
|
||||||
or returnServerError('Error loading category ' . $this->uri);
|
|
||||||
|
|
||||||
foreach($html->find('ul.explore-covers-list li') as $cover) {
|
|
||||||
$item = array();
|
$item = array();
|
||||||
|
|
||||||
$item['uri'] = static::URI . $cover->find('a.cover-image', 0)->href;
|
$item['uri'] = $cover->find('a.ible-title', 0)->href;
|
||||||
$item['title'] = $cover->find('.title', 0)->innertext;
|
$item['title'] = $cover->find('a.ible-title', 0)->innertext;
|
||||||
$item['author'] = $this->getCategoryAuthor($cover);
|
$item['author'] = $this->getCategoryAuthor($cover);
|
||||||
$item['content'] = '<a href='
|
$item['content'] = '<a href='
|
||||||
. $item['uri']
|
. $item['uri']
|
||||||
. '><img src='
|
. '><img src='
|
||||||
. $cover->find('a.cover-image img', 0)->src
|
. $cover->find('img', 0)->getAttribute('data-src')
|
||||||
. '></a>';
|
. '></a>';
|
||||||
|
|
||||||
$image = str_replace('.RECTANGLE1', '.LARGE', $cover->find('a.cover-image img', 0)->src);
|
$item['enclosures'][] = str_replace(
|
||||||
$item['enclosures'] = [$image];
|
'.RECTANGLE1',
|
||||||
|
'.LARGE',
|
||||||
|
$cover->find('img', 0)->getAttribute('data-src')
|
||||||
|
);
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
if(!is_null($this->getInput('category'))
|
switch($this->queriedContext) {
|
||||||
&& !is_null($this->getInput('filter'))) {
|
case 'Category': {
|
||||||
foreach(self::PARAMETERS[$this->queriedContext]['category']['values'] as $key => $value) {
|
foreach(self::PARAMETERS[$this->queriedContext]['category']['values'] as $key => $value) {
|
||||||
$subcategory = array_search($this->getInput('category'), $value);
|
$subcategory = array_search($this->getInput('category'), $value);
|
||||||
|
|
||||||
if($subcategory !== false)
|
if($subcategory !== false)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$filter = array_search(
|
$filter = array_search(
|
||||||
$this->getInput('filter'),
|
$this->getInput('filter'),
|
||||||
self::PARAMETERS[$this->queriedContext]['filter']['values']
|
self::PARAMETERS[$this->queriedContext]['filter']['values']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $subcategory . ' (' . $filter . ') - ' . static::NAME;
|
return $subcategory . ' (' . $filter . ') - ' . static::NAME;
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI() {
|
public function getURI() {
|
||||||
if(!is_null($this->getInput('category'))
|
switch($this->queriedContext) {
|
||||||
&& !is_null($this->getInput('filter'))) {
|
case 'Category': {
|
||||||
return $this->uri;
|
return self::URI
|
||||||
|
. $this->getInput('category')
|
||||||
|
. $this->getInput('filter');
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
|
@ -349,9 +354,9 @@ class InstructablesBridge extends BridgeAbstract {
|
||||||
*/
|
*/
|
||||||
private function getCategoryAuthor($cover) {
|
private function getCategoryAuthor($cover) {
|
||||||
return '<a href='
|
return '<a href='
|
||||||
. static::URI . $cover->find('span.author a', 0)->href
|
. $cover->find('.ible-author a', 0)->href
|
||||||
. '>'
|
. '>'
|
||||||
. $cover->find('span.author a', 0)->innertext
|
. $cover->find('.ible-author a', 0)->innertext
|
||||||
. '</a>';
|
. '</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue