PageRenderTime 43ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/album/bpm_audio/loader.php

http://buddypress-media.googlecode.com/
PHP | 806 lines | 344 code | 195 blank | 267 comment | 47 complexity | 639cf7ac32e32aa1ffb543023e468fd5 MD5 | raw file
Possible License(s): AGPL-1.0, Apache-2.0, GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * ALBUM MODULE - BPM Audio
  4. * The audio layout for BP-Media
  5. *
  6. * @version 0.1.9
  7. * @since 0.1.9
  8. * @package BP-Media
  9. * @subpackage Album Modules
  10. * @license GPL v2.0
  11. * @link http://code.google.com/p/buddypress-media/
  12. *
  13. * ========================================================================================================
  14. */
  15. class BPAM_Audio extends BPM_albumModule_base implements iBPM_albumModule {
  16. var $name = "BPM - Audio"; // Human readable name for this module
  17. var $slug = "bpm_audio"; // Internal slug for this module
  18. // ============================================================================================================ //
  19. /**
  20. * Returns the human-readable name of the album module. This is displayed in the admin interface.
  21. * Example: "Video Gallery"
  22. *
  23. * @version 0.1.9
  24. * @since 0.1.9
  25. * @return string | Album module admin name
  26. */
  27. public function getName(){
  28. return $this->name;
  29. }
  30. /**
  31. * Returns the url-safe slug for the album module. Must be unique from all other
  32. * album modules installed on the system. Example: "bpm_photo"
  33. *
  34. * @version 0.1.9
  35. * @since 0.1.9
  36. * @return string | Album module slug
  37. */
  38. public function getSlug(){
  39. return $this->slug;
  40. }
  41. /**
  42. * Returns the guid of the album module as assigned by the database
  43. *
  44. * @version 0.1.9
  45. * @since 0.1.9
  46. * @return int | Album module id
  47. */
  48. public function getId(){
  49. global $bpm;
  50. $result = $bpm->albumModules->getBySlug( $this->slug );
  51. return $result["module_id"];
  52. }
  53. /**
  54. * Returns the HTTP path to the module's icon. Icons MUST be 64px*64px .PNG files.
  55. *
  56. * @version 0.1.9
  57. * @since 0.1.9
  58. * @return string | path to icon file
  59. */
  60. public function getIconPath(){
  61. return BPM_URL_BASE . "/modules/album/bpm_audio/admin/icon.png";
  62. }
  63. /**
  64. * Returns a short (30 words) description of what the album module does.
  65. *
  66. * @version 0.1.9
  67. * @since 0.1.9
  68. * @return string | description
  69. */
  70. public function getDesc(){
  71. return __("BP-Media's Audio layout. Lorem ipsum dolor sit
  72. amet, consectetur adipiscing elit. Curabitur volutpat nisi et sapien iaculis viverra. Phasellus aliquam rutrum.","bp-media");
  73. }
  74. /**
  75. * Returns the album module's version number. 64 chars max.
  76. *
  77. * @version 0.1.9
  78. * @since 0.1.9
  79. * @return string | version number
  80. */
  81. public static function getVersion(){
  82. return "0.1.0";
  83. }
  84. /**
  85. * Returns a composited HTML string, including the name of the content module developer
  86. * and a link to their personal or company website.
  87. *
  88. * @version 0.1.9
  89. * @since 0.1.9
  90. * @return string | version number
  91. */
  92. public function getAuthor(){
  93. return "<a href='http://code.google.com/p/buddypress-media/'>The BP-Media Team</a>";
  94. }
  95. /**
  96. * Returns a composited HTML string containing a link to the album module's support page, or dedicated
  97. * project site. Example: <a href='http://code.google.com/p/buddypress-media/'>The BP-Media Team</a>
  98. *
  99. * @version 0.1.9
  100. * @since 0.1.9
  101. * @return string | version number
  102. */
  103. public static function getSite(){
  104. return "<a href='http://code.google.com/p/buddypress-media/'>Support Forum</a>";
  105. }
  106. /**
  107. * Performs all of the album module's installation operations
  108. *
  109. * @version 0.1.9
  110. * @since 0.1.9
  111. * @return bool | True on success. False on failure.
  112. */
  113. public function install(){
  114. global $bpm;
  115. // Load the base install classes
  116. $bpm->config->installMode();
  117. $cls = new BPM_albumModule_install_base( $slug=self::getSlug(), $name=self::getName(), $php_class=get_class($this) );
  118. // Add 'settings' page keys and set default values
  119. $settings_ok = $cls->settings($error);
  120. if(!$settings_ok){
  121. $error_string = "Album module install error during 'settings'";
  122. $error_string .= " Module class: " . get_class($this);
  123. $error_string .= " Failed keys: " . implode(",", $error) . "\n";
  124. trigger_error($error_string);
  125. }
  126. // Add 'templates' page keys and set default values
  127. $templates_ok = $cls->templates($error);
  128. if(!$settings_ok){
  129. $error_string = "Album module install error during 'templates'";
  130. $error_string .= " Module class: " . get_class($this);
  131. $error_string .= " Failed keys: " . implode(",", $error) . "\n";
  132. trigger_error($error_string);
  133. }
  134. // Add module-specific keys
  135. if(!$bpm->config->createKey( $tree="albumModules",
  136. $branch = self::getSlug(),
  137. $key="thumbAlgorithm",
  138. $val="scale",
  139. $filter="keyName",
  140. $ctrl=null,
  141. $error=null)
  142. ) {$result[]=$key;}
  143. if(!$bpm->config->createKey( $tree="albumModules",
  144. $branch = self::getSlug(),
  145. $key="maxItemsPage",
  146. $val=72,
  147. $filter="int",
  148. $ctrl=null,
  149. $error=null)
  150. ) {$result[]=$key;}
  151. if(!$bpm->config->createKey( $tree="albumModules",
  152. $branch = self::getSlug(),
  153. $key="maxItemsRow",
  154. $val=36,
  155. $filter="int",
  156. $ctrl=null,
  157. $error=null)
  158. ) {$result[]=$key;}
  159. if(!$bpm->config->createKey( $tree="albumModules",
  160. $branch = self::getSlug(),
  161. $key="thumbSize",
  162. $val="system",
  163. $filter="keyName",
  164. $ctrl=null,
  165. $error=null)
  166. ) {$result[]=$key;}
  167. if(!$bpm->config->createKey( $tree="albumModules",
  168. $branch = self::getSlug(),
  169. $key="thumbPixelsX",
  170. $val=100,
  171. $filter="int",
  172. $ctrl=null,
  173. $error=null)
  174. ) {$result[]=$key;}
  175. if(!$bpm->config->createKey( $tree="albumModules",
  176. $branch = self::getSlug(),
  177. $key="thumbPixelsY",
  178. $val=100,
  179. $filter="int",
  180. $ctrl=null,
  181. $error=null)
  182. ) {$result[]=$key;}
  183. if(!$bpm->config->createKey( $tree="albumModules",
  184. $branch = self::getSlug(),
  185. $key="albumName",
  186. $val="Audio Album",
  187. $filter="i18nString",
  188. $ctrl=null,
  189. $error=null)
  190. ) {$result[]=$key;}
  191. if(!$bpm->config->createKey( $tree="albumModules",
  192. $branch = self::getSlug(),
  193. $key="albumDescription",
  194. $val="Upload or embed audio files",
  195. $filter="i18nString",
  196. $ctrl=null,
  197. $error=null)
  198. ) {$result[]=$key;}
  199. if(!$bpm->config->createKey( $tree="albumModules",
  200. $branch = self::getSlug(),
  201. $key="createText",
  202. $val="Create an audio album",
  203. $filter="i18nString",
  204. $ctrl=null,
  205. $error=null)
  206. ) {$result[]=$key;}
  207. // Generate allowed media module ids
  208. // ============================================
  209. $allowed_module_slugs = array("bpm_audio_embed"=>true, "bpm_audio_stream"=>true);
  210. $allowed_modules = array();
  211. foreach( $allowed_module_slugs as $slug => $status){
  212. $module_data = $bpm->mediaModules->getBySlug($slug);
  213. $allowed_modules[$module_data['module_id']] = $status;
  214. }
  215. unset($slug, $status);
  216. if(!$bpm->config->createKey( $tree="albumModules",
  217. $branch = self::getSlug(),
  218. $key="allowedMediaModules",
  219. $val=$allowed_modules,
  220. $filter="arraySimple",
  221. $ctrl=null,
  222. $error=null)
  223. ) {$result[]=$key;}
  224. // Generate active media module ids
  225. // ============================================
  226. $active_module_slugs = array("bpm_audio_embed"=>true, "bpm_audio_stream"=>true);
  227. $active_modules = array();
  228. foreach( $active_module_slugs as $slug => $status){
  229. $module_data = $bpm->mediaModules->getBySlug($slug);
  230. $active_modules[$module_data['module_id']] = $status;
  231. }
  232. unset($slug, $status);
  233. if(!$bpm->config->createKey( $tree="albumModules",
  234. $branch = self::getSlug(),
  235. $key="activeMediaModules",
  236. $val=$active_modules,
  237. $filter="arraySimple",
  238. $ctrl=null,
  239. $error=null)
  240. ) {$result[]=$key;}
  241. if( count($result) == 0) {
  242. $custom_ok = true;
  243. }
  244. else {
  245. $custom_ok = false;
  246. $error_string = "Album module install error during 'custom settings'";
  247. $error_string .= " Module class: " . get_class($this);
  248. $error_string .= " Failed keys: " . implode(",", $result) . "\n";
  249. trigger_error($error_string);
  250. }
  251. // Activate the module and return result
  252. if($settings_ok && $templates_ok && $custom_ok){
  253. $activate_ok = $bpm->albumModules->activateBySlug( self::getSlug() );
  254. return $activate_ok;
  255. }
  256. else {
  257. return false;
  258. }
  259. }
  260. /**
  261. * Performs all of the album module's uninstallation operations. Completely
  262. * removes the module from the system, and deletes all items stored within
  263. * albums that this module owns.
  264. *
  265. * @version 0.1.9
  266. * @since 0.1.9
  267. * @return bool | True on success. False on failure.
  268. */
  269. public function uninstall(){
  270. global $bpm;
  271. // Load the base uninstall classes
  272. $bpm->config->uninstallMode();
  273. $cls = new BPM_albumModule_uninstall_base( $slug=self::getSlug(), $name=self::getName(), $php_class=get_class($this) );
  274. // Remove 'settings' page keys
  275. $settings_ok = $cls->settings($error);
  276. if(!$settings_ok){
  277. $error_string = "Album module uninstall error during 'settings'";
  278. $error_string .= " Module class: " . get_class($this);
  279. $error_string .= " Failed keys: " . implode(",", $error) . "\n";
  280. trigger_error($error_string);
  281. }
  282. // Remove 'templates' page keys
  283. $templates_ok = $cls->templates($error);
  284. if(!$settings_ok){
  285. $error_string = "Album module uninstall error during 'templates'";
  286. $error_string .= " Module class: " . get_class($this);
  287. $error_string .= " Failed keys: " . implode(",", $error) . "\n";
  288. trigger_error($error_string);
  289. }
  290. // Remove module-specific keys
  291. if(!$bpm->config->dropKey( $tree="albumModules",
  292. $branch = self::getSlug(),
  293. $key="thumbAlgorithm")
  294. ) {$result[]=$key;}
  295. if(!$bpm->config->dropKey( $tree="albumModules",
  296. $branch = self::getSlug(),
  297. $key="maxItemsPage")
  298. ) {$result[]=$key;}
  299. if(!$bpm->config->dropKey( $tree="albumModules",
  300. $branch = self::getSlug(),
  301. $key="maxItemsRow")
  302. ) {$result[]=$key;}
  303. if(!$bpm->config->dropKey( $tree="albumModules",
  304. $branch = self::getSlug(),
  305. $key="thumbSize")
  306. ) {$result[]=$key;}
  307. if(!$bpm->config->dropKey( $tree="albumModules",
  308. $branch = self::getSlug(),
  309. $key="thumbPixelsX")
  310. ) {$result[]=$key;}
  311. if(!$bpm->config->dropKey( $tree="albumModules",
  312. $branch = self::getSlug(),
  313. $key="thumbPixelsY")
  314. ) {$result[]=$key;}
  315. if(!$bpm->config->dropKey( $tree="albumModules",
  316. $branch = self::getSlug(),
  317. $key="albumName")
  318. ) {$result[]=$key;}
  319. if(!$bpm->config->dropKey( $tree="albumModules",
  320. $branch = self::getSlug(),
  321. $key="albumDescription")
  322. ) {$result[]=$key;}
  323. if(!$bpm->config->dropKey( $tree="albumModules",
  324. $branch = self::getSlug(),
  325. $key="createText")
  326. ) {$result[]=$key;}
  327. if(!$bpm->config->dropKey( $tree="albumModules",
  328. $branch = self::getSlug(),
  329. $key="allowedMediaModules")
  330. ) {$result[]=$key;}
  331. if(!$bpm->config->dropKey( $tree="albumModules",
  332. $branch = self::getSlug(),
  333. $key="activeMediaModules")
  334. ) {$result[]=$key;}
  335. if( count($result) == 0) {
  336. $custom_ok = true;
  337. }
  338. else {
  339. $custom_ok = false;
  340. $error_string = "Album module uninstall error during 'custom settings'";
  341. $error_string .= " Module class: " . get_class($this);
  342. $error_string .= " Failed keys: " . implode(",", $result) . "\n";
  343. trigger_error($error_string);
  344. }
  345. // Delete the module's content and return result
  346. if($settings_ok && $templates_ok && $custom_ok){
  347. // Delete all of the module's albums, items, and content
  348. $delete_ok = $bpm->albumModules->deleteBySlug( self::getSlug() );
  349. return $delete_ok;
  350. }
  351. else {
  352. return false;
  353. }
  354. }
  355. /**
  356. * Adds scripts used by the album module to the admin page header
  357. *
  358. * @version 0.1.9
  359. * @since 0.1.9
  360. * @param string $tab | Name of the admin tab the plugin is rendering
  361. */
  362. public function enqueueAdminScripts($tab){
  363. // Album Types Tab
  364. if(!$tab || ($tab == "BPAM_tab_albumTypes") ){
  365. wp_enqueue_script( 'bpm-jquery-ui-core');
  366. wp_enqueue_script( 'bpm-jquery-ui-widget');
  367. wp_enqueue_script( 'bpm-jquery-ui-mouse');
  368. wp_enqueue_script( 'bpm-jquery-ui-position');
  369. wp_enqueue_script( 'bpm-jquery-ui-tabs');
  370. wp_enqueue_script( 'bpm-jquery-ui-slider');
  371. wp_enqueue_script( 'bpm-jquery-ui-dialog');
  372. wp_enqueue_script( 'bpm-jquery-ui-draggable');
  373. wp_enqueue_script( 'bpm-jquery-ui-resizable');
  374. wp_enqueue_script( 'bpm-jquery-ui-sortable');
  375. wp_enqueue_script( 'bpm-albumModules');
  376. }
  377. }
  378. /**
  379. * Adds CSS styles used by the album module to the admin page header
  380. *
  381. * @version 0.1.9
  382. * @since 0.1.9
  383. * @param string $tab | Name of the admin tab the plugin is rendering
  384. */
  385. public function enqueueAdminStyles($tab){
  386. // Album Types Tab
  387. if(!$tab || ($tab == "BPAM_tab_albumTypes") ){
  388. wp_enqueue_style( 'bpa-base', BPM_URL_CORE .'/admin/css/jquery.ui.base.css', false, '2.8.1', 'screen' );
  389. wp_enqueue_style( 'bpa-theme', BPM_URL_CORE .'/admin/css/jquery.ui.theme.css', false, '2.8.1', 'screen' );
  390. wp_enqueue_style( 'bpm-dialogs', BPM_URL_CORE .'/admin/css/bpm.albumtype.dialogs.css', false, '2.8.1', 'screen' );
  391. wp_enqueue_style( self::getSlug(), dirname( __FILE__ ) . '/admin/admin.css', false, '2.8.1', 'screen' );
  392. }
  393. else {
  394. wp_enqueue_style( self::getSlug(), dirname( __FILE__ ) . '/admin/admin.css', false, '2.8.1', 'screen' );
  395. }
  396. }
  397. /**
  398. * Adds scripts used by the album module to the site page header
  399. *
  400. * @version 0.1.9
  401. * @since 0.1.9
  402. * @param string $page | Name of the site page the plugin is rendering
  403. */
  404. public function enqueueSiteScripts($page){
  405. return $page;
  406. }
  407. /**
  408. * Adds CSS styles used by the album module to the site page header
  409. *
  410. * @version 0.1.9
  411. * @since 0.1.9
  412. * @param string $page | Name of the site page the plugin is rendering
  413. */
  414. public function enqueueSiteStyles($page){
  415. return $page;
  416. }
  417. /**
  418. * Album module init function. Album modules place all of their hook and filter functions in the init
  419. * function inside their class. When the core loads album modules, it fires the init function in each
  420. * album module, attaching the module's functions to the core.
  421. *
  422. * @version 0.1.9
  423. * @since 0.1.9
  424. */
  425. public function init(){
  426. return true;
  427. }
  428. /**
  429. * Specifies the view structure of the module's screens
  430. *
  431. * @version 0.1.9
  432. * @since 0.1.9
  433. * @return array | mixed
  434. */
  435. public function viewStructure(){
  436. $result = array(
  437. "site"=>array("type"=>"page", "views"=>array("visitor") ),
  438. "profile"=>array("type"=>"page","views"=>array("visitor") ),
  439. "tab"=>array("type"=>"page","views"=>array("visitor") )
  440. );
  441. return $result;
  442. }
  443. /**
  444. * Renders the configuration page for a album module, as seen on the admin
  445. * "album modules" screen.
  446. *
  447. * @version 0.1.9
  448. * @since 0.1.9
  449. * @return string | composited HTML block
  450. */
  451. public function adminConfigPage(){
  452. global $bpm;
  453. require ( dirname( __FILE__ ) . '/admin/loader.php' );
  454. $current_page = new BPAM_admin_loader( new self() );
  455. }
  456. /**
  457. * Renders the configuration page for a album module, as seen on the user's
  458. * site settings screens.
  459. *
  460. * @version 0.1.9
  461. * @since 0.1.9
  462. * @return string | composited HTML block
  463. */
  464. public function userConfigPage(){
  465. }
  466. /**
  467. * Renders the HTML block for the page a user sees when they create a new
  468. * instance of an album type owned by the album module.
  469. *
  470. * @version 0.1.9
  471. * @since 0.1.9
  472. * @param ?
  473. * @return string | composited HTML block
  474. */
  475. public function render_createAlbum(){
  476. }
  477. /**
  478. * Renders the HTML block for an upload page when items are uploaded to an
  479. * album type owned by the album module.
  480. *
  481. * @version 0.1.9
  482. * @since 0.1.9
  483. * @param ?
  484. * @return string | composited HTML block
  485. */
  486. public function render_uploadItem(){
  487. }
  488. /**
  489. * Renders the HTML block for the page a user sees when they edit an
  490. * instance of an album type owned by the album module.
  491. *
  492. * @version 0.1.9
  493. * @since 0.1.9
  494. * @param ?
  495. * @return string | composited HTML block
  496. */
  497. public function render_editAlbum(){
  498. }
  499. /**
  500. * Renders the HTML block for the page a user sees when they edit an individual
  501. * media item within an instance of an album type owned by the album module.
  502. *
  503. * @version 0.1.9
  504. * @since 0.1.9
  505. * @param ?
  506. * @return string | composited HTML block
  507. */
  508. public function render_editItem(){
  509. }
  510. /**
  511. * Renders the HTML block for the first page of items a user sees when they
  512. * view an instance of an album type owned by the album module.
  513. *
  514. * @version 0.1.9
  515. * @since 0.1.9
  516. * @param ?
  517. * @return string | composited HTML block
  518. */
  519. public function render_landingPage(){
  520. }
  521. /**
  522. * Renders the HTML block for for the second and subsequent pages of items a user
  523. * sees when they view an instance of an album type owned by the album module.
  524. *
  525. * @version 0.1.9
  526. * @since 0.1.9
  527. * @param ?
  528. * @return string | composited HTML block
  529. */
  530. public function render_galleryPage(){
  531. }
  532. /**
  533. * Renders the HTML block for the page a user sees when they view an individual
  534. * item within an album instance owned by the album module.
  535. *
  536. * @version 0.1.9
  537. * @since 0.1.9
  538. * @param ?
  539. * @return string | composited HTML block
  540. */
  541. public function render_singlePage(){
  542. }
  543. /**
  544. * Renders the HTML block for the page a user sees when they sort items within
  545. * an album instance owned by the album module.
  546. *
  547. * @version 0.1.9
  548. * @since 0.1.9
  549. * @param ?
  550. * @return string | composited HTML block
  551. */
  552. public function render_sortPage(){
  553. }
  554. /**
  555. * Renders the HTML block for the page a user sees when they apply user tags to a
  556. * media item within an album instance owned by the album module.
  557. *
  558. * @version 0.1.9
  559. * @since 0.1.9
  560. * @param ?
  561. * @return string | composited HTML block
  562. */
  563. public function render_userTagPage(){
  564. }
  565. /**
  566. * Renders the HTML block for the page a user sees when they apply keyword tags to
  567. * a media item within an album instance owned by the album module.
  568. *
  569. * @version 0.1.9
  570. * @since 0.1.9
  571. * @param ?
  572. * @return string | composited HTML block
  573. */
  574. public function render_keywordTagPage(){
  575. }
  576. /**
  577. * Renders the HTML block for the page a user sees when they add geotagging info to
  578. * a media item within an album instance owned by the album module.
  579. *
  580. * @version 0.1.9
  581. * @since 0.1.9
  582. * @param ?
  583. * @return string | composited HTML block
  584. */
  585. public function render_geoTagPage(){
  586. }
  587. /**
  588. * Renders the HTML block for the page a user sees when they add licensing info to
  589. * a media item within an album instance owned by the album module.
  590. *
  591. * @version 0.1.9
  592. * @since 0.1.9
  593. * @param ?
  594. * @return string | composited HTML block
  595. */
  596. public function render_licenseTagPage(){
  597. }
  598. public function register(){
  599. global $bpm;
  600. $slug = $this->getSlug();
  601. $name = $this->getName();
  602. $php_class = get_class($this);
  603. $bpm->albumModules->register($slug, $name, $php_class);
  604. }
  605. }
  606. $temp = new BPAM_Audio();
  607. $temp->register();
  608. unset($temp);
  609. ?>