Skip to content

Commit

Permalink
added p2 theme
Browse files Browse the repository at this point in the history
  • Loading branch information
voitto committed Mar 25, 2009
1 parent 163eb42 commit 44b9949
Show file tree
Hide file tree
Showing 40 changed files with 5,603 additions and 8 deletions.
133 changes: 133 additions & 0 deletions app/omb/controllers/posts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?php


function get( &$vars ) {
extract( $vars );
switch ( count( $collection->members )) {
case ( 1 ) :
if ($request->id && $request->entry_url())
render( 'action', 'entry' );
default :
render( 'action', 'index' );
}
}


function post( &$vars ) {
extract( $vars );
$resource->insert_from_post( $request );
header_status( '201 Created' );
redirect_to( $request->base );
}


function put( &$vars ) {
extract( $vars );
$resource->update_from_post( $request );
header_status( '200 OK' );
redirect_to( $request->resource );
}


function delete( &$vars ) {
extract( $vars );
$resource->delete_from_post( $request );
header_status( '200 OK' );
redirect_to( $request->resource );
}


function _doctype( &$vars ) {
// doctype controller
}



function index( &$vars ) {
extract( $vars );
$theme = environment('theme');
$blocks = environment('blocks');
$atomfeed = $request->feed_url();
return vars(
array(
&$blocks,
&$profile,
&$collection,
&$atomfeed,
&$theme
),
get_defined_vars()
);
}


function _index( &$vars ) {
// index controller returns
// a Collection of recent entries
extract( $vars );
return vars(
array( &$collection, &$profile ),
get_defined_vars()
);
}


function _entry( &$vars ) {
// entry controller returns
// a Collection w/ 1 member entry
extract( $vars );
$Member = $collection->MoveNext();
$Entry = $Member->FirstChild( 'entries' );
return vars(
array( &$collection, &$Member, &$Entry, &$profile ),
get_defined_vars()
);
}


function _new( &$vars ) {
extract( $vars );
$model =& $db->get_table( $request->resource );
$Member = $model->base();
return vars(
array( &$Member, &$profile ),
get_defined_vars()
);
}


function _edit( &$vars ) {
extract( $vars );
$Member = $collection->MoveFirst();
$Entry = $Member->FirstChild( 'entries' );
return vars(
array( &$Member, &$Entry, &$profile ),
get_defined_vars()
);
}


function _remove( &$vars ) {
extract( $vars );
$Member = $collection->MoveFirst();
$Entry = $Member->FirstChild( 'entries' );
return vars(
array( &$Member, &$Entry, &$profile ),
get_defined_vars()
);
}


function _block( &$vars ) {

extract( $vars );
return vars(
array(
&$Entry,
&$collection
),
get_defined_vars()
);

}

4 changes: 3 additions & 1 deletion app/omb/plugins/omb.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

global $request,$omb_routes,$db;
global $request,$omb_routes,$db,$ombversion;

$ombversion = "0.3.0";

define( OMB_VERSION, 'http://openmicroblogging.org/protocol/0.1' );
define( OAUTH_VERSION, 'http://oauth.net/core/1.0' );
Expand Down
82 changes: 76 additions & 6 deletions app/omb/plugins/wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,40 @@

}

function wp_create_nonce($action = -1) {
return wp_get_current_user();
}

function post_password_required() {
return false;
}

function wp_list_comments() {
echo "";
}

function cancel_comment_reply_link() {
echo "";
}

function comment_id_fields() {
echo "";
}

function get_the_tags( $id = 0 ) {
return null;
}


function get_the_id() {
global $id;
return $id;
}

function is_front_page() {
return true;
}

function allowed_tags() {
return true;
}
Expand Down Expand Up @@ -282,6 +316,18 @@ function query($query) {
if (!($pos === false))
return true;
global $db;

$pos = strpos($query,"post_status");
if (!($pos === false)) {
global $posts,$request;
if ($request->action == 'index')
get_posts_init();
$set = array();
foreach($posts as $p=>$o) {
$set[] = $p->id;
}
return $set;
}

if ( preg_match("/^\\s*(delete) /i",$query) )
$query = str_replace("LIMIT 1","",$query);
Expand Down Expand Up @@ -365,13 +411,17 @@ function add_management_page( $page,$menu,$access,$file,$func='',$url='' ) {
}

function balanceTags() {

echo "";
}

function query_posts() {
// meh
}

function post_class() {
echo "";
}

function get_bloginfo( $var ) {
global $blogdata;
if (in_array($var,array('wpurl')))
Expand All @@ -390,7 +440,7 @@ function add_option( $opt, $newval ) {
if (!(class_exists('WpPost'))) {
class WpPost {
var $post_password = "";
var $comment_status = "open";
var $comment_status = "closed";
function WpPost() {
}
}
Expand Down Expand Up @@ -1293,6 +1343,12 @@ function get_avatar( $current_user_id, $pixels ) {
if (!isset($the_post->id) || ($the_author->id == $p->id))
$avatar = $p->avatar;
}
if (!(environment('theme') == 'P2'))
return '
<img alt=\'\' src=\''.$avatar.'\'
class=\'avatar avatar-48\' height=\'48\' width=\'48\' />
';
if (!(empty($avatar)))
return '<a href="'.$the_author->profile.'"><img alt="avatar" src="' . $avatar . '" style="width:'.$pixels.'px;height:'.$pixels.'px;" class="avatar" /></a>';
}
Expand Down Expand Up @@ -1358,12 +1414,12 @@ function the_content( $linklabel ) {

$title = $the_post->title;

if (environment('theme') != 'prologue-theme') {
if (!in_array(environment('theme'),array('p2','prologue-theme'))) {

$current_user_id = get_the_author_ID( );
if (function_exists('prologue_get_avatar'))
echo prologue_get_avatar( $current_user_id, get_the_author_email( ), 48 );
return;

}


Expand Down Expand Up @@ -1572,12 +1628,23 @@ function add_custom_image_header( $var, $name ) {
return false;
}

function edit_post_link( $post ) {
function get_edit_post_link( &$post ) {
global $the_post,$request;
if (!isset($the_post->id))
return "";
return $request->url_for(array(
'resource' => 'posts',
'id' => $the_post->id,
'action' => 'edit'
));
}

function edit_post_link( &$post ) {
global $the_post,$request;
if (!isset($the_post->id))
return;
if ($the_post->profile_id == get_profile_id() || get_profile_id() == 1)
echo "<a href=\"".$request->url_for(array(
return "<a href=\"".$request->url_for(array(
'resource' => 'posts',
'id' => $the_post->id,
'action' => 'edit'
Expand Down Expand Up @@ -1652,6 +1719,9 @@ function comments_popup_link( $var1, $var2, $var3 ) {
return;
}

if ($theme == 'p2')
return "";

echo "|&nbsp;<a href=\"JavaScript:add_comment('addcomment-$the_post->id')";
echo "\">comment</a><div id=\"addcomment-$the_post->id\"></div>";

Expand Down
2 changes: 1 addition & 1 deletion db/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@

// authenticate yourself without OpenID

//test_log_in();
test_log_in();

function test_log_in() {
$person_id = 1;
Expand Down
Loading

0 comments on commit 44b9949

Please sign in to comment.