/** * 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}"; }
/** * 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'); } } }
/** * 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; }