问:
Proper LogoutRequest for Single Logout with ADFS IdP
I'm successfully using OneLogin java-saml library for SAML SSO. But there are problems with SLO (Single Logout) with Active Directory Federation Service (ADFS). LogoutRequest created by the library is rejected by ADFS, while it is accepted by SimpleSAMLphp IdP. I pass both nameId and sessionIndex received from ADFS in Response at LogoutRequest creation.

Here are generated requests and received responses:

AuthNRequest:

```<code><samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="ONELOGIN_a80567d6-8957-482b-90e9-99d1b40ec8b1" Version="2.0" IssueInstant="2017-05-31T15:43:07Z" ProviderName="My Company Service Provider" Destination="https://wintest.mycompany.test/adfs/ls/" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="https://localhost:8443/builder/login_check_sso">
   <saml:Issuer>http://localhost:4568/sso/saml/metadata</saml:Issuer>
   <samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" AllowCreate="true" />
   <samlp:RequestedAuthnContext Comparison="exact">
      <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml:AuthnContextClassRef>
   </samlp:RequestedAuthnContext>
</samlp:AuthnRequest>
</code>```

Response:

```<code><samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" Destination="https://localhost:8443/builder/login_check_sso" ID="_f5ea3a59-92f9-4b22-aaf0-36ed392df051" InResponseTo="ONELOGIN_a80567d6-8957-482b-90e9-99d1b40ec8b1" IssueInstant="2017-05-31T15:43:10.158Z" Version="2.0">
   <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://wintest.mycompany.test/adfs/services/trust</Issuer>
   <samlp:Status>
      <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
   </samlp:Status>
   <Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe" IssueInstant="2017-05-31T15:43:10.158Z" Version="2.0">
      <Issuer>http://wintest.mycompany.test/adfs/services/trust</Issuer>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
         <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
            <ds:Reference URI="#_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe">
               <ds:Transforms>
                  <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                  <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
               </ds:Transforms>
               <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
               <ds:DigestValue>FNwbMonYZBBvTXSRbCWP7WxZgPZPSCcCFZozok9eRK4=</ds:DigestValue>
            </ds:Reference>
         </ds:SignedInfo>
         <ds:SignatureValue>fG1SIq3azZfBFQ+5YBBruuCQ03sLIHJ/YpK/AAOYkyJKXEZ5+SvNLgl+8/3a6Tk8mabZmwmawoJRf5UPb+fNtk+CeeWJ7kiUYcb2uvB4ic7Qd4qB+OgfqK0qVCkn9FWGEODLXA6v4tXWBZfSnzDrHEg7xLHrngesSnffY3uyQvH/rm4G2Vjd59LUeUtpJo2X5ZjVuk4sT5r21+UxpNU9LX8z7hXAZHhD1o4d2dqAs21tAGoid3p0RgNDy1WWGh1WSjFLHPDh220ZIchRFKveJE3R9M9nTKtOFESQsYc6TfmhJ5+Xm/j0VY7vvdhgguyq4MKzcPFK6tBL7I8KREck/Q==</ds:SignatureValue>
         <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <ds:X509Data>
               <ds:X509Certificate>MIIC4DCCAcigAwIBAgIQawxJmIMxo49K2BnRDsVfGDANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwHhcNMTcwNDIwMTIxNzUyWhcNMTgwNDIwMTIxNzUyWjAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLUb41Ui5/ytBky/npDW5eV6gQhR7WZ3KJs/JEHEN+pbyNRYZXDY3zXIXcUDRMMdDUnewOisNN4iAMHDri/J7c2zBa05XReyQarnTBDPuiB2Hex6pxA486Mk5KqW8MGB2oWexCM+g1VXiaaSJEOHTb0V+GOhYHcDckNOfnBCKehqnYxqAmJp5WHzmU7IZWNb5P6tl92EfbdATA5fU29dkKVoYDGQJqdDDeLDI1mzxyMENce3v8JER9cnTW7zC2k4hD0TYafF3xphn2yLpnqnGEgbHDla9vdDMqX82+L4DSt4747kEdpc4+V9wwrkOnM5Cz5KKHyzQqzOS91CorCJI/AgMBAAEwDQYJKoZIhvcNAQELBQADggEBACdbOOfVkVNgaPzD+o60HHytR2MzbPcksKq1tZnS++nR+KM5Vo9FiH3LQ8BUulv8sEEq3ITeiLo92fMRySwiaftunLAAEYdBDTIbdi/fUJgLBoCVkDQvdtlRpnunr1KY7ILhKq4w9eQ0I5M5RDZlY2g3LEbyZpFknV1P1Ykx4d/re7BP42kt6JvY8SeA6TnfzgoQUGRBP7DAHiJ3J/HFPQZUvhqpKf6b5SEFMiSczx7wT1/CManyQ9rxOc0rycbGOcIuMNvxCipKWHsBwxvX021uXojhiSx37VxHWSNyWx5HA60GKkOolK8z2xZ/kdXmn5lxaRvH1P169Cd6HrjKzes=</ds:X509Certificate>
            </ds:X509Data>
         </KeyInfo>
      </ds:Signature>
      <Subject>
         <NameID>hamilton1@mycompany.test</NameID>
         <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
            <SubjectConfirmationData InResponseTo="ONELOGIN_a80567d6-8957-482b-90e9-99d1b40ec8b1" NotOnOrAfter="2017-05-31T15:48:10.158Z" Recipient="https://localhost:8443/builder/login_check_sso" />
         </SubjectConfirmation>
      </Subject>
      <Conditions NotBefore="2017-05-31T15:43:10.158Z" NotOnOrAfter="2017-05-31T16:43:10.158Z">
         <AudienceRestriction>
            <Audience>http://localhost:4568/sso/saml/metadata</Audience>
         </AudienceRestriction>
      </Conditions>
      <AttributeStatement>
         <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
            <AttributeValue>hamilton@mycompany.com</AttributeValue>
         </Attribute>
      </AttributeStatement>
      <AuthnStatement AuthnInstant="2017-05-31T12:18:50.194Z" SessionIndex="_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe">
         <AuthnContext>
            <AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
         </AuthnContext>
      </AuthnStatement>
   </Assertion>
</samlp:Response>
</code>```

LogoutRequest:

```<code><samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="ONELOGIN_947f5e64-8423-4464-b4b0-fa416dfe62a0" Version="2.0" IssueInstant="2017-05-31T15:43:18Z" Destination="https://wintest.mycompany.test/adfs/ls/">
   <saml:Issuer>http://localhost:4568/sso/saml/metadata</saml:Issuer>
   <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">hamilton1@mycompany.test</saml:NameID>
   <samlp:SessionIndex>_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe</samlp:SessionIndex>
</samlp:LogoutRequest>
</code>```

LogoutResponse:

```<code><samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_1b3e8c81-2aba-45be-8fe6-54edda514d51" Version="2.0" IssueInstant="2017-05-31T15:43:24.808Z" Destination="https://localhost:8443/builder/logout_sso" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" InResponseTo="ONELOGIN_947f5e64-8423-4464-b4b0-fa416dfe62a0">
   <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://wintest.mycompany.test/adfs/services/trust</Issuer>
   <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
      <ds:SignedInfo>
         <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
         <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
         <ds:Reference URI="#_1b3e8c81-2aba-45be-8fe6-54edda514d51">
            <ds:Transforms>
               <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
               <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </ds:Transforms>
            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
            <ds:DigestValue>NDfLVWPkh2/UCEbLQ6V97OK2u4pajv3aLB9cPs5JkSc=</ds:DigestValue>
         </ds:Reference>
      </ds:SignedInfo>
      <ds:SignatureValue>M1JaIz/AeJAh1bUzAUBrljch9EVOVA6K3lzuFDWwF0LtmXgcMEZV9Htp9owq5MNcOZ/mymBrKmndz1EDwDxwOCLjpvp5QX42G23dUCyYAGfQXE1Dzub7dsaTSlMWnkbh6fMLk/j5/fcLEi8vwXMInQv6isVpxnbYI+4ayQWOzo9QpfJBaromDDqVwbmkoT8lhRo06n32OAi8CtaAS2rjNqJyPfcnLp3jMpfg5Qh3wiKYnT6VkMpXw5ddVASByKlqzIRiuItwJsqF4JDDj+f2qgSdq6PaTgYpu8xnbFXTdOvDeg0ZgetQrnaZ07+5xLFLGI73feAWPUFPXwMHQ2THXA==</ds:SignatureValue>
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
         <ds:X509Data>
            <ds:X509Certificate>MIIC4DCCAcigAwIBAgIQawxJmIMxo49K2BnRDsVfGDANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwHhcNMTcwNDIwMTIxNzUyWhcNMTgwNDIwMTIxNzUyWjAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLUb41Ui5/ytBky/npDW5eV6gQhR7WZ3KJs/JEHEN+pbyNRYZXDY3zXIXcUDRMMdDUnewOisNN4iAMHDri/J7c2zBa05XReyQarnTBDPuiB2Hex6pxA486Mk5KqW8MGB2oWexCM+g1VXiaaSJEOHTb0V+GOhYHcDckNOfnBCKehqnYxqAmJp5WHzmU7IZWNb5P6tl92EfbdATA5fU29dkKVoYDGQJqdDDeLDI1mzxyMENce3v8JER9cnTW7zC2k4hD0TYafF3xphn2yLpnqnGEgbHDla9vdDMqX82+L4DSt4747kEdpc4+V9wwrkOnM5Cz5KKHyzQqzOS91CorCJI/AgMBAAEwDQYJKoZIhvcNAQELBQADggEBACdbOOfVkVNgaPzD+o60HHytR2MzbPcksKq1tZnS++nR+KM5Vo9FiH3LQ8BUulv8sEEq3ITeiLo92fMRySwiaftunLAAEYdBDTIbdi/fUJgLBoCVkDQvdtlRpnunr1KY7ILhKq4w9eQ0I5M5RDZlY2g3LEbyZpFknV1P1Ykx4d/re7BP42kt6JvY8SeA6TnfzgoQUGRBP7DAHiJ3J/HFPQZUvhqpKf6b5SEFMiSczx7wT1/CManyQ9rxOc0rycbGOcIuMNvxCipKWHsBwxvX021uXojhiSx37VxHWSNyWx5HA60GKkOolK8z2xZ/kdXmn5lxaRvH1P169Cd6HrjKzes=</ds:X509Certificate>
         </ds:X509Data>
      </KeyInfo>
   </ds:Signature>
   <samlp:Status>
      <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Requester" />
   </samlp:Status>
</samlp:LogoutResponse>
</code>```

The error appeared on ADFS is: The SAML Single Logout request does not correspond to the logged-in session participant. With extra error description:

```<code>User Action
Verify that the claim provider trust or the relying party trust configuration is up to date. If the name identifier in the request is different from the name identifier in the session only by NameQualifier or SPNameQualifier, check and correct the name identifier policy issuance rule using the AD FS Management snap-in.
</code>```

What should be modified in LogoutRequest to make logout happen?

答:
OK, the problem is solved.

As you can see in SAML Response I've posted NameID element doesn't have Format attribute:

```<code><Subject>
     <NameID>hamilton1@mycompany.test</NameID>
     ...
</Subject>
</code>```

So ADFS expects that Format attribute will be absent in LogouRequest too.
The following LogoutRequests results in successful logout:

```<code><samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="ONELOGIN_947f5e64-8423-4464-b4b0-fa416dfe62a0" Version="2.0" IssueInstant="2017-05-31T15:43:18Z" Destination="https://wintest.mycompany.test/adfs/ls/">
   <saml:Issuer>http://localhost:4568/sso/saml/metadata</saml:Issuer>
   <saml:NameID>hamilton1@mycompany.test</saml:NameID>
   <samlp:SessionIndex>_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe</samlp:SessionIndex>
</samlp:LogoutRequest>
</code>```

If I change Claim Issuing Policy to map Name ID to EmailAddress in ADFS with the following rules:

```<code>c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
 => issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), query = ";mail;{0}", param = c.Value);

c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"]
 => issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer, Value = c.Value, ValueType = c.ValueType, Properties["http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/format"] = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress");
</code>```

I receive the following SAML Response:

```<code><Subject>
     <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress">hamilton1@mycompany.test</NameID>
     ...
</Subject>
</code>```

And sending LogutRequest with <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"> logout happens successfully:

I'm using java-saml of version 2.0.1, so I'm doing the following in Java because LogoutRequest doesn't have a constructor accepting nameIdFormat: https://github.com/onelogin/java-saml/blob/v2.0.1/core/src/main/java/com/onelogin/saml2/logout/LogoutRequest.java:

```<code>LogoutRequest logoutRequest = new LogoutRequest(settings, null, nameId, sessionIndex);
String samlRequestXml = logoutRequest.getLogoutRequestXml();
samlRequestXml = samlRequestXml.replaceAll(" Format=\".+\"", "");
</code>```

There plans to add LogoutRequest constructor accepting nameIdFormat as an argument. More details in https://github.com/onelogin/java-saml/issues/98.

Body:
I'm successfully using OneLogin java-saml library for SAML SSO. But there are problems with SLO (Single Logout) with Active Directory Federation Service (ADFS). LogoutRequest created by the library is rejected by ADFS, while it is accepted by SimpleSAMLphp IdP. I pass both nameId and sessionIndex received from ADFS in Response at LogoutRequest creation.

Here are generated requests and received responses:

AuthNRequest:

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="ONELOGIN_a80567d6-8957-482b-90e9-99d1b40ec8b1" Version="2.0" IssueInstant="2017-05-31T15:43:07Z" ProviderName="My Company Service Provider" Destination="https://wintest.mycompany.test/adfs/ls/" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" AssertionConsumerServiceURL="https://localhost:8443/builder/login_check_sso">
   <saml:Issuer>http://localhost:4568/sso/saml/metadata</saml:Issuer>
   <samlp:NameIDPolicy Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" AllowCreate="true" />
   <samlp:RequestedAuthnContext Comparison="exact">
      <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml:AuthnContextClassRef>
   </samlp:RequestedAuthnContext>
</samlp:AuthnRequest>

Response:

<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" Destination="https://localhost:8443/builder/login_check_sso" ID="_f5ea3a59-92f9-4b22-aaf0-36ed392df051" InResponseTo="ONELOGIN_a80567d6-8957-482b-90e9-99d1b40ec8b1" IssueInstant="2017-05-31T15:43:10.158Z" Version="2.0">
   <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://wintest.mycompany.test/adfs/services/trust</Issuer>
   <samlp:Status>
      <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
   </samlp:Status>
   <Assertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion" ID="_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe" IssueInstant="2017-05-31T15:43:10.158Z" Version="2.0">
      <Issuer>http://wintest.mycompany.test/adfs/services/trust</Issuer>
      <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
         <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
            <ds:Reference URI="#_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe">
               <ds:Transforms>
                  <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                  <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
               </ds:Transforms>
               <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
               <ds:DigestValue>FNwbMonYZBBvTXSRbCWP7WxZgPZPSCcCFZozok9eRK4=</ds:DigestValue>
            </ds:Reference>
         </ds:SignedInfo>
         <ds:SignatureValue>fG1SIq3azZfBFQ+5YBBruuCQ03sLIHJ/YpK/AAOYkyJKXEZ5+SvNLgl+8/3a6Tk8mabZmwmawoJRf5UPb+fNtk+CeeWJ7kiUYcb2uvB4ic7Qd4qB+OgfqK0qVCkn9FWGEODLXA6v4tXWBZfSnzDrHEg7xLHrngesSnffY3uyQvH/rm4G2Vjd59LUeUtpJo2X5ZjVuk4sT5r21+UxpNU9LX8z7hXAZHhD1o4d2dqAs21tAGoid3p0RgNDy1WWGh1WSjFLHPDh220ZIchRFKveJE3R9M9nTKtOFESQsYc6TfmhJ5+Xm/j0VY7vvdhgguyq4MKzcPFK6tBL7I8KREck/Q==</ds:SignatureValue>
         <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <ds:X509Data>
               <ds:X509Certificate>MIIC4DCCAcigAwIBAgIQawxJmIMxo49K2BnRDsVfGDANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwHhcNMTcwNDIwMTIxNzUyWhcNMTgwNDIwMTIxNzUyWjAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLUb41Ui5/ytBky/npDW5eV6gQhR7WZ3KJs/JEHEN+pbyNRYZXDY3zXIXcUDRMMdDUnewOisNN4iAMHDri/J7c2zBa05XReyQarnTBDPuiB2Hex6pxA486Mk5KqW8MGB2oWexCM+g1VXiaaSJEOHTb0V+GOhYHcDckNOfnBCKehqnYxqAmJp5WHzmU7IZWNb5P6tl92EfbdATA5fU29dkKVoYDGQJqdDDeLDI1mzxyMENce3v8JER9cnTW7zC2k4hD0TYafF3xphn2yLpnqnGEgbHDla9vdDMqX82+L4DSt4747kEdpc4+V9wwrkOnM5Cz5KKHyzQqzOS91CorCJI/AgMBAAEwDQYJKoZIhvcNAQELBQADggEBACdbOOfVkVNgaPzD+o60HHytR2MzbPcksKq1tZnS++nR+KM5Vo9FiH3LQ8BUulv8sEEq3ITeiLo92fMRySwiaftunLAAEYdBDTIbdi/fUJgLBoCVkDQvdtlRpnunr1KY7ILhKq4w9eQ0I5M5RDZlY2g3LEbyZpFknV1P1Ykx4d/re7BP42kt6JvY8SeA6TnfzgoQUGRBP7DAHiJ3J/HFPQZUvhqpKf6b5SEFMiSczx7wT1/CManyQ9rxOc0rycbGOcIuMNvxCipKWHsBwxvX021uXojhiSx37VxHWSNyWx5HA60GKkOolK8z2xZ/kdXmn5lxaRvH1P169Cd6HrjKzes=</ds:X509Certificate>
            </ds:X509Data>
         </KeyInfo>
      </ds:Signature>
      <Subject>
         <NameID>hamilton1@mycompany.test</NameID>
         <SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
            <SubjectConfirmationData InResponseTo="ONELOGIN_a80567d6-8957-482b-90e9-99d1b40ec8b1" NotOnOrAfter="2017-05-31T15:48:10.158Z" Recipient="https://localhost:8443/builder/login_check_sso" />
         </SubjectConfirmation>
      </Subject>
      <Conditions NotBefore="2017-05-31T15:43:10.158Z" NotOnOrAfter="2017-05-31T16:43:10.158Z">
         <AudienceRestriction>
            <Audience>http://localhost:4568/sso/saml/metadata</Audience>
         </AudienceRestriction>
      </Conditions>
      <AttributeStatement>
         <Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress">
            <AttributeValue>hamilton@mycompany.com</AttributeValue>
         </Attribute>
      </AttributeStatement>
      <AuthnStatement AuthnInstant="2017-05-31T12:18:50.194Z" SessionIndex="_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe">
         <AuthnContext>
            <AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</AuthnContextClassRef>
         </AuthnContext>
      </AuthnStatement>
   </Assertion>
</samlp:Response>

LogoutRequest:

<samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="ONELOGIN_947f5e64-8423-4464-b4b0-fa416dfe62a0" Version="2.0" IssueInstant="2017-05-31T15:43:18Z" Destination="https://wintest.mycompany.test/adfs/ls/">
   <saml:Issuer>http://localhost:4568/sso/saml/metadata</saml:Issuer>
   <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">hamilton1@mycompany.test</saml:NameID>
   <samlp:SessionIndex>_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe</samlp:SessionIndex>
</samlp:LogoutRequest>

LogoutResponse:

<samlp:LogoutResponse xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" ID="_1b3e8c81-2aba-45be-8fe6-54edda514d51" Version="2.0" IssueInstant="2017-05-31T15:43:24.808Z" Destination="https://localhost:8443/builder/logout_sso" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" InResponseTo="ONELOGIN_947f5e64-8423-4464-b4b0-fa416dfe62a0">
   <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://wintest.mycompany.test/adfs/services/trust</Issuer>
   <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
      <ds:SignedInfo>
         <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
         <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
         <ds:Reference URI="#_1b3e8c81-2aba-45be-8fe6-54edda514d51">
            <ds:Transforms>
               <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
               <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </ds:Transforms>
            <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
            <ds:DigestValue>NDfLVWPkh2/UCEbLQ6V97OK2u4pajv3aLB9cPs5JkSc=</ds:DigestValue>
         </ds:Reference>
      </ds:SignedInfo>
      <ds:SignatureValue>M1JaIz/AeJAh1bUzAUBrljch9EVOVA6K3lzuFDWwF0LtmXgcMEZV9Htp9owq5MNcOZ/mymBrKmndz1EDwDxwOCLjpvp5QX42G23dUCyYAGfQXE1Dzub7dsaTSlMWnkbh6fMLk/j5/fcLEi8vwXMInQv6isVpxnbYI+4ayQWOzo9QpfJBaromDDqVwbmkoT8lhRo06n32OAi8CtaAS2rjNqJyPfcnLp3jMpfg5Qh3wiKYnT6VkMpXw5ddVASByKlqzIRiuItwJsqF4JDDj+f2qgSdq6PaTgYpu8xnbFXTdOvDeg0ZgetQrnaZ07+5xLFLGI73feAWPUFPXwMHQ2THXA==</ds:SignatureValue>
      <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
         <ds:X509Data>
            <ds:X509Certificate>MIIC4DCCAcigAwIBAgIQawxJmIMxo49K2BnRDsVfGDANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwHhcNMTcwNDIwMTIxNzUyWhcNMTgwNDIwMTIxNzUyWjAsMSowKAYDVQQDEyFBREZTIFNpZ25pbmcgLSBXSU5URVNULlRvbmljLnRlc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDLUb41Ui5/ytBky/npDW5eV6gQhR7WZ3KJs/JEHEN+pbyNRYZXDY3zXIXcUDRMMdDUnewOisNN4iAMHDri/J7c2zBa05XReyQarnTBDPuiB2Hex6pxA486Mk5KqW8MGB2oWexCM+g1VXiaaSJEOHTb0V+GOhYHcDckNOfnBCKehqnYxqAmJp5WHzmU7IZWNb5P6tl92EfbdATA5fU29dkKVoYDGQJqdDDeLDI1mzxyMENce3v8JER9cnTW7zC2k4hD0TYafF3xphn2yLpnqnGEgbHDla9vdDMqX82+L4DSt4747kEdpc4+V9wwrkOnM5Cz5KKHyzQqzOS91CorCJI/AgMBAAEwDQYJKoZIhvcNAQELBQADggEBACdbOOfVkVNgaPzD+o60HHytR2MzbPcksKq1tZnS++nR+KM5Vo9FiH3LQ8BUulv8sEEq3ITeiLo92fMRySwiaftunLAAEYdBDTIbdi/fUJgLBoCVkDQvdtlRpnunr1KY7ILhKq4w9eQ0I5M5RDZlY2g3LEbyZpFknV1P1Ykx4d/re7BP42kt6JvY8SeA6TnfzgoQUGRBP7DAHiJ3J/HFPQZUvhqpKf6b5SEFMiSczx7wT1/CManyQ9rxOc0rycbGOcIuMNvxCipKWHsBwxvX021uXojhiSx37VxHWSNyWx5HA60GKkOolK8z2xZ/kdXmn5lxaRvH1P169Cd6HrjKzes=</ds:X509Certificate>
         </ds:X509Data>
      </KeyInfo>
   </ds:Signature>
   <samlp:Status>
      <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Requester" />
   </samlp:Status>
</samlp:LogoutResponse>

The error appeared on ADFS is: The SAML Single Logout request does not correspond to the logged-in session participant. With extra error description:

User Action
Verify that the claim provider trust or the relying party trust configuration is up to date. If the name identifier in the request is different from the name identifier in the session only by NameQualifier or SPNameQualifier, check and correct the name identifier policy issuance rule using the AD FS Management snap-in.

What should be modified in LogoutRequest to make logout happen?

Body:
OK, the problem is solved.

As you can see in SAML Response I've posted NameID element doesn't have Format attribute:

<Subject>
     <NameID>hamilton1@mycompany.test</NameID>
     ...
</Subject>

So ADFS expects that Format attribute will be absent in LogouRequest too.
The following LogoutRequests results in successful logout:

<samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="ONELOGIN_947f5e64-8423-4464-b4b0-fa416dfe62a0" Version="2.0" IssueInstant="2017-05-31T15:43:18Z" Destination="https://wintest.mycompany.test/adfs/ls/">
   <saml:Issuer>http://localhost:4568/sso/saml/metadata</saml:Issuer>
   <saml:NameID>hamilton1@mycompany.test</saml:NameID>
   <samlp:SessionIndex>_6f6daef8-f0b5-4437-8e35-ae44ffc48cfe</samlp:SessionIndex>
</samlp:LogoutRequest>

If I change Claim Issuing Policy to map Name ID to EmailAddress in ADFS with the following rules:

c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
 => issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), query = ";mail;{0}", param = c.Value);

c:[Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"]
 => issue(Type = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer, Value = c.Value, ValueType = c.ValueType, Properties["http://schemas.xmlsoap.org/ws/2005/05/identity/claimproperties/format"] = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress");

I receive the following SAML Response:

<Subject>
     <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress">hamilton1@mycompany.test</NameID>
     ...
</Subject>

And sending LogutRequest with <NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:emailAddress"> logout happens successfully:

I'm using java-saml of version 2.0.1, so I'm doing the following in Java because LogoutRequest doesn't have a constructor accepting nameIdFormat: https://github.com/onelogin/java-saml/blob/v2.0.1/core/src/main/java/com/onelogin/saml2/logout/LogoutRequest.java:

LogoutRequest logoutRequest = new LogoutRequest(settings, null, nameId, sessionIndex);
String samlRequestXml = logoutRequest.getLogoutRequestXml();
samlRequestXml = samlRequestXml.replaceAll(" Format=\".+\"", "");

There plans to add LogoutRequest constructor accepting nameIdFormat as an argument. More details in https://github.com/onelogin/java-saml/issues/98.


来源: stackexchange

问:
jQuery code not working as I want
Sorry about the title I just don't know what to set it as. If you can think of a title for this question please tell me or edit, thanks. Now to the question. I have written some jQuery code which displays different boxes depending on which link is clicked. And when you click the link again all the boxes reappear which is exactly what I want. My problem is that when I click link1 then link2 and then go back to link1 all the images reappear. I don't want this to happen. I only want the boxes for link1 to appear. All the boxes should only show at the start and when you click a link twice.

$(".links").click(function(){
  var current_link = $(this);
  var images = $(".images")

  $(images).removeClass('hide');
  $(images).removeClass('show');

  var current = $(this).data("cat");
  $(images).addClass('hide');
  $('.'+current).addClass('show');

   $(current_link).click(function(){
      $(images).toggleClass('hide');
   });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
  display: inline-block;
}

.portfolio{
  height: 100px;
  width: 100px;
  background-color: red;
  display: inline-block;
}

.web{
  height: 100px;
  width: 100px;
  background-color: orange;
  display: inline-block;
}

.hide{
  display: none;
}

.show{
  display: inline-block;
}</code>```

link1

link2

link3

```

答:
You need to maintain the current link in global variable or like I have done it inside the window object, Try this:

$(".links").click(function(){
  var current_link = $(this);
  var images = $(".images")
  var current = $(this).data("cat");

  if(current == window.currentImage){
      $(images).removeClass('hide');
    $(images).removeClass('show');
    window.currentImage = null;
    return; // don't do anything id current link is clicked
  }

  $(images).addClass('hide');
  $('.'+current).removeClass('hide');
  $('.'+current).addClass('show');
  window.currentImage = current;
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
  display: inline-block;
}

.portfolio{
  height: 100px;
  width: 100px;
  background-color: red;
  display: inline-block;
}

.web{
  height: 100px;
  width: 100px;
  background-color: orange;
  display: inline-block;
}

.show{
  display: inline-block;
}

.hide{
  display: none;
}</code>```

link1

link2

link3

    ```

Thanks

ContentLicense: CC BY-SA 3.0

Title: jQuery code not working as I want

Body:
Sorry about the title I just don't know what to set it as. If you can think of a title for this question please tell me or edit, thanks. Now to the question. I have written some jQuery code which displays different boxes depending on which link is clicked. And when you click the link again all the boxes reappear which is exactly what I want. My problem is that when I click link1 then link2 and then go back to link1 all the images reappear. I don't want this to happen. I only want the boxes for link1 to appear. All the boxes should only show at the start and when you click a link twice.

$(".links").click(function(){
  var current_link = $(this);
  var images = $(".images")

  $(images).removeClass('hide');
  $(images).removeClass('show');

  var current = $(this).data("cat");
  $(images).addClass('hide');
  $('.'+current).addClass('show');

   $(current_link).click(function(){
      $(images).toggleClass('hide');
   });
});

ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
  display: inline-block;
}

.portfolio{
  height: 100px;
  width: 100px;
  background-color: red;
  display: inline-block;
}

.web{
  height: 100px;
  width: 100px;
  background-color: orange;
  display: inline-block;
}

.hide{
  display: none;
}

.show{
  display: inline-block;
}

link1

link2

link3

Body:
You need to maintain the current link in global variable or like I have done it inside the window object, Try this:

$(".links").click(function(){
  var current_link = $(this);
  var images = $(".images")
  var current = $(this).data("cat");

  if(current == window.currentImage){
      $(images).removeClass('hide');
    $(images).removeClass('show');
    window.currentImage = null;
    return; // don't do anything id current link is clicked
  }

  $(images).addClass('hide');
  $('.'+current).removeClass('hide');
  $('.'+current).addClass('show');
  window.currentImage = current;
});

ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
  display: inline-block;
}

.portfolio{
  height: 100px;
  width: 100px;
  background-color: red;
  display: inline-block;
}

.web{
  height: 100px;
  width: 100px;
  background-color: orange;
  display: inline-block;
}

.show{
  display: inline-block;
}

.hide{
  display: none;
}

<ul>
  <li><a id="hi" class="links" data-cat="print" href="#">link1</a></li>
  <li><a class="links" data-cat="portfolio" href="#">link2</a></li>
  <li><a class="links" data-cat="web" href="#">link3</a></li>
</ul>

<div class="print images">

</div>

<div class="portfolio images">

</div>

<div class="web images">

</div>
    <script
      src="https://code.jquery.com/jquery-3.2.1.js"
      integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
      crossorigin="anonymous"></script>

Thanks


问:
Breaking centred words whilst keeping document outline intact
I have the following code

h2 {
  display: block;
  text-align: center;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><h2>Example<br/>text</h2></code>```

The document outline displays the heading like "Exampletext" and I would like it to appear as "Example text".

I initially added a space like

```<code> <h2>Some <br/>text</h2>
</code>```

This corrects the document outline but throws off the centering visually.

Is there an easy way to achieve what I want?

Update

Here is a
visual example showing the centering issue with the document outline I'm using a google chrome extension called HTML5 outliner to generate the document outline.

答:
Adding the space after the
 tag accomplishes what I want, posting here as others could potentially benefit in future.

Body:
I have the following code

h2 {
  display: block;
  text-align: center;
}

Example
text

The document outline displays the heading like "Exampletext" and I would like it to appear as "Example text".

I initially added a space like

Some
text

This corrects the document outline but throws off the centering visually.

Is there an easy way to achieve what I want?

Update

Here is a
visual example showing the centering issue with the document outline I'm using a google chrome extension called HTML5 outliner to generate the document outline.

Body: Adding the space after the <br/> tag accomplishes what I want, posting here as others could potentially benefit in future.


问:
In Java StreamTokenizer docs, what does "ordinary" mean?
I'm trying to understand how to use StreamTokenizer. I don't understand the difference between wordChars and ordinaryChars. What is the difference between this two methods? What 'ordinary' means?

答:
Ordinary means that the char is a 'structural' char of a code, e.g. for JSON the 'ordinary' chars are '{', '}', '[', ']', ':', ','.

This chars are used in StreamTokenizer as separated token and when it is found, the value on StreamTokenizer.sval is not update instead of StreamTokenizer.ttype is update.


问:
Converting xml object hierarchy to objects and adding to a list
I am new to xml , so please don't mind if it is too trivial question

Assume I have a xml file like below

```<code> <Person>
        <Name>John-Jaime-Winston Junior</Name>
    </Person>
    <Person>
        <Name>Steve</Name>
    </person
</code>```

Now i will have a person object , Can i know how to read the xml and cover to a array of objects.

Finally i want something like a list which will have all person objects.

I am unable to get the start how to do this as i am new to xml

```<code>class person {

 string _name

 public string Name
        {
            get { return _name}
            set { _name= value; }
        }

}
</code>```

Thanks in advance

答:
Given .NET 3.5 and System.Xml.Linq this is quite easy.

```<code>var q = from e in XElement.Parse(xml).Elements()
        select new Person() {
            Name = e.Element("Name").Value
        };

var p = q.ToList();
</code>```

You will need to provide valid XML like what follows:

```<code><People>
    <Person>
        <Name>Jim</Name>
    </Person>
    <Person>
        <Name>Bill</Name>
    </Person>
</People>
</code>```

Body:
I am new to xml , so please don't mind if it is too trivial question

Assume I have a xml file like below

 <Person>
        <Name>John-Jaime-Winston Junior</Name>
    </Person>
    <Person>
        <Name>Steve</Name>
    </person

Now i will have a person object , Can i know how to read the xml and cover to a array of objects.

Finally i want something like a list which will have all person objects.

I am unable to get the start how to do this as i am new to xml

class person {

 string _name

 public string Name
        {
            get { return _name}
            set { _name= value; }
        }

}

Thanks in advance

Body:
Given .NET 3.5 and System.Xml.Linq this is quite easy.

var q = from e in XElement.Parse(xml).Elements()
        select new Person() {
            Name = e.Element("Name").Value
        };

var p = q.ToList();

You will need to provide valid XML like what follows:

<People>
    <Person>
        <Name>Jim</Name>
    </Person>
    <Person>
        <Name>Bill</Name>
    </Person>
</People>

ContentLicense: CC BY-SA 2.5


答:
This could be a cleaner solution for you. i am also using a condition :)

var current = null;
var images = $('.images');

$(".links").click(function(){
  if(current === $(this).data("cat")){
    images.removeClass('hide');
    current = null;
  } else {
    current = $(this).data("cat");
    $(images).addClass('hide');
    $('.'+current).removeClass('hide');
  }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
  display: inline-block;
}

.portfolio{
  height: 100px;
  width: 100px;
  background-color: red;
  display: inline-block;
}

.web{
  height: 100px;
  width: 100px;
  background-color: orange;
  display: inline-block;
}

.hide{
  display: none;
}

.show{
  display: inline-block;
}</code>```

link1

link2

link3

```

Title: jQuery code not working as I want

Body:
This could be a cleaner solution for you. i am also using a condition :)

var current = null;
var images = $('.images');

$(".links").click(function(){
  if(current === $(this).data("cat")){
    images.removeClass('hide');
    current = null;
  } else {
    current = $(this).data("cat");
    $(images).addClass('hide');
    $('.'+current).removeClass('hide');
  }
});

ul{
  list-style-type: none;
}

ul li{
  display: inline-block;
}

ul li a{
  font-size: 20px;
  padding: 10px;
  background-color: yellow;
}

.change{
  background-color: red;
}

.print{
  height: 100px;
  width: 100px;
  background-color: blue;
  display: inline-block;
}

.portfolio{
  height: 100px;
  width: 100px;
  background-color: red;
  display: inline-block;
}

.web{
  height: 100px;
  width: 100px;
  background-color: orange;
  display: inline-block;
}

.hide{
  display: none;
}

.show{
  display: inline-block;
}

<ul>
  <li><a id="hi" class="links" data-cat="print" href="#">link1</a></li>
  <li><a class="links" data-cat="portfolio" href="#">link2</a></li>
  <li><a class="links" data-cat="web" href="#">link3</a></li>
</ul>

<div class="print images">

</div>

<div class="portfolio images">

</div>

<div class="web images">

</div>

<script
  src="https://code.jquery.com/jquery-3.2.1.js"
  integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
  crossorigin="anonymous"></script>


问:
undefined index file (Tried a lot of solutions from this forum but not working ...)
I'm sorry to ask question that has been seen a lot of time, but it seems to not work for me, so I have to ask you guys ...
Thanks in advance !

here is my html form :

```<code><form action="action/actionindex.php" method="post">
<label style="text-align:center;"><b>Changer d'image</b></label>
    <input type="file" name="file" id="indeximage" style="margin-left:500px;"/>
    <div class="bg" style="background-image:url('../image/papierpeint.jpg');width:95%;margin:0 auto;height:auto;">
        <div class="welcometxt">
            <ul>

                <label><b>Titre de l'article (Saut de ligne : <img src="../image/sautligne.png"/>| Gras : <img src="../image/gras.png"/>| Italique : <img src="../image/italique.png"/>| Souligné : <img src="../image/souligne.png"/>)</b></label>
                <textarea name="indexh2" rows="1" cols="80">
                    <?php getDesc(1) ?>
                </textarea></br>
    <label><b>Contenu l'article (Saut de ligne : <img src="../image/sautligne.png"/>| Gras : <img src="../image/gras.png"/>| Italique : <img src="../image/italique.png"/>| Souligné : <img src="../image/souligne.png"/>)</b></label>
            <textarea name="indexp" rows="15" cols="110">
                <?php getDesc(2)?>
            </textarea>
            <input type="submit" name="submit" value="Modifier"></br>
</code>```

and here is actionindex.php :

```<code>if(isset($_POST['submit'])){
    $name = $_FILES['file']['name'];
    echo 'nom : '.$name;
    $temp_name  = $_FILES['file']['tmp_name'];
    echo 'dossier temp : '.$temp_name;
    if(isset($name)){
        if(!empty($name)){
            $location = '../../image/';
            if(move_uploaded_file($temp_name, $location)){
                echo 'File uploaded successfully';
            }
        }
    }  else {
        echo 'You should select a file to upload !!';
    }
}
</code>```

Hope you guys help me, thanks !!

答:
If $_FILES["file"] gives undefined index file then there were no uploaded files.

You're missing enctype="multipart/form-data" in the form.

Body:
I'm sorry to ask question that has been seen a lot of time, but it seems to not work for me, so I have to ask you guys ...
Thanks in advance !

here is my html form :

<form action="action/actionindex.php" method="post">
Changer d'image
    <input type="file" name="file" id="indeximage" style="margin-left:500px;"/>

                Titre de l'article (Saut de ligne : | Gras : | Italique : | Souligné : )
                <textarea name="indexh2" rows="1" cols="80">
                    <?php getDesc(1) ?>
                </textarea>

    Contenu l'article (Saut de ligne : | Gras : | Italique : | Souligné : )
            <textarea name="indexp" rows="15" cols="110">
                <?php getDesc(2)?>
            </textarea>
            <input type="submit" name="submit" value="Modifier">

and here is actionindex.php :

if(isset($_POST['submit'])){
    $name = $_FILES['file']['name'];
    echo 'nom : '.$name;
    $temp_name  = $_FILES['file']['tmp_name'];
    echo 'dossier temp : '.$temp_name;
    if(isset($name)){
        if(!empty($name)){
            $location = '../../image/';
            if(move_uploaded_file($temp_name, $location)){
                echo 'File uploaded successfully';
            }
        }
    }  else {
        echo 'You should select a file to upload !!';
    }
}

Hope you guys help me, thanks !!


问:
Show and Hide element from Script and/or from Razor Model View with MVC
I have an element in a Razor View:

```<code><div class="label">When? *</div>
</code>```

That I need to show in a View based on a ModeView condition:

```<code><div id="label" class="label" style="@(Model.SearchedServiceId == 14 ? "display:block" : "")">When? *</div>
</code>```

But I need to be able to hide it from jQuery:

```<code>$("#label").fadeOut();
</code>```

And I define the style like:

```<code>.label {
    display: none;
}
</code>```

The problem is that when the condition is true in the element, and the display:block is added to the element, I am unable to hide it from jQuery:

```<code>$("#label").fadeOut();
</code>```

is not hiding the element.

答:
you can use this

```<code>Model.SearchedServiceId = 14
</code>```

//var a = @Html.Raw(Model.SearchedServiceId); //you can add your Model.SearchedServiceId
var a = 14;
if(a == 14)
{
  $( "#book" ).fadeIn( "slow", function() {
    // Animation complete.
  });
}
else
{
  $( "#book" ).fadeOut( "slow", function() {
    // Animation complete.
  });
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<label id="book" class="label-block" style="display:block">adsada</label>

<style>
.label-block{
  display:none;
}

</style></code>```

```<code>Model.SearchedServiceId = 15
</code>```

//var a = @Html.Raw(Model.SearchedServiceId); //you can add your Model.SearchedServiceId
var a = 15;
if(a == 14)
{
  $( "#book" ).fadeIn( "slow", function() {
    // Animation complete.
  });
}
else
{
  $( "#book" ).fadeOut( "slow", function() {
    // Animation complete.
  });
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<label id="book" class="label-block" style="display:block">adsada</label>

<style>
.label-block{
  display:none;
}

</style></code>```

Body:
I have an element in a Razor View:

When? *

That I need to show in a View based on a ModeView condition:

When? *

But I need to be able to hide it from jQuery:

$("#label").fadeOut();

And I define the style like:

.label {
    display: none;
}

The problem is that when the condition is true in the element, and the display:block is added to the element, I am unable to hide it from jQuery:

$("#label").fadeOut();

is not hiding the element.

Body:
you can use this

Model.SearchedServiceId = 14

//var a = @Html.Raw(Model.SearchedServiceId); //you can add your Model.SearchedServiceId
var a = 14;
if(a == 14)
{
  $( "#book" ).fadeIn( "slow", function() {
    // Animation complete.
  });
}
else
{
  $( "#book" ).fadeOut( "slow", function() {
    // Animation complete.
  });
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<label id="book" class="label-block" style="display:block">adsada</label>

<style>
.label-block{
  display:none;
}

</style>

Model.SearchedServiceId = 15

//var a = @Html.Raw(Model.SearchedServiceId); //you can add your Model.SearchedServiceId
var a = 15;
if(a == 14)
{
  $( "#book" ).fadeIn( "slow", function() {
    // Animation complete.
  });
}
else
{
  $( "#book" ).fadeOut( "slow", function() {
    // Animation complete.
  });
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<label id="book" class="label-block" style="display:block">adsada</label>

<style>
.label-block{
  display:none;
}

</style>


问:
Syntax error in VBA
I have a syntax challenge that is returning a "Data Mismatch" error

Basically, I am using the VBA DMin function to target a range of prices using two criteria, one string and one date.

The code:

```<code>EndDate = #11/1/2017#

Target = DMin("Price", "qryPrice", " [CodeName]='Macan'" And " [MyDate] <=" & EndDate)
</code>```

I can't seem to figure out the syntax in order to use both of the different criteria data types. [CodeName] is string, [MyDate] is date/time

答:
You should always format your date values to string expressions when concatenating:</p>

```<code>Target = DMin("Price", "qryPrice", "[CodeName]='" & [SomeCodeName] & "' And [MyDate] <= #" & Format([EndDate], "yyyy\/mm\/dd") & "#")
</code>```

Title: Syntax error in VBA

Body:
I have a syntax challenge that is returning a "Data Mismatch" error

Basically, I am using the VBA DMin function to target a range of prices using two criteria, one string and one date.

The code:

EndDate = #11/1/2017#

Target = DMin("Price", "qryPrice", " [CodeName]='Macan'" And " [MyDate] <=" & EndDate)

I can't seem to figure out the syntax in order to use both of the different criteria data types. [CodeName] is string, [MyDate] is date/time

Body:
You should always format your date values to string expressions when concatenating:

Target = DMin("Price", "qryPrice", "[CodeName]='" & [SomeCodeName] & "' And [MyDate] <= #" & Format([EndDate], "yyyy\/mm\/dd") & "#")


问:
Resizing the image in S3 bucket from lambda trigger using nodejs
I newbie to nodejs and aws, Can anyone point out whats wrong with the following code to resize the images in s3 bucket

Program as follows

```<code> 'use strict';
 const AWS = require('aws-sdk');
 const S3 = new AWS.S3({
 accessKeyId: "xxxxxxxxxxxx",
 secretAccessKey: "yyyyyyyyyyy",
 region: "us-east-1",
 signatureVersion: 'v4',
 });

const Sharp = require('sharp');
const BUCKET = "patientimg";
const URL = "https://s3.ap-south-1.amazonaws.com";
exports.handler = function(event, context, callback) {
const key = event.queryStringParameters.key;
const match = key.match(/(\d+)x(\d+)\/(.*)/);
const width = parseInt(match[1], 10);
const height = parseInt(match[2], 10);
const originalKey = match[3];

S3.getObject({Bucket: BUCKET, Key: originalKey}).promise()
.then(data => Sharp(data.Body)
  .resize(width, height)
  .toFormat('png')
  .toBuffer()
)
.then(buffer => S3.putObject({
    Body: buffer,
    Bucket: BUCKET,
    ContentType: "image/png",
    Key: key,
  }).promise()
)
.then(() => callback(null, {
    statusCode: '301',
    headers: {'location': "${URL}/${key}"},
    body: "",
  })
)
.catch(err => callback(err))
}
</code>```

this is my exact code I'm using,
output from lambda when testing with "S3 put" request

```<code>  {
   "errorMessage": "RequestId: edaddaf7-4c5e-11e7-bed8-13f72aaa5d38 Process exited before completing request"
    }
</code>```

Thanks in advance

答:
Resizing images using a lambda is a classic example that has been well explained by the AWS team. Follow their instructions, not something else.

https://aws.amazon.com/blogs/compute/resize-images-on-the-fly-with-amazon-s3-aws-lambda-and-amazon-api-gateway/

The correct resizing code is: http://github.com/awslabs/serverless-image-resizing.  Whatever you found is probably wrong.

Basically it works like this:

Upload this code as your lambda.

Go to the triggers tab of your lambda and copy the URL

Go to your s3 bucket and set up a redirection rule: on 404, redirect to the lambda URL.  The image will be automatically resized when requested.

All of these steps are well documented in detail at the AWS blog above.  The benefit of their approach is that the resized image is not created until it is actually needed, which saves on resources.

Body:
I newbie to nodejs and aws, Can anyone point out whats wrong with the following code to resize the images in s3 bucket

Program as follows

 'use strict';
 const AWS = require('aws-sdk');
 const S3 = new AWS.S3({
 accessKeyId: "xxxxxxxxxxxx",
 secretAccessKey: "yyyyyyyyyyy",
 region: "us-east-1",
 signatureVersion: 'v4',
 });

const Sharp = require('sharp');
const BUCKET = "patientimg";
const URL = "https://s3.ap-south-1.amazonaws.com";
exports.handler = function(event, context, callback) {
const key = event.queryStringParameters.key;
const match = key.match(/(\d+)x(\d+)\/(.*)/);
const width = parseInt(match[1], 10);
const height = parseInt(match[2], 10);
const originalKey = match[3];

S3.getObject({Bucket: BUCKET, Key: originalKey}).promise()
.then(data => Sharp(data.Body)
  .resize(width, height)
  .toFormat('png')
  .toBuffer()
)
.then(buffer => S3.putObject({
    Body: buffer,
    Bucket: BUCKET,
    ContentType: "image/png",
    Key: key,
  }).promise()
)
.then(() => callback(null, {
    statusCode: '301',
    headers: {'location': "${URL}/${key}"},
    body: "",
  })
)
.catch(err => callback(err))
}

this is my exact code I'm using,
output from lambda when testing with "S3 put" request

  {
   "errorMessage": "RequestId: edaddaf7-4c5e-11e7-bed8-13f72aaa5d38 Process exited before completing request"
    }

Thanks in advance


问:
Search many expressions in many documents using Python
I often have to search many words (1000+) in many documents (million+). I need position of matched word (if matched).

So slow pseudo version of code is

```<code>for text in documents:
     for word in words:
             position = search(word, text)
             if position:
                  print word, position
</code>```

Is there any fast Python module for doing this? Or should I implement something myself?

答: Assuming documents is a list of strings, you can use text.index(word) to find the first occurrence and text.count(word) to find the total number of occurrences.  Your pseudocode seems to assume words will only occur once, so text.count(word) may be unnecessary.

Body:
I often have to search many words (1000+) in many documents (million+). I need position of matched word (if matched).

So slow pseudo version of code is

for text in documents:
     for word in words:
             position = search(word, text)
             if position:
                  print word, position

Is there any fast Python module for doing this? Or should I implement something myself?


问:
Redirection of window.open() does not work in IE
I have the following code which works perfectly in Chrome: by clicking on New, it opens a popup, then clicking on Change leads to the redirection to another page.

JSBin

```<code><!DOCTYPE html>
<html ng-app="plunker">
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
  </head>
  <body ng-controller="contentCtrl">
    <button ng-click="openNew()">New</button>
    <button ng-click="change()">Change</button>
    <script>
      var app = angular.module('plunker', []);
      app.controller('contentCtrl', ['$scope', function ($scope) {
        $scope.openNew = function () {
          $scope.popup = window.open("https://www.stackoverflow.com", "popup", "status=1, location=1");
        }

        $scope.change = function () {
          // $scope.popup = window.open("https://www.sina.com", "popup", "status=1, location=1");
          // $scope.popup.location.assign("https://www.sina.com")
          // $scope.popup.location.href("https://www.sina.com")
          // $scope.popup.location = "https://www.sina.com"
          $scope.popup.location.href = "https://www.sina.com"
        }
      }]);
    </script>
  </body>
</html>
</code>```

However, this code does not work in IE 11. I have found this thread which lists several ways of redirection in IE, I tried location.assign(...), location.href(...), etc. none of them worked.

Does anyone know how to achieve the redirection of window.open in IE?

答:
As per documentation, window.location.href= seems to be the best way to set (and get) the URL of a window in IE.

If that's not working, replace should do the trick: $scope.popup.location.replace("https://www.google.com/");

Body:
I have the following code which works perfectly in Chrome: by clicking on New, it opens a popup, then clicking on Change leads to the redirection to another page.

JSBin

<!DOCTYPE html>

    <button ng-click="openNew()">New</button>
    <button ng-click="change()">Change</button>

However, this code does not work in IE 11. I have found this thread which lists several ways of redirection in IE, I tried location.assign(...), location.href(...), etc. none of them worked.

Does anyone know how to achieve the redirection of window.open in IE?


问:
Qt 5.9 QML How to show ScrollBar on key up/down in material style with Flickable TextArea
I want to put some text in a Flickable that can also scroll using keys up and down. It works, but the scrollbar does not show when scrolling with keys after it has already faded. Mouse wheel scrolling works fine.

-style universal doesn't show

-style material doesn't show

-style default does show

here's my code:

```<code>import QtQuick 2.7
import QtQuick.Controls 2.2

ApplicationWindow
{
    visible: true
    width: 640
    height: 480

    Flickable
    {
        anchors.fill: parent
        flickableDirection: Flickable.VerticalFlick
        focus: true

        TextArea.flickable: TextArea
        {
            text:

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " ;

            font.pixelSize: 25
            wrapMode: TextArea.Wrap
            readOnly: true
        }

        ScrollBar.vertical: ScrollBar { id: scrollBar }

        // up/down keys described here:
        // https://doc-snapshots.qt.io/qt5-5.8/qml-qtquick-controls2-scrollbar.html
        Keys.onUpPressed: scrollBar.decrease()
        Keys.onDownPressed: scrollBar.increase()

    }
}
</code>```

Thanks for any help.

答:
I recommend like this for mobile applications:

```<code>ScrollBar.vertical: ScrollBar {
  id: scrollBar
  policy: ScrollBar.AlwaysOn
  interactive: false
}
</code>```

You can see: policy and interactive props.

Body:
I want to put some text in a Flickable that can also scroll using keys up and down. It works, but the scrollbar does not show when scrolling with keys after it has already faded. Mouse wheel scrolling works fine.

-style universal doesn't show

-style material doesn't show

-style default does show

here's my code:

import QtQuick 2.7
import QtQuick.Controls 2.2

ApplicationWindow
{
    visible: true
    width: 640
    height: 480

    Flickable
    {
        anchors.fill: parent
        flickableDirection: Flickable.VerticalFlick
        focus: true

        TextArea.flickable: TextArea
        {
            text:

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " +

        "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
        "sed do eiusmod tempor incididunt ut labore et dolore magna " +
        "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " +
        "ullamco laboris nisi ut aliquip ex ea commodo cosnsequat. " ;

            font.pixelSize: 25
            wrapMode: TextArea.Wrap
            readOnly: true
        }

        ScrollBar.vertical: ScrollBar { id: scrollBar }

        // up/down keys described here:
        // https://doc-snapshots.qt.io/qt5-5.8/qml-qtquick-controls2-scrollbar.html
        Keys.onUpPressed: scrollBar.decrease()
        Keys.onDownPressed: scrollBar.increase()

    }
}

Thanks for any help.

Body:
I recommend like this for mobile applications:

ScrollBar.vertical: ScrollBar {
  id: scrollBar
  policy: ScrollBar.AlwaysOn
  interactive: false
}

You can see: policy and interactive props.


问:
Ruby on Rails - Using callback to multiply two objects in separate tables when new entry is created
I have 3 tables, Goals, Activities and Goal_Activities. Goal has a set value for xp and Activity takes an input from the user. Using the on_create method in Activity, I'd like to multiply the user input with the goal xp and store that in the Goal Activities table so I can keep a record of each update and eventually add them all together to create a total goal xp in the Goal table.

I've found a couple of questions on SO, here and here, that cover similar topics but I'm finding it hard to get my head around the associations between the model files and how to access certain methods in different models.

I've also read the documentation on callbacks which I think is what I need to setup but if there's a better way of doing it, please let me know.

Here are my model associations at the moment.

goal.rb

```<code>class Goal < ActiveRecord::Base
  has_many :goal_activities
  has_many :activities, through: :goal_activities
end
</code>```

goal_activity.rb

```<code>class GoalActivity < ActiveRecord::Base
  belongs_to :goal
  belongs_to :activity
end
</code>```

activity.rb

```<code>class Activity < ActiveRecord::Base
  has_many :goal_activities
  belongs_to :goal, through: :goal_activities
end
</code>```

Here are a set of example values in the tables.

Goals

goal_id: 1, xp: 500, total_goal_xp: default 0

Activities

activity_id: 1, quantity: 3, goal_id: 1

Goal_activities

goal_activity_id: 1, goal_id: 1, activity_id: 1, total_xp: 1500

The total_xp would then be added to the total_goal_xp in the Goal table once the activity has been created.

Any advice would be appreciated. Let me know if you have any questions.

答:
You can use after_create callback in your activity.rb as

```<code>after_create :set_total_xp

private

def set_total_xp
  goal_activity = self.goal_activities.where(goal_id: goal_id).first_or_initialize
  goal_activity.update_attribute(:total_xp, (quantity*goal.xp))
end
</code>```

Body:
I have 3 tables, Goals, Activities and Goal_Activities. Goal has a set value for xp and Activity takes an input from the user. Using the on_create method in Activity, I'd like to multiply the user input with the goal xp and store that in the Goal Activities table so I can keep a record of each update and eventually add them all together to create a total goal xp in the Goal table.

I've found a couple of questions on SO, here and here, that cover similar topics but I'm finding it hard to get my head around the associations between the model files and how to access certain methods in different models.

I've also read the documentation on callbacks which I think is what I need to setup but if there's a better way of doing it, please let me know.

Here are my model associations at the moment.

goal.rb

class Goal < ActiveRecord::Base
  has_many :goal_activities
  has_many :activities, through: :goal_activities
end

goal_activity.rb

class GoalActivity < ActiveRecord::Base
  belongs_to :goal
  belongs_to :activity
end

activity.rb

class Activity < ActiveRecord::Base
  has_many :goal_activities
  belongs_to :goal, through: :goal_activities
end

Here are a set of example values in the tables.

Goals

goal_id: 1, xp: 500, total_goal_xp: default 0

Activities

activity_id: 1, quantity: 3, goal_id: 1

Goal_activities

goal_activity_id: 1, goal_id: 1, activity_id: 1, total_xp: 1500

The total_xp would then be added to the total_goal_xp in the Goal table once the activity has been created.

Any advice would be appreciated. Let me know if you have any questions.

Body:
You can use after_create callback in your activity.rb as

after_create :set_total_xp

private

def set_total_xp
  goal_activity = self.goal_activities.where(goal_id: goal_id).first_or_initialize
  goal_activity.update_attribute(:total_xp, (quantity*goal.xp))
end


问:
Window is not showing any text
I tried index.js with following lines:

var electron = require('electron');
var app = electron.app;
var BrowserWindow = electron.BrowserWindow;

app.on('ready',function() {
  var mainWindow = new BrowserWindow({
    width:800,
    height:600
  })
  mainWindow.loadURL('file://' + __dirname + '/index.html/')
})
```

<p>And index.html with:</p>

<pre class="lang-html prettyprint-override"><code><html>
  <head>
    <title> </title>
  </head>
  <body> hello </body>
</html>
</code>```

But the window which gets popped is not showing hello in it:

答:
```<code>mainWindow.loadURL('file://' + __dirname + '/index.html/')
</code>```

should be

```<code>mainWindow.loadURL('file://' + __dirname + '/index.html')
</code>```

(without / at the end)

Title: Window is not showing any text

Body:
I tried index.js with following lines:

var electron = require('electron');
var app = electron.app;
var BrowserWindow = electron.BrowserWindow;

app.on('ready',function() {
  var mainWindow = new BrowserWindow({
    width:800,
    height:600
  })
  mainWindow.loadURL('file://' + __dirname + '/index.html/')
})

And index.html with:

    <title> </title>

   hello

But the window which gets popped is not showing hello in it:

Body:
mainWindow.loadURL('file://' + __dirname + '/index.html/')

should be

mainWindow.loadURL('file://' + __dirname + '/index.html')

(without / at the end)


问:
Django: How to use local copy of base theme?
I am working in Django 1.10, and have inherited a project. The base.html template extends a theme template that is not included in the project:

```<code>{% extends "theme_base.html" %}
</code>```

It seems there is another base theme repo, which is specified via a github URL in the requirements file. This all works seamlessly.

I now want to make a minor text change to the base theme, but I'm not sure how to do this and test the change locally.

I have checked out a copy of the theme repo locally, and installed it with:

```<code>pip install -U -e ../dc_base_theme
</code>```

But when I make changes in that local repo, they don't appear in my running Django site on localhost.

How do I make sure my Django repo is pointing to that local copy of the theme?

答:
is the theme_base.html  file in the project folder correclty?
for example, if you have a subfolders you shoud use it like:

```<code>{% extends 'template/theme_base.html' %}
</code>```

Body:
I am working in Django 1.10, and have inherited a project. The base.html template extends a theme template that is not included in the project:

{% extends "theme_base.html" %}

It seems there is another base theme repo, which is specified via a github URL in the requirements file. This all works seamlessly.

I now want to make a minor text change to the base theme, but I'm not sure how to do this and test the change locally.

I have checked out a copy of the theme repo locally, and installed it with:

pip install -U -e ../dc_base_theme

But when I make changes in that local repo, they don't appear in my running Django site on localhost.

How do I make sure my Django repo is pointing to that local copy of the theme?

Body:
is the theme_base.html  file in the project folder correclty?
for example, if you have a subfolders you shoud use it like:

{% extends 'template/theme_base.html' %}


问:
Why is Scala promoting List[Any] to List[Long]?
In the following code:

```<code>def test(list: List[Any]): Unit = {
  list.foreach {
    v =>
    v match {
      case r: AnyRef => println(r + ": " + r.getClass.getName)
      case d: Double => println(d + ": Double")
      case f: Float=> println(f + ": Float")
      case b: Byte => println(b + ": Byte")
      case c: Char => println(c + ": Char")
      case s: Short => println(s + ": Short")
      case i: Int => println(i + ": Int")
      case l: Long=> println(l + ": Long")
      case b: Boolean => println(b + ": Boolean")
      case _ => throw new IllegalArgumentException("Unknown type: " + v)
    }
  }
}

test(List(0L, 1.asInstanceOf[Int], 2.asInstanceOf[Short]))
</code>```

here is the output (Scala 2.8.1):

```<code>0: java.lang.Long
1: java.lang.Long
2: java.lang.Long
</code>```

Why are the numbers being promoted to java.lang.Long? How can I do this so that they either keep their AnyVal types or get "boxed" to the equivalent AnyRef type?

答:
I think the answer is in Section 3.5.3 of the language reference:

Byte weakly conforms to Short

Short weakly conforms to Int

Char weakly conforms to Int

Int weakly conforms to Long

Long weakly conforms to Float

Float weakly conforms to Double

Because of this, Scala infers that the common type between Short, Int and Long is Long and then converts the non-Long objects to Longs:

```<code>scala> List(0L, 0, 0: Short)
res1: List[Long] = List(0, 0, 0)
</code>```

If you want to use the whole chain of weak conformance, try:

```<code>scala> List(0: Byte, 1: Short, 'c', 3, 4L, 5.0f, 6.0)
res2: List[Double] = List(0.0, 1.0, 99.0, 3.0, 4.0, 5.0, 6.0)
</code>```

And, of course to say that you want a List[Any], just add [Any] to your call to List:

```<code>scala> List[Any](0: Byte, 1: Short, 'c', 3, 4L, 5.0f, 6.0)
res11: List[Any] = List(0, 1, c, 3, 4, 5.0, 6.0)
</code>```

Body:
In the following code:

def test(list: List[Any]): Unit = {
  list.foreach {
    v =>
    v match {
      case r: AnyRef => println(r + ": " + r.getClass.getName)
      case d: Double => println(d + ": Double")
      case f: Float=> println(f + ": Float")
      case b: Byte => println(b + ": Byte")
      case c: Char => println(c + ": Char")
      case s: Short => println(s + ": Short")
      case i: Int => println(i + ": Int")
      case l: Long=> println(l + ": Long")
      case b: Boolean => println(b + ": Boolean")
      case _ => throw new IllegalArgumentException("Unknown type: " + v)
    }
  }
}

test(List(0L, 1.asInstanceOf[Int], 2.asInstanceOf[Short]))

here is the output (Scala 2.8.1):

0: java.lang.Long
1: java.lang.Long
2: java.lang.Long

Why are the numbers being promoted to java.lang.Long? How can I do this so that they either keep their AnyVal types or get "boxed" to the equivalent AnyRef type?

Body:
I think the answer is in Section 3.5.3 of the language reference:

Byte weakly conforms to Short

Short weakly conforms to Int

Char weakly conforms to Int

Int weakly conforms to Long

Long weakly conforms to Float

Float weakly conforms to Double

Because of this, Scala infers that the common type between Short, Int and Long is Long and then converts the non-Long objects to Longs:

scala> List(0L, 0, 0: Short)
res1: List[Long] = List(0, 0, 0)

If you want to use the whole chain of weak conformance, try:

scala> List(0: Byte, 1: Short, 'c', 3, 4L, 5.0f, 6.0)
res2: List[Double] = List(0.0, 1.0, 99.0, 3.0, 4.0, 5.0, 6.0)

And, of course to say that you want a List[Any], just add [Any] to your call to List:

scala> List[Any](0: Byte, 1: Short, 'c', 3, 4L, 5.0f, 6.0)
res11: List[Any] = List(0, 1, c, 3, 4, 5.0, 6.0)


问:
copy/paste functionality in fabric.js
In currently I have added code for copy and paste object in fabric js.But while selecting group of objects its not working.
Is there any way to implement copy/paste functionality for group of objects on canvas with fabric.js framework?

here is my code for paste

```<code>pasteSelectedObjs: function() {
    cur_canvas = canvasObjArr[this.page];
    if (clipboard.length < 1) {
        return;
    }
    if (cur_canvas.getActiveObject()) {
        clipboard.set('active', true);
        cur_canvas.add(clipboard);
        cur_canvas.setActiveObject(clipboard);
    }
    clipboard = [];
}
</code>```

答:
Here's the way I did it. It checks if it's an object or group and that's it's not a path group - which wasn't happy about being cloned.</p>

```<code>   /**
     * Will copy an object on the canvas
     */
    var copyObject;

    copy(){
        let o = canvas.getActiveObject();
        let t = o.get('type');

        if (o && t !== 'path-group'){
            let clone = o.clone();
            if (clone) {
                clone.set({
                    top: clone.top + 50,
                    left: clone.left + 50
                });
            }

            copyObject = clone;
        }
    }

    /**
     * Will clone an object to the canvas
     */
    paste(){
        if (copyObject){
            canvas.add(copyObject);
            canvas.deactivateAll().renderAll();
        }
    }
</code>```

Title: copy/paste functionality in fabric.js

Body:
In currently I have added code for copy and paste object in fabric js.But while selecting group of objects its not working.
Is there any way to implement copy/paste functionality for group of objects on canvas with fabric.js framework?

here is my code for paste

pasteSelectedObjs: function() {
    cur_canvas = canvasObjArr[this.page];
    if (clipboard.length < 1) {
        return;
    }
    if (cur_canvas.getActiveObject()) {
        clipboard.set('active', true);
        cur_canvas.add(clipboard);
        cur_canvas.setActiveObject(clipboard);
    }
    clipboard = [];
}

Body:
Here's the way I did it. It checks if it's an object or group and that's it's not a path group - which wasn't happy about being cloned.

   /**
     * Will copy an object on the canvas
     */
    var copyObject;

    copy(){
        let o = canvas.getActiveObject();
        let t = o.get('type');

        if (o && t !== 'path-group'){
            let clone = o.clone();
            if (clone) {
                clone.set({
                    top: clone.top + 50,
                    left: clone.left + 50
                });
            }

            copyObject = clone;
        }
    }

    /**
     * Will clone an object to the canvas
     */
    paste(){
        if (copyObject){
            canvas.add(copyObject);
            canvas.deactivateAll().renderAll();
        }
    }


问:
Why "npm install" removes all package in node_modules?
The npm install command removes all packages in node_modules but not in package.json.

The npm's config (npm confg ls -l) is

```<code>long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.0.3 node/v7.4.0 win32 x64"

; globalconfig C:\Users\Nicola\AppData\Roaming\npm\etc\npmrc
production = true

; builtin config undefined
prefix = "C:\\Users\\Nicola\\AppData\\Roaming\\npm"

; default values
access = null
allow-same-version = false
also = null
always-auth = false
auth-type = "legacy"
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\Nicola\\AppData\\Roaming\\npm-cache"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
color = true
depth = null
description = true
dev = false
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\Nicola\\AppData\\Roaming\\npm\\etc\\npmrc"
globalignorefile = "C:\\Users\\Nicola\\AppData\\Roaming\\npm\\etc\\npmignore"
group = 0
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\Nicola\\.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-version = "7.4.0"
offline = false
onload-script = null
only = null
optional = true
package-lock = true
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" (overridden)
production = true
progress = true
proprietary-attribs = true
proxy = null
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false

umask = 0
unicode = false
unsafe-perm = true
usage = false
user = 0

version = false
versions = false
viewer = "browser"
</code>```

Other strange thing: the npm update and 'npm install --only=dev' works good but after executing this commad in PhpStorm (File -> Settings -> Laguanges and Framework -> Node.js ana NPM) I see listed only the devDependecies....Why?

package.json

```<code>{
  "name": "XYZ",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "scripts": {
    "dev": "webpack",
    "devWatch": "webpack --watch",
    "build": "webpack -p"
  },
  "author": "X, Y, Z",
  "license": "ISC",
  "devDependencies": {
    "assets-webpack-plugin": "^3.4.0",
    "babel-core": "^6.11.4",
    "babel-loader": "^6.2.4",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-runtime": "^6.11.6",
    "clean-webpack-plugin": "^0.1.10",
    "copy-webpack-plugin": "^3.0.1",
    "create-react-class": "^15.5.3",
    "css-loader": "^0.28.4",
    "extract-text-webpack-plugin": "^2.1.0",
    "file-loader": "^0.9.0",
    "html-webpack-plugin": "^2.22.0",
    "imports-loader": "^0.6.5",
    "style-loader": "^0.18.2",
    "uglify-loader": "^1.3.0",
    "url-loader": "^0.5.8",
    "webpack": "^2.6.1",
    "webpack-dev-server": "^1.14.1"
  },
  "dependencies": {
    "babel-plugin-transform-runtime": "^6.23.0",
    "bbcode-to-react": "^0.2.6",
    "dropzone": "^4.3.0",
    "flux": "^3.1.2",
    "history": "^3.3.0",
    "jquery": "^2.2.4",
    "jquery-file-download": "^1.4.6",
    "jquery.nicescroll": "^3.6.8",
    "js-cookie": "^2.1.4",
    "lg-autoplay": "^1.0.4",
    "lg-fullscreen": "^1.0.1",
    "lg-hash": "^1.0.2",
    "lg-pager": "^1.0.2",
    "lg-share": "^1.0.2",
    "lg-thumbnail": "^1.0.3",
    "lg-video": "^1.0.2",
    "lg-zoom": "^1.0.4",
    "lightgallery": "^1.4.0",
    "linkifyjs": "^2.1.4",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-dropzone-component": "^1.4.1",
    "react-intl": "^2.3.0",
    "react-router": "^3.0.5",
    "validator": "^7.0.0"
  }
}
</code>```

答: PhpStorm lists all dependencies in Node.js and NPM settings page. Do you actually have "dependencies" in package.json?

Body:
The npm install command removes all packages in node_modules but not in package.json.

The npm's config (npm confg ls -l) is

long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/5.0.3 node/v7.4.0 win32 x64"

; globalconfig C:\Users\Nicola\AppData\Roaming\npm\etc\npmrc
production = true

; builtin config undefined
prefix = "C:\\Users\\Nicola\\AppData\\Roaming\\npm"

; default values
access = null
allow-same-version = false
also = null
always-auth = false
auth-type = "legacy"
bin-links = true
browser = null
ca = null
cache = "C:\\Users\\Nicola\\AppData\\Roaming\\npm-cache"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
color = true
depth = null
description = true
dev = false
dry-run = false
editor = "notepad.exe"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "C:\\Users\\Nicola\\AppData\\Roaming\\npm\\etc\\npmrc"
globalignorefile = "C:\\Users\\Nicola\\AppData\\Roaming\\npm\\etc\\npmignore"
group = 0
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "C:\\Users\\Nicola\\.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-version = "7.4.0"
offline = false
onload-script = null
only = null
optional = true
package-lock = true
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "C:\\Program Files\\nodejs" (overridden)
production = true
progress = true
proprietary-attribs = true
proxy = null
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "C:\\WINDOWS\\system32\\cmd.exe"
shrinkwrap = true
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false

umask = 0
unicode = false
unsafe-perm = true
usage = false
user = 0

version = false
versions = false
viewer = "browser"

Other strange thing: the npm update and 'npm install --only=dev' works good but after executing this commad in PhpStorm (File -> Settings -> Laguanges and Framework -> Node.js ana NPM) I see listed only the devDependecies....Why?

package.json

{
  "name": "XYZ",
  "version": "1.0.0",
  "description": "",
  "main": "index.html",
  "scripts": {
    "dev": "webpack",
    "devWatch": "webpack --watch",
    "build": "webpack -p"
  },
  "author": "X, Y, Z",
  "license": "ISC",
  "devDependencies": {
    "assets-webpack-plugin": "^3.4.0",
    "babel-core": "^6.11.4",
    "babel-loader": "^6.2.4",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react": "^6.11.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-runtime": "^6.11.6",
    "clean-webpack-plugin": "^0.1.10",
    "copy-webpack-plugin": "^3.0.1",
    "create-react-class": "^15.5.3",
    "css-loader": "^0.28.4",
    "extract-text-webpack-plugin": "^2.1.0",
    "file-loader": "^0.9.0",
    "html-webpack-plugin": "^2.22.0",
    "imports-loader": "^0.6.5",
    "style-loader": "^0.18.2",
    "uglify-loader": "^1.3.0",
    "url-loader": "^0.5.8",
    "webpack": "^2.6.1",
    "webpack-dev-server": "^1.14.1"
  },
  "dependencies": {
    "babel-plugin-transform-runtime": "^6.23.0",
    "bbcode-to-react": "^0.2.6",
    "dropzone": "^4.3.0",
    "flux": "^3.1.2",
    "history": "^3.3.0",
    "jquery": "^2.2.4",
    "jquery-file-download": "^1.4.6",
    "jquery.nicescroll": "^3.6.8",
    "js-cookie": "^2.1.4",
    "lg-autoplay": "^1.0.4",
    "lg-fullscreen": "^1.0.1",
    "lg-hash": "^1.0.2",
    "lg-pager": "^1.0.2",
    "lg-share": "^1.0.2",
    "lg-thumbnail": "^1.0.3",
    "lg-video": "^1.0.2",
    "lg-zoom": "^1.0.4",
    "lightgallery": "^1.4.0",
    "linkifyjs": "^2.1.4",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "react-dropzone-component": "^1.4.1",
    "react-intl": "^2.3.0",
    "react-router": "^3.0.5",
    "validator": "^7.0.0"
  }
}


问:
Resolving Unkown custom element: <star-rating> vue js
I am using Vue js in my javascript code.  I downloaded the vue-star-rating npm package to have a rating system for one of my elements.  I believe I have followed the instructions here correctly, but I am getting the error

[Vue warn]: Unknown custom element:  - did you register the component correctly? For recursive components, make sure to provide the "name" option.

html

```<code><!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <link type="text/css" rel="../css/ProductEvaluation.css" />
</head>
<body>
    <button class="btn btn-sm" id="btnRun">Run</button>

    <div id="product-eval-areas">
        <ul>
            <li v-for="area in areas">
            {{area.EvaluationArea}}
            // Error is occurring on this custom element
            <star-rating v-model="area.ProductEvaluationScore"></star-rating>
            </li>
        </ul>
    </div>

    <script src="https://url.com/WebResources/ccseq_/Scripts/jquery3.1.1.js"></script>
    <script src="../../Scripts/papaparse.js"></script>
    <script src="../../node_modules/vue/dist/vue.js"></script>
    <script src="../../Scripts/require.js" data-main="../js/main/ProductEvaluation.js"></script>
</body>
</html>
</code>```

.js

```<code>"use strict";

requirejs.config({
    bundles: {
        'https://url.com/WebResources/ccseq_/WebResources/js/lib/CCSEQ.WebAPI.js': ['Model/ProductEvaluation', 'Model/ProductEvaluationArea', 'API/ProductEvaluation', 'API/ProductEvaluationArea']
        //'../lib/CCSEQ.WebAPI.js': ['Model/ProductEvaluation', 'Model/ProductEvaluationArea', 'API/ProductEvaluation', 'API/ProductEvaluationArea']
    }
});

require(["Model/ProductEvaluation", "Model/ProductEvaluationArea", "API/ProductEvaluation", "API/ProductEvaluationArea", "../../../node_modules/vue-star-rating/dist/star-rating.min"], function (ProductEvaluationModel, ProductEvaluationAreaModel, ProductEvaluationAPI, ProductEvaluationAreaAPI, StarRating) {

    var currentProductEvaluation = new ProductEvaluationModel.ProductEvaluation();

    Vue.component('star-rating', StarRating);

    var areas = new Vue({
        el: '#product-eval-areas',
        data: { areas: currentProductEvaluation.ProductEvaluationAreas }
                    })

    $(document).ready(function () {
        PopulatePage();
    });

    function PopulatePage() {
        $("#btnRun").click(function () {
            var productEvaluationAPI = new ProductEvaluationAPI.ProductEvaluation();
            productEvaluationAPI.Get(window.parent.Xrm.Page.data.entity.getId().replace(/({|})/g, "")).
                then(
                function (results) {
                    LoadProductEvaluation(results);
                    console.log("success");
                }).catch(function (results) {
                    console.log("Fail");
                });
        });
    }

    function LoadProductEvaluation(productEvaluation) {
        productEvaluation.ccseq_ccseq_productevaluation_ccseq_producteval.forEach(function (pe) {
            var newProductEvaluationArea = new ProductEvaluationAreaModel.ProductEvaluationArea();
            newProductEvaluationArea.EvaluationArea = pe.ccseq_evaluationarea;
            newProductEvaluationArea.ProductEvaluationScore = pe.ccseq_productevaluationscore;
            newProductEvaluationArea.SelfEvaluation = pe.ccseq_selfevaluation;
            newProductEvaluationArea.ProductEvaluationID = pe.ccseq_productevaluationid;
            currentProductEvaluation.ProductEvaluationAreas.push(newProductEvaluationArea);
        });
    }
});
</code>```

答:
This is my package, but I didn't document how to use it with requireJS as I haven't used it in quite a few years. It is however bundled as a named UMD module which is defined as "VueStarRating" so you need to add the following to your requirejs config:

```<code>paths: {
  'VueStarRating': '../../../node_modules/vue-star-rating/dist/star-rating.min'
}
</code>```

Then you can do:

```<code>require(['VueStarRating'], function(StarRating) {
  Vue.component('star-rating', StarRating.default);

  new Vue({
    el: '#app'
  })
});
</code>```

You can check it out on this JSFiddle: https://jsfiddle.net/2Lgz9vs4/

If you run into further trouble then it might be worth tagging your questions with requirejs aswell. Most Vue developers use CommonJS (including myself) so you should get better responses there.

Body:
I am using Vue js in my javascript code.  I downloaded the vue-star-rating npm package to have a rating system for one of my elements.  I believe I have followed the instructions here correctly, but I am getting the error

[Vue warn]: Unknown custom element:  - did you register the component correctly? For recursive components, make sure to provide the "name" option.

html

<!DOCTYPE html>

    <title></title>
    <meta charset="utf-8" />
    <link type="text/css" rel="../css/ProductEvaluation.css" />

    <button class="btn btn-sm" id="btnRun">Run</button>

            {{area.EvaluationArea}}
            // Error is occurring on this custom element
            <star-rating v-model="area.ProductEvaluationScore"></star-rating>

.js

"use strict";

requirejs.config({
    bundles: {
        'https://url.com/WebResources/ccseq_/WebResources/js/lib/CCSEQ.WebAPI.js': ['Model/ProductEvaluation', 'Model/ProductEvaluationArea', 'API/ProductEvaluation', 'API/ProductEvaluationArea']
        //'../lib/CCSEQ.WebAPI.js': ['Model/ProductEvaluation', 'Model/ProductEvaluationArea', 'API/ProductEvaluation', 'API/ProductEvaluationArea']
    }
});

require(["Model/ProductEvaluation", "Model/ProductEvaluationArea", "API/ProductEvaluation", "API/ProductEvaluationArea", "../../../node_modules/vue-star-rating/dist/star-rating.min"], function (ProductEvaluationModel, ProductEvaluationAreaModel, ProductEvaluationAPI, ProductEvaluationAreaAPI, StarRating) {

    var currentProductEvaluation = new ProductEvaluationModel.ProductEvaluation();

    Vue.component('star-rating', StarRating);

    var areas = new Vue({
        el: '#product-eval-areas',
        data: { areas: currentProductEvaluation.ProductEvaluationAreas }
                    })

    $(document).ready(function () {
        PopulatePage();
    });

    function PopulatePage() {
        $("#btnRun").click(function () {
            var productEvaluationAPI = new ProductEvaluationAPI.ProductEvaluation();
            productEvaluationAPI.Get(window.parent.Xrm.Page.data.entity.getId().replace(/({|})/g, "")).
                then(
                function (results) {
                    LoadProductEvaluation(results);
                    console.log("success");
                }).catch(function (results) {
                    console.log("Fail");
                });
        });
    }

    function LoadProductEvaluation(productEvaluation) {
        productEvaluation.ccseq_ccseq_productevaluation_ccseq_producteval.forEach(function (pe) {
            var newProductEvaluationArea = new ProductEvaluationAreaModel.ProductEvaluationArea();
            newProductEvaluationArea.EvaluationArea = pe.ccseq_evaluationarea;
            newProductEvaluationArea.ProductEvaluationScore = pe.ccseq_productevaluationscore;
            newProductEvaluationArea.SelfEvaluation = pe.ccseq_selfevaluation;
            newProductEvaluationArea.ProductEvaluationID = pe.ccseq_productevaluationid;
            currentProductEvaluation.ProductEvaluationAreas.push(newProductEvaluationArea);
        });
    }
});

Body:
This is my package, but I didn't document how to use it with requireJS as I haven't used it in quite a few years. It is however bundled as a named UMD module which is defined as "VueStarRating" so you need to add the following to your requirejs config:

paths: {
  'VueStarRating': '../../../node_modules/vue-star-rating/dist/star-rating.min'
}

Then you can do:

require(['VueStarRating'], function(StarRating) {
  Vue.component('star-rating', StarRating.default);

  new Vue({
    el: '#app'
  })
});

You can check it out on this JSFiddle: https://jsfiddle.net/2Lgz9vs4/

If you run into further trouble then it might be worth tagging your questions with requirejs aswell. Most Vue developers use CommonJS (including myself) so you should get better responses there.


问:
How to set a separate proxy for Wagtail to fetch YouTube embed video?
I tried to add a YouTube video in article content, but it alway failed to upload the video link because YouTube is blocked in my country. So I built a HTTP proxy to watch YouTube, how could I tell the wagtail application to use my HTTP proxy while fetching YouTube embed metadata?</p>

答:
As far as I understand, your server and your users are behind a firewall that blocks access to YouTube. So there is two problems to solve:

Your Wagtail app should be able to access https://www.youtube.com/oembed to fetch metadata and iframe code to embed (see the example response).

Your users should be able to access youtube servers to watch videos.

To solve the first problem you can use a custom embed finder. You can find some information on how to add a custom embed finder the Wagtail's documentation.

Your embed finder should recognise youtube urls and send requests to fetch meta info through the proxy.

The second problem should be solved on the client's side (the client's browser should use proxy) or you should transparently proxy traffic youtube <-> your users somehow. It's not really Wagtail related issue, so I'll leave it with you.


答:
when your form includes any <input type="file"> elements use multipart/form-data:

```<code><form action="action/actionindex.php" method="post" enctype="multipart/form-data">
</code>```

Read more about multipart/form-data What does enctype='multipart/form-data' mean?

Title: undefined index file (Tried a lot of solutions from this forum but not working ...)

Body:
I'm sorry to ask question that has been seen a lot of time, but it seems to not work for me, so I have to ask you guys ...
Thanks in advance !

here is my html form :

<form action="action/actionindex.php" method="post">
Changer d'image
    <input type="file" name="file" id="indeximage" style="margin-left:500px;"/>

                Titre de l'article (Saut de ligne : | Gras : | Italique : | Souligné : )
                <textarea name="indexh2" rows="1" cols="80">
                    <?php getDesc(1) ?>
                </textarea>

    Contenu l'article (Saut de ligne : | Gras : | Italique : | Souligné : )
            <textarea name="indexp" rows="15" cols="110">
                <?php getDesc(2)?>
            </textarea>
            <input type="submit" name="submit" value="Modifier">

and here is actionindex.php :

if(isset($_POST['submit'])){
    $name = $_FILES['file']['name'];
    echo 'nom : '.$name;
    $temp_name  = $_FILES['file']['tmp_name'];
    echo 'dossier temp : '.$temp_name;
    if(isset($name)){
        if(!empty($name)){
            $location = '../../image/';
            if(move_uploaded_file($temp_name, $location)){
                echo 'File uploaded successfully';
            }
        }
    }  else {
        echo 'You should select a file to upload !!';
    }
}

Hope you guys help me, thanks !!

Body:
when your form includes any <input type="file"> elements use multipart/form-data:

<form action="action/actionindex.php" method="post" enctype="multipart/form-data">

Read more about multipart/form-data What does enctype='multipart/form-data' mean?