本文整理汇总了PHP中DataUtil::formatForURL方法的典型用法代码示例。如果您正苦于以下问题:PHP DataUtil::formatForURL方法的具体用法?PHP DataUtil::formatForURL怎么用?PHP DataUtil::formatForURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataUtil
的用法示例。
在下文中一共展示了DataUtil::formatForURL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_id
/**
* Smarty function to generate a valid atom ID for the feed
*
* Example
*
* <id>{id}</id>
*
* @return string the atom ID
*/
function smarty_function_id($params, &$smarty)
{
$baseurl = System::getBaseUrl();
$parts = parse_url($baseurl);
$starttimestamp = strtotime(System::getVar('startdate'));
$startdate = strftime('%Y-%m-%d', $starttimestamp);
$sitename = System::getVar('sitename');
$sitename = preg_replace('/[^a-zA-Z0-9-\\s]/', '', $sitename);
$sitename = DataUtil::formatForURL($sitename);
return "tag:{$parts['host']},{$startdate}:{$sitename}";
}
示例2: importData
/**
* create the new pages and content items from data
*/
private function importData()
{
$this->createRecords();
$items = $this->records;
foreach ($items as $item) {
// create page
$page = array('parentPageId' => (int) $this->pageMap[(int) $item['ppid']], 'level' => $item['level'], 'title' => $item['title'], 'urlname' => DataUtil::formatForURL($item['title']), 'layout' => $item['layouttype'], 'showTitle' => $item['showtitle'], 'views' => $item['views'], 'activeFrom' => $item['activefrom'], 'activeTo' => $item['activeto'], 'active' => $item['active'], 'categoryId' => $this->categoryMap[(int) $item['categoryid']], 'position' => $item['position'], 'setLeft' => $item['setleft'], 'setRight' => $item['setright'], 'language' => $item['language']);
// insert the page
$obj = DBUtil::insertObject($page, 'content_page');
// add item id to pagemap
$this->pageMap[(int) $item['id']] = (int) $obj['id'];
// create the contentitems for this page
$content = array();
if ($item['useheader']) {
$content[] = array('pageId' => $obj['id'], 'areaIndex' => '0', 'position' => '0', 'module' => 'Content', 'type' => 'Heading', 'data' => serialize(array('text' => $item['title'], 'headerSize' => 'h3')));
}
foreach ($item['contentitems'] as $position => $pageParts) {
$content[] = array('pageId' => $obj['id'], 'areaIndex' => $pageParts['areaIndex'], 'position' => $position, 'module' => 'Content', 'type' => $pageParts['contenttype'], 'data' => serialize(array('text' => $pageParts['data'], 'inputType' => $pageParts['inputType'])));
}
// write the items to the dbase
foreach ($content as $contentItem) {
DBUtil::insertObject($contentItem, 'content_content');
}
}
}
示例3: decodeurl
/**
* decode custom url string
*
* @author Philipp Niethammer
* @return bool true if succeded false otherwise
*/
public function decodeurl($args)
{
$suffix = $this->getVar('shorturlsuffix');
$supportedfunctions = array('main', 'list', 'view', 'subpages', 'sitemap', 'extlist', 'categoriesList', 'pagelist');
$argsnum = count($args['vars']);
if (!isset($args['vars'][2]) || empty($args['vars'][2])) {
System::queryStringSetVar('func', 'sitemap');
return true;
}
if (in_array($args['vars'][2], $supportedfunctions)) {
return false;
}
$lastarg = end($args['vars']);
$urlname = '';
if (substr($lastarg, strlen($lastarg) - strlen($suffix)) == $suffix) {
for ($i = 2; $i < $argsnum; $i++) {
if (!empty($urlname)) {
$urlname .= '/';
}
$urlname .= $args['vars'][$i];
}
if (($suffixLen = strlen($suffix)) > 0) {
$urlname = substr($urlname, 0, -$suffixLen);
}
System::queryStringSetVar('func', 'view');
System::queryStringSetVar('name', $urlname);
return true;
}
if (!isset($args['vars'][3]) || empty($args['vars'][3])) {
$mainCategory = CategoryRegistryUtil::getRegisteredModuleCategory('Content', 'content_page', $this->getVar('categoryPropPrimary'), 30);
// 30 == /__SYSTEM__/Modules/Global
//$cats = CategoryUtil::getCategoriesByParentID($mainCategory);
$cats = CategoryUtil::getSubCategories($mainCategory);
foreach ($cats as $cat) {
if ($args['vars'][2] == $cat['name'] || $args['vars'][2] == DataUtil::formatForURL($cat['name'])) {
System::queryStringSetVar('func', 'listpages');
System::queryStringSetVar('cat', $cat['id']);
return true;
}
}
}
for ($i = 2; $i < $argsnum; $i++) {
if (!empty($urlname)) {
$urlname .= '/';
}
$urlname .= $args['vars'][$i];
}
System::queryStringSetVar('func', 'subpages');
System::queryStringSetVar('name', $urlname);
return true;
}