Skip to content

Commit

Permalink
theme-swapping improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
voitto committed Nov 20, 2008
1 parent fadd90c commit 9293772
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 125 deletions.
10 changes: 6 additions & 4 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ env:
site_subtitle:
site_description:

theme: kubrick
theme: prologue-theme

remote_sources:
dbscript: dbscript.net/?apps
Expand All @@ -54,15 +54,17 @@ env:
authentication: email

debug_enabled: true

apps:
- twitter
- identica
- photo
- auction

installed:

installed:

threaded: false

plugins:
- sessions
- validation
Expand Down
11 changes: 5 additions & 6 deletions app/plugins/omb.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ function omb_filter_posts( &$model, &$db ) {

// THREADED MODE

// } elseif (in_array($request->action, array('index','get')) && $model->table == 'posts' && $request->resource == 'posts' && $request->id == 0) {
// $where = array(
// 'parent_id'=>0
// );


} elseif (environment('threaded') && in_array($request->action, array('index','get')) && $model->table == 'posts' && $request->resource == 'posts' && $request->id == 0) {
$where = array(
'parent_id'=>0
);
$model->set_param( 'find_by', $where );
} elseif ($request->action == 'index' && $model->table == 'posts' && $request->resource == 'posts' && $request->id == 0) {
$where = array(
'local'=>1
Expand Down
132 changes: 122 additions & 10 deletions app/plugins/wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,14 @@ function wp_new_user_notification( $userlogin ) {

}
function is_user_logged_in() {


return true;

$id = get_profile_id();

if ($id)
return true;

return false;

}
function wp_clearcookie() {

Expand Down Expand Up @@ -720,6 +725,98 @@ function wp_head() {

//trigger_before( 'admin_head', $current_user, $current_user );


if ($request->resource == "identities")
echo '<script type="text/javascript" src="'.$request->base_url.'resource/jquery-1.2.6.min.js"></script>';
else
echo '<script type="text/javascript" src="'.$request->base_url.'resource/jquery-1.2.1.min.js"></script>';

echo '
<script type="text/javascript" src=" '.$request->base_url.'resource/jquery.corner.js"></script>
<script type="text/javascript" src=" '.$request->base_url.'resource/jquery.flash.js"></script>
<script type="text/javascript" src=" '.$request->base_url.'resource/jquery.jqUploader.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#postfile").jqUploader({
background:"FFFFFF",
barColor:"336699",
allowedExt:"*.avi; *.jpg; *.jpeg; *.mp3; *.mov",
allowedExtDescr: "Movies, Photos and Songs",
validFileMessage: "Click [Upload]",
endMessage: "",
hideSubmit: false
});
});
</script>
<script type="text/javascript">
function show_page(url) {
$("#main").html("<img src=\"resource/jeditable/indicator.gif\">");
$.get(url, function(str) {
$("#main").hide();
$("#main").html(str);
$("#main").slideDown("fast");
});
}
</script>
<?php if (get_profile_id() ) : ?>
<script type="text/javascript">
function setMaxLength() {
var x = document.getElementsByTagName("textarea");
var counter = document.createElement("div");
counter.className = "counter";
for (var i=0;i<x.length;i++) {
if (x[i].getAttribute("maxlength")) {
var counterClone = counter.cloneNode(true);
counterClone.relatedElement = x[i];
counterClone.innerHTML = "<span>0</span>/"+x[i].getAttribute("maxlength");
x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
x[i].relatedElement = counterClone.getElementsByTagName("span")[0];
x[i].onkeyup = x[i].onchange = checkMaxLength;
x[i].onkeyup();
}
}
}
function checkMaxLength() {
var maxLength = this.getAttribute("maxlength");
var currentLength = this.value.length;
if (currentLength > maxLength)
this.relatedElement.className = "toomuch";
else
this.relatedElement.className = "";
this.relatedElement.firstChild.nodeValue = currentLength;
// not innerHTML
}
</script>
';

do_action('wp_head');

if (isset($request->resource) && $request->resource == 'identities' && $request->id > 0) {
Expand Down Expand Up @@ -1139,17 +1236,20 @@ function the_author_ID() {
function the_content( $linklabel ) {
global $the_post,$request,$the_author;

if (!(environment('theme') == 'prologue-theme')) {

echo $the_post->body;
return;

}


$e = $the_post->FirstChild('entries');

$title = $the_post->title;

if (environment('theme') != 'prologue-theme') {

$current_user_id = get_the_author_ID( );
echo prologue_get_avatar( $current_user_id, get_the_author_email( ), 48 );

}


if (strpos($title, 'http') !== false || strpos($title, '@') !== false) {
$title = str_replace("\n"," ",$title);
$expl = explode( " ", $title );
Expand Down Expand Up @@ -1489,6 +1589,8 @@ function apply_filters($tag, $string) {

function current_user_can( $action ) {
global $request;
if ($action == 'publish_posts' && ($request->resource != 'posts' || $request->action != 'index'))
return false;
$id = get_profile_id();
if (isset($request->params['byid']))
$byid = $request->params['byid'];
Expand All @@ -1512,6 +1614,15 @@ function setup_postdata( $post ) {
function dynamic_sidebar() {
global $request;
global $sidebar_done;

if (!$sidebar_done && get_profile_id() && $request->resource == 'identities' && in_array($request->action,array('edit','entry'))) {
if ($request->id == get_profile_id())
render_partial('admin');
$sidebar_done = true;
return true;
}


$blocks = environment('blocks');
if (!empty($blocks) && !$sidebar_done) {
foreach ($blocks as $b) {
Expand All @@ -1531,8 +1642,9 @@ function dynamic_sidebar() {
}
$sidebar_done = true;
}
if (environment('theme') == 'prologue-theme')
echo '<a href="http://openmicroblogger.org"><img src="http://openmicroblogger.org/omb.gif" style="border:none;" alt="openmicroblogger.org" /></a>'."\n";
return true;
//echo '<a href="http://openmicroblogger.org"><img src="http://openmicroblogger.org/omb.gif" style="border:none;" alt="openmicroblogger.org" /></a>'."\n";
}

function single_tag_title( ) {
Expand Down
8 changes: 7 additions & 1 deletion app/views/posts/_entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@
<?php $Post =& $db->model(tableize($request->resource)); $Post->has_one('profile_id:identities'); $Post->find_by('parent_id',$Member->id); ?>
<?php while ($c = $Post->MoveNext()) : ?>
<?php $replyauthor = $c->FirstChild('identities'); ?>
<?php echo "<tr><td><p><font size=\"-1\">".'reply by '.$replyauthor->nickname."&nbsp; ".time_of($c->created)."</font></p></td></tr><tr><td><p>".htmlentities($c->title)."</p><br></td></tr>"; ?>
<tr><td>
<?php
$current_user_id = get_the_author_ID( );
echo prologue_get_avatar( $current_user_id, get_the_author_email( ), 48 );
?>
<?php echo "<p><font size=\"-1\">".'reply by '.$replyauthor->nickname."&nbsp; ".time_of($c->created)."</font></p></td></tr><tr><td><p>".htmlentities($c->title)."</p><br>"; ?>
</td></tr>
<?php endwhile; ?>
</table>
</td>
Expand Down
3 changes: 1 addition & 2 deletions db/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@

$request->routematch();

//print_r($request->activeroute); exit;

//print_r($request->activeroute); echo '<BR><BR>'; print_r($request->params); exit;

/**
* attach functions to aspect crosscuts
Expand Down
4 changes: 3 additions & 1 deletion db/library/dbscript/_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1034,13 +1034,15 @@ function render_theme( $theme ) {

add_include_path($folder);

if (isset($request->action) && !($request->action == 'index')) {
if ($request->resource != 'posts' || (isset($request->action) && !($request->action == 'index'))) {
get_header();
if ($theme == 'prologue-theme')
show_prologue_nav();
echo '<div id="main">'."\n";
content_for_layout();
echo '</div>'."\n";
if ($theme != 'prologue-theme')
get_sidebar();
get_footer();
exit;
}
Expand Down
76 changes: 1 addition & 75 deletions wp-content/themes/prologue-theme/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">

<?php if ($request->resource == 'identities') : ?>
<script type="text/javascript" src="<?php base_url(); ?>resource/jquery-1.2.6.min.js"></script>
<?php else : ?>
<script type="text/javascript" src="<?php base_url(); ?>resource/jquery-1.2.1.min.js"></script>
<?php endif; ?>

<script type="text/javascript" src="<?php base_url(); ?>resource/jquery.corner.js"></script>
<script type="text/javascript" src="<?php base_url(); ?>resource/jquery.flash.js"></script>
<script type="text/javascript" src="<?php base_url(); ?>resource/jquery.jqUploader.js"></script>

<script type="text/javascript">
$(document).ready(function(){
$('#postfile').jqUploader({
background:'FFFFFF',
barColor:'336699',
allowedExt:'*.avi; *.jpg; *.jpeg; *.mp3; *.mov',
allowedExtDescr: 'Movies, Photos and Songs',
validFileMessage: 'Click [Upload]',
endMessage: '',
hideSubmit: false
});
});

</script>




Expand Down Expand Up @@ -120,58 +97,7 @@



<script type="text/javascript">


function show_page(url) {

$("#main").html("<img src='resource/jeditable/indicator.gif'>");

$.get(url, function(str) {
$("#main").hide();
$("#main").html(str);
$("#main").slideDown("fast");
});

}

</script>

<?php if (get_profile_id() ) : ?>

<script type="text/javascript">

function setMaxLength() {
var x = document.getElementsByTagName('textarea');
var counter = document.createElement('div');
counter.className = 'counter';
for (var i=0;i<x.length;i++) {
if (x[i].getAttribute('maxlength')) {
var counterClone = counter.cloneNode(true);
counterClone.relatedElement = x[i];
counterClone.innerHTML = '<span>0</span>/'+x[i].getAttribute('maxlength');
x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

x[i].onkeyup = x[i].onchange = checkMaxLength;
x[i].onkeyup();
}
}
}

function checkMaxLength() {
var maxLength = this.getAttribute('maxlength');
var currentLength = this.value.length;
if (currentLength > maxLength)
this.relatedElement.className = 'toomuch';
else
this.relatedElement.className = '';
this.relatedElement.firstChild.nodeValue = currentLength;
// not innerHTML
}


</script>

</head>
<body onLoad="JavaScript:setMaxLength();">
Expand Down
16 changes: 2 additions & 14 deletions wp-content/themes/prologue-theme/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,8 @@
</span>
</h4>
<div class="postcontent">
<?php
global $the_post;
$e = $the_post->FirstChild('entries');
if ($e->content_type != 'text/html') {
echo "<div class='snap_preview'><p><a href=\"".$request->url_for(array('resource'=>'__'.$the_post->id))."\">";
echo $the_post->title;
echo "</a></p></div>";
} else {
echo "<div class='snap_preview'>";
the_content( __( '(More ...)' ) );
echo "</div>";
}
?>
<?php ; ?>
<?php the_content( __( '(More ...)' ) ); ?>




Expand Down

0 comments on commit 9293772

Please sign in to comment.