Conditions | 30 |
Paths | 4100 |
Total Lines | 993 |
Code Lines | 148 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
775 | function get_xslt_stylesheet($format, $uid) |
||
776 | { |
||
777 | global $context, $txt, $settings, $modSettings, $sourcedir, $forum_copyright, $smcFunc; |
||
778 | |||
779 | static $xslts = array(); |
||
780 | |||
781 | $dtd = ''; |
||
782 | $stylesheet = array(); |
||
783 | $xslt_variables = array(); |
||
784 | |||
785 | // Do not change any of these to HTTPS URLs. For explanation, see comments in the buildXmlFeed() function. |
||
786 | $smf_ns = 'htt'.'p:/'.'/ww'.'w.simple'.'machines.o'.'rg/xml/profile'; |
||
787 | $xslt_ns = 'htt'.'p:/'.'/ww'.'w.w3.o'.'rg/1999/XSL/Transform'; |
||
788 | $html_ns = 'htt'.'p:/'.'/ww'.'w.w3.o'.'rg/1999/xhtml'; |
||
789 | |||
790 | require_once($sourcedir . DIRECTORY_SEPARATOR . 'News.php'); |
||
791 | |||
792 | if (in_array($format, array('HTML', 'XML_XSLT'))) |
||
793 | { |
||
794 | if (!class_exists('DOMDocument') || !class_exists('XSLTProcessor')) |
||
795 | $format = 'XML_XSLT'; |
||
796 | |||
797 | $export_formats = get_export_formats(); |
||
798 | |||
799 | /* Notes: |
||
800 | * 1. The 'value' can be one of the following: |
||
801 | * - an integer or string |
||
802 | * - an XPath expression |
||
803 | * - raw XML, which may or not not include other XSLT statements. |
||
804 | * |
||
805 | * 2. Always set 'no_cdata_parse' to true when the value is raw XML. |
||
806 | * |
||
807 | * 3. Set 'xpath' to true if the value is an XPath expression. When this |
||
808 | * is true, the value will be placed in the 'select' attribute of the |
||
809 | * <xsl:variable> element rather than in a child node. |
||
810 | * |
||
811 | * 4. Set 'param' to true in order to create an <xsl:param> instead |
||
812 | * of an <xsl:variable>. |
||
813 | * |
||
814 | * A word to PHP coders: Do not let the term "variable" mislead you. |
||
815 | * XSLT variables are roughly equivalent to PHP constants rather |
||
816 | * than PHP variables; once the value has been set, it is immutable. |
||
817 | * Keeping this in mind may spare you from some confusion and |
||
818 | * frustration while working with XSLT. |
||
819 | */ |
||
820 | $xslt_variables = array( |
||
821 | 'scripturl' => array( |
||
822 | 'value' => '/*/@forum-url', |
||
823 | 'xpath' => true, |
||
824 | ), |
||
825 | 'themeurl' => array( |
||
826 | 'value' => $settings['default_theme_url'], |
||
827 | ), |
||
828 | 'member_id' => array( |
||
829 | 'value' => $uid, |
||
830 | ), |
||
831 | 'last_page' => array( |
||
832 | 'param' => true, |
||
833 | 'value' => !empty($context['export_last_page']) ? $context['export_last_page'] : 1, |
||
834 | 'xpath' => true, |
||
835 | ), |
||
836 | 'dlfilename' => array( |
||
837 | 'param' => true, |
||
838 | 'value' => !empty($context['export_dlfilename']) ? $context['export_dlfilename'] : '', |
||
839 | ), |
||
840 | 'ext' => array( |
||
841 | 'value' => $export_formats[$format]['extension'], |
||
842 | ), |
||
843 | 'forum_copyright' => array( |
||
844 | 'value' => sprintf($forum_copyright, SMF_FULL_VERSION, SMF_SOFTWARE_YEAR), |
||
845 | ), |
||
846 | 'txt_summary_heading' => array( |
||
847 | 'value' => $txt['summary'], |
||
848 | ), |
||
849 | 'txt_posts_heading' => array( |
||
850 | 'value' => $txt['posts'], |
||
851 | ), |
||
852 | 'txt_personal_messages_heading' => array( |
||
853 | 'value' => $txt['personal_messages'], |
||
854 | ), |
||
855 | 'txt_view_source_button' => array( |
||
856 | 'value' => $txt['export_view_source_button'], |
||
857 | ), |
||
858 | 'txt_download_original' => array( |
||
859 | 'value' => $txt['export_download_original'], |
||
860 | ), |
||
861 | 'txt_help' => array( |
||
862 | 'value' => $txt['help'], |
||
863 | ), |
||
864 | 'txt_terms_rules' => array( |
||
865 | 'value' => $txt['terms_and_rules'], |
||
866 | ), |
||
867 | 'txt_go_up' => array( |
||
868 | 'value' => $txt['go_up'], |
||
869 | ), |
||
870 | 'txt_pages' => array( |
||
871 | 'value' => $txt['pages'], |
||
872 | ), |
||
873 | ); |
||
874 | |||
875 | // Let mods adjust the XSLT variables. |
||
876 | call_integration_hook('integrate_export_xslt_variables', array(&$xslt_variables, $format)); |
||
877 | |||
878 | $idhash = hash_hmac('sha1', $uid, get_auth_secret()); |
||
879 | $xslt_variables['dltoken'] = array( |
||
880 | 'value' => hash_hmac('sha1', $idhash, get_auth_secret()) |
||
881 | ); |
||
882 | |||
883 | // Efficiency = good. |
||
884 | $xslt_key = $smcFunc['json_encode'](array($format, $uid, $xslt_variables)); |
||
885 | if (isset($xslts[$xslt_key])) |
||
886 | return $xslts[$xslt_key]; |
||
887 | |||
888 | if ($format == 'XML_XSLT') |
||
889 | { |
||
890 | $dtd = implode("\n", array( |
||
891 | '<!--', |
||
892 | "\t" . $txt['export_open_in_browser'], |
||
893 | '-->', |
||
894 | '<?xml-stylesheet type="text/xsl" href="#stylesheet"?>', |
||
895 | '<!DOCTYPE smf:xml-feed [', |
||
896 | '<!ATTLIST xsl:stylesheet', |
||
897 | 'id ID #REQUIRED>', |
||
898 | ']>', |
||
899 | )); |
||
900 | |||
901 | $stylesheet['header'] = "\n" . implode("\n", array( |
||
902 | '', |
||
903 | "\t" . '<xsl:stylesheet version="1.0" xmlns:xsl="' . $xslt_ns . '" xmlns:html="' . $html_ns . '" xmlns:smf="' . $smf_ns . '" exclude-result-prefixes="smf html" id="stylesheet">', |
||
904 | '', |
||
905 | "\t\t" . '<xsl:template match="xsl:stylesheet"/>', |
||
906 | "\t\t" . '<xsl:template match="xsl:stylesheet" mode="detailedinfo"/>', |
||
907 | )); |
||
908 | } |
||
909 | else |
||
910 | { |
||
911 | $dtd = ''; |
||
912 | $stylesheet['header'] = implode("\n", array( |
||
913 | '<?xml version="1.0" encoding="' . $context['character_set'] . '"?' . '>', |
||
914 | '<xsl:stylesheet version="1.0" xmlns:xsl="' . $xslt_ns . '" xmlns:html="' . $html_ns . '" xmlns:smf="' . $smf_ns . '" exclude-result-prefixes="smf html">', |
||
915 | )); |
||
916 | } |
||
917 | |||
918 | // Output control settings. |
||
919 | $stylesheet['output_control'] = ' |
||
920 | <xsl:output method="html" encoding="utf-8" indent="yes"/> |
||
921 | <xsl:strip-space elements="*"/>'; |
||
922 | |||
923 | // Insert the XSLT variables. |
||
924 | $stylesheet['variables'] = ''; |
||
925 | |||
926 | foreach ($xslt_variables as $name => $var) |
||
927 | { |
||
928 | $element = !empty($var['param']) ? 'param' : 'variable'; |
||
929 | |||
930 | $stylesheet['variables'] .= "\n\t\t" . '<xsl:' . $element . ' name="' . $name . '"'; |
||
931 | |||
932 | if (isset($var['xpath'])) |
||
933 | $stylesheet['variables'] .= ' select="' . $var['value'] . '"/>'; |
||
934 | else |
||
935 | $stylesheet['variables'] .= '>' . (!empty($var['no_cdata_parse']) ? $var['value'] : cdata_parse($var['value'])) . '</xsl:' . $element . '>'; |
||
936 | } |
||
937 | |||
938 | // The top-level template. Creates the shell of the HTML document. |
||
939 | $stylesheet['html'] = ' |
||
940 | <xsl:template match="/*"> |
||
941 | <xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text> |
||
942 | <html> |
||
943 | <head> |
||
944 | <title> |
||
945 | <xsl:value-of select="@title"/> |
||
946 | </title> |
||
947 | <xsl:call-template name="css_js"/> |
||
948 | </head> |
||
949 | <body> |
||
950 | <div id="footerfix"> |
||
951 | <div id="header"> |
||
952 | <h1 class="forumtitle"> |
||
953 | <a id="top"> |
||
954 | <xsl:attribute name="href"> |
||
955 | <xsl:value-of select="$scripturl"/> |
||
956 | </xsl:attribute> |
||
957 | <xsl:value-of select="@forum-name"/> |
||
958 | </a> |
||
959 | </h1> |
||
960 | </div> |
||
961 | <div id="wrapper"> |
||
962 | <div id="upper_section"> |
||
963 | <div id="inner_section"> |
||
964 | <div id="inner_wrap"> |
||
965 | <div class="user"> |
||
966 | <time> |
||
967 | <xsl:attribute name="datetime"> |
||
968 | <xsl:value-of select="@generated-date-UTC"/> |
||
969 | </xsl:attribute> |
||
970 | <xsl:value-of select="@generated-date-localized"/> |
||
971 | </time> |
||
972 | </div> |
||
973 | <hr class="clear"/> |
||
974 | </div> |
||
975 | </div> |
||
976 | </div> |
||
977 | |||
978 | <xsl:call-template name="content_section"/> |
||
979 | |||
980 | </div> |
||
981 | </div> |
||
982 | <div id="footer"> |
||
983 | <div class="inner_wrap"> |
||
984 | <ul> |
||
985 | <li class="floatright"> |
||
986 | <a> |
||
987 | <xsl:attribute name="href"> |
||
988 | <xsl:value-of select="concat($scripturl, \'?action=help\')"/> |
||
989 | </xsl:attribute> |
||
990 | <xsl:value-of select="$txt_help"/> |
||
991 | </a> |
||
992 | <xsl:text> | </xsl:text> |
||
993 | <a> |
||
994 | <xsl:attribute name="href"> |
||
995 | <xsl:value-of select="concat($scripturl, \'?action=help;sa=rules\')"/> |
||
996 | </xsl:attribute> |
||
997 | <xsl:value-of select="$txt_terms_rules"/> |
||
998 | </a> |
||
999 | <xsl:text> | </xsl:text> |
||
1000 | <a href="#top"> |
||
1001 | <xsl:value-of select="$txt_go_up"/> |
||
1002 | <xsl:text> ▲</xsl:text> |
||
1003 | </a> |
||
1004 | </li> |
||
1005 | <li class="copyright"> |
||
1006 | <xsl:value-of select="$forum_copyright" disable-output-escaping="yes"/> |
||
1007 | </li> |
||
1008 | </ul> |
||
1009 | </div> |
||
1010 | </div> |
||
1011 | </body> |
||
1012 | </html> |
||
1013 | </xsl:template>'; |
||
1014 | |||
1015 | // Template to show the content of the export file. |
||
1016 | $stylesheet['content_section'] = ' |
||
1017 | <xsl:template name="content_section"> |
||
1018 | <div id="content_section"> |
||
1019 | <div id="main_content_section"> |
||
1020 | |||
1021 | <div class="cat_bar"> |
||
1022 | <h3 class="catbg"> |
||
1023 | <xsl:value-of select="@title"/> |
||
1024 | </h3> |
||
1025 | </div> |
||
1026 | <div class="information"> |
||
1027 | <h2 class="display_title"> |
||
1028 | <xsl:value-of select="@description"/> |
||
1029 | </h2> |
||
1030 | </div> |
||
1031 | |||
1032 | <xsl:if test="username"> |
||
1033 | <div class="cat_bar"> |
||
1034 | <h3 class="catbg"> |
||
1035 | <xsl:value-of select="$txt_summary_heading"/> |
||
1036 | </h3> |
||
1037 | </div> |
||
1038 | <div id="profileview" class="roundframe flow_auto noup"> |
||
1039 | <xsl:call-template name="summary"/> |
||
1040 | </div> |
||
1041 | </xsl:if> |
||
1042 | |||
1043 | <xsl:call-template name="page_index"/> |
||
1044 | |||
1045 | <xsl:if test="member_post"> |
||
1046 | <div class="cat_bar"> |
||
1047 | <h3 class="catbg"> |
||
1048 | <xsl:value-of select="$txt_posts_heading"/> |
||
1049 | </h3> |
||
1050 | </div> |
||
1051 | <div id="posts" class="roundframe flow_auto noup"> |
||
1052 | <xsl:apply-templates select="member_post" mode="posts"/> |
||
1053 | </div> |
||
1054 | </xsl:if> |
||
1055 | |||
1056 | <xsl:if test="personal_message"> |
||
1057 | <div class="cat_bar"> |
||
1058 | <h3 class="catbg"> |
||
1059 | <xsl:value-of select="$txt_personal_messages_heading"/> |
||
1060 | </h3> |
||
1061 | </div> |
||
1062 | <div id="personal_messages" class="roundframe flow_auto noup"> |
||
1063 | <xsl:apply-templates select="personal_message" mode="pms"/> |
||
1064 | </div> |
||
1065 | </xsl:if> |
||
1066 | |||
1067 | <xsl:call-template name="page_index"/> |
||
1068 | |||
1069 | </div> |
||
1070 | </div> |
||
1071 | </xsl:template>'; |
||
1072 | |||
1073 | // Template for user profile summary |
||
1074 | $stylesheet['summary'] = ' |
||
1075 | <xsl:template name="summary"> |
||
1076 | <div id="basicinfo"> |
||
1077 | <div class="username clear"> |
||
1078 | <h4> |
||
1079 | <a> |
||
1080 | <xsl:attribute name="href"> |
||
1081 | <xsl:value-of select="link"/> |
||
1082 | </xsl:attribute> |
||
1083 | <xsl:value-of select="name"/> |
||
1084 | </a> |
||
1085 | <xsl:text> </xsl:text> |
||
1086 | <span class="position"> |
||
1087 | <xsl:choose> |
||
1088 | <xsl:when test="position"> |
||
1089 | <xsl:value-of select="position"/> |
||
1090 | </xsl:when> |
||
1091 | <xsl:otherwise> |
||
1092 | <xsl:value-of select="post_group"/> |
||
1093 | </xsl:otherwise> |
||
1094 | </xsl:choose> |
||
1095 | </span> |
||
1096 | </h4> |
||
1097 | </div> |
||
1098 | <img class="avatar"> |
||
1099 | <xsl:attribute name="src"> |
||
1100 | <xsl:value-of select="avatar"/> |
||
1101 | </xsl:attribute> |
||
1102 | </img> |
||
1103 | </div> |
||
1104 | |||
1105 | <div id="detailedinfo"> |
||
1106 | <dl class="settings noborder"> |
||
1107 | <xsl:apply-templates mode="detailedinfo"/> |
||
1108 | </dl> |
||
1109 | </div> |
||
1110 | </xsl:template>'; |
||
1111 | |||
1112 | // Some helper templates for details inside the summary. |
||
1113 | $stylesheet['detail_default'] = ' |
||
1114 | <xsl:template match="*" mode="detailedinfo"> |
||
1115 | <dt> |
||
1116 | <xsl:value-of select="concat(@label, \':\')"/> |
||
1117 | </dt> |
||
1118 | <dd> |
||
1119 | <xsl:value-of select="." disable-output-escaping="yes"/> |
||
1120 | </dd> |
||
1121 | </xsl:template>'; |
||
1122 | |||
1123 | $stylesheet['detail_email'] = ' |
||
1124 | <xsl:template match="email" mode="detailedinfo"> |
||
1125 | <dt> |
||
1126 | <xsl:value-of select="concat(@label, \':\')"/> |
||
1127 | </dt> |
||
1128 | <dd> |
||
1129 | <a> |
||
1130 | <xsl:attribute name="href"> |
||
1131 | <xsl:text>mailto:</xsl:text> |
||
1132 | <xsl:value-of select="."/> |
||
1133 | </xsl:attribute> |
||
1134 | <xsl:value-of select="."/> |
||
1135 | </a> |
||
1136 | </dd> |
||
1137 | </xsl:template>'; |
||
1138 | |||
1139 | $stylesheet['detail_website'] = ' |
||
1140 | <xsl:template match="website" mode="detailedinfo"> |
||
1141 | <dt> |
||
1142 | <xsl:value-of select="concat(@label, \':\')"/> |
||
1143 | </dt> |
||
1144 | <dd> |
||
1145 | <a> |
||
1146 | <xsl:attribute name="href"> |
||
1147 | <xsl:value-of select="link"/> |
||
1148 | </xsl:attribute> |
||
1149 | <xsl:value-of select="title"/> |
||
1150 | </a> |
||
1151 | </dd> |
||
1152 | </xsl:template>'; |
||
1153 | |||
1154 | $stylesheet['detail_ip'] = ' |
||
1155 | <xsl:template match="ip_addresses" mode="detailedinfo"> |
||
1156 | <dt> |
||
1157 | <xsl:value-of select="concat(@label, \':\')"/> |
||
1158 | </dt> |
||
1159 | <dd> |
||
1160 | <ul class="nolist"> |
||
1161 | <xsl:apply-templates mode="ip_address"/> |
||
1162 | </ul> |
||
1163 | </dd> |
||
1164 | </xsl:template> |
||
1165 | <xsl:template match="*" mode="ip_address"> |
||
1166 | <li> |
||
1167 | <xsl:value-of select="."/> |
||
1168 | <xsl:if test="@label and following-sibling"> |
||
1169 | <xsl:text> </xsl:text> |
||
1170 | <span>(<xsl:value-of select="@label"/>)</span> |
||
1171 | </xsl:if> |
||
1172 | </li> |
||
1173 | </xsl:template>'; |
||
1174 | |||
1175 | $stylesheet['detail_not_included'] = ' |
||
1176 | <xsl:template match="name|link|avatar|online|member_post|personal_message" mode="detailedinfo"/>'; |
||
1177 | |||
1178 | // Template for printing a single post |
||
1179 | $stylesheet['member_post'] = ' |
||
1180 | <xsl:template match="member_post" mode="posts"> |
||
1181 | <div> |
||
1182 | <xsl:attribute name="id"> |
||
1183 | <xsl:value-of select="concat(\'member_post_\', id)"/> |
||
1184 | </xsl:attribute> |
||
1185 | <xsl:attribute name="class"> |
||
1186 | <xsl:choose> |
||
1187 | <xsl:when test="approval_status = 1"> |
||
1188 | <xsl:text>windowbg</xsl:text> |
||
1189 | </xsl:when> |
||
1190 | <xsl:otherwise> |
||
1191 | <xsl:text>approvebg</xsl:text> |
||
1192 | </xsl:otherwise> |
||
1193 | </xsl:choose> |
||
1194 | </xsl:attribute> |
||
1195 | |||
1196 | <div class="post_wrapper"> |
||
1197 | <div class="poster"> |
||
1198 | <h4> |
||
1199 | <a> |
||
1200 | <xsl:attribute name="href"> |
||
1201 | <xsl:value-of select="poster/link"/> |
||
1202 | </xsl:attribute> |
||
1203 | <xsl:value-of select="poster/name"/> |
||
1204 | </a> |
||
1205 | </h4> |
||
1206 | <ul class="user_info"> |
||
1207 | <xsl:if test="poster/id = $member_id"> |
||
1208 | <xsl:call-template name="own_user_info"/> |
||
1209 | </xsl:if> |
||
1210 | <li> |
||
1211 | <xsl:value-of select="poster/email"/> |
||
1212 | </li> |
||
1213 | <li class="poster_ip"> |
||
1214 | <xsl:value-of select="concat(poster/ip/@label, \': \')"/> |
||
1215 | <xsl:value-of select="poster/ip"/> |
||
1216 | </li> |
||
1217 | </ul> |
||
1218 | </div> |
||
1219 | |||
1220 | <div class="postarea"> |
||
1221 | <div class="flow_hidden"> |
||
1222 | |||
1223 | <div class="keyinfo"> |
||
1224 | <h5> |
||
1225 | <strong> |
||
1226 | <a> |
||
1227 | <xsl:attribute name="href"> |
||
1228 | <xsl:value-of select="board/link"/> |
||
1229 | </xsl:attribute> |
||
1230 | <xsl:value-of select="board/name"/> |
||
1231 | </a> |
||
1232 | <xsl:text> / </xsl:text> |
||
1233 | <a> |
||
1234 | <xsl:attribute name="href"> |
||
1235 | <xsl:value-of select="link"/> |
||
1236 | </xsl:attribute> |
||
1237 | <xsl:value-of select="subject"/> |
||
1238 | </a> |
||
1239 | </strong> |
||
1240 | </h5> |
||
1241 | <span class="smalltext"><xsl:value-of select="time"/></span> |
||
1242 | <xsl:if test="modified_time"> |
||
1243 | <span class="smalltext modified floatright mvisible em"> |
||
1244 | <xsl:attribute name="id"> |
||
1245 | <xsl:value-of select="concat(\'modified_\', id)"/> |
||
1246 | </xsl:attribute> |
||
1247 | <span class="lastedit"> |
||
1248 | <xsl:value-of select="modified_time/@label"/> |
||
1249 | </span> |
||
1250 | <xsl:text>: </xsl:text> |
||
1251 | <xsl:value-of select="modified_time"/> |
||
1252 | <xsl:text>. </xsl:text> |
||
1253 | <xsl:value-of select="modified_by/@label"/> |
||
1254 | <xsl:text>: </xsl:text> |
||
1255 | <xsl:value-of select="modified_by"/> |
||
1256 | <xsl:text>. </xsl:text> |
||
1257 | </span> |
||
1258 | </xsl:if> |
||
1259 | </div> |
||
1260 | |||
1261 | <div class="post"> |
||
1262 | <div class="inner"> |
||
1263 | <xsl:value-of select="body_html" disable-output-escaping="yes"/> |
||
1264 | </div> |
||
1265 | <div class="inner monospace" style="display:none;"> |
||
1266 | <xsl:choose> |
||
1267 | <xsl:when test="contains(body/text(), \'[html]\')"> |
||
1268 | <xsl:call-template name="bbc_html_splitter"> |
||
1269 | <xsl:with-param name="bbc_string" select="body/text()"/> |
||
1270 | </xsl:call-template> |
||
1271 | </xsl:when> |
||
1272 | <xsl:otherwise> |
||
1273 | <xsl:value-of select="body" disable-output-escaping="yes"/> |
||
1274 | </xsl:otherwise> |
||
1275 | </xsl:choose> |
||
1276 | </div> |
||
1277 | </div> |
||
1278 | |||
1279 | <xsl:apply-templates select="attachments"> |
||
1280 | <xsl:with-param name="post_id" select="id"/> |
||
1281 | </xsl:apply-templates> |
||
1282 | |||
1283 | <div class="under_message"> |
||
1284 | <ul class="floatleft"> |
||
1285 | <xsl:if test="likes > 0"> |
||
1286 | <li class="smflikebutton"> |
||
1287 | <xsl:attribute name="id"> |
||
1288 | <xsl:value-of select="concat(\'msg_\', id, \'_likes\')"/> |
||
1289 | </xsl:attribute> |
||
1290 | <span><span class="main_icons like"></span> <xsl:value-of select="likes"/></span> |
||
1291 | </li> |
||
1292 | </xsl:if> |
||
1293 | </ul> |
||
1294 | <xsl:call-template name="quickbuttons"> |
||
1295 | <xsl:with-param name="toggle_target" select="concat(\'member_post_\', id)"/> |
||
1296 | </xsl:call-template> |
||
1297 | </div> |
||
1298 | |||
1299 | </div> |
||
1300 | </div> |
||
1301 | |||
1302 | <div class="moderatorbar"> |
||
1303 | <xsl:if test="poster/id = $member_id"> |
||
1304 | <xsl:call-template name="signature"/> |
||
1305 | </xsl:if> |
||
1306 | </div> |
||
1307 | |||
1308 | </div> |
||
1309 | </div> |
||
1310 | </xsl:template>'; |
||
1311 | |||
1312 | // Template for printing a single PM |
||
1313 | $stylesheet['personal_message'] = ' |
||
1314 | <xsl:template match="personal_message" mode="pms"> |
||
1315 | <div class="windowbg"> |
||
1316 | <xsl:attribute name="id"> |
||
1317 | <xsl:value-of select="concat(\'personal_message_\', id)"/> |
||
1318 | </xsl:attribute> |
||
1319 | |||
1320 | <div class="post_wrapper"> |
||
1321 | <div class="poster"> |
||
1322 | <h4> |
||
1323 | <a> |
||
1324 | <xsl:attribute name="href"> |
||
1325 | <xsl:value-of select="sender/link"/> |
||
1326 | </xsl:attribute> |
||
1327 | <xsl:value-of select="sender/name"/> |
||
1328 | </a> |
||
1329 | </h4> |
||
1330 | <ul class="user_info"> |
||
1331 | <xsl:if test="sender/id = $member_id"> |
||
1332 | <xsl:call-template name="own_user_info"/> |
||
1333 | </xsl:if> |
||
1334 | </ul> |
||
1335 | </div> |
||
1336 | |||
1337 | <div class="postarea"> |
||
1338 | <div class="flow_hidden"> |
||
1339 | |||
1340 | <div class="keyinfo"> |
||
1341 | <h5> |
||
1342 | <xsl:attribute name="id"> |
||
1343 | <xsl:value-of select="concat(\'subject_\', id)"/> |
||
1344 | </xsl:attribute> |
||
1345 | <xsl:value-of select="subject"/> |
||
1346 | </h5> |
||
1347 | <span class="smalltext"> |
||
1348 | <strong> |
||
1349 | <xsl:value-of select="concat(recipient[1]/@label, \': \')"/> |
||
1350 | </strong> |
||
1351 | <xsl:apply-templates select="recipient"/> |
||
1352 | </span> |
||
1353 | <br/> |
||
1354 | <span class="smalltext"> |
||
1355 | <strong> |
||
1356 | <xsl:value-of select="concat(sent_date/@label, \': \')"/> |
||
1357 | </strong> |
||
1358 | <time> |
||
1359 | <xsl:attribute name="datetime"> |
||
1360 | <xsl:value-of select="sent_date/@UTC"/> |
||
1361 | </xsl:attribute> |
||
1362 | <xsl:value-of select="normalize-space(sent_date)"/> |
||
1363 | </time> |
||
1364 | </span> |
||
1365 | </div> |
||
1366 | |||
1367 | <div class="post"> |
||
1368 | <div class="inner"> |
||
1369 | <xsl:value-of select="body_html" disable-output-escaping="yes"/> |
||
1370 | </div> |
||
1371 | <div class="inner monospace" style="display:none;"> |
||
1372 | <xsl:call-template name="bbc_html_splitter"> |
||
1373 | <xsl:with-param name="bbc_string" select="body/text()"/> |
||
1374 | </xsl:call-template> |
||
1375 | </div> |
||
1376 | </div> |
||
1377 | |||
1378 | <div class="under_message"> |
||
1379 | <xsl:call-template name="quickbuttons"> |
||
1380 | <xsl:with-param name="toggle_target" select="concat(\'personal_message_\', id)"/> |
||
1381 | </xsl:call-template> |
||
1382 | </div> |
||
1383 | |||
1384 | </div> |
||
1385 | </div> |
||
1386 | |||
1387 | <div class="moderatorbar"> |
||
1388 | <xsl:if test="sender/id = $member_id"> |
||
1389 | <xsl:call-template name="signature"/> |
||
1390 | </xsl:if> |
||
1391 | </div> |
||
1392 | |||
1393 | </div> |
||
1394 | </div> |
||
1395 | </xsl:template>'; |
||
1396 | |||
1397 | // A couple of templates to handle attachments |
||
1398 | $stylesheet['attachments'] = ' |
||
1399 | <xsl:template match="attachments"> |
||
1400 | <xsl:param name="post_id"/> |
||
1401 | <xsl:if test="attachment"> |
||
1402 | <div class="attachments"> |
||
1403 | <xsl:attribute name="id"> |
||
1404 | <xsl:value-of select="concat(\'msg_\', $post_id, \'_footer\')"/> |
||
1405 | </xsl:attribute> |
||
1406 | <xsl:apply-templates/> |
||
1407 | </div> |
||
1408 | </xsl:if> |
||
1409 | </xsl:template> |
||
1410 | <xsl:template match="attachment"> |
||
1411 | <div class="attached"> |
||
1412 | <div class="attachments_bot"> |
||
1413 | <a> |
||
1414 | <xsl:attribute name="href"> |
||
1415 | <xsl:value-of select="concat(id, \' - \', name)"/> |
||
1416 | </xsl:attribute> |
||
1417 | <img class="centericon" alt="*"> |
||
1418 | <xsl:attribute name="src"> |
||
1419 | <xsl:value-of select="concat($themeurl, \'/images/icons/clip.png\')"/> |
||
1420 | </xsl:attribute> |
||
1421 | </img> |
||
1422 | <xsl:text> </xsl:text> |
||
1423 | <xsl:value-of select="name"/> |
||
1424 | </a> |
||
1425 | <br/> |
||
1426 | <xsl:text>(</xsl:text> |
||
1427 | <a class="bbc_link"> |
||
1428 | <xsl:attribute name="href"> |
||
1429 | <xsl:value-of select="concat($scripturl, \'?action=profile;area=dlattach;u=\', $member_id, \';attach=\', id, \';t=\', $dltoken)"/> |
||
1430 | </xsl:attribute> |
||
1431 | <xsl:value-of select="$txt_download_original"/> |
||
1432 | </a> |
||
1433 | <xsl:text>)</xsl:text> |
||
1434 | <br/> |
||
1435 | <xsl:value-of select="size/@label"/> |
||
1436 | <xsl:text>: </xsl:text> |
||
1437 | <xsl:value-of select="size"/> |
||
1438 | <br/> |
||
1439 | <xsl:value-of select="downloads/@label"/> |
||
1440 | <xsl:text>: </xsl:text> |
||
1441 | <xsl:value-of select="downloads"/> |
||
1442 | </div> |
||
1443 | </div> |
||
1444 | </xsl:template>'; |
||
1445 | |||
1446 | // Helper template for printing the user's own info next to the post or personal message. |
||
1447 | $stylesheet['own_user_info'] = ' |
||
1448 | <xsl:template name="own_user_info"> |
||
1449 | <xsl:if test="/*/avatar"> |
||
1450 | <li class="avatar"> |
||
1451 | <a> |
||
1452 | <xsl:attribute name="href"> |
||
1453 | <xsl:value-of select="/*/link"/> |
||
1454 | </xsl:attribute> |
||
1455 | <img class="avatar"> |
||
1456 | <xsl:attribute name="src"> |
||
1457 | <xsl:value-of select="/*/avatar"/> |
||
1458 | </xsl:attribute> |
||
1459 | </img> |
||
1460 | </a> |
||
1461 | </li> |
||
1462 | </xsl:if> |
||
1463 | <li class="membergroup"> |
||
1464 | <xsl:value-of select="/*/position"/> |
||
1465 | </li> |
||
1466 | <xsl:if test="/*/title"> |
||
1467 | <li class="title"> |
||
1468 | <xsl:value-of select="/*/title"/> |
||
1469 | </li> |
||
1470 | </xsl:if> |
||
1471 | <li class="postgroup"> |
||
1472 | <xsl:value-of select="/*/post_group"/> |
||
1473 | </li> |
||
1474 | <li class="postcount"> |
||
1475 | <xsl:value-of select="concat(/*/posts/@label, \': \')"/> |
||
1476 | <xsl:value-of select="/*/posts"/> |
||
1477 | </li> |
||
1478 | <xsl:if test="/*/blurb"> |
||
1479 | <li class="blurb"> |
||
1480 | <xsl:value-of select="/*/blurb"/> |
||
1481 | </li> |
||
1482 | </xsl:if> |
||
1483 | </xsl:template>'; |
||
1484 | |||
1485 | // Helper template for printing the quickbuttons |
||
1486 | $stylesheet['quickbuttons'] = ' |
||
1487 | <xsl:template name="quickbuttons"> |
||
1488 | <xsl:param name="toggle_target"/> |
||
1489 | <ul class="quickbuttons quickbuttons_post sf-js-enabled sf-arrows" style="touch-action: pan-y;"> |
||
1490 | <li> |
||
1491 | <a> |
||
1492 | <xsl:attribute name="onclick"> |
||
1493 | <xsl:text>$(\'#</xsl:text> |
||
1494 | <xsl:value-of select="$toggle_target"/> |
||
1495 | <xsl:text> .inner\').toggle();</xsl:text> |
||
1496 | </xsl:attribute> |
||
1497 | <xsl:value-of select="$txt_view_source_button"/> |
||
1498 | </a> |
||
1499 | </li> |
||
1500 | </ul> |
||
1501 | </xsl:template>'; |
||
1502 | |||
1503 | // Helper template for printing a signature |
||
1504 | $stylesheet['signature'] = ' |
||
1505 | <xsl:template name="signature"> |
||
1506 | <xsl:if test="/*/signature"> |
||
1507 | <div class="signature"> |
||
1508 | <xsl:value-of select="/*/signature" disable-output-escaping="yes"/> |
||
1509 | </div> |
||
1510 | </xsl:if> |
||
1511 | </xsl:template>'; |
||
1512 | |||
1513 | // Helper template for printing a list of PM recipients |
||
1514 | $stylesheet['recipient'] = ' |
||
1515 | <xsl:template match="recipient"> |
||
1516 | <a> |
||
1517 | <xsl:attribute name="href"> |
||
1518 | <xsl:value-of select="link"/> |
||
1519 | </xsl:attribute> |
||
1520 | <xsl:value-of select="name"/> |
||
1521 | </a> |
||
1522 | <xsl:choose> |
||
1523 | <xsl:when test="following-sibling::recipient"> |
||
1524 | <xsl:text>, </xsl:text> |
||
1525 | </xsl:when> |
||
1526 | <xsl:otherwise> |
||
1527 | <xsl:text>. </xsl:text> |
||
1528 | </xsl:otherwise> |
||
1529 | </xsl:choose> |
||
1530 | </xsl:template>'; |
||
1531 | |||
1532 | // Helper template for special handling of the contents of the [html] BBCode |
||
1533 | $stylesheet['bbc_html'] = ' |
||
1534 | <xsl:template name="bbc_html_splitter"> |
||
1535 | <xsl:param name="bbc_string"/> |
||
1536 | <xsl:param name="inside_outside" select="outside"/> |
||
1537 | <xsl:choose> |
||
1538 | <xsl:when test="$inside_outside = \'outside\'"> |
||
1539 | <xsl:choose> |
||
1540 | <xsl:when test="contains($bbc_string, \'[html]\')"> |
||
1541 | <xsl:variable name="following_string"> |
||
1542 | <xsl:value-of select="substring-after($bbc_string, \'[html]\')" disable-output-escaping="yes"/> |
||
1543 | </xsl:variable> |
||
1544 | <xsl:value-of select="substring-before($bbc_string, \'[html]\')" disable-output-escaping="yes"/> |
||
1545 | <xsl:text>[html]</xsl:text> |
||
1546 | <xsl:call-template name="bbc_html_splitter"> |
||
1547 | <xsl:with-param name="bbc_string" select="$following_string"/> |
||
1548 | <xsl:with-param name="inside_outside" select="inside"/> |
||
1549 | </xsl:call-template> |
||
1550 | </xsl:when> |
||
1551 | <xsl:otherwise> |
||
1552 | <xsl:value-of select="$bbc_string" disable-output-escaping="yes"/> |
||
1553 | </xsl:otherwise> |
||
1554 | </xsl:choose> |
||
1555 | </xsl:when> |
||
1556 | <xsl:otherwise> |
||
1557 | <xsl:choose> |
||
1558 | <xsl:when test="contains($bbc_string, \'[/html]\')"> |
||
1559 | <xsl:variable name="following_string"> |
||
1560 | <xsl:value-of select="substring-after($bbc_string, \'[/html]\')" disable-output-escaping="yes"/> |
||
1561 | </xsl:variable> |
||
1562 | <xsl:value-of select="substring-before($bbc_string, \'[/html]\')" disable-output-escaping="no"/> |
||
1563 | <xsl:text>[/html]</xsl:text> |
||
1564 | <xsl:call-template name="bbc_html_splitter"> |
||
1565 | <xsl:with-param name="bbc_string" select="$following_string"/> |
||
1566 | <xsl:with-param name="inside_outside" select="outside"/> |
||
1567 | </xsl:call-template> |
||
1568 | </xsl:when> |
||
1569 | <xsl:otherwise> |
||
1570 | <xsl:value-of select="$bbc_string" disable-output-escaping="no"/> |
||
1571 | </xsl:otherwise> |
||
1572 | </xsl:choose> |
||
1573 | </xsl:otherwise> |
||
1574 | </xsl:choose> |
||
1575 | </xsl:template>'; |
||
1576 | |||
1577 | // Helper templates to build a page index |
||
1578 | $stylesheet['page_index'] = ' |
||
1579 | <xsl:template name="page_index"> |
||
1580 | <xsl:variable name="current_page" select="/*/@page"/> |
||
1581 | <xsl:variable name="prev_page" select="/*/@page - 1"/> |
||
1582 | <xsl:variable name="next_page" select="/*/@page + 1"/> |
||
1583 | |||
1584 | <div class="pagesection"> |
||
1585 | <div class="pagelinks floatleft"> |
||
1586 | |||
1587 | <span class="pages"> |
||
1588 | <xsl:value-of select="$txt_pages"/> |
||
1589 | </span> |
||
1590 | |||
1591 | <xsl:if test="$current_page > 1"> |
||
1592 | <a class="nav_page"> |
||
1593 | <xsl:attribute name="href"> |
||
1594 | <xsl:value-of select="concat($dlfilename, \'_\', $prev_page, \'.\', $ext)"/> |
||
1595 | </xsl:attribute> |
||
1596 | <span class="main_icons previous_page"></span> |
||
1597 | </a> |
||
1598 | </xsl:if> |
||
1599 | |||
1600 | <xsl:call-template name="page_links"/> |
||
1601 | |||
1602 | <xsl:if test="$current_page < $last_page"> |
||
1603 | <a class="nav_page"> |
||
1604 | <xsl:attribute name="href"> |
||
1605 | <xsl:value-of select="concat($dlfilename, \'_\', $next_page, \'.\', $ext)"/> |
||
1606 | </xsl:attribute> |
||
1607 | <span class="main_icons next_page"></span> |
||
1608 | </a> |
||
1609 | </xsl:if> |
||
1610 | </div> |
||
1611 | </div> |
||
1612 | </xsl:template> |
||
1613 | |||
1614 | <xsl:template name="page_links"> |
||
1615 | <xsl:param name="page_num" select="1"/> |
||
1616 | <xsl:variable name="current_page" select="/*/@page"/> |
||
1617 | <xsl:variable name="prev_page" select="/*/@page - 1"/> |
||
1618 | <xsl:variable name="next_page" select="/*/@page + 1"/> |
||
1619 | |||
1620 | <xsl:choose> |
||
1621 | <xsl:when test="$page_num = $current_page"> |
||
1622 | <span class="current_page"> |
||
1623 | <xsl:value-of select="$page_num"/> |
||
1624 | </span> |
||
1625 | </xsl:when> |
||
1626 | <xsl:when test="$page_num = 1 or $page_num = ($current_page - 1) or $page_num = ($current_page + 1) or $page_num = $last_page"> |
||
1627 | <a class="nav_page"> |
||
1628 | <xsl:attribute name="href"> |
||
1629 | <xsl:value-of select="concat($dlfilename, \'_\', $page_num, \'.\', $ext)"/> |
||
1630 | </xsl:attribute> |
||
1631 | <xsl:value-of select="$page_num"/> |
||
1632 | </a> |
||
1633 | </xsl:when> |
||
1634 | <xsl:when test="$page_num = 2 or $page_num = ($current_page + 2)"> |
||
1635 | <span class="expand_pages" onclick="$(\'.nav_page\').removeClass(\'hidden\'); $(\'.expand_pages\').hide();"> ... </span> |
||
1636 | <a class="nav_page hidden"> |
||
1637 | <xsl:attribute name="href"> |
||
1638 | <xsl:value-of select="concat($dlfilename, \'_\', $page_num, \'.\', $ext)"/> |
||
1639 | </xsl:attribute> |
||
1640 | <xsl:value-of select="$page_num"/> |
||
1641 | </a> |
||
1642 | </xsl:when> |
||
1643 | <xsl:otherwise> |
||
1644 | <a class="nav_page hidden"> |
||
1645 | <xsl:attribute name="href"> |
||
1646 | <xsl:value-of select="concat($dlfilename, \'_\', $page_num, \'.\', $ext)"/> |
||
1647 | </xsl:attribute> |
||
1648 | <xsl:value-of select="$page_num"/> |
||
1649 | </a> |
||
1650 | </xsl:otherwise> |
||
1651 | </xsl:choose> |
||
1652 | |||
1653 | <xsl:text> </xsl:text> |
||
1654 | |||
1655 | <xsl:if test="$page_num < $last_page"> |
||
1656 | <xsl:call-template name="page_links"> |
||
1657 | <xsl:with-param name="page_num" select="$page_num + 1"/> |
||
1658 | </xsl:call-template> |
||
1659 | </xsl:if> |
||
1660 | </xsl:template>'; |
||
1661 | |||
1662 | // Template to insert CSS and JavaScript |
||
1663 | $stylesheet['css_js'] = ' |
||
1664 | <xsl:template name="css_js">'; |
||
1665 | |||
1666 | export_load_css_js(); |
||
1667 | |||
1668 | if (!empty($context['export_css_files'])) |
||
1669 | { |
||
1670 | foreach ($context['export_css_files'] as $css_file) |
||
1671 | { |
||
1672 | $stylesheet['css_js'] .= ' |
||
1673 | <link rel="stylesheet"> |
||
1674 | <xsl:attribute name="href"> |
||
1675 | <xsl:text>' . $css_file['fileUrl'] . '</xsl:text> |
||
1676 | </xsl:attribute>'; |
||
1677 | |||
1678 | if (!empty($css_file['options']['attributes'])) |
||
1679 | { |
||
1680 | foreach ($css_file['options']['attributes'] as $key => $value) |
||
1681 | $stylesheet['css_js'] .= ' |
||
1682 | <xsl:attribute name="' . $key . '"> |
||
1683 | <xsl:text>' . (is_bool($value) ? $key : $value) . '</xsl:text> |
||
1684 | </xsl:attribute>'; |
||
1685 | } |
||
1686 | |||
1687 | $stylesheet['css_js'] .= ' |
||
1688 | </link>'; |
||
1689 | } |
||
1690 | } |
||
1691 | |||
1692 | if (!empty($context['export_css_header'])) |
||
1693 | { |
||
1694 | $stylesheet['css_js'] .= ' |
||
1695 | <style><![CDATA[' . "\n" . implode("\n", $context['export_css_header']) . "\n" . ']]> |
||
1696 | </style>'; |
||
1697 | } |
||
1698 | |||
1699 | if (!empty($context['export_javascript_vars'])) |
||
1700 | { |
||
1701 | $stylesheet['css_js'] .= ' |
||
1702 | <script><![CDATA['; |
||
1703 | |||
1704 | foreach ($context['export_javascript_vars'] as $var => $val) |
||
1705 | $stylesheet['css_js'] .= "\nvar " . $var . (!empty($val) ? ' = ' . $val : '') . ';'; |
||
1706 | |||
1707 | $stylesheet['css_js'] .= "\n" . ']]> |
||
1708 | </script>'; |
||
1709 | } |
||
1710 | |||
1711 | if (!empty($context['export_javascript_files'])) |
||
1712 | { |
||
1713 | foreach ($context['export_javascript_files'] as $js_file) |
||
1714 | { |
||
1715 | $stylesheet['css_js'] .= ' |
||
1716 | <script> |
||
1717 | <xsl:attribute name="src"> |
||
1718 | <xsl:text>' . $js_file['fileUrl'] . '</xsl:text> |
||
1719 | </xsl:attribute>'; |
||
1720 | |||
1721 | if (!empty($js_file['options']['attributes'])) |
||
1722 | { |
||
1723 | foreach ($js_file['options']['attributes'] as $key => $value) |
||
1724 | $stylesheet['css_js'] .= ' |
||
1725 | <xsl:attribute name="' . $key . '"> |
||
1726 | <xsl:text>' . (is_bool($value) ? $key : $value) . '</xsl:text> |
||
1727 | </xsl:attribute>'; |
||
1728 | } |
||
1729 | |||
1730 | $stylesheet['css_js'] .= ' |
||
1731 | </script>'; |
||
1732 | } |
||
1733 | } |
||
1734 | |||
1735 | if (!empty($context['export_javascript_inline']['standard'])) |
||
1736 | { |
||
1737 | $stylesheet['css_js'] .= ' |
||
1738 | <script><![CDATA[' . "\n" . implode("\n", $context['export_javascript_inline']['standard']) . "\n" . ']]> |
||
1739 | </script>'; |
||
1740 | } |
||
1741 | |||
1742 | if (!empty($context['export_javascript_inline']['defer'])) |
||
1743 | { |
||
1744 | $stylesheet['css_js'] .= ' |
||
1745 | <script><![CDATA[' . "\n" . 'window.addEventListener("DOMContentLoaded", function() {'; |
||
1746 | |||
1747 | $stylesheet['css_js'] .= "\n\t" . str_replace("\n", "\n\t", implode("\n", $context['export_javascript_inline']['defer'])); |
||
1748 | |||
1749 | $stylesheet['css_js'] .= "\n" . '});'. "\n" . ']]> |
||
1750 | </script>'; |
||
1751 | } |
||
1752 | |||
1753 | $stylesheet['css_js'] .= ' |
||
1754 | </xsl:template>'; |
||
1755 | |||
1756 | // End of the XSLT stylesheet |
||
1757 | $stylesheet['footer'] = ($format == 'XML_XSLT' ? "\t" : '') . '</xsl:stylesheet>'; |
||
1758 | } |
||
1759 | |||
1760 | // Let mods adjust the XSLT stylesheet. |
||
1761 | call_integration_hook('integrate_export_xslt_stylesheet', array(&$stylesheet, $format)); |
||
1762 | |||
1763 | // Remember for later. |
||
1764 | $xslt_key = isset($xslt_key) ? $xslt_key : $smcFunc['json_encode'](array($format, $uid, $xslt_variables)); |
||
1765 | $xslts[$xslt_key] = array('stylesheet' => implode("\n", (array) $stylesheet), 'dtd' => $dtd); |
||
1766 | |||
1767 | return $xslts[$xslt_key]; |
||
1768 | } |
||
1957 | ?> |