本文整理匯總了PHP中UTF8::slugify方法的典型用法代碼示例。如果您正苦於以下問題:PHP UTF8::slugify方法的具體用法?PHP UTF8::slugify怎麽用?PHP UTF8::slugify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UTF8
的用法示例。
在下文中一共展示了UTF8::slugify方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: makeSlug
/**
* Creates a URL safe slug of the plugin's name
*
* @return string A URL-safe slug.
*/
public function makeSlug()
{
if (empty($this->slug)) {
$this->slug = UTF8::slugify($this->name);
}
return $this->slug;
}
示例2: display
public static function display()
{
$r = "";
if ($_POST['cc_form'] == 'settings') {
$name_lookup = array();
Database::beginTransaction();
foreach ($_POST as $key => $value) {
if ($key == 'cc_form') {
continue;
}
if (substr($key, 0, 12) == 'cc_settings_') {
$name_lookup[substr($key, 12)] = explode('|', $value);
continue;
}
$setting_name = $key;
//var_dump(array_key_exists($key, $name_lookup),$name_lookup);
if (!array_key_exists($setting_name, $name_lookup)) {
continue;
}
if ($key == 'clean-urls') {
$value = (bool) $value;
}
Database::update('settings', array('data'), array(serialize($value)), array('package = ? AND name = ?', $name_lookup[$setting_name][1], $name_lookup[$setting_name][0]));
}
$r .= Message::success(__('admin', 'settings-saved'));
Database::endTransaction();
}
$settings = Database::select('settings', '*', array('package = ? OR package = ? OR package = ? OR package = ?', 'core', 'admin', 'site', 'gui'), array('package', 'ASC', 'name', 'ASC'));
$settings = $settings->fetchAll(PDO::FETCH_ASSOC);
$rows = array();
foreach ($settings as $row) {
if (!array_key_exists($row['package'], $rows)) {
$rows[$row['package']] = array();
}
$rows[$row['package']][] = $row;
}
ksort($rows);
$form = new Form('self', 'POST', 'settings');
foreach ($rows as $cat => $catRows) {
$form->startFieldset(__('settings', $cat));
foreach ($catRows as $row) {
$data = unserialize($row['data']);
$form->addHidden('cc_settings_' . UTF8::slugify($row['name']), $row['name'] . '|' . $row['package']);
if ($row['name'] == 'clean urls') {
$form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), array(1 => __('admin', 'yes'), 0 => __('admin', 'no')), true, $data);
} else {
if ($row['name'] == 'theme') {
$themes = Themes::getThemeList();
$options = array();
foreach ($themes as $slug => $ini) {
$options[$slug] = $ini['name'];
}
$form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $options, true, $data);
} else {
if ($row['name'] == 'locale') {
$locales = i18n::getLocales();
$form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $locales, false, $data);
} else {
if ($row['name'] == 'homepage id') {
$form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Content::optionListArrayFromArray(Content::parseNavigation()), true, $data);
} else {
if ($row['name'] == 'site name') {
$form->addInput(__('settings', $row['name']), 'text', UTF8::slugify($row['name']), $data);
} else {
if ($row['name'] == 'editor') {
$editors = Editors::getNamesOfRegistered();
$form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), $editors, false, $data);
} else {
if ($row['name'] == 'homepage') {
$form->addSelectList(__('settings', $row['name']), UTF8::slugify($row['name']), Admin::getAdminPageOptions(), true, $data);
}
}
}
}
}
}
}
}
$form->endFieldset();
}
$form->startFieldset('');
$form->addSubmit('', 'save-settings', __('admin', 'save'));
$form->endFieldset();
return array(__('admin', 'settings'), $r . $form->endAndGetHTML());
}