API16

JHtmlRules/assetFormWidget

From Joomla! Documentation

< API16:JHtmlRules
Revision as of 21:58, 13 May 2013 by JoomlaWikiBot (talk | contribs) (removing red link to edit, no existant pages)

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Displays a list of the available access sections

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

static assetFormWidget($actions, $assetId=null, $parent=null, $control= 'jform[rules]', $idPrefix= 'jform_rules')
Parameter Name Default Value Description
$actions The form field name.
$assetId null The name of the selected section.
$parent null Additional attributes to add to the select field.
$control 'jform[rules]' True to add "All Sections" option.
$idPrefix 'jform_rules'

Returns[edit]

string The required HTML for the SELECT tag.

Defined in[edit]

libraries/joomla/html/html/rules.php

Importing[edit]

jimport( 'joomla.html.html.rules' );

Source Body[edit]

public static function assetFormWidget($actions, $assetId = null, $parent = null, $control = 'jform[rules]', $idPrefix = 'jform_rules')
{
        // Load the behavior.
        self::_loadBehavior();

        // Load the behavior.
        $images = self::_getImagesArray();

        // Get the user groups.
        $groups = self::_getUserGroups();

        // Get the incoming inherited rules as well as the asset specific rules.
        $inheriting = JAccess::getAssetRules($parent ? $parent : self::_getParentAssetId($assetId), true);
        $inherited = JAccess::getAssetRules($assetId, true);
        $rules = JAccess::getAssetRules($assetId);


        $html = array();

        $html[] = '<div class="acl-options">';
        $html[] = '     <dl class="tabs">';
        $html[] = '             <dt><a href="#">'.JText::_('CONTENT_ACCESS_SUMMARY').'</a></dt>';
        $html[] = '             <dd>';
        $html[] = '                     <p>'.JText::_('CONTENT_ACCESS_SUMMARY_DESC').'</p>';
        $html[] = '                     <table class="aclsummary-table" summary="'.JText::_('CONTENT_ACCESS_SUMMARY_DESC').'">';
        $html[] = '                     <caption>'.JText::_('CONTENT_ACCESS_SUMMARY_DESC_CAPTION').'</caption>';
        $html[] = '                     <tr>';
        $html[] = '                             <th class="col1 hidelabeltxt">'.JText::_('JGROUPS').'</th>';
        foreach ($actions as $i => $action)
        {
                $html[] = '                             <th class="col'.($i+2).'">'.JText::_($action->title).'</th>';
        }
        $html[] = '                     </tr>';

        foreach ($groups as $i => $group)
        {
                $html[] = '                     <tr class="row'.($i%2).'">';
                $html[] = '                             <td class="col1">'.$group->text.'</td>';
                foreach ($actions as $i => $action)
                {
                        $html[] = '                             <td class="col'.($i+2).'">'.($assetId ? ($inherited->allow($action->name, $group->identities) ? $images['allow'] : $images['deny']) : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])).'</td>';
                }
                $html[] = '                     </tr>';
        }

        $html[] = '             </table>';
        $html[] = '     </dd>';

        foreach ($actions as $action)
        {
                $html[] = '             <dt><a href="#">'.JText::_($action->title).'</a></dt>';
                $html[] = '             <dd>';
                $html[] = '                     <p>'.JText::_($action->description).'</p>';
                $html[] = '                     <table class="aclmodify-table" summary="'.JText::_($action->description).'">';
                $html[] = '                     <caption>'.JText::_('CONTENT_ACCESS_MODIFY_DESC_CAPTION_ACL').' '.JText::_($action->title).' '.JText::_('CONTENT_ACCESS_MODIFY_DESC_CAPTION_TABLE').'</caption>';
                $html[] = '                     <tr>';
                $html[] = '                             <th class="col1 hidelabeltxt">'.JText::_('JGROUPS').'</th>';
                $html[] = '                             <th class="col2">'.JText::_('JINHERIT').'</th>';
                $html[] = '                             <th class="col3 hidelabeltxt">'.JText::_('JMODIFY').'</th>';
                $html[] = '                             <th class="col4">'.JText::_('JCURRENT').'</th>';
                $html[] = '                     </tr>';

                foreach ($groups as $i => $group)
                {
                        $selected = $rules->allow($action->name, $group->value);

                        $html[] = '                     <tr class="row'.($i%2).'">';
                        $html[] = '                             <td class="col1">'.$group->text.'</td>';
                        $html[] = '                             <td class="col2">'.($inheriting->allow($action->name, $group->identities) ? $images['allow-i'] : $images['deny-i']).'</td>';
                        $html[] = '                             <td class="col3">';
                        $html[] = '                                     <select id="'.$idPrefix.'_'.$action->name.'_'.$group->value.'" class="inputbox" size="1" name="'.$control.'['.$action->name.']['.$group->value.']" title="'.JText::_('JMODIFY')." ".$group->text.'">';
                        $html[] = '                                             <option value=""'.($selected === null ? ' selected="selected"' : '').'>'.JText::_('JINHERIT').'</option>';
                        $html[] = '                                             <option value="1"'.($selected === true ? ' selected="selected"' : '').'>'.JText::_('JALLOW').'</option>';
                        $html[] = '                                             <option value="0"'.($selected === false ? ' selected="selected"' : '').'>'.JText::_('JDENY').'</option>';
                        $html[] = '                                     </select>';
                        $html[] = '                             </td>';
                        $html[] = '                             <td class="col4">'.($assetId ? ($inherited->allow($action->name, $group->identities) ? $images['allow'] : $images['deny']) : ($inheriting->allow($action->name, $group->identities) ? $images['allow'] : $images['deny'])).'</td>';
                        $html[] = '                     </tr>';
                }

                $html[] = '             </table>';
                $html[] = '     </dd>';
        }

        $html[] = ' </dl>';

        // Build the footer with legend and special purpose buttons.
        $html[] = '     <div class="clr"></div>';
        $html[] = '     <ul class="acllegend fltlft">';
        $html[] = '             <li class="acl-allowed">'.JText::_('JALLOWED').'</li>';
        $html[] = '             <li class="acl-denied">'.JText::_('JDENIED').'</li>';
        $html[] = '     </ul>';
        $html[] = '     <ul class="acllegend fltrt">';
        $html[] = '             <li class="acl-editgroups"><a href="#">'.JText::_('CONTENT_ACCESS_EDIT_GROUPS').'</a></li>';
        $html[] = '             <li class="acl-resetbtn"><a href="#">'.JText::_('CONTENT_ACCESS_RESET_TO_INHERIT').'</a></li>';
        $html[] = '     </ul>';
        $html[] = '</div>';

        return implode("\n", $html);
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

<CodeExamplesForm />