Skip to content

Commit

Permalink
#14 formatted as the function doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pratiksid007 committed Apr 8, 2016
1 parent aaf6c78 commit eaa709b
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions administrator/components/com_fields/helpers/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ public static function getFields ($context, $item = null, $prepareValue = false)
$item = (object) $item;
}

// If item has assigned_cat_ids parameter display only fields which
// belong to the category
/*
*If item has assigned_cat_ids parameter display only fields which
* belong to the category
*/
if ($item && (isset($item->catid) || isset($item->fieldscatid)))
{
$assignedCatIds = isset($item->catid) ? $item->catid : $item->fieldscatid;
Expand All @@ -147,8 +149,10 @@ public static function getFields ($context, $item = null, $prepareValue = false)

foreach ($fields as $key => $original)
{
// Doing a clone, otherwise fields for different items will
// always reference to the same object
/*
* Doing a clone, otherwise fields for different items will
* always reference to the same object
*/
$field = clone $original;
$field->value = self::$fieldCache->getFieldValue($field->id, $field->context, $item->id);

Expand Down Expand Up @@ -293,15 +297,19 @@ public static function prepareForm ($context, JForm $form, $data)
}
}

// If there is a catid field we need to reload the page when the catid
// is changed
/*
* If there is a catid field we need to reload the page when the catid
* is changed
*/
if ($form->getField('catid') && $parts[0] != 'com_fields')
{
// The uri to submit to
$uri = clone JUri::getInstance('index.php');

// Removing the catid parameter from the actual url and set it as
// return
/*
* Removing the catid parameter from the actual url and set it as
* return
*/
$returnUri = clone JUri::getInstance();
$returnUri->setVar('catid', null);
$uri->setVar('return', base64_encode($returnUri->toString()));
Expand All @@ -314,8 +322,10 @@ public static function prepareForm ($context, JForm $form, $data)
$uri->setVar('view', null);
$uri->setVar('layout', null);

// Setting the onchange event to reload the page when the category
// has changed
/*
* Setting the onchange event to reload the page when the category
* has changed
*/
$form->setFieldAttribute('catid', 'onchange', "categoryHasChanged(this);");
JFactory::getDocument()->addScriptDeclaration(
"function categoryHasChanged(element){
Expand Down Expand Up @@ -381,8 +391,10 @@ public static function prepareForm ($context, JForm $form, $data)

if ($catid > 0)
{
// JCategories can't handle com_content with a section, going
// directly to the table
/*
* JCategories can't handle com_content with a section, going
* directly to the table
*/
$category = JTable::getInstance('Category');
$category->load($catid);

Expand Down

0 comments on commit eaa709b

Please sign in to comment.