本文整理汇总了PHP中iaSanitize::alias方法的典型用法代码示例。如果您正苦于以下问题:PHP iaSanitize::alias方法的具体用法?PHP iaSanitize::alias怎么用?PHP iaSanitize::alias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iaSanitize
的用法示例。
在下文中一共展示了iaSanitize::alias方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: titleAlias
public function titleAlias($title)
{
$result = iaSanitize::tags($title);
$this->iaCore->factory('util');
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad', 'utf8_to_ascii');
utf8_is_ascii($result) || ($result = utf8_to_ascii($result));
$result = preg_replace('#' . self::ALIAS_SUFFIX . '$#i', '', $result);
$result = iaSanitize::alias($result);
$result = substr($result, 0, 150);
// the DB scheme applies this limitation
$result .= self::ALIAS_SUFFIX;
return $result;
}
示例2: _generateFileName
protected static function _generateFileName($filename = '', $prefix = '', $glue = true)
{
if (empty($filename)) {
return $prefix . iaUtil::generateToken();
}
$extension = '';
if (false !== strpos($filename, '.')) {
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$filename = $prefix . pathinfo($filename, PATHINFO_FILENAME);
if (false !== strpos($filename, '.')) {
$filename = str_replace(array('.', '~'), '-', $filename);
}
}
$filename = iaSanitize::alias($filename) . '_' . iaUtil::generateToken(5);
return $glue ? $filename . '.' . $extension : array($filename, $extension);
}
示例3: _saveTags
protected function _saveTags($tagsString)
{
$tags = array_filter(explode(',', $tagsString));
$this->_iaDb->setTable($this->_tableBlogEntriesTags);
$sql = 'DELETE ' . 'FROM `:prefix:table_blog_tags` ' . 'WHERE `id` IN (' . 'SELECT DISTINCT `tag_id` ' . 'FROM `:prefix:table_blog_entries_tags` ' . 'WHERE `tag_id` IN (' . 'SELECT DISTINCT `tag_id` FROM `:prefix:table_blog_entries_tags` ' . 'WHERE `blog_id` = :id) ' . 'GROUP BY 1 ' . 'HAVING COUNT(*) = 1)';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_tags' => $this->_tableBlogTags, 'table_blog_entries_tags' => $this->_tableBlogEntriesTags, 'id' => $this->getEntryId()));
$this->_iaDb->query($sql);
$sql = 'DELETE ' . 'FROM :prefix:table_blog_entries_tags ' . 'WHERE `blog_id` = :id';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_entries_tags' => $this->_tableBlogEntriesTags, 'id' => $this->getEntryId()));
$this->_iaDb->query($sql);
$allTagTitles = $this->_iaDb->keyvalue(array('title', 'id'), null, $this->_tableBlogTags);
foreach ($tags as $tag) {
$tagAlias = iaSanitize::alias(strtolower($tag));
$tagEntry = array('title' => $tag, 'alias' => $tagAlias);
$tagId = isset($allTagTitles[$tag]) ? $allTagTitles[$tag] : $this->_iaDb->insert($tagEntry, null, $this->_tableBlogTags);
$tagBlogIds = array('blog_id' => $this->getEntryId(), 'tag_id' => $tagId);
$this->_iaDb->insert($tagBlogIds);
}
}
示例4: _parseTreeNodes
private function _parseTreeNodes($nodesFlatData)
{
$nestedIds = array();
$preservedKeys = array('id', 'text', 'parent');
$data = iaUtil::jsonDecode($nodesFlatData);
foreach ($data as $i => $node) {
foreach ($node as $key => $value) {
if (!in_array($key, $preservedKeys)) {
unset($data[$i][$key]);
}
}
$alias = strtolower(iaSanitize::alias($node['text']));
$nestedIds[$node['id']] = array('node_id' => $node['id'], 'text' => $node['text'], 'parent_node_id' => '#' != $node['parent'] ? $node['parent'] : '', 'alias' => '#' != $node['parent'] && isset($nestedIds[$node['parent']]) ? $nestedIds[$node['parent']]['alias'] . $alias . IA_URL_DELIMITER : $alias . IA_URL_DELIMITER);
}
return array(iaUtil::jsonEncode($data), $nestedIds);
}
示例5: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
$this->_iaCore->startHook('phpAdminAddPageValidation', array('entry' => &$entry));
iaUtil::loadUTF8Functions('ascii', 'bad', 'utf8_to_ascii', 'validation');
$entry['name'] = preg_replace('#[^a-z0-9-_]#iu', '', strtolower($data['name'] = !utf8_is_ascii($data['name']) ? utf8_to_ascii($data['name']) : $data['name']));
$entry['meta_description'] = utf8_is_valid($data['meta_description']) ? $data['meta_description'] : utf8_bad_replace($data['meta_description']);
$entry['meta_keywords'] = utf8_is_valid($data['meta_keywords']) ? $data['meta_keywords'] : utf8_bad_replace($data['meta_keywords']);
$entry['status'] = isset($data['preview']) ? iaCore::STATUS_DRAFT : $data['status'];
if (iaCore::ACTION_ADD == $action) {
$entry['group'] = 2;
$entry['filename'] = 'page';
}
foreach ($data['titles'] as $key => $title) {
if (empty($title)) {
$this->addMessage(iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('title') . ' (' . $key . ')')), false);
break;
}
}
if (!isset($data['service']) || !$data['service']) {
$entry['alias'] = empty($data['alias']) ? $data['name'] : $data['alias'];
$entry['custom_url'] = empty($data['custom_url']) ? '' : $data['custom_url'];
$entry['passw'] = empty($data['passw']) ? '' : $data['passw'];
$entry['alias'] = utf8_is_ascii($entry['alias']) ? $entry['alias'] : utf8_to_ascii($entry['alias']);
$entry['alias'] = empty($entry['alias']) ? '' : iaSanitize::alias($entry['alias']);
$entry['alias'] .= $data['extension'];
if ($data['parent_id']) {
$parentPage = $this->getById($data['parent_id']);
$parentAlias = empty($parentPage['alias']) ? $parentPage['name'] . IA_URL_DELIMITER : $parentPage['alias'];
$entry['parent'] = $parentPage['name'];
$entry['alias'] = $parentAlias . (IA_URL_DELIMITER == substr($parentAlias, -1, 1) ? '' : IA_URL_DELIMITER) . $entry['alias'];
} else {
$entry['parent'] = '';
}
if ($this->_iaDb->exists('`id` != :id AND `alias` = :alias', array('id' => $this->getEntryId(), 'alias' => $entry['alias']))) {
$this->addMessage('page_alias_exists');
}
if (isset($data['nofollow'])) {
$entry['nofollow'] = (int) $data['nofollow'];
}
if (isset($data['new_window'])) {
$entry['new_window'] = (int) $data['new_window'];
}
// delete custom url
if (isset($data['unique']) && 0 == $data['unique']) {
$entry['custom_url'] = '';
}
if (isset($data['custom_tpl']) && $data['custom_tpl']) {
$entry['custom_tpl'] = (int) $data['custom_tpl'];
$entry['template_filename'] = $data['template_filename'];
if (!$data['template_filename']) {
$this->addMessage('page_incorrect_template_filename');
}
} else {
$entry['custom_tpl'] = 0;
$entry['template_filename'] = '';
}
}
if (empty($entry['name'])) {
$this->addMessage(iaLanguage::getf('field_is_empty', array('field' => iaLanguage::get('name'))), false);
} elseif (iaCore::ACTION_ADD == $action && $this->_iaDb->exists('`name` = :name', array('name' => $entry['name']))) {
$this->addMessage('page_name_exists');
}
return !$this->getMessages();
}
示例6: _preSaveEntry
protected function _preSaveEntry(array &$entry, array $data, $action)
{
$entry = array('name' => iaSanitize::alias(iaUtil::checkPostParam('name')), 'item' => iaUtil::checkPostParam('item'), 'default' => iaUtil::checkPostParam('default'), 'lang_values' => iaUtil::checkPostParam('lang_values'), 'text_default' => iaSanitize::html(iaUtil::checkPostParam('text_default')), 'type' => iaUtil::checkPostParam('type'), 'annotation' => iaUtil::checkPostParam('annotation'), 'fieldgroup_id' => (int) iaUtil::checkPostParam('fieldgroup_id'), 'text_length' => (int) iaUtil::checkPostParam('text_length', 100), 'length' => iaUtil::checkPostParam('length', false), 'title' => iaUtil::checkPostParam('title'), 'pages' => iaUtil::checkPostParam('pages', array()), 'required' => iaUtil::checkPostParam('required'), 'use_editor' => (int) iaUtil::checkPostParam('use_editor'), 'empty_field' => iaSanitize::html(iaUtil::checkPostParam('empty_field')), 'url_nofollow' => (int) iaUtil::checkPostParam('url_nofollow'), 'groups' => iaUtil::checkPostParam('groups'), 'searchable' => (int) iaUtil::checkPostParam('searchable'), 'adminonly' => (int) iaUtil::checkPostParam('adminonly'), 'for_plan' => (int) iaUtil::checkPostParam('for_plan'), 'required_checks' => iaUtil::checkPostParam('required_checks'), 'extra_actions' => iaUtil::checkPostParam('extra_actions'), 'link_to' => (int) iaUtil::checkPostParam('link_to'), 'values' => '', 'relation' => iaUtil::checkPostParam('relation', iaField::RELATION_REGULAR), 'parents' => isset($data['parents']) && is_array($data['parents']) ? $data['parents'] : array(), 'children' => isset($data['children']) && is_array($data['children']) ? $data['children'] : array(), 'status' => iaUtil::checkPostParam('status', iaCore::STATUS_ACTIVE));
iaUtil::loadUTF8Functions('ascii', 'validation', 'bad');
if (!$this->_iaDb->exists(iaDb::convertIds($entry['fieldgroup_id']), null, iaField::getTableGroups())) {
$entry['fieldgroup_id'] = 0;
}
foreach ($this->_iaCore->languages as $code => $language) {
if (!empty($entry['annotation'][$code])) {
if (!utf8_is_valid($entry['annotation'][$code])) {
$entry['annotation'][$code] = utf8_bad_replace($entry['annotation'][$code]);
}
}
if (!empty($entry['title'][$code])) {
if (!utf8_is_valid($entry['title'][$code])) {
$entry['title'][$code] = utf8_bad_replace($entry['title'][$code]);
}
} else {
$this->addMessage(iaLanguage::getf('field_is_empty', array('field' => $language['title'] . ' ' . iaLanguage::get('title'))), false);
break;
}
}
if (iaCore::ACTION_ADD == $action) {
$entry['name'] = trim(strtolower(iaSanitize::paranoid($entry['name'])));
if (empty($entry['name'])) {
$this->addMessage('field_name_incorrect');
}
} else {
unset($entry['name']);
}
$fieldTypes = $this->_iaDb->getEnumValues(iaField::getTable(), 'type');
if ($fieldTypes['values'] && !in_array($entry['type'], $fieldTypes['values'])) {
$this->addMessage('field_type_invalid');
} else {
if (!$entry['length']) {
$entry['length'] = iaField::DEFAULT_LENGTH;
}
switch ($entry['type']) {
case iaField::TEXT:
if (empty($entry['text_length'])) {
$entry['text_length'] = 100;
}
$entry['length'] = min(255, max(1, $entry['text_length']));
$entry['default'] = $entry['text_default'];
break;
case iaField::TEXTAREA:
$entry['default'] = '';
break;
case iaField::COMBO:
case iaField::RADIO:
case iaField::CHECKBOX:
if (!empty($data['values']) && is_array($data['values'])) {
$keys = array();
$lang_values = array();
$multiDefault = explode('|', iaUtil::checkPostParam('multiple_default'));
$_keys = iaUtil::checkPostParam('keys');
$_values = iaUtil::checkPostParam('values');
$_langValues = iaUtil::checkPostParam('lang_values');
foreach ($_keys as $index => $key) {
if (trim($key) == '') {
$key = $index + 1;
$_keys[$index] = $key;
}
if (isset($_values[$index]) && trim($_values[$index]) != '') {
$values[$key] = $_values[$index];
$keys[$key] = $key;
} else {
unset($_keys[$index], $_values[$index]);
}
if ($_langValues) {
foreach ($this->_iaCore->languages as $code => $language) {
if ($code != $this->_iaCore->iaView->language) {
if (!isset($_values[$index])) {
unset($_langValues[$code][$index]);
} elseif (!isset($_langValues[$code][$index]) || trim($_langValues[$code][$index]) == '') {
$lang_values[$code][$key] = $values[$key];
} else {
$lang_values[$code][$key] = $_langValues[$code][$index];
}
}
}
}
}
// delete default values if not exists in values
foreach ($multiDefault as $index => $default) {
if (!in_array($default, $values)) {
unset($multiDefault[$index]);
} else {
$k = array_search($default, $values);
$multiDefault[$index] = $k;
}
}
$multiDefault = array_values($multiDefault);
if (iaField::CHECKBOX == $entry['type']) {
$multiDefault = implode(',', $multiDefault);
} elseif (isset($multiDefault[0])) {
// multiple default is available for checkboxes only
$_POST['multiple_default'] = $multiDefault = $multiDefault[0];
} else {
$_POST['multiple_default'] = $multiDefault = '';
//.........这里部分代码省略.........
示例7: list
if ($fields) {
list($data, $error, $messages, $errorFields) = iaField::parsePost($fields, $genre, true);
}
if (!defined('IA_NOUTF')) {
iaUtf8::loadUTF8Core();
iaUtf8::loadUTF8Util('ascii', 'validation', 'bad', 'utf8_to_ascii');
}
if (!$error) {
$iaCore->startHook("phpAdminBeforeGenreSubmit");
$data['status'] = iaUtil::checkPostParam('status', iaCore::STATUS_ACTIVE);
// validate title_alias
$data['title_alias'] = !empty($_POST['title_alias']) ? $_POST['title_alias'] : $_POST['title'];
if (!utf8_is_ascii($data['title_alias'])) {
$data['title_alias'] = utf8_to_ascii($data['title_alias']);
}
$data['title_alias'] = iaSanitize::alias($data['title_alias']);
// check for duplicate title_alias in case a new genre is added or title_alias has been updated
if (!empty($genre['id']) && $genre['title_alias'] != $data['title_alias'] || empty($genre['id'])) {
if ($iaGenre->existsAlias($data['title_alias'])) {
$error = true;
$messages[] = iaLanguage::get('genre_already_exists');
}
}
// validate account
if (isset($_POST['account']) && !empty($_POST['account'])) {
$member_id = $iaDb->one('id', "`username` = '{$_POST['account']}' ", iaUsers::getTable());
if (!$member_id) {
$error = true;
$messages[] = iaLanguage::get('genre_incorrect_account');
} else {
$data['member_id'] = $member_id;
示例8: _postSaveEntry
protected function _postSaveEntry(array &$entry, array $data, $action)
{
$tags = array_filter(explode(',', $data['tags']));
$iaLog = $this->_iaCore->factory('log');
$actionCode = iaCore::ACTION_ADD == $action ? iaLog::ACTION_CREATE : iaLog::ACTION_UPDATE;
$params = array('module' => 'blog', 'item' => 'blog', 'name' => $entry['title'], 'id' => $this->getEntryId());
$this->_iaDb->setTable($this->_tableBlogEntriesTags);
$sql = 'DELETE ' . 'FROM `:prefix:table_blog_tags` ' . 'WHERE `id` IN (' . 'SELECT DISTINCT `tag_id` ' . 'FROM `:prefix:table_blog_entries_tags` ' . 'WHERE `tag_id` IN (' . 'SELECT DISTINCT `tag_id` FROM `:prefix:table_blog_entries_tags` ' . 'WHERE :id) ' . 'GROUP BY 1 ' . 'HAVING COUNT(*) = 1)';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_tags' => $this->_tableBlogTags, 'table_blog_entries_tags' => $this->_tableBlogEntriesTags, 'id' => iaDb::convertIds($this->getEntryId(), 'blog_id')));
$this->_iaDb->query($sql);
$sql = 'DELETE ' . 'FROM :prefix:table_blog_entries_tags ' . 'WHERE :id';
$sql = iaDb::printf($sql, array('prefix' => $this->_iaDb->prefix, 'table_blog_entries_tags' => $this->_tableBlogEntriesTags, 'id' => iaDb::convertIds($this->getEntryId(), 'blog_id')));
$this->_iaDb->query($sql);
$allTagTitles = $this->_iaDb->keyvalue(array('title', 'id'), '', $this->_tableBlogTags);
foreach ($tags as $tag) {
$tagAlias = iaSanitize::alias(strtolower($tag));
$tagEntry = array('title' => $tag, 'alias' => $tagAlias);
$tagId = isset($allTagTitles[$tag]) ? $allTagTitles[$tag] : $this->_iaDb->insert($tagEntry, null, $this->_tableBlogTags);
$tagBlogIds = array('blog_id' => $this->getEntryId(), 'tag_id' => $tagId);
$this->_iaDb->insert($tagBlogIds);
}
$iaLog->write($actionCode, $params);
}