Skip to content
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

Update article.php - Adding new options to article plugin: Alias, Access, Language #1815

Merged
merged 1 commit into from
Mar 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions plugins/fabrik_form/article/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,13 @@ protected function saveArticle($id, $catId)
'state' => '1',
'metadesc' => '',
'metakey' => '',
'tags' => ''
'tags' => '',
'alias' => ''
);

$data['images'] = json_encode($this->images());
$data['language'] = $this->getLang();
$data['access'] = $this->getLevel();

$isNew = is_null($id) ? true : false;

Expand Down Expand Up @@ -506,6 +509,66 @@ protected function setImage($elementId, $size)
return array($file, $placeholder);
}

/**
* Get selected language
*
* @return string
*/
protected function getLang()
{
$params = $this->getParams();
$lang = '*';
$languageElement = $params->get('language_element');

if (empty($languageElement))
{
$language = $params->get('language');
if (!empty($language))
{
$lang = $language;
}
}
else
{
$language = $this->findElementData($languageElement);
if (!empty($language))
{
$lang = $language;
}
}
return $lang;
}

/**
* Get selected access level
*
* @return string
*/
protected function getLevel()
{
$params = $this->getParams();
$levelID = '1';
$levelElement = $params->get('level_element');

if (empty($levelElement))
{
$level = $params->get('level');
if (!empty($level))
{
$levelID = $level;
}
}
else
{
$level = $this->findElementData($levelElement);
if (!empty($level))
{
$levelID = $level;
}
}
return $levelID;
}

/**
* Method to change the title & alias.
*
Expand All @@ -518,7 +581,9 @@ protected function setImage($elementId, $size)
protected function generateNewTitle($id, $catId, &$data)
{
$table = JTable::getInstance('Content');
$alias = JApplication::stringURLSafe(JStringNormalise::toDashSeparated($data['title']));
$alias = empty($data['alias']) ? $data['title'] : $data['alias'];
$alias = JApplication::stringURLSafe(JStringNormalise::toDashSeparated( $alias ));

$data['alias'] = $alias;
$title = $data['title'];
$titles = array();
Expand Down