00001 <?php
00002
00015
00016
00017
00018 import('core.Handler');
00019 import('classes.plugins.PluginRegistry');
00020
00021
00022 class CmsHandler extends Handler {
00023 function index( $args ) {
00024 }
00025
00026 function view( $args ) {
00027 if ( count($args) > 0 ) {
00028 $journal = &Request::getJournal();
00029 $journalId = $journal->getJournalId();
00030 $cmsPlugin = &PluginRegistry::getPlugin('generic', 'CmsPlugin');
00031 $templateMgr = &TemplateManager::getManager();
00032
00033 $allContent = $cmsPlugin->getSetting($journalId, 'content');
00034
00035 $cmsPlugin->import('ContentManager');
00036 $contentManager =& new ContentManager();
00037
00038 $content = array();
00039 $headings = array();
00040
00041 $current = $contentManager->cleanurl($args[0]);
00042
00043 $contentManager->parseContents( $headings, $content, $current );
00044
00045
00046
00047 $title = $current;
00048 $cur_array = explode(":", $current);
00049 if ( count($cur_array) > 1 )
00050 $cur_array[1] = $cur_array[0].':'.$cur_array[1];
00051 if ( count($cur_array) > 2 )
00052 $cur_array[2] = $cur_array[0].':'.$cur_array[1].':'.$cur_array[2];
00053 array_pop($cur_array);
00054
00055
00056 $breadcrumbs = array();
00057 foreach ( $headings as $heading ) {
00058 if ( count($cur_array) > 0 && $cur_array[0] == $heading[1] )
00059 $breadcrumbs[] = array(
00060 './'.$heading[1],
00061 $heading[2],
00062 $heading[2] );
00063
00064 elseif ( count($cur_array) > 1 && $cur_array[1] == $heading[1] )
00065 $breadcrumbs[] = array(
00066 './'.$heading[1],
00067 $heading[2],
00068 $heading[2] );
00069
00070 elseif ( count($cur_array) > 2 && $cur_array[2] == $heading[1] )
00071 $breadcrumbs[] = array(
00072 './'.$heading[1],
00073 $heading[2],
00074 $heading[2] );
00075
00076 if ( $heading[1] == $current ) {
00077 $title = $heading[2];
00078 break;
00079 }
00080 }
00081
00082 $theContent = isset($content[$current])?$content[$current]:null;
00083
00084 HookRegistry::call("Plugins::CmsHandler", array($current, &$theContent));
00085
00086
00087 $templateMgr->assign('title', $title);
00088 $templateMgr->assign('content', $theContent);
00089 $templateMgr->assign('headings', $headings);
00090 $templateMgr->assign('cmsPluginToc', $headings);
00091 $templateMgr->assign('pageHierarchy', $breadcrumbs);
00092 $templateMgr->display($cmsPlugin->getTemplatePath().'content.tpl');
00093 }
00094 }
00095 }
00096
00097 ?>