/apps/netcoid/profiles.php

https://github.com/wamplo/red · PHP · 314 lines · 223 code · 49 blank · 42 comment · 9 complexity · 8f4612446cfc11c28c4478cdba065541 MD5 · raw file

  1. <?php
  2. /**
  3. * CORE NODE
  4. */
  5. use Engine\libraries\Assets;
  6. use Engine\libraries\RedRiver;
  7. use Engine\libraries\Memcached;
  8. use Engine\libraries\Social;
  9. use Engine\libraries\Forms;
  10. use Engine\libraries\Sessions;
  11. use Engine\libraries\Pagination;
  12. use Engine\libraries\Flash;
  13. class Profiles Extends Engine\Red
  14. {
  15. public $a, $r, $e;
  16. public function __construct(){
  17. $this->a = new Assets;
  18. $this->r = new RedRiver;
  19. $this->e = new Sessions;
  20. $this->i = new Pagination;
  21. $this->h = new Flash;
  22. $this->u = new Apps\Netcoid\Models\Users;
  23. }
  24. private function __securitycheck($username){
  25. if (!$this->u->getData($username)) {
  26. header('HTTP/1.1 404 Not Found');
  27. echo '404';
  28. die();
  29. }
  30. }
  31. /**
  32. * www.networks.co.id/(username)/Posts
  33. * Search Page Netcoid
  34. * @author Adam Ramadhan
  35. * @version 1
  36. **/
  37. public function Posts($username){
  38. $this->__securitycheck($username);
  39. $p = new Apps\Netcoid\Models\Posts;
  40. $o = new Apps\Netcoid\Models\Follow;
  41. $userdata = $this->u->getData($username);
  42. $this->__Header($userdata['name'] . ' &mdash; Posts');
  43. $this->h->showAll(); # SHOW FLASH
  44. $postdata = array(
  45. 'user' => $userdata,
  46. 'follow' => $o->isFollowingUID($this->e->get('uid'), $userdata['uid']),
  47. 'posts' => $p->getPostbyUID($userdata['uid'], 20, $this->i->curroffset),
  48. 'pagination' => $this->i,
  49. 'login' => $this->e->get('uid'),
  50. 'ispost0' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset),
  51. 'ispost1' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset,1),
  52. 'ispost2' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset,2)
  53. );
  54. $this->i->maxperpage = 20;
  55. $this->i->totalrow = $p->CountPostsbyUID($userdata['uid']);
  56. $this->i->currrow = count($postdata['posts']);
  57. $this->r->branch(array(
  58. 'src' =>
  59. array(
  60. 'html' => $this->a->getView('netcoid','profiles/posts.php',$postdata),
  61. 'id' => 'rr-2'
  62. ),
  63. 'css' =>
  64. array(
  65. $this->a->getPath('default','css/framework.css'),
  66. $this->a->getPath('netcoid','css/main.v2.css'),
  67. $this->a->getPath('netcoid','css/profile.css'),
  68. $this->a->getPath('netcoid','css/pagination.css')
  69. ),
  70. 'cache' => 0
  71. ),1); # START
  72. $this->__Footer();
  73. }
  74. /**
  75. * www.networks.co.id/(username)/Offers
  76. * Search Page Netcoid
  77. * @author Adam Ramadhan
  78. * @version 1
  79. **/
  80. public function Offers($username){
  81. $this->__securitycheck($username);
  82. $p = new Apps\Netcoid\Models\Posts;
  83. $o = new Apps\Netcoid\Models\Follow;
  84. $userdata = $this->u->getData($username);
  85. $this->__Header($userdata['name'] . ' &mdash; Penawaran');
  86. $this->h->showAll(); # SHOW FLASH
  87. $offerdata = array(
  88. 'user' => $userdata,
  89. 'follow' => $o->isFollowingUID($this->e->get('uid'), $userdata['uid']),
  90. 'posts' => $p->getPostbyUID($userdata['uid'], 20, $this->i->curroffset,1),
  91. 'pagination' => $this->i,
  92. 'login' => $this->e->get('uid'),
  93. 'ispost0' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset),
  94. 'ispost1' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset,1),
  95. 'ispost2' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset,2)
  96. );
  97. $this->i->maxperpage = 20;
  98. $this->i->totalrow = $p->CountPostsbyUID($userdata['uid'],1);
  99. $this->i->currrow = count($offerdata['posts']);
  100. $this->r->branch(array(
  101. 'src' =>
  102. array(
  103. 'html' => $this->a->getView('netcoid','profiles/posts.php',$offerdata),
  104. 'id' => 'rr-2'
  105. ),
  106. 'css' =>
  107. array(
  108. $this->a->getPath('default','css/framework.css'),
  109. $this->a->getPath('netcoid','css/main.v2.css'),
  110. $this->a->getPath('netcoid','css/profile.css'),
  111. $this->a->getPath('netcoid','css/pagination.css')
  112. ),
  113. 'cache' => 0
  114. ),1); # START
  115. $this->__Footer();
  116. }
  117. /**
  118. * www.networks.co.id/(username)/Requests
  119. * Search Page Netcoid
  120. * @author Adam Ramadhan
  121. * @version 1
  122. **/
  123. public function Requests($username){
  124. $this->__securitycheck($username);
  125. $p = new Apps\Netcoid\Models\Posts;
  126. $o = new Apps\Netcoid\Models\Follow;
  127. $userdata = $this->u->getData($username);
  128. $this->__Header($userdata['name'] . ' &mdash; Permintaan');
  129. $this->h->showAll(); # SHOW FLASH
  130. $offerdata = array(
  131. 'user' => $userdata,
  132. 'follow' => $o->isFollowingUID($this->e->get('uid'), $userdata['uid']),
  133. 'posts' => $p->getPostbyUID($userdata['uid'], 20, $this->i->curroffset,2),
  134. 'pagination' => $this->i,
  135. 'login' => $this->e->get('uid'),
  136. 'ispost0' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset),
  137. 'ispost1' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset,1),
  138. 'ispost2' => $p->getPostbyUID($userdata['uid'], 1, $this->i->curroffset,2)
  139. );
  140. $this->i->maxperpage = 20;
  141. $this->i->totalrow = $p->CountPostsbyUID($userdata['uid'],2);
  142. $this->i->currrow = count($offerdata['posts']);
  143. $this->r->branch(array(
  144. 'src' =>
  145. array(
  146. 'html' => $this->a->getView('netcoid','profiles/posts.php',$offerdata),
  147. 'id' => 'rr-2'
  148. ),
  149. 'css' =>
  150. array(
  151. $this->a->getPath('default','css/framework.css'),
  152. $this->a->getPath('netcoid','css/main.v2.css'),
  153. $this->a->getPath('netcoid','css/profile.css'),
  154. $this->a->getPath('netcoid','css/pagination.css')
  155. ),
  156. 'cache' => 0
  157. ),1); # START
  158. $this->__Footer();
  159. }
  160. /**
  161. * www.networks.co.id/(username)
  162. * Search Page Netcoid
  163. * @author Adam Ramadhan
  164. * @version 1
  165. **/
  166. public function Index($username){
  167. $this->__securitycheck($username);
  168. $o = new Apps\Netcoid\Models\Follow;
  169. $p = new Apps\Netcoid\Models\Posts;
  170. $user = $this->u->getData($username);
  171. $this->__Header($user['name']);
  172. $this->h->showAll(); # SHOW FLASH
  173. # @TODO OPTIMASI DATANYA
  174. $profiledata = array(
  175. 'user' => $user,
  176. 'login' => $this->e->get('uid'),
  177. 'follow' => $o->isFollowingUID($this->e->get('uid'), $user['uid']),
  178. 'ispost0' => $p->getPostbyUID($user['uid'], 1, $this->i->curroffset),
  179. 'ispost1' => $p->getPostbyUID($user['uid'], 1, $this->i->curroffset,1),
  180. 'ispost2' => $p->getPostbyUID($user['uid'], 1, $this->i->curroffset,2)
  181. );
  182. $this->r->branch(array(
  183. 'src' =>
  184. array(
  185. 'html' => $this->a->getView('netcoid','profiles/index.php',$profiledata),
  186. 'id' => 'rr-2'
  187. ),
  188. 'css' =>
  189. array(
  190. $this->a->getPath('default','css/framework.css'),
  191. $this->a->getPath('netcoid','css/main.v2.css'),
  192. $this->a->getPath('netcoid','css/profile.css'),
  193. $this->a->getPath('netcoid','css/blog.css'),
  194. ),
  195. 'cache' => 0
  196. ),1); # START
  197. $this->__Footer();
  198. }
  199. /**
  200. * FRAMEWORK __HEADER
  201. * @author Adam Ramadhan
  202. * @version 1 + PJAX
  203. **/
  204. private function __Header($title = 'Netcoid &mdash; jejaring bisnis indonesia', $desc = 'Netcoid, jejaring bisnis indonesia, menghubungkan pelaku bisnis indonesia'){
  205. if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" ) {
  206. echo "<title>$title</title>";
  207. # AN AJAX REQUEAST && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == $request
  208. # var_dump($_SERVER);
  209. } else {
  210. echo $this->a->getView('netcoid','framework/header.php',
  211. array(
  212. 'title' => $title,
  213. 'description' => $desc
  214. )
  215. );
  216. $o = new Apps\Netcoid\Models\Mentions;
  217. $m = new Apps\Netcoid\Models\Messages;
  218. $menudata = array(
  219. 'sessions' => $this->e,
  220. 'countmentions' => $o->countMentionUID($this->e->get('uid')),
  221. 'countmessages' => $m->countMessageUID($this->e->get('uid'))
  222. );
  223. $this->r->branch(array(
  224. 'src' =>
  225. array(
  226. 'html' => $this->a->getView('netcoid','framework/menu.php', $menudata),
  227. 'id' => 'rr-1'
  228. ),
  229. 'css' =>
  230. array(
  231. $this->a->getPath('default','css/framework.css'),
  232. $this->a->getPath('netcoid','css/main.v2.css')
  233. ),
  234. 'cache' => 0
  235. ),0); # START
  236. }
  237. }
  238. /**
  239. * FRAMEWORK __FOOTER
  240. * @author Adam Ramadhan
  241. * @version 1 + PJAX
  242. **/
  243. private function __Footer(){
  244. if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest" ) {
  245. # AN AJAX REQUEAST && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == $request
  246. # var_dump($_SERVER);
  247. } else {
  248. $this->r->branch(array(
  249. 'src' =>
  250. array(
  251. 'html' => $this->a->getView('netcoid','framework/bottom.php'),
  252. 'id' => 'rr-3'
  253. ),
  254. 'css' =>
  255. array(
  256. $this->a->getPath('default','css/framework.css'),
  257. $this->a->getPath('netcoid','css/main.v2.css')
  258. ),
  259. 'cache' => 0
  260. ),2); # END
  261. echo $this->a->getView('netcoid','Framework/Footer.php');
  262. }
  263. }
  264. }
  265. ?>