RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð ....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 104.225.223.251  /  Your IP : 216.73.216.41
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux agtdemo03 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/web/dev.agtindia.co.in/test-form/wp-content/plugins/gravityformssurvey/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/web/dev.agtindia.co.in/test-form/wp-content/plugins/gravityformssurvey/class-gf-survey.php
<?php

//------------------------------------------

// don't load directly
if ( ! defined( 'ABSPATH' ) ) {
	die();
}

GFForms::include_addon_framework();

class GFSurvey extends GFAddOn {

	protected $_version = GF_SURVEY_VERSION;
	protected $_min_gravityforms_version = '2.0';
	protected $_slug = 'gravityformssurvey';
	protected $_path = 'gravityformssurvey/survey.php';
	protected $_full_path = __FILE__;
	protected $_url = 'http://www.gravityforms.com';
	protected $_title = 'Gravity Forms Survey Add-On';
	protected $_short_title = 'Survey';
	protected $_enable_rg_autoupgrade = true;

	/**
	 * Whether this add-on has access to the Gravity Forms settings renderer.
	 *
	 * @since 3.5
	 *
	 * @var bool
	 */
	protected $_has_settings_renderer;

	/**
	 * Members plugin integration
	 */
	protected $_capabilities = array( 'gravityforms_survey', 'gravityforms_survey_uninstall', 'gravityforms_survey_results' );

	/**
	 * Permissions
	 */
	protected $_capabilities_settings_page = 'gravityforms_survey';
	protected $_capabilities_form_settings = 'gravityforms_survey';
	protected $_capabilities_uninstall = 'gravityforms_survey_uninstall';

	private static $_instance = null;

	/**
	 * Get an instance of this class.
	 *
	 * @return GFSurvey
	 */
	public static function get_instance() {
		if ( self::$_instance == null ) {
			self::$_instance = new GFSurvey();
		}

		return self::$_instance;
	}

	private function __clone() {
	} /* do nothing */

	/**
	 * Handles anything which requires early initialization.
	 */
	public function pre_init() {
		parent::pre_init();

		if ( $this->is_gravityforms_supported() && class_exists( 'GF_Field' ) ) {
			require_once( 'includes/class-gf-field-survey.php' );
			require_once( 'includes/class-gf-field-likert.php' );
			require_once( 'includes/class-gf-field-rank.php' );
			require_once( 'includes/class-gf-field-rating.php' );

			add_filter( 'gform_export_field_value', array( $this, 'export_field_value' ), 10, 4 );
		}
	}

	/**
	 * Handles hooks and loading of language files.
	 */
	public function init() {
		$this->_has_settings_renderer = $this->is_gravityforms_supported( '2.5-beta' );

		// Integration with the feed add-ons as of GF 1.9.15.12; for add-ons which don't override get_field_value().
		add_filter( 'gform_addon_field_value', array( $this, 'addon_field_value' ), 10, 5 );

		// AWeber 2.3 and newer use the gform_addon_field_value hook, only use the gform_aweber_field_value hook with older versions.
		if ( defined( 'GF_AWEBER_VERSION' ) && version_compare( 'GF_AWEBER_VERSION', '2.3', '<' ) ) {
			add_filter( 'gform_aweber_field_value', array( $this, 'legacy_addon_field_value' ), 10, 4 );
		}

		// Campaign Monitor Add-On integration
		add_filter( 'gform_campaignmonitor_field_value', array( $this, 'legacy_addon_field_value' ), 10, 4 );

		// Mailchimp Add-On integration
		add_filter( 'gform_mailchimp_field_value', array( $this, 'legacy_addon_field_value' ), 10, 4 );

		// Zapier Add-On integration
		add_filter( 'gform_zapier_field_value', array( $this, 'zapier_field_value' ), 10, 4 );

		// merge tags
		add_filter( 'gform_replace_merge_tags', array( $this, 'replace_merge_tags' ), 10, 7 );

		// add a special class to likert fields so we can identify them later
		add_action( 'gform_field_css_class', array( $this, 'add_custom_class' ), 10, 3 );

		// display survey results on entry detail
		add_filter( 'gform_entry_field_value', array( $this, 'entry_field_value' ), 10, 4 );

		// conditional logic filters
		add_filter( 'gform_entry_meta_conditional_logic_confirmations', array( $this, 'conditional_logic_filters' ), 10, 3 );
		add_filter( 'gform_entry_meta_conditional_logic_notifications', array( $this, 'conditional_logic_filters' ), 10, 3 );

		parent::init();

	}

	/**
	 * Initialize the admin specific hooks.
	 */
	public function init_admin() {

		// form editor
		add_action( 'gform_field_standard_settings', array( $this, 'survey_field_settings' ), 10, 2 );
		add_filter( 'gform_tooltips', array( $this, 'add_survey_tooltips' ) );

		// display results on entry list
		add_filter( 'gform_entries_field_value', array( $this, 'export_field_value' ), 10, 4 );

		// declare arrays on form import
		add_filter( 'gform_import_form_xml_options', array( $this, 'import_file_options' ) );

		// contacts
		add_filter( 'gform_contacts_tabs_contact_detail', array( $this, 'add_tab_to_contact_detail' ), 10, 2 );
		add_action( 'gform_contacts_tab_survey', array( $this, 'contacts_tab' ) );

		parent::init_admin();

	}

	/**
	 * The Survey add-on does not support logging.
	 *
	 * @param array $plugins The plugins which support logging.
	 *
	 * @return array
	 */
	public function set_logging_supported( $plugins ) {

		return $plugins;

	}


	// # SCRIPTS & STYLES -----------------------------------------------------------------------------------------------

	/**
	 * Return the scripts which should be enqueued.
	 *
	 * @return array
	 */
	public function scripts() {

		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min';

		$gsurvey_js_deps = array( 'jquery', 'jquery-ui-sortable' );
		if ( wp_is_mobile() ) {
			$gsurvey_js_deps[] = 'jquery-touch-punch';
		}

		$scripts = array(
			array(
				'handle'   => 'gsurvey_form_editor_js',
				'src'      => $this->get_base_url() . "/js/gsurvey_form_editor{$min}.js",
				'version'  => $this->_version,
				'deps'     => array( 'jquery' ),
				'callback' => array( $this, 'localize_scripts' ),
				'enqueue'  => array(
					array( 'admin_page' => array( 'form_editor' ) ),
				),
			),
			array(
				'handle'  => 'gsurvey_js',
				'src'     => $this->get_base_url() . "/js/gsurvey{$min}.js",
				'version' => $this->_version,
				'deps'    => $gsurvey_js_deps,
				'enqueue' => array(
					array( 'admin_page' => array( 'form_editor', 'results', 'entry_view', 'entry_detail', 'entry_edit' ) ),
					array( 'field_types' => array( 'survey' ) ),
				),
			),
		);

		$merge_tags = $this->get_merge_tags();

		if ( ! empty( $merge_tags ) ) {
			$scripts[] = array(
				'handle'  => 'gform_survey_merge_tags',
				'src'     => $this->get_base_url() . "/js/gsurvey_merge_tags{$min}.js",
				'version' => $this->_version,
				'deps'    => array( 'jquery' ),
				'enqueue' => array(
					array( 'admin_page' => array( 'form_settings' ) ),
				),
				'strings' => array(
					'merge_tags' => $merge_tags,
				),
			);
		}

		return array_merge( parent::scripts(), $scripts );
	}

	/**
	 * Return the stylesheets which should be enqueued.
	 *
	 * @return array
	 */
	public function styles() {

		$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min';

		$styles = array(
			array(
				'handle'  => 'gsurvey_form_editor_css',
				'src'     => $this->get_base_url() . "/css/gsurvey_form_editor{$min}.css",
				'version' => $this->_version,
				'enqueue' => array(
					array( 'admin_page' => array( 'form_editor' ) ),
				),
			),
			array(
				'handle'  => 'gsurvey_css',
				'src'     => $this->get_base_url() . "/css/gsurvey{$min}.css",
				'version' => $this->_version,
				'media'   => 'screen',
				'enqueue' => array(
					array( 'admin_page' => array( 'form_editor', 'results', 'entry_view', 'entry_detail', 'entry_edit' ) ),
					array(
						'field_types' => array( 'survey' )
					),
				),
			),
		);

		return array_merge( parent::styles(), $styles );
	}

	/**
	 * Localize the strings used by the scripts.
	 */
	public function localize_scripts() {

		// Get current page protocol
		$protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
		// Output admin-ajax.php URL with same protocol as current page
		$params = array(
			'ajaxurl'   => admin_url( 'admin-ajax.php', $protocol ),
			'imagesUrl' => $this->get_base_url() . '/images',
			'strings'   => array(
				'untitledSurveyField' => wp_strip_all_tags( __( 'Untitled Survey Field', 'gravityformssurvey' ) ),
			),
		);
		wp_localize_script( 'gsurvey_form_editor_js', 'gsurveyVars', $params );

		//localize strings for the js file
		$strings = array(
			'isLegacy'         => ! $this->_has_settings_renderer ? 'true' : 'false',
			'firstChoice'      => wp_strip_all_tags( __( 'First row', 'gravityformssurvey' ) ),
			'secondChoice'     => wp_strip_all_tags( __( 'Second row', 'gravityformssurvey' ) ),
			'thirdChoice'      => wp_strip_all_tags( __( 'Third row', 'gravityformssurvey' ) ),
			'fourthChoice'     => wp_strip_all_tags( __( 'Fourth row', 'gravityformssurvey' ) ),
			'fifthChoice'      => wp_strip_all_tags( __( 'Fifth row', 'gravityformssurvey' ) ),
			'dragToReOrder'    => wp_strip_all_tags( __( 'Drag to re-order', 'gravityformssurvey' ) ),
			'addAnotherRow'    => wp_strip_all_tags( __( 'Add another row', 'gravityformssurvey' ) ),
			'removeThisRow'    => wp_strip_all_tags( __( 'Remove this row', 'gravityformssurvey' ) ),
			'addAnotherColumn' => wp_strip_all_tags( __( 'Add another column', 'gravityformssurvey' ) ),
			'removeThisColumn' => wp_strip_all_tags( __( 'Remove this column', 'gravityformssurvey' ) ),
			'columnLabel1'     => wp_strip_all_tags( __( 'Strongly disagree', 'gravityformssurvey' ) ),
			'columnLabel2'     => wp_strip_all_tags( __( 'Disagree', 'gravityformssurvey' ) ),
			'columnLabel3'     => wp_strip_all_tags( __( 'Neutral', 'gravityformssurvey' ) ),
			'columnLabel4'     => wp_strip_all_tags( __( 'Agree', 'gravityformssurvey' ) ),
			'columnLabel5'     => wp_strip_all_tags( __( 'Strongly agree', 'gravityformssurvey' ) ),
		);
		wp_localize_script( 'gsurvey_form_editor_js', 'gsurveyLikertStrings', $strings );

		//localize strings for the rank field
		$rank_strings = array(
			'firstChoice'  => wp_strip_all_tags( __( 'First Choice', 'gravityformssurvey' ) ),
			'secondChoice' => wp_strip_all_tags( __( 'Second Choice', 'gravityformssurvey' ) ),
			'thirdChoice'  => wp_strip_all_tags( __( 'Third Choice', 'gravityformssurvey' ) ),
			'fourthChoice' => wp_strip_all_tags( __( 'Fourth Choice', 'gravityformssurvey' ) ),
			'fifthChoice'  => wp_strip_all_tags( __( 'Fifth Choice', 'gravityformssurvey' ) ),
		);
		wp_localize_script( 'gsurvey_form_editor_js', 'gsurveyRankStrings', $rank_strings );

		//localize strings for the ratings field
		$rating_strings = array(
			'firstChoice'  => wp_strip_all_tags( __( 'Terrible', 'gravityformssurvey' ) ),
			'secondChoice' => wp_strip_all_tags( __( 'Not so great', 'gravityformssurvey' ) ),
			'thirdChoice'  => wp_strip_all_tags( __( 'Neutral', 'gravityformssurvey' ) ),
			'fourthChoice' => wp_strip_all_tags( __( 'Pretty good', 'gravityformssurvey' ) ),
			'fifthChoice'  => wp_strip_all_tags( __( 'Excellent', 'gravityformssurvey' ) ),
		);
		wp_localize_script( 'gsurvey_form_editor_js', 'gsurveyRatingStrings', $rating_strings );

	}

	public function localize_results_scripts() {

		$filter_fields    = rgget( 'f' );
		$filter_types     = rgget( 't' );
		$filter_operators = rgget( 'o' );
		$filter_values    = rgget( 'v' );

		// Get current page protocol
		$protocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
		// Output admin-ajax.php URL with same protocol as current page

		$vars = array(
			'ajaxurl'         => admin_url( 'admin-ajax.php', $protocol ),
			'imagesUrl'       => $this->get_base_url() . '/images',
			'filterFields'    => $filter_fields,
			'filterTypes'     => $filter_types,
			'filterOperators' => $filter_operators,
			'filterValues'    => $filter_values,
		);

		wp_localize_script( 'gsurvey_results_js', 'gresultsVars', $vars );

		$strings = array(
			'noFilters'         => wp_strip_all_tags( __( 'No filters', 'gravityformspolls' ) ),
			'addFieldFilter'    => wp_strip_all_tags( __( 'Add a field filter', 'gravityformspolls' ) ),
			'removeFieldFilter' => wp_strip_all_tags( __( 'Remove a field filter', 'gravityformspolls' ) ),
			'ajaxError'         => wp_strip_all_tags( __( 'Error retrieving results. Please contact support.', 'gravityformspolls' ) ),
		);

		wp_localize_script( 'gsurvey_results_js', 'gresultsStrings', $strings );

	}


	// # RESULTS & SCORING ----------------------------------------------------------------------------------------------

	/**
	 * Configure the survey results page.
	 *
	 * @return array
	 */
	public function get_results_page_config() {
		return array(
			'title'        => esc_html__( 'Survey Results', 'gravityformssurvey' ),
			'capabilities' => array( 'gravityforms_survey_results' ),
			'callbacks'    => array(
				'fields'  => array( $this, 'results_fields' ),
				'filters' => array( $this, 'results_filters' ),
			),
		);
	}

	/**
	 * Remove the score from the results page filters if scoring is not enabled on a Likert field.
	 *
	 * @param array $filters
	 * @param array $form
	 *
	 * @return array
	 */
	public function results_filters( $filters, $form ) {
		$fields = $form['fields'];
		foreach ( $fields as $field ) {
			if ( $field->get_input_type() == 'likert' && $field->gsurveyLikertEnableScoring ) {
				return $filters;
			}
		}

		foreach ( $filters as $key => $filter ) {
			if ( $filter['key'] == 'gsurvey_score' ) {
				unset( $filters[ $key ] );
			}
		}

		return $filters;
	}

	/**
	 * Get all the survey fields for the current form.
	 *
	 * @param array $form The current form object.
	 *
	 * @return GF_Field[]
	 */
	public function results_fields( $form ) {
		return GFAPI::get_fields_by_type( $form, array( 'survey' ) );
	}

	/**
	 * Helper to check if scoring is enabled on at least one of the forms Likert fields.
	 *
	 * @param array $form The current form object.
	 *
	 * @return bool
	 */
	private function scoring_enabled( $form ) {
		$survey_fields = $this->results_fields( $form );

		foreach ( $survey_fields as $field ) {
			if ( $field->get_input_type() == 'likert' && $field->gsurveyLikertEnableScoring ) {
				return true;
			}
		}

		return false;
	}

	/**
	 * Returns the total score of all likert fields with scoring enabled.
	 *
	 * @param array $form The current form object.
	 * @param array $entry The current entry object.
	 *
	 * @return float|int
	 */
	public function get_survey_score( $form, $entry ) {
		$survey_fields = $this->results_fields( $form );
		$score         = 0;
		foreach ( $survey_fields as $field ) {
			if ( $field->get_input_type() == 'likert' && $field->gsurveyLikertEnableScoring ) {
				$score += $this->get_field_score( $field, $entry );
			}
		}

		return $score;
	}

	/**
	 * Returns the total score of all likert fields with scoring enabled.
	 *
	 * @param array $form The current form object.
	 * @param array $entry The current entry object.
	 *
	 * @return float|int
	 */
	public function get_total_score( $form, $entry ) {

		return $this->get_survey_score( $form, $entry );
	}

	/**
	 * Returns the score for the specified field.
	 *
	 * Called statically by GFResults.
	 *
	 * @param GF_Field_Likert $field The current field.
	 * @param array $entry The current entry object.
	 *
	 * @return float|int
	 */
	public static function get_field_score( $field, $entry ) {
		$score = 0;
		if ( $field->gsurveyLikertEnableMultipleRows ) {
			// cycle through the entry values in case the the number of choices has changed since the entry was submitted
			foreach ( $entry as $key => $value ) {
				if ( intval( $key ) != $field->id ) {
					continue;
				}

				if ( false === strpos( $value, ':' ) ) {
					continue;
				}

				list( $row_val, $col_val ) = explode( ':', $value, 2 );

				foreach ( $field->gsurveyLikertRows as $row ) {
					if ( $row['value'] == $row_val ) {
						foreach ( $field->choices as $choice ) {
							if ( $choice['value'] == $col_val ) {
								$score += floatval( rgar( $choice, 'score' ) );
							}
						}
					}
				}
			}
		} else {
			$value = rgar( $entry, $field->id );
			if ( ! empty( $value ) ) {
				foreach ( $field->choices as $choice ) {
					if ( $choice['value'] == $value ) {
						$score += floatval( rgar( $choice, 'score' ) );
					}
				}
			}
		}

		return $score;
	}

	/**
	 * Returns the score for the specified row.
	 *
	 * @param string $target_row_val The unique id (value) for the likert row.
	 * @param GF_Field_Likert $field The current field.
	 * @param array $entry The current entry.
	 *
	 * @return float|int
	 */
	public static function get_likert_row_score( $target_row_val, $field, $entry ) {
		$score = 0;

		if ( $field->gsurveyLikertEnableMultipleRows ) {

			foreach ( $entry as $key => $value ) {
				if ( intval( $key ) != $field->id ) {
					continue;
				}

				if ( false === strpos( $value, ':' ) ) {
					continue;
				}

				list( $row_val, $col_val ) = explode( ':', $value, 2 );

				foreach ( $field->gsurveyLikertRows as $row ) {
					if ( $row['value'] == $row_val && $target_row_val == $row_val ) {
						foreach ( $field->choices as $choice ) {
							if ( $choice['value'] == $col_val ) {
								$score = floatval( rgar( $choice, 'score' ) );

								return $score;
							}
						}
					}
				}
			}
		} else {
			$score = self::get_field_score( $field, $entry );
		}

		return $score;
	}

	// # MERGE TAGS -----------------------------------------------------------------------------------------------------

	/**
	 * Add the score merge tags to the merge tag drop downs in the admin.
	 *
	 * @deprecated 3.7 Use GFSurvey::get_merge_tags().
	 *
	 * @param array $form The current form.
	 *
	 * @return array
	 */
	public function add_merge_tags( $form ) {
		_deprecated_function( __METHOD__, '3.7', 'GFSurvey::get_merge_tags()' );
		return $form;
	}

	/**
	 * Gets the merge tags to add to the merge tag drop downs in the admin.
	 *
	 * @return array
	 */
	private function get_merge_tags() {
		$merge_tags = array();
		$form       = $this->get_current_form();

		if ( ! $form ) {
			return $merge_tags;
		}

		$survey_fields = GFAPI::get_fields_by_type( $form, array( 'survey' ) );

		if ( empty( $survey_fields ) ) {
			return $merge_tags;
		}

		$scoring_enabled = false;

		foreach ( $form['fields'] as $field ) {
			if ( $field->get_input_type() == 'likert' && $field->gsurveyLikertEnableScoring ) {
				$scoring_enabled = true;
				$field_id        = $field->id;
				$field_label     = $field->label;
				$group           = $field->isRequired ? 'required' : 'optional';
				$merge_tags[]    = array(
					'group' => $group,
					'label' => esc_html__( 'Survey Field Score: ', 'gravityformssurvey' ) . $field_label,
					'tag'   => "{score:id={$field_id}}",
				);
			}
		}

		if ( $scoring_enabled ) {
			$merge_tags[] = array(
				'group' => 'other',
				'label' => esc_html__( 'Survey Total Score', 'gravityformssurvey' ),
				'tag'   => '{survey_total_score}',
			);
		}

		return $merge_tags;
	}

	/**
	 * Replace the score merge tags.
	 *
	 * @param string $text The current text in which merge tags are being replaced.
	 * @param array $form The current form object.
	 * @param array $entry The current entry object.
	 * @param bool $url_encode Whether or not to encode any URLs found in the replaced value.
	 * @param bool $esc_html Whether or not to encode HTML found in the replaced value.
	 * @param bool $nl2br Whether or not to convert newlines to break tags.
	 * @param string $format The format requested for the location the merge is being used. Possible values: html, text or url.
	 *
	 * @return string
	 */
	public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html, $nl2br, $format ) {

		if ( empty( $entry ) || empty( $form ) ) {
			return $text;
		}

		$survey_fields = GFAPI::get_fields_by_type( $form, array( 'survey' ) );
		if ( empty( $survey_fields ) ) {
			return $text;
		}

		$total_merge_tag = '{survey_total_score}';

		if ( false !== strpos( $text, $total_merge_tag ) ) {
			$score_total = $this->get_total_score( $form, $entry );
			$text        = str_replace( $total_merge_tag, $score_total, $text );
		}

		preg_match_all( "/\{score:(.*?)\}/", $text, $matches, PREG_SET_ORDER );
		foreach ( $matches as $match ) {

			$full_tag       = $match[0];
			$options_string = isset( $match[1] ) ? $match[1] : '';
			$options        = shortcode_parse_atts( $options_string );
			extract(
				shortcode_atts(
					array(
						'id' => 0,
					), $options
				)
			);
			if ( 0 == $id ) {
				continue;
			}

			$field = GFFormsModel::get_field( $form, $id );
			if ( ! is_object( $field ) || $field->get_input_type() != 'likert' ) {
				continue;
			}

			if ( $id == intval( $id ) ) {
				$score = $this->get_field_score( $field, $entry );
			} else {
				$score = $this->get_likert_row_score( $field->get_row_id( $id ), $field, $entry );
			}

			$text = str_replace( $full_tag, $url_encode ? urlencode( $score ) : $score, $text );
		}

		return $text;
	}


	// # ENTRY RELATED --------------------------------------------------------------------------------------------------

	/**
	 * Add the Survey Total Score entry meta property.
	 *
	 * @param array $entry_meta An array of entry meta already registered with the gform_entry_meta filter.
	 * @param int $form_id The form id
	 *
	 * @return array The filtered entry meta array.
	 */
	public function get_entry_meta( $entry_meta, $form_id ) {
		if ( empty( $form_id ) ) {
			return $entry_meta;
		}
		$form          = RGFormsModel::get_form_meta( $form_id );
		$survey_fields = GFAPI::get_fields_by_type( $form, array( 'survey' ) );
		if ( false === empty( $survey_fields ) && $this->scoring_enabled( $form ) ) {

			$entry_meta['gsurvey_score'] = array(
				'label'                      => esc_html__( 'Survey Total Score', 'gravityformssurvey' ),
				'is_numeric'                 => true,
				'is_default_column'          => false,
				'update_entry_meta_callback' => array( $this, 'update_entry_meta' ),
				'filter'                     => array(
					'operators' => array( 'is', 'isnot', '>', '<' ),
				),
			);

		}

		return $entry_meta;
	}

	/**
	 * Used to update the Survey Total Score entry meta property
	 *
	 * @param string $key The key of the property to be updated.
	 * @param array $entry The current entry object.
	 * @param array $form The current form object.
	 *
	 * @return mixed
	 */
	public function update_entry_meta( $key, $entry, $form ) {
		$value = '';

		if ( $key == 'gsurvey_score' ) {
			$value = $this->get_survey_score( $form, $entry );
		}


		return $value;
	}

	/**
	 * Remove the survey score from the entry meta conditional logic filters on the notifications/confirmations pages.
	 *
	 * @param array $filters The array of filters.
	 * @param array $form The current form object.
	 * @param string $id The ID of the notification/confirmation being edited.
	 *
	 * @return mixed
	 */
	public function conditional_logic_filters( $filters, $form, $id ) {
		$survey_fields = GFAPI::get_fields_by_type( $form, array( 'survey' ) );
		if ( empty( $survey_fields ) ) {
			return $filters;
		}

		if ( false === $this->scoring_enabled( $form ) ) {
			unset( $filters['gsurvey_score'] );
		}

		return $filters;
	}

	/**
	 * Format the Survey field values for entry exports and the entry list page so they use the choice text instead of values.
	 *
	 * @param string|array $value The field value.
	 * @param int $form_id The ID of the form currently being processed.
	 * @param string $field_id The ID of the field currently being processed.
	 * @param array $entry The entry object currently being processed.
	 *
	 * @return string|array
	 */
	public function export_field_value( $value, $form_id, $field_id, $entry ) {
		if ( ! rgblank( $value ) ) {
			$form_meta = RGFormsModel::get_form_meta( $form_id );
			$field     = RGFormsModel::get_field( $form_meta, $field_id );

			return $this->maybe_format_field_values( $value, $field );
		}

		return $value;
	}

	/**
	 * Format the Survey field values on the entry detail page so they use the choice text instead of values.
	 *
	 * @param string|array $value The field value.
	 * @param GF_Field $field The field currently being processed.
	 * @param array $entry The entry object currently being processed.
	 * @param array $form The form object currently being processed.
	 *
	 * @return string|array
	 */
	public function entry_field_value( $value, $field, $entry, $form ) {

		return ! rgblank( $value ) ? $this->maybe_format_field_values( $value, $field ) : $value;
	}

	/**
	 * Format the Survey field values so they use the choice text instead of values before being passed to the third-party.
	 *
	 * @param string $value The field value.
	 * @param array $form The form currently being processed.
	 * @param array $entry The entry object currently being processed.
	 * @param string $field_id The ID of the field currently being processed.
	 *
	 * @return string
	 */
	public function addon_field_value( $value, $form, $entry, $field_id, $slug ) {
		if ( ! rgblank( $value ) ) {
			$field = RGFormsModel::get_field( $form, $field_id );

			return $this->maybe_format_field_values( $value, $field );
		}

		return $value;
	}

	/**
	 * If the field is a Survey type radio, select or checkbox then replace the choice value with the choice text.
	 *
	 * @param string $value The field value.
	 * @param GF_Field|null $field The field object being processed or null.
	 *
	 * @return string
	 */
	public function maybe_format_field_values( $value, $field ) {

		if ( is_object( $field ) && $field->type == 'survey' ) {
			switch ( $field->inputType ) {
				case 'radio' :
				case 'select' :
					return RGFormsModel::get_choice_text( $field, $value );

				case 'checkbox' :
					if ( is_array( $value ) ) {
						foreach ( $value as &$choice ) {
							if ( ! empty( $choice ) ) {
								$choice = RGFormsModel::get_choice_text( $field, $choice );
							}
						}
					} else {
						foreach ( $field->choices as $choice ) {
							$val   = rgar( $choice, 'value' );
							$text  = rgar( $choice, 'text' );
							$value = str_replace( $val, $text, $value );
						}
					}
			}
		}

		return $value;
	}

	/**
	 * Format the Survey field values so they use the choice text instead of values before being passed to the third-party.
	 *
	 * @param string $value The field value.
	 * @param int $form_id The ID of the form currently being processed.
	 * @param string $field_id The ID of the field currently being processed.
	 * @param array $entry The entry object currently being processed.
	 *
	 * @return string
	 */
	public function legacy_addon_field_value( $value, $form_id, $field_id, $entry ) {
		if ( ! rgblank( $value ) ) {
			$form_meta = RGFormsModel::get_form_meta( $form_id );
			$field     = RGFormsModel::get_field( $form_meta, $field_id );

			if ( is_object( $field ) && $field->type == 'survey' ) {
				return $field->get_value_export( $entry, $field_id, true );
			}
		}

		return $value;
	}

	/**
	 * Format the Survey field values so they use the choice text instead of values before they are sent to Zapier.
	 *
	 * @param string|array $value The field value.
	 * @param int $form_id The ID of the form currently being processed.
	 * @param string $field_id The ID of the field currently being processed.
	 * @param array $entry The entry object currently being processed.
	 *
	 * @return string|array
	 */
	public function zapier_field_value( $value, $form_id, $field_id, $entry ) {
		if ( ! rgblank( $value ) ) {
			$form_meta = RGFormsModel::get_form_meta( $form_id );
			$field     = RGFormsModel::get_field( $form_meta, $field_id );

			if ( is_object( $field ) && $field->type == 'survey' ) {
				switch ( $field->inputType ) {
					case 'likert' :
						if ( is_array( $value ) ) {
							foreach ( $value as $key => &$row ) {
								if ( ! empty( $row ) ) {
									$row = $field->get_column_text( $value, false, $key );
								}
							}
						} else {

							return $field->get_column_text( $value );
						}

						break;

					case 'rank' :
					case 'rating' :
					case 'radio' :
					case 'select' :
						return $field->get_value_export( $entry, $field_id, true );

					case 'checkbox' :
						foreach ( $value as &$choice ) {
							if ( ! empty( $choice ) ) {
								$choice = RGFormsModel::get_choice_text( $field, $choice );
							}
						}
				}
			}
		}

		return $value;
	}


	// # FIELD SETTINGS -------------------------------------------------------------------------------------------------

	/**
	 * Add the gsurvey-field class to the Survey field.
	 *
	 * @param string $classes The CSS classes to be filtered, separated by empty spaces.
	 * @param GF_Field $field The field currently being processed.
	 * @param array $form The form currently being processed.
	 *
	 * @return string
	 */
	public function add_custom_class( $classes, $field, $form ) {
		if ( $field->type == 'survey' ) {
			$classes .= ' gsurvey-survey-field ';
		}

		return $classes;
	}

	/**
	 * Add the tooltips for the Survey field.
	 *
	 * @param array $tooltips An associative array of tooltips where the key is the tooltip name and the value is the tooltip.
	 *
	 * @return array
	 */
	public function add_survey_tooltips( $tooltips ) {
		$tooltips['gsurvey_question']                    = '<h6>' . esc_html__( 'Survey Question', 'gravityformssurvey' ) . '</h6>' . esc_html__( 'Enter the question you would like to ask the user.', 'gravityformssurvey' );
		$tooltips['gsurvey_field_type']                  = '<h6>' . esc_html__( 'Survey Field Type', 'gravityformssurvey' ) . '</h6>' . esc_html__( 'Select the type of field that will be used for the survey.', 'gravityformssurvey' );
		$tooltips['gsurvey_likert_columns']              = '<h6>' . esc_html__( 'Likert Columns', 'gravityformssurvey' ) . '</h6>' . esc_html__( 'Edit the choices for this likert field.', 'gravityformssurvey' );
		$tooltips['gsurvey_likert_enable_multiple_rows'] = '<h6>' . esc_html__( 'Enable Multiple Rows', 'gravityformssurvey' ) . '</h6>' . esc_html__( 'Select to add multiple rows to the likert field.', 'gravityformssurvey' );
		$tooltips['gsurvey_likert_rows']                 = '<h6>' . esc_html__( 'Likert Rows', 'gravityformssurvey' ) . '</h6>' . esc_html__( 'Edit the texts that will appear to the left of each row of choices.', 'gravityformssurvey' );
		$tooltips['gsurvey_likert_enable_scoring']       = '<h6>' . esc_html__( 'Enable Scoring', 'gravityformssurvey' ) . '</h6>' . esc_html__( 'Scoring allows different scores for each column. Aggregate scores are displayed in the results page and can be used in merge tags.', 'gravityformssurvey' );

		return $tooltips;
	}

	/**
	 * Add the custom settings for the Survey fields to the fields general tab.
	 *
	 * @param int $position The position the settings should be located at.
	 * @param int $form_id  The ID of the form currently being edited.
	 */
	public function survey_field_settings( $position, $form_id ) {
		if ( $position == 25 ) {
			?>
			<li class="gsurvey-setting-question field_setting">
				<label for="gsurvey-question" class="section_label">
					<?php esc_html_e( 'Survey Question', 'gravityformssurvey' ); ?>
					<?php gform_tooltip( 'gsurvey_question' ); ?>
				</label>
				<textarea
					id="gsurvey-question"
					class="fieldwidth-3 fieldheight-2"
					onkeyup="SetFieldLabel(this.value)"
					size="35">
				</textarea>
			</li>
			<li class="gsurvey-setting-field-type field_setting">
				<label for="gsurvey-field-type" class="section_label">
					<?php esc_html_e( 'Survey Field Type', 'gravityformssurvey' ); ?>
					<?php gform_tooltip( 'gsurvey_field_type' ); ?>
				</label>
				<select
					id="gsurvey-field-type"
					onchange="if(jQuery(this).val() == '') return; jQuery('#field_settings').slideUp(function(){StartChangeSurveyType(jQuery('#gsurvey-field-type').val());});"
				>
					<option value="likert"><?php esc_html_e( 'Likert', 'gravityformssurvey' ); ?></option>
					<option value="rank"><?php esc_html_e( 'Rank', 'gravityformssurvey' ); ?></option>
					<option value="rating"><?php esc_html_e( 'Rating', 'gravityformssurvey' ); ?></option>
					<option value="radio"><?php esc_html_e( 'Radio Buttons', 'gravityformssurvey' ); ?></option>
					<option value="checkbox"><?php esc_html_e( 'Checkboxes', 'gravityformssurvey' ); ?></option>
					<option value="text"><?php esc_html_e( 'Single Line Text', 'gravityformssurvey' ); ?></option>
					<option value="textarea"><?php esc_html_e( 'Paragraph Text', 'gravityformssurvey' ); ?></option>
					<option value="select"><?php esc_html_e( 'Drop Down', 'gravityformssurvey' ); ?></option>
				</select>
			</li>
			<?php
		} elseif ( $position == 1362 ) {
			?>
			<li class="gsurvey-likert-setting-columns field_setting">
				<div class="gsurvey-likert-setting-columns-header">
					<label for="gsurvey-likert-columns" class="section_label">
						<?php esc_html_e( 'Columns', 'gravityformssurvey' ); ?>
						<?php gform_tooltip( 'gsurvey_likert_columns' ); ?>
					</label>

					<div class="gsurvey-likert-enable-scoring-container">
						<input
							id="gsurvey-likert-enable-scoring"
							type="checkbox"
							onclick="SetFieldProperty('gsurveyLikertEnableScoring', this.checked); jQuery('#gsurvey-likert-columns-container').toggleClass('gsurvey-likert-scoring-enabled');"
						/>
						<label class="inline gfield_value_label" for="gsurvey-likert-enable-scoring">
							<?php esc_html_e( 'Enable Scoring', 'gravityformssurvey' ); ?>
						</label> <?php gform_tooltip( 'gsurvey_likert_enable_scoring' ); ?>
					</div>
				</div>

				<div id="gsurvey-likert-columns-container">
					<ul id="gsurvey-likert-columns"></ul>
				</div>
			</li>
			<li class="gsurvey-likert-setting-enable-multiple-rows field_setting">
				<input
					type="checkbox"
					id="gsurvey-likert-enable-multiple-rows"
					onclick="field = GetSelectedField(); var value = jQuery(this).is(':checked'); SetFieldProperty('gsurveyLikertEnableMultipleRows', value); gsurveyLikertUpdateInputs(field); gsurveyLikertUpdatePreview(); jQuery('.gsurvey-likert-setting-rows').toggle();"
				/>
				<label for="gsurvey-likert-enable-multiple-rows" class="inline">
					<?php esc_html_e( 'Enable Multiple Rows', 'gravityformssurvey' ); ?>
					<?php gform_tooltip( 'gsurvey_likert_enable_multiple_rows' ); ?>
				</label>

			</li>
			<li class="gsurvey-likert-setting-rows field_setting">
				<label for="gsurvey-likert-rows" class="section_label">
					<?php esc_html_e( 'Rows', 'gravityformssurvey' ); ?>
					<?php gform_tooltip( 'gsurvey_likert_rows' ); ?>
				</label>
				<div id="gsurvey-likert-rows-container">
					<ul id="gsurvey-likert-rows"></ul>
				</div>
			</li>
			<?php
		}
	}


	// # CONTACTS INTEGRATION -------------------------------------------------------------------------------------------

	public function add_tab_to_contact_detail( $tabs, $contact_id ) {
		if ( $contact_id > 0 ) {
			$tabs[] = array( 'name' => 'survey', 'label' => esc_html__( 'Survey Entries', 'gravityformssurvey' ) );
		}

		return $tabs;
	}

	public function contacts_tab( $contact_id ) {

		if ( false === empty( $contact_id ) ) :
			$search_criteria['status'] = 'active';
			$search_criteria['field_filters'][] = array(
				'type'  => 'meta',
				'key'   => 'gcontacts_contact_id',
				'value' => $contact_id,
			);
			$form_ids                           = array();
			$forms                              = GFFormsModel::get_forms( true );
			foreach ( $forms as $form ) {
				$form_meta     = GFFormsModel::get_form_meta( $form->id );
				$survey_fields = GFCommon::get_fields_by_type( $form_meta, array( 'survey' ) );
				if ( ! empty( $survey_fields ) ) {
					$form_ids[] = $form->id;
				}
			}

			if ( empty( $form_ids ) ) {
				return;
			}
			$entries                   = GFAPI::get_entries( $form_ids, $search_criteria );

			if ( empty( $entries ) ) :
				esc_html_e( 'This contact has not submitted any survey entries yet.', 'gravityformssurvey' );
			else :
				?>
				<h3><span><?php esc_html_e( 'Survey Entries', 'gravityformssurvey' ) ?></span></h3>
				<div>
					<table id="gcontacts-entry-list" class="widefat">
						<tr class="gcontacts-entries-header">
							<td>
								<?php esc_html_e( 'Entry ID', 'gravityformssurvey' ) ?>
							</td>
							<td>
								<?php esc_html_e( 'Date', 'gravityformssurvey' ) ?>
							</td>
							<td>
								<?php esc_html_e( 'Form', 'gravityformssurvey' ) ?>
							</td>
						</tr>
						<?php


						foreach ( $entries as $entry ) {
							$form_id    = $entry['form_id'];
							$form       = GFFormsModel::get_form_meta( $form_id );
							$form_title = rgar( $form, 'title' );
							$entry_id   = $entry['id'];
							$entry_date = GFCommon::format_date( rgar( $entry, 'date_created' ), false );
							$entry_url  = admin_url( "admin.php?page=gf_entries&view=entry&id={$form_id}&lid={$entry_id}" );

							?>
							<tr>
								<td>
									<a href="<?php echo $entry_url; ?>"><?php echo $entry_id; ?></a>
								</td>
								<td>
									<?php echo $entry_date; ?>
								</td>
								<td>
									<?php echo $form_title; ?>
								</td>


							</tr>
							<?php
						}
						?>
					</table>
				</div>
				<?php
			endif;
		endif;

	}


	// # DEPRECATED -----------------------------------------------------------------------------------------------------

	/**
	 * Returns the Likert column text.
	 *
	 * @deprecated
	 * @param GF_Field_Likert $field The field being processed.
	 * @param string $value The field value.
	 *
	 * @return string
	 */
	public function get_likert_column_text( $field, $value ) {
		_deprecated_function( __FUNCTION__, '3.0', '$field->get_column_text( $value, $entry = false, $field_id = false, $include_row_text = false )' );

		if ( $field->gsurveyLikertEnableMultipleRows ) {
			if ( false === strpos( $value, ':' ) ) {
				return '';
			}
			list( $row_val, $col_val ) = explode( ':', $value, 2 );

			foreach ( $field->gsurveyLikertRows as $row ) {
				if ( $row['value'] == $row_val ) {
					foreach ( $field->choices as $choice ) {
						if ( $choice['value'] == $col_val ) {
							return $choice['text'];
						}
					}
				}
			}
		} else {
			foreach ( $field->choices as $choice ) {
				if ( $choice['value'] == $value ) {
					return $choice['text'];
				}
			}
		}

	}

	/**
	 * Returns the label for the row at the specified index in the gsurveyLikertRows array.
	 *
	 * @param GF_Field_Likert $field The field being processed.
	 * @param integer $index The row index.
	 *
	 * @return string
	 */
	public function get_likert_row_text( $field, $index ) {

		return $field->gsurveyLikertEnableMultipleRows ? $field->gsurveyLikertRows[ $index ]['text'] : '';
	}

	/**
	 * Support importing forms using the old XML format.
	 *
	 * @param array $options Array of options for the XML import.
	 *
	 * @return array
	 */
	public function import_file_options( $options ) {
		$options['gsurveyLikertRow'] = array( 'unserialize_as_array' => true );

		return $options;
	}

} // end class

Youez - 2016 - github.com/yon3zu
LinuXploit