コード例 #1
0
 /**
  * @covers \NewFrontiers\Framework\Output\Javascript::registerLibrary
  * @covers \NewFrontiers\Framework\Output\Javascript::requireLibrary
  * @covers \NewFrontiers\Framework\Output\Javascript::includeRequiredLibraries
  * @covers \NewFrontiers\Framework\Output\Javascript::includeRegisteredLibrary
  * @covers \NewFrontiers\Framework\Output\Javascript::getInstance
  */
 public function testExternalLibrary()
 {
     Javascript::requireLibrary("nfs.StdControls");
     Javascript::requireLibrary("nfs.ExtControls");
     Javascript::requireLibrary("nfs.DataControls");
     Javascript::requireLibrary("jQuery");
     Javascript::requireLibrary("datetimepicker");
     Javascript::requireLibrary("magnific");
     Javascript::requireLibrary("typeahead");
     Javascript::requireLibrary("googlemaps");
     Javascript::requireLibrary("jqueryuploader");
     Javascript::requireLibrary("ckeditor");
     Javascript::requireLibrary("bootstrap-toggle");
     Javascript::requireLibrary("bootstrap-star-rating");
     Javascript::requireLibrary("code-prettify");
     Javascript::requireLibrary("bootstrap-slider");
     Javascript::requireLibrary("chosen");
     Javascript::requireLibrary("froala");
     Javascript::requireLibrary("Chart.js");
     $string = $this->getActualOutput();
     $this->assertEmpty($string);
     //Read test configuration for full path
     Configuration::getInstance()->readConfig();
     Javascript::includeRequiredLibraries();
     $this->expectOutputRegex('/.*(script)+.*/');
     //check that valid html is produced
     $html = $this->getActualOutput();
     $this->assertNotEmpty($html);
     $dom = new \DOMDocument();
     $dom->validateOnParse = true;
     $isValid = $dom->loadHTML($html);
     $this->assertTrue($isValid);
     /* now follows a quite complex way to check if all URLs are parsable and if all
      * scripts that are not located on localhost are accessible. The complex thing
      * about this is to check scheme-relative URLs. For example //domain.de */
     $URL_string = preg_replace('(.*src\\=\\"|\\".*)', "", $html);
     $URL_array = explode("\n", $URL_string);
     foreach ($URL_array as $URL) {
         if (!empty($URL)) {
             $parsed = parse_url($URL);
             if ($parsed === false) {
                 $this->fail("Malformed URL: {$URL}");
                 continue;
             }
             if (isset($parsed['host']) && $parsed['host'] != "localhost") {
                 if (empty($parsed['scheme'])) {
                     $httpURL = 'http://' . ltrim($URL, '/');
                     $headers = @get_headers($httpURL);
                     if (!$headers && strpos($headers[0], '200') !== false) {
                         $httpsURL = 'https://' . ltrim($URL, '/');
                         $headers = @get_headers($httpsURL);
                     }
                 } else {
                     $headers = @get_headers($URL);
                 }
                 $this->assertTrue($headers && strpos($headers[0], '200') !== false, "Script not found: {$URL}");
             }
         }
     }
 }
コード例 #2
0
                <button type="button" id="btnYes" class="btn btn-danger">Ja</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Nein</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>


<!-- Placed at the end of the document so the pages load faster -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<?php 
Javascript::requireLibrary('nfs.StdControls');
Javascript::includeRequiredLibraries();
?>

<?php 
Debug::showDebugConsole();
Javascript::display();
?>

<script>

    Globalize.cultureSelector = "de-DE";

    $('.checkbox').click(function (event) {
        hiddenElement = '#' + event.target.id + '_hidden';
        if (event.target.checked)
            $(hiddenElement).attr('value', 1);