-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
798c223
commit d11e74c
Showing
2 changed files
with
42 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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,81 +1,88 @@ | ||
<?php | ||
|
||
|
||
class qanda extends \rex_yform_manager_dataset | ||
{ | ||
public function getCategory() | ||
{ | ||
return $this->getCategories()[0]; | ||
} | ||
|
||
public function getCategories() | ||
{ | ||
return $this->getRelatedCollection('category_ids'); | ||
} | ||
public function getQuestion($lang = null) :string | ||
|
||
public function getQuestion($lang = null): string | ||
{ | ||
if($lang) { | ||
return $this->getTranslation($lang)->getValue("question"); | ||
if ($lang) { | ||
return $this->getTranslation($lang)->getValue('question'); | ||
} | ||
return $this->getValue("question"); | ||
return $this->getValue('question'); | ||
} | ||
|
||
public static function findByIds(array $ids, float $status = 1) | ||
{ | ||
$ids = implode(",", $ids); | ||
return qanda::query()->whereRaw('status >= '.$status.' AND FIND_IN_SET(id, "'.$ids.'")')->find(); | ||
$ids = implode(',', $ids); | ||
return self::query()->whereRaw('status >= ' . $status . ' AND FIND_IN_SET(id, "' . $ids . '")')->find(); | ||
} | ||
|
||
public static function findByCategoryIds(array $category_ids, float $status = 1) | ||
{ | ||
$ids = implode(',', $category_ids); | ||
return self::query()->whereRAW('status >= ' . $status . ' AND FIND_IN_SET(category_ids, "' . $ids . '")')->find(); | ||
} | ||
public function getAnswer($lang = null) :string | ||
|
||
public function getAnswer($lang = null): string | ||
{ | ||
if($lang) { | ||
return $this->getTranslation($lang)->getValue("answer"); | ||
if ($lang) { | ||
return $this->getTranslation($lang)->getValue('answer'); | ||
} | ||
return $this->getValue("answer"); | ||
return $this->getValue('answer'); | ||
} | ||
public function getAnswerAsPlaintext($lang = null) :string | ||
|
||
public function getAnswerAsPlaintext($lang = null): string | ||
{ | ||
if($lang) { | ||
return strip_tags($this->getTranslation($lang)->getValue("answer")); | ||
if ($lang) { | ||
return strip_tags($this->getTranslation($lang)->getValue('answer')); | ||
} | ||
return strip_tags($this->getValue("answer")); | ||
return strip_tags($this->getValue('answer')); | ||
} | ||
|
||
public function getTranslation($lang = null) :mixed | ||
public function getTranslation($lang = null): mixed | ||
{ | ||
if($lang) { | ||
if ($lang) { | ||
return qanda_lang::getTranslation($this->getId(), $lang); | ||
} | ||
return $this->getRelatedCollection("lang"); | ||
return $this->getRelatedCollection('lang'); | ||
} | ||
public function getAuthor() :string | ||
|
||
public function getAuthor(): string | ||
{ | ||
return $this->getValue("author"); | ||
return $this->getValue('author'); | ||
} | ||
public function getUrl($param = "question-header-") | ||
|
||
public function getUrl($param = 'question-header-') | ||
{ | ||
if (rex_addon::get("yrewrite") && rex_addon::get("yrewrite")->isAvailable()) { | ||
if (rex_addon::get('yrewrite') && rex_addon::get('yrewrite')->isAvailable()) { | ||
$host = rex_yrewrite::getFullUrlByArticleId(rex_article::getCurrentId(), rex_clang::getCurrentId()); | ||
} else { | ||
$host = rtrim(rex::getServer(), '/') . rex_getUrl(rex_article::getCurrentId(), rex_clang::getCurrentId()); | ||
} | ||
|
||
return rtrim($host, '/') . '#' . $param . $this->getId(); | ||
} | ||
|
||
public static function showJsonLd($question) | ||
{ | ||
$fragment = new rex_fragment; | ||
$fragment->setVar("question", $question); | ||
$fragment = new rex_fragment(); | ||
$fragment->setVar('question', $question); | ||
return $fragment->parse('qanda.json-ld.php'); | ||
} | ||
|
||
public static function showFAQPage($questions) | ||
{ | ||
$fragment = new rex_fragment; | ||
$fragment->setVar("questions", $questions); | ||
$fragment = new rex_fragment(); | ||
$fragment->setVar('questions', $questions); | ||
return $fragment->parse('FAQPage.json-ld.php'); | ||
} | ||
} |
This file contains 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