aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorZach Prezkuta <fermion@gmx.com>2013-01-06 14:42:51 -0700
committerZach Prezkuta <fermion@gmx.com>2013-01-06 15:57:11 -0700
commita0d19ffb7241a1c7a4b85e6d0fd58fbb2f718468 (patch)
tree280d792355cb2e60cf62e8451b6d8afbbfcc7c0d /mod
parent61b8ea9e1af74e2056e18b02c170a899de9abd1b (diff)
downloadvolse-hubzilla-a0d19ffb7241a1c7a4b85e6d0fd58fbb2f718468.tar.gz
volse-hubzilla-a0d19ffb7241a1c7a4b85e6d0fd58fbb2f718468.tar.bz2
volse-hubzilla-a0d19ffb7241a1c7a4b85e6d0fd58fbb2f718468.zip
implement Smarty3
Diffstat (limited to 'mod')
-rw-r--r--mod/admin.php2
-rw-r--r--mod/channel.php26
-rw-r--r--mod/display.php3
-rw-r--r--mod/fbrowser.php22
-rw-r--r--mod/hcard.php3
-rw-r--r--mod/hostxrd.php13
-rw-r--r--mod/message.php49
-rw-r--r--mod/photos.php105
-rw-r--r--mod/profile.php31
-rw-r--r--mod/profile_photo.php12
-rw-r--r--mod/profiles.php278
-rw-r--r--mod/profperm.php9
-rw-r--r--mod/viewcontacts.php10
-rw-r--r--mod/xrd.php2
14 files changed, 389 insertions, 176 deletions
diff --git a/mod/admin.php b/mod/admin.php
index d0c904b02..13ecf7eef 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -610,7 +610,7 @@ function admin_page_users(&$a){
t('Community/Celebrity Account'),
t('Automatic Friend Account')
);
- $e['page-flags'] = $accounts[$e['page-flags']];
+ $e['page_flags'] = $accounts[$e['page-flags']];
$e['register_date'] = relative_date($e['register_date']);
$e['login_date'] = relative_date($e['login_date']);
$e['lastitem_date'] = relative_date($e['lastitem_date']);
diff --git a/mod/channel.php b/mod/channel.php
index 8729fee2d..096c76ae2 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -2,16 +2,6 @@
function channel_init(&$a) {
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
-
-}
-
-
-function channel_aside(&$a) {
-
- require_once('include/contact_widgets.php');
- require_once('include/items.php');
-
if(argc() > 1)
$which = argv(1);
else {
@@ -28,10 +18,24 @@ function channel_aside(&$a) {
$profile = argv(1);
}
- $cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat']) : '');
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
+ // Run profile_load() here to make sure the theme is set before
+ // we start loading content
profile_load($a,$which,$profile);
+}
+
+
+function channel_aside(&$a) {
+
+ require_once('include/contact_widgets.php');
+ require_once('include/items.php');
+
+ profile_aside($a);
+
+ $cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat']) : '');
+
$a->set_widget('archive',posted_date_widget($a->get_baseurl(true) . '/channel/' . $a->profile['nickname'],$a->profile['profile_uid'],true));
$a->set_widget('categories',categories_widget($a->get_baseurl(true) . '/channel/' . $a->profile['nickname'],$cat));
diff --git a/mod/display.php b/mod/display.php
index c6af8fdd2..d109d9a9b 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -16,7 +16,7 @@ function display_content(&$a) {
$o = '<div id="live-display"></div>' . "\r\n";
- $a->page['htmlhead'] .= get_markup_template('display-head.tpl');
+ $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), array());
if(argc() > 1)
@@ -60,6 +60,7 @@ function display_content(&$a) {
// $nick = (($a->argc > 1) ? $a->argv[1] : '');
// profile_load($a,$nick);
+// profile_aside($a);
// $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
diff --git a/mod/fbrowser.php b/mod/fbrowser.php
index cdcde4b17..81f47e39d 100644
--- a/mod/fbrowser.php
+++ b/mod/fbrowser.php
@@ -55,9 +55,17 @@ function fbrowser_content($a){
global $a;
$types = Photo::supportedTypes();
$ext = $types[$rr['type']];
+
+ if($a->theme['template_engine'] === 'internal') {
+ $filename_e = template_escape($rr['filename']);
+ }
+ else {
+ $filename_e = $rr['filename'];
+ }
+
return array(
$a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['hiq'] . '.' .$ext,
- template_escape($rr['filename']),
+ $filename_e,
$a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['loq'] . '.'. $ext
);
}
@@ -70,6 +78,7 @@ function fbrowser_content($a){
'$path' => $path,
'$folders' => $albums,
'$files' =>$files,
+ '$cancel' => t('Cancel'),
));
@@ -83,7 +92,15 @@ function fbrowser_content($a){
function files2($rr){ global $a;
list($m1,$m2) = explode("/",$rr['filetype']);
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
- return array( $a->get_baseurl() . '/attach/' . $rr['id'], template_escape($rr['filename']), $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
+
+ if($a->theme['template_engine'] === 'internal') {
+ $filename_e = template_escape($rr['filename']);
+ }
+ else {
+ $filename_e = $rr['filename'];
+ }
+
+ return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
}
$files = array_map("files2", $files);
//echo "<pre>"; var_dump($files); killme();
@@ -96,6 +113,7 @@ function fbrowser_content($a){
'$path' => array( array($a->get_baseurl()."/fbrowser/image/", t("Files")) ),
'$folders' => false,
'$files' =>$files,
+ '$cancel' => t('Cancel'),
));
}
diff --git a/mod/hcard.php b/mod/hcard.php
index cc6d326b5..83ae7c7af 100644
--- a/mod/hcard.php
+++ b/mod/hcard.php
@@ -48,3 +48,6 @@ function hcard_init(&$a) {
}
+function hcard_aside(&$a) {
+ profile_aside($a);
+}
diff --git a/mod/hostxrd.php b/mod/hostxrd.php
index 9b2411f26..0a66dcc84 100644
--- a/mod/hostxrd.php
+++ b/mod/hostxrd.php
@@ -14,10 +14,15 @@ function hostxrd_init(&$a) {
set_config('system','site_pubkey', $res['pubkey']);
}
- $tpl = file_get_contents('view/xrd_host.tpl');
- echo str_replace(array(
- '$zhost','$zroot','$domain','$zot_post','$bigkey'),array($a->get_hostname(),z_root(),z_path(),z_root() . '/post', salmon_key(get_config('system','site_pubkey'))),$tpl);
+ $tpl = get_markup_template('xrd_host.tpl');
+ echo replace_macros($tpl, array(
+ '$zhost' => $a->get_hostname(),
+ '$zroot' => z_root(),
+ '$domain' => z_path(),
+ '$zot_post' => z_root() . '/post',
+ '$bigkey' => salmon_key(get_config('system','site_pubkey')),
+ ));
session_write_close();
exit();
-} \ No newline at end of file
+}
diff --git a/mod/message.php b/mod/message.php
index 3e88362a0..1a1ce4813 100644
--- a/mod/message.php
+++ b/mod/message.php
@@ -362,6 +362,19 @@ function message_content(&$a) {
$rr['to'] = find_xchan_in_array($rr['to_xchan'],$c);
$rr['seen'] = (($rr['mail_flags'] & MAIL_SEEN) ? 1 : "");
+ if($a->theme['template_engine'] === 'internal') {
+ $from_name_e = template_escape($rr['from']['xchan_name']);
+ $subject_e = template_escape((($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'));
+ $body_e = template_escape($rr['body']);
+ $to_name_e = template_escape($rr['to']['xchan_name']);
+ }
+ else {
+ $from_name_e = $rr['from']['xchan_name'];
+ $subject_e = (($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>');
+ $body_e = $rr['body'];
+ $to_name_e = $rr['to']['xchan_name'];
+ }
+
$o .= replace_macros($tpl, array(
'$id' => $rr['id'],
'$from_name' => template_escape($rr['from']['xchan_name']),
@@ -385,6 +398,10 @@ function message_content(&$a) {
$o .= $header;
+ $plaintext = true;
+ if( local_user() && feature_enabled(local_user(),'richtext') )
+ $plaintext = false;
+
$r = q("SELECT parent_uri from mail WHERE channel_id = %d and id = %d limit 1",
intval(local_user()),
intval(argv(1))
@@ -433,6 +450,8 @@ function message_content(&$a) {
$a->page['htmlhead'] .= replace_macros($tpl, array(
'$nickname' => $channel['channel_addr'],
'$baseurl' => $a->get_baseurl(true)
+ '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
+ '$linkurl' => t('Please enter a link URL:')
));
@@ -451,16 +470,29 @@ logger('message: ' . print_r($message,true));
// if($extracted['images'])
// $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
+ if($a->theme['template_engine'] === 'internal') {
+ $from_name_e = template_escape($message['from']['xchan_name']);
+ $subject_e = template_escape($message['title']);
+ $body_e = template_escape(smilies(bbcode($message['body'])));
+ $to_name_e = template_escape($message['to']['xchan_name']);
+ }
+ else {
+ $from_name_e = $message['from']['xchan_name'];
+ $subject_e = $message['title'];
+ $body_e = smilies(bbcode($message['body']));
+ $to_name_e = $message['to']['xchan_name'];
+ }
+
$mails[] = array(
'id' => $message['id'],
- 'from_name' => template_escape($message['from']['xchan_name']),
+ 'from_name' => $from_name_e,
'from_url' => z_root() . '/chanview/?f=&hash=' . $message['from_xchan'],
'from_photo' => $message['from']['xchan_photo_m'],
- 'to_name' => template_escape($message['to']['xchan_name']),
+ 'to_name' => $to_name_e,
'to_url' => z_root() . '/chanview/?f=&hash=' . $message['to_xchan'],
'to_photo' => $message['to']['xchan_photo_m'],
- 'subject' => template_escape($message['title']),
- 'body' => template_escape(smilies(bbcode($message['body']))),
+ 'subject' => $subject_e,
+ 'body' => $body_e,
'delete' => t('Delete message'),
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
);
@@ -476,6 +508,13 @@ logger('message: ' . print_r($message,true));
$select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />';
$parent = '<input type="hidden" name="replyto" value="' . $message['parent_uri'] . '" />';
+ if($a->theme['template_engine'] === 'internal') {
+ $subjtxt_e = template_escape($message['title']);
+ }
+ else {
+ $subjtxt_e = $message['title'];
+ }
+
$tpl = get_markup_template('mail_display.tpl');
$o = replace_macros($tpl, array(
'$thread_id' => $a->argv[1],
@@ -491,7 +530,7 @@ logger('message: ' . print_r($message,true));
'$to' => t('To:'),
'$showinputs' => '',
'$subject' => t('Subject:'),
- '$subjtxt' => template_escape($message['title']),
+ '$subjtxt' => $subjtxt_e,
'$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
'$yourmessage' => t('Your message:'),
'$text' => '',
diff --git a/mod/photos.php b/mod/photos.php
index ee0a930fd..2cd2646d5 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -1063,6 +1063,15 @@ function photos_content(&$a) {
}
+ if($a->theme['template_engine'] === 'internal') {
+ $albumselect_e = template_escape($albumselect);
+ $aclselect_e = (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb)));
+ }
+ else {
+ $albumselect_e = $albumselect;
+ $aclselect_e = (($visitor) ? '' : populate_acl($a->user, $celeb));
+ }
+
$tpl = get_markup_template('photos_upload.tpl');
$o .= replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
@@ -1072,9 +1081,9 @@ function photos_content(&$a) {
'$newalbum' => t('New album name: '),
'$existalbumtext' => t('or existing album name: '),
'$nosharetext' => t('Do not show a status post for this upload'),
- '$albumselect' => template_escape($albumselect),
+ '$albumselect' => $albumselect_e,
'$permissions' => t('Permissions'),
- '$aclselect' => (($visitor) ? '' : template_escape(populate_acl($a->user, $celeb))),
+ '$aclselect' => $aclselect_e,
'$uploader' => $ret['addon_text'],
'$default' => (($ret['default_upload']) ? $default_upload : ''),
'$uploadurl' => $ret['post_url']
@@ -1116,11 +1125,18 @@ function photos_content(&$a) {
if($cmd === 'edit') {
if(($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) {
+ if($a->theme['template_engine'] === 'internal') {
+ $album_e = template_escape($album);
+ }
+ else {
+ $album_e = $album;
+ }
+
$edit_tpl = get_markup_template('album_edit.tpl');
$o .= replace_macros($edit_tpl,array(
'$nametext' => t('New album name: '),
'$nickname' => $a->data['channel']['channel_address'],
- '$album' => template_escape($album),
+ '$album' => $album_e,
'$hexalbum' => bin2hex($album),
'$submit' => t('Submit'),
'$dropsubmit' => t('Delete Album')
@@ -1160,6 +1176,15 @@ function photos_content(&$a) {
$ext = $phototypes[$rr['type']];
+ if($a->theme['template_engine'] === 'internal') {
+ $imgalt_e = template_escape($rr['filename']);
+ $desc_e = template_escape($rr['desc']);
+ }
+ else {
+ $imgalt_e = $rr['filename'];
+ $desc_e = $rr['desc'];
+ }
+
$o .= replace_macros($tpl,array(
'$id' => $rr['id'],
'$twist' => ' ' . $twist . rand(2,4),
@@ -1167,8 +1192,8 @@ function photos_content(&$a) {
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''),
'$phototitle' => t('View Photo'),
'$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . $rr['scale'] . '.' .$ext,
- '$imgalt' => template_escape($rr['filename']),
- '$desc'=> template_escape($rr['desc'])
+ '$imgalt' => $imgalt_e,
+ '$desc'=> $desc_e
));
}
@@ -1365,21 +1390,32 @@ function photos_content(&$a) {
$edit = Null;
if(($cmd === 'edit') && ($can_post)) {
+ if($a->theme['template_engine'] === 'internal') {
+ $album_e = template_escape($ph[0]['album']);
+ $caption_e = template_escape($ph[0]['desc']);
+ $aclselect_e = template_escape(populate_acl($ph[0]));
+ }
+ else {
+ $album_e = $ph[0]['album'];
+ $caption_e = $ph[0]['desc'];
+ $aclselect_e = populate_acl($ph[0]);
+ }
+
$edit_tpl = get_markup_template('photo_edit.tpl');
$edit = replace_macros($edit_tpl, array(
'$id' => $ph[0]['id'],
'$rotatecw' => t('Rotate CW (right)'),
'$rotateccw' => t('Rotate CCW (left)'),
- '$album' => template_escape($ph[0]['album']),
+ '$album' => $album_e,
'$newalbum' => t('New album name'),
'$nickname' => $a->data['channel']['channel_address'],
'$resource_id' => $ph[0]['resource_id'],
'$capt_label' => t('Caption'),
- '$caption' => template_escape($ph[0]['desc']),
+ '$caption' => $caption_e,
'$tag_label' => t('Add a Tag'),
'$tags' => $link_item['tag'],
'$permissions' => t('Permissions'),
- '$aclselect' => template_escape(populate_acl($ph[0])),
+ '$aclselect' => $aclselect_e,
'$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
'$item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
'$submit' => t('Submit'),
@@ -1516,14 +1552,25 @@ function photos_content(&$a) {
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
+ if($a->theme['template_engine'] === 'internal') {
+ $name_e = template_escape($profile_name);
+ $title_e = template_escape($item['title']);
+ $body_e = template_escape(bbcode($item['body']));
+ }
+ else {
+ $name_e = $profile_name;
+ $title_e = $item['title'];
+ $body_e = bbcode($item['body']);
+ }
+
$comments .= replace_macros($template,array(
'$id' => $item['item_id'],
'$profile_url' => $profile_link,
- '$name' => template_escape($profile_name),
+ '$name' => $name_e,
'$thumb' => $profile_avatar,
'$sparkle' => $sparkle,
- '$title' => template_escape($item['title']),
- '$body' => template_escape(bbcode($item['body'])),
+ '$title' => $title_e,
+ '$body' => $body_e,
'$ago' => relative_date($item['created']),
'$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
'$drop' => $drop,
@@ -1535,21 +1582,34 @@ function photos_content(&$a) {
$paginate = paginate($a);
}
+ if($a->theme['template_engine'] === 'internal') {
+ $album_e = array($album_link,template_escape($ph[0]['album']));
+ $tags_e = template_escape($tags);
+ $like_e = template_escape($like);
+ $dislike_e = template_escape($dislike);
+ }
+ else {
+ $album_e = array($album_link,$ph[0]['album']);
+ $tags_e = $tags;
+ $like_e = $like;
+ $dislike_e = $dislike;
+ }
+
$photo_tpl = get_markup_template('photo_view.tpl');
$o .= replace_macros($photo_tpl, array(
'$id' => $ph[0]['id'],
- '$album' => array($album_link,template_escape($ph[0]['album'])),
+ '$album' => $album_e,
'$tools' => $tools,
'$lock' => $lock,
'$photo' => $photo,
'$prevlink' => $prevlink,
'$nextlink' => $nextlink,
'$desc' => $ph[0]['desc'],
- '$tags' => template_escape($tags),
+ '$tags' => $tags_e,
'$edit' => $edit,
'$likebuttons' => $likebuttons,
- '$like' => template_escape($like),
- '$dislike' => template_escape($dislike),
+ '$like' => $like_e,
+ '$dislike' => $dislike_e,
'$comments' => $comments,
'$paginate' => $paginate,
));
@@ -1593,16 +1653,25 @@ function photos_content(&$a) {
$twist = 'rotright';
$ext = $phototypes[$rr['type']];
+ if($a->theme['template_engine'] === 'internal') {
+ $alt_e = template_escape($rr['filename']);
+ $name_e = template_escape($rr['album']);
+ }
+ else {
+ $alt_e = $rr['filename'];
+ $name_e = $rr['album'];
+ }
+
$photos[] = array(
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id'],
'title' => t('View Photo'),
'src' => $a->get_baseurl() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
- 'alt' => template_escape($rr['filename']),
+ 'alt' => $alt_e,
'album' => array(
'link' => $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']),
- 'name' => template_escape($rr['album']),
+ 'name' => $name_e,
'alt' => t('View Album'),
),
@@ -1611,7 +1680,7 @@ function photos_content(&$a) {
}
$tpl = get_markup_template('photos_recent.tpl');
- $o .= replace_macros($tpl,array(
+ $o .= replace_macros($tpl, array(
'$title' => t('Recent Photos'),
'$can_post' => $can_post,
'$upload' => array(t('Upload New Photos'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'),
diff --git a/mod/profile.php b/mod/profile.php
index ce2d92f9b..8f15766b6 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -2,16 +2,6 @@
function profile_init(&$a) {
- $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
-
-}
-
-
-function profile_aside(&$a) {
-
- require_once('include/contact_widgets.php');
- require_once('include/items.php');
-
if(argc() > 1)
$which = argv(1);
else {
@@ -28,6 +18,7 @@ function profile_aside(&$a) {
$profile = argv(1);
}
+ $a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
$x = q("select channel_id as profile_uid from channel where channel_address = '%s' limit 1",
dbesc(argv(1))
@@ -37,13 +28,33 @@ function profile_aside(&$a) {
$channel_display = get_pconfig($a->profile['profile_uid'],'system','channel_format');
if(! $channel_display)
profile_load($a,$which,$profile);
+ }
+
+}
+
+
+function profile_aside(&$a) {
+
+ require_once('include/contact_widgets.php');
+ require_once('include/items.php');
+
+ $x = q("select channel_id as profile_uid from channel where channel_address = '%s' limit 1",
+ dbesc(argv(1))
+ );
+ if($x) {
+ $channel_display = get_pconfig($a->profile['profile_uid'],'system','channel_format');
+ if(! $channel_display)
+ profile_aside($a);
+
if($channel_display === 'full')
$a->page['template'] = 'full';
else {
+ $cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat']) : '');
$a->set_widget('archive',posted_date_widget($a->get_baseurl(true) . '/channel/' . $a->profile['nickname'],$a->profile['profile_uid'],true));
$a->set_widget('categories',categories_widget($a->get_baseurl(true) . '/channel/' . $a->profile['nickname'],$cat));
}
}
+
}
diff --git a/mod/profile_photo.php b/mod/profile_photo.php
index e78d2ca6f..e7be543c6 100644
--- a/mod/profile_photo.php
+++ b/mod/profile_photo.php
@@ -14,6 +14,16 @@ function profile_photo_init(&$a) {
}
+function profile_photo_init(&$a) {
+
+ if(! local_user()) {
+ return;
+ }
+
+ profile_aside($a);
+}
+
+
function profile_photo_post(&$a) {
if(! local_user()) {
@@ -318,7 +328,7 @@ function profile_photo_crop_ui_head(&$a, $ph){
$a->config['imagecrop'] = $hash;
$a->config['imagecrop_resolution'] = $smallest;
$a->config['imagecrop_ext'] = $ph->getExt();
- $a->page['htmlhead'] .= get_markup_template("crophead.tpl");
+ $a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
return;
}}
diff --git a/mod/profiles.php b/mod/profiles.php
index 37be9bd08..5b2102852 100644
--- a/mod/profiles.php
+++ b/mod/profiles.php
@@ -1,6 +1,162 @@
<?php
+function profiles_init(&$a) {
+
+ nav_set_selected('profiles');
+
+ if(! local_user()) {
+ return;
+ }
+
+ if((argc() > 2) && (argv(1) === "drop") && intval(argv(2))) {
+ $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1",
+ intval($a->argv[2]),
+ intval(local_user())
+ );
+ if(! count($r)) {
+ notice( t('Profile not found.') . EOL);
+ goaway($a->get_baseurl(true) . '/profiles');
+ return; // NOTREACHED
+ }
+ $profile_guid = $r['profile_guid'];
+
+ check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
+
+ // move every contact using this profile as their default to the user default
+
+ $r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ",
+ intval(local_user()),
+ dbesc($profile_guid),
+ intval(local_user())
+ );
+ $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval(argv(2)),
+ intval(local_user())
+ );
+ if($r)
+ info( t('Profile deleted.') . EOL);
+
+ goaway($a->get_baseurl(true) . '/profiles');
+ return; // NOTREACHED
+ }
+
+
+
+
+
+ if((argc() > 1) && (argv(1) === 'new')) {
+
+ check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
+
+ $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
+ intval(local_user()));
+ $num_profiles = count($r0);
+
+ $name = t('Profile-') . ($num_profiles + 1);
+
+ $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1",
+ intval(local_user()));
+
+ $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `name`, `photo`, `thumb`)
+ VALUES ( %d, '%s', '%s', '%s', '%s' )",
+ intval(get_account_id()),
+ intval(local_user()),
+ dbesc(random_string()),
+ dbesc($name),
+ dbesc($r1[0]['name']),
+ dbesc($r1[0]['photo']),
+ dbesc($r1[0]['thumb'])
+ );
+
+ $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile_name` = '%s' LIMIT 1",
+ intval(local_user()),
+ dbesc($name)
+ );
+
+ info( t('New profile created.') . EOL);
+ if(count($r3) == 1)
+ goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
+
+ goaway($a->get_baseurl(true) . '/profiles');
+ }
+
+ if((argc() > 2) && (argv(1) === 'clone')) {
+
+ check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
+
+ $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
+ intval(local_user()));
+ $num_profiles = count($r0);
+
+ $name = t('Profile-') . ($num_profiles + 1);
+ $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ intval(local_user()),
+ intval($a->argv[2])
+ );
+ if(! count($r1)) {
+ notice( t('Profile unavailable to clone.') . EOL);
+ $a->error = 404;
+ return;
+ }
+ unset($r1[0]['id']);
+ $r1[0]['is_default'] = 0;
+ $r1[0]['publish'] = 0;
+ $r1[0]['profile_name'] = dbesc($name);
+ $r1[0]['profile_guid'] = dbesc(random_string());
+
+ dbesc_array($r1[0]);
+
+ $r2 = dbq("INSERT INTO `profile` (`"
+ . implode("`, `", array_keys($r1[0]))
+ . "`) VALUES ('"
+ . implode("', '", array_values($r1[0]))
+ . "')" );
+
+ $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile_name` = '%s' LIMIT 1",
+ intval(local_user()),
+ dbesc($name)
+ );
+ info( t('New profile created.') . EOL);
+ if(count($r3) == 1)
+ goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
+
+ goaway($a->get_baseurl(true) . '/profiles');
+
+ return; // NOTREACHED
+ }
+
+
+ // Run profile_load() here to make sure the theme is set before
+ // we start loading content
+ if((argc() > 1) && (intval(argv(1)))) {
+ $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($a->argv[1]),
+ intval(local_user())
+ );
+ if(! count($r)) {
+ notice( t('Profile not found.') . EOL);
+ $a->error = 404;
+ return;
+ }
+
+ $chan = $a->get_channel();
+
+ profile_load($a,$chan['channel_address'],$r[0]['id']);
+ }
+}
+
+function profiles_aside(&$a) {
+
+ if(! local_user()) {
+ return;
+ }
+
+ if((argc() > 1) && (intval(argv(1)))) {
+ profile_aside($a);
+ }
+}
+
function profiles_post(&$a) {
if(! local_user()) {
@@ -307,130 +463,12 @@ function profiles_post(&$a) {
function profiles_content(&$a) {
$o = '';
- nav_set_selected('profiles');
if(! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
- if((argc() > 2) && (argv(1) === "drop") && intval(argv(2))) {
- $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1",
- intval($a->argv[2]),
- intval(local_user())
- );
- if(! count($r)) {
- notice( t('Profile not found.') . EOL);
- goaway($a->get_baseurl(true) . '/profiles');
- return; // NOTREACHED
- }
- $profile_guid = $r['profile_guid'];
-
- check_form_security_token_redirectOnErr('/profiles', 'profile_drop', 't');
-
- // move every contact using this profile as their default to the user default
-
- $r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ",
- intval(local_user()),
- dbesc($profile_guid),
- intval(local_user())
- );
- $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval(argv(2)),
- intval(local_user())
- );
- if($r)
- info( t('Profile deleted.') . EOL);
-
- goaway($a->get_baseurl(true) . '/profiles');
- return; // NOTREACHED
- }
-
-
-
-
-
- if((argc() > 1) && (argv(1) === 'new')) {
-
- check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't');
-
- $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
- intval(local_user()));
- $num_profiles = count($r0);
-
- $name = t('Profile-') . ($num_profiles + 1);
-
- $r1 = q("SELECT `name`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1",
- intval(local_user()));
-
- $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `name`, `photo`, `thumb`)
- VALUES ( %d, '%s', '%s', '%s', '%s' )",
- intval(get_account_id()),
- intval(local_user()),
- dbesc(random_string()),
- dbesc($name),
- dbesc($r1[0]['name']),
- dbesc($r1[0]['photo']),
- dbesc($r1[0]['thumb'])
- );
-
- $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile_name` = '%s' LIMIT 1",
- intval(local_user()),
- dbesc($name)
- );
-
- info( t('New profile created.') . EOL);
- if(count($r3) == 1)
- goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
-
- goaway($a->get_baseurl(true) . '/profiles');
- }
-
- if((argc() > 2) && (argv(1) === 'clone')) {
-
- check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't');
-
- $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d",
- intval(local_user()));
- $num_profiles = count($r0);
-
- $name = t('Profile-') . ($num_profiles + 1);
- $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1",
- intval(local_user()),
- intval($a->argv[2])
- );
- if(! count($r1)) {
- notice( t('Profile unavailable to clone.') . EOL);
- return;
- }
- unset($r1[0]['id']);
- $r1[0]['is_default'] = 0;
- $r1[0]['publish'] = 0;
- $r1[0]['profile_name'] = dbesc($name);
- $r1[0]['profile_guid'] = dbesc(random_string());
-
- dbesc_array($r1[0]);
-
- $r2 = dbq("INSERT INTO `profile` (`"
- . implode("`, `", array_keys($r1[0]))
- . "`) VALUES ('"
- . implode("', '", array_values($r1[0]))
- . "')" );
-
- $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile_name` = '%s' LIMIT 1",
- intval(local_user()),
- dbesc($name)
- );
- info( t('New profile created.') . EOL);
- if(count($r3) == 1)
- goaway($a->get_baseurl(true) . '/profiles/' . $r3[0]['id']);
-
- goaway($a->get_baseurl(true) . '/profiles');
-
- return; // NOTREACHED
- }
-
-
if((argc() > 1) && (intval(argv(1)))) {
$r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($a->argv[1]),
@@ -441,10 +479,6 @@ function profiles_content(&$a) {
return;
}
- $chan = $a->get_channel();
-
- profile_load($a,$chan['channel_address'],$r[0]['id']);
-
require_once('include/profile_selectors.php');
diff --git a/mod/profperm.php b/mod/profperm.php
index b31dfc128..7c7fe7b11 100644
--- a/mod/profperm.php
+++ b/mod/profperm.php
@@ -13,6 +13,15 @@ function profperm_init(&$a) {
}
+function profperm_aside(&$a) {
+
+ if(! local_user())
+ return;
+
+ profile_aside($a);
+}
+
+
function profperm_content(&$a) {
if(! local_user()) {
diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php
index 8133fb4a0..7f5050d5d 100644
--- a/mod/viewcontacts.php
+++ b/mod/viewcontacts.php
@@ -11,6 +11,16 @@ function viewcontacts_init(&$a) {
}
+function viewcontacts_aside(&$a) {
+
+ if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+ return;
+ }
+
+ profile_aside($a);
+}
+
+
function viewcontacts_content(&$a) {
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
diff --git a/mod/xrd.php b/mod/xrd.php
index d22ff4699..a576f76c4 100644
--- a/mod/xrd.php
+++ b/mod/xrd.php
@@ -29,7 +29,7 @@ function xrd_init(&$a) {
$dspr = '';
- $tpl = file_get_contents('view/xrd_person.tpl');
+ $tpl = get_markup_template('view/xrd_person.tpl');
$o = replace_macros($tpl, array(
'$nick' => $r[0]['nickname'],