private function _getLabel($optionName) { if ($this->_reference->getUntranslatedLabel($optionName)) { $label = $this->_reference->getUntranslatedLabel($optionName); return $this->_translator->trans($label); } return $optionName; }
public function onAction_widgets_init(tubepress_api_event_EventInterface $event) { if (!$event->hasArgument('unit-testing') && !class_exists('tubepress_wordpress_impl_wp_WpWidget')) { require TUBEPRESS_ROOT . '/src/add-ons/wordpress/classes/tubepress/wordpress/impl/wp/WpWidget.php'; } $this->_wpFunctions->register_widget('tubepress_wordpress_impl_wp_WpWidget'); /* * These next three lines are deprecated! */ $widgetOps = array('classname' => 'widget_tubepress', 'description' => $this->_translator->trans('Displays YouTube or Vimeo videos with TubePress. Limited to a single instance per site. Use the other TubePress widget instead!')); //>(translatable)< $this->_wpFunctions->wp_register_sidebar_widget('tubepress', 'TubePress (legacy)', array($this, '__fireWidgetHtmlEvent'), $widgetOps); $this->_wpFunctions->wp_register_widget_control('tubepress', 'TubePress (legacy)', array($this, '__fireWidgetControlEvent')); }
/** * {@inheritdoc} */ public function formatDateAttribute(tubepress_api_media_MediaItem $item, $sourceAttributeName, $destinationAttributeName) { if (!$item->hasAttribute($sourceAttributeName)) { return; } /* * Hacky way of warming up the translation service and thus setting locale etc. */ $this->_translator->trans(''); $dateFormat = $this->_context->get(tubepress_api_options_Names::META_DATEFORMAT); $relative = $this->_context->get(tubepress_api_options_Names::META_RELATIVE_DATES); $unixTime = $item->getAttribute($sourceAttributeName); $formatted = $this->_timeUtils->unixTimeToHumanReadable($unixTime, $dateFormat, $relative); $item->setAttribute($destinationAttributeName, $formatted); }
public function onSingleItemTemplate(tubepress_api_event_EventInterface $event) { if (!$this->_legacyThemeInUse()) { return; } $existingTemplateVars = $event->getSubject(); $itemId = $existingTemplateVars[tubepress_api_template_VariableNames::MEDIA_ITEM_ID]; if (!isset($existingTemplateVars[tubepress_api_template_VariableNames::MEDIA_ITEM])) { throw new RuntimeException(sprintf($this->_translator->trans('Video %s not found'), $itemId)); //>(translatable)< } $item = $existingTemplateVars[tubepress_api_template_VariableNames::MEDIA_ITEM]; $existingTemplateVars[tubepress_api_const_template_Variable::VIDEO] = $item; $existingTemplateVars[tubepress_api_const_template_Variable::EMBEDDED_WIDTH] = $this->_context->get(tubepress_api_options_Names::EMBEDDED_WIDTH); $event->setSubject($existingTemplateVars); }
private function _setLegacyVariables(array &$templateVars) { $metaNames = $this->_getAllMetaOptionNames(); $shouldShow = array(); $labels = array(); foreach ($metaNames as $metaName) { if (!$this->_optionReference->optionExists($metaName)) { $shouldShow[$metaName] = false; $labels[$metaName] = ''; continue; } $shouldShow[$metaName] = $this->_context->get($metaName); $untranslatedLabel = $this->_optionReference->getUntranslatedLabel($metaName); $labels[$metaName] = $this->_translator->trans($untranslatedLabel); } $templateVars[tubepress_api_const_template_Variable::META_SHOULD_SHOW] = $shouldShow; $templateVars[tubepress_api_const_template_Variable::META_LABELS] = $labels; }
private function _prepareModeTemplateMap($map) { if (!is_array($map)) { //this should never happen return $map; } foreach ($map as $key => $untranslated) { $map[$key] = $this->_translator->trans($untranslated); } return $map; }
/** * Filter the content (which may be empty). */ public function printControlHtml() { /* are we saving? */ if ($this->_httpRequestParams->hasParam(self::WIDGET_SUBMIT_TAG)) { $this->_wpFunctions->check_admin_referer('tubepress-widget-nonce-save', 'tubepress-widget-nonce'); $this->_persistence->queueForSave(tubepress_wordpress_api_Constants::OPTION_WIDGET_SHORTCODE, $this->_httpRequestParams->getParamValue('tubepress-widget-tagstring')); $this->_persistence->queueForSave(tubepress_wordpress_api_Constants::OPTION_WIDGET_TITLE, $this->_httpRequestParams->getParamValue('tubepress-widget-title')); $this->_persistence->flushSaveQueue(); } $templateVars = array(self::WIDGET_TITLE => $this->_persistence->fetch(tubepress_wordpress_api_Constants::OPTION_WIDGET_TITLE), self::WIDGET_CONTROL_TITLE => $this->_translator->trans('Title'), self::WIDGET_CONTROL_SHORTCODE => $this->_translator->trans(sprintf('TubePress shortcode for the widget. See the <a href="%s" target="_blank">documentation</a>.', "http://docs.tubepress.com/")), self::WIDGET_SHORTCODE => $this->_persistence->fetch(tubepress_wordpress_api_Constants::OPTION_WIDGET_SHORTCODE), self::WIDGET_SUBMIT_TAG => self::WIDGET_SUBMIT_TAG, self::WIDGET_NONCE_FIELD => $this->_wpFunctions->wp_nonce_field('tubepress-widget-nonce-save', 'tubepress-widget-nonce', true, false)); echo $this->_templating->renderTemplate('wordpress/single-widget-controls', $templateVars); }
/** * {@inheritdoc} */ public function getTranslatedClientRegistrationInstructions(tubepress_api_translation_TranslatorInterface $translator, tubepress_api_url_UrlInterface $redirectUrl) { $step1 = $translator->trans('<a href="%client-registration-url%" target="_blank">Click here</a> to create a new Vimeo "App".', array('%client-registration-url%' => 'https://developer.vimeo.com/apps/new')); $step1Subs = array($translator->trans('Use anything you\'d like for the App Name, App Description, and App URL.'), $translator->trans('In the field for "App Callback URLs", enter:<br /><code>%redirect-uri%</code>', array('%redirect-uri%' => $redirectUrl->toString()))); $step2 = $translator->trans('Under the "OAuth2" tab of your new Vimeo App, you will find your "Client Identifier" and "Client Secret". Enter those values into the text boxes below.'); //>(translatable)< $step3 = $translator->trans('Click the "New token" button below to authorize TubePress to communicate with Vimeo on your behalf. This step will take place in a popup window.'); //>(translatable)< return array($step1, $step1Subs, $step2, $step3); }
public function __callback_transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null) { return $this->_translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale); }