mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Book and Chapter SEF Url support added.
This commit is contained in:
parent
7f1a946562
commit
a790848bdb
@ -17,11 +17,11 @@ $CHAPTER_TEMPLATE['default']['listPages']['item'] = "<li><a href='{CPAGEURL
|
||||
$CHAPTER_TEMPLATE['default']['listPages']['end'] = "</ul>";
|
||||
|
||||
$CHAPTER_TEMPLATE['default']['listChapters']['start'] = "<ul class='page-chapters-list'>";
|
||||
$CHAPTER_TEMPLATE['default']['listChapters']['item'] = "<li><h4>{CHAPTER_NAME}</h4>{PAGES}";
|
||||
$CHAPTER_TEMPLATE['default']['listChapters']['item'] = "<li><h4><a href='{CHAPTER_URL}'>{CHAPTER_NAME}</a></h4>{PAGES}";
|
||||
$CHAPTER_TEMPLATE['default']['listChapters']['end'] = "</ul>";
|
||||
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['start'] = "<ul class='page-chapters-list'>";
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['item'] = "<li><h3>{BOOK_NAME}</h3>{CHAPTERS}";
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['item'] = "<li><h3><a href='{BOOK_URL}'>{BOOK_NAME}</a></h3>{CHAPTERS}";
|
||||
$CHAPTER_TEMPLATE['default']['listBooks']['end'] = "</ul>";
|
||||
|
||||
|
||||
|
@ -30,14 +30,13 @@ class core_page_sef_noid_url extends eUrlConfig
|
||||
),
|
||||
),
|
||||
|
||||
'rules' => array(
|
||||
|
||||
### using only title for pages is risky enough (empty sef for old DB's)
|
||||
'<name:{secure}>' => array('view/index', 'allowVars' => false, 'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||
|
||||
### page list
|
||||
'/' => array('list/index', 'legacyQuery' => '', ),
|
||||
) // rule set array
|
||||
### using only title for pages is risky enough (empty sef for old DB's)
|
||||
'rules' => array(
|
||||
'chapter/<name:{sefsecureOptional}>' => array('chapter/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}', 'parseCallback' => 'chapterIdByTitle'),
|
||||
'book/<name:{sefsecureOptional}>' => array('book/index', 'allowVars' => false, 'mapVars' => array('chapter_id'=>'id', 'chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}', 'parseCallback' => 'chapterIdByTitle'),
|
||||
'<name:{secure}>' => array('view/index', 'allowVars' => false, 'legacyQuery' => '{name}.{page}', 'parseCallback' => 'itemIdByTitle'),
|
||||
'/' => array('list/index', 'legacyQuery' => '', ), // page list
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -73,16 +72,23 @@ class core_page_sef_noid_url extends eUrlConfig
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
|
||||
e107::getMessage()->addDebug('name = '.$name);
|
||||
e107::getMessage()->addDebug(print_r($request,true));
|
||||
e107::getAdminLog()->toFile('page_sef_noid_url');
|
||||
// e107::getMessage()->addDebug('name = '.$name);
|
||||
// e107::getMessage()->addDebug(print_r($request,true));
|
||||
// e107::getAdminLog()->toFile('page_sef_noid_url');
|
||||
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name)) return;
|
||||
elseif(!$name || is_numeric($name))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("One of your pages is missing a SEF URL value");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
@ -94,7 +100,52 @@ class core_page_sef_noid_url extends eUrlConfig
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't find a page with a SEF URL value of '".$name."'");
|
||||
}
|
||||
$request->setRequestParam('name', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* chapter/index and book/index by name callback
|
||||
* @param eRequest $request
|
||||
*/
|
||||
public function chapterIdByTitle(eRequest $request)
|
||||
{
|
||||
$name = $request->getRequestParam('name');
|
||||
|
||||
if(($id = $request->getRequestParam('id')))
|
||||
{
|
||||
$request->setRequestParam('name', $id);
|
||||
return;
|
||||
}
|
||||
elseif(!$name || is_numeric($name))
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("One of your page-chapters is missing a SEF URL value");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = e107::getDb('url');
|
||||
$name = e107::getParser()->toDB($name);
|
||||
|
||||
if($sql->select('page_chapters', 'chapter_id', "chapter_sef='{$name}'"))
|
||||
{
|
||||
$name = $sql->fetch();
|
||||
$request->setRequestParam('id', $name['chapter_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ADMIN)
|
||||
{
|
||||
e107::getMessage()->addError("Couldn't find a book or chapter with a SEF URL value of '".$name."'");
|
||||
}
|
||||
$request->setRequestParam('id', 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,8 +32,10 @@ class core_page_sef_url extends eUrlConfig
|
||||
|
||||
'rules' => array(
|
||||
### using only title for pages is risky enough (non-unique title, possible bad characters)
|
||||
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
|
||||
'<id:{number}>/<name:{sefsecureOptional}>' => array('view/index', 'legacyQuery' => '{id}.{page}', ),
|
||||
'chapter/<id:{number}>/<name:{sefsecureOptional}>' => array('chapter/index', 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'ch={id}' ),
|
||||
'book/<id:{number}>/<name:{sefsecureOptional}>' => array('book/index', 'mapVars' => array('chapter_id'=>'id','chapter_sef'=>'name'), 'legacyQuery' => 'bk={id}' ),
|
||||
|
||||
### page list
|
||||
'/' => array('list/index', 'legacyQuery' => '', ),
|
||||
) // rule set array
|
||||
|
@ -2732,12 +2732,14 @@ class e_parser
|
||||
{
|
||||
return $this->toGlyph($icon);
|
||||
}
|
||||
|
||||
if($icon[0] == '{')
|
||||
|
||||
if(strpos($icon,'e_MEDIA')!==FALSE)
|
||||
{
|
||||
// $path = $this->replaceConstants($icon,'full');
|
||||
$path = $this->thumbUrl($icon);
|
||||
|
||||
}
|
||||
elseif($icon[0] == '{')
|
||||
{
|
||||
$path = $this->replaceConstants($icon,'full');
|
||||
}
|
||||
elseif($legacyPath)
|
||||
{
|
||||
|
5
page.php
5
page.php
@ -17,6 +17,7 @@ e107::coreLan('page');
|
||||
|
||||
$e107CorePage = new pageClass(false);
|
||||
|
||||
|
||||
// Important - save request BEFORE any output (header footer) - used in navigation menu
|
||||
if(!e_QUERY)
|
||||
{
|
||||
@ -196,7 +197,7 @@ class pageClass
|
||||
'BOOK_ICON' => $this->chapterIcon($row['chapter_icon']),
|
||||
'BOOK_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
|
||||
'CHAPTERS' => $this->listChapters(intval($row['chapter_id'])),
|
||||
'BOOK_URL' => e_BASE."page.php?bk=".intval($row['chapter_id']) // FIXME SEF-URL
|
||||
'BOOK_URL' => e107::getUrl()->create('page/book/index', $row,'allow=chapter_id,chapter_sef') // e_BASE."page.php?bk=".intval($row['chapter_id']) // FIXME SEF-URL
|
||||
);
|
||||
|
||||
$text .= $tp->simpleParse($template['item'],$var);
|
||||
@ -262,7 +263,7 @@ class pageClass
|
||||
'CHAPTER_ICON' => $this->chapterIcon($row['chapter_icon']),
|
||||
'CHAPTER_DESCRIPTION' => $tp->toHtml($row['chapter_meta_description'],true,'BODY'),
|
||||
'PAGES' => $tmp['text'],
|
||||
'CHAPTER_URL' => e_BASE."page.php?ch=".intval($row['chapter_id']) // FIXME SEF-URL
|
||||
'CHAPTER_URL' => e107::getUrl()->create('page/chapter/index', $row,'allow=chapter_id,chapter_sef') // e_BASE."page.php?ch=".intval($row['chapter_id']) // FIXME SEF-URL
|
||||
);
|
||||
|
||||
$text .= $tp->simpleParse($template['item'],$var);
|
||||
|
Loading…
x
Reference in New Issue
Block a user