/modules/album/bpm_document/loader.php
PHP | 806 lines | 335 code | 197 blank | 274 comment | 48 complexity | b1368a94fc4fdac14483df5418f7dfde MD5 | raw file
Possible License(s): AGPL-1.0, Apache-2.0, GPL-2.0, LGPL-2.1
- <?php
- /**
- * ALBUM MODULE - BPM Portfolio
- * The portfolio layout from BP-Album
- *
- * @version 0.1.9
- * @since 0.1.9
- * @package BP-Media
- * @subpackage Album Modules
- * @license GPL v2.0
- * @link http://code.google.com/p/buddypress-media/
- *
- * ========================================================================================================
- */
- class BPAM_Document extends BPM_albumModule_base implements iBPM_albumModule {
- var $name = "BPM - Document"; // Human readable name for this module
- var $slug = "bpm_document"; // Internal slug for this module
- // ============================================================================================================ //
- /**
- * Returns the human-readable name of the album module. This is displayed in the admin interface.
- * Example: "Video Gallery"
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | Album module admin name
- */
- public function getName(){
- return $this->name;
- }
- /**
- * Returns the url-safe slug for the album module. Must be unique from all other
- * album modules installed on the system. Example: "bpm_photo"
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | Album module slug
- */
- public function getSlug(){
- return $this->slug;
- }
- /**
- * Returns the guid of the album module as assigned by the database
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return int | Album module id
- */
- public function getId(){
- global $bpm;
- $result = $bpm->albumModules->getBySlug( $this->slug );
- return $result["module_id"];
- }
- /**
- * Returns the HTTP path to the module's icon. Icons MUST be 64px*64px .PNG files.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | path to icon file
- */
- public function getIconPath(){
- return BPM_URL_BASE . "/modules/album/bpm_document/admin/icon.png";
- }
- /**
- * Returns a short (30 words) description of what the album module does.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | description
- */
- public function getDesc(){
- return __("The document layout for BP-Media. Lorem ipsum dolor sit
- amet, consectetur adipiscing elit. Curabitur volutpat nisi et sapien iaculis viverra. Phasellus aliquam rutrum.","bp-media");
- }
- /**
- * Returns the album module's version number. 64 chars max.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | version number
- */
- public static function getVersion(){
- return "0.1.0";
- }
- /**
- * Returns a composited HTML string, including the name of the content module developer
- * and a link to their personal or company website.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | version number
- */
- public function getAuthor(){
- return "<a href='http://code.google.com/p/buddypress-media/'>The BP-Media Team</a>";
- }
- /**
- * Returns a composited HTML string containing a link to the album module's support page, or dedicated
- * project site. Example: <a href='http://code.google.com/p/buddypress-media/'>The BP-Media Team</a>
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | version number
- */
- public static function getSite(){
- return "<a href='http://code.google.com/p/buddypress-media/'>Support Forum</a>";
- }
- /**
- * Performs all of the album module's installation operations
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return bool | True on success. False on failure.
- */
- public function install(){
- global $bpm;
- // Load the base install classes
- $bpm->config->installMode();
- $cls = new BPM_albumModule_install_base( $slug=self::getSlug(), $name=self::getName(), $php_class=get_class($this) );
- // Add 'settings' page keys and set default values
- $settings_ok = $cls->settings($error);
- if(!$settings_ok){
- $error_string = "Album module install error during 'settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Add 'templates' page keys and set default values
- $templates_ok = $cls->templates($error);
- if(!$settings_ok){
- $error_string = "Album module install error during 'templates'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Add module-specific keys
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbAlgorithm",
- $val="scale",
- $filter="keyName",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="maxItemsPage",
- $val=72,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="maxItemsRow",
- $val=36,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbSize",
- $val="system",
- $filter="keyName",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbPixelsX",
- $val=100,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbPixelsY",
- $val=100,
- $filter="int",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
-
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="albumName",
- $val="Document Album",
- $filter="i18nString",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="albumDescription",
- $val="Create an album to hold office documents",
- $filter="i18nString",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="createText",
- $val="Create a document album",
- $filter="i18nString",
- $ctrl=null,
- $error=null)
- ) {$result[]=$key;}
- // Generate allowed media module ids
- // ============================================
- $allowed_module_slugs = array( "bpm_pdf_local"=>true, "bpm_pdf_embed"=>true);
- $allowed_modules = array();
- foreach( $allowed_module_slugs as $slug => $status){
- $module_data = $bpm->mediaModules->getBySlug($slug);
- $allowed_modules[$module_data['module_id']] = $status;
- }
- unset($slug, $status);
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="allowedMediaModules",
- $val=$allowed_modules,
- $filter="arraySimple",
- $ctrl=null,
- $error=null)
- ) { $result[] = $key; }
- // Generate active media module ids
- // ============================================
- $active_module_slugs = array( "bpm_pdf_local"=>true, "bpm_pdf_embed"=>true);
- $active_modules = array();
- foreach( $active_module_slugs as $slug => $status){
- $module_data = $bpm->mediaModules->getBySlug($slug);
- $active_modules[$module_data['module_id']] = $status;
- }
- unset($slug, $status);
- if(!$bpm->config->createKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="activeMediaModules",
- $val=$active_modules,
- $filter="arraySimple",
- $ctrl=null,
- $error=null)
- ) { $result[] = $key; }
- if( count($result) == 0) {
- $custom_ok = true;
- }
- else {
- $custom_ok = false;
- $error_string = "Album module install error during 'custom settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $result) . "\n";
- trigger_error($error_string);
- }
- // Activate the module and return result
- if($settings_ok && $templates_ok && $custom_ok){
- $activate_ok = $bpm->albumModules->activateBySlug( self::getSlug() );
- return $activate_ok;
- }
- else {
- return false;
- }
- }
- /**
- * Performs all of the album module's uninstallation operations. Completely
- * removes the module from the system, and deletes all items stored within
- * albums that this module owns.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return bool | True on success. False on failure.
- */
- public function uninstall(){
- global $bpm;
- // Load the base uninstall classes
- $bpm->config->uninstallMode();
- $cls = new BPM_albumModule_uninstall_base( $slug=self::getSlug(), $name=self::getName(), $php_class=get_class($this) );
- // Remove 'settings' page keys
- $settings_ok = $cls->settings($error);
- if(!$settings_ok){
- $error_string = "Album module uninstall error during 'settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Remove 'templates' page keys
- $templates_ok = $cls->templates($error);
- if(!$settings_ok){
- $error_string = "Album module uninstall error during 'templates'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $error) . "\n";
- trigger_error($error_string);
- }
- // Remove module-specific keys
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbAlgorithm")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="maxItemsPage")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="maxItemsRow")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbSize")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbPixelsX")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="thumbPixelsY")
- ) {$result[]=$key;}
-
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="albumName")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="albumDescription")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="createText")
- ) {$result[]=$key;}
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="allowedMediaModules")
- ) { $result[] = $key; }
- if(!$bpm->config->dropKey( $tree="albumModules",
- $branch = self::getSlug(),
- $key="activeMediaModules")
- ) { $result[] = $key; }
- if( count($result) == 0) {
- $custom_ok = true;
- }
- else {
- $custom_ok = false;
- $error_string = "Album module uninstall error during 'custom settings'";
- $error_string .= " Module class: " . get_class($this);
- $error_string .= " Failed keys: " . implode(",", $result) . "\n";
- trigger_error($error_string);
- }
- // Delete the module's content and return result
- if($settings_ok && $templates_ok && $custom_ok){
- // Delete all of the module's albums, items, and content
- $delete_ok = $bpm->albumModules->deleteBySlug( self::getSlug() );
- return $delete_ok;
- }
- else {
- return false;
- }
-
- }
- /**
- * Adds scripts used by the album module to the admin page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $tab | Name of the admin tab the plugin is rendering
- */
- public function enqueueAdminScripts($tab){
- // Album Types Tab
- if(!$tab || ($tab == "BPAM_tab_albumTypes") ){
- wp_enqueue_script( 'bpm-jquery-ui-core');
- wp_enqueue_script( 'bpm-jquery-ui-widget');
- wp_enqueue_script( 'bpm-jquery-ui-mouse');
- wp_enqueue_script( 'bpm-jquery-ui-position');
- wp_enqueue_script( 'bpm-jquery-ui-tabs');
- wp_enqueue_script( 'bpm-jquery-ui-slider');
- wp_enqueue_script( 'bpm-jquery-ui-dialog');
- wp_enqueue_script( 'bpm-jquery-ui-draggable');
- wp_enqueue_script( 'bpm-jquery-ui-resizable');
- wp_enqueue_script( 'bpm-jquery-ui-sortable');
- wp_enqueue_script( 'bpm-albumModules');
- }
- }
- /**
- * Adds CSS styles used by the album module to the admin page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $tab | Name of the admin tab the plugin is rendering
- */
- public function enqueueAdminStyles($tab){
- // Album Types Tab
- if(!$tab || ($tab == "BPAM_tab_albumTypes") ){
- wp_enqueue_style( 'bpa-base', BPM_URL_CORE .'/admin/css/jquery.ui.base.css', false, '2.8.1', 'screen' );
- wp_enqueue_style( 'bpa-theme', BPM_URL_CORE .'/admin/css/jquery.ui.theme.css', false, '2.8.1', 'screen' );
- wp_enqueue_style( 'bpm-dialogs', BPM_URL_CORE .'/admin/css/bpm.albumtype.dialogs.css', false, '2.8.1', 'screen' );
- wp_enqueue_style( self::getSlug(), dirname( __FILE__ ) . '/admin/admin.css', false, '2.8.1', 'screen' );
- }
- else {
- wp_enqueue_style( self::getSlug(), dirname( __FILE__ ) . '/admin/admin.css', false, '2.8.1', 'screen' );
- }
- }
- /**
- * Adds scripts used by the album module to the site page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $page | Name of the site page the plugin is rendering
- */
- public function enqueueSiteScripts($page){
- return $page;
- }
- /**
- * Adds CSS styles used by the album module to the site page header
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param string $page | Name of the site page the plugin is rendering
- */
- public function enqueueSiteStyles($page){
- return $page;
- }
- /**
- * Album module init function. Album modules place all of their hook and filter functions in the init
- * function inside their class. When the core loads album modules, it fires the init function in each
- * album module, attaching the module's functions to the core.
- *
- * @version 0.1.9
- * @since 0.1.9
- */
- public function init(){
- return true;
- }
- /**
- * Specifies the view structure of the module's screens
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return array | mixed
- */
- public function viewStructure(){
- $result = array(
- "site"=>array("type"=>"page", "views"=>array("visitor") ),
- "profile"=>array("type"=>"page","views"=>array("visitor") ),
- "tab"=>array("type"=>"page","views"=>array("visitor") )
- );
- return $result;
- }
-
- /**
- * Renders the configuration page for a album module, as seen on the admin
- * "album modules" screen.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | composited HTML block
- */
- public function adminConfigPage(){
- global $bpm;
- require ( dirname( __FILE__ ) . '/admin/loader.php' );
- $current_page = new BPAM_admin_loader( new self() );
-
- }
- /**
- * Renders the configuration page for a album module, as seen on the user's
- * site settings screens.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @return string | composited HTML block
- */
- public function userConfigPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they create a new
- * instance of an album type owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_createAlbum(){
- }
- /**
- * Renders the HTML block for an upload page when items are uploaded to an
- * album type owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_uploadItem(){
- }
- /**
- * Renders the HTML block for the page a user sees when they edit an
- * instance of an album type owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_editAlbum(){
- }
- /**
- * Renders the HTML block for the page a user sees when they edit an individual
- * media item within an instance of an album type owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_editItem(){
- }
- /**
- * Renders the HTML block for the first page of items a user sees when they
- * view an instance of an album type owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_landingPage(){
- }
- /**
- * Renders the HTML block for for the second and subsequent pages of items a user
- * sees when they view an instance of an album type owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_galleryPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they view an individual
- * item within an album instance owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_singlePage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they sort items within
- * an album instance owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_sortPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they apply user tags to a
- * media item within an album instance owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_userTagPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they apply keyword tags to
- * a media item within an album instance owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_keywordTagPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they add geotagging info to
- * a media item within an album instance owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_geoTagPage(){
- }
- /**
- * Renders the HTML block for the page a user sees when they add licensing info to
- * a media item within an album instance owned by the album module.
- *
- * @version 0.1.9
- * @since 0.1.9
- * @param ?
- * @return string | composited HTML block
- */
- public function render_licenseTagPage(){
- }
- public function register(){
- global $bpm;
- $slug = $this->getSlug();
- $name = $this->getName();
- $php_class = get_class($this);
- $bpm->albumModules->register($slug, $name, $php_class);
- }
-
- }
- $temp = new BPAM_Document();
- $temp->register();
- unset($temp);
- ?>