diff --git a/include/conversation.php b/include/conversation.php index 2ef37694dc..f4740688cd 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -6,11 +6,6 @@ function localize_item(&$item){ $Text = $item['body']; - - - // find private image (w/data url) if present and convert image - // link to a magic-auth redirect. - $saved_image = ''; $img_start = strpos($Text,'[img]data:'); $img_end = strpos($Text,'[/img]'); @@ -184,6 +179,7 @@ function localize_item(&$item){ * that are based on unique features of the calling module. * */ + if(!function_exists('conversation')){ function conversation(&$a, $items, $mode, $update, $preview = false) { require_once('bbcode.php'); @@ -231,13 +227,13 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $items = $cb['items']; $cmnt_tpl = get_markup_template('comment_item.tpl'); - $tpl = get_markup_template('wall_item.tpl'); - $wallwall = get_markup_template('wallwall_item.tpl'); + $tpl = 'wall_item.tpl'; + $wallwall = 'wallwall_item.tpl'; $hide_comments_tpl = get_markup_template('hide_comments.tpl'); $alike = array(); $dlike = array(); - $o = ""; + // array with html for each thread (parent+comments) $threads = array(); @@ -250,7 +246,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display - $tpl = get_markup_template('search_item.tpl'); + //$tpl = get_markup_template('search_item.tpl'); + $tpl = 'search_item.tpl'; foreach($items as $item) { $threadsid++; @@ -316,43 +313,46 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $body = prepare_body($item,true); - $tmp_item = replace_macros($tpl,array( - '$id' => (($preview) ? 'P0' : $item['item_id']), - '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - '$profile_url' => $profile_link, - '$item_photo_menu' => item_photo_menu($item), - '$name' => template_escape($profile_name), - '$sparkle' => $sparkle, - '$lock' => $lock, - '$thumb' => $profile_avatar, - '$title' => template_escape($item['title']), - '$body' => template_escape($body), - '$ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - '$lock' => $lock, - '$location' => template_escape($location), - '$indent' => '', - '$owner_name' => template_escape($owner_name), - '$owner_url' => $owner_url, - '$owner_photo' => $owner_photo, - '$plink' => get_plink($item), - '$edpost' => false, - '$isstarred' => $isstarred, - '$star' => $star, - '$drop' => $drop, - '$vote' => $likebuttons, - '$like' => '', - '$dislike' => '', - '$comment' => '', - '$conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), - '$previewing' => $previewing, - '$wait' => t('Please wait'), - )); + //$tmp_item = replace_macros($tpl,array( + $tmp_item = array( + 'template' => $tpl, + 'id' => (($preview) ? 'P0' : $item['item_id']), + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'profile_url' => $profile_link, + 'item_photo_menu' => item_photo_menu($item), + 'name' => template_escape($profile_name), + 'sparkle' => $sparkle, + 'lock' => $lock, + 'thumb' => $profile_avatar, + 'title' => template_escape($item['title']), + 'body' => template_escape($body), + 'text' => strip_tags(template_escape($body)), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'lock' => $lock, + 'location' => template_escape($location), + 'indent' => '', + 'owner_name' => template_escape($owner_name), + 'owner_url' => $owner_url, + 'owner_photo' => $owner_photo, + 'plink' => get_plink($item), + 'edpost' => false, + 'isstarred' => $isstarred, + 'star' => $star, + 'drop' => $drop, + 'vote' => $likebuttons, + 'like' => '', + 'dislike' => '', + 'comment' => '', + 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), + 'previewing' => $previewing, + 'wait' => t('Please wait'), + ); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; - $threads[$threadsid]['html'] .= $arr['output']; + $threads[$threadsid]['items'] = array($arr['output']); } @@ -385,6 +385,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $comments_collapsed = false; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; $blowhard = 0; $blowhard_count = 0; @@ -438,10 +440,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comments_seen = 0; $comments_collapsed = false; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; $threadsid++; $threads[$threadsid]['id'] = $item['item_id']; - $threads[$threadsid]['html'] = ""; + $threads[$threadsid]['items'] = array(); } else { @@ -449,6 +453,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if((! $toplevelpost) && (! $toplevelprivate) && ($item['private']) && ($profile_owner != local_user())) continue; $comments_seen ++; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; } $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); @@ -456,23 +462,17 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { - if(! $comments_collapsed) { - // IMPORTANT: the closing in the hide_comments template - // is supplied below in code. - - $threads[$threadsid]['html'] .= replace_macros($hide_comments_tpl,array( - '$id' => $item['parent'], - '$num_comments' => sprintf( tt('%d comment','%d comments',$comments[$item['parent']]), - $comments[$item['parent']]), - '$display' => 'none', - '$hide_text' => t('show more') - )); + if (!$comments_collapsed){ + $threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] ); + $threads[$threadsid]['hide_text'] = t('show more'); $comments_collapsed = true; + $comment_firstcollapsed = true; } } if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { - $threads[$threadsid]['html'] .= ''; + + $comment_lastcollapsed = true; } $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; @@ -649,63 +649,72 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // Build the HTML $body = prepare_body($item,true); + //$tmp_item = replace_macros($template, + $tmp_item = array( + // collapse comments in template. I don't like this much... + 'comment_firstcollapsed' => $comment_firstcollapsed, + 'comment_lastcollapsed' => $comment_lastcollapsed, + // template to use to render item (wall, walltowall, search) + 'template' => $template, + + 'type' => implode("",array_slice(split("/",$item['verb']),-1)), + 'tags' => $tags, + 'body' => template_escape($body), + 'text' => strip_tags(template_escape($body)), + 'id' => $item['item_id'], + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), + 'to' => t('to'), + 'wall' => t('Wall-to-Wall'), + 'vwall' => t('via Wall-To-Wall:'), + 'profile_url' => $profile_link, + 'item_photo_menu' => item_photo_menu($item), + 'name' => template_escape($profile_name), + 'thumb' => $profile_avatar, + 'osparkle' => $osparkle, + 'sparkle' => $sparkle, + 'title' => template_escape($item['title']), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'lock' => $lock, + 'location' => template_escape($location), + 'indent' => $indent, + 'owner_url' => $owner_url, + 'owner_photo' => $owner_photo, + 'owner_name' => template_escape($owner_name), + 'plink' => get_plink($item), + 'edpost' => $edpost, + 'isstarred' => $isstarred, + 'star' => $star, + 'drop' => $drop, + 'vote' => $likebuttons, + 'like' => $like, + 'dislike' => $dislike, + 'comment' => $comment, + 'previewing' => $previewing, + 'wait' => t('Please wait'), - $tmp_item = replace_macros($template,array( - '$type' => implode("",array_slice(explode("/",$item['verb']),-1)), - '$tags' => $tags, - '$body' => template_escape($body), - '$id' => $item['item_id'], - '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - '$olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), - '$to' => t('to'), - '$wall' => t('Wall-to-Wall'), - '$vwall' => t('via Wall-To-Wall:'), - '$profile_url' => $profile_link, - '$item_photo_menu' => item_photo_menu($item), - '$name' => template_escape($profile_name), - '$thumb' => $profile_avatar, - '$osparkle' => $osparkle, - '$sparkle' => $sparkle, - '$title' => template_escape($item['title']), - '$ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - '$lock' => $lock, - '$location' => template_escape($location), - '$indent' => $indent, - '$owner_url' => $owner_url, - '$owner_photo' => $owner_photo, - '$owner_name' => template_escape($owner_name), - '$plink' => get_plink($item), - '$edpost' => $edpost, - '$isstarred' => $isstarred, - '$star' => $star, - '$drop' => $drop, - '$vote' => $likebuttons, - '$like' => $like, - '$dislike' => $dislike, - '$comment' => $comment, - '$previewing' => $previewing, - '$wait' => t('Please wait'), - - )); + ); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); - $threads[$threadsid]['html'] .= $arr['output']; + $threads[$threadsid]['items'][] = $arr['output']; } } } - $page_template = get_markup_template("conversation.tpl"); $o .= replace_macros($page_template, array( + '$baseurl' => $a->get_baseurl(), + '$mode' => $mode, + '$user' => $a->user, '$threads' => $threads, '$dropping' => ($dropping?t('Delete Selected Items'):False), )); return $o; -} +}} function best_link_url($item,&$sparkle) { diff --git a/include/template_processor.php b/include/template_processor.php index 28c3f07ddd..b4d444e1c6 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -116,7 +116,15 @@ * {{ inc [with $var1=$var2] }}{{ endinc }} */ private function _replcb_inc($args){ - list($tplfile, $newctx) = array_map('trim', explode("with",$args[2])); + if (strpos($args[2],"with")) { + list($tplfile, $newctx) = array_map('trim', explode("with",$args[2])); + } else { + $tplfile = trim($args[2]); + $newctx = null; + } + + if ($tplfile[0]=="$") $tplfile = $this->_get_var($tplfile); + $this->_push_stack(); $r = $this->r; if (!is_null($newctx)) { diff --git a/mod/admin.php b/mod/admin.php index 0f600e3126..94bf445032 100755 --- a/mod/admin.php +++ b/mod/admin.php @@ -366,7 +366,7 @@ function admin_page_users_post(&$a){ intval( $uid ) ); } - notice( sprintf( tt("%s user blocked", "%s users blocked/unblocked", count($users)), count($users)) ); + notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) ); } if (x($_POST,'page_users_delete')){ require_once("include/Contact.php"); @@ -428,6 +428,7 @@ function admin_page_users(&$a){ LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid` LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;"); + /* get users */ $total = q("SELECT count(*) as total FROM `user` where 1"); @@ -435,7 +436,8 @@ function admin_page_users(&$a){ $a->set_pager_total($total[0]['total']); $a->set_pager_itemspage(100); } - + + $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date` FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid` @@ -469,6 +471,7 @@ function admin_page_users(&$a){ } $users = array_map("_setup_users", $users); + $t = get_markup_template("admin_users.tpl"); $o = replace_macros($t, array( // strings // diff --git a/mod/group.php b/mod/group.php index c896362ca2..f6f8e41733 100755 --- a/mod/group.php +++ b/mod/group.php @@ -76,14 +76,17 @@ function group_content(&$a) { if($switchtotext === false) $switchtotext = 400; + $tpl = get_markup_template('group_edit.tpl'); + $context = array('$submit' => t('Submit')); + if(($a->argc == 2) && ($a->argv[1] === 'new')) { - $tpl = get_markup_template('group_new.tpl'); - $o .= replace_macros($tpl,array( - '$desc' => t('Create a group of contacts/friends.'), - '$name' => t('Group Name: '), - '$submit' => t('Submit') - )); - return $o; + + return replace_macros($tpl, $context + array( + '$title' => t('Create a group of contacts/friends.'), + '$gname' => array('groupname',t('Group Name: '),$group['name'], ''), + )); + + } if(($a->argc == 3) && ($a->argv[1] === 'drop')) { @@ -156,66 +159,61 @@ function group_content(&$a) { $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $tpl = get_markup_template('group_edit.tpl'); - $o .= replace_macros($tpl, array( - '$gid' => $group['id'], - '$name' => $group['name'], - '$drop' => $drop_txt, - '$desc' => t('Click on a contact to add or remove.'), + + $context = $context + array( '$title' => t('Group Editor'), - '$gname' => t('Group Name: '), - '$submit' => t('Submit') - )); + '$gname' => array('groupname',t('Group Name: '),$group['name'], ''), + '$gid' => $group['id'], + '$drop' => $drop_txt, + ); } if(! isset($group)) return; - $o .= '
'; - if($change) - $o = ''; + $groupeditor = array( + 'label_members' => t('Members'), + 'members' => array(), + 'label_contacts' => t('All Contacts'), + 'contacts' => arraY(), + ); + - $o .= '

' . t('Members') . '

'; - $o .= '
'; $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { if($member['url']) { $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;'; - $o .= micropro($member,true,'mpgroup', $textmode); + $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); } else group_rmv_member(local_user(),$group['name'],$member['id']); } - $o .= '
'; - $o .= '
'; - - $o .= '

' . t('All Contacts') . '

'; - $o .= '
'; + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 ORDER BY `name` ASC", + intval(local_user()) + ); - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 ORDER BY `name` ASC", - intval(local_user()) - ); - - if(count($r)) { - $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); - foreach($r as $member) { - if(! in_array($member['id'],$preselected)) { - $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;'; - $o .= micropro($member,true,'mpall', $textmode); - } + if(count($r)) { + $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); + foreach($r as $member) { + if(! in_array($member['id'],$preselected)) { + $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;'; + $groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode); } } + } - $o .= '
'; + $context['$groupeditor'] = $groupeditor; + $context['$desc'] = t('Click on a contact to add or remove.'); if($change) { - echo $o; + $tpl = get_markup_template('groupeditor.tpl'); + echo replace_macros($tpl, $context); killme(); } - $o .= '
'; - return $o; + + return replace_macros($tpl, $context); } diff --git a/view/contact_template.tpl b/view/contact_template.tpl index f4c0670bfe..b826acc65d 100755 --- a/view/contact_template.tpl +++ b/view/contact_template.tpl @@ -17,6 +17,7 @@
$contact.name
+ {{ if $contact.alt_text }}
$contact.alt_text
{{ endif }}
$contact.itemurl
$contact.network
diff --git a/view/conversation.tpl b/view/conversation.tpl index 7d4e7d2621..ff202bbe44 100755 --- a/view/conversation.tpl +++ b/view/conversation.tpl @@ -1,6 +1,18 @@ {{ for $threads as $thread }}
- $thread.html + {{ for $thread.items as $item }} + {{if $item.comment_firstcollapsed}} +
+ $thread.num_comments $thread.hide_text +
+ {{endif}} + + {{ inc $item.template }}{{ endinc }} + + + {{ endfor }}
{{ endfor }} diff --git a/view/group_edit.tpl b/view/group_edit.tpl index 51782ab952..3689db7535 100755 --- a/view/group_edit.tpl +++ b/view/group_edit.tpl @@ -2,17 +2,21 @@
-
-
- - -
-
-$drop -
- -
-
$desc
-
-
+
+ + {{ inc field_input.tpl with $field=$gname }}{{ endinc }} + {{ if $drop }}$drop{{ endif }} +
+ +
+
+
+ + +{{ if $groupeditor }} +
+ {{ inc groupeditor.tpl }}{{ endinc }} +
+{{ endif }} +{{ if $desc }}
$desc
{{ endif }} diff --git a/view/group_new.tpl b/view/group_new.tpl deleted file mode 100755 index 735b51634d..0000000000 --- a/view/group_new.tpl +++ /dev/null @@ -1,23 +0,0 @@ - - - -
-
- -
-

-$desc - -

- - -
-
- -
- - -
-
- - \ No newline at end of file diff --git a/view/groupeditor.tpl b/view/groupeditor.tpl new file mode 100644 index 0000000000..755985eb35 --- /dev/null +++ b/view/groupeditor.tpl @@ -0,0 +1,16 @@ +
+

$groupeditor.label_members

+
+{{ for $groupeditor.members as $c}} $c {{ endfor }} +
+
+
+
+ +
+

$groupeditor.label_contacts

+
+{{ for $groupeditor.contacts as $m}} $m {{ endfor }} +
+
+
diff --git a/view/search_item.tpl b/view/search_item.tpl index de8bd23961..a889062e06 100755 --- a/view/search_item.tpl +++ b/view/search_item.tpl @@ -1,75 +1,75 @@
- $star.starred - {{ if $lock }}$lock{{ endif }} - + $item.star.starred + {{ if $item.lock }}$item.lock{{ endif }} +
-
+
- {{ for $tags as $tag }} - $tag + {{ for $item.tags as $item.tag }} + $item.tag {{ endfor }}
- {{ if $plink }}$plink.title{{ endif }} + {{ if $item.plink }}$item.plink.title{{ endif }}
- $name $ago + $item.name $item.ago
- {{ if $star }} - $star.do - $star.undo - $star.tagger + {{ if $item.star }} + $item.star.do + $item.star.undo + $item.star.tagger {{ endif }} - {{ if $vote }} - $vote.like.1 - $vote.dislike.1 + {{ if $item.vote }} + $item.vote.like.1 + $item.vote.dislike.1 {{ endif }} - {{ if $vote.share }} - $vote.share.1 + {{ if $item.vote.share }} + $item.vote.share.1 {{ endif }}
- {{ if $drop.dropping }} - - $drop.delete + {{ if $item.drop.dropping }} + + $item.drop.delete {{ endif }} - {{ if $edpost }} - + {{ if $item.edpost }} + {{ endif }}
@@ -77,11 +77,11 @@
- -
$dislike
- {{ if $conv }} -
- $conv.title + +
$item.dislike
+ {{ if $item.conv }} +
+ $item.conv.title {{ endif }}
diff --git a/view/theme/dispy/search_item.tpl b/view/theme/dispy/search_item.tpl index 3d841ab080..54c3e389c0 100755 --- a/view/theme/dispy/search_item.tpl +++ b/view/theme/dispy/search_item.tpl @@ -1,40 +1,40 @@ -
-
-
-
- - $name - menu -
+
+
+
+
+ + $item.name + menu +
    - $item_photo_menu + $item.item_photo_menu
-
{{ if $location }}$location {{ endif }}
+
{{ if $item.location }}$item.location {{ endif }}
- {{ if $lock }}
$lock
+ {{ if $item.lock }}
$item.lock
{{ else }}
{{ endif }}
-
-
- {{ if $drop.dropping }}{{ endif }} +
+
+ {{ if $item.drop.dropping }}{{ endif }}
- {{ if $drop.dropping }}{{ endif }} + {{ if $item.drop.dropping }}{{ endif }}
-
-
$title
+
+
$item.title
-
$body
+
$item.body
- $name -
$ago
+ $item.name +
$item.ago
@@ -42,10 +42,10 @@
-
-
- {{ if $conv }} - $conv.title +
+
+ {{ if $item.conv }} + $item.conv.title {{ endif }}
diff --git a/view/theme/dispy/wall_item.tpl b/view/theme/dispy/wall_item.tpl index 882843a093..0dcd30f7b4 100755 --- a/view/theme/dispy/wall_item.tpl +++ b/view/theme/dispy/wall_item.tpl @@ -1,77 +1,77 @@ -
-
-
-
- - $name +
+
+
+
+ + $item.name - menu -
+ menu +
    - $item_photo_menu + $item.item_photo_menu
-
{{ if $location }}$location {{ endif }}
+
{{ if $item.location }}$item.location {{ endif }}
- {{ if $lock }}
$lock
+ {{ if $item.lock }}
$item.lock
{{ else }}
{{ endif }}
-
- {{ if $star }} - - +
+ {{ if $item.star }} + + {{ endif }} - {{ if $vote }} -