Example #1
0
/**
 * 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;
}
 /**
  * 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>';
 }
Example #3
0
    /**
     * 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;
    }
Example #4
0
        <?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>
Example #5
0
 /**
  *
  *
  * @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";
 }
Example #6
0
 /**
  * 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>';
 }
Example #7
0
 /**
  * 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;
 }
Example #8
0
<?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';
Example #9
0
<?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 
}
Example #10
0
?>
        </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>
Example #11
0
        ?>
                </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') {
Example #12
0
 /**
  * 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 . '>';
 }