Luis Felipe Schenone has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/97861


Change subject: Initial commit
......................................................................

Initial commit

Change-Id: I474e2ab608af5c6f9fb420efcdff9c5f1c61256e
---
A YotpoReviews.body.php
A YotpoReviews.i18n.php
A YotpoReviews.php
3 files changed, 104 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/YotpoReviews 
refs/changes/61/97861/1

diff --git a/YotpoReviews.body.php b/YotpoReviews.body.php
new file mode 100644
index 0000000..69db44e
--- /dev/null
+++ b/YotpoReviews.body.php
@@ -0,0 +1,56 @@
+<?php
+
+class YotpoReviews {
+
+       public static function setParserHook( $parser ) {
+               $parser->setHook( 'yotpo-reviews', 
'YotpoReviews::renderReviews' );
+               return true;
+       }
+
+       public static function addYotpoScript( &$data ) {
+               global $wgYotpoAppKey;
+               $data .= '<script src="//www.yotpo.com/js/yQuery.js"></script>';
+               $data .= '<script>var yotpo_app_key = "' . $wgYotpoAppKey . 
'";</script>';
+               return true;
+       }
+
+       public static function renderReviews( $input, array $args, Parser 
$parser, PPFrame $frame ) {
+               global $wgTitle, $wgLogo, $wgServer, $wgYotpoAppKey;
+
+               $width = '100%'; //Default
+               if ( array_key_exists( 'width', $args ) ) {
+                       $width = $args['width'] . 'px';
+               }
+
+               $height = '100%'; //Default
+               if ( array_key_exists( 'height', $args ) ) {
+                       $height = $args['height'] . 'px';
+               }
+
+               $align = 'center'; //Default
+               if ( array_key_exists( 'align', $args ) ) {
+                       $align = $args['align'];
+               }
+               if ( $align == 'left' ) {
+                       $margin = '0 auto 0 0';
+               }
+               if ( $align == 'right' ) {
+                       $margin = '0 0 0 auto';
+               }
+               if ( $align == 'center' ) {
+                       $margin = '0 auto 0 auto';
+               }
+
+               $data_app_key = $wgYotpoAppKey;
+               $data_domain = $wgServer;
+               $data_product_id = $wgTitle->getDBKey();
+               $data_product_models = '';
+               $data_name = $wgTitle->getText();
+               $data_url = $wgTitle->getFullURL();
+               $data_image_url = '';
+               $data_description = '';
+               $data_bread_crumbs = '';
+
+               return '<div class="yotpo reviews" style="margin:' . $margin . 
'; width:' . $width . '; height:' . $height . ';" data-appkey="' .$data_app_key 
. '" data-domain="' . $data_domain . '" data-product-id="' . $data_product_id . 
'" data-product-models="' . $data_product_models . '" data-name="' . $data_name 
. '" data-url="' . $data_url . '" data-image-url="' . $data_image_url . '" 
data-description="' . $data_description . '" data-bread-crumbs="' . 
$data_bread_crumbs . '"></div>';
+       }
+}
\ No newline at end of file
diff --git a/YotpoReviews.i18n.php b/YotpoReviews.i18n.php
new file mode 100644
index 0000000..a1c6edd
--- /dev/null
+++ b/YotpoReviews.i18n.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Internationalisation for LivefyreReviews extension
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+/** English
+ * @author Luis Felipe Schenone
+ */
+$messages['en'] = array(
+       'yotpo-reviews-desc' => 'Adds the &lt;yotpo-reviews&gt; tag that 
inserts the Yotpo reviews system',
+);
+
+/** Message documentation (Message documentation)
+ * @author Raimond Spekking
+ * @author Shirayuki
+ */
+$messages['qqq'] = array(
+       'yotpo-reviews-desc' => 
'{{desc|name=LivefyreReviews|url=http://www.mediawiki.org/wiki/Extension:LivefyreReviews}}',
+);
+
+/** Spanish (español)
+ * @author Luis Felipe Schenone
+ */
+$messages['es'] = array(
+       'yotpo-reviews-desc' => 'Agrega la etiqueta &lt;yotpo-reviews&gt; que 
inserta el sistema de reseñas Yotpo',
+);
diff --git a/YotpoReviews.php b/YotpoReviews.php
new file mode 100644
index 0000000..5e8f805
--- /dev/null
+++ b/YotpoReviews.php
@@ -0,0 +1,17 @@
+<?php
+
+$wgExtensionCredits['parserhook'][] = array(
+       'path'           => __FILE__,
+       'name'           => 'YotpoReviews',
+       'description'    => '',
+       'descriptionmsg' => 'yotpo-reviews-desc',
+       'version'        => 0.1,
+       'author'         => 'Luis Felipe Schenone',
+       'url'            => 
'http://www.mediawiki.org/wiki/Extension:YotpoReviews'
+);
+
+$wgExtensionMessagesFiles['YotpoReviews'] = __DIR__ . '/YotpoReviews.i18n.php';
+$wgAutoloadClasses['YotpoReviews'] = __DIR__ . '/YotpoReviews.body.php';
+
+$wgHooks['ParserFirstCallInit'][] = 'YotpoReviews::setParserHook';
+$wgHooks['SkinAfterContent'][] = 'YotpoReviews::addYotpoScript';
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/97861
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I474e2ab608af5c6f9fb420efcdff9c5f1c61256e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/YotpoReviews
Gerrit-Branch: master
Gerrit-Owner: Luis Felipe Schenone <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to