当前位置: 首页>>代码示例>>PHP>>正文


PHP attribute函数代码示例

本文整理汇总了PHP中attribute函数的典型用法代码示例。如果您正苦于以下问题:PHP attribute函数的具体用法?PHP attribute怎么用?PHP attribute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了attribute函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: attributes

/**
 * Outputs a list of HTML attributes and values
 *
 * @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
 *       The values will be escaped with {@link s()}
 * @return string HTML fragment
 */
function attributes(array $attributes = null)
{
    $attributes = (array) $attributes;
    $output = '';
    foreach ($attributes as $name => $value) {
        $output .= attribute($name, $value);
    }
    return $output;
}
开发者ID:Raxine,项目名称:lightning,代码行数:16,代码来源:print.php

示例2: userAnchor

 /**
  * Take a user object, and writes out an anchor of the user's name to the user's profile.
  */
 function userAnchor($User, $CssClass = null, $Options = null)
 {
     static $NameUnique = null;
     if ($NameUnique === null) {
         $NameUnique = c('Garden.Registration.NameUnique');
     }
     if (is_array($CssClass)) {
         $Options = $CssClass;
         $CssClass = null;
     } elseif (is_string($Options)) {
         $Options = array('Px' => $Options);
     }
     $Px = val('Px', $Options, '');
     $Name = val($Px . 'Name', $User, t('Unknown'));
     //        $UserID = GetValue($Px.'UserID', $User, 0);
     $Text = val('Text', $Options, htmlspecialchars($Name));
     // Allow anchor text to be overridden.
     $Attributes = array('class' => $CssClass, 'rel' => val('Rel', $Options));
     if (isset($Options['title'])) {
         $Attributes['title'] = $Options['title'];
     }
     $UserUrl = userUrl($User, $Px);
     return '<a href="' . htmlspecialchars(url($UserUrl)) . '"' . attribute($Attributes) . '>' . $Text . '</a>';
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:27,代码来源:functions.render.php

示例3: input

    /**
     * Returns the xhtml for a standard input tag.
     *
     * @param string $FieldName The name of the field that is being displayed/posted with this input. It
     *  should related directly to a field name in $this->_DataArray.
     * @param string $Type The type attribute for the input.
     * @param array $Attributes An associative array of attributes for the input. (e.g. maxlength, onclick, class)
     *    Setting 'InlineErrors' to FALSE prevents error message even if $this->InlineErrors is enabled.
     * @return string
     */
    public function input($FieldName, $Type = 'text', $Attributes = false)
    {
        if ($Type == 'text' || $Type == 'password') {
            $CssClass = arrayValueI('class', $Attributes);
            if ($CssClass == false) {
                $Attributes['class'] = 'InputBox';
            }
        }
        // Show inline errors?
        $ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
        // Add error class to input element
        if ($ShowErrors) {
            $this->addErrorClass($Attributes);
        }
        $Return = '';
        $Wrap = val('Wrap', $Attributes, false, true);
        $Strength = val('Strength', $Attributes, false, true);
        if ($Wrap) {
            $Return .= '<div class="TextBoxWrapper">';
        }
        if (strtolower($Type) == 'checkbox') {
            if (isset($Attributes['nohidden'])) {
                unset($Attributes['nohidden']);
            } else {
                $Return .= '<input type="hidden" name="Checkboxes[]" value="' . (substr($FieldName, -2) === '[]' ? substr($FieldName, 0, -2) : $FieldName) . '" />';
            }
        }
        $Return .= '<input type="' . $Type . '"';
        $Return .= $this->_idAttribute($FieldName, $Attributes);
        if ($Type == 'file') {
            $Return .= attribute('name', arrayValueI('Name', $Attributes, $FieldName));
        } else {
            $Return .= $this->_nameAttribute($FieldName, $Attributes);
        }
        if ($Strength) {
            $Return .= ' data-strength="true"';
        }
        $Return .= $this->_valueAttribute($FieldName, $Attributes);
        $Return .= $this->_attributesToString($Attributes);
        $Return .= ' />';
        // Append validation error message
        if ($ShowErrors && arrayValueI('InlineErrors', $Attributes, true)) {
            $Return .= $this->inlineError($FieldName);
        }
        if ($Type == 'password' && $Strength) {
            $Return .= <<<PASSWORDMETER
<div class="PasswordStrength">
   <div class="Background"></div>
   <div class="Strength"></div>
   <div class="Separator" style="left: 20%;"></div>
   <div class="Separator" style="left: 40%;"></div>
   <div class="Separator" style="left: 60%;"></div>
   <div class="Separator" style="left: 80%;"></div>
   <div class="StrengthText">&nbsp;</div>
</div>
PASSWORDMETER;
        }
        if ($Wrap) {
            $Return .= '</div>';
        }
        return $Return;
    }
开发者ID:bryanjamesmiller,项目名称:vanilla,代码行数:72,代码来源:class.form.php

示例4: implode

        <?php 
if ($this->getMeta()) {
    ?>
            <div class="info">
                <?php 
    echo implode('<span class="spacer">|</span>', $this->getMeta());
    ?>
            </div>
        <?php 
}
?>
        <?php 
foreach ($this->getButtons() as $button) {
    ?>
            <a <?php 
    echo attribute(val('attributes', $button));
    ?>
 href="<?php 
    echo val('url', $button);
    ?>
">
                <?php 
    echo val('text', $button);
    ?>
            </a>
        <?php 
}
?>
    </div>
</div>
开发者ID:vanilla,项目名称:vanilla,代码行数:30,代码来源:media-sm.php

示例5: renderGroup

 /**
  *
  *
  * @param $key
  * @param $group
  * @param int $level
  */
 protected function renderGroup($key, $group, $level = 0)
 {
     $text = $group['text'];
     $group['class'] = 'nav-group ' . ($text ? '' : 'nav-group-noheading ') . $this->getCssClass($key, $group);
     $items = $group['items'];
     unset($group['text'], $group['items']);
     // Don't render an empty group.
     if (empty($items)) {
         return;
     }
     echo '<div ' . attribute($group) . ">\n";
     // Write the heading.
     if ($text) {
         echo "<h3>{$text}</h3>\n";
     }
     // Write the group items.
     $this->renderItems($items, $level + 1);
     echo "</div>\n";
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:26,代码来源:class.navmodule.php

示例6: gdn_form_captcha_handler

 /**
  * Display reCAPTCHA entry field.
  *
  * THIS METHOD ECHOS DATA
  *
  * @param Gdn_Form $sender
  * @return string
  */
 public function gdn_form_captcha_handler($sender)
 {
     if (!$this->getPrivateKey() || !$this->getPublicKey()) {
         echo '<div class="Warning">' . t('reCAPTCHA has not been set up by the site administrator in registration settings. This is required to register.') . '</div>';
     }
     // Google whitelist https://developers.google.com/recaptcha/docs/language
     $whitelist = ['ar', 'bg', 'ca', 'zh-CN', 'zh-TW', 'hr', 'cs', 'da', 'nl', 'en-GB', 'en', 'fil', 'fi', 'fr', 'fr-CA', 'de', 'de-AT', 'de-CH', 'el', 'iw', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'lv', 'lt', 'no', 'fa', 'pl', 'pt', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sr', 'sk', 'sl', 'es', 'es-419', 'sv', 'th', 'tr', 'uk', 'vi'];
     // Use our current locale against the whitelist.
     $language = Gdn::locale()->language();
     if (!in_array($language, $whitelist)) {
         $language = in_array(Gdn::locale()->Locale, $whitelist) ? Gdn::locale()->Locale : false;
     }
     Gdn::controller()->Head->addScript('https://www.google.com/recaptcha/api.js?hl=' . $language);
     $attributes = array('class' => 'g-recaptcha', 'data-sitekey' => $this->getPublicKey(), 'data-theme' => c('Recaptcha.Theme', 'light'));
     // see https://developers.google.com/recaptcha/docs/display for details
     $this->EventArguments['Attributes'] =& $attributes;
     $this->fireEvent('BeforeCaptcha');
     echo '<div ' . attribute($attributes) . '></div>';
 }
开发者ID:R-J,项目名称:vanilla,代码行数:27,代码来源:class.recaptcha.plugin.php

示例7: radioList

 /**
  * Returns XHTML for an unordered list of radio button elements.
  *
  * @param string $FieldName The name of the field that is being displayed/posted with this input.
  *    It should related directly to a field name in $this->_DataArray. ie. RoleID
  * @param mixed $DataSet The data to fill the options in the select list. Either an associative
  *    array or a database dataset.
  * @param array $Attributes An associative array of attributes for the list. Here is a list of
  *    "special" attributes and their default values:
  *
  *   Attribute   Options                        Default
  *   ------------------------------------------------------------------------
  *   ValueField  The name of the field in       'value'
  *               $DataSet that contains the
  *               option values.
  *   TextField   The name of the field in       'text'
  *               $DataSet that contains the
  *               option text.
  *   Value       A string or array of strings.  $this->_DataArray->$FieldName
  *   Default     The default value.             empty
  *   InlineErrors  Show inline error message?   TRUE
  *               Allows disabling per-dropdown
  *               for multi-fields like Date()
  *
  * @return string
  */
 public function radioList($FieldName, $DataSet, $Attributes = array())
 {
     $List = val('list', $Attributes);
     $Return = '';
     if ($List) {
         $Return .= '<ul' . (isset($Attributes['listclass']) ? " class=\"{$Attributes['listclass']}\"" : '') . '>';
         $LiOpen = '<li' . attribute('class', $this->getStyle('radio-container', '') . ' ' . val('list-item-class', $Attributes)) . '>';
         $LiClose = '</li>';
     } elseif ($this->getStyle('radio-container', '') && stripos(val('class', $Attributes), 'inline') === false) {
         $class = $this->getStyle('radio-container');
         $LiOpen = "<div class=\"{$class}\">";
         $LiClose = '</div>';
     } else {
         $LiOpen = '';
         $LiClose = ' ';
     }
     // Show inline errors?
     $ShowErrors = $this->_InlineErrors && array_key_exists($FieldName, $this->_ValidationResults);
     // Add error class to input element
     if ($ShowErrors) {
         $this->addErrorClass($Attributes);
     }
     if (is_object($DataSet)) {
         $ValueField = arrayValueI('ValueField', $Attributes, 'value');
         $TextField = arrayValueI('TextField', $Attributes, 'text');
         $Data = $DataSet->firstRow();
         if (property_exists($Data, $ValueField) && property_exists($Data, $TextField)) {
             foreach ($DataSet->result() as $Data) {
                 $Attributes['value'] = $Data->{$ValueField};
                 $Return .= $LiOpen . $this->radio($FieldName, $Data->{$TextField}, $Attributes) . $LiClose;
             }
         }
     } elseif (is_array($DataSet)) {
         foreach ($DataSet as $ID => $Text) {
             $Attributes['value'] = $ID;
             $Return .= $LiOpen . $this->radio($FieldName, $Text, $Attributes) . $LiClose;
         }
     }
     if ($List) {
         $Return .= '</ul>';
     }
     // Append validation error message
     if ($ShowErrors && arrayValueI('InlineErrors', $Attributes, true)) {
         $Return .= $this->inlineError($FieldName);
     }
     return $Return;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:73,代码来源:class.form.php

示例8: attribute

<?php 
for ($i = 0; $i < count($general_url) - 1; $i++) {
    attribute($general_url[$i], $general_byline[$i]);
}
?>

  <h2>Google Autonomous Vehicle Sources</h2>
    <p>These links only pertain to Google AVs</p>
<?php 
for ($i = 0; $i < count($google_url) - 1; $i++) {
    attribute($google_url[$i], $google_byline[$i]);
}
?>
  <h2>Defensive Driving Sources</h2>
    <p>Links to further brush up on defensive driving skills</p>
<?php 
for ($i = 0; $i < count($defensive_url) - 1; $i++) {
    attribute($defensive_url[$i], $defensive_byline[$i]);
}
?>

  <h2>Driving Under an Influence</h2>
    <p>Links pertaining to altered state driving</p>
<?php 
for ($i = 0; $i < count($altered_url) - 1; $i++) {
    attribute($altered_url[$i], $altered_byline[$i]);
}
?>

<?php 
include 'footer.php';
开发者ID:sluggets,项目名称:transition,代码行数:31,代码来源:sources.php

示例9: attribute

<?php

/** @var MediaItemModule $this */
?>
<div <?php 
echo attribute($this->getAttributes());
?>
>
    <?php 
if ($this->getImageHtml()) {
    ?>
        <div class="media-left">
            <div class="media-image-wrap">
                <?php 
    echo $this->getImageHtml();
    ?>
            </div>
        </div>
    <?php 
}
?>
    <div class="media-body">
        <?php 
if (val('is-current', $this->getOptions())) {
    ?>
            <div class="flag"><?php 
    echo t('Current Theme');
    ?>
</div>
        <?php 
}
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:media-callout.php

示例10: foreach

?>
        </tr>
        </thead>
        <tbody>
        <?php 
foreach ($this->getRows() as $row) {
    ?>
            <tr <?php 
    echo attribute(val('attributes', $row));
    ?>
>
                <?php 
    foreach (val('cells', $row) as $key => $cell) {
        ?>
                    <td <?php 
        echo attribute(val('attributes', $cell));
        ?>
><?php 
        echo val('data', $cell);
        ?>
</td>
                <?php 
    }
    ?>
            </tr>
        <?php 
}
?>
        </tbody>
    </table>
</div>
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:tablesummary.php

示例11: val

        ?>
                </div>
            <?php 
    }
    ?>
            <?php 
    if (val('type', $item) == 'link') {
        ?>
                <a role="menuitem" class="dropdown-item <?php 
        echo val('cssClass', $item);
        ?>
" tabindex="-1" href="<?php 
        echo url(val('url', $item));
        ?>
"  <?php 
        echo attribute(val('attributes', $item, []));
        ?>
>
                    <?php 
        if (val('icon', $item)) {
            echo icon(val('icon', $item));
        }
        echo val('text', $item);
        if (val('badge', $item)) {
            echo badge(val('badge', $item));
        }
        ?>
                </a>
            <?php 
    }
    if (val('type', $item) == 'divider') {
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:dropdown-twbs.php

示例12: wrap

 /**
  * Wrap the provided string in the specified tag.
  *
  * @example wrap('This is bold!', 'b');
  *
  * @param $String
  * @param string $Tag
  * @param string $Attributes
  * @return string
  */
 function wrap($String, $Tag = 'span', $Attributes = '')
 {
     if ($Tag == '') {
         return $String;
     }
     if (is_array($Attributes)) {
         $Attributes = attribute($Attributes);
     }
     // Strip the first part of the tag as the closing tag - this allows us to
     // easily throw 'span class="something"' into the $Tag field.
     $Space = strpos($Tag, ' ');
     $ClosingTag = $Space ? substr($Tag, 0, $Space) : $Tag;
     return '<' . $Tag . $Attributes . '>' . $String . '</' . $ClosingTag . '>';
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:24,代码来源:functions.render.php


注:本文中的attribute函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。