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