����JFIFXX�����    $.' ",#(7),01444'9=82<.342  2!!22222222222222222222222222222222222222222222222222����"��4�� ���,�PG"Z_�4�˷����kjز�Z�,F+��_z�,�© �����zh6�٨�ic�fu���#ډb���_�N�?��wQ���5-�~�I���8����TK<5o�Iv-�����k�_U_�����~b�M��d����Ӝ�U�Hh��?]��E�w��Q���k�{��_}qFW7HTՑ��Y��F�?_�'ϔ��_�Ջt��=||I ��6�έ"�����D���/[�k�9���Y�8ds|\���Ҿp6�Ҵ���]��.����6�z<�v��@]�i%��$j��~�g��J>��no����pM[me�i$[����s�o�ᘨ�˸ nɜG-�ĨU�ycP�3.DB�li�;��hj���x7Z^�N�h������N3u{�:j�x�힞��#M&��jL P@_���� P��&��o8������9�����@Sz6�t7#O�ߋ �s}Yf�T���lmr����Z)'N��k�۞p����w\�Tȯ?�8`�O��i{wﭹW�[�r�� ��Q4F�׊���3m&L�=��h3����z~��#�\�l :�F,j@�� ʱ�wQT����8�"kJO���6�֚l����}���R�>ډK���]��y����&����p�}b��;N�1�m�r$�|��7�>e�@B�TM*-iH��g�D�)� E�m�|�ؘbҗ�a��Ҿ����t4���o���G��*oCN�rP���Q��@z,|?W[0�����:�n,jWiE��W��$~/�hp\��?��{(�0���+�Y8rΟ�+����>S-S����VN;�}�s?.����� w�9��˟<���Mq4�Wv'��{)0�1mB��V����W[�����8�/<� �%���wT^�5���b��)iM� pg�N�&ݝ��VO~�q���u���9� ����!��J27����$O-���! �:�%H��� ـ����y�ΠM=t{!S�� oK8������t<����è:a������[�����ա�H���~��w��Qz`�po�^ ����Q��n� �,uu�C�$ ^���,������8�#��:�6��e�|~���!�3�3.�\0��q��o�4`.|� ����y�Q�`~;�d�ׯ,��O�Zw�������`73�v�܋�<���Ȏ�� ـ4k��5�K�a�u�=9Yd��$>x�A�&�� j0� ���vF��� Y�|�y��� ~�6�@c��1vOp�Ig����4��l�OD���L����� R���c���j�_�uX6��3?nk��Wy�f;^*B� ��@�~a�`��Eu������+���6�L��.ü>��}y���}_�O�6�͐�:�YrG�X��kG�����l^w���~㒶sy��Iu�!� W ��X��N�7BV��O��!X�2����wvG�R�f�T#�����t�/?���%8�^�W�aT��G�cL�M���I��(J����1~�8�?aT ���]����AS�E��(��*E}� 2��#I/�׍qz��^t�̔���b�Yz4x���t�){ OH��+(E��A&�N�������XT��o��"�XC��'���)}�J�z�p� ��~5�}�^����+�6����w��c��Q�|Lp�d�H��}�(�.|����k��c4^�"�����Z?ȕ ��a<�L�!039C� �Eu�C�F�Ew�ç ;�n?�*o���B�8�bʝ���'#Rqf���M}7����]����s2tcS{�\icTx;�\��7K���P���ʇ Z O-��~��c>"��?�������P��E��O�8��@�8��G��Q�g�a�Վ���󁶠�䧘��_%#r�>�1�z�a��eb��qcPѵ��n���#L��� =��׀t� L�7�`��V���A{�C:�g���e@�w1 Xp3�c3�ġ����p��M"'-�@n4���fG��B3�DJ�8[Jo�ߐ���gK)ƛ��$���� ���8�3�����+���� �����6�ʻ���� ���S�kI�*KZlT _`���?��K����QK�d����B`�s}�>���`��*�>��,*@J�d�oF*����弝��O}�k��s��]��y�ߘ��c1G�V���<=�7��7����6�q�PT��tXԀ�!9*4�4Tހ3XΛex�46���Y��D ����� �BdemDa����\�_l,��G�/���֌7���Y�](�xTt^%�GE�����4�}bT���ڹ�����;Y)���B�Q��u��>J/J �⮶.�XԄ��j�ݳ�+E��d ��r�5�_D�1 ��o�� �B�x�΢�#���<��W�����8���R6�@g�M�.��� dr�D��>(otU��@x=��~v���2� ӣ�d�oBd��3�eO�6�㣷�����ݜ6��6Y��Qz`��S��{���\P�~z m5{J/L��1������<�e�ͅPu�b�]�ϔ���'������f�b� Zpw��c`"��i���BD@:)ִ�:�]��hv�E�w���T�l��P���"Ju�}��وV J��G6��. J/�Qgl߭�e�����@�z�Zev2u�)]կ�����7x���s�M�-<ɯ�c��r�v�����@��$�ޮ}lk���a���'����>x��O\�ZFu>�����ck#��&:��`�$�ai�>2Δ����l���oF[h��lE�ܺ�Πk:)���`�� $[6�����9�����kOw�\|���8}������ބ:��񶐕��I�A1/�=�2[�,�!��.}gN#�u����b��� ~��݊��}34q����d�E��Lc��$��"�[q�U�硬g^��%B �z���r�pJ�ru%v\h1Y�ne`ǥ:g���pQM~�^�Xi� ��`S�:V29.�P���V�?B�k�� AEvw%�_�9C�Q����wKekPؠ�\�;Io d�{ ߞo�c1eP����\� `����E=���@K<�Y���eڼ�J���w����{av�F�'�M�@/J��+9p���|]�����Iw &`��8���&M�hg��[�{��Xj��%��Ӓ�$��(����ʹN���<>�I���RY���K2�NPlL�ɀ)��&e����B+ь����( � �JTx���_?EZ� }@ 6�U���뙢ط�z��dWI�n` D����噥�[��uV��"�G&Ú����2g�}&m��?ċ�"����Om#��������� ��{�ON��"S�X��Ne��ysQ���@Fn��Vg���dX�~nj�]J�<�K]:��FW��b�������62�=��5f����JKw��bf�X�55��~J �%^����:�-�QIE��P��v�nZum� z � ~ə ���� ���ة����;�f��\v���g�8�1��f24;�V���ǔ�)����9���1\��c��v�/'Ƞ�w�������$�4�R-��t���� e�6�/�ġ �̕Ecy�J���u�B���<�W�ַ~�w[B1L۲�-JS΂�{���΃������A��20�c#��@ 0!1@AP"#2Q`$3V�%45a6�FRUq��� ����^7ׅ,$n�������+��F�`��2X'��0vM��p�L=������5��8������u�p~���.�`r�����\���O��,ư�0oS ��_�M�����l���4�kv\JSd���x���SW�<��Ae�IX����������$I���w�:S���y���›R��9�Q[���,�5�;�@]�%���u�@ *ro�lbI �� ��+���%m:�͇ZV�����u�̉����θau<�fc�.����{�4Ա� �Q����*�Sm��8\ujqs]{kN���)qO�y�_*dJ�b�7���yQqI&9�ԌK!�M}�R�;������S�T���1���i[U�ɵz�]��U)V�S6���3$K{�ߊ<�(� E]Զ[ǼENg�����'�\?#)Dkf��J���o��v���'�%ƞ�&K�u�!��b�35LX�Ϸ��63$K�a�;�9>,R��W��3�3� d�JeTYE.Mϧ��-�o�j3+y��y^�c�������VO�9NV\nd�1 ��!͕_)a�v;����թ�M�lWR1��)El��P;��yوÏ�u 3�k�5Pr6<�⒲l�!˞*��u־�n�!�l:����UNW ��%��Chx8vL'��X�@��*��)���̮��ˍ��� ���D-M�+J�U�kvK����+�x8��cY������?�Ԡ��~3mo��|�u@[XeY�C�\Kp�x8�oC�C�&����N�~3-H���� ��MX�s�u<`���~"WL��$8ξ��3���a�)|:@�m�\���^�`�@ҷ)�5p+��6���p�%i)P M���ngc�����#0Aruz���RL+xSS?���ʮ}()#�t��mˇ!��0}}y����<�e� �-ή�Ԩ��X������ MF���ԙ~l L.3���}�V뽺�v�����멬��Nl�)�2����^�Iq��a��M��qG��T�����c3#������3U�Ǎ���}��לS�|qa��ڃ�+���-��2�f����/��bz��ڐ�� �ݼ[2�ç����k�X�2�* �Z�d���J�G����M*9W���s{��w���T��x��y,�in�O�v��]���n����P�$�JB@=4�OTI�n��e�22a\����q�d���%�$��(���:���: /*�K[PR�fr\nڙdN���F�n�$�4�[�� U�zƶ����� �mʋ���,�ao�u 3�z� �x��Kn����\[��VFmbE;�_U��&V�Gg�]L�۪&#n%�$ɯ�dG���D�TI=�%+AB�Ru#��b4�1�»x�cs�YzڙJG��f��Il��d�eF'T� iA��T���uC�$����Y��H?����[!G`}���ͪ� �纤Hv\������j�Ex�K���!���OiƸ�Yj�+u-<���'q����uN�*�r\��+�]���<�wOZ.fp�ێ��,-*)V?j-kÊ#�`�r��dV����(�ݽBk�����G�ƛk�QmUڗe��Z���f}|����8�8��a���i��3'J�����~G_�^���d�8w������ R�`(�~�.��u���l�s+g�bv���W���lGc}��u���afE~1�Ue������Z�0�8�=e�� f@/�jqEKQQ�J��oN��J���W5~M>$6�Lt�;$ʳ{���^��6�{����v6���ķܰg�V�cnn �~z�x�«�,2�u�?cE+Ș�H؎�%�Za�)���X>uW�Tz�Nyo����s���FQƤ��$��*�&�LLXL)�1�" L��eO��ɟ�9=���:t��Z���c��Ž���Y?�ӭV�wv�~,Y��r�ۗ�|�y��GaF�����C�����.�+� ���v1���fήJ�����]�S��T��B��n5sW}y�$��~z�'�c ��8 ��� ,! �p��VN�S��N�N�q��y8z˱�A��4��*��'������2n<�s���^ǧ˭P�Jޮɏ�U�G�L�J�*#��<�V��t7�8����TĜ>��i}K%,���)[��z�21z ?�N�i�n1?T�I�R#��m-�����������������1����lA�`��fT5+��ܐ�c�q՝��ʐ��,���3�f2U�եmab��#ŠdQ�y>\��)�SLY����w#��.���ʑ�f��� ,"+�w�~�N�'�c�O�3F�������N<���)j��&��,-� �љ���֊�_�zS���TǦ����w�>��?�������n��U仆�V���e�����0���$�C�d���rP �m�׈e�Xm�Vu� �L��.�bֹ��� �[Դaզ���*��\y�8�Է:�Ez\�0�Kq�C b��̘��cө���Q��=0Y��s�N��S.���3.���O�o:���#���v7�[#߫ ��5�܎�L���Er4���9n��COWlG�^��0k�%<���ZB���aB_���������'=��{i�v�l�$�uC���mƎҝ{�c㱼�y]���W�i ��ߧc��m�H� m�"�"�����;Y�ߝ�Z�Ǔ�����:S#��|}�y�,/k�Ld� TA�(�AI$+I3��;Y*���Z��}|��ӧO��d�v��..#:n��f>�>���ȶI�TX��� 8��y����"d�R�|�)0���=���n4��6ⲑ�+��r<�O�܂~zh�z����7ܓ�HH�Ga롏���nCo�>������a ���~]���R���̲c?�6(�q�;5%� |�uj�~z8R=X��I�V=�|{v�Gj\gc��q����z�؋%M�ߍ����1y��#��@f^���^�>N�����#x#۹��6�Y~�?�dfPO��{��P�4��V��u1E1J �*|���%���JN��`eWu�zk M6���q t[�� ��g�G���v��WIG��u_ft����5�j�"�Y�:T��ɐ���*�;� e5���4����q$C��2d�}���� _S�L#m�Yp��O�.�C�;��c����Hi#֩%+) �Ӎ��ƲV���SYź��g |���tj��3�8���r|���V��1#;.SQ�A[���S������#���`n�+���$��$I �P\[�@�s��(�ED�z���P��])8�G#��0B��[ى��X�II�q<��9�~[Z멜�Z�⊔IWU&A>�P~�#��dp<�?����7���c��'~���5 ��+$���lx@�M�dm��n<=e�dyX��?{�|Aef ,|n3�<~z�ƃ�uۧ�����P��Y,�ӥQ�*g�#먙R�\���;T��i,��[9Qi歉����c>]9�� ��"�c��P�� �Md?٥��If�ت�u��k��/����F��9�c*9��Ǎ:�ØF���z�n*�@|I�ށ9����N3{'��[�'ͬ�Ҳ4��#}��!�V� Fu��,�,mTIk���v C�7v���B�6k�T9��1�*l� '~��ƞF��lU��'�M ����][ΩũJ_�{�i�I�n��$���L�� j��O�dx�����kza۪��#�E��Cl����x˘�o�����V���ɞ�ljr��)�/,�߬h�L��#��^��L�ф�,íMƁe�̩�NB�L�����iL����q�}��(��q��6IçJ$�W�E$��:������=#����(�K�B����zђ <��K(�N�۫K�w��^O{!����)�H���>x�������lx�?>Պ�+�>�W���,Ly!_�D���Ō�l���Q�!�[ �S����J��1��Ɛ�Y}��b,+�Lo�x�ɓ)����=�y�oh�@�꥟/��I��ѭ=��P�y9��� �ۍYӘ�e+�p�Jnϱ?V\SO%�(�t� ���=?MR�[Ș�����d�/ ��n�l��B�7j� ��!�;ӥ�/�[-���A�>�dN�sLj ��,ɪv��=1c�.SQ�O3�U���ƀ�ܽ�E����������̻��9G�ϷD�7(�}��Ävӌ\�y�_0[w ���<΍>����a_��[0+�L��F.�޺��f�>oN�T����q;���y\��bՃ��y�jH�<|q-eɏ�_?_9+P���Hp$�����[ux�K w�Mw��N�ی'$Y2�=��q���KB��P��~������Yul:�[<����F1�2�O���5=d����]Y�sw:���Ϯ���E��j,_Q��X��z`H1,#II ��d�wr��P˂@�ZJV����y$�\y�{}��^~���[:N����ߌ�U�������O��d�����ؾe��${p>G��3c���Ė�lʌ�� ת��[��`ϱ�-W����dg�I��ig2��� ��}s ��ؤ(%#sS@���~���3�X�nRG�~\jc3�v��ӍL��M[JB�T��s3}��j�Nʖ��W����;7��ç?=X�F=-�=����q�ߚ���#���='�c��7���ڑW�I(O+=:uxq�������������e2�zi+�kuG�R��������0�&e�n���iT^J����~\jy���p'dtG��s����O��3����9* �b#Ɋ�� p������[Bws�T�>d4�ۧs���nv�n���U���_�~,�v����ƜJ1��s�� �QIz��)�(lv8M���U=�;����56��G���s#�K���MP�=��LvyGd��}�VwWBF�'�à �?MH�U�g2�� ����!�p�7Q��j��ڴ����=��j�u��� Jn�A s���uM������e��Ɔ�Ҕ�!)'��8Ϣ�ٔ��ޝ(��Vp���צ֖d=�IC�J�Ǡ{q������kԭ�߸���i��@K����u�|�p=..�*+����x�����z[Aqġ#s2a�Ɗ���RR�)*HRsi�~�a &f��M��P����-K�L@��Z��Xy�'x�{}��Zm+���:�)�) IJ�-i�u���� ���ܒH��'�L(7�y�GӜq���� j��� 6ߌg1�g�o���,kر���tY�?W,���p���e���f�OQS��!K�۟cҒA�|ս�j�>��=⬒��˧L[�� �߿2JaB~R��u�:��Q�] �0H~���]�7��Ƽ�I���(}��cq '�ήET���q�?f�ab���ӥvr� �)o��-Q��_'����ᴎo��K������;��V���o��%���~OK ����*��b�f:���-ťIR��`B�5!RB@���ï�� �u �̯e\�_U�_������� g�ES��3�������QT��a����x����U<~�c?�*�#]�MW,[8O�a�x��]�1bC|踤�P��lw5V%�)�{t�<��d��5���0i�XSU��m:��Z�┵�i�"��1�^B�-��P�hJ��&)O��*�D��c�W��vM��)����}���P��ܗ-q����\mmζZ-l@�}��a��E�6��F�@��&Sg@���ݚ�M����� ȹ 4����#p�\H����dYDo�H���"��\��..R�B�H�z_�/5˘����6��KhJR��P�mƶi�m���3�,#c�co��q�a)*Pt����R�m�k�7x�D�E�\Y�閣_X�<���~�)���c[[�BP����6�Yq���S��0����%_����;��Àv�~�| VS؇ ��'O0��F0��\���U�-�d@�����7�SJ*z��3n��y��P����O���������m�~�P�3|Y��ʉr#�C�<�G~�.,! ���bqx���h~0=��!ǫ�jy����l�O,�[B��~��|9��ٱ����Xly�#�i�B��g%�S��������tˋ���e���ې��\[d�t)��.+u�|1 ������#�~Oj����hS�%��i.�~X���I�H�m��0n���c�1uE�q��cF�RF�o���7� �O�ꮧ� ���ۛ{��ʛi5�rw?׌#Qn�TW��~?y$��m\�\o����%W� ?=>S�N@�� �Ʈ���R����N�)�r"C�:��:����� �����#��qb��Y�. �6[��2K����2u�Ǧ�HYR��Q�MV��� �G�$��Q+.>�����nNH��q�^��� ����q��mM��V��D�+�-�#*�U�̒ ���p욳��u:�������IB���m���PV@O���r[b= �� ��1U�E��_Nm�yKbN�O���U�}�the�`�|6֮P>�\2�P�V���I�D�i�P�O;�9�r�mAHG�W�S]��J*�_�G��+kP�2����Ka�Z���H�'K�x�W�MZ%�O�YD�Rc+o��?�q��Ghm��d�S�oh�\�D�|:W������UA�Qc yT�q������~^�H��/��#p�CZ���T�I�1�ӏT����4��"�ČZ�����}��`w�#�*,ʹ�� ��0�i��課�Om�*�da��^gJ݅{���l�e9uF#T�ֲ��̲�ٞC"�q���ߍ ոޑ�o#�XZTp����@ o�8��(jd��xw�]�,f���`~�|,s��^����f�1���t��|��m�򸄭/ctr��5s��7�9Q�4�H1꠲BB@l9@���C�����+�wp�xu�£Yc�9��?`@#�o�mH�s2��)�=��2�.�l����jg�9$�Y�S�%*L������R�Y������7Z���,*=�䷘$�������arm�o�ϰ���UW.|�r�uf����IGw�t����Zwo��~5 ��YյhO+=8fF�)�W�7�L9lM�̘·Y���֘YLf�큹�pRF���99.A �"wz��=E\Z���'a� 2��Ǚ�#;�'}�G���*��l��^"q��+2FQ� hj��kŦ��${���ޮ-�T�٭cf�|�3#~�RJ����t��$b�(R��(����r���dx� >U b�&9,>���%E\� Ά�e�$��'�q't��*�א���ެ�b��-|d���SB�O�O��$�R+�H�)�܎�K��1m`;�J�2�Y~9��O�g8=vqD`K[�F)k�[���1m޼c��n���]s�k�z$@��)!I �x՝"v��9=�ZA=`Ɠi �:�E��)`7��vI��}d�YI�_ �o�:ob���o ���3Q��&D&�2=�� �Ά��;>�h����y.*ⅥS������Ӭ�+q&����j|UƧ����}���J0��WW< ۋS�)jQR�j���Ư��rN)�Gű�4Ѷ(�S)Ǣ�8��i��W52���No˓� ۍ%�5brOn�L�;�n��\G����=�^U�dI���8$�&���h��'���+�(������cȁ߫k�l��S^���cƗjԌE�ꭔ��gF���Ȓ��@���}O���*;e�v�WV���YJ\�]X'5��ղ�k�F��b 6R�o՜m��i N�i����>J����?��lPm�U��}>_Z&�KK��q�r��I�D�Չ~�q�3fL�:S�e>���E���-G���{L�6p�e,8��������QI��h��a�Xa��U�A'���ʂ���s�+טIjP�-��y�8ۈZ?J$��W�P� ��R�s�]��|�l(�ԓ��sƊi��o(��S0��Y� 8�T97.�����WiL��c�~�dxc�E|�2!�X�K�Ƙਫ਼�$((�6�~|d9u+�qd�^3�89��Y�6L�.I�����?���iI�q���9�)O/뚅����O���X��X�V��ZF[�یgQ�L��K1���RҖr@v�#��X�l��F���Нy�S�8�7�kF!A��sM���^rkp�jP�DyS$N���q��nxҍ!U�f�!eh�i�2�m���`�Y�I�9r�6� �TF���C}/�y�^���Η���5d�'��9A-��J��>{�_l+�`��A���[�'��յ�ϛ#w:݅�%��X�}�&�PSt�Q�"�-��\縵�/����$Ɨh�Xb�*�y��BS����;W�ջ_mc�����vt?2}1�;qS�d�d~u:2k5�2�R�~�z+|HE!)�Ǟl��7`��0�<�,�2*���Hl-��x�^����'_TV�gZA�'j� ^�2Ϊ��N7t�����?w�� �x1��f��Iz�C-Ȗ��K�^q�;���-W�DvT�7��8�Z�������� hK�(P:��Q- �8�n�Z���܃e貾�<�1�YT<�,�����"�6{/ �?�͟��|1�:�#g��W�>$����d��J��d�B��=��jf[��%rE^��il:��B���x���Sּ�1հ��,�=��*�7 fcG��#q� �eh?��2�7�����,�!7x��6�n�LC�4x��},Geǝ�tC.��vS �F�43��zz\��;QYC,6����~;RYS/6���|2���5���v��T��i����������mlv��������&� �nRh^ejR�LG�f���? �ۉҬܦƩ��|��Ȱ����>3����!v��i�ʯ�>�v��オ�X3e���_1z�Kȗ\<������!�8���V��]��?b�k41�Re��T�q��mz��TiOʦ�Z��Xq���L������q"+���2ۨ��8}�&N7XU7Ap�d�X��~�׿��&4e�o�F��� �H����O���č�c�� 懴�6���͉��+)��v;j��ݷ�� �UV�� i��� j���Y9GdÒJ1��詞�����V?h��l����l�cGs�ځ�������y�Ac�����\V3�? �� ܙg�>qH�S,�E�W�[�㺨�uch�⍸�O�}���a��>�q�6�n6����N6�q������N ! 1AQaq�0@����"2BRb�#Pr���3C`��Scst���$4D���%Td�� ?���N����a��3��m���C���w��������xA�m�q�m���m������$����4n淿t'��C"w��zU=D�\R+w�p+Y�T�&�պ@��ƃ��3ޯ?�Aﶂ��aŘ���@-�����Q�=���9D��ռ�ѻ@��M�V��P��܅�G5�f�Y<�u=,EC)�<�Fy'�"�&�չ�X~f��l�KԆV��?�� �W�N����=(� �;���{�r����ٌ�Y���h{�١������jW����P���Tc�����X�K�r��}���w�R��%��?���E��m�� �Y�q|����\lEE4���r���}�lsI�Y������f�$�=�d�yO����p�����yBj8jU�o�/�S��?�U��*������ˍ�0������u�q�m [�?f����a�� )Q�>����6#������� ?����0UQ����,IX���(6ڵ[�DI�MNލ�c&���υ�j\��X�R|,4��� j������T�hA�e��^���d���b<����n�� �즇�=!���3�^�`j�h�ȓr��jẕ�c�,ٞX����-����a�ﶔ���#�$��]w�O��Ӫ�1y%��L�Y<�wg#�ǝ�̗`�x�xa�t�w��»1���o7o5��>�m뭛C���Uƃߜ}�C���y1Xνm�F8�jI���]����H���ۺиE@I�i;r�8ӭ����V�F�Շ| ��&?�3|x�B�MuS�Ge�=Ӕ�#BE5G�����Y!z��_e��q�р/W>|-�Ci߇�t�1ޯќd�R3�u��g�=0 5��[?�#͏��q�cf���H��{ ?u�=?�?ǯ���}Z��z���hmΔ�BFTW�����<�q�(v� ��!��z���iW]*�J�V�z��gX֧A�q�&��/w���u�gYӘa���; �i=����g:��?2�dž6�ى�k�4�>�Pxs����}������G�9��3 ���)gG�R<>r h�$��'nc�h�P��Bj��J�ҧH� -��N1���N��?��~��}-q!=��_2hc�M��l�vY%UE�@|�v����M2�.Y[|y�"Eï��K�ZF,�ɯ?,q�?v�M 80jx�"�;�9vk�����+ ֧�� �ȺU��?�%�vcV��mA�6��Qg^M����A}�3�nl� QRN�l8�kkn�'�����(��M�7m9و�q���%ޟ���*h$Zk"��$�9��: �?U8�Sl��,,|ɒ��xH(ѷ����Gn�/Q�4�P��G�%��Ա8�N��!� �&�7�;���eKM7�4��9R/%����l�c>�x;������>��C�:�����t��h?aKX�bhe�ᜋ^�$�Iհ �hr7%F$�E��Fd���t��5���+�(M6�t����Ü�UU|zW�=a�Ts�Tg������dqP�Q����b'�m���1{|Y����X�N��b �P~��F^F:����k6�"�j!�� �I�r�`��1&�-$�Bevk:y���#yw��I0��x��=D�4��tU���P�ZH��ڠ底taP��6����b>�xa����Q�#� WeF��ŮNj�p�J* mQ�N����*I�-*�ȩ�F�g�3 �5��V�ʊ�ɮ�a��5F���O@{���NX��?����H�]3��1�Ri_u��������ѕ�� ����0��� F��~��:60�p�͈�S��qX#a�5>���`�o&+�<2�D����: �������ڝ�$�nP���*)�N�|y�Ej�F�5ټ�e���ihy�Z �>���k�bH�a�v��h�-#���!�Po=@k̆IEN��@��}Ll?j�O������߭�ʞ���Q|A07x���wt!xf���I2?Z��<ץ�T���cU�j��]��陎Ltl �}5�ϓ��$�,��O�mˊ�;�@O��jE��j(�ا,��LX���LO���Ц�90�O �.����a��nA���7������j4 ��W��_ٓ���zW�jcB������y՗+EM�)d���N�g6�y1_x��p�$Lv:��9�"z��p���ʙ$��^��JԼ*�ϭ����o���=x�Lj�6�J��u82�A�H�3$�ٕ@�=Vv�]�'�qEz�;I˼��)��=��ɯ���x �/�W(V���p�����$ �m�������u�����񶤑Oqˎ�T����r��㠚x�sr�GC��byp�G��1ߠ�w e�8�$⿄����/�M{*}��W�]˷.�CK\�ުx���/$�WPw���r� |i���&�}�{�X� �>��$-��l���?-z���g����lΆ���(F���h�vS*���b���߲ڡn,|)mrH[���a�3�ר�[1��3o_�U�3�TC�$��(�=�)0�kgP���� ��u�^=��4 �WYCҸ:��vQ�ר�X�à��tk�m,�t*��^�,�}D*� �"(�I��9R����>`�`��[~Q]�#af��i6l��8���6�:,s�s�N6�j"�A4���IuQ��6E,�GnH��zS�HO�uk�5$�I�4��ؤ�Q9�@��C����wp�BGv[]�u�Ov���0I4���\��y�����Q�Ѹ��~>Z��8�T��a��q�ޣ;z��a���/��S��I:�ܫ_�|������>=Z����8:�S��U�I�J��"IY���8%b8���H��:�QO�6�;7�I�S��J��ҌAά3��>c���E+&jf$eC+�z�;��V����� �r���ʺ������my�e���aQ�f&��6�ND��.:��NT�vm�<- u���ǝ\MvZY�N�NT��-A�>jr!S��n�O 1�3�Ns�%�3D@���`������ܟ 1�^c<���� �a�ɽ�̲�Xë#�w�|y�cW�=�9I*H8�p�^(4���՗�k��arOcW�tO�\�ƍR��8����'�K���I�Q�����?5�>[�}��yU�ײ -h��=��% q�ThG�2�)���"ו3]�!kB��*p�FDl�A���,�eEi�H�f�Ps�����5�H:�Փ~�H�0Dت�D�I����h�F3�������c��2���E��9�H��5�zԑ�ʚ�i�X�=:m�xg�hd(�v����׊�9iS��O��d@0ڽ���:�p�5�h-��t�&���X�q�ӕ,��ie�|���7A�2���O%P��E��htj��Y1��w�Ѓ!����  ���� ࢽ��My�7�\�a�@�ţ�J �4�Ȼ�F�@o�̒?4�wx��)��]�P��~�����u�����5�����7X ��9��^ܩ�U;Iꭆ 5 �������eK2�7(�{|��Y׎ �V��\"���Z�1� Z�����}��(�Ǝ"�1S���_�vE30>���p;� ΝD��%x�W�?W?v����o�^V�i�d��r[��/&>�~`�9Wh��y�;���R��� ;;ɮT��?����r$�g1�K����A��C��c��K��l:�'��3 c�ﳯ*"t8�~l��)���m��+U,z��`(�>yJ�?����h>��]��v��ЍG*�{`��;y]��I�T� ;c��NU�fo¾h���/$���|NS���1�S�"�H��V���T���4��uhǜ�]�v;���5�͠x��'C\�SBpl���h}�N����� A�Bx���%��ޭ�l��/����T��w�ʽ]D�=����K���ž�r㻠l4�S�O?=�k �M:� ��c�C�a�#ha���)�ѐxc�s���gP�iG��{+���x���Q���I= �� z��ԫ+ �8"�k�ñ�j=|����c ��y��CF��/��*9ж�h{ �?4�o� ��k�m�Q�N�x��;�Y��4膚�a�w?�6�>e]�����Q�r�:����g�,i"�����ԩA�*M�<�G��b�if��l^M��5� �Ҩ�{����6J��ZJ�����P�*�����Y���ݛu�_4�9�I8�7���������,^ToR���m4�H��?�N�S�ѕw��/S��甍�@�9H�S�T��t�ƻ���ʒU��*{Xs�@����f�����֒Li�K{H�w^���������Ϥm�tq���s� ���ք��f:��o~s��g�r��ט� �S�ѱC�e]�x���a��) ���(b-$(�j>�7q�B?ӕ�F��hV25r[7 Y� }L�R��}����*sg+��x�r�2�U=�*'WS��ZDW]�WǞ�<��叓���{�$�9Ou4��y�90-�1�'*D`�c�^o?(�9��u���ݐ��'PI&� f�Jݮ�������:wS����jfP1F:X �H�9dԯ���˝[�_54 �}*;@�ܨ�� ð�yn�T���?�ןd�#���4rG�ͨ��H�1�|-#���Mr�S3��G�3�����)�.᧏3v�z֑��r����$G"�`j �1t��x0<Ɔ�Wh6�y�6��,œ�Ga��gA����y��b��)��h�D��ß�_�m��ü �gG;��e�v��ݝ�nQ� ��C����-�*��o���y�a��M��I�>�<���]obD��"�:���G�A��-\%LT�8���c�)��+y76���o�Q�#*{�(F�⽕�y����=���rW�\p���۩�c���A���^e6��K������ʐ�cVf5$�'->���ՉN"���F�"�UQ@�f��Gb~��#�&�M=��8�ט�JNu9��D��[̤�s�o�~������ G��9T�tW^g5y$b��Y'��س�Ǵ�=��U-2 #�MC�t(�i� �lj�@Q 5�̣i�*�O����s�x�K�f��}\��M{E�V�{�υ��Ƈ�����);�H����I��fe�Lȣr�2��>��W�I�Ȃ6������i��k�� �5�YOxȺ����>��Y�f5'��|��H+��98pj�n�.O�y�������jY��~��i�w'������l�;�s�2��Y��:'lg�ꥴ)o#'Sa�a�K��Z� �m��}�`169�n���"���x��I ��*+� }F<��cГ���F�P�������ֹ*�PqX�x۩��,� ��N�� �4<-����%����:��7����W���u�`����� $�?�I��&����o��o��`v�>��P��"��l���4��5'�Z�gE���8���?��[�X�7(��.Q�-��*���ތL@̲����v��.5���[��=�t\+�CNܛ��,g�SQnH����}*F�G16���&:�t��4ُ"A��̣��$�b �|����#rs��a�����T�� ]�<�j��BS�('$�ɻ� �wP;�/�n��?�ݜ��x�F��yUn�~mL*-�������Xf�wd^�a�}��f�,=t�׵i�.2/wpN�Ep8�OР���•��R�FJ� 55TZ��T �ɭ�<��]��/�0�r�@�f��V��V����Nz�G��^���7hZi����k��3�,kN�e|�vg�1{9]_i��X5y7� 8e]�U����'�-2,���e"����]ot�I��Y_��n�(JҼ��1�O ]bXc���Nu�No��pS���Q_���_�?i�~�x h5d'�(qw52] ��'ޤ�q��o1�R!���`ywy�A4u���h<קy���\[~�4�\ X�Wt/� 6�����n�F�a8��f���z �3$�t(���q��q�x��^�XWeN'p<-v�!�{�(>ӽDP7��ո0�y)�e$ٕv�Ih'Q�EA�m*�H��RI��=:��� ���4牢) �%_iN�ݧ�l]� �Nt���G��H�L��� ɱ�g<���1V�,�J~�ٹ�"K��Q�� 9�HS�9�?@��k����r�;we݁�]I�!{ �@�G�[�"��`���J:�n]�{�cA�E����V��ʆ���#��U9�6����j�#Y�m\��q�e4h�B�7��C�������d<�?J����1g:ٳ���=Y���D�p�ц� ׈ǔ��1�]26؜oS�'��9�V�FVu�P�h�9�xc�oq�X��p�o�5��Ա5$�9W�V(�[Ak�aY錎qf;�'�[�|���b�6�Ck��)��#a#a˙��8���=äh�4��2��C��4tm^ �n'c���]GQ$[Wҿ��i���vN�{Fu ��1�gx��1┷���N�m��{j-,��x�� Ūm�ЧS�[�s���Gna���䑴�� x�p 8<������97�Q���ϴ�v�aϚG��Rt�Һ׈�f^\r��WH�JU�7Z���y)�vg=����n��4�_)y��D'y�6�]�c�5̪�\� �PF�k����&�c;��cq�$~T�7j ���nç]�<�g ":�to�t}�159�<�/�8������m�b�K#g'I'.W�����6��I/��>v��\�MN��g���m�A�yQL�4u�Lj�j9��#44�t��l^�}L����n��R��!��t��±]��r��h6ٍ>�yҏ�N��fU�� ���� Fm@�8}�/u��jb9������he:A�y�ծw��GpΧh�5����l}�3p468��)U��d��c����;Us/�֔�YX�1�O2��uq�s��`hwg�r~�{ R��mhN��؎*q 42�*th��>�#���E����#��Hv�O����q�}�����6�e��\�,Wk�#���X��b>��p}�դ��3���T5��†��6��[��@�P�y*n��|'f�֧>�lư΂�̺����SU�'*�q�p�_S�����M�� '��c�6�����m�� ySʨ;M��r���Ƌ�m�Kxo,���Gm�P��A�G�:��i��w�9�}M(�^�V��$ǒ�ѽ�9���|���� �a����J�SQ�a���r�B;����}���ٻ֢�2�%U���c�#�g���N�a�ݕ�'�v�[�OY'��3L�3�;,p�]@�S��{ls��X�'���c�jw�k'a�.��}�}&�� �dP�*�bK=ɍ!����;3n�gΊU�ߴmt�'*{,=SzfD� A��ko~�G�aoq�_mi}#�m�������P�Xhύ����mxǍ�΂���巿zf��Q���c���|kc�����?���W��Y�$���_Lv����l߶��c���`?����l�j�ݲˏ!V��6����U�Ђ(A���4y)H���p�Z_�x��>���e��R��$�/�`^'3qˏ�-&Q�=?��CFVR �D�fV�9��{�8g�������n�h�(P"��6�[�D���< E�����~0<@�`�G�6����Hг�cc�� �c�K.5��D��d�B���`?�XQ��2��ٿyqo&+�1^� DW�0�ꊩ���G�#��Q�nL3��c���������/��x ��1�1[y�x�პCW��C�c�UĨ80�m�e�4.{�m��u���I=��f�����0QRls9���f���������9���~f�����Ǩ��a�"@�8���ȁ�Q����#c�ic������G��$���G���r/$W�(��W���V�"��m�7�[m�A�m����bo��D� j����۳� l���^�k�h׽����� ��#� iXn�v��eT�k�a�^Y�4�BN��ĕ��0 !01@Q"2AaPq3BR������?���@4�Q�����T3,���㺠�W�[=JK�Ϟ���2�r^7��vc�:�9 �E�ߴ�w�S#d���Ix��u��:��Hp��9E!�� V 2;73|F��9Y���*ʬ�F��D����u&���y؟��^EA��A��(ɩ���^��GV:ݜDy�`��Jr29ܾ�㝉��[���E;Fzx��YG��U�e�Y�C���� ����v-tx����I�sם�Ę�q��Eb�+P\ :>�i�C'�;�����k|z�رn�y]�#ǿb��Q��������w�����(�r|ӹs��[�D��2v-%��@;�8<a���[\o[ϧw��I!��*0�krs)�[�J9^��ʜ��p1)� "��/_>��o��<1����A�E�y^�C��`�x1'ܣn�p��s`l���fQ��):�l����b>�Me�jH^?�kl3(�z:���1ŠK&?Q�~�{�ٺ�h�y���/�[��V�|6��}�KbX����mn[-��7�5q�94�������dm���c^���h� X��5��<�eޘ>G���-�}�دB�ޟ� ��|�rt�M��V+�]�c?�-#ڛ��^ǂ}���Lkr���O��u�>�-D�ry� D?:ޞ�U��ǜ�7�V��?瓮�"�#���r��չģVR;�n���/_� ؉v�ݶe5d�b9��/O��009�G���5n�W����JpA�*�r9�>�1��.[t���s�F���nQ� V 77R�]�ɫ8����_0<՜�IF�u(v��4��F�k�3��E)��N:��yڮe��P�`�1}�$WS��J�SQ�N�j�ٺ��޵�#l���ј(�5=��5�lǏmoW�v-�1����v,W�mn��߀$x�<����v�j(����c]��@#��1������Ǔ���o'��u+����;G�#�޸��v-lη��/(`i⣍Pm^���ԯ̾9Z��F��������n��1��� ��]�[��)�'������:�֪�W��FC����� �B9،!?���]��V��A�Վ�M��b�w��G F>_DȬ0¤�#�QR�[V��kz���m�w�"��9ZG�7'[��=�Q����j8R?�zf�\a�=��O�U����*oB�A�|G���2�54 �p��.w7� �� ��&������ξxGHp� B%��$g�����t�Џ򤵍z���HN�u�Я�-�'4��0��;_��3 !01"@AQa2Pq#3BR������?��ʩca��en��^��8���<�u#��m*08r��y�N"�<�Ѳ0��@\�p��� �����Kv�D��J8�Fҽ� �f�Y��-m�ybX�NP����}�!*8t(�OqѢ��Q�wW�K��ZD��Δ^e��!� ��B�K��p~�����e*l}z#9ң�k���q#�Ft�o��S�R����-�w�!�S���Ӥß|M�l޶V��!eˈ�8Y���c�ЮM2��tk���� ������J�fS����Ö*i/2�����n]�k�\���|4yX�8��U�P.���Ы[���l��@"�t�<������5�lF���vU�����W��W��;�b�cД^6[#7@vU�xgZv��F�6��Q,K�v��� �+Ъ��n��Ǣ��Ft���8��0��c�@�!�Zq s�v�t�;#](B��-�nῃ~���3g������5�J�%���O������n�kB�ĺ�.r��+���#�N$?�q�/�s�6��p��a����a��J/��M�8��6�ܰ"�*������ɗud"\w���aT(����[��F��U՛����RT�b���n�*��6���O��SJ�.�ij<�v�MT��R\c��5l�sZB>F��<7�;EA��{��E���Ö��1U/�#��d1�a�n.1ě����0�ʾR�h��|�R��Ao�3�m3 ��%�� ���28Q� ��y��φ���H�To�7�lW>����#i`�q���c����a��� �m,B�-j����݋�'mR1Ήt�>��V��p���s�0IbI�C.���1R�ea�����]H�6����������4B>��o��](��$B���m�����a�!=��?�B� K�Ǿ+�Ծ"�n���K��*��+��[T#�{E�J�S����Q�����s�5�:�U�\wĐ�f�3����܆&�)����I���Ԇw��E T�lrTf6Q|R�h:��[K�� �z��c֧�G�C��%\��_�a�84��HcO�bi��ؖV��7H �)*ģK~Xhչ0��4?�0��� �E<���}3���#���u�?�� ��|g�S�6ꊤ�|�I#Hڛ� �ա��w�X��9��7���Ŀ%�SL��y6č��|�F�a 8���b��$�sק�h���b9RAu7�˨p�Č�_\*w��묦��F ����4D~�f����|(�"m���NK��i�S�>�$d7SlA��/�²����SL��|6N�}���S�˯���g��]6��; �#�.��<���q'Q�1|KQ$�����񛩶"�$r�b:���N8�w@��8$�� �AjfG|~�9F ���Y��ʺ��Bwؒ������M:I岎�G��`s�YV5����6��A �b:�W���G�q%l�����F��H���7�������Fsv7��k�� 403WebShell
403Webshell
Server IP : 54.89.25.11  /  Your IP : 216.73.216.121
Web Server : Apache/2.4.7 (Ubuntu)
System : Linux ip-172-31-88-18 3.13.0-74-generic #118-Ubuntu SMP Thu Dec 17 22:52:10 UTC 2015 x86_64
User : www-data ( 33)
PHP Version : 5.5.9-1ubuntu4.24
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/kalemon/public/blog/wp-content/plugins/wysija-newsletters/views/back/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/kalemon/public/blog/wp-content/plugins/wysija-newsletters/views/back/config.php
<?php
defined('WYSIJA') or die('Restricted access');

class WYSIJA_view_back_config extends WYSIJA_view_back {

	var $title = 'Settings';

	var $icon = 'icon-options-general';

	var $skip_header = true;

	function reinstall() {
		?>
		<form name="wysija-settings" method="post" id="wysija-settings" action="" class="form-valid" autocomplete="off">
			<input type="hidden" value="doreinstall" name="action" />
			<input type="hidden" value="reinstall" name="postedfrom" />
			<h3><?php _e('If you confirm this, all your current MailPoet data will be erased (newsletters, themes, statistics, lists, subscribers, etc.)', WYSIJA); ?></h3>
			<p class="submit">
				<input type="submit" value="<?php _e('Confirm Reinstallation', WYSIJA) ?>" class="button-secondary" id="submit" name="submit" />
				<?php $this->secure(array( 'action' => 'doreinstall' )); ?>
			</p>
		</form>
		<?php
	}

	function fieldFormHTML_commentform($key, $value, $model, $paramsex) {
		// second part concerning the checkbox
		$formsHelp	   = WYSIJA::get('forms', 'helper');
		$checked		 = false;
		if ($this->model->getValue($key))
			$checked		 = true;
		$checkboxDetails = array( 'id'		  => $key, 'name'		=> 'wysija['.$model.']['.$key.']', 'class'	   => 'activateInput' );
		$contentAfter = '';

		// if it's the commentform field and jetpacks is activated with its comment module then we disable the box
		if ($key == 'commentform' && WYSIJA::is_plugin_active('jetpack/jetpack.php') && in_array('comments', Jetpack::get_active_modules())) {
			$checkboxDetails['disabled'] = 'disabled';
			$contentAfter				= '<p>'.__('This feature cannot work because the "Comments" feature of the plugin JetPack is enabled.', WYSIJA).'</p>';
		}

		// if it's the register form field and registration is not allowed on the site then we just disable it
		$active_signup = false;
		if (is_multisite()) {
			$active_signup = get_site_option('registration');
			if (!$active_signup)
				$active_signup = 'all';

			$active_signup = apply_filters('wpmu_active_signup', $active_signup);
			if (in_array($active_signup, array( 'none', 'blog' )))
				$active_signup = false;
			else
				$active_signup = true;
		}
		else
			$active_signup = get_option('users_can_register');

		if ($key == 'registerform' && !$active_signup) {
			$checkboxDetails['disabled'] = 'disabled';

			$contentAfter = '<p>'.__('Registration is disabled on this site.', WYSIJA).'</p>';
		}

		$fieldHTML = '<label class="checkbox_optin_label" for="'.$key.'">';
		$fieldHTML.=$formsHelp->checkbox($checkboxDetails, 1, $checked);
		$fieldHTML.='</label>';

		$value = $this->model->getValue($key.'_linkname');

		$fieldHTML.='<div id="'.$key.'_linkname'.'" class="checkbox_optin_value">';

		if ($contentAfter) {
			$fieldHTML.='</div>';
			$fieldHTML.=$contentAfter;
		}
		else {
			$fieldHTML.=$formsHelp->input(array( 'name'	  => 'wysija['.$model.']['.$key.'_linkname]', 'size'	  => '75' ), $value);
			$model_list = WYSIJA::get('list', 'model');
			$lists	  = $model_list->get(array( 'name', 'list_id' ), array( 'is_enabled' => 1 ));
			$valuefield  = $this->model->getValue($key.'_lists');
			if (!$valuefield)
				$valuefield  = array( );
			foreach ($lists as $list) {
				if (in_array($list['list_id'], $valuefield))
					$checked = true;
				else
					$checked = false;

				$fieldHTML.= '<p class="labelcheck"><label for="list-'.$list['list_id'].'">'.$formsHelp->checkbox(array( 'id'	=> 'list-'.$list['list_id'],
							'name'  => 'wysija[config]['.$key.'_lists][]', 'class' => 'validate[minCheckbox[1]]' ), $list['list_id'], $checked).$list['name'].'</label></p>';
			}
			$fieldHTML.='</div>';
		}


		return $fieldHTML;
	}

	function fieldFormHTML_subscribers_count($key, $value, $model, $paramsex) {
		// second part concerning the checkbox
		$formsHelp = WYSIJA::get('forms', 'helper');
		$checked   = false;
		if ($this->model->getValue($key)) {
			$checked   = true;
		}
		$fieldHTML = '';
		$fieldHTML .= '<div id="'.$key.'_linkname'.'" class="checkbox_optin_value">';
		$fieldHTML .= $formsHelp->input(array( 'name'	  => 'wysija['.$model.']['.$key.'_linkname]', 'size'	  => '75', 'class'	 => 'subscribers-count-shortcode', 'readonly'  => 'readonly' ), '[wysija_subscribers_count]').'</p>';
		$model_list = WYSIJA::get('list', 'model');
		$lists	  = $model_list->get(array( 'name', 'list_id', 'is_public' ), array( 'is_enabled' => 1 ));


		foreach ($lists as $list) {
			$fieldHTML.= '<p class="labelcheck"><label for="'.$key.'list-'.$list['list_id'].'">'.$formsHelp->checkbox(array( 'id'	=> $key.'list-'.$list['list_id'],
						'name'  => 'wysija[config]['.$key.'_lists][]', 'class' => 'subscribers-count-list' ), $list['list_id']).$list['name'].'</label></p>';
		}
		$fieldHTML.='</div>';


		return $fieldHTML;
	}

	function fieldFormHTML_managesubscribe($key, $value, $model, $paramsex) {
		// second part concerning the checkbox
		$formsHelp = WYSIJA::get('forms', 'helper');
		$checked   = false;
		if ($this->model->getValue($key))
			$checked   = true;
		$fieldHTML = '<label class="checkbox_optin_label" for="'.$key.'">';
		$fieldHTML .= $formsHelp->checkbox(array( 'id'	=> $key, 'name'  => 'wysija['.$model.']['.$key.']', 'class' => 'activateInput' ), 1, $checked);
		$fieldHTML .= '</label>';
		$value  = $this->model->getValue($key.'_linkname');

		$fieldHTML .= '<div id="'.$key.'_linkname'.'" class="checkbox_optin_value">';
		$fieldHTML .= $formsHelp->input(array( 'name'	  => 'wysija['.$model.']['.$key.'_linkname]', 'size'	  => '75' ), $value);
		$fieldHTML .= '<p style="margin-bottom:0px;">'.__('Subscribers can choose from these lists :', WYSIJA).'</p>';
		$model_list = WYSIJA::get('list', 'model');
		$lists	  = $model_list->get(array( 'name', 'list_id', 'is_public' ), array( 'is_enabled' => 1 ));

		usort($lists, array( $this, 'sort_by_name' ));
		foreach ($lists as $list) {
			if ($list['is_public'])
				$checked = true;
			else
				$checked = false;

			$fieldHTML.= '<p class="labelcheck"><label for="'.$key.'list-'.$list['list_id'].'">'.$formsHelp->checkbox(array( 'id'   => $key.'list-'.$list['list_id'],
						'name' => 'wysija[config]['.$key.'_lists][]' ), $list['list_id'], $checked).$list['name'].'</label></p>';
		}
		$fieldHTML.='</div>';


		return $fieldHTML;
	}

	function fieldFormHTML_viewinbrowser($key, $value, $model, $paramsex) {
		/* second part concerning the checkbox */
		$formsHelp = WYSIJA::get('forms', 'helper');
		$checked   = false;
		if ($this->model->getValue($key))
			$checked   = true;
		$field	 = '<p><label for="'.$key.'">';
		$field.=$formsHelp->checkbox(array( 'id'	=> $key, 'name'  => 'wysija['.$model.']['.$key.']', 'class' => 'activateInput' ), 1, $checked);
		$field.='</label>';
		$value  = $this->model->getValue($key.'_linkname');

		$field.=$formsHelp->input(array( "id"   => $key.'_linkname', 'name' => 'wysija['.$model.']['.$key.'_linkname]', 'size' => '75' ), $value).'</p>';

		return $field;
	}

	function fieldFormHTML_page_selection($key, $value, $model, $paramsex) {
		$model_user	= WYSIJA::get('user', 'model');
		$action_takens = array( 'confirmation_page'  => 'subscribe', 'unsubscribe_page'   => 'unsubscribe', 'subscriptions_page' => 'subscriptions' );
		$pages			   = array( $this->model->getValue('confirm_email_link') => __('MailPoet page', WYSIJA) );
		$pages_objects							   = get_pages();


		foreach ($pages_objects as $page_object) {
			$pages[$page_object->ID] = $page_object->post_title;
		}

		$preview_edit_links = '<span id="'.$key.'-links">';
		foreach ($pages as $page_id => $page_title) {

			$preview_link = $model_user->getConfirmLink(false, $action_takens[$key], false, true, '_blank', $page_id);
			$edit_link	= get_edit_post_link($page_id);

			$preview_edit_links .= '<span id="'.$key.'-links-'.$page_id.'" class="links-page">';
			$preview_edit_links .= '<a href="'.$preview_link.'" target="_blank" title="'.__('Preview', WYSIJA).'">'.__('Preview', WYSIJA).'</a>';
			$preview_edit_links .= ' | <a href="'.$edit_link.'" target="_blank" title="'.__('Edit', WYSIJA).'">'.__('Edit', WYSIJA).'</a>';
			$preview_edit_links .= '</span>';
		}
		$preview_edit_links .= '</span>';

		$helper_forms = WYSIJA::get('forms', 'helper');
		$field		= $helper_forms->dropdown(array( 'id'	=> $key, 'class' => 'page_select', 'name'  => 'wysija['.$model.']['.$key.']' ), $pages, $this->model->getValue($key));
		$field .= $preview_edit_links;

		return $field;
	}

	function fieldFormHTML_cron($key, $value, $model) {
		//second part concerning the checkbox
		$helper_forms = WYSIJA::get('forms', 'helper');
		$checked	  = false;
		if ($this->model->getValue($key))
			$checked	  = true;

		$field = '<div><div class="cronleft"><label for="'.$key.'">';
		$field .= $helper_forms->checkbox(array( 'id'	=> $key, 'name'  => 'wysija['.$model.']['.$key.']', 'class' => 'activateInput' ), 1, $checked);
		$field .= '</label></div>';

		$url_cron = site_url('wp-cron.php').'?'.WYSIJA_CRON.'&action=wysija_cron&process=all';
		$field .= '<div class="cronright" id="'.$key.'_linkname">';

		$text_cron_manual_trigger = __('I\'ll setup a cron job on my server to execute at the frequency I want. Read about [link]setting up a cron job yourself[/link].', WYSIJA).'<br/><span>'.__('Use this URL in your cron job: [cron_url]').'</span>';
		$text_cron_manual_trigger = str_replace(array( '[link]', '[/link]', '[cron_url]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/configure-cron-job/?utm_source=wpadmin&utm_campaign=advanced_settings" title="Seting up cron job" target="_blank">', '</a>', '<a href="'.$url_cron.'" target="_blank">'.$url_cron.'</a>' ), $text_cron_manual_trigger);

		$text_cron_page_view	  = __('No thanks! I have enough visitors on my site. Their visits will trigger MailPoet\'s cron automatically.', WYSIJA);
		$values_page_view_trigger = array( 2 => $text_cron_manual_trigger, 1 => $text_cron_page_view );

		$value = 2;
		if ((int)$this->model->getValue('cron_page_hit_trigger') === 1)
			$value = 1;

		$key = 'cron_page_hit_trigger';

		$content_radios = $helper_forms->radios(array( 'id'   => $key, 'name' => 'wysija['.$model.']['.$key.']' ), $values_page_view_trigger, $value);
		add_filter('wysija_extend_cron_config', array( $this, 'add_text_cron_premium' ));
		$field .= apply_filters('wysija_extend_cron_config', $content_radios);

		$field .= '</div></div>';

		// replace the variable in the text
		$field = str_replace(array( '[link]', '[/link]', '[cron_url]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/configure-cron-job/?utm_source=wpadmin&utm_campaign=advanced_settings" title="Seting up cron job" target="_blank">', '</a>', '<a href="'.$url_cron.'" target="_blank">'.$url_cron.'</a>' ), $field);

		return $field;
	}

	// TODO remove that function which is in the premium plugin
	function add_text_cron_premium($content) {
		if (WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php') && $this->model->getValue('premium_key')) {

			$content = __('I\'m a premium user, MailPoet.com will make sure my emails get sent on time.', WYSIJA).'<br/>';
			$content .= __('If I want I can [link]create an additional cron job[/link] on my end to increase the sending frequency.', WYSIJA).'<br/><span>'.__('Use this URL in your cron job: [cron_url]').'</span>';
		}
		return $content;
	}

	function fieldFormHTML_cron_prem($key, $value, $model) {

		$url_cron = site_url('wp-cron.php').'?'.WYSIJA_CRON.'&action=wysija_cron&process=all';
		$field	= '<p>';

		$text_cron_manual_trigger = __('If I want I can [link]create an additional cron job[/link] on my end to increase the frequency.', WYSIJA).'<br/><span>'.__('Use this URL in your cron job: [cron_url]').'</span>';
		$field .= str_replace(array( '[link]', '[/link]', '[cron_url]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/configure-cron-job/?utm_source=wpadmin&utm_campaign=advanced_settings" title="Seting up cron job" target="_blank">', '</a>', '<a href="'.$url_cron.'" target="_blank">'.$url_cron.'</a>' ), $text_cron_manual_trigger);

		$field .= '</p>';

//        $model_config = WYSIJA::get('config', 'model');
//        if ($model_config->getValue('cron_manual') !== true) {
//            $model_config->save(array('cron_manual' => true));
//
//            $helper_licence = WYSIJA::get('licence', 'helper');
//            $helper_licence->check(true);
//        }

		return $field;
	}

	function fieldFormHTML_debugnew($key, $value, $model, $paramsex) {
		/* second part concerning the checkbox */
		$formsHelp = WYSIJA::get('forms', 'helper');
		$selected  = $this->model->getValue($key);
		if (!$selected)
			$selected  = 0;
		$field	 = '<p><label for="'.$key.'">';
		$options   = array( 0 => 'off', 1 => 'SQL queries', 2 => '&nbsp;+extra data', 3 => '&nbsp;&nbsp;+safe PHP errors' );
		$field.=$formsHelp->dropdown(array( 'id'   => $key, 'name' => 'wysija['.$model.']['.$key.']' ), $options, $selected);
		$field.='</label></p>';

		return $field;
	}

	function fieldFormHTML_debuglog($key, $value, $model, $paramsex) {
		/* second part concerning the checkbox */
		$formsHelp = WYSIJA::get('forms', 'helper');

		$lists = array( 'cron', 'post_notif', 'query_errors', 'queue_process', 'manual' );

		$fieldHTML = '<div id="'.$key.'_linkname'.'" class="checkbox_optin_value">';
		foreach ($lists as $list) {
			$checked = false;
			if ($this->model->getValue($key.'_'.$list))
				$checked = true;

			$fieldHTML.= '<p class="labelcheck"><label for="'.$key.'list-'.$list.'">'.$formsHelp->checkbox(array( 'id'   => $key.'list-'.$list,
						'name' => 'wysija[config]['.$key.'_'.$list.'][]' ), 1, $checked).$list.'</label></p>';
		}
		$fieldHTML.='</div>';

		return $fieldHTML;
	}

	function fieldFormHTML_dkim($key, $value, $model, $paramsex) {

		$field		= '';
		$keypublickey = $key.'_pubk';

		//there is no public key, this is the first time we load that function so we need to generate the dkim
		if (!$this->model->getValue($keypublickey)) {
			//refresh the public key private key generation
			$helpersLi = WYSIJA::get('licence', 'helper');
			$helpersLi->dkim_config();
		}

		WYSIJA::update_option('dkim_autosetup', false);
		$formsHelp = WYSIJA::get('forms', 'helper');

		$realkey = $key.'_active';
		$checked = false;
		if ($this->model->getValue($realkey))
			$checked = true;

		$field.='<p>';
		$field.=$formsHelp->checkbox(array( 'id'	=> $realkey, 'name'  => 'wysija['.$model.']['.$realkey.']', 'style' => 'margin-left:0px;', 'class' => 'activateInput' ), 1, $checked);
		$field.='</p>';

		$field.='<div id="'.$realkey.'_linkname" >';
		//$titlelink=str_replace(array('[link]','[\link]'), array('<a href="">','</a>'),'');
		$titlelink = __('Configure your DNS by adding a key/value record in TXT as shown below.', WYSIJA).' <a href="http://support.mailpoet.com/knowledgebase/guide-to-dkim-in-wysija/?utm_source=wpadmin&utm_campaign=settings" target="_blank">'.__('Read more', WYSIJA).'</a>';
		$field.='<fieldset style=" border: 1px solid #ccc;margin: 0;padding: 10px;"><legend>'.$titlelink.'</legend>';

		$field.='<label id="drlab" for="domainrecord">'.__('Key', WYSIJA).' <input readonly="readonly" id="domainrecord" style="margin-right:10px;" type="text" value="wys._domainkey"/></label><label id="drpub" for="dkimpub">'.__('Value', WYSIJA).' <input readonly="readonly" id="dkimpub" type="text" size="70" value="v=DKIM1;s=email;t=s;p='.$this->model->getValue($keypublickey).'"/></label>';

		//the DKIM key is not a 1024 bits it is therefore obsolete
		if (!$this->model->getValue('dkim_1024')) {
			$stringRegenerate = __('You\'re using an older DKIM key which is unsupported by Gmail.', WYSIJA).' '.__('You\'ll need to update your DNS if you upgrade.', WYSIJA);
			$field.='<p><strong>'.$stringRegenerate.'</strong></p>';
			$field.='<p><input type="hidden" id="dkim_regenerate" value="0" name="wysija[config][dkim_regenerate]"><a id="button-regenerate-dkim" class="button-secondary" href="javascript:;">'.__('Upgrade DKIM key', WYSIJA).'</a></p>';
		}

		$field.='</fieldset>';
		$realkey = $key.'_domain';
		$field.='<p><label class="dkim" for="'.$realkey.'">'.__('Domain', WYSIJA).'</label>';

		$field.=$formsHelp->input(array( 'id'   => $realkey, 'name' => 'wysija['.$model.']['.$realkey.']' ), $this->model->getValue($realkey));
		$field.='</p>';

		$field.='</div>';

		return $field;
	}

	function fieldFormHTML_debug($key, $value, $model, $paramsex) {
		/* second part concerning the checkbox */
		$formsHelp = WYSIJA::get('forms', 'helper');
		$checked   = false;
		if ($this->model->getValue($key))
			$checked   = true;
		$field	 = '<p><label for="'.$key.'">';
		$field.=$formsHelp->checkbox(array( 'id'   => $key, 'name' => 'wysija['.$model.']['.$key.']' ), 1, $checked);
		$field.='</label></p>';

		return $field;
	}

	function fieldFormHTML_capabilities($key, $value, $model, $paramsex) {
		/* second part concerning the checkbox */
		$formsHelp = WYSIJA::get('forms', 'helper');

		$field = '<table cellspacing="0" cellpadding="3" class="wp-list-table widefat fixed capabilities_form">
	<thead>
		<tr>
<th class="rolestitle" style="width:200px">'.__('Roles and permissions', WYSIJA).'</th>';

		$wptools		= WYSIJA::get('wp_tools', 'helper');
		$editable_roles = $wptools->wp_get_roles();


		foreach ($editable_roles as $role) {
			$field.='<th class="rolestable" >'.translate_user_role($role['name']).'</th>';
		}

		$field.='</tr></thead><tbody>';

		$alternate = true;
		$count	 = 1;
		$is_hidden = false;
		foreach ($this->model->capabilities as $keycap => $capability) {
			$classAlternate = array( );
			if ($alternate)
				$classAlternate[] = 'alternate';
			if ($count > 2) {
				$classAlternate[] = 'hidden';
				$is_hidden		= true;
			}
			$classAlternate   = implode(' ', $classAlternate);
			$classAlternate   = ' class="'.$classAlternate.'" ';
			$field.='<tr'.$classAlternate.'><td class="title"><p class="description">'.$capability['label'].'</p></td>';

			foreach ($editable_roles as $role) {
				$checked  = false;
				$keycheck = 'rolescap---'.$role['key'].'---'.$keycap;

				//if($this->model->getValue($keycheck))   $checked=true;
				$checkboxparams = array( 'id'   => $keycheck, 'name' => 'wysija['.$model.']['.$keycheck.']' );
				if (in_array($role['key'], array( 'administrator', 'super_admin' ))) {
					$checkboxparams['disabled'] = 'disabled';
				}

				$roling = get_role($role['key']);

				// add "organize_gallery" to this role object
				if ($roling->has_cap('wysija_'.$keycap)) {
					$checked = true;
				}

				$field.='<td class="rolestable" >'.$formsHelp->checkbox($checkboxparams, 1, $checked).'</td>';
			}

			$field.='</tr>';
			$alternate = !$alternate;
			$count++;
		}
		if ($is_hidden) {
			$classAlternate = '';
			if ($alternate)
				$classAlternate = ' class="alternate" ';
			$field.= '<tr'.$classAlternate.'><td colspan="'.(count($editable_roles) + 1).'"><a class="view_all" href="javascript:void(0);">'.__('View all', WYSIJA).'</a></td></tr>';
		}

		$field.='</tbody></table>';
		return $field;
	}

	function fieldFormHTML_email_notifications($key, $value, $model, $paramsex) {
		/* first part concerning the field itself */
		$params = array( );
		$params['type'] = 'default';
		$params['size'] = 38;
		$field		  = $this->fieldHTML($key, $value, $model, $params);

		/* second part concerning the checkbox */
		$threecheck = array(
			'_when_sub'		  => __('When someone subscribes', WYSIJA)
			, '_when_unsub'		=> __('When someone unsubscribes', WYSIJA),
			'_when_dailysummary' => __('Daily summary of emails sent', WYSIJA)
				//,"_when_bounce"=>__('When an email bounces',WYSIJA)
		);
		$formsHelp		   = WYSIJA::get('forms', 'helper');
		foreach ($threecheck as $keycheck => $checkobj) {
			$checked = false;
			if ($this->model->getValue($key.$keycheck))
				$checked = true;
			$field.='<p><label for="'.$key.$keycheck.'">';
			$field.=$formsHelp->checkbox(array( "id"   => $key.$keycheck, 'name' => 'wysija['.$model.']['.$key.$keycheck.']' ), 1, $checked);
			$field.=$checkobj.'</label></p>';
		}

		return $field;
	}

	function fieldFormHTML_selfsigned($key, $value, $model, $params) {

		$formsHelp = WYSIJA::get('forms', 'helper');

		$realvalue = $this->model->getValue($key);

		$value   = 0;
		$checked = false;
		if ($value == $realvalue)
			$checked = true;
		$id	  = str_replace('_', '-', $key).'-'.$value;
		$field   = '<label for="'.$id.'">';
		$field.=$formsHelp->radio(array( "id"   => $id, 'name' => 'wysija['.$model.']['.$key.']' ), $value, $checked);
		$field.=__('No', WYSIJA).'</label>';

		$value   = 1;
		$checked = false;
		if ($value == $realvalue)
			$checked = true;
		$id	  = str_replace('_', '-', $key).'-'.$value;
		$field.='<label for="'.$id.'">';
		$field.=$formsHelp->radio(array( "id"   => $id, 'name' => 'wysija['.$model.']['.$key.']' ), $value, $checked);
		$field.=__('Yes', WYSIJA).'</label>';

		return $field;
	}

	function tabs($current = null) {
		$tabs = array(
			'basics'			 => _x('Basics', 'settings tab title', WYSIJA),
			'forms'			  => _x('Forms', 'settings tab title', WYSIJA),
			'signupconfirmation' => _x('Signup Confirmation', 'settings tab title', WYSIJA),
			'sendingmethod'	  => _x('Send With...', 'settings tab title', WYSIJA),
			'advanced'		   => _x('Advanced', 'settings tab title', WYSIJA),
			'add-ons'			=> _x('Add-ons', 'settings tab title', WYSIJA),
		);

		if (!$this->_user_can('change_sending_method'))
			unset($tabs['sendingmethod']);

		$tabs = apply_filters('wysija_extend_settings', $tabs);
		echo '<div id="icon-options-general" class="icon32"><br /></div>';
		echo '<h2 id="wysija-tabs" class="nav-tab-wrapper">';

		foreach ($tabs as $tab => $name) {
			$class = ($tab === $current) ? ' nav-tab-active' : '';
			$extra = ($tab === 'premium') ? ' premium' : '';
			echo "<a class='nav-tab$class$extra' href='#$tab'>$name</a>";
		}
		echo '</h2>';
	}

	function save($data) {
		$this->main($data);
	}

	/**
	 *
	 * @param string $action
	 * @return boolean
	 */
	function _user_can($action) {
		if (empty($action))
			return false;
		$is_network_admin = WYSIJA::current_user_can('manage_network');

		//$is_network_admin=true;//PROD comment that line
		if ($is_network_admin)
			return true;

		$is_multisite = is_multisite();

		//$is_multisite=true;//PROD comment that line
		switch ($action) {
			case 'change_sending_method':
				if ((!$is_multisite || ($is_multisite && $this->model->getValue('ms_allow_admin_sending_method'))) && WYSIJA::current_user_can('switch_themes')
				) {
					return true;
				}
				return false;
				break;
			case 'toggle_signup_confirmation':
				if ((!$is_multisite || ($is_multisite && $this->model->getValue('ms_allow_admin_toggle_signup_confirmation'))) && WYSIJA::current_user_can('switch_themes')) {
					return true;
				}
				return false;
				break;
		}
	}

	function main($data) {
		$is_multisite	 = is_multisite();
		$is_network_admin = WYSIJA::current_user_can('manage_network');
		//$is_network_admin=$is_multisite=true;//PROD comment that line

		if ($is_multisite && $is_network_admin) {
			add_filter('wysija_extend_settings', array( $this, 'ms_tab_name' ), 12);
			add_filter('wysija_extend_settings_content', array( $this, 'ms_tab_content' ), 12, 2);
		}

		// check for debug
		if (isset($_REQUEST['wysija_debug'])) {
			switch ((int)$_REQUEST['wysija_debug']) {
				// turn off debug
				case 0:
					WYSIJA::update_option('debug_on', false);
					WYSIJA::update_option('debug_new', false);
					break;

				// turn on debug (with debug level as value)
				case 1:
				case 2:
				case 3:
				case 4:
				case 99:
					WYSIJA::update_option('debug_on', true);
					WYSIJA::update_option('debug_new', (int)$_REQUEST['wysija_debug']);
					break;
			}
		}

		echo $this->messages();
		?>
		<div id="wysija-config">
			<?php $this->tabs(); ?>
			<form name="wysija-settings" method="post" id="wysija-settings" action="" class="form-valid" autocomplete="off">
				<div id="basics" class="wysija-panel hidden">
					<?php $this->basics(); ?>
					<p class="submit">
						<input type="submit" value="<?php echo esc_attr(__('Save settings', WYSIJA)); ?>" class="button-primary wysija" />
					</p>
				</div>
				<div id="forms" class="wysija-panel hidden">
					<?php /* if(WYSIJA::is_wysija_admin()) */ $this->form_list(); ?>
				</div>

				<div id="signupconfirmation" class="wysija-panel hidden">
					<?php $this->signupconfirmation(); ?>
					<p class="submit">
						<input type="submit" value="<?php echo esc_attr(__('Save settings', WYSIJA)); ?>" class="button-primary wysija" />
					</p>
				</div>
				<?php
				if ($this->_user_can('change_sending_method')) {
					?>
					<div id="sendingmethod" class="wysija-panel hidden">
						<?php $this->sendingmethod(); ?>
						<p class="submit">
							<input type="submit" value="<?php echo esc_attr(__('Save settings', WYSIJA)); ?>" class="button-primary wysija" />
						</p>
					</div>
					<?php
				}
				?>


				<div id="advanced" class="wysija-panel hidden">
					<?php $this->advanced($data); ?>
					<p class="submit">
						<input type="submit" value="<?php echo esc_attr(__('Save settings', WYSIJA)); ?>" class="button-primary wysija" />
					</p>
				</div>

				<div id="add-ons" class="wysija-panel hidden">
					<?php $this->add_ons(); ?>
				</div>

				<?php
				echo apply_filters('wysija_extend_settings_content', '', array( 'viewObj' => &$this ));
				?>

				<?php $this->secure(array( 'action' => "save" )); ?>
				<input type="hidden" value="save" name="action" />
				<input type="hidden" value="" name="redirecttab" id="redirecttab" />
			</form>
		</div>
		<?php
	}

	function basics() {
		$step = array( );

		$step['company_address'] = array(
			'type'  => 'textarea',
			'label' => __("Your company's address", WYSIJA),
			'desc'  => __("The address will be added to your newsletter's footer. This helps avoid spam filters.", WYSIJA),
			'rows'  => "3",
			'cols'  => "40", );

		$step['emails_notified'] = array(
			'type'  => 'email_notifications',
			'label' => __('Email notifications', WYSIJA),
			'desc'  => __('Enter the email addresses that should receive notifications (separate by comma).', WYSIJA) );

		$step['from_name'] = array(
			'type'  => 'fromname',
			'class' => 'validate[required]',
			'label' => __('Sender of notifications', WYSIJA),
			'desc'  => __('Choose a FROM name and email address for notifications emails.', WYSIJA) );

		$step['commentform'] = array(
			'type'  => 'commentform',
			'label' => __('Subscribe in comments', WYSIJA),
			'desc'  => __('Visitors who submit a comment on a post can click on a checkbox to subscribe.', WYSIJA),
		);

		$showregisteroption = true;
		//this option is only available for the main site
		if (is_multisite()) {
                    $mpoet_allow_register_option_on_all_sites = false;
                    $mpoet_allow_register_option_on_all_sites = apply_filters( 'mpoet_allow_register_option_on_all_sites', $mpoet_allow_register_option_on_all_sites );
                    if( $mpoet_allow_register_option_on_all_sites === false && !is_main_site() ){
                        $showregisteroption = false;
                    }
		}

		if ($showregisteroption) {
			$step ['registerform'] = array(
				'type'  => 'commentform',
				'label' => __('Subscribe in registration form', WYSIJA),
				'desc'  => __('Allow users who register to your site to subscribe on a list of your choice.', WYSIJA)
			);
		}

		$modelU				= WYSIJA::get('user', 'model');
		$objUser			   = $modelU->getCurrentSubscriber();
		$step['viewinbrowser'] = array(
			'type'  => 'viewinbrowser',
			'label' => __('Link to browser version', WYSIJA),
			'desc'  => __('Displays at the top of your newsletters. Don\'t forget to include the link tag, ie: [link]The link[/link]', WYSIJA),
		);

		$step['unsubscribe_linkname'] = array(
			'type'  => 'input',
			'label' => __('Text of "Unsubscribe" link', WYSIJA),
			'desc'  => __('This changes the label for the unsubscribe link in the footer of your newsletters.', WYSIJA) );

		$step['unsubscribe_page'] = array(
			'type'  => 'page_selection',
			'label' => __('Unsubscribe page', WYSIJA),
			'desc'  => __('A subscriber is directed to a page of your choice after clicking on the unsubscribe link, at the bottom of a newsletter.', WYSIJA),
		);

		$model_config = WYSIJA::get('config', 'model');
		?>
		<table class="form-table">
			<tbody>
				<?php
				do_action('mailpoet_pre_config_screen');
				echo $this->buildMyForm($step, $model_config->values, 'config');
				?>
			</tbody>
		</table>
		<?php
	}

	function signupconfirmation() {
		$step = array( );

		$step['confirm_dbleoptin'] = array(
			'type'   => 'radio',
			'values' => array( true	=> __('Yes', WYSIJA), false   => __('No', WYSIJA) ),
			'label' => __('Enable signup confirmation', WYSIJA),
			'desc'  => __('Prevent people from being subscribed to your list unwillingly, this option ensures you to keep a clean list.', WYSIJA).' <a href="http://support.mailpoet.com/knowledgebase/why-you-should-enforce-email-activation/?utm_source=wpadmin&utm_campaign=activation email" target="_blank">'.__('Learn more.', WYSIJA).'</a>' );

		if (!$this->_user_can('toggle_signup_confirmation')) {
			$step['confirm_dbleoptin']['type'] = 'disabled_radio';
		}

		$step['confirm_email_title'] = array(
			'type'	 => 'input',
			'label'	=> __('Email subject', WYSIJA),
			'rowclass' => 'confirmemail' );

		$step['confirm_email_body'] = array(
			'type'	 => 'textarea',
			'label'	=> __('Email content', WYSIJA),
			'desc'	 => __('Don\'t forget to include: <br><br>[activation_link]Confirm your subscription.[/activation_link]. <br><br>Optional: [lists_to_confirm].', WYSIJA),
			'rowclass' => 'confirmemail' );

		$step['confirmation_page'] = array(
			'type'	 => 'page_selection',
			'label'	=> __('Confirmation page', WYSIJA),
			'desc'	 => __('When subscribers click on the activation link, they are redirected to a page of your choice.', WYSIJA),
			'rowclass' => 'confirmemail' );
		?>

		<table class="form-table">
			<tbody>
				<?php
				echo $this->buildMyForm($step, '', 'config');
				?>
			</tbody>
		</table>
		<?php
	}

	function sendingmethod() {
		$key	   = 'sending_method';
		$realvalue = $this->model->getValue($key);
		// Since 2.6.12, remove gmail and use stmp instead
		if ($realvalue == 'gmail')
			$realvalue = 'smtp';

		$helper_forms = WYSIJA::get('forms', 'helper');
		$current_user = WYSIJA::wp_get_userdata();
		?>
		<table class="form-table" id="ms-sendingmethod">
			<tbody>
				<tr class="methods">
					<?php
					$is_multisite = is_multisite();

					if (is_multisite()) {
						$field   = '<th scope="row">';
						$checked = false;
						$value   = 'network';
						$id	  = str_replace('_', '-', $key).'-'.$value;
						if ($value == $realvalue) {
							$checked = true;
						}
						$field .= '<label for="'.$id.'" class="clearfix">';
						$field .= $helper_forms->radio(
								array(
							'id'	=> $id,
							'class' => 'mailpoet-delivery-method',
							'name'  => 'wysija[config]['.$key.']',
								), $value, $checked
						);
						$field .= '<h3>'.__('Network\'s Method', WYSIJA).'</h3></label>';
						$field .= '<p>'.__('Method set by the network admin.', WYSIJA).'</p>';
						if (!$this->model->getValue('ms_sending_emails_ok')) {
							$field .= '<strong'.__('Not Configured!', WYSIJA).'</strong>';
						}
						$field .= '</th>';
						echo $field;
					}
					?>

					<th scope="row">
						<?php
						$checked = false;
						$value   = 'site';
						$id	  = str_replace('_', '-', $key).'-'.$value;
						if ($value == $realvalue)
							$checked = true;
						$field   = '<label for="'.$id.'" class="clearfix">';
						$field.=$helper_forms->radio(array( "id"	 => $id, 'class'  => 'mailpoet-delivery-method', 'name'   => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.='<h3>'.__('Your own website', WYSIJA).'</h3></label>';
						$field.='<p>'.__('The simplest solution for small lists. Your web host sets a daily email limit.', WYSIJA).'</p>';
						echo $field;
						?>
					</th>
					<th scope="row">
						<?php
						$checked = false;
						$value   = 'smtp';
						if ($value === $realvalue)
							$checked = true;

						$id	= str_replace('_', '-', $key).'-'.$value;
						$field = '<label for="'.$id.'" class="clearfix">';
						$field.= $helper_forms->radio(array( 'id'	   => $id, 'class'	=> 'mailpoet-delivery-method', 'name'	 => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.= '<h3>'.__('Third party', WYSIJA).'</h3></label>';
						$field.='<p>'.__('Send with a professional SMTP provider, a great choice for big and small lists. We\'ve negotiated promotional offers with a few providers for you.', WYSIJA).' <a href="http://support.mailpoet.com/knowledgebase/send-with-smtp-when-using-a-professional-sending-provider/?utm_source=wpadmin&utm_campaign=sending method" target="_blank">'.__('Read more', WYSIJA).'</a>.</p>';
						echo $field;
						?>
					</th>
				</tr>

				<tr class="hidechoice choice-sending-method-site">
					<th scope="row">
						<?php
						$field	 = __('Delivery method', WYSIJA);
						$field.='<p class="description">'.__('Send yourself some test emails to confirm which method works with your server.', WYSIJA).'</p>';
						echo $field;
						?>
					</th>
					<td colspan="2">
						<?php
						$key	   = "sending_emails_site_method";
						$checked   = false;
						$realvalue = $this->model->getValue($key);
						$value	 = "phpmail";
						if ($value == $realvalue)
							$checked   = true;

						$id	= str_replace("_", '-', $key).'-'.$value;
						$field = '<p class="title"><label for="'.$id.'">';
						$field.=$helper_forms->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.='PHP Mail</label></p>';
						$field.='<p class="description">'.__('This email engine works on 95&#37; of servers', WYSIJA).'</p>';


						$value   = "sendmail";
						$checked = false;
						if ($value == $realvalue)
							$checked = true;

						$id = str_replace("_", '-', $key).'-'.$value;
						$field.='<p class="title"><label for="'.$id.'">';
						$field.=$helper_forms->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.='Sendmail</label>';
						$field.='<p class="description">'.__('This method works on 5&#37; of servers', WYSIJA).'</p>';

						$id = str_replace("_", '-', $key).'-'.$value."-path";
						$field.='<p class="title" id="p-'.$id.'"><label for="'.$id.'">';
						$field.=__("Sendmail path", WYSIJA).'</label>'.$helper_forms->input(array( "id"   => $id, 'name' => 'wysija[config][sendmail_path]' ), $this->model->getValue("sendmail_path")).'</p>';


						if ($this->model->getValue('allow_wpmail')) {
							$checked = false;
							$value   = 'wpmail';
							if ($value == $realvalue)
								$checked = true;

							$id = str_replace('_', '-', $key).'-'.$value;
							$field.='<p class="title"><label for="'.$id.'">';
							$field.=$helper_forms->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
							$field.='WP Mail</label></p>';
							$field.='<p class="description">'.__('Use the same method as the one used for your WP site.', WYSIJA).'</p>';
						}


						echo $field;
						?>
					</td>
				</tr>

				<tr class="hidechoice choice-sending-method-smtp">
					<th scope="row">
						<?php
						$key   = "smtp_host";
						$id	= str_replace("_", '-', $key);
						$field = '<label for="'.$id.'">'.__('SMTP Hostname', WYSIJA)."</label>";
						$field.='<p class="description">'.__('e.g.:smtp.mydomain.com', WYSIJA).'</p>';
						echo $field;
						?>
					</th>
					<td>
						<?php
						$value = $this->model->getValue($key);
						$field = $helper_forms->input(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '40' ), $value, $checked);
						echo $field;
						?>
					</td>
				</tr>
				<tr class="hidechoice choice-sending-method-smtp choice-sending-method-gmail">
					<th scope="row">
						<?php
						$key   = "smtp_login";
						$id	= str_replace("_", '-', $key);
						$field = '<label for="'.$id.'">'.__('Login', WYSIJA)."</label>";
						echo $field;
						?>
					</th>
					<td colspan="2">
						<?php
						$value = $this->model->getValue($key);
						$field = $helper_forms->input(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '40' ), $value, $checked);
						echo $field;
						?>
					</td>
				</tr>
				<tr class="hidechoice choice-sending-method-smtp choice-sending-method-gmail">
					<th scope="row">
						<?php
						$key   = "smtp_password";
						$id	= str_replace("_", '-', $key);
						$field = '<label for="'.$id.'">'.__('Password', WYSIJA)."</label>";
						echo $field;
						?>
					</th>
					<td colspan="2">
						<?php
						$value = $this->model->getValue($key);
						$field = $helper_forms->input(array( "type"   => "password", "id"	 => $id, 'name'   => 'wysija[config]['.$key.']', 'size'   => '40' ), $value, $checked);
						echo $field;
						?>
					</td>
				</tr>
				<tr id="restapipossible" class="hidechoice">
					<th scope="row">
						<?php
						$key	 = 'smtp_rest';
						$id	  = str_replace('_', '-', $key);
						$field   = '<label for="'.$id.'">web API</label>';
						$field.='<p class="description">'.__('Activate if your SMTP ports are blocked.', WYSIJA).'</p>';
						echo $field;
						?>
					</th>
					<td>
						<?php
						$value   = $this->model->getValue($key);
						$checked = false;
						if ($this->model->getValue('smtp_rest'))
							$checked = true;
						$field   = $helper_forms->checkbox(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '3' ), 1, $checked);

						echo $field;
						?>
					</td>
				</tr>

				<tr class="hidechoice choice-sending-method-smtp choice-no-restapi">
					<th scope="row">
						<?php
						$key   = 'smtp_port';
						$id	= str_replace('_', '-', $key);
						$field = '<label for="'.$id.'">'.__('SMTP port', WYSIJA)."</label>";

						echo $field;
						?>
					</th>
					<td>
						<?php
						$value = $this->model->getValue($key);
						$field = $helper_forms->input(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '3' ), $value, $checked);

						echo $field;
						?>
					</td>
				</tr>

				<tr class="hidechoice choice-sending-method-smtp choice-no-restapi">
					<th scope="row">
						<?php
						$key   = "smtp_secure";
						$id	= str_replace("_", '-', $key);
						$field = '<label for="'.$id.'">'.__('Secure connection', WYSIJA)."</label>";
						echo $field;
						?>
					</th>
					<td colspan="2">
						<?php
						$value = $this->model->getValue($key);

						$field = $helper_forms->dropdown(array( 'name' => 'wysija[config]['.$key.']', "id"   => $id ), array( false	  => __("No"), "ssl"	  => "SSL", "tls"	  => "TLS" ), $value);
						echo $field;
						?>
					</td>
				</tr>

				<tr class="hidechoice choice-sending-method-smtp choice-no-restapi">
					<th scope="row">
						<?php
						$field	 = __('Authentication', WYSIJA);
						echo $field.'<p class="description">'.__("Leave this option to Yes. Only a tiny portion of SMTP services ask Authentication to be turned off.", WYSIJA).'</p>';
						?>
					</th>
					<td colspan="2">
						<?php
						$key	   = 'smtp_auth';
						$realvalue = $this->model->getValue($key);

						$value   = false;
						$checked = false;
						if ($value == $realvalue)
							$checked = true;
						$id	  = str_replace('_', '-', $key).'-'.$value;
						$field   = '<label for="'.$id.'">';
						$field.=$helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.=__('No', WYSIJA).'</label>';

						$value   = true;
						$checked = false;
						if ($value == $realvalue)
							$checked = true;
						$id	  = str_replace('_', '-', $key).'-'.$value;
						$field.='<label for="'.$id.'">';
						$field.=$helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.=__('Yes', WYSIJA).'</label>';


						$value   = false;
						$checked = false;
						if ($value == $realvalue)
							$checked = true;
						$id	  = str_replace('_', '-', $key).'-'.$value;
						$field   = '<label for="'.$id.'">';
						$field.=$helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.=__('No', WYSIJA).'</label>';

						$value   = true;
						$checked = false;
						if ($value == $realvalue)
							$checked = true;
						$id	  = str_replace('_', '-', $key).'-'.$value;
						$field.='<label for="'.$id.'">';
						$field.=$helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
						$field.=__('Yes', WYSIJA).'</label>';


						echo $field;
						?>
					</td>
				</tr>

				<tr class="hidechoice choice-sending-method-smtp choice-sending-method-site choice-sending-method-gmail choice-sending-method-network">
					<th scope="row">
						<?php _e('Test method'); ?>
					</th>
					<td colspan="<?php echo ( is_multisite() ? 3 : 2 ); ?>">
						<input type="text" value="<?php echo esc_attr($current_user->data->user_email); ?>" class="mailpoet-test-emails" name="wysija[config][test_mails]" />
						<a class="button-secondary mailpoet-test-delivery"><?php _e('Send a test mail', WYSIJA); ?></a>
					</td>
				</tr>

				<tr class="hidechoice choice-sending-method-smtp choice-sending-method-site choice-sending-method-gmail">
					<th scope="row">
						<?php
						$field = __('Send...', WYSIJA);

						echo $field.'<p class="description">'.str_replace(array( '[link]', '[/link]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/wp-cron-batch-emails-sending-frequency/?utm_source=wpadmin&utm_campaign=choosing%20frequency" target="_blank">', '</a>' ), __('Your web host has limits. We suggest 70 emails per hour to be safe. [link]Find out more[/link].', WYSIJA)).'</p>';
						?>
					</th>
					<td colspan="<?php echo ( is_multisite() ? 3 : 2 ); ?>">

						<?php
						$name   = 'sending_emails_number';
						$id	 = str_replace('_', '-', $name);
						$value  = $this->model->getValue($name);
						$params = array( "id"   => $id, 'name' => 'wysija[config]['.$name.']', 'size' => '6' );
						//if($this->model->getValue("smtp_host")=="smtp.gmail.com") $params["readonly"]="readonly";
						$field = $helper_forms->input($params, $value);
						$field.= '<span class="mailpoet-frequency_inner_texting">'.__('emails', WYSIJA).'</span>';


						$name  = 'sending_emails_each';
						$id	= str_replace('_', '-', $name);
						$value = $this->model->getValue($name);
						$field .=$helper_forms->dropdown(array( 'name' => 'wysija[config]['.$name.']', 'id'   => $id ), $helper_forms->eachValues, $value);
						echo $field;
						echo '<div class="mailpoet-frequency_warning hidden"><b>'.__('This is fast!', WYSIJA).'</b> '.str_replace(array( '[link]', '[/link]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/wp-cron-batch-emails-sending-frequency/?utm_source=wpadmin&utm_campaign=cron" target="_blank">', '</a>' ), __('We suggest you setup a cron job. [link]Read more[/link] on support.mailpoet.com', WYSIJA)).'</span>';
						?>
					</td>
				</tr>

			</tbody>
		</table>
		<script>
		  wysija_translations = {};
		  wysija_translations.api = "<?php _e('API Key', WYSIJA); ?>";
		  wysija_translations.password = "<?php _e('Password', WYSIJA); ?>";
		</script>
		<?php
	}

	function clearlog() {

		echo '<h3>Logs have been cleared</h3>';
	}

	function log() {
		$option_log = get_option('wysija_log');

		foreach ($option_log as $key => $data) {
			echo '<h3>'.$key.'</h3>';
			dbg($data, 0);
		}
	}

	function advanced($data) {

		$advanced_fields	   = $super_advanced_fields = array( );
		$advanced_fields ['role_campaign'] = array(
			'type' => 'capabilities',
			'1col' => 1 );

		$advanced_fields['replyto_name'] = array(
			'type'  => 'fromname',
			'class' => 'validate[required]',
			'label' => __('Reply-to name & email', WYSIJA),
			'desc'  => __('You can change the default reply-to name and email for your newsletters. This option is also used for the activation emails and Admin notifications (in Basics).', WYSIJA) );

		$helper_licence				   = WYSIJA::get('licence', 'helper');
		$url_checkout					 = $helper_licence->get_url_checkout('bounce_address_automated');
		$advanced_fields ['bounce_email'] = array(
			'type'  => 'input',
			'label' => __('Bounce Email', WYSIJA),
			'desc'  => __('To which address should all the bounced emails go? Get the [link]Premium version[/link] to automatically handle these.', WYSIJA),
			'link'  => '<a href="'.$url_checkout.'" target="_blank" title="'.__('Purchase the premium version.', WYSIJA).'">' );

		$advanced_fields = apply_filters('wysija_settings_advanced', $advanced_fields);

		$modelU = WYSIJA::get('user', 'model');

		$advanced_fields ['manage_subscriptions'] = array(
			'type'  => 'managesubscribe',
			'label' => __('Subscribers can edit their profile', WYSIJA),
			'desc'  => __('Add a link in the footer of all your newsletters so subscribers can edit their profile and lists. [link]See your own subscriber profile page.[/link]', WYSIJA),
			'link'  => '<a href="'.$modelU->getConfirmLink(false, 'subscriptions', false, true).'" target="_blank" title="'.__('Preview page', WYSIJA).'">', );

		$advanced_fields['subscriptions_page'] = array(
			'type'	 => 'page_selection',
			'label'	=> __('Subscriber profile page', WYSIJA),
			'desc'	 => __('Select the page to display the subscriber\'s profile.', WYSIJA),
			'rowclass' => 'manage_subscriptions',
		);

		$advanced_fields ['html_source'] = array(
			'label'  => __('Allow HTML edits', WYSIJA),
			'type'   => 'radio',
			'values' => array( true   => __('Yes', WYSIJA), false  => __('No', WYSIJA) ),
			'desc' => __('This allows you to modify the HTML of text blocks in the visual editor.', WYSIJA)
		);

		$advanced_fields ['analytics'] = array(
			'rowclass' => 'analytics',
			'type'	 => 'radio',
			'values'   => array( true	=> __('Yes', WYSIJA), false   => __('No', WYSIJA) ),
			'label' => __('Share anonymous data', WYSIJA),
			'desc'  => __('Share anonymous data and help us improve the plugin. [link]Read more[/link].', WYSIJA),
			'link'  => '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=advanced_settings">'
		);

		$advanced_fields ['industry'] = array(
			'rowclass' => 'industry',
			'type'	 => 'dropdown_keyval',
			'values'   => array(
				'other'			   => __('other', WYSIJA),
				'art'				 => __('art', WYSIJA),
				'business'			=> __('business', WYSIJA),
				'education'		   => __('education', WYSIJA),
				'e-commerce'		  => __('e-commerce', WYSIJA),
				'food'				=> __('food', WYSIJA),
				'insurance'		   => __('insurance', WYSIJA),
				'government'		  => __('government', WYSIJA),
				'health and sports'   => __('health and sports', WYSIJA),
				'manufacturing'	   => __('manufacturing', WYSIJA),
				'marketing and media' => __('marketing and media', WYSIJA),
				'non profit'		  => __('non profit', WYSIJA),
				'photography'		 => __('photography', WYSIJA),
				'travel'			  => __('travel', WYSIJA),
				'real estate'		 => __('real estate', WYSIJA),
				'religious'		   => __('religious', WYSIJA),
				'technology'		  => __('technology', WYSIJA)
			),
			'label'			   => __('Industry', WYSIJA),
			'desc'				=> __('Select your industry.', WYSIJA) );

		$advanced_fields ['recaptcha'] = array(
			'type'	 => 'radio',
			'values'   => array( true	=> __('Yes', WYSIJA), false   => __('No', WYSIJA) ),
			'label' => __('Enable reCAPTCHA', WYSIJA),
			'desc'  => __('Use reCAPTCHA to protect MailPoet subscription forms. [link]Sign up for an API key pair here[/link].', WYSIJA),
      'link' => '<a target="_blank" href="https://www.google.com/recaptcha/admin">'
		);

		$advanced_fields ['recaptcha_key'] = array(
			'rowclass' => 'recaptcha',
			'type'  => 'input',
			'label' => __('reCAPTCHA site key', WYSIJA),
			'desc' => __('Used in the HTML code your site serves to users.', WYSIJA) );

		$advanced_fields ['recaptcha_secret'] = array(
			'rowclass' => 'recaptcha',
			'type'  => 'input',
			'label' => __('reCAPTCHA secret key', WYSIJA),
			'desc' => __('Used for communication between your site and Google. Be sure to keep it a secret.', WYSIJA) );

		$super_advanced_fields ['subscribers_count'] = array(
			'type'  => 'subscribers_count',
			'label' => __('Shortcode to display total number of subscribers', WYSIJA),
			'desc'  => __('Paste this shortcode to display the number of confirmed subscribers in post or page.', WYSIJA)
		);



		$super_advanced_fields ['advanced_charset'] = array(
			'type'   => 'dropdown_keyval',
			'values' => array( 'UTF-8', 'UTF-7', 'BIG5', 'ISO-2022-JP',
				'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3',
				'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6',
				'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9',
				'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14',
				'ISO-8859-15', 'Windows-1251', 'Windows-1252' ),
			'label' => __('Charset', WYSIJA),
			'desc'  => __('Squares or weird characters are displayed in your emails? Select the encoding for your language.', WYSIJA) );

		$super_advanced_fields = apply_filters('wysija_settings_advancednext', $super_advanced_fields);

		$super_advanced_fields ['cron_manual'] = array(
			'type'  => 'cron',
			'label' => __('Enable MailPoet\'s Cron', WYSIJA),
			'desc'  => __('None of your queued emails have been sent? Then activate this option.', WYSIJA) );


		$super_advanced_fields ['debug_new'] = array(
			'type'  => 'debugnew',
			'label' => __('Debug mode', WYSIJA),
			'desc'  => __('Enable this to show MailPoet\'s errors. Our support might ask you to enable this if you seek their help.', WYSIJA) );

		if (WYSIJA_DBG > 1) {
			$advanced_fields ['debug_log'] = array(
				'type'  => 'debuglog',
				'label' => 'Logs',
				'desc'  => str_replace(array( '[link]', '[linkclear]', '[/link]', '[/linkclear]' ), array( '<a href="admin.php?page=wysija_config&action=log" target="_blank">', '<a target="_blank" href="admin.php?page=wysija_config&action=clearlog&_wpnonce='.$this->secure(array( 'action' => 'clearlog' ), true).'">', '</a>', '</a>' ), 'View them [link]here[/link]. Clear them [linkclear]here[/linkclear]') );
		}

		//attach 'super-advanced' class to super_advanced_fields
		$super_advanced_field_class = 'super-advanced';
		foreach ($super_advanced_fields as $key => $field) {
			if (!empty($super_advanced_fields[$key]['rowclass']))
				$super_advanced_fields[$key]['rowclass'] = $super_advanced_fields[$key]['rowclass'].' '.$super_advanced_field_class;
			else
				$super_advanced_fields[$key]['rowclass'] = $super_advanced_field_class;
		}
		?>
		<table class="form-table">
			<tbody>
				<?php echo $this->buildMyForm($advanced_fields, '', 'config'); ?>
				<tr class='title_row'>
					<td colspan="2">
						<h3 class='title' alt='<?php esc_attr_e('Do or do not. There is no try.', WYSIJA); ?>'>
							<?php _e("Geeky Options", WYSIJA); ?>
							<a href='#geeky_options' alt='<?php esc_attr_e("Toggle Geeky Options", WYSIJA); ?>' data-hide='<?php esc_attr_e("Hide", WYSIJA); ?>' class='add-new-h2 mailpoet-geeky-toggle is_toggled'><?php esc_attr_e("Show", WYSIJA); ?></a>
						</h3>
					</td>
				</tr>
				<?php if (!empty($data['hooks']['hook_settings_super_advanced'])) echo $data['hooks']['hook_settings_super_advanced']; ?>
				<?php echo $this->buildMyForm($super_advanced_fields, '', 'config'); ?>
				<?php if (current_user_can('delete_plugins')): ?>
					<tr class="<?php echo $super_advanced_field_class ?>">
						<th scope="row">
				<div class="label"><?php _e('Reinstall from scratch', WYSIJA) ?>
					<p class="description"><?php _e('Want to start all over again? This will wipe out MailPoet and reinstall anew.', WYSIJA) ?></p>
				</div>
			</th>
			<td>
				<p>
					<a class="button" href="admin.php?page=wysija_config&action=reinstall"><?php _e('Reinstall now...', WYSIJA); ?></a>
				</p>
			</td>
			</tr>
		<?php endif ?>
		</tbody>
		</table>
		<?php
	}

	/**
	 * Add-ons Manager developed by Sebs Studio
	 */
	function add_ons() {
		include_once(WYSIJA_DIR.'/add-ons/add-ons.php');
	}

	/**
	 * filter adding its own tab to wysija's config(this deals with the name of the tab)
	 * @param string $tabs
	 * @return string
	 */
	function ms_tab_name($tabs) {
		$tabs['multisite'] = 'MS';
		return $tabs;
	}

	/**
	 * filter adding its own tab to wysija's config (this deals with the content of the tab)
	 * @param type $htmlContent
	 * @param type $arg
	 * @return string
	 */
	function ms_tab_content($htmlContent, $arg) {
		$this->viewObj = $arg['viewObj'];
		$mConfig   = WYSIJA::get('config', 'model');
		$formsHelp = WYSIJA::get('forms', 'helper');

		$htmlContent .='<div id="multisite" class="wysija-panel hidden">'; //start multisite div
		$htmlContent.= '<div class="intro"><h3>'.__('Pick your prefered configuration?', WYSIJA).'</h3></div>';

		$htmlContent.= '<table class="form-table" id="form-ms-config">
			<tbody>
				<tr class="methods">
					<th scope="row">';

		$checked   = false;
		$key	   = 'ms_sending_config';
		$realvalue = $mConfig->getValue($key);
		$value	 = 'one-for-all';
		$id		= str_replace('_', '-', $key).'-'.$value;
		if ($value == $realvalue)
			$checked   = true;
		$field	 = '<label for="'.$id.'" class="clearfix">';
		$field.=$formsHelp->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.='<p class="title"><strong>'.__('One configuration for all sites', WYSIJA).'</strong></p></label>';
		$field.='<p>'.__('Enforce all sites to send with a unique FROM email address. You only need to configure the Automated Bounce Handling (Premium), SPF & DKIM only once.', WYSIJA).'</p>';
		$field.='<p>'.__('Users can still change their reply-to address for their newsletter. Network admins can still edit sending method for each site.', WYSIJA).'</p>';
		$htmlContent.= $field;

		$htmlContent.= '</th><th scope="row">';

		$checked = false;
		$value   = 'one-each';
		$id	  = str_replace('_', '-', $key).'-'.$value;
		if ($value == $realvalue)
			$checked = true;
		$field   = '<label for="'.$id.'" class="clearfix">';
		$field.=$formsHelp->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.='<p class="title"><strong>'.__('Configure each site manually', WYSIJA).'</strong></p></label>';
		$field.='<p>'.__('Configure SPF and DKIM independently for each site.', WYSIJA).'</p>';
		$htmlContent.= $field;

		$htmlContent.= '</th><td>
					</td>
				</tr>';

		$htmlContent.='</tbody></table>';

		$htmlContent.='<div class="intro"><h3>'.__('Configuration and Permissions', WYSIJA).'</h3></div>';

		$fields = array( );


		$fields['ms_allow_admin_sending_method'] = array(
			'type'											   => 'debug',
			'label'											  => __('Allow site admins to change the sending method', WYSIJA) );
		$fields['ms_allow_admin_toggle_signup_confirmation'] = array(
			'type'  => 'debug',
			'label' => __('Allow site admins to deactivate Signup Confirmation', WYSIJA) );

		$htmlContent.='<table class="form-table"><tbody>';
		$htmlContent.=$this->viewObj->buildMyForm($fields, '', 'config');
		$htmlContent.='</tbody></table>';

		$htmlContent.='<div class="intro"><h3>'.__('Network\'s Default Sending Method', WYSIJA).'</h3></div>';
		$htmlContent.=$this->ms_sending_method();
		if (false) {
			$htmlContent.= '<div class="intro"><h3>'.__('SPF and DKIM', WYSIJA).'</h3></div>';

			$htmlContent.= '<table class="form-table">
				<tbody>
					<tr class="methods">
						<th scope="row">';

			$htmlContent.='<p>'.__('Your SPF record', WYSIJA).'</p>';

			$htmlContent.= '</th>';
			$htmlContent.= '<th scope="row"></th><td></td></tr>';

			$htmlContent.='</tbody></table>';
		}


		$htmlContent .='<p class="submit"><input type="submit" value="'.esc_attr(__('Save settings', WYSIJA)).'" class="button-primary wysija" /></p>';
		$htmlContent.='</div>'; //end multisite div

		return $htmlContent;
	}

	function ms_sending_method() {
		$prefix	   = 'ms_';
		$model_config = WYSIJA::get('config', 'model');
		$helper_forms = WYSIJA::get('forms', 'helper');
		$html_content = '<table class="form-table" id="ms-sendingmethod">
			<tbody>';



		$key = $prefix.'sending_method';

		$realvalue = $model_config->getValue($key);
		$html_content .= '<tr class="methods">
					<th scope="row">';

		$checked = false;
		$value   = 'site';
		$id	  = str_replace("_", '-', $key).'-'.$value;
		if ($value == $realvalue)
			$checked = true;
		$field   = '<label for="'.$id.'" class="clearfix">';
		$field.=$helper_forms->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.='<h3>'.__('Your own website', WYSIJA).'</h3></label>';
		$html_content.=$field;
		$html_content.='</th>
					<th scope="row">';

		$checked = false;
		$value   = 'smtp';
		if ($value === $realvalue)
			$checked = true;

		$id	= str_replace('_', '-', $key).'-'.$value;
		$field = '<label for="'.$id.'" class="clearfix">';
		$field.= $helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.= '<h3>'.__('Third party', WYSIJA).'</h3></label>';
		$html_content.=$field;
		$html_content.='</th>

					<td>
					</td>
				</tr>';


		$html_content.='<tr>
					<th scope="row">';

		$key   = $prefix.'from_email';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">'.__('FROM email address for sites using this method', WYSIJA)."</label>";
		$html_content.=$field;
		$html_content.='
					</th>
					<td colspan="2">';
		$html_content.=$helper_forms->input(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '40' ), $model_config->getValue($key));
		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-site">
					<th scope="row">';
		$field = __('Delivery method', WYSIJA);
		$field.='<p class="description">'.__('Send yourself some test emails to confirm which method works with your server.', WYSIJA).'</p>';
		$html_content.=$field;

		$html_content.='</th>
					<td colspan="2">';

		$key	   = $prefix.'sending_emails_site_method';
		$checked   = false;
		$realvalue = $model_config->getValue($key);
		$value	 = 'phpmail';
		if ($value == $realvalue)
			$checked   = true;

		$id	= str_replace('_', '-', $key).'-'.$value;
		$field = '<p class="title"><label for="'.$id.'">';
		$field.=$helper_forms->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.='PHP Mail</label></p>';
		$field.='<p class="description">'.__('This email engine works on 95&#37; of servers', WYSIJA).'</p>';


		if ($model_config->getValue('allow_wpmail')) {
			$checked = false;
			$value   = 'wpmail';
			if ($value == $realvalue)
				$checked = true;

			$id = str_replace('_', '-', $key).'-'.$value;
			$field.='<p class="title"><label for="'.$id.'">';
			$field.=$helper_forms->radio(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
			$field.='WP Mail</label></p>';
			$field.='<p class="description">'.__('Use the same method as the one used for your WP site.', WYSIJA).'</p>';
		}


		$html_content.=$field;
		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp">
					<th scope="row">';

		$key   = $prefix.'smtp_host';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">'.__('SMTP Hostname', WYSIJA)."</label>";
		$field.='<p class="description">'.__('e.g.:smtp.mydomain.com', WYSIJA).'</p>';
		$html_content.=$field;
		$html_content.='
					</th>
					<td colspan="2">';

		$value = $model_config->getValue($key);
		$field = $helper_forms->input(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '40' ), $value, $checked);
		$html_content.=$field;
		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp">
					<th scope="row">';

		$key   = $prefix.'smtp_login';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">'.__('Login', WYSIJA)."</label>";

		$html_content.=$field;

		$html_content.='</th>
					<td colspan="2">';

		$value = $model_config->getValue($key);
		$field = $helper_forms->input(array( "id"   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '40' ), $value, $checked);
		$html_content.=$field;
		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp">
					<th scope="row">';

		$key   = $prefix.'smtp_password';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">'.__('Password', WYSIJA)."</label>";
		$html_content.=$field;

		$html_content.='</th>
					<td colspan="2">';

		$value = $model_config->getValue($key);
		$field = $helper_forms->input(array( "type" => "password", "id"   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '40' ), $value, $checked);
		$html_content.=$field;

		$html_content.='</td>
				</tr>';

		$html_content.='<tr id="ms-restapipossible" class="hidechoice">
					<th scope="row">';

		$key   = $prefix.'smtp_rest';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">web API</label>';
		$field.='<p class="description">'.__('Activate if your SMTP ports are blocked.', WYSIJA).'</p>';
		$html_content.=$field;

		$html_content.='</th>
					<td colspan="2">';

		$value   = $model_config->getValue($key);
		$checked = false;
		if ($value)
			$checked = true;
		$field   = $helper_forms->checkbox(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '3' ), 1, $checked);

		$html_content.=$field;

		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-no-restapi">
					<th scope="row">';

		$key   = $prefix.'smtp_port';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">'.__('SMTP port', WYSIJA)."</label>";

		$html_content.=$field;

		$html_content.='</th>
					<td colspan="2">';

		$value = $model_config->getValue($key);
		$field = $helper_forms->input(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']', 'size' => '3' ), $value, $checked);

		$html_content.=$field;
		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-no-restapi">
					<th scope="row">';

		$key   = $prefix.'smtp_secure';
		$id	= str_replace('_', '-', $key);
		$field = '<label for="'.$id.'">'.__('Secure connection', WYSIJA)."</label>";
		$html_content.=$field;
		$html_content.='</th>
					<td colspan="2">';

		$value = $model_config->getValue($key);

		$field = $helper_forms->dropdown(array( 'name' => 'wysija[config]['.$key.']', "id"   => $id ), array( false => __("No"), "ssl" => "SSL", "tls" => "TLS" ), $value);
		$html_content.=$field;

		$html_content.='</td>
				</tr>';

		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-no-restapi">
					<th scope="row">';

		$field = __('Authentication', WYSIJA);
		$html_content.=$field.'<p class="description">'.__("Leave this option to Yes. Only a tiny portion of SMTP services ask Authentication to be turned off.", WYSIJA).'</p>';
		$html_content.='</th>
					<td colspan="2">';

		$key	   = $prefix.'smtp_auth';
		$realvalue = $model_config->getValue($key);

		$value   = false;
		$checked = false;
		if ($value == $realvalue)
			$checked = true;
		$id	  = str_replace('_', '-', $key).'-'.$value;
		$field   = '<label for="'.$id.'">';
		$field.=$helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.=__('No', WYSIJA).'</label>';

		$value   = true;
		$checked = false;
		if ($value == $realvalue)
			$checked = true;
		$id	  = str_replace('_', '-', $key).'-'.$value;
		$field.='<label for="'.$id.'">';
		$field.=$helper_forms->radio(array( 'id'   => $id, 'name' => 'wysija[config]['.$key.']' ), $value, $checked);
		$field.=__('Yes', WYSIJA).'</label>';


		$html_content.=$field;
		$html_content.='</td>
				</tr>';

		$current_user = wp_get_current_user();
		$html_content .=
				'<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-sending-method-site">'.
				'<th scope="row">'.
				__('Test method').
				'</th>'.
				'<td colspan="'.( is_multisite() ? 3 : 2 ).'">'.
				'<input type="text" value="'.esc_attr($current_user->data->user_email).'" class="mailpoet-test-emails" name="wysija[config][test_mails]" />'.
				'<a class="button-secondary mailpoet-test-delivery" data-multisite="'.( is_multisite() ? 'true' : 'false' ).'">'.esc_attr__('Send a test mail', WYSIJA).'</a>'.
				'</td>'.
				'</tr>';


		$html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-sending-method-site">
					<th scope="row">';

		$field = __('Send...', WYSIJA);

		$html_content.=$field.'<p class="description">'.str_replace(array( '[link]', '[/link]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/wp-cron-batch-emails-sending-frequency/?utm_source=wpadmin&utm_campaign=choosing%20frequency" target="_blank">', '</a>' ), __('Your web host has limits. We suggest 70 emails per hour to be safe. [link]Find out more[/link].', WYSIJA)).'</p>';
		$html_content.='</th>
					<td colspan="2">';

		$name   = $prefix.'sending_emails_number';
		$id	 = str_replace('_', '-', $name);
		$value  = $model_config->getValue($name);
		$params = array( 'id'   => $id, 'name' => 'wysija[config]['.$name.']', 'size' => '6' );
		$field = $helper_forms->input($params, $value);
		$field.= '&nbsp;'.__('emails', WYSIJA).'&nbsp;';


		$name  = $prefix.'sending_emails_each';
		$id	= str_replace('_', '-', $name);
		$value = $model_config->getValue($name);
		$field.=$helper_forms->dropdown(array( 'name' => 'wysija[config]['.$name.']', 'id'   => $id ), $helper_forms->eachValues, $value);
		$field.='<span class="ms-choice-under15"><b>'.__('This is fast!', WYSIJA).'</b> '.str_replace(array( '[link]', '[/link]' ), array( '<a href="http://support.mailpoet.com/knowledgebase/wp-cron-batch-emails-sending-frequency/?utm_source=wpadmin&utm_campaign=cron" target="_blank">', '</a>' ), __('We suggest you setup a cron job. [link]Read more[/link] on support.mailpoet.com', WYSIJA)).'</span>';
		$html_content.=$field;


		$html_content.='</td>
				</tr>
			</tbody>
		</table>';
		return $html_content;
	}

	// WYSIJA Form Editor
	function form_list() {
		$model_forms = WYSIJA::get('forms', 'model');

		$forms = $model_forms->getRows();

		// get available lists which users can subscribe to
		$model_list = WYSIJA::get('list', 'model');

		// get lists users can subscribe to (aka "enabled list")
		$lists = $model_list->get(array( 'name', 'list_id', 'is_public' ), array( 'is_enabled' => 1 ));

		// generate table header/footer
		$table_headers = '
			<th class="manage-column" scope="col"><span>'.__('Name', WYSIJA).'</span></th>
			<th class="manage-column" scope="col"><span>'.__('Lists', WYSIJA).'</span></th>
		';

		$classes = function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2';
		?>

		<!-- Create a new form -->
		<p class="new_form">
			<a class="<?php echo $classes; ?>" href="admin.php?page=wysija_config&action=form_add&_wpnonce=<?php echo $this->secure(array( "action" => "form_add" ), true); ?>"><?php _e('Create a new form', WYSIJA); ?></a>
		</p>

		<?php
		if (count($forms) > 0) {
			?>
			<!-- List of forms -->
			<div class="list">
				<table cellspacing="0" class="widefat fixed">
					<thead>
						<tr>
							<?php echo $table_headers; ?>
						</tr>
					</thead>
					<tfoot>
						<tr>
							<?php echo $table_headers; ?>
						</tr>
					</tfoot>

					<tbody>
						<?php
						for ($i	 = 0, $count = count($forms); $i < $count; $i++) {
							// set current row
							$row = $forms[$i];

							// get lists in settings and build list of lists (separated by "," for display only)
							$form_data = unserialize(base64_decode($row['data']));

							$form_lists = array( );
							if (isset($form_data['settings']['lists']) && !empty($form_data['settings']['lists'])) {
								for ($j		  = 0, $list_count = count($lists); $j < $list_count; $j++) {
									if (in_array($lists[$j]['list_id'], $form_data['settings']['lists'])) {
										$form_lists[] = $lists[$j]['name'];
									}
								}
							}

							// format list of lists depending on who's choosing the list to subscribe to (admin OR user)
							if (empty($form_lists)) {
								$form_lists_display = '<strong>'.__('No list specified', WYSIJA).'</strong>';
							}
							else {
								if ($form_data['settings']['lists_selected_by'] === 'user') {
									// user can select his own lists
									$form_lists_display = sprintf(__('User choice: %s', WYSIJA), join(', ', $form_lists));
								}
								else {
									// admin has selected which lists the user subscribes to
									$form_lists_display = join(', ', $form_lists);
								}
							}
							?>
							<tr class="<?php echo (($i % 2) ? 'alternate' : ''); ?>">
								<td>
									<?php echo $row['name']; ?>
									<div class="row-actions">
										<span class="edit">
											<a href="admin.php?page=wysija_config&action=form_edit&id=<?php echo $row['form_id'] ?>"><?php _e('Edit', WYSIJA); ?></a>
										</span> |
										<span class="duplicate">
											<a href="admin.php?page=wysija_config&action=form_duplicate&id=<?php echo $row['form_id'] ?>&_wpnonce=<?php echo $this->secure(array( 'action' => 'form_duplicate', 'id'	 => $row['form_id'] ), true); ?>"><?php _e('Duplicate', WYSIJA) ?></a>
										</span> |
										<span class="delete">
											<a href="admin.php?page=wysija_config&action=form_delete&id=<?php echo $row['form_id'] ?>&_wpnonce=<?php echo $this->secure(array( 'action' => 'form_delete', 'id'	 => $row['form_id'] ), true); ?>" class="submitdelete"><?php _e('Delete', WYSIJA) ?></a>
										</span>
									</div>
								</td>
								<td>
									<?php echo $form_lists_display ?>
								</td>
							</tr><?php
				}//endfor
								?>
					</tbody>
				</table>
			</div>
			<?php
		} //endif
	}

	function form_edit($data) {
		// get form editor rendering engine
		$helper_form_engine = WYSIJA::get('form_engine', 'helper');
		$helper_form_engine->set_lists($data['lists']);
		$helper_form_engine->set_data($data['form']['data'], true);
		$classes			= function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2';
		?>
		<div class="icon32"><img src="<?php echo WYSIJA_URL ?>img/form-icon.png" alt="" /></div>

		<?php
		if ($data['can_edit'] === false) {
			echo '<h2 class="title clearfix">';
			echo '<span>'.__('Edit form', WYSIJA).'</span>';
			echo '</h2>';
			echo __('Yikes! To edit a form, you need to have at least 1 list.', WYSIJA);
			echo '<a href="admin.php?page=wysija_subscribers&action=addlist" class="button-secondary2">'.__('Add List', WYSIJA).'</a>';
		}
		else {
			echo '<h2 class="title clearfix">';
			echo '<span>'.__('Edit', WYSIJA).'</span>';
			echo '<span id="form-name">'.$data['form']['name'].'</span>';
			echo '<span id="form-name-default">'.$data['form']['name'].'</span>';
			?>
			<span>
				<a id="edit-form-name" class="button" href="javascript:;"><?php echo __('Edit name', WYSIJA); ?></a>
				<a class="<?php echo $classes; ?>" href="admin.php?page=wysija_config#tab-forms"><?php echo __('List of forms', WYSIJA); ?></a>
			</span>
			</h2>

			<div class="clearfix">
				<!-- Form Editor Container -->
				<div id="wysija_form_container">
					<!-- Form Editor -->
					<div id="wysija_form_editor">
						<?php
						// render form editor
						echo $helper_form_engine->render_editor();
						?>
					</div>

					<!-- Form settings -->
					<form id="wysija-form-settings" action="" method="POST">
						<input type="hidden" name="form_id" value="<?php echo (int)$data['form_id']; ?>" />

						<!-- Form settings: list selection -->
						<div id="list-selection" class="clearfix">
							<p>
								<strong><?php _e('This form adds subscribers to these lists:', WYSIJA) ?></strong>
							</p>
							<?php
							if (!empty($data['lists'])) {
								$form_lists = $helper_form_engine->get_setting('lists');
								// make sure that form_lists is an array
								if ($form_lists === null or is_array($form_lists) === false)
									$form_lists = array( );

								usort($data['lists'], array( $this, 'sort_by_name' ));

								print '<select id="lists-selection" name="lists" data-placeholder="'.__('Choose a list', WYSIJA).'" multiple class="chosen_select">';

								for ($i	 = 0, $count = count($data['lists']); $i < $count; $i++) {
									$list	   = $data['lists'][$i];
									$is_checked = (in_array($list['list_id'], $form_lists)) ? 'selected="selected"' : '';
									//print '<label><input type="checkbox" class="checkbox" name="lists" value="' . $list['list_id'] . '" ' . $is_checked . ' />' . $list['name'] . '</label>';
									print '<option value="'.$list['list_id'].'" '.$is_checked.' />'.$list['name'].'</option>';
								}

								print '</select>';
							}
							?>
						</div>

						<!-- Form settings: after submit -->
						<div id="after-submit">
							<p>
								<strong><?php _e('After submit...', WYSIJA) ?></strong>
								<input type="hidden" name="on_success" value="message" />
								<!--<label><input type="radio" name="on_success" value="message" checked="checked"  /><?php _e('show message', WYSIJA); ?></label>
								<label><input type="radio" name="on_success" value="page" /><?php _e('go to page', WYSIJA); ?></label>-->
							</p>
							<textarea name="success_message"><?php echo $helper_form_engine->get_setting('success_message'); ?></textarea>
						</div>

						<p id="form-error" style="display:none;"></p>

						<p class="submit">
							<a href="javascript:;" id="form-save" class="button-primary wysija" ><?php echo esc_attr(__('Save', WYSIJA)); ?></a>
						</p>

						<p id="form-notice" style="display:none;"></p>
					</form>

					<!-- Form export links -->
					<div id="form-export-links"><p><?php echo str_replace(array( '[link]', '[/link]' ), array( '<a href="widgets.php" target="_blank">', '</a>' ), __('You can easily add this form to your theme\'s [link]Widgets areas[/link].', WYSIJA)); ?></p>
						<p><?php
				$text = __('[link_html]HTML[/link_html], [link_php]PHP[/link_php], [link_iframe]iframe[/link_iframe] and [link_shortcode]shortcode[/link_shortcode] versions are also available.', WYSIJA);
				echo str_replace(
						array( '[link_html]', '[link_php]', '[link_iframe]', '[link_shortcode]', '[/link_html]', '[/link_php]', '[/link_iframe]', '[/link_shortcode]' ), array( '<a target="javascript:;" class="expand-code" title="html">', '<a target="javascript:;" class="expand-code" title="php">', '<a target="javascript:;" class="expand-code" title="iframe">', '<a target="javascript:;" class="expand-code" title="shortcode">', '</a>', '</a>', '</a>', '</a>' ), $text);
							?></p></div>

					<!-- Form export -->
					<div id="form-export">
						<?php echo $helper_form_engine->render_editor_export($data['form_id']); ?>
					</div>
				</div>
				<!-- Form Editor: Toolbar -->
				<div id="wysija_form_toolbar">
					<!-- <ul class="wysija_form_toolbar_tabs">
						<li class="wjt-content">
							<a class="selected" href="javascript:;" rel="wj_content"><?php _e('Content', WYSIJA) ?></a>
						</li>
					</ul> -->

					<!-- CONTENT BAR -->
					<ul class="wj_content">
						<?php
						// render editor toolbar
						echo $helper_form_engine->render_editor_toolbar();
						?>
					</ul>

					<!-- WIDGET TEMPLATES -->
					<div id="wysija_widget_templates">
						<?php
						// render editor widget templates
						echo $helper_form_engine->render_editor_templates();
						?>
					</div>

					<div id="wysija_notices" style="display:none;"><span id="wysija_notice_msg"></span><img alt="loader" style="display:none;" id="ajax-loading" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /></div>
				</div>
			</div>
			<script type="text/javascript" charset="utf-8">
				wysijaAJAX.form_id = <?php echo (int)$_REQUEST['id'] ?>;

				function formEditorSave(callback) {
					wysijaAJAX.task = 'form_save';
					wysijaAJAX._wpnonce = wysijanonces.config.form_save;
					wysijaAJAX.wysijaData = WysijaForm.save();
					WYSIJA_SYNC_AJAX({
						success: callback
					});
				}

				function refreshToolbar(data) {
					// update toolbar
					$('wysija_form_toolbar').down('.wj_content').innerHTML = Base64.decode(data.toolbar);

					// update templates
					$('wysija_widget_templates').innerHTML = Base64.decode(data.templates);

					// setup events on widgets
					setupToolbar();
				}

				function refreshBlocks(field_name, block) {
					var elements = $$('#wysija_form_editor .wysija_form_block[wysija_field="'+ field_name +'"]');

					if(elements.length > 0) {
						$(elements).each(function(element) {
							// replace each block by new block
							refreshBlock(element, block);
						});

						// init wysija form
						setTimeout(function() {
							formEditorSave(function() { WysijaForm.init() });
						}, 1);
					}
				}

				function refreshBlock(element, block) {
					element.replace(Base64.decode(block));
				}

				function setupToolbar() {
					// add custom field button
					$('wysija-add-field').observe('click', function() {
						WysijaPopup.open(wysijatrans.add_field, $(this).readAttribute('href2'), function(data) {
							refreshToolbar(data);

							// make sure disabled widgets stay disabled after editing
							WysijaForm.toggleWidgets();
						});
						return false;
					});

					// edit custom field settings
					$$('.wysija_form_item_settings').invoke('stopObserving', 'click');
					$$('.wysija_form_item_settings').invoke('observe', 'click', function() {
						var self = this;
						// get field type
						var field_type = $(this).previous('.wysija_form_item').readAttribute('wysija_field');
						toggleBlocksHighlight('on', field_type);
						WysijaPopup.open(wysijatrans.edit_field, $(this).readAttribute('href2'), function(data) {
							refreshToolbar(data);

							// get field type
							var field_name = $(self).previous('.wysija_form_item').readAttribute('wysija_field');
							refreshBlocks(field_name, data.block);

							// make sure disabled widgets stay disabled after editing
							WysijaForm.toggleWidgets();

							toggleBlocksHighlight('off', field_type);
						}, function() {
							toggleBlocksHighlight('off', field_type);
						});
						return false;
					});

					// remove custom field
					$$('.wysija_form_item_delete').invoke('stopObserving', 'click');
					$$('.wysija_form_item_delete').invoke('observe', 'click', function(e) {
						// get field type
						var field_type = $(this).previous('.wysija_form_item').readAttribute('wysija_field');

						// highlight blocks using this field type
						toggleBlocksHighlight('on', field_type);

						if(window.confirm(wysijatrans.delete_field_confirmation)) {
							// make ajax request
							wysijaAJAX.task = 'form_field_delete';
							wysijaAJAX._wpnonce = wysijanonces.config.form_field_delete;
							// build data with field id
							var data = { field_id: parseInt($(this).readAttribute('data-field-id'), 10) },
							self = this;
							wysijaAJAX.wysijaData = Base64.encode(Object.toJSON(data).gsub('\\"', '"').gsub('"[{', '[{').gsub('}]"', '}]'));

							new Ajax.Request(wysijaAJAX.ajaxurl, {
								method: 'post',
								parameters: wysijaAJAX,
								onSuccess:function(response) {
									// remove widget from list
									$(self).up('li').remove();

									// remove all blocks from the same type
									$$('.wysija_form_block[wysija_field="'+ field_type +'"]').each(function(element) {
										// get block id
										var block = WysijaForm.get($(element));
										block.removeBlock();
									});

									// save form
									formEditorSave();
								},
								onFailure:function(response) {
									// nothing we can do about it.
								}
							});
						}

						// highlight blocks using this field type
						toggleBlocksHighlight('off', field_type);
						return false;
					});
				}

				function toggleBlocksHighlight(toggle, field_type) {
					if(field_type === undefined) return false;

					if(toggle === 'on') {
						// turn highlight on
						$$('.wysija_form_block[wysija_field="'+ field_type +'"]').invoke('addClassName', 'highlighted');
					} else {
						// turn highlight off
						$$('.wysija_form_block[wysija_field="'+ field_type +'"]').invoke('removeClassName', 'highlighted');
					}

				}

				$('form-save').observe('click', function() {
					// hide any previous error
					$('form-error').hide();
					// hide any previous notice
					$('form-notice').hide();
					$('form-export-links').hide();

					// make sure a list has been selected or that we have a list selection widget inserted
					if ($F('lists-selection').length === 0 && $$('#wysija_form_body div[wysija_field="list"]').length === 0) {
						$('form-error').update(wysijatrans.list_cannot_be_empty).show();
					} else {
						// hide export options while saving
						WysijaForm.hideExport();

						formEditorSave(function(response) {
							// regenerate export methods and show
							$('form-export').innerHTML = Base64.decode(response.responseJSON.result.exports);

							// display save message
							$('form-notice').update(Base64.decode(response.responseJSON.result.save_message));
							$('form-export-links').show();
							$('form-notice').show();

							WysijaForm.showExport();
						});
					}
					return false;
				});

				$(document).observe('dom:loaded', function() {
					// setup widget events
					setupToolbar();

					// Setups the jQuery Select2
					jQuery('#lists-selection').select2({
						'width': 640
					});

					// in place editor for form name
					new Ajax.InPlaceEditor('form-name', wysijaAJAX.ajaxurl, {
						okControl: false,
						cancelControl: false,
						clickToEditText: '',
						submitOnBlur: true,
						highlightColor: '#f9f9f9',
						externalControl: 'edit-form-name',
						callback: function(form, value) {
							wysijaAJAX.task = 'form_name_save';
							wysijaAJAX._wpnonce = wysijanonces.config.form_name_save;

							return Object.toQueryString(wysijaAJAX) + '&id=' + wysijaAJAX.form_id + '&name=' + encodeURIComponent(WysijaForm.stripHtmlValue(value));
						},
						onComplete: function(response, element) {
							if(response.responseJSON.result.name.length === 0) {
								$(element).innerHTML = $('form-name-default').innerHTML;
							} else {
								var sanitized_name = WysijaForm.stripHtmlValue(response.responseJSON.result.name);
								$(element).innerHTML = sanitized_name;
								$('form-name-default').innerHTML = sanitized_name;
							}

							// remove observe on input field
							$('form-name-inplaceeditor').down('.editor_field').stopObserving('keypress');
						},
						onEnterEditMode: function(form, value) {
							setTimeout(function() {
								$('form-name-inplaceeditor').down('.editor_field').observe('keypress', function(e) {
									// prevent form from submitting on enter key press
									if (e.keyCode == 13) {
										e.preventDefault();
									}
								});
							}, 1);
						}
					});
				});
			</script>
			<?php
		}
	}

	// Wysija Form Editor: Widget Settings
	function popup_form_widget_settings($data = array( )) {
		$type			 = (isset($data['type']) && strlen(trim($data['type'])) > 0) ? $data['type'] : 'new';
		?>
		<div class="popup_content inline_form form_widget_settings widget_<?php echo $type; ?>">
			<?php
			// it means it's a new field if we have a field_id parameter with a 0 value
			$is_editing_field = (bool)(isset($data['field_id']));

			if (isset($data['field_id'])) {
				$valid_types = array(
					'input'	=> __('Text Input', WYSIJA),
					'textarea' => __('Text Area', WYSIJA),
					'radio'	=> __('Radio buttons', WYSIJA),
					'checkbox' => __('Checkbox', WYSIJA),
					'select'   => __('Select', WYSIJA),
					'date'	 => __('Date', WYSIJA)
						//'country' => __('Country', WYSIJA)
				);
				?>
				<form id="field-settings-form" method="get" action="">
					<input type="hidden" name="action" value="<?php echo esc_attr($_REQUEST['action']); ?>" />
					<input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
					<input type="hidden" name="field_id" value="<?php echo (int)$data['field_id']; ?>" />

					<p class="clearfix">
						<label for="field-type-select"><?php _e('Select a field type:', WYSIJA) ?></label>
						<select id="field-type-select" name="type">
							<option value=""></option>
							<?php
							foreach ($valid_types as $type => $label) {
								$is_selected = ($data['type'] === $type) ? ' selected="selected"' : '';

								echo '<option value="'.$type.'"'.$is_selected.'>'.$label.'</option>';
							}
							?>
						</select>
					</p>
					<hr />
				</form>

				<?php
			}

			if (method_exists($this, 'form_widget_'.$data['type']) === false) {
				// display warning because the widget has no form built in
				// print 'missing method "' . 'form_widget_' . $data['type'] . '"';
			}
			else {
				// get widget form
				$data['is_editing_field'] = $is_editing_field;
				$widget_form			  = $this->{'form_widget_'.$data['type']}($data);
				// check whether the field is a custom field
				$form_engine			  = WYSIJA::get('form_engine', 'helper');
				$is_custom_field		  = $form_engine->is_custom_field($data);
				?>

				<!-- this is to display error messages -->
				<p id="widget-settings-error" style="display:none;"></p>

				<!-- common form for every wysija form widget -->
				<form enctype="multipart/form-data" method="post" action="" class="" id="widget-settings-form">
					<input type="hidden" name="type" value="<?php echo $data['type']; ?>" />
					<input type="hidden" name="field" value="<?php echo $data['field']; ?>" />
					<?php
					if ($is_editing_field === true) {
						?>
						<p class="clearfix">
							<label for="name"><?php _e("Field's name:", WYSIJA); ?></label>
							<input type="text" id="name" name="name" value="<?php echo stripslashes(esc_attr($data['name'])); ?>" />
						</p>
						<?php
					}
					else {
						?>
						<input type="hidden" name="name" value="<?php echo esc_attr($data['name']); ?>" />
						<?php
					}
					?>
					<?php echo $widget_form; ?>

					<p class="submit_button">
						<input id="widget-settings-submit" type="submit" name="submit" value="<?php echo esc_attr(__('Done', WYSIJA)) ?>" class="button-primary" />
						<?php
						if ($is_editing_field === false && $is_custom_field === true) {
							$field_id = (int)substr($data['field'], 3);
							?>
							<a id="widget-field-settings" wysija_field="<?php echo $field_id; ?>" href="javascript:;"><?php echo __('Edit field', WYSIJA); ?></a>
							<?php
						}
						?>
					</p>
				</form>
			</div>
			<?php
		}
	}

	function form_widget_html($data = array( )) {
		$output = '';

		// get widget params from data, this will contain all user editable parameters
		$params = $data['params'];

		// text
		$text = isset($params['text']) ? $params['text'] : '';
		$output .= '<textarea name="text">'.$text.'</textarea>';

		// nl2br?
		$is_checked = (isset($params['nl2br']) && (bool)$params['nl2br'] === true) ? 'checked="checked"' : '';
		$output .= '<label for="field-nl2br"><input id="field-nl2br" type="checkbox" class="checkbox" name="nl2br" '.$is_checked.' value="1" />'.__('Automatically add paragraphs', WYSIJA).'</label>';

		return $output;
	}

	function form_widget_submit($data = array( )) {
		$output = '';

		// label
		$output .= $this->_widget_label($data);

		return $output;
	}

	function form_widget_input($data = array( )) {
		$output = '';

		// label
		$output .= $this->_widget_label($data);

		// inline label
		$output .= $this->_widget_label_inline($data);

		// extra validation
		$output .= $this->_widget_validation($data);

		return $output;
	}

	function form_widget_textarea($data = array( )) {
		$output = '';

		// label
		$output .= $this->_widget_label($data);

		// inline label
		$output .= $this->_widget_label_inline($data);

		// extra validation
		$output .= $this->_widget_validation($data);

		if ($data['is_editing_field'] === false) {
			// number of lines (defaults to 1)
			$number_of_lines = (isset($data['params']['lines']) && (int)$data['params']['lines'] > 0) ? (int)$data['params']['lines'] : 1;

			$output .= '<p class="clearfix"><label for="number-lines-select">'.__('Number of lines:', WYSIJA).'</label>';
			$output .= '    <select id="number-lines-select" name="lines">';
			for ($i = 1; $i < 6; $i++) {
				$is_selected = ($number_of_lines === $i) ? ' selected="selected"' : '';
				$output .= '    <option value="'.$i.'" '.$is_selected.'>'.sprintf(_n('1 line', '%d lines', $i, WYSIJA), $i).'</option>';
			}
			$output .= '    </select>';
			$output .= '</p>';
		}

		return $output;
	}

	function form_widget_list($data = array( )) {
		$output = '';

		// get widget params from data, this will contain all user editable parameters
		$params = $data['params'];

		// get widget extra data, this will contain all the available lists
		$extra = $data['extra'];

		// label
		$output .= $this->_widget_label($data);

		$helper_form_engine = WYSIJA::get('form_engine', 'helper');
		// get list names
		$list_names		 = $helper_form_engine->get_formatted_lists();

		// display select lists
		$output .= '<ul id="lists-selection" class="selection sortable">';

		if (!empty($params['values'])) {
			for ($i	 = 0, $count = count($params['values']); $i < $count; $i++) {
				$list	   = $params['values'][$i];
				$is_checked = ((int)$list['is_checked'] > 0) ? 'checked="checked"' : '';
				if (isset($list_names[$list['list_id']])) {
					$output .= '<li class="clearfix">';
					$output .= '    <input class="is_selected" id="list-'.$list['list_id'].'" type="checkbox" data-list="'.$list['list_id'].'" value="1" '.$is_checked.' />';
					$output .= '    <label for="list-'.$list['list_id'].'">'.$list_names[$list['list_id']].'</label>';
					$output .= '    <a class="icon remove" href="javascript:;"><span></span></a>';
					$output .= '    <a class="icon handle" href="javascript:;"><span></span></a>';
					$output .= '</li>';
				}
			}
		}

		$output .= '</ul>';

		// available lists container
		$output .= '<div id="lists-add-container" class="clearfix">';
		$output .= '<h3>'.__('Select the list you want to add:', WYSIJA).'</h3>';

		// available lists select
		$output .= '<select id="lists-available" class="mp-select-sort">';
		for ($j	 = 0, $count = count($extra['lists']); $j < $count; $j++) {
			// set current list
			$list = $extra['lists'][$j];
			// generate select option
			$output .= '<option value="'.$list['list_id'].'">'.$list['name'].'</option>';
		}
		$output .= '</select>';

		// add button to add currently selected list to selected lists
		$output .= '<a href="javascript:;" class="icon add"><span></span></a>';
		$output .= '</div>';

		// generate prototypeJS template for list selection so we can dynamically add/remove elements
		$output .= '<div id="selection-template">';
		$output .= '<li class="clearfix">';
		$output .= '<input class="is_selected" id="list-#{list_id}" type="checkbox" data-list="#{list_id}" value="1" /><label for="list-#{list_id}">#{name}</label>';
		$output .= '<a class="icon remove" href="javascript:;"><span></span></a>';
		$output .= '<a class="icon handle" href="javascript:;"><span></span></a>';
		$output .= '</li>';
		$output .= '</div>';

		return $output;
	}

	function form_widget_radio($data = array( )) {
		return $this->form_widget_multiple($data, 'radio');
	}

	function form_widget_checkbox($data = array( )) {
		return $this->form_widget_multiple($data, 'checkbox');
	}

	function form_widget_select($data = array( )) {
		return $this->form_widget_multiple($data, 'select');
	}

	// Country selection widget
	function form_widget_country($data = array( )) {
		$output = '';

		// TODO: JSON data coming from API
		//$country_data = json_decode(file_get_contents('http://localhost/countries.json'), true);
		$country_data = array( );

		// format countries for select widget
		$countries = array( );
		foreach ($country_data as $country) {
			$countries[] = array(
				'value'				   => $country['name'],
				'is_checked'			  => false
			);
		}
		$data['params']['values'] = $countries;

		// render select widget form
		$output .= $this->form_widget_multiple($data, 'select');

		return $output;
	}

	public function form_widget_date($data = array( )) {
		$output = '';

		// label
		$output .= $this->_widget_label($data);

		// date types
		$date_types = array(
			'year_month_day' => __('Year, month, day', WYSIJA),
			'year_month'	 => __('Year, month', WYSIJA),
			'month'		  => __('Month (January, February,...)', WYSIJA),
			'year'		   => __('Year', WYSIJA)
		);

		if ($data['is_editing_field'] === false) {
			$date_type_value = (isset($data['params']['date_type']) && strlen(trim($data['params']['date_type'])) > 0) ? trim($data['params']['date_type']) : $date_types[0];
			$output .= '<input type="hidden" name="date_type" value="'.$date_type_value.'">';
		}
		else {

			// date type selection
			$output .= '<p class="clearfix"><label for="date_type">'.__('Type of date:', WYSIJA).'</label>';
			$output .= '    <select id="date_type" name="date_type">';
			foreach ($date_types as $key => $label) {
				$is_selected = (isset($data['params']['date_type']) && $data['params']['date_type'] === $key) ? ' selected="selected"' : '';
				$output .= '    <option value="'.$key.'" '.$is_selected.'>'.$label.'</option>';
			}
			$output .= '    </select>';
			$output .= '</p>';
		}

		// date set default as today
		$output .= $this->_widget_date_default_today($data);

		// date display order
		$output .= $this->_widget_date_order($data);

		return $output;
	}

	// generic widget for handling multiple choices (radio, checkbox, select)
	private function form_widget_multiple($data = array( ), $type = false) {
		$output = '';

		if ($type === false)
			return $output;

		// get widget params from data, this will contain all user editable parameters
		$params = $data['params'];

		// label
		$output .= $this->_widget_label($data);

		// label inline
		$output .= $this->_widget_label_inline($data);

		// flag to know whether to allow multiple values or not
		$is_multiple = true;

		// checkbox only allow one value (for now...)
		if ($type === 'checkbox') {
			$is_multiple = false;

			// make sure we have one value
			if (empty($params['values'])) {
				$params['values'][] = array( 'value'	  => '', 'is_checked' => false );
			}
			else {
				// restrict to 1 value
				if (count($params['values']) > 1) {
					$value			= $params['values'][0];
					$params['values'] = array( $value );
				}
			}
		}

		// set CSS classes for list
		$list_classes = array( 'selection' );
		if ($is_multiple === true) {
			$list_classes[] = 'sortable';
		}

		// hide values when no editing CF global settings
		if ($data['is_editing_field'] === false) {
			$output .= '<div class="hidden">';
		}

		// display values
		$output .= '<ul id="items-selection" class="'.join(' ', $list_classes).'">';

		if (!empty($params['values'])) {
			for ($i	 = 0, $count = count($params['values']); $i < $count; $i++) {
				$item	   = $params['values'][$i];
				$is_checked = ((int)$item['is_checked'] > 0) ? 'checked="checked"' : '';

				$output .= '<li class="clearfix">';
				if ($type === 'checkbox') {
					$output .= '<input type="checkbox" class="is_checked" value="1" '.$is_checked.' />';
				}
				else {
					$output .= '<input type="radio" name="is_checked" class="is_checked" value="1" '.$is_checked.' />';
				}

				$output .= '    <input type="text" class="value" value="'.$item['value'].'" tabindex="'.($i + 1).'" />';

				if ($is_multiple === true) {
					$output .= '    <a class="icon remove" href="javascript:;"><span></span></a>';
					$output .= '    <a class="icon handle" href="javascript:;"><span></span></a>';
				}
				$output .= '</li>';
			}
		}

		$output .= '</ul>';

		if ($is_multiple === true) {
			// add a new option
			$output .= '<a id="items-selection-add" href="javascript:;" class="icon add"><span></span>'.__('Add item', WYSIJA).'</a>';

			// generate prototypeJS template for list selection so we can dynamically add/remove elements
			$output .= '<div id="selection-template">';
			$output .= '<li class="clearfix">';
			if ($type === 'checkbox') {
				$output .= '<input type="checkbox" class="is_checked" value="1" />';
			}
			else {
				$output .= '<input type="radio" name="is_checked" class="is_checked" value="1" />';
			}
			$output .= '    <input type="text" class="value" value="" tabindex="#{item_index}" />';
			$output .= '    <a class="icon remove" href="javascript:;"><span></span></a>';
			$output .= '    <a class="icon handle" href="javascript:;"><span></span></a>';
			$output .= '</li>';
			$output .= '</div>';
		}

		// hide values when no editing CF global settings
		if ($data['is_editing_field'] === false) {
			$output .= '</div>';
		}

		$output .= $this->_widget_validation($data);

		return $output;
	}

	// widget feature: ability to specify a label
	private function _widget_label($data = array( )) {
		$output = '';

		if ($data['is_editing_field'] === false) {
			// label
			$label = (isset($data['params']['label'])) ? $data['params']['label'] : '';
			$output .= '<p class="clearfix"><label for="label">'.__('Label:', WYSIJA).'</label>';
			$output .= '<input id="label" type="text" name="label" value="'.$label.'" /></p>';
		}

		return $output;
	}

	// widget feature: ability to choose whether the label should be inline (a placeholder)
	private function _widget_label_inline($data = array( )) {
		$output = '';

		// only show extra validation for these types
		if (in_array($data['type'], array( 'input', 'textarea', 'select' )) && $data['is_editing_field'] === false) {
			// inline
			$is_label_within = (bool)(isset($data['params']['label_within']) && (int)$data['params']['label_within'] > 0);
			$output .= '<p class="clearfix">';
			$output .= '<label>'.__('Display label within input:', WYSIJA).'</label>';
			$output .= '	<span class="group">';
			$output .= '		<label class="radio"><input type="radio" name="label_within" value="1" '.(($is_label_within === true) ? 'checked="checked"' : '').' />'.__('Yes', WYSIJA).'</label>';
			$output .= '		<label class="radio"><input type="radio" name="label_within" value="0" '.(($is_label_within === false) ? 'checked="checked"' : '').' />'.__('No', WYSIJA).'</label>';
			$output .= '	</span>';
			$output .= '</p>';
		}

		return $output;
	}

	private function _widget_date_order($data = array( )) {
		// date order
		$date_orders = array(
			'year_month_day' => array( 'mm/dd/yyyy', 'dd/mm/yyyy', 'yyyy/mm/dd' ),
			'year_month' => array( 'mm/yyyy', 'yyyy/mm' ),
			'year' => array( 'yyyy' ),
			'month' => array( 'mm' )
		);

		$output = '';

		// get date orders from date type
		$orders = array( );
		if (isset($date_orders[$data['params']['date_type']])) {
			$orders = $date_orders[$data['params']['date_type']];
		}
		else {
			$orders = $date_orders['year_month_day'];
		}

		if ($data['is_editing_field'] === false) {
			if (count($orders) === 1) {
				// show as hidden input
				$output .= '<input type="hidden" name="date_order" value="'.$orders[0].'" />';
			}
			else {
				$output .= '<p class="clearfix">';
				$output .= '<label for="date_order">'.__('Order:', WYSIJA).'</label>';
				$output .= '<select id="date_order" class="date_order" name="date_order">';

				foreach ($orders as $date_order) {
					$is_selected = (isset($data['params']['date_order']) && $data['params']['date_order'] === $date_order) ? ' selected="selected"' : '';
					$output .= '<option value="'.$date_order.'" '.$is_selected.'>'.$date_order.'</option>';
				}
				$output .= '</select>';
				$output .= '</p>';
			}
		}
		else {
			if (isset($data['params']['date_order'])) {
				$output .= '<input type="hidden" name="date_order" value="'.$data['params']['date_order'].'" />';
			}
			else {
				$output .= '<input type="hidden" name="date_order" value="'.$orders[0].'" />';
			}
		}

		return $output;
	}

	private function _widget_date_default_today($data = array( )) {
		$output = '';

		$display_default_today = true;
		$is_default_today	  = (bool)(isset($data['params']['is_default_today']) && (int)$data['params']['is_default_today'] > 0);


		// in the case of a "year", we don't offer the possibility to select today's date as the default
		if ($data['params']['date_type'] === 'year') {
			$display_default_today = false;
			$is_default_today	  = false;
		}

		if ($data['is_editing_field'] === false && $display_default_today === true) {
			$output .= '<p class="clearfix">';
			$output .= '<label>'.__("Preselect today's date:", WYSIJA).'</label>';
			$output .= '    <span class="group">';
			$output .= '        <label class="radio"><input type="radio" name="is_default_today" value="1" '.(($is_default_today === true) ? 'checked="checked"' : '').' />'.__('Yes', WYSIJA).'</label>';
			$output .= '        <label class="radio"><input type="radio" name="is_default_today" value="0" '.(($is_default_today === false) ? 'checked="checked"' : '').' />'.__('No', WYSIJA).'</label>';
			$output .= '    </span>';
			$output .= '</p>';
		}
		else {
			$output .= '<input type="hidden" name="is_default_today" value="'.(int)$is_default_today.'" />';
		}

		return $output;
	}

	// widget feature: data validation - is_required checkbox
	private function _widget_validation_is_required($data = array( )) {
		// is the field mandatory?
		$is_required = (bool)(isset($data['params']['required']) && (int)$data['params']['required'] > 0);
		$output	  = '<p class="clearfix">';
		$output .= '    <label>'.__('Is this field mandatory?', WYSIJA).'</label>';
		$output .= '    <span class="group">';
		$output .= '        <label class="radio"><input type="radio" name="required" value="1" '.(($is_required === true) ? 'checked="checked"' : '').' />'.__('Yes', WYSIJA).'</label>';
		$output .= '        <label class="radio"><input type="radio" name="required" value="0" '.(($is_required === false) ? 'checked="checked"' : '').' />'.__('No', WYSIJA).'</label>';
		$output .= '    </span>';
		$output .= '</p>';
		return $output;
	}

	// widget feature: data validation
	private function _widget_validation($data = array( )) {

		$output = '';

		// display hidden parameters in case we're editing display settings
		if ($data['is_editing_field'] === false) {

			// special case for firstname & lastname
			// we need to display the "is_required" in the form since they're not actual custom fields, they don't have "field settings"
			if (in_array($data['field'], array( 'firstname', 'lastname' ))) {
				$output .= $this->_widget_validation_is_required($data);
			}
			else {
				// display hidden input since these settings are set on the custom field itself
				if (isset($data['params']['required'])) {
					$required_value = (isset($data['params']['required']) && (int)$data['params']['required'] > 0) ? 1 : 0;
					$output .= '<input type="hidden" name="required" value="'.$required_value.'" />';
				}

				if (isset($data['params']['validate'])) {
					$validate_value = (isset($data['params']['validate']) && strlen(trim($data['params']['validate'])) > 0) ? trim($data['params']['validate']) : '';
					$output .= '<input type="hidden" name="validate" value="'.$validate_value.'" />';
				}
			}
		}
		else {
			// validation
			if ($data['field'] === 'email') {
				// the email field is always mandatory, no questions asked
				$output .= '<input type="hidden" name="required" value="1" />';
			}
			else {
				$output .= $this->_widget_validation_is_required($data);
			}

			// extra validation rules
			$rules = array(
				'onlyNumberSp'	 => __('Numbers only', WYSIJA),
				'onlyLetterSp'	 => __('Letters only', WYSIJA),
				'onlyLetterNumber' => __('Alphanumerical ', WYSIJA),
				'phone'			=> __('Phone number, (+,-,#,(,) and spaces allowed)', WYSIJA)
			);

			// only show extra validation for these types
			if (in_array($data['type'], array( 'input', 'textarea' ))) {
				$output .= '<p class="clearfix">';
				$output .= '    <label>'.__('Validate for:', WYSIJA).'</label>';
				$output .= '    <select name="validate">';
				$output .= '        <option value="">'.__('Nothing', WYSIJA).'</option>';
				foreach ($rules as $rule => $label) {
					$is_selected = (isset($data['params']['validate']) && ($rule === $data['params']['validate'])) ? ' selected="selected"' : '';
					$output .= '    <option value="'.$rule.'"'.$is_selected.'>'.$label.'</option>';
				}
				$output .= '    </select>';
				$output .= '</p>';
			}
		}

		return $output;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit