/** * Create html link elements that we can use in the form * * @param CRM_Core_Form $form the form object * @param int $index the current index of the element being processed * @param int $maxIndex the max number of elements that will be processed * @param string $prefix the attribute that we are referencing * @param string $showLinkText the text to be shown for the show link * @param string $hideLinkText the text to be shown for the hide link * @param string $elementType the set the class * @param string $hideLink the hide block string * * @return void * @access public */ function linksForArray(&$form, $index, $maxIndex, $prefix, $showLinkText, $hideLinkText, $elementType = null, $hideLink = null) { if ($index == $maxIndex) { $showCode = $hideCode = "return false;"; } else { $next = $index + 1; if ($elementType) { $showCode = "show('{$prefix}[{$next}][show]','table-row'); return false;"; if ($hideLink) { $hideCode = $hideLink; } else { $hideCode = "hide('{$prefix}[{$next}][show]','table-row'); hide('{$prefix}[{$next}]'); return false;"; } } else { $showCode = "show('{$prefix}[{$next}][show]'); return false;"; $hideCode = "hide('{$prefix}[{$next}][show]'); hide('{$prefix}[{$next}]'); return false;"; } } CRM_Core_ShowHideBlocks::setIcons(); if ($elementType) { $form->addElement('link', "{$prefix}[{$index}][show]", null, "#{$prefix}[{$index}]", $GLOBALS['_CRM_CORE_SHOWHIDEBLOCKS']['_showIcon'] . $showLinkText, array('onclick' => "hide('{$prefix}[{$index}][show]'); show('{$prefix}[{$index}]','table-row');" . $showCode)); $form->addElement('link', "{$prefix}[{$index}][hide]", null, "#{$prefix}[{$index}]", $GLOBALS['_CRM_CORE_SHOWHIDEBLOCKS']['_hideIcon'] . $hideLinkText, array('onclick' => "hide('{$prefix}[{$index}]'); show('{$prefix}[{$index}][show]');" . $hideCode)); } else { $form->addElement('link', "{$prefix}[{$index}][show]", null, "#{$prefix}[{$index}]", $GLOBALS['_CRM_CORE_SHOWHIDEBLOCKS']['_showIcon'] . $showLinkText, array('onclick' => "hide('{$prefix}[{$index}][show]'); show('{$prefix}[{$index}]');" . $showCode)); $form->addElement('link', "{$prefix}[{$index}][hide]", null, "#{$prefix}[{$index}]", $GLOBALS['_CRM_CORE_SHOWHIDEBLOCKS']['_hideIcon'] . $hideLinkText, array('onclick' => "hide('{$prefix}[{$index}]'); show('{$prefix}[{$index}][show]');" . $hideCode)); } }