Skip to content

Commit

Permalink
Updated address helper function
Browse files Browse the repository at this point in the history
Updated address helper function
  • Loading branch information
kartik-v committed Nov 25, 2013
1 parent 7bcb4dc commit c66cec4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions extensions/bootstrap/helpers/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ public static function abbr($content, $title, $initialism = false, $options = []
* include the wildtag '{source}' to embed the cite source
* @param string $citeTitle the cite source title (optional)
* @param string $citeSource the cite source (optional)
* @param array $options html options for the blockquote
*
* Example(s):
* ```php
Expand Down Expand Up @@ -739,6 +740,7 @@ public static function blockquote($content, $citeContent = '', $citeTitle = '',
* @param array $email the list of email addresses - passed as $key => $value, where:
* - $key is the email type could be 'Res', 'Off'
* - $value is the email address
* @param array $options html options for the address
* @param string $phoneLabel the prefix label for each phone - defaults to '(P)'
* @param string $emailLabel the prefix label for each email - defaults to '(E)'
*
Expand All @@ -750,19 +752,20 @@ public static function blockquote($content, $citeContent = '', $citeTitle = '',
* ['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'],
* ['Res' => 'first.last@example.com', 'Off' => 'last.first@example.com']
* );
* echo Html::address(
* $address = Html::address(
* 'Twitter, Inc.',
* ['795 Folsom Ave, Suite 600', 'San Francisco, CA 94107'],
* ['Res' => '(123) 456-7890', 'Off'=> '(456) 789-0123'],
* ['Res' => 'first.last@example.com', 'Off' => 'last.first@example.com'],
* Html::icon('phone'),
* Html::icon('envelope')
* );
* echo Html::well($address, Html::TINY);
* ```
*
* @see http://getbootstrap.com/css/#type-addresses
*/
public static function address($name, $lines = [], $phone = [], $email = [], $phoneLabel = '(P)', $emailLabel = '(E)') {
public static function address($name, $lines = [], $phone = [], $email = [], $options = [], $phoneLabel = '(P)', $emailLabel = '(E)') {
$addresses = '';
if (!empty($lines)) {
$addresses = implode('<br>', $lines) . "<br>\n";
Expand All @@ -771,10 +774,10 @@ public static function address($name, $lines = [], $phone = [], $email = [], $ph
$phones = '';
foreach ($phone as $type => $number) {
if (is_numeric($type)) { // no keys were passed to the phone array
$type = Html::tag('abbr', $phoneLabel, ['title' => Yii::t('app', 'Phone')]) . ': ';
$type = static::tag('abbr', $phoneLabel, ['title' => Yii::t('app', 'Phone')]) . ': ';
}
else {
$type = Html::tag('abbr', $phoneLabel . ' ' . $type, ['title' => Yii::t('app', 'Phone')]) . ': ';
$type = static::tag('abbr', $phoneLabel . ' ' . $type, ['title' => Yii::t('app', 'Phone')]) . ': ';
}
$phones .= "{$type}{$number}<br>\n";
}
Expand All @@ -789,13 +792,7 @@ public static function address($name, $lines = [], $phone = [], $email = [], $ph
}
$emails .= $type . static::mailto($addr, $addr) . "<br>\n";
}

return "<address>\n" .
"<strong>{$name}</strong><br>\n" .
$addresses .
$phones .
$emails .
"</address>";
return static::tag('address', "<strong>{$name}</strong><br>\n" . $addresses . $phones . $emails, $options);
}

/**
Expand Down

0 comments on commit c66cec4

Please sign in to comment.