本文整理汇总了PHP中seoFriendly函数的典型用法代码示例。如果您正苦于以下问题:PHP seoFriendly函数的具体用法?PHP seoFriendly怎么用?PHP seoFriendly使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了seoFriendly函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copy
/**
* duplicates an article
* @param string $newtitle the title for the new article
*/
function copy($newtitle)
{
$newID = $newtitle;
$id = parent::copy(array('titlelink' => $newID));
if (!$id) {
$newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
$id = parent::copy(array('titlelink' => $newID));
}
if ($id) {
$newobj = new ZenpageNews($newID);
$newobj->setTitle($newtitle);
$newobj->setTags($this->getTags());
$newobj->save();
$categories = array();
foreach ($this->getCategories() as $cat) {
$categories[] = $cat['cat_id'];
}
$result = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
foreach ($result as $cat) {
if (in_array($cat['id'], $categories)) {
query("INSERT INTO " . prefix('news2cat') . " (cat_id, news_id) VALUES ('" . $cat['id'] . "', '" . $id . "')");
}
}
return $newobj;
}
return false;
}
示例2: makeArticle
function makeArticle($class, $text)
{
global $unique;
$unique++;
$i = strpos($text, '</a>');
$j = strpos($text, '</h4>');
$h4 = substr($text, $i + 4, $j - $i - 4);
$text = substr($text, $j + 5);
$text = str_replace('<hr />', '', $text);
$text = str_replace('<hr/>', '', $text);
$ts_news = new ZenpageNews(seoFriendly($class . '_' . trim(truncate_string(strip_tags($h4), 30, '')) . '_' . $unique), true);
$ts_news->setShow(0);
$ts_news->setDateTime(date('Y-m-d H:i:s'));
$ts_news->setAuthor('TSGenerator');
$ts_news->setTitle($h4);
$ts_news->setContent($text);
$ts_news->setCategories(array());
$ts_news->setCategories(array('troubleshooting', 'troubleshooting-' . $class));
$ts_news->save();
}
示例3: createPrimealbum
/**
* Creates a "prime" album for the user. Album name is based on the userid
*/
function createPrimealbum($new = true, $name = NULL)
{
// create his album
$t = 0;
$ext = '';
if (is_null($name)) {
$filename = internalToFilesystem(str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', seoFriendly($this->getUser())));
} else {
$filename = internalToFilesystem(str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', $name));
}
while ($new && file_exists(ALBUM_FOLDER_SERVERPATH . $filename . $ext)) {
$t++;
$ext = '-' . $t;
}
$path = ALBUM_FOLDER_SERVERPATH . $filename . $ext;
$albumname = filesystemToInternal($filename . $ext);
if (@mkdir_recursive($path, FOLDER_MOD)) {
$album = newAlbum($albumname);
if ($title = $this->getName()) {
$album->setTitle($title);
}
$album->save();
$this->setAlbum($album);
$this->setRights($this->getRights() | ALBUM_RIGHTS);
if (getOption('user_album_edit_default')) {
$subrights = MANAGED_OBJECT_RIGHTS_EDIT;
} else {
$subrights = 0;
}
if ($this->getRights() & UPLOAD_RIGHTS) {
$subrights = $subrights | MANAGED_OBJECT_RIGHTS_UPLOAD;
}
$objects = $this->getObjects();
$objects[] = array('data' => $albumname, 'name' => $albumname, 'type' => 'album', 'edit' => $subrights);
$this->setObjects($objects);
}
}
示例4: createMenuIfNotExists
//.........这里部分代码省略.........
$orders[$nesting] = addCategoriesToDatabase($menuset, $orders);
$type = false;
break;
case 'album':
$result['title'] = NULL;
if (empty($result['link'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty link.'), $key));
}
break;
case 'galleryindex':
$result['link'] = NULL;
if (empty($result['title'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
}
break;
case 'Page':
$result['title'] = NULL;
if (empty($result['link'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty link.'), $key));
}
break;
case 'newsindex':
$result['link'] = NULL;
if (empty($result['title'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
}
break;
case 'category':
$result['title'] = NULL;
if (empty($result['link'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty link.'), $key));
}
break;
case 'custompage':
if (empty($result['title']) || empty($result['link'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title or link.'), $key));
}
break;
case 'customlink':
if (empty($result['title'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
} else {
if (empty($result['link'])) {
$result['link'] = seoFriendly(get_language_string($result['title']));
}
}
break;
case 'menulabel':
if (empty($result['title'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
}
$result['link'] = sha1($result['title']);
break;
case 'menufunction':
if (empty($result['title']) || empty($result['link'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title or link.'), $key));
}
break;
case 'html':
if (empty($result['title']) || empty($result['link'])) {
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title or link.'), $key));
}
break;
default:
$success = -1;
debugLog(sprintf(gettext('createMenuIfNotExists item %s has an invalid type.'), $key));
break;
}
if ($success > 0 && $type) {
$orders[$nesting]++;
$sort_order = '';
for ($i = 0; $i < count($orders); $i++) {
$sort_order .= sprintf('%03u', $orders[$i]) . '-';
}
$sort_order = substr($sort_order, 0, -1);
$sql = "INSERT INTO " . prefix('menu') . " (`title`,`link`,`type`,`show`,`menuset`,`sort_order`,`include_li`) " . "VALUES (" . db_quote($result['title']) . ", " . db_quote($result['link']) . "," . db_quote($result['type']) . "," . $result['show'] . "," . db_quote($menuset) . "," . db_quote($sort_order) . ",{$includeli})";
if (!query($sql, false)) {
$success = -2;
debugLog(sprintf(gettext('createMenuIfNotExists item %1$s query (%2$s) failed: %3$s.'), $key, $sql, db_error()));
}
}
}
} else {
$success = 0;
}
if ($success < 0) {
zp_error(gettext('createMenuIfNotExists has posted processing errors to your debug log.'), E_USER_NOTICE);
}
return $success;
}
示例5: handle_file_upload
private function handle_file_upload($uploaded_file, $name, $size, $type, $error)
{
global $folder, $targetPath, $_zp_current_admin_obj;
$file = new stdClass();
$name = $this->trim_file_name($name, $type);
$seoname = seoFriendly($name);
if (strrpos($seoname, '.') === 0) {
$seoname = sha1($name) . $seoname;
}
// soe stripped out all the name.
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
if (file_exists($targetFile)) {
$append = '_' . time();
$seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
}
$file->name = $seoname;
$file->size = intval($size);
$file->type = $type;
$error = $this->has_error($uploaded_file, $file, $error);
if (!$error && $file->name) {
$file_path = $this->options['upload_dir'] . $file->name;
$append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
clearstatcache();
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
// multipart/formdata uploads (POST method uploads)
if ($append_file) {
file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
} else {
move_uploaded_file($uploaded_file, $file_path);
if (Gallery::validImage($name) || Gallery::validImageAlt($name)) {
@chmod($targetFile, FILE_MOD);
$album = newAlbum($folder);
$image = newImage($album, $seoname);
$image->setOwner($_zp_current_admin_obj->getUser());
if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) {
$image->setTitle(stripSuffix($name, '.'));
}
$image->save();
} else {
if (is_zip($targetFile)) {
unzip($targetFile, $targetPath);
unlink($targetFile);
} else {
$file->error = $error = UPLOAD_ERR_EXTENSION;
// invalid file uploaded
}
}
}
} else {
// Non-multipart uploads (PUT method support)
file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
}
$file_size = filesize($file_path);
if ($file_size === $file->size) {
$file->url = $this->options['upload_url'] . rawurlencode($file->name);
foreach ($this->options['image_versions'] as $version => $options) {
if ($this->create_scaled_image($file->name, $options)) {
$file->{$version . '_url'} = $options['upload_url'] . rawurlencode($file->name);
}
}
} else {
if ($this->options['discard_aborted_uploads']) {
@chmod($file_path, 0777);
unlink($file_path);
$file->error = 'abort';
}
}
$file->size = $file_size;
$file->delete_url = $this->options['script_url'] . '?file=' . rawurlencode($file->name);
$file->delete_type = 'DELETE';
} else {
$file->error = $error;
}
return $file;
}
示例6: getRSSCacheFilename
/**
* Gets the RSS file name from the feed url and clears out query items and special chars
*
* @return string
*/
function getRSSCacheFilename()
{
$uri = explode('?', $_SERVER["REQUEST_URI"]);
$filename = array();
foreach (explode('&', $uri[1]) as $param) {
$p = explode('=', $param);
if (isset($p[1]) && !empty($p[1])) {
$filename[] = $p[1];
} else {
$filename[] = $p[0];
}
}
$filename = seoFriendly(implode('_', $filename));
return $filename . ".xml";
//old way
$replace = array(WEBPATH . '/' => '', "albumname=" => "_", "albumsmode=" => "_", "title=" => "_", "folder=" => "_", "type=" => "-", "albumtitle=" => "_", "category=" => "_", "id=" => "_", "lang=" => "_", "&" => "_", "&" => "_", "index.php" => "", "/" => "-", "?" => "");
$filename = strtr($_SERVER["REQUEST_URI"], $replace);
$filename = preg_replace("/__/", "_", $filename);
$filename = seoFriendly($filename);
return $filename . ".xml";
}
示例7: mkdir_recursive
exit;
}
}
if ($new) {
mkdir_recursive($targetPath, CHMOD_VALUE);
$album = new Album($gallery, $folder);
$album->setShow($_POST['http_publishalbum']);
$album->setTitle(sanitize($_POST['http_albumtitle']));
$album->setOwner($_zp_current_admin_obj->getUser());
$album->save();
}
@chmod($targetPath, CHMOD_VALUE);
$error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile);
if (!$error) {
if (is_valid_image($name) || is_valid_other_type($name)) {
$seoname = seoFriendly($name);
if (strrpos($seoname, '.') === 0) {
$seoname = sha1($name) . $seoname;
}
// soe stripped out all the name.
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
if (file_exists($targetFile)) {
$append = '_' . time();
$seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
$targetFile = $targetPath . '/' . internalToFilesystem($seoname);
}
if (move_uploaded_file($tempFile, $targetFile)) {
@chmod($targetFile, 0666 & CHMOD_VALUE);
$album = new Album($gallery, $folder);
$image = newImage($album, $seoname);
$image->setOwner($_zp_current_admin_obj->getUser());
示例8: copy
/**
* duplicates an article
* @param string $newtitle the title for the new article
*/
function copy($newtitle)
{
$newID = $newtitle;
$id = parent::copy(array('titlelink' => $newID));
if (!$id) {
$newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
$id = parent::copy(array('titlelink' => $newID));
}
if ($id) {
$newobj = new ZenpagePage($newID);
$newobj->setTitle($newtitle);
$newobj->setSortOrder(NULL);
$newobj->setTags($this->getTags());
$newobj->save();
return $newobj;
}
return false;
}
示例9: copy
/**
* duplicates a category
* @param string $newtitle the title for the new category
*/
function copy($newtitle)
{
$newID = $newtitle;
$id = parent::copy(array('titlelink' => $newID));
if (!$id) {
$newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
$id = parent::copy(array('titlelink' => $newID));
}
if ($id) {
$newobj = newCategory($newID);
$newobj->setTitle($newtitle);
$newobj->setSortOrder(NULL);
$newobj->setDateTime(date('Y-m-d H:i:s'));
$newobj->setShow(1);
$newobj->save();
return $newobj;
}
return false;
}
示例10: createPrimealbum
/**
* Creates a "prime" album for the user. Album name is based on the userid
*/
function createPrimealbum()
{
// create his album
$t = 0;
$ext = '';
$filename = str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', seoFriendly($this->getUser()));
while (file_exists(ALBUM_FOLDER_SERVERPATH . '/' . $filename . $ext)) {
$t++;
$ext = '-' . $t;
}
$path = ALBUM_FOLDER_SERVERPATH . '/' . $filename . $ext;
if (@mkdir_recursive($path, CHMOD_VALUE)) {
$album = new Album(new Gallery(), $filename . $ext);
$album->save();
$this->setAlbum($album);
$objects = $this->getObjects();
$objects[] = array('data' => $filename . $ext, 'name' => $filename . $ext, 'type' => 'album');
$this->setObjects($objects);
}
}
示例11: zp_apply_filter
zp_apply_filter('admin_note', 'albums', 'dynamic');
echo "<h1>" . gettext("Create Dynamic Album") . "</h1>\n";
if (isset($_POST['savealbum'])) {
// we fell through, some kind of error
echo "<div class=\"errorbox space\">";
echo "<h2>" . $msg . "</h2>";
echo "</div>\n";
}
$albumlist = array();
genAlbumList($albumlist);
$fields = $search->fieldList;
$words = $search->codifySearchString();
if (isset($_GET['name'])) {
$albumname = sanitize($_GET['name']);
} else {
$albumname = seoFriendly(sanitize_path($words));
$old = '';
while ($old != $albumname) {
$old = $albumname;
$albumname = str_replace('--', '-', $albumname);
}
}
$images = $search->getImages(0);
foreach ($images as $image) {
$folder = $image['folder'];
$filename = $image['filename'];
$imagelist[] = '/' . $folder . '/' . $filename;
}
$subalbums = $search->getAlbums(0);
foreach ($subalbums as $folder) {
getSubalbumImages($folder);
示例12: unzip
/**
* Unzips an image archive
*
* @param file $file the archive
* @param string $dir where the images go
*/
function unzip($file, $dir)
{
//check if zziplib is installed
if (function_exists('zip_open')) {
$zip = zip_open($file);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
// Skip non-images in the zip file.
$fname = zip_entry_name($zip_entry);
$seoname = internalToFilesystem(seoFriendly($fname));
if (Gallery::validImage($seoname) || Gallery::validImageAlt($seoname)) {
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$path_file = str_replace("/", DIRECTORY_SEPARATOR, $dir . '/' . $seoname);
$fp = fopen($path_file, "w");
fwrite($fp, $buf);
fclose($fp);
clearstatcache();
zip_entry_close($zip_entry);
$albumname = substr($dir, strlen(ALBUM_FOLDER_SERVERPATH));
$album = newAlbum($albumname);
$image = newImage($album, $seoname);
if ($fname != $seoname) {
$image->setTitle($fname);
$image->save();
}
}
}
}
zip_close($zip);
}
} else {
require_once dirname(__FILE__) . '/lib-pclzip.php';
$zip = new PclZip($file);
if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
return false;
}
}
return true;
}
示例13: checkFolder
function checkFolder($album, $album_cleaned)
{
global $count, $albumcount;
$subalbums = $album->getAlbums(0);
foreach ($subalbums as $subalbum) {
$obj = newAlbum($subalbum);
cleanAlbum($obj);
}
$folder = $album->name . '/';
$files = $album->getImages(0);
foreach ($files as $filename) {
$seoname = seoFriendly($filename);
if (stripSuffix($seoname) != stripSuffix($filename)) {
$image = newImage($album, $filename);
if ($e = $image->rename($seoname)) {
$error = getE($e, $filename, $seoname);
printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $folder . $filename, $seoname, $error);
echo "<br />\n";
} else {
$image->save();
clearstatcache();
echo ' ';
printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $folder . $filename, $seoname);
echo "<br />\n";
$count++;
if (!$album_cleaned) {
Gallery::clearCache(SERVERCACHE . '/' . $album->name);
if (extensionEnabled('static_html_cache')) {
Gallery::clearCache(SERVERPATH . '/' . STATIC_CACHE_FOLDER);
}
}
}
}
}
}
示例14: checkFolder
function checkFolder($album)
{
global $count, $albumcount;
$subalbums = $album->getAlbums(0);
foreach ($subalbums as $subalbum) {
$obj = newAlbum($subalbum);
cleanAlbum($obj);
}
$folder = $album->name . '/';
$files = $album->getImages(0);
foreach ($files as $filename) {
$seoname = seoFriendly($filename);
if (stripSuffix($seoname) != stripSuffix($filename)) {
$image = newImage($album, $filename);
if ($e = $image->rename($seoname)) {
$error = getE($e, $filename, $seoname);
printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $folder . $filename, $seoname, $error);
echo "<br />\n";
} else {
$image->save();
clearstatcache();
echo ' ';
printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $folder . $filename, $seoname);
echo "<br />\n";
$count++;
}
}
}
}
示例15: publishArticle
/**
*
* Creates the news article
* @param object $obj
*/
protected static function publishArticle($obj, $override = NULL)
{
global $_zp_CMS;
$galleryitem_text = array();
$locale = getOption('locale');
switch ($type = $obj->table) {
case 'albums':
$album = $obj->name;
$dbstring = getOption('galleryArticles_album_text');
$localtext = get_language_string($dbstring);
$galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale));
foreach (generateLanguageList() as $key) {
$languagetext = get_language_string($dbstring, $key);
if ($localtext != $languagetext) {
$galleryitem_text[$key] = sprintf($languagetext, $obj->getTitle($key));
}
}
$ref = '"' . $album . '"';
$title = $folder = $album;
$img = $obj->getAlbumThumbImage();
$class = 'galleryarticles-newalbum';
break;
case 'images':
$album = $obj->album->name;
$image = $obj->filename;
$dbstring = unserialize(getOption('galleryArticles_image_text'));
$localtext = get_language_string($dbstring);
$galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale), $obj->album->getTitle($locale));
foreach (generateLanguageList() as $key => $val) {
$languagetext = get_language_string($dbstring, $key);
if ($localtext != $languagetext) {
$galleryitem_text[$key] = sprintf($localtext, $obj->getTitle($key), $obj->album->getTitle($key));
}
}
$ref = '"' . $album . '" "' . $image . '"';
$folder = $obj->imagefolder;
$title = $folder . '-' . $image;
$img = $obj;
$class = 'galleryarticles-newimage';
break;
default:
//not a gallery object
return;
}
$article = newArticle(seoFriendly('galleryArticles-' . $title));
$article->setTitle(serialize($galleryitem_text));
$imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
$desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>[GALLERYARTICLEDESC ' . $ref . ']</p>';
$article->setContent($desc);
$date = $obj->getPublishDate();
if (!$date) {
$date = date('Y-m-d H:i:s');
}
$article->setDateTime($date);
$article->setLastchange(date('Y-m-d H:i:s'));
$article->setAuthor('galleryArticles');
$article->setLastchangeauthor('galleryArticles');
$article->setShow(true);
$article->save();
if ($override) {
$cat = $override;
} else {
$cat = getOption('galleryArticles_category');
if (getOption('galleryArticles_albumCategory')) {
$catlist = $_zp_CMS->getAllCategories();
foreach ($catlist as $category) {
if ($category['titlelink'] == $folder) {
$cat = $category['titlelink'];
break;
}
}
}
}
$article->setCategories(array($cat));
}