本文整理汇总了PHP中Contao\StringUtil::standardize方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::standardize方法的具体用法?PHP StringUtil::standardize怎么用?PHP StringUtil::standardize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contao\StringUtil
的用法示例。
在下文中一共展示了StringUtil::standardize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate the widget and return it as string
*
* @return string
*/
public function generate()
{
$arrOptions = array();
if (!$this->multiple && count($this->arrOptions) > 1) {
$this->arrOptions = array($this->arrOptions[0]);
}
// The "required" attribute only makes sense for single checkboxes
if ($this->mandatory && !$this->multiple) {
$this->arrAttributes['required'] = 'required';
}
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
$state = $objSessionBag->get('checkbox_groups');
// Toggle the checkbox group
if (\Input::get('cbc')) {
$state[\Input::get('cbc')] = isset($state[\Input::get('cbc')]) && $state[\Input::get('cbc')] == 1 ? 0 : 1;
$objSessionBag->set('checkbox_groups', $state);
$this->redirect(preg_replace('/(&(amp;)?|\\?)cbc=[^& ]*/i', '', \Environment::get('request')));
}
$blnFirst = true;
$blnCheckAll = true;
foreach ($this->arrOptions as $i => $arrOption) {
// Single dimension array
if (is_numeric($i)) {
$arrOptions[] = $this->generateCheckbox($arrOption, $i);
continue;
}
$id = 'cbc_' . $this->strId . '_' . \StringUtil::standardize($i);
$img = 'folPlus.svg';
$display = 'none';
if (!isset($state[$id]) || !empty($state[$id])) {
$img = 'folMinus.svg';
$display = 'block';
}
$arrOptions[] = '<div class="checkbox_toggler' . ($blnFirst ? '_first' : '') . '"><a href="' . $this->addToUrl('cbc=' . $id) . '" onclick="AjaxRequest.toggleCheckboxGroup(this,\'' . $id . '\');Backend.getScrollOffset();return false">' . \Image::getHtml($img) . '</a>' . $i . '</div><fieldset id="' . $id . '" class="tl_checkbox_container checkbox_options" style="display:' . $display . '"><input type="checkbox" id="check_all_' . $id . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this, \'' . $id . '\')"> <label for="check_all_' . $id . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label>';
// Multidimensional array
foreach ($arrOption as $k => $v) {
$arrOptions[] = $this->generateCheckbox($v, standardize($i) . '_' . $k);
}
$arrOptions[] = '</fieldset>';
$blnFirst = false;
$blnCheckAll = false;
}
// Add a "no entries found" message if there are no options
if (empty($arrOptions)) {
$arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
$blnCheckAll = false;
}
if ($this->multiple) {
return sprintf('<fieldset id="ctrl_%s" class="tl_checkbox_container%s"><legend>%s%s%s%s</legend><input type="hidden" name="%s" value="">%s%s</fieldset>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->xlabel, $this->strName, $blnCheckAll ? '<input type="checkbox" id="check_all_' . $this->strId . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this,\'ctrl_' . $this->strId . '\')' . ($this->onclick ? ';' . $this->onclick : '') . '"> <label for="check_all_' . $this->strId . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label><br>' : '', str_replace('<br></fieldset><br>', '</fieldset>', implode('<br>', $arrOptions)), $this->wizard);
} else {
return sprintf('<div id="ctrl_%s" class="tl_checkbox_single_container%s"><input type="hidden" name="%s" value="">%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->strName, str_replace('<br></div><br>', '</div>', implode('<br>', $arrOptions)), $this->wizard);
}
}
示例2: createNewUser
/**
* Create a new user and redirect
*
* @param array $arrData
*/
protected function createNewUser($arrData)
{
$arrData['tstamp'] = time();
$arrData['login'] = $this->reg_allowLogin;
$arrData['activation'] = md5(uniqid(mt_rand(), true));
$arrData['dateAdded'] = $arrData['tstamp'];
// Set default groups
if (!array_key_exists('groups', $arrData)) {
$arrData['groups'] = $this->reg_groups;
}
// Disable account
$arrData['disable'] = 1;
// Send activation e-mail
if ($this->reg_activate) {
$this->sendActivationMail($arrData);
}
// Make sure newsletter is an array
if (isset($arrData['newsletter']) && !is_array($arrData['newsletter'])) {
$arrData['newsletter'] = array($arrData['newsletter']);
}
// Create the user
$objNewUser = new \MemberModel();
$objNewUser->setRow($arrData);
$objNewUser->save();
// Assign home directory
if ($this->reg_assignDir) {
$objHomeDir = \FilesModel::findByUuid($this->reg_homeDir);
if ($objHomeDir !== null) {
$this->import('Files');
$strUserDir = \StringUtil::standardize($arrData['username']) ?: 'user_' . $objNewUser->id;
// Add the user ID if the directory exists
while (is_dir(TL_ROOT . '/' . $objHomeDir->path . '/' . $strUserDir)) {
$strUserDir .= '_' . $objNewUser->id;
}
// Create the user folder
new \Folder($objHomeDir->path . '/' . $strUserDir);
$objUserDir = \FilesModel::findByPath($objHomeDir->path . '/' . $strUserDir);
// Save the folder ID
$objNewUser->assignDir = 1;
$objNewUser->homeDir = $objUserDir->uuid;
$objNewUser->save();
}
}
// HOOK: send insert ID and user data
if (isset($GLOBALS['TL_HOOKS']['createNewUser']) && is_array($GLOBALS['TL_HOOKS']['createNewUser'])) {
foreach ($GLOBALS['TL_HOOKS']['createNewUser'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($objNewUser->id, $arrData, $this);
}
}
// Create the initial version (see #7816)
$objVersions = new \Versions('tl_member', $objNewUser->id);
$objVersions->setUsername($objNewUser->username);
$objVersions->setUserId(0);
$objVersions->setEditUrl('contao/main.php?do=member&act=edit&id=%s&rt=1');
$objVersions->initialize();
// Inform admin if no activation link is sent
if (!$this->reg_activate) {
$this->sendAdminNotification($objNewUser->id, $arrData);
}
// Check whether there is a jumpTo page
if (($objJumpTo = $this->objModel->getRelated('jumpTo')) instanceof PageModel) {
$this->jumpToOrReload($objJumpTo->row());
}
$this->reload();
}
示例3: getCustomSections
/**
* Return all custom layout sections
*
* @param string $strKey An optional section name
*
* @return string The section markup
*
* @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
* Use FrontendTemplate::sections() instead.
*/
public function getCustomSections($strKey = null)
{
@trigger_error('Using FrontendTemplate::getCustomSections() has been deprecated and will no longer work in Contao 5.0. Use FrontendTemplate::sections() instead.', E_USER_DEPRECATED);
if ($strKey != '' && $this->sPosition != $strKey) {
return '';
}
$tag = 'div';
if ($strKey == 'main') {
/** @var PageModel $objPage */
global $objPage;
// Use the section tag in HTML5
if ($objPage->outputFormat == 'html5') {
$tag = 'section';
}
}
$sections = '';
// Standardize the IDs (thanks to Tsarma) (see #4251)
foreach ($this->sections as $k => $v) {
$sections .= "\n" . '<' . $tag . ' id="' . \StringUtil::standardize($k, true) . '">' . "\n" . '<div class="inside">' . "\n" . $v . "\n" . '</div>' . "\n" . '</' . $tag . '>' . "\n";
}
if ($sections == '') {
return '';
}
return '<div class="custom">' . "\n" . $sections . "\n" . '</div>' . "\n";
}