PageRenderTime 27ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/wordpress/praized-community/includes/php/functions/friend.php

http://praized.googlecode.com/
PHP | 358 lines | 130 code | 24 blank | 204 comment | 12 complexity | 81a0cb3c211255ef06208a106af8160d MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /**
  3. * Praized template functions/helpers/tags: individual friend related functions
  4. *
  5. * @version 2.0
  6. * @package PraizedCommunity
  7. * @subpackage TemplateFunctions
  8. * @author Stephane Daury for Praized Media, Inc.
  9. * @copyright Praized Media, Inc. <http://praizedmedia.com/>
  10. * @license Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>
  11. */
  12. /**
  13. * Template function: Tests if a valid friend object is set.
  14. *
  15. * <code><?php if ( pzdc_has_friend() ) : ?>...<?php endif; ?></code>
  16. *
  17. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  18. * @return boolean
  19. * @since 0.1
  20. */
  21. function pzdc_has_friend($identifier = FALSE) {
  22. global $PraizedCommunity;
  23. return $PraizedCommunity->tpt_has_friend();
  24. }
  25. /**
  26. * Template function: Current friend object
  27. *
  28. * <code><?php $friend_object = pzdc_friend(); ?></code>
  29. *
  30. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  31. * @return mixed Boolean FALSE or Object Current friend (see params)
  32. * @since 0.1
  33. */
  34. function pzdc_friend($identifier = FALSE) {
  35. global $PraizedCommunity;
  36. if ( ! empty($identifier) )
  37. $PraizedCommunity->tpt_has_friend($identifier);
  38. return $PraizedCommunity->tpt_friend;
  39. }
  40. /**
  41. * Template function: Current friend login
  42. *
  43. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  44. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  45. * @return string
  46. * @since 0.1
  47. */
  48. function pzdc_friend_login($echo = TRUE, $identifier = FALSE) {
  49. global $PraizedCommunity;
  50. return $PraizedCommunity->tpt_attribute_helper('friend', 'login', $echo, $identifier);
  51. }
  52. /**
  53. * Template function: Current friend permalink
  54. *
  55. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  56. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  57. * @return string
  58. * @since 0.1
  59. */
  60. function pzdc_friend_permalink($echo = TRUE, $identifier = FALSE) {
  61. global $PraizedCommunity;
  62. $out = pzdc_friend_login(FALSE, $identifier);
  63. $out = $PraizedCommunity->link_helper($out, 'user');
  64. if ( $echo )
  65. echo $out;
  66. return $out;
  67. }
  68. /**
  69. * Template function: Current friend display name
  70. *
  71. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  72. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  73. * @return string
  74. * @since 2.0
  75. */
  76. function pzdc_friend_display_name($echo = TRUE, $identifier = FALSE) {
  77. global $PraizedCommunity;
  78. return $PraizedCommunity->tpt_attribute_helper('friend', 'display_name', $echo, $identifier);
  79. }
  80. /**
  81. * Template function: Current friend first name
  82. *
  83. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  84. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  85. * @return string
  86. * @since 0.1
  87. */
  88. function pzdc_friend_first_name($echo = TRUE, $identifier = FALSE) {
  89. global $PraizedCommunity;
  90. return $PraizedCommunity->tpt_attribute_helper('friend', 'first_name', $echo, $identifier);
  91. }
  92. /**
  93. * Template function: Current friend last name
  94. *
  95. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  96. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  97. * @return string
  98. * @since 0.1
  99. */
  100. function pzdc_friend_last_name($echo = TRUE, $identifier = FALSE) {
  101. global $PraizedCommunity;
  102. return $PraizedCommunity->tpt_attribute_helper('friend', 'last_name', $echo, $identifier);
  103. }
  104. /**
  105. * Template function: Current friend gender
  106. *
  107. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  108. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  109. * @return string
  110. * @since 0.1
  111. */
  112. function pzdc_friend_gender($echo = TRUE, $identifier = FALSE) {
  113. global $PraizedCommunity;
  114. return $PraizedCommunity->tpt_attribute_helper('friend', 'gender', $echo, $identifier);
  115. }
  116. /**
  117. * Template function: Current friend about
  118. *
  119. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  120. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  121. * @return string
  122. * @since 0.1
  123. */
  124. function pzdc_friend_about($echo = TRUE, $identifier = FALSE) {
  125. global $PraizedCommunity;
  126. return $PraizedCommunity->tpt_attribute_helper('friend', 'about', $echo, $identifier);
  127. }
  128. /**
  129. * Template function: Current friend date_of_birth
  130. *
  131. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  132. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  133. * @return string
  134. * @since 0.1
  135. */
  136. function pzdc_friend_date_of_birth($echo = TRUE, $identifier = FALSE) {
  137. global $PraizedCommunity;
  138. return $PraizedCommunity->tpt_attribute_helper('friend', 'date_of_birth', $echo, $identifier);
  139. }
  140. /**
  141. * Template function: Current friend claim_to_fame
  142. *
  143. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  144. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  145. * @return string
  146. * @since 0.1
  147. */
  148. function pzdc_friend_claim_to_fame($echo = TRUE, $identifier = FALSE) {
  149. global $PraizedCommunity;
  150. return $PraizedCommunity->tpt_attribute_helper('friend', 'claim_to_fame', $echo, $identifier);
  151. }
  152. /**
  153. * Template function: Current friend large avatar (140x140)
  154. *
  155. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  156. * @param string $identifier Optional friend identifier (login) for custom template development (see bundled praized-php lib)
  157. * @return string
  158. * @since 2.0
  159. */
  160. function pzdc_friend_avatar_large($echo = TRUE, $identifier = FALSE) {
  161. global $PraizedCommunity;
  162. return $PraizedCommunity->tpt_attribute_helper('friend', 'avatar->large', $echo, $identifier);
  163. }
  164. /**
  165. * Template function: Current friend medium avatar (70x70)
  166. *
  167. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  168. * @param string $identifier Optional friend identifier (login) for custom template development (see bundled praized-php lib)
  169. * @return string
  170. * @since 2.0
  171. */
  172. function pzdc_friend_avatar_medium($echo = TRUE, $identifier = FALSE) {
  173. global $PraizedCommunity;
  174. return $PraizedCommunity->tpt_attribute_helper('friend', 'avatar->medium', $echo, $identifier);
  175. }
  176. /**
  177. * Template function: Current friend small avatar (40x40)
  178. *
  179. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  180. * @param string $identifier Optional friend identifier (login) for custom template development (see bundled praized-php lib)
  181. * @return string
  182. * @since 2.0
  183. */
  184. function pzdc_friend_avatar_small($echo = TRUE, $identifier = FALSE) {
  185. global $PraizedCommunity;
  186. return $PraizedCommunity->tpt_attribute_helper('friend', 'avatar->small', $echo, $identifier);
  187. }
  188. /**
  189. * Template function: Current friend vote count
  190. *
  191. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  192. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  193. * @return string
  194. * @since 0.1
  195. */
  196. function pzdc_friend_vote_count($echo = TRUE, $identifier = FALSE) {
  197. global $PraizedCommunity;
  198. $count = intval($PraizedCommunity->tpt_attribute_helper('friend', 'votes_count', FALSE, $identifier));
  199. if ( $echo )
  200. echo $count;
  201. return $count;
  202. }
  203. /**
  204. * Template function: Current friend favorite count
  205. *
  206. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  207. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  208. * @return string
  209. * @since 0.1
  210. */
  211. function pzdc_friend_favorite_count($echo = TRUE, $identifier = FALSE) {
  212. global $PraizedCommunity;
  213. $count = intval($PraizedCommunity->tpt_attribute_helper('friend', 'favorite_count', FALSE, $identifier));
  214. if ( $echo )
  215. echo $count;
  216. return $count;
  217. }
  218. /**
  219. * Template function: Current friend comment count
  220. *
  221. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  222. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  223. * @return string
  224. * @since 0.1
  225. */
  226. function pzdc_friend_comment_count($echo = TRUE, $identifier = FALSE) {
  227. global $PraizedCommunity;
  228. $count = intval($PraizedCommunity->tpt_attribute_helper('friend', 'comment_count', FALSE, $identifier));
  229. if ( $echo )
  230. echo $count;
  231. return $count;
  232. }
  233. /**
  234. * Template function: Current friend friend count
  235. *
  236. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  237. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  238. * @return string
  239. * @since 0.1
  240. */
  241. function pzdc_friend_friend_count($echo = TRUE, $identifier = FALSE) {
  242. global $PraizedCommunity;
  243. $count = intval($PraizedCommunity->tpt_attribute_helper('friend', 'friend_count', FALSE, $identifier));
  244. if ( $echo )
  245. echo $count;
  246. return $count;
  247. }
  248. /**
  249. * Template function: Current friend creation date
  250. *
  251. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  252. * @param string $format strftime() conversion specifiers
  253. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  254. * @return string
  255. * @since 0.1
  256. */
  257. function pzdc_friend_created_at($echo = TRUE, $format = NULL, $identifier = FALSE) {
  258. global $PraizedCommunity;
  259. $out = $PraizedCommunity->tpt_attribute_helper('friend', 'created_at', FALSE, $identifier);
  260. if ( strstr($format, '%') )
  261. $out = pzdc_date($out, $format);
  262. if ( $echo )
  263. echo $out;
  264. return $out;
  265. }
  266. /**
  267. * Template function: Current friend last update date
  268. *
  269. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  270. * @param string $format strftime() conversion specifiers
  271. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  272. * @return string
  273. * @since 0.1
  274. */
  275. function pzdc_friend_updated_at($echo = TRUE, $format = NULL, $identifier = FALSE) {
  276. global $PraizedCommunity;
  277. $out = $PraizedCommunity->tpt_attribute_helper('friend', 'updated_at', FALSE, $identifier);
  278. if ( strstr($format, '%') )
  279. $out = pzdc_date($out, $format);
  280. if ( $echo )
  281. echo $out;
  282. return $out;
  283. }
  284. /**
  285. * Template function: Tests if the current displayed friend is already in the authn'd friend's friends
  286. *
  287. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  288. * @return boolean
  289. * @since 0.1
  290. */
  291. function pzdc_friend_is_self_friend($identifier = FALSE) {
  292. global $PraizedCommunity;
  293. if ( ! empty($identifier) )
  294. $PraizedCommunity->tpt_has_friend($identifier);
  295. return $PraizedCommunity->tpt_friend_is_friend('self');
  296. }
  297. /**
  298. * Template function: Returns the value of the current displayed friend's self-friend node, related to the current authn'd friend.
  299. *
  300. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  301. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  302. * @return string
  303. * @since 0.1
  304. */
  305. function pzdc_friend_self_friend($echo = TRUE, $identifier = FALSE) {
  306. global $PraizedCommunity;
  307. return $PraizedCommunity->tpt_attribute_helper('friend', 'self->friend', $echo, $identifier);
  308. }
  309. /**
  310. * Template function: Tests if the current displayed friend is already in the displayed friend's friends
  311. *
  312. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  313. * @return boolean
  314. * @since 0.1
  315. */
  316. function pzdc_friend_is_target_friend($identifier = FALSE) {
  317. global $PraizedCommunity;
  318. if ( ! empty($identifier) )
  319. $PraizedCommunity->tpt_has_friend($identifier);
  320. return $PraizedCommunity->tpt_friend_is_friend('target');
  321. }
  322. /**
  323. * Template function: Returns the value of the current displayed friend's target->friend node, related to the current authn'd friend.
  324. *
  325. * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
  326. * @param string $identifier Optional user identifier (login) for custom template development (see bundled praized-php lib)
  327. * @return string
  328. * @since 0.1
  329. */
  330. function pzdc_friend_target_friend($echo = TRUE, $identifier = FALSE) {
  331. global $PraizedCommunity;
  332. return $PraizedCommunity->tpt_attribute_helper('friend', 'target->friend', $echo, $identifier);
  333. }
  334. ?>