registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->lang = $this->registry->getClass('class_localization'); $this->member = $this->registry->member(); $this->memberData =& $this->registry->member()->fetchMemberData(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); } /** * Requires a permission check * * @param array $array Data array * @return @e boolean */ public function requiresPermissionCheck( $array ) { return false; } /** * Using a custom template bit? * * @return @e array array( skinGroup, templateBitName, lang ) */ public function customOutput() { //----------------------------------------- // Work out the language // @see https://developers.google.com/+/plugins/+1button/#available-languages //----------------------------------------- $langCode = 'en-US'; if ( isset( $this->settings['googlePlusOneLanguage'] ) ) // so you can use a power setting if you like { $langCode = $this->settings['googlePlusOneLanguage']; } else { $acceptedLanguages = array( 'ar', 'bg', 'ca', 'zh', 'hr', 'cs', 'da', 'nl', 'en', 'et', 'fil', 'fi', 'fr', 'de', 'el', 'iw', 'hi', 'hu', 'id', 'it', 'ja', 'ko', 'lv', 'lt', 'ms', 'no', 'fa', 'pl', 'pt', 'ro', 'ru', 'sr', 'sk', 'sl', 'es', 'sv', 'th', 'tr', 'uk', 'vi' ); $subLanguages = array( 'en' => array( 'gb', 'us' ), 'zh' => array( 'cn', 'tw' ), 'pt' => array( 'br', 'pt' ) ); foreach( $this->caches['lang_data'] as $lang ) { if ( $lang['lang_default'] ) { if ( strstr( $lang['lang_short'], '_' ) !== FALSE ) { $localeExploded = explode( '_', $lang['lang_short'] ); } elseif ( strstr( $lang['lang_short'], '-' ) !== FALSE ) { $localeExploded = explode( '-', $lang['lang_short'] ); } else { break; } if ( in_array( strtolower( $localeExploded[0] ), $acceptedLanguages ) ) { $langCode = strtolower( $localeExploded[0] ); if ( isset( $subLanguages[ strtolower( $localeExploded[0] ) ] ) ) { if ( isset( $subLanguages[ strtolower( $localeExploded[1] ) ] ) ) { $langCode = strtolower( $localeExploded[0] ) . '-' . strtoupper( $localeExploded[1] ); } else { $langCode = strtolower( $localeExploded[0] ) . '-' . strtoupper( $subLanguages[ strtolower( $localeExploded[0] ) ][0] ); } } } break; } } } return array( 'global', 'googlePlusOneButton', array( 'lang' => $langCode ) ); } /** * Redirect to Google * Exciting, isn't it. * * @param string Plug in */ public function share( $title, $url ) { $title = IPSText::convertCharsets( $title, IPS_DOC_CHAR_SET, 'utf-8' ); $url = "http://www.google.com/sharer.php?u=" . urlencode( $url ); $this->registry->output->silentRedirect( $url ); } }