[cc-commits] [CC SVN] r12612 - in cchost/trunk: cchost_lib cchost_lib/ccextras mixter-files/pages
webmaster at creativecommons.org
webmaster at creativecommons.org
Wed May 13 16:58:07 EDT 2009
Author: fourstones
Date: 2009-05-13 20:58:07 +0000 (Wed, 13 May 2009)
New Revision: 12612
Modified:
cchost/trunk/cchost_lib/cc-file-props.php
cchost/trunk/cchost_lib/cc-page.php
cchost/trunk/cchost_lib/ccextras/cc-content-page.inc
cchost/trunk/mixter-files/pages/about.php
cchost/trunk/mixter-files/pages/artist-spotlight-q-a.php
Log:
added breadcrumbs and page_title to content pages
Modified: cchost/trunk/cchost_lib/cc-file-props.php
===================================================================
--- cchost/trunk/cchost_lib/cc-file-props.php 2009-05-13 19:24:00 UTC (rev 12611)
+++ cchost/trunk/cchost_lib/cc-file-props.php 2009-05-13 20:58:07 UTC (rev 12612)
@@ -71,14 +71,20 @@
$prop_name = array_shift($parts);
$props[ trim($prop_name) ] = trim( join( '=', $parts) );
}
- if( !empty($props['desc']) )
+ $this->_get_wrapped_prop($props,'desc');
+ $this->_get_wrapped_prop($props,'page_title');
+ return $props;
+ }
+
+ function _get_wrapped_prop(&$props,$pt)
+ {
+ if( !empty($props[$pt]) )
{
- if( preg_match("/^_\(['\"](.+)['\"]\)$/",$props['desc'],$m) )
- $props['desc'] = _($m[1]);
+ if( preg_match("/^_\(['\"](.+)['\"]\)$/",$props[$pt],$m) )
+ $props[$pt] = _($m[1]);
}
- return $props;
}
-
+
function _scan_dir( &$match_files, $source, $format_dir, $type, $ret_files, $must_have, &$seen )
{
foreach( $source as $dir )
Modified: cchost/trunk/cchost_lib/cc-page.php
===================================================================
--- cchost/trunk/cchost_lib/cc-page.php 2009-05-13 19:24:00 UTC (rev 12611)
+++ cchost/trunk/cchost_lib/cc-page.php 2009-05-13 20:58:07 UTC (rev 12612)
@@ -102,8 +102,7 @@
if( !empty($title) )
$page->SetTitle($title);
- if( !empty($queryObj->templateProps['breadcrumbs']) )
- $this->_add_template_bread_crumbs($queryObj->templateProps['breadcrumbs'],$page);
+ $page->_add_template_bread_crumbs($queryObj->templateProps);
$dochop = isset($chop) && $chop > 0;
$chop = isset($chop) ? $chop : 25;
$page->PageArg('chop',$chop);
@@ -128,47 +127,6 @@
$result = true;
}
- function _add_template_bread_crumbs($breadcrumbs,&$page)
- {
- $bc = array();
- $args = split(',',$breadcrumbs);
- foreach( $args as $arg )
- {
- $arg = trim($arg);
-
- if( $arg == 'home' )
- {
- $bc[] = array( 'url' => ccl(), 'text' => 'str_home' );
- }
- elseif( $arg == 'user_name' || $arg == 'user' || $arg == 'username')
- {
- global $CC_GLOBALS;
- if( empty($CC_GLOBALS['user_name']) )
- CCUtil::Send404(); // this is bot or a-h
-
- $bc[] = array( 'url' => ccl('people'), 'text' => 'str_people' );
- $bc[] = array( 'url' => ccl('people',$CC_GLOBALS['user_name'] ),
- 'text' => $CC_GLOBALS['user_real_name'] );
- }
- elseif( $arg == 'forum' )
- {
- $bc[] = array( 'url' => ccl('forum'), 'text' => 'str_forum' );
- }
- else
- {
- if( preg_match( '/text\(([^\)]+)\)/', $arg, $m ) )
- {
- $bc[] = array( 'url' => '', 'text' => $m[1] );
- }
- }
- }
-
- if( !empty($bc) )
- {
- $page->AddBreadCrumbs($bc);
- }
- }
-
/**
* Display a file in the client area of the page (wrapper)
*
@@ -303,6 +261,7 @@
$page =& CCPage::GetPage();
else
$page =& $this;
+
if( !($file = $page->GetViewFile($template)) && !preg_match('/\.xml$/',$template) )
{
$file = $page->GetViewFile($template . '.xml');
@@ -315,13 +274,25 @@
}
else
{
- // see notes in CCPage::Show for why this is important
- if( empty($page->vars['page-title']) )
+ require_once('cchost_lib/cc-file-props.php');
+ $fp = new CCFileProps();
+ $props = $fp->GetFileProps($file);
+ if( empty($props['page_title']) )
{
- $contents = file_get_contents($file);
- $page->_check_for_title($contents);
+ // see notes in CCPage::Show for why this is important
+ if( empty($page->vars['page-title']) )
+ {
+ $contents = file_get_contents($file);
+ $page->_check_for_title($contents);
+ }
}
+ else
+ {
+ $page->SetTitle( $props['page_title'] );
+ }
+ $page->_add_template_bread_crumbs($props);
+
$page->_body_template = $file;
}
}
@@ -973,6 +944,71 @@
return $args;
}
+
+ function _add_template_bread_crumbs($props)
+ {
+ if( empty($props['breadcrumbs']) )
+ return;
+
+ $breadcrumbs = $props['breadcrumbs'];
+ $bc = array();
+ $args = split(',',$breadcrumbs);
+ foreach( $args as $arg )
+ {
+ $arg = trim($arg);
+
+ if( $arg == 'home' )
+ {
+ $bc[] = array( 'url' => ccl(), 'text' => 'str_home' );
+ }
+ elseif( $arg == 'user_name' || $arg == 'user' || $arg == 'username')
+ {
+ global $CC_GLOBALS;
+ if( empty($CC_GLOBALS['user_name']) )
+ CCUtil::Send404(); // this is bot or a-h
+
+ $bc[] = array( 'url' => ccl('people'), 'text' => 'str_people' );
+ $bc[] = array( 'url' => ccl('people',$CC_GLOBALS['user_name'] ),
+ 'text' => $CC_GLOBALS['user_real_name'] );
+ }
+ elseif( $arg == 'forum' )
+ {
+ $bc[] = array( 'url' => ccl('forum'), 'text' => 'str_forum' );
+ }
+ elseif( $arg == 'page_title' || $arg == 'page-title'|| $arg == 'title')
+ {
+ $title = $this->GetTitle();
+ if( empty($title) )
+ return; // we're done
+ $bc[] = array( 'url' => cc_current_url(), 'text' => $title );
+ }
+ elseif( $arg == 'topic_title' || $arg == 'topic-title'|| $arg == 'topic')
+ {
+ if( empty($props['topic_type']) || empty($_GET['topic']) )
+ {
+ continue;
+ }
+ $res = cc_query_fmt("dataview=topic_info&f=php&type={$props['topic_type']}&topic={$_GET['topic']}" );
+ if( !empty($res[0]['topic_name']) )
+ {
+ $bc[] = array( 'url' => '', 'text' => $res[0]['topic_name'] );
+ }
+ }
+ else
+ {
+ if( preg_match( '/text\(([^\)]+)\)/', $arg, $m ) )
+ {
+ $bc[] = array( 'url' => '', 'text' => $m[1] );
+ }
+ }
+ }
+
+ if( !empty($bc) )
+ {
+ $this->AddBreadCrumbs($bc);
+ }
+ }
+
}
Modified: cchost/trunk/cchost_lib/ccextras/cc-content-page.inc
===================================================================
--- cchost/trunk/cchost_lib/ccextras/cc-content-page.inc 2009-05-13 19:24:00 UTC (rev 12611)
+++ cchost/trunk/cchost_lib/ccextras/cc-content-page.inc 2009-05-13 20:58:07 UTC (rev 12612)
@@ -40,8 +40,6 @@
$types = CCDatabase::QueryItems('SELECT DISTINCT topic_type FROM cc_tbl_topics');
$new_types[] = _('home');
- $new_types[] = _('sidebar_blurb');
- $new_types[] = _('blog');
$types = array_filter(array_unique(array_merge($types,$new_types)));
$types = array_combine( array_values($types), $types );
$fields['topic_type'] =
@@ -157,7 +155,7 @@
$fields['keep_name'] = array( 'label' => _('URL Follows Title'),
'form_tip' => $tip,
'formatter' => 'checkbox',
- 'value' => '',
+ 'value' => 'on',
'flags' => CCFF_NONE );
}
@@ -176,13 +174,6 @@
'flags' => CCFF_POPULATE );
}
-/*
- $fields['ids'] =
- array( 'label' => _('Topic IDs'),
- 'form_tip' => _('...or you can specify a list of content (topic) ids, separated by commas'),
- 'formatter' => 'textedit',
- 'flags' => CCFF_POPULATE );
-*/
require_once('cchost_lib/cc-template.inc');
$formats = CCTemplateAdmin::GetContentTemplates();
$fields['t'] =
@@ -281,6 +272,12 @@
'formatter' => 'checkbox',
'flags' => CCFF_POPULATE );
+ $fields['show_bread_crumbs'] =
+ array( 'label' => _('Show Bread Crumbs'),
+ 'form_tip' => _('Check this to display a bread crumbs'),
+ 'formatter' => 'checkbox',
+ 'flags' => CCFF_POPULATE );
+
$this->AddFormFields( $fields );
}
}
@@ -520,13 +517,18 @@
ksort($values);
foreach( $values as $K => $V )
{
- if( ($K == 'title') || ($K == 'type') || ($K == 'keep_name') )
+ if( ($K == 'title') || ($K == 'type') || ($K == 'keep_name') )
continue;
$meta .= ' ' . $K . ' = ' . $V . "\n";
}
$meta .= ' topic_type = ' . $values['type'] . "\n";
+ if( !empty($values['show_bread_crumbs']) )
+ {
+ $meta .= " breadcrumbs = home,page_title,topic\n";
+ }
+
$q = 'f=embed';
foreach( array('t','sort','ord','type','limit','paging',) as $K )
{
@@ -541,6 +543,7 @@
$vars .= "\$A['{$K}'] = '" . $values[$K] . "';\n";
}
+
$feed_goo = empty($values['content_feed']) ? '// ' :
"cc_content_feed('datasource=topics&type={$values['type']}&page={$fname}','{$values['title']}','topics');";
@@ -579,12 +582,12 @@
$text .=<<<EOF
type = dynamic_content_page
desc = _('{$values['title']}')
+ page_title = _('{$values['title']}')
{$meta}
[/meta]
*/
{$vars}
\$topic = empty(\$_GET['topic']) ? '' : \$_GET['topic'];
-print "<h1>{$values['title']}</h1>";
{$toc}cc_query_fmt('{$q}&topic=' . \$topic );
{$paging_goo}{$feed_goo}
Modified: cchost/trunk/mixter-files/pages/about.php
===================================================================
--- cchost/trunk/mixter-files/pages/about.php 2009-05-13 19:24:00 UTC (rev 12611)
+++ cchost/trunk/mixter-files/pages/about.php 2009-05-13 20:58:07 UTC (rev 12612)
@@ -4,6 +4,7 @@
[meta]
type = dynamic_content_page
desc = _('Yea, But Is It Legal?')
+ page_title = _('Yea, But Is It Legal?')
content_feed = 0
content_page_box = 0
content_page_columns = 1
@@ -13,9 +14,11 @@
limit =
ord = asc
paging = off
+ show_bread_crumbs = 1
sort = date
t = ccskins/shared/pages/content_page.tpl
topic_type = faq
+ breadcrumbs = home,page_title,topic
[/meta]
*/
@@ -25,7 +28,6 @@
$A['content_page_columns'] = '1';
$topic = empty($_GET['topic']) ? '' : $_GET['topic'];
-print "<h1>Yea, But Is It Legal?</h1>";
cc_query_fmt('f=embed&t=ccskins/shared/pages/content_page.tpl&sort=date&ord=asc&type=faq&limit=&paging=off&topic=' . $topic );
// no paging
//
Modified: cchost/trunk/mixter-files/pages/artist-spotlight-q-a.php
===================================================================
--- cchost/trunk/mixter-files/pages/artist-spotlight-q-a.php 2009-05-13 19:24:00 UTC (rev 12611)
+++ cchost/trunk/mixter-files/pages/artist-spotlight-q-a.php 2009-05-13 20:58:07 UTC (rev 12612)
@@ -2,8 +2,9 @@
This file was generated by ccHost Content Manager
[meta]
- type = dynamic_content_page
- desc = _('Artist Spotlight Q & A')
+ type = dynamic_content_page
+ desc = _('Artist Spotlight Q & A')
+ page_title = _('Artist Spotlight Q & A')
content_feed = 1
content_page_box = 0
content_page_columns = 1
@@ -13,22 +14,24 @@
limit = 1
ord = desc
paging = on
+ show_bread_crumbs = 1
sort = date
t = ccskins/shared/pages/content_page.tpl
topic_type = artist_qa
-
-[/meta]
-*/
+ breadcrumbs = home,page_title,topic
+
+[/meta]
+*/
$A['content_page_box'] = '0';
$A['content_page_width'] = '830px';
$A['content_page_textformat'] = 'format';
$A['content_page_columns'] = '1';
-
-$topic = empty($_GET['topic']) ? '' : $_GET['topic'];
-print "<h1>Artist Spotlight Q & A</h1>";
+
+$topic = empty($_GET['topic']) ? '' : $_GET['topic'];
cc_query_fmt('f=html&limit=query&&noexit=1&nomime=1&t=ccskins/shared/formats/topic_toc_ul.tpl&page=artist-spotlight-q-a&sort=date&ord=desc');
-cc_query_fmt('f=embed&t=ccskins/shared/pages/content_page.tpl&sort=date&ord=desc&type=artist_qa&limit=1&paging=on&topic=' . $topic );
+cc_query_fmt('f=embed&t=ccskins/shared/pages/content_page.tpl&sort=date&ord=desc&type=artist_qa&limit=1&paging=on&topic=' . $topic );
cc_add_content_paging_links($A,'artist_qa',$topic,'desc','artist-spotlight-q-a', '1');
$A['macro_names'][] = 'prev_next_links';
-cc_content_feed('datasource=topics&type=artist_qa&page=artist-spotlight-q-a','Artist Spotlight Q & A','topics');
-?>
\ No newline at end of file
+cc_content_feed('datasource=topics&type=artist_qa&page=artist-spotlight-q-a','Artist Spotlight Q & A','topics');
+?>
+
More information about the cc-commits
mailing list