start.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <?php
  2. /**
  3. * Photo Gallery plugin
  4. *
  5. * @author Cash Costello
  6. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
  7. */
  8. elgg_register_event_handler('init', 'system', 'tidypics_init');
  9. /**
  10. * Tidypics plugin initialization
  11. */
  12. function tidypics_init() {
  13. // Register libraries
  14. $base_dir = elgg_get_plugins_path() . 'tidypics/lib';
  15. elgg_register_library('tidypics:core', "$base_dir/tidypics.php");
  16. elgg_register_library('tidypics:upload', "$base_dir/upload.php");
  17. elgg_register_library('tidypics:resize', "$base_dir/resize.php");
  18. elgg_register_library('tidypics:exif', "$base_dir/exif.php");
  19. elgg_load_library('tidypics:core');
  20. // Register an ajax view that allows selection of album to upload images to
  21. elgg_register_ajax_view('photos/selectalbum');
  22. // Set up site menu
  23. elgg_register_menu_item('site', array(
  24. 'name' => 'photos',
  25. 'href' => 'photos/siteimagesall',
  26. 'text' => elgg_echo('photos'),
  27. ));
  28. // Register a page handler so we can have nice URLs
  29. elgg_register_page_handler('photos', 'tidypics_page_handler');
  30. // Extend CSS
  31. elgg_extend_view('css/elgg', 'photos/css');
  32. elgg_extend_view('css/admin', 'photos/css');
  33. // Register the JavaScript lib
  34. $js = elgg_get_simplecache_url('js', 'photos/tidypics');
  35. elgg_register_simplecache_view('js/photos/tidypics');
  36. elgg_register_js('tidypics', $js, 'footer');
  37. $js = elgg_get_simplecache_url('js', 'photos/tagging');
  38. elgg_register_simplecache_view('js/photos/tagging');
  39. elgg_register_js('tidypics:tagging', $js, 'footer');
  40. $js = elgg_get_simplecache_url('js', 'photos/uploading');
  41. elgg_register_simplecache_view('js/photos/uploading');
  42. elgg_register_js('tidypics:uploading', $js, 'footer');
  43. elgg_register_js('tidypics:slideshow', 'mod/tidypics/vendors/PicLensLite/piclens_optimized.js');
  44. elgg_register_js('jquery.plupload-tp', 'mod/tidypics/vendors/plupload/js/plupload.full.min.js', 'footer');
  45. elgg_register_js('jquery.plupload.ui-tp', 'mod/tidypics/vendors/plupload/js/jquery.ui.plupload/jquery.ui.plupload.min.js', 'footer');
  46. $plupload_language = get_plugload_language();
  47. elgg_register_js('jquery.plupload.ui.lang-tp', 'mod/tidypics/vendors/plupload/js/i18n/' . $plupload_language . '.js', 'footer');
  48. elgg_register_css('jquery.plupload.jqueryui-theme', 'mod/tidypics/vendors/jqueryui/css/smoothness/jquery-ui-1.10.4.custom.min.css');
  49. elgg_register_css('jquery.plupload.ui', 'mod/tidypics/vendors/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css');
  50. // Add photos link to owner block/hover menus
  51. elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'tidypics_owner_block_menu');
  52. // Add admin menu item
  53. elgg_register_admin_menu_item('configure', 'photos', 'settings');
  54. // Register for search
  55. elgg_register_entity_type('object', 'image');
  56. elgg_register_entity_type('object', 'album');
  57. // Register for the entity menu
  58. elgg_register_plugin_hook_handler('register', 'menu:entity', 'tidypics_entity_menu_setup');
  59. // Register group options
  60. add_group_tool_option('photos', elgg_echo('tidypics:enablephotos'), true);
  61. elgg_extend_view('groups/tool_latest', 'photos/group_module');
  62. add_group_tool_option('tp_images', elgg_echo('tidypics:enable_group_images'), true);
  63. elgg_extend_view('groups/tool_latest', 'photos/group_tp_images_module');
  64. // Register widgets
  65. elgg_register_widget_type('album_view', elgg_echo("tidypics:widget:albums"), elgg_echo("tidypics:widget:album_descr"), array('profile'));
  66. elgg_register_widget_type('latest_photos', elgg_echo("tidypics:widget:latest"), elgg_echo("tidypics:widget:latest_descr"), array('profile'));
  67. if (elgg_is_active_plugin('widget_manager')) {
  68. //add index widgets for Widget Manager plugin
  69. elgg_register_widget_type('index_latest_photos', elgg_echo("tidypics:mostrecent"), elgg_echo('tidypics:mostrecent:description'), array('index'));
  70. elgg_register_widget_type('index_latest_albums', elgg_echo("tidypics:albums_mostrecent"), elgg_echo('tidypics:albums_mostrecent:description'), array('index'));
  71. //add groups widgets for Widget Manager plugin
  72. elgg_register_widget_type('groups_latest_photos', elgg_echo("tidypics:mostrecent"), elgg_echo('tidypics:mostrecent:description'), array('groups'));
  73. elgg_register_widget_type('groups_latest_albums', elgg_echo("tidypics:albums_mostrecent"), elgg_echo('tidypics:albums_mostrecent:description'), array('groups'));
  74. //register title urls for widgets
  75. elgg_register_plugin_hook_handler('widget_url', 'widget_manager', "tidypics_widget_urls", 499);
  76. }
  77. // RSS extensions for embedded media
  78. elgg_extend_view('extensions/xmlns', 'extensions/photos/xmlns');
  79. // allow group members add photos to group albums
  80. elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'tidypics_group_permission_override');
  81. elgg_register_plugin_hook_handler('permissions_check:metadata', 'object', 'tidypics_group_permission_override');
  82. // notifications
  83. elgg_register_notification_event('object', 'album', array('album_first', 'album_more'));
  84. elgg_register_plugin_hook_handler('prepare', 'notification:album_first:object:album', 'tidypics_notify_message');
  85. elgg_register_plugin_hook_handler('prepare', 'notification:album_more:object:album', 'tidypics_notify_message');
  86. // allow people in a walled garden to use flash uploader
  87. elgg_register_plugin_hook_handler('public_pages', 'walled_garden', 'tidypics_walled_garden_override');
  88. // override the default url to view a tidypics_batch object
  89. elgg_register_plugin_hook_handler('entity:url', 'object', 'tidypics_batch_url_handler');
  90. // custom layout for comments on tidypics river entries
  91. elgg_register_plugin_hook_handler('creating', 'river', 'tidypics_comments_handler');
  92. // Register actions
  93. $base_dir = elgg_get_plugins_path() . 'tidypics/actions/photos';
  94. elgg_register_action("photos/delete", "$base_dir/delete.php");
  95. elgg_register_action("photos/album/save", "$base_dir/album/save.php");
  96. elgg_register_action("photos/album/sort", "$base_dir/album/sort.php");
  97. elgg_register_action("photos/album/set_cover", "$base_dir/album/set_cover.php");
  98. elgg_register_action("photos/image/upload", "$base_dir/image/upload.php");
  99. elgg_register_action("photos/image/save", "$base_dir/image/save.php");
  100. elgg_register_action("photos/image/ajax_upload", "$base_dir/image/ajax_upload.php", 'logged_in');
  101. elgg_register_action("photos/image/ajax_upload_complete", "$base_dir/image/ajax_upload_complete.php", 'logged_in');
  102. elgg_register_action("photos/image/tag", "$base_dir/image/tag.php");
  103. elgg_register_action("photos/image/untag", "$base_dir/image/untag.php");
  104. elgg_register_action("photos/batch/edit", "$base_dir/batch/edit.php");
  105. elgg_register_action("photos/admin/settings", "$base_dir/admin/settings.php", 'admin');
  106. elgg_register_action("photos/admin/create_thumbnails", "$base_dir/admin/create_thumbnails.php", 'admin');
  107. elgg_register_action("photos/admin/delete_image", "$base_dir/admin/delete_image.php", 'admin');
  108. elgg_register_action("photos/admin/upgrade", "$base_dir/admin/upgrade.php", 'admin');
  109. elgg_register_action('photos/image/selectalbum', "$base_dir/image/selectalbum.php");
  110. }
  111. /**
  112. * Tidypics page handler
  113. *
  114. * @param array $page Array of url segments
  115. * @return bool
  116. */
  117. function tidypics_page_handler($page) {
  118. if (!isset($page[0])) {
  119. return false;
  120. }
  121. elgg_load_js('tidypics');
  122. elgg_load_js('lightbox');
  123. elgg_load_css('lightbox');
  124. if (elgg_get_plugin_setting('slideshow', 'tidypics')) {
  125. elgg_load_js('tidypics:slideshow');
  126. }
  127. $base = elgg_get_plugins_path() . 'tidypics/pages/photos';
  128. $base_lists = elgg_get_plugins_path() . 'tidypics/pages/lists';
  129. switch ($page[0]) {
  130. case "siteimagesall":
  131. require "$base_lists/siteimagesall.php";
  132. break;
  133. case "siteimagesowner":
  134. if (isset($page[1])) {
  135. set_input('guid', $page[1]);
  136. }
  137. require "$base_lists/siteimagesowner.php";
  138. break;
  139. case "siteimagesfriends":
  140. require "$base_lists/siteimagesfriends.php";
  141. break;
  142. case "siteimagesgroup":
  143. if (isset($page[1])) {
  144. set_input('guid', $page[1]);
  145. }
  146. require "$base_lists/siteimagesgroup.php";
  147. break;
  148. case "all": // all site albums
  149. case "world":
  150. require "$base/all.php";
  151. break;
  152. case "owned": // albums owned by container entity
  153. case "owner":
  154. require "$base/owner.php";
  155. break;
  156. case "friends": // albums of friends
  157. require "$base/friends.php";
  158. break;
  159. case "group": // albums of a group
  160. require "$base/owner.php";
  161. break;
  162. case "album": // view an album individually
  163. set_input('guid', $page[1]);
  164. require "$base/album/view.php";
  165. break;
  166. case "new": // create new album
  167. case "add":
  168. set_input('guid', $page[1]);
  169. require "$base/album/add.php";
  170. break;
  171. case "edit": //edit image or album
  172. set_input('guid', $page[1]);
  173. $entity = get_entity($page[1]);
  174. switch ($entity->getSubtype()) {
  175. case 'album':
  176. require "$base/album/edit.php";
  177. break;
  178. case 'image':
  179. require "$base/image/edit.php";
  180. break;
  181. case 'tidypics_batch':
  182. require "$base/batch/edit.php";
  183. break;
  184. default:
  185. return false;
  186. }
  187. break;
  188. case "sort": // sort a photo album
  189. set_input('guid', $page[1]);
  190. require "$base/album/sort.php";
  191. break;
  192. case "image": //view an image
  193. case "view":
  194. set_input('guid', $page[1]);
  195. require "$base/image/view.php";
  196. break;
  197. case "thumbnail": // tidypics thumbnail
  198. set_input('guid', $page[1]);
  199. set_input('size', elgg_extract(2, $page, 'small'));
  200. require "$base/image/thumbnail.php";
  201. break;
  202. case "upload": // upload images to album
  203. set_input('guid', $page[1]);
  204. if (elgg_get_plugin_setting('uploader', 'tidypics')) {
  205. $default_uploader = 'ajax';
  206. } else {
  207. $default_uploader = 'basic';
  208. }
  209. set_input('uploader', elgg_extract(2, $page, $default_uploader));
  210. require "$base/image/upload.php";
  211. break;
  212. case "download": // download an image
  213. set_input('guid', $page[1]);
  214. set_input('disposition', elgg_extract(2, $page, 'attachment'));
  215. include "$base/image/download.php";
  216. break;
  217. case "tagged": // all photos tagged with user
  218. if (isset($page[1])) {
  219. set_input('guid', $page[1]);
  220. }
  221. require "$base/tagged.php";
  222. break;
  223. case "mostviewed": // images with the most views
  224. if (isset($page[1])) {
  225. set_input('username', $page[1]);
  226. }
  227. require "$base_lists/mostviewedimages.php";
  228. break;
  229. case "mostviewedtoday":
  230. if (isset($page[1])) {
  231. set_input('username', $page[1]);
  232. }
  233. require "$base_lists/mostviewedimagestoday.php";
  234. break;
  235. case "mostviewedthismonth":
  236. if (isset($page[1])) {
  237. set_input('username', $page[1]);
  238. }
  239. require "$base_lists/mostviewedimagesthismonth.php";
  240. break;
  241. case "mostviewedlastmonth":
  242. if (isset($page[1])) {
  243. set_input('username', $page[1]);
  244. }
  245. require "$base_lists/mostviewedimageslastmonth.php";
  246. break;
  247. case "mostviewedthisyear":
  248. if (isset($page[1])) {
  249. set_input('username', $page[1]);
  250. }
  251. require "$base_lists/mostviewedimagesthisyear.php";
  252. break;
  253. case "mostcommented":
  254. if (isset($page[1])) {
  255. set_input('username', $page[1]);
  256. }
  257. require "$base_lists/mostcommentedimages.php";
  258. break;
  259. case "mostcommentedtoday":
  260. if (isset($page[1])) {
  261. set_input('username', $page[1]);
  262. }
  263. require "$base_lists/mostcommentedimagestoday.php";
  264. break;
  265. case "mostcommentedthismonth":
  266. if (isset($page[1])) {
  267. set_input('username', $page[1]);
  268. }
  269. require "$base_lists/mostcommentedimagesthismonth.php";
  270. break;
  271. case "mostcommentedlastmonth":
  272. if (isset($page[1])) {
  273. set_input('username', $page[1]);
  274. }
  275. require "$base_lists/mostcommentedimageslastmonth.php";
  276. break;
  277. case "mostcommentedthisyear":
  278. if (isset($page[1])) {
  279. set_input('username', $page[1]);
  280. }
  281. require "$base_lists/mostcommentedimagesthisyear.php";
  282. break;
  283. case "recentlyviewed":
  284. require "$base_lists/recentlyviewed.php";
  285. break;
  286. case "recentlycommented":
  287. require "$base_lists/recentlycommented.php";
  288. break;
  289. case "recentvotes":
  290. if(elgg_is_active_plugin('elggx_fivestar')) {
  291. require "$base_lists/recentvotes.php";
  292. break;
  293. } else {
  294. return false;
  295. }
  296. case "highestrated":
  297. if(elgg_is_active_plugin('elggx_fivestar')) {
  298. require "$base_lists/highestrated.php";
  299. break;
  300. } else {
  301. return false;
  302. }
  303. case "highestvotecount":
  304. if(elgg_is_active_plugin('elggx_fivestar')) {
  305. require "$base_lists/highestvotecount.php";
  306. break;
  307. } else {
  308. return false;
  309. }
  310. default:
  311. return false;
  312. }
  313. return true;
  314. }
  315. /**
  316. * Add a menu item to an ownerblock
  317. */
  318. function tidypics_owner_block_menu($hook, $type, $return, $params) {
  319. if (elgg_instanceof($params['entity'], 'user')) {
  320. $url = "photos/siteimagesowner/{$params['entity']->guid}";
  321. $item = new ElggMenuItem('photos', elgg_echo('photos'), $url);
  322. $return[] = $item;
  323. } else {
  324. if ($params['entity']->tp_images_enable != "no") {
  325. $url = "photos/siteimagesgroup/{$params['entity']->guid}";
  326. $item = new ElggMenuItem('photos', elgg_echo('photos:group'), $url);
  327. $return[] = $item;
  328. }
  329. }
  330. if (elgg_instanceof($params['entity'], 'user')) {
  331. $url = "photos/owner/{$params['entity']->username}";
  332. $item = new ElggMenuItem('photo_albums', elgg_echo('albums'), $url);
  333. $return[] = $item;
  334. } else {
  335. if ($params['entity']->photos_enable != "no") {
  336. $url = "photos/group/{$params['entity']->guid}/all";
  337. $item = new ElggMenuItem('photo_albums', elgg_echo('photos:group_albums'), $url);
  338. $return[] = $item;
  339. }
  340. }
  341. return $return;
  342. }
  343. /**
  344. * Add Tidypics links/info to entity menu
  345. */
  346. function tidypics_entity_menu_setup($hook, $type, $return, $params) {
  347. if (elgg_in_context('widgets')) {
  348. return $return;
  349. }
  350. $entity = $params['entity'];
  351. $handler = elgg_extract('handler', $params, false);
  352. if ($handler != 'photos') {
  353. return $return;
  354. }
  355. if (elgg_instanceof($entity, 'object', 'image')) {
  356. $album = $entity->getContainerEntity();
  357. $cover_guid = $album->getCoverImageGuid();
  358. if ($cover_guid != $entity->getGUID() && $album->canEdit()) {
  359. $url = 'action/photos/album/set_cover'
  360. . '?image_guid=' . $entity->getGUID()
  361. . '&album_guid=' . $album->getGUID();
  362. $params = array(
  363. 'href' => $url,
  364. 'text' => elgg_echo('album:cover_link'),
  365. 'is_action' => true,
  366. 'is_trusted' => true,
  367. 'confirm' => elgg_echo('album:cover')
  368. );
  369. $text = elgg_view('output/confirmlink', $params);
  370. $options = array(
  371. 'name' => 'set_cover',
  372. 'text' => $text,
  373. 'priority' => 80,
  374. );
  375. $return[] = ElggMenuItem::factory($options);
  376. }
  377. if (elgg_get_plugin_setting('view_count', 'tidypics')) {
  378. $view_info = $entity->getViewInfo();
  379. $text = elgg_echo('tidypics:views', array((int)$view_info['total']));
  380. $options = array(
  381. 'name' => 'views',
  382. 'text' => "<span>$text</span>",
  383. 'href' => false,
  384. 'priority' => 90,
  385. );
  386. $return[] = ElggMenuItem::factory($options);
  387. }
  388. if (elgg_get_plugin_setting('tagging', 'tidypics') && elgg_is_logged_in()) {
  389. $options = array(
  390. 'name' => 'tagging',
  391. 'text' => elgg_echo('tidypics:actiontag'),
  392. 'href' => '#',
  393. 'title' => elgg_echo('tidypics:tagthisphoto'),
  394. 'rel' => 'photo-tagging',
  395. 'priority' => 80,
  396. );
  397. $return[] = ElggMenuItem::factory($options);
  398. }
  399. }
  400. return $return;
  401. }
  402. function tidypics_widget_urls($hook_name, $entity_type, $return_value, $params){
  403. $result = $return_value;
  404. $widget = $params["entity"];
  405. if(empty($result) && ($widget instanceof ElggWidget)) {
  406. $owner = $widget->getOwnerEntity();
  407. switch($widget->handler) {
  408. case "latest_photos":
  409. $result = "/photos/siteimagesowner/" . $owner->guid;
  410. break;
  411. case "album_view":
  412. $result = "/photos/owner/" . $owner->username;
  413. break;
  414. case "index_latest_photos":
  415. $result = "/photos/siteimagesall";
  416. break;
  417. case "index_latest_albums":
  418. $result = "/photos/all";
  419. break;
  420. case "groups_latest_photos":
  421. if($owner instanceof ElggGroup){
  422. $result = "photos/siteimagesgroup/{$owner->guid}";
  423. } else {
  424. $result = "/photos/siteimagesowner/" . $owner->guid;
  425. }
  426. break;
  427. case "groups_latest_albums":
  428. if($owner instanceof ElggGroup){
  429. $result = "photos/group/{$owner->guid}/all";
  430. } else {
  431. $result = "/photos/owner/" . $owner->username;
  432. }
  433. break;
  434. }
  435. }
  436. return $result;
  437. }
  438. /**
  439. * Override permissions for group albums
  440. *
  441. * 1. To write to a container (album) you must be able to write to the owner of the container (odd)
  442. * 2. We also need to change metadata on the album
  443. *
  444. * @param string $hook
  445. * @param string $type
  446. * @param bool $result
  447. * @param array $params
  448. * @return mixed
  449. */
  450. function tidypics_group_permission_override($hook, $type, $result, $params) {
  451. if (get_input('action') == 'photos/image/upload' || get_input('action') == 'photos/image/ajax_upload' || get_input('action') == 'photos/image/ajax_upload_complete') {
  452. if (isset($params['container'])) {
  453. $album = $params['container'];
  454. } else {
  455. $album = $params['entity'];
  456. }
  457. if (elgg_instanceof($album, 'object', 'album')) {
  458. return $album->getContainerEntity()->canWriteToContainer();
  459. }
  460. }
  461. }
  462. /**
  463. *
  464. * Prepare a notification message about a new images added to an album
  465. *
  466. * Does not run if a new album without photos
  467. *
  468. * @param string $hook Hook name
  469. * @param string $type Hook type
  470. * @param Elgg_Notifications_Notification $notification The notification to prepare
  471. * @param array $params Hook parameters
  472. * @return Elgg_Notifications_Notification (on Elgg 1.9); mixed (on Elgg 1.8)
  473. */
  474. function tidypics_notify_message($hook, $type, $notification, $params) {
  475. $entity = $params['event']->getObject();
  476. if (elgg_instanceof($entity, 'object', 'album')) {
  477. $owner = $params['event']->getActor();
  478. $recipient = $params['recipient'];
  479. $language = $params['language'];
  480. $method = $params['method'];
  481. $descr = $entity->description;
  482. $title = $entity->getTitle();
  483. if ($type == 'notification:album_first:object:album') {
  484. $notification->subject = elgg_echo('tidypics:notify:subject_newalbum', array($entity->title), $language);
  485. $notification->body = elgg_echo('tidypics:notify:body_newalbum', array($owner->name, $title, $entity->getURL()), $language);
  486. $notification->summary = elgg_echo('tidypics:notify:summary_newalbum', array($entity->title), $language);
  487. return $notification;
  488. } else {
  489. $notification->subject = elgg_echo('tidypics:notify:subject_updatealbum', array($entity->title), $language);
  490. $notification->body = elgg_echo('tidypics:notify:body_updatealbum', array($owner->name, $title, $entity->getURL()), $language);
  491. $notification->summary = elgg_echo('tidypics:notify:summary_updatealbum', array($entity->title), $language);
  492. return $notification;
  493. }
  494. }
  495. }
  496. /**
  497. * Allows the flash uploader actions through walled garden since
  498. * they come without the session cookie
  499. */
  500. function tidypics_walled_garden_override($hook, $type, $pages) {
  501. $pages[] = 'action/photos/image/ajax_upload';
  502. $pages[] = 'action/photos/image/ajax_upload_complete';
  503. return $pages;
  504. }
  505. /**
  506. * return the album url of the album the tidypics_batch entitities belongs to
  507. */
  508. function tidypics_batch_url_handler($hook, $type, $url, $params) {
  509. $batch = $params['entity'];
  510. if (elgg_instanceof($batch, 'object', 'tidypics_batch')) {
  511. if (!$batch->getOwnerEntity()) {
  512. // default to a standard view if no owner.
  513. return false;
  514. }
  515. $album = get_entity($batch->container_guid);
  516. return $album->getURL();
  517. }
  518. }
  519. /**
  520. * custom layout for comments on tidypics river entries
  521. *
  522. * Overriding generic_comment view
  523. */
  524. function tidypics_comments_handler($hook, $type, $value, $params) {
  525. $result = $value;
  526. $action_type = $value['action_type'];
  527. if ($action_type != 'comment') {
  528. return;
  529. }
  530. $target_guid = $value['target_guid'];
  531. if (!$target_guid) {
  532. return;
  533. }
  534. $target_entity = get_entity($target_guid);
  535. $subtype = $target_entity->getSubtype();
  536. if ($subtype == 'image') {
  537. // update river entry attributes
  538. $result['view'] = 'river/object/comment/image';
  539. } else if ($subtype == 'album') {
  540. // update river entry attributes
  541. $result['view'] = 'river/object/comment/album';
  542. } else {
  543. return;
  544. }
  545. return $result;
  546. }
  547. function get_plugload_language() {
  548. if ($current_language = get_current_language()) {
  549. $path = elgg_get_plugins_path() . "tidypics/vendors/plupload/js/i18n";
  550. if (file_exists("$path/$current_language.js")) {
  551. return $current_language;
  552. }
  553. }
  554. return 'en';
  555. }