From a4b44d0684c8b85e0fc46a6e5c38d011f8318ae4 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 21 Jul 2009 23:28:12 -0700 Subject: [PATCH] #94 #69 #23 #27 #58 --- README | 5 +- app/config/config.yml | 14 +- app/omb/controllers/admin.php | 20 +- app/omb/controllers/identities.php | 56 +++-- app/omb/controllers/posts.php | 71 +++++- app/omb/models/Page.php | 2 + app/omb/models/Thumbnail.php | 35 +++ app/omb/views/admin/index.html | 11 + app/omb/views/pages/_block.js | 33 --- app/omb/views/pages/_edit.html | 39 ---- app/omb/views/pages/_entry.html | 345 ----------------------------- app/omb/views/pages/_entry.wml | 14 -- app/omb/views/pages/_index.atom | 9 - app/omb/views/pages/_index.html | 38 ---- app/omb/views/pages/_index.wml | 18 -- app/omb/views/pages/_new.html | 76 ------- app/omb/views/pages/_remove.html | 32 --- app/omb/views/posts/_pagelist.html | 24 ++ app/omb/views/posts/_pagenew.html | 53 +++++ app/omb/views/posts/_pagespan.html | 21 ++ db/library/dbscript/_functions.php | 67 +++++- db/library/dbscript/cookie.php | 2 + db/library/dbscript/mapper.php | 18 +- db/library/dbscript/model.php | 13 +- db/library/dbscript/view.php | 2 + wp-content/language/eng.php | 5 +- wp-content/language/ger.php | 1 + wp-content/themes/p2/footer.php | 2 +- 28 files changed, 389 insertions(+), 637 deletions(-) create mode 100644 app/omb/models/Thumbnail.php delete mode 100755 app/omb/views/pages/_block.js delete mode 100755 app/omb/views/pages/_edit.html delete mode 100755 app/omb/views/pages/_entry.html delete mode 100755 app/omb/views/pages/_entry.wml delete mode 100755 app/omb/views/pages/_index.atom delete mode 100755 app/omb/views/pages/_index.html delete mode 100755 app/omb/views/pages/_index.wml delete mode 100755 app/omb/views/pages/_new.html delete mode 100755 app/omb/views/pages/_remove.html create mode 100644 app/omb/views/posts/_pagelist.html create mode 100644 app/omb/views/posts/_pagenew.html create mode 100644 app/omb/views/posts/_pagespan.html diff --git a/README b/README index ce44469..d6a4e82 100755 --- a/README +++ b/README @@ -223,9 +223,12 @@ OTHER DOCUMENTATION The /app/omb/views/categories/_block.js file can be edited to change this setting. At the top of this file the $category_count variable is set to 10 by default. +2. login timeout can be set by changing "cookielife" in config.yml +3. creating a Contact Page/Impressum/About page: as an administrator you will have an app called "Pages" + use this app to add new pages, links to these will appear in the footer of your P2-themed site - +4. to change the allowed file-types for uploads, in config.yml is the "upload_types" list diff --git a/app/config/config.yml b/app/config/config.yml index 59af714..88f77a0 100755 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -80,6 +80,7 @@ env: - streams - translate - facebook + - pages installed: - password @@ -88,6 +89,7 @@ env: - identica - translate - facebook + - pages boot: omb @@ -146,7 +148,7 @@ env: ldap_user_field: ping_server: http://dejafeed.com/?submit - + blocks: -pages -categories @@ -159,6 +161,16 @@ env: duration : 0 location : uploads + cookielife: 1209600 + + upload_types: + -png + -gif + -jpg + -mp3 + -mov + -avi + content_types: - 0: id : xhtml diff --git a/app/omb/controllers/admin.php b/app/omb/controllers/admin.php index ca4cb8d..400cde6 100755 --- a/app/omb/controllers/admin.php +++ b/app/omb/controllers/admin.php @@ -144,6 +144,21 @@ function index( &$vars ) { } $n2url = $request->url_for(array('resource'=>'settings','id'=>$n2mode->id,'action'=>'put')); $n2entry = $n2mode->FirstChild('entries'); + + // n3mode = image upload thumbnail size + $n3mode = $Setting->find_by(array('name'=>'config.env.max_pixels','profile_id'=>get_profile_id())); + if (!$n3mode) { + $n3mode = $Setting->base(); + $n3mode->set_value('profile_id',get_profile_id()); + $n3mode->set_value('person_id',get_person_id()); + $n3mode->set_value('name','config.env.max_pixels'); + $n3mode->set_value('value',200); + $n3mode->save_changes(); + $n3mode->set_etag(); + $n3mode = $Setting->find($n3mode->id); + } + $n3url = $request->url_for(array('resource'=>'settings','id'=>$n3mode->id,'action'=>'put')); + $n3entry = $n3mode->FirstChild('entries'); return vars( array( @@ -165,7 +180,10 @@ function index( &$vars ) { &$n2mode, &$n2url, &$n2entry, - &$n2list + &$n2list, + &$n3mode, + &$n3url, + &$n3entry ), get_defined_vars() ); diff --git a/app/omb/controllers/identities.php b/app/omb/controllers/identities.php index aeb1f03..b7bc7d8 100755 --- a/app/omb/controllers/identities.php +++ b/app/omb/controllers/identities.php @@ -2,32 +2,36 @@ -function validate_identities_photo( $value ) { + + +before_filter('resize_uploaded_image','pre_insert'); +before_filter('resize_uploaded_image','pre_update'); + +function resize_uploaded_image( &$rec, &$db ) { + + // this happens before validate_identities_photo + if (!(is_upload('identities','photo'))) - return true; + return; + $size = filesize($_FILES['identity']['tmp_name']['photo']); + if (!$size || $size > 409600) { if (file_exists($_FILES['identity']['tmp_name']['photo'])) unlink($_FILES['identity']['tmp_name']['photo']); trigger_error( "That photo is too big. Please find one that is smaller than 400K.", E_USER_ERROR ); } - if (!is_jpg($_FILES['identity']['tmp_name']['photo'])) - trigger_error( "Sorry for the trouble, but your photo must be a JPG file.", E_USER_ERROR ); - return true; -} - - -before_filter('resize_uploaded_jpg','pre_insert'); -before_filter('resize_uploaded_jpg','pre_update'); - -function resize_uploaded_jpg( &$rec, &$db ) { - if (!(is_upload('identities','photo'))) - return; + $upl = $_FILES['identity']['tmp_name']['photo']; + + $ext = '.'.type_of_image($upl); - $orig = $rec->attributes['photo']; - $newthumb = tempnam( "/tmp", "new".$rec->id.".jpg" ); - photoCreateCropThumb( $newthumb, $orig, 96 ); + if (!$ext) + trigger_error( "Sorry for the trouble, but your photo must be a JPG, PNG or GIF file.", E_USER_ERROR ); + + $orig = $_FILES['identity']['tmp_name']['photo']; + $newthumb = tempnam( "/tmp", "new".$rec->id.$ext ); + photoCreateCropThumb( $newthumb, $orig, 96, 100, $upl ); $rec->attributes['photo'] = $newthumb; } @@ -174,17 +178,31 @@ function put( &$vars ) { if (is_upload('identities','photo')) { $sql = "SELECT photo FROM ".$prefix."identities WHERE id = ".$db->escape_string($request->id); $result = $db->get_result($sql); + + $upl = $_FILES['identity']['tmp_name']['photo']; + + $ext = '.'.type_of_image($upl); + + if (!$ext) + trigger_error( "Sorry for the trouble, but your photo must be a JPG, PNG or GIF file.", E_USER_ERROR ); + + $content_type = type_of($ext); + if ($blobval = $db->result_value($result,0,"photo")) - $rec->set_value( 'avatar', $request->url_for(array('resource'=>"_".$rec->id)) . ".jpg" ); + $rec->set_value( 'avatar', $request->url_for(array('resource'=>"_".$rec->id)) . $ext ); elseif (exists_uploads_blob( 'identities',$rec->id )) - $rec->set_value( 'avatar', $request->url_for(array('resource'=>"_".$rec->id)) . ".jpg" ); + $rec->set_value( 'avatar', $request->url_for(array('resource'=>"_".$rec->id)) . $ext ); else $rec->set_value( 'avatar', '' ); if (empty($rec->profile)) $rec->set_value( 'profile', $request->url_for(array('resource'=>"_".$rec->id))); if (empty($rec->profile_url)) $rec->set_value( 'profile_url', $request->url_for(array('resource'=>"".$rec->nickname))); + $rec->save_changes(); + + $atomentry = $Identity->set_metadata($rec,$content_type,$rec->table,'id'); + } broadcast_omb_profile_update(); diff --git a/app/omb/controllers/posts.php b/app/omb/controllers/posts.php index 8562a3c..a7a6d6c 100644 --- a/app/omb/controllers/posts.php +++ b/app/omb/controllers/posts.php @@ -40,6 +40,17 @@ function post( &$vars ) { $atomentry = $Post->set_metadata($rec,$content_type,$table,'id'); $Post->set_categories($rec,$request,$atomentry); if ((is_upload('posts','attachment'))) { + + $upload_types = environment('upload_types'); + + if (!$upload_types) + $upload_types = array('jpg','jpeg','png','gif'); + + $ext = extension_for( type_of($_FILES[strtolower(classify($table))]['name']['attachment'])); + + if (!(in_array($ext,$upload_types))) + trigger_error('Sorry, this site only allows the following file types: '.implode(',',$upload_types), E_USER_ERROR); + $url = $request->url_for(array( 'resource'=>'posts', 'id'=>$rec->id @@ -51,10 +62,27 @@ function post( &$vars ) { else $rec->set_value('title',$title." ".$url); $rec->save_changes(); + + $tmp = $_FILES[strtolower(classify($table))]['tmp_name']['attachment']; + + if (is_jpg($tmp)) { + $thumbsize = environment('max_pixels'); + $Thumbnail =& $db->model('Thumbnail'); + $t = $Thumbnail->base(); + $newthumb = tempnam( "/tmp", "new".$rec->id.".jpg" ); + resize_jpeg($tmp,$newthumb,$thumbsize); + $t->set_value('target_id',$atomentry->id); + $t->save_changes(); + update_uploadsfile( 'thumbnails', $t->id, $newthumb ); + $t->set_etag(); + } + } + trigger_after( 'insert_from_post', $Post, $rec ); header_status( '201 Created' ); redirect_to( $request->base ); + } @@ -262,7 +290,7 @@ function _oembed( &$vars ) { $url = $request->url_for(array( 'resource'=>'posts', 'id'=>$id, - 'action'=>'attachment.'.extension_for($e->content_type) + 'action'=>'preview' )); return vars( @@ -329,3 +357,44 @@ function _apps( &$vars ) { get_defined_vars() ); } + + +function preview( &$vars ) { + extract($vars); + $p = $Post->find($request->id); + $e = $p->FirstChild('entries'); + $t = $Thumbnail->find_by('target_id',$e->id); + if ($t) { + $request->set_param('resource','thumbnails'); + $request->set_param('id',$t->id); + render_blob($t->attachment,extension_for($e->content_type)); + } else { + render_blob($p->attachment,extension_for($e->content_type)); + } +} + +function _pagelist( &$vars ) { + extract( $vars ); + return vars( + array( &$collection, &$profile ), + get_defined_vars() + ); +} + +function _pagenew( &$vars ) { + extract( $vars ); + $model =& $db->get_table( $request->resource ); + $Member = $model->base(); + return vars( + array( &$Member, &$profile ), + get_defined_vars() + ); +} + +function _pagespan( &$vars ) { + extract( $vars ); + return vars( + array( &$collection, &$profile ), + get_defined_vars() + ); +} diff --git a/app/omb/models/Page.php b/app/omb/models/Page.php index 3b85b4d..016f3e2 100755 --- a/app/omb/models/Page.php +++ b/app/omb/models/Page.php @@ -56,6 +56,8 @@ function Page() { $this->let_access( 'all:administrators' ); + $this->use_templates_from( 'posts' ); + } } diff --git a/app/omb/models/Thumbnail.php b/app/omb/models/Thumbnail.php new file mode 100644 index 0000000..372e9a3 --- /dev/null +++ b/app/omb/models/Thumbnail.php @@ -0,0 +1,35 @@ +file_field( 'attachment' ); + + $this->time_field( 'created' ); + $this->time_field( 'modified' ); + + $this->int_field( 'target_id' ); + + $this->int_field( 'entry_id' ); + + $this->auto_field( 'id' ); + + // relationships + + $this->has_one( 'entry' ); + + // permissions + + $this->let_read( 'all:everyone' ); + $this->let_access( 'all:administrators' ); + + $this->set_hidden(); + + } + +} + +?> \ No newline at end of file diff --git a/app/omb/views/admin/index.html b/app/omb/views/admin/index.html index 8852cf0..752ec38 100755 --- a/app/omb/views/admin/index.html +++ b/app/omb/views/admin/index.html @@ -187,6 +187,8 @@ + + }); // ]]> @@ -246,6 +248,15 @@

Max Upload Size (in Megabytes):

+ + +

Preview Image Size (in pixels):

+ + +

value; ?>

+ + + diff --git a/app/omb/views/pages/_block.js b/app/omb/views/pages/_block.js deleted file mode 100755 index 867c6f2..0000000 --- a/app/omb/views/pages/_block.js +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/omb/views/pages/_edit.html b/app/omb/views/pages/_edit.html deleted file mode 100755 index 09dc870..0000000 --- a/app/omb/views/pages/_edit.html +++ /dev/null @@ -1,39 +0,0 @@ -resource)); - -?> - -
-
- - - - - - - - - - - - - - - - - - - - - - - -
- -
Title
Body
Attachment
- -
-
-
\ No newline at end of file diff --git a/app/omb/views/pages/_entry.html b/app/omb/views/pages/_entry.html deleted file mode 100755 index bd726ae..0000000 --- a/app/omb/views/pages/_entry.html +++ /dev/null @@ -1,345 +0,0 @@ -resource)); - -?> - - - - - - - - - - - - -attachment) : ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -get_table('identities'); - - $Person =& $db->get_table('people'); - - $p = $Person->find(get_person_id()); - - if ($p) - $ident = $p->FirstChild('identities'); - else - $ident = $Identity->base(); - - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- title ?> -

-
- body ?> -

- - content_type) == 'mp3') : ?> - - - - - - - - - - content_type) == 'jpg') : ?> - - - - content_type) == 'mov') : ?> - - - - - - content_type) == 'avi') : ?> - - - - - - - - - - -

- profile_id); print $author->nickname." ".time_of($Member->created); ?> -

-



-

- - - model(tableize($request->resource)); $Post->has_one('profile_id:identities'); $Post->find_by('parent_id',$Member->id); ?> - MoveNext()) : ?> - FirstChild('identities'); ?> - "; ?> - -

".'Reply by '.$replyauthor->nickname."  ".time_of($c->created)."

".htmlentities($c->title)."


-
-model('Review'); $Review->has_one('profile_id:identities'); $Review->find_by('target_id',$Entry->id); ?> - -MoveNext()) : ?> -FirstChild('identities'); ?> - - -rating) : ?> -* - - - - - - - -".$reviewer->nickname." ".time_of($r->created)."
"; ?> - - - -
-

-



-

:

- -
- - - - - - -
- - -
-

:

- - - - -
- - - - - - - - - -* - - -
- - - - - - - - - - -
- - - - - - - - - - -

-



-
- -

- - -

-



-

- - -

:

- - - -

given_name." ".$member_ident->url.""; ?>

- - - -

-



-
- - - - -
-
-

Bookmark this:

-Bookmark to Blinklist! -Bookmark to Blogmarks! -Bookmark to Del.icio.us! -Bookmark to De.lirio.us! -Bookmark to Digg! -Bookmark to Fark! -Bookmark to Furl! -Bookmark to Ma.gnolia! -Bookmark to Newsvine! -Bookmark to Reddit! -Bookmark to Scuttle! -Bookmark to Simpy! -Bookmark to Spurl! -Bookmark to StumbleUpon! -Bookmark to Technorati! -Bookmark to Yahoo! My Web! - - - - - -

-



-
\ No newline at end of file diff --git a/app/omb/views/pages/_entry.wml b/app/omb/views/pages/_entry.wml deleted file mode 100755 index 992be83..0000000 --- a/app/omb/views/pages/_entry.wml +++ /dev/null @@ -1,14 +0,0 @@ - -

- title; ?> -

-

- body; ?> -

-

- contributor; ?> -

-

- created); ?> -

-
diff --git a/app/omb/views/pages/_index.atom b/app/omb/views/pages/_index.atom deleted file mode 100755 index 320aa74..0000000 --- a/app/omb/views/pages/_index.atom +++ /dev/null @@ -1,9 +0,0 @@ -MoveNext() ) : ?> - - created); ?> - $collection->resource, 'id'=>$Member->id )); ?> - - <?php print $Member->title; ?> - body.""); ?> - - \ No newline at end of file diff --git a/app/omb/views/pages/_index.html b/app/omb/views/pages/_index.html deleted file mode 100755 index 25a8211..0000000 --- a/app/omb/views/pages/_index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - MoveNext() ) : ?> - - - - - - - - - - - - - - - - -
-

- title; ?> -

-
-

- body; ?> -

-
-
-
-
-
- - - diff --git a/app/omb/views/pages/_index.wml b/app/omb/views/pages/_index.wml deleted file mode 100755 index 3513c1e..0000000 --- a/app/omb/views/pages/_index.wml +++ /dev/null @@ -1,18 +0,0 @@ - -MoveNext() ) : ?> - -

- title; ?> -

-

- body; ?> -

-

- contributor; ?> -

-

- created; ?> -

-
- - \ No newline at end of file diff --git a/app/omb/views/pages/_new.html b/app/omb/views/pages/_new.html deleted file mode 100755 index 2f82eac..0000000 --- a/app/omb/views/pages/_new.html +++ /dev/null @@ -1,76 +0,0 @@ -resource)); - -?> - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - model('Category'); - //$Category->find(); - - $p = get_profile(); -?> - - - - - - - - - - - - - - - -

 

Title
Body
Choose File

  • jpeg photo
  • avi or mov (quicktime) movie
  • mp3 audio

 

Categories

 


-family_name; ?>"> -
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/app/omb/views/pages/_remove.html b/app/omb/views/pages/_remove.html deleted file mode 100755 index 264103e..0000000 --- a/app/omb/views/pages/_remove.html +++ /dev/null @@ -1,32 +0,0 @@ -resource)); - -?> - - -
-
- - - - - - - - - - - - - - -
- -




title; ?>

- -
-
-
- diff --git a/app/omb/views/posts/_pagelist.html b/app/omb/views/posts/_pagelist.html new file mode 100644 index 0000000..86735b6 --- /dev/null +++ b/app/omb/views/posts/_pagelist.html @@ -0,0 +1,24 @@ + + + + + + MoveNext()) : ?> + + title; ?> + + + "; ?> + + + + + members) == 0 ) print "no entries found"; ?> +
+
+ + + New resource); ?> + + + \ No newline at end of file diff --git a/app/omb/views/posts/_pagenew.html b/app/omb/views/posts/_pagenew.html new file mode 100644 index 0000000..61443f7 --- /dev/null +++ b/app/omb/views/posts/_pagenew.html @@ -0,0 +1,53 @@ +resource)); + +?> + + + + + + +
+
+ + + + + + + + + + + + + + + + + + +
+family_name; ?>"> + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/app/omb/views/posts/_pagespan.html b/app/omb/views/posts/_pagespan.html new file mode 100644 index 0000000..fbba114 --- /dev/null +++ b/app/omb/views/posts/_pagespan.html @@ -0,0 +1,21 @@ +model('Page'); + $Page->find(); + if (!($Page->rowcount() > 0)) + return; + + echo " | "; + + $pipe = ''; + while ($p = $Page->MoveNext()) { + echo $pipe; + echo ''; + echo $p->title; + echo ''; + $pipe = ' | '; + } + echo ""; + +?> \ No newline at end of file diff --git a/db/library/dbscript/_functions.php b/db/library/dbscript/_functions.php index c0ccadc..65b7586 100755 --- a/db/library/dbscript/_functions.php +++ b/db/library/dbscript/_functions.php @@ -409,6 +409,13 @@ function read_aws_blob( &$request, $value, $coll, $ext ) { function read_uploads_blob( &$request, $value, $coll, $ext ) { + if (!(isset($coll[$request->resource]))) { + // use posts location for metadata blobs + global $db; + $model =& $db->get_table($request->resource); + if (array_key_exists( 'target_id', $model->field_array )) + $coll[$request->resource]['location'] = $coll['posts']['location']; + } if (isset($coll[$request->resource])) { if ($coll[$request->resource]['location'] == 'uploads') { $file = 'uploads' . DIRECTORY_SEPARATOR . $request->resource . $request->id; @@ -434,6 +441,13 @@ function exists_uploads_blob( $resource,$id ) { function update_uploadsfile( $table, $id, $tmpfile ) { $coll = environment('collection_cache'); + if (!(isset($coll[$table]))) { + // use posts location for metadata blobs + global $db; + $model =& $db->get_table($table); + if (array_key_exists( 'target_id', $model->field_array )) + $coll[$table]['location'] = $coll['posts']['location']; + } if (!(isset($coll[$table]))) return; $uploadFile = $coll[$table]['location'].DIRECTORY_SEPARATOR.$table.$id; @@ -730,6 +744,20 @@ function type_of( $file ) { } +function type_of_image( $file ) { + + if (is_jpg($file)) + return 'jpg'; + + if (is_png($file)) + return 'png'; + + if (is_gif($file)) + return 'gif'; + + return false; + +} function extension_for( $type ) { @@ -1141,9 +1169,32 @@ function register_type( $arr ) { } -function photoCreateCropThumb ($p_thumb_file, $p_photo_file, $p_max_size, $p_quality = 100) { +function photoCreateCropThumb ($p_thumb_file, $p_photo_file, $p_max_size, $p_quality = 100, $tmpfile = null ) { - $pic = imagecreatefromjpeg($p_photo_file); + if ($tmpfile == null) + $ext = 'jpg'; + else + $ext = type_of_image($tmpfile); + + if ($ext == 'jpg') + $pic = imagecreatefromjpeg($p_photo_file); + if ($ext == 'gif') + $pic = imagecreatefromgif($p_photo_file); + if ($ext == 'png'){ + + $image = imagecreatefromstring(file_get_contents($p_photo_file)); + $width = imagesx($image); + $height = imagesy($image); + unset($image); + $size = getimagesize($p_photo_file); + $required_memory = Round($width * $height * $size['bits']) +500000; + unset($size); + $new_limit=memory_get_usage() + $required_memory; + ini_set("memory_limit", $new_limit); + + $pic = imagecreatefrompng($p_photo_file); + + } if ($pic) { $thumb = imagecreatetruecolor ($p_max_size, $p_max_size); @@ -1161,7 +1212,17 @@ function photoCreateCropThumb ($p_thumb_file, $p_photo_file, $p_max_size, $p_qua imagecopyresized($thumb, $pic, 0, 0, ($width/2)-($height/2), 0, $twidth, $theight, $width, $height); } - imagejpeg($thumb, $p_thumb_file, $p_quality); + if ($ext == 'jpg') + imagejpeg($thumb, $p_thumb_file, $p_quality); + + if ($ext == 'gif') + imagegif($thumb, $p_thumb_file); + + if ($ext == 'png') { + imagepng($thumb, $p_thumb_file); + ini_restore("memory_limit"); + } + } } diff --git a/db/library/dbscript/cookie.php b/db/library/dbscript/cookie.php index a660ea5..025ccb0 100755 --- a/db/library/dbscript/cookie.php +++ b/db/library/dbscript/cookie.php @@ -62,6 +62,8 @@ class Cookie { function Cookie() { global $prefix; + if (environment('cookielife')) + $this->expiration = environment('cookielife'); $this->cookiename = $prefix.$this->cookiename; if (array_key_exists($this->cookiename, $_COOKIE)) { $buffer = $this->_unpackage($_COOKIE[$this->cookiename]); diff --git a/db/library/dbscript/mapper.php b/db/library/dbscript/mapper.php index 8b60257..19f6f72 100755 --- a/db/library/dbscript/mapper.php +++ b/db/library/dbscript/mapper.php @@ -149,6 +149,8 @@ class Mapper { * @var string */ var $DbSession; + + var $templates_resource; function Mapper() { @@ -170,7 +172,7 @@ function Mapper() { $this->layout_path = ''; $this->error = false; $this->openid_complete = false; - + $this->templates_resource = array(); } function setup() { @@ -206,7 +208,12 @@ function setup() { $this->client_wants = $actionsplit[1]; } - session_set_cookie_params( 60*60*24*$this->cookiedays, $this->path ); + $expiry = 60*60*24*$this->cookiedays; + + if (environment('cookielife')) + $expiry = environment('cookielife'); + + session_set_cookie_params( $expiry, $this->path ); if (strpos($this->base,"twitter\/")) $this->path = $this->path.$this->prefix; @@ -425,6 +432,9 @@ function get_template_path( $ext, $template = null ) { else $resource = ""; + if (isset($this->templates_resource[$this->params['resource']])) + $resource = $this->templates_resource[$this->params['resource']] . DIRECTORY_SEPARATOR; + if ($template == null) { $partial = false; $template = $this->params['action']; @@ -722,5 +732,9 @@ function restore() { } } + function use_templates_from( $resource, $model ) { + $this->templates_resource[$model] = $resource; + } + } diff --git a/db/library/dbscript/model.php b/db/library/dbscript/model.php index d9da087..f915e5a 100755 --- a/db/library/dbscript/model.php +++ b/db/library/dbscript/model.php @@ -228,8 +228,9 @@ function insert_from_post( &$req ) { function set_metadata(&$rec,$content_type,$table,$pkfield) { global $db; - $atomentry = $db->models['entries']->base(); - if ($atomentry) { + $atomentry = $db->models['entries']->find($rec->entry_id); + if (!$atomentry) { + $atomentry = $db->models['entries']->base(); $atomentry->set_value( 'etag', getEtag( $rec->$pkfield ) ); $atomentry->set_value( 'resource', $table ); $atomentry->set_value( 'record_id', $rec->$pkfield ); @@ -244,6 +245,9 @@ function set_metadata(&$rec,$content_type,$table,$pkfield) { $rec->set_value( 'person_id', get_person_id() ); $rec->save_changes(); } + } else { + $atomentry->set_value( 'content_type', $content_type ); + $aresult = $atomentry->save_changes(); } return $atomentry; } @@ -1224,6 +1228,11 @@ function get_query( $id=NULL, $find_by=NULL ) { return $db->get_query( $id, $find_by, $this ); } + function use_templates_from( $resource ) { + global $request; + $request->use_templates_from( $resource, $this->table ); + } + } ?> \ No newline at end of file diff --git a/db/library/dbscript/view.php b/db/library/dbscript/view.php index 6a81d2e..c89f5e5 100755 --- a/db/library/dbscript/view.php +++ b/db/library/dbscript/view.php @@ -67,6 +67,8 @@ function View() { $cont = $controller_path . $request->resource . ".php"; if ( file_exists( $cont )) { $this->controller = $request->resource . ".php"; + } elseif (isset($request->templates_resource[$request->resource]) && file_exists($controller_path . $request->templates_resource[$request->resource] . ".php")) { + $this->controller = $request->templates_resource[$request->resource] . ".php"; } else { if (isset($GLOBALS['PATH']['apps'])) { foreach($GLOBALS['PATH']['apps'] as $k=>$v) { diff --git a/wp-content/language/eng.php b/wp-content/language/eng.php index ef66557..309472c 100644 --- a/wp-content/language/eng.php +++ b/wp-content/language/eng.php @@ -301,10 +301,11 @@ $txt['new_status'] = "Status"; $txt['new_article'] = "Article"; $txt['new_choose_file'] = "Choose File"; -$txt['new_image'] = "jpeg photo"; +$txt['new_image'] = "Picture"; $txt['new_movie'] = "avi or mov (quicktime) movie"; $txt['new_audio'] = "mp3 audio"; $txt['new_categories'] = "Categories"; +$txt['new_page'] = "Page Title"; ///////////////////////////////////// @@ -353,7 +354,7 @@ $txt['editprofile_openid'] = "OpenID URL"; $txt['editprofile_bio'] = "Bio"; $txt['editprofile_email'] = "E-mail"; -$txt['editprofile_photo'] = "Jpeg Photo"; +$txt['editprofile_photo'] = "Picture"; $txt['editprofile_licence_url'] = "Licence URL"; $txt['editprofile_button_cancel'] = "Cancel"; $txt['editprofile_button_save'] = "Save"; diff --git a/wp-content/language/ger.php b/wp-content/language/ger.php index 345e2c1..ca89b69 100644 --- a/wp-content/language/ger.php +++ b/wp-content/language/ger.php @@ -304,6 +304,7 @@ $txt['new_movie'] = ".avi oder .mov (quicktime) Video"; $txt['new_audio'] = ".mp3 Audiodatei"; $txt['new_categories'] = "Kategorien"; +$txt['new_page'] = "Page Title"; ///////////////////////////////////// diff --git a/wp-content/themes/p2/footer.php b/wp-content/themes/p2/footer.php index a190fe4..c47c9d0 100644 --- a/wp-content/themes/p2/footer.php +++ b/wp-content/themes/p2/footer.php @@ -2,7 +2,7 @@