Exemple #1
0
function outputJSON($msg, $status = 'error', $preview = '')
{
    global $context;
    Js_css::prepare_scripts_for_overlaying();
    $js = $context['javascript']['footer'];
    header('Content-Type: application/json');
    die(json_encode(array('data' => $msg, 'status' => $status, 'preview' => $preview, 'js' => $js)));
}
Exemple #2
0
 /**
  * link a javascript file in the header of the page
  * 
  * @param string $path 
  */
 public static function load_script($path, $now = false)
 {
     $job = Js_css::link_file($path, 'js', 'header', $now);
     if ($now) {
         echo $job;
     }
 }
Exemple #3
0
echo '<footer id="footer_panel" class="mw960p line mod center">' . "\n";
// last <p>
Page::footer();
echo '</footer>' . "\n";
// call jquery
// echo '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>'."\n";
// echo '<script>window.jQuery || document.write(\'<script src="'.$context['url_to_root'].'skins/boilerplate/js/vendor/jquery-1.8.0.min.js"><\/script>\')</script>'."\n";
// scripts concatenated and minified via ant build script
// <script src="js/plugins.js"></script>
// <script src="js/script.js"></script>
// end scripts
// insert the dynamic footer, if any, including inline scripts
echo $context['page_footer'];
// template layout activation, if needed (http://code.google.com/p/css-template-layout)
// echo '<script>$(function() {$.setTemplateLayout("'.$context['url_to_root'].'skins/starterfive/starterfive.css", "js");});</script>'."\n";
// Google Analytics: change UA-XXXXX-X to be your site's ID.
/*echo '<script>'."\n"
      ."\t"."(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]="."\n"
      ."\t"."function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;"."\n"
      ."\t"."e=o.createElement(i);r=o.getElementsByTagName(i)[0];"."\n"
      ."\t"."e.src='//www.google-analytics.com/analytics.js';"."\n"
      ."\t"."r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));"."\n"
      ."\t"."ga('create','UA-XXXXX-X','auto');ga('send','pageview');"."\n"
  .'</script>'."\n";*/
// CSS3Pie for decoration with old IE browser
echo '<!--[if lt IE 10]>' . "\n";
echo Js_css::link_file('skins/starterfive/js/PIE.js', 'now') . "\n";
echo Js_css::link_file('skins/starterfive/js/pie_enhance_ie.js', 'now') . "\n";
echo '<![endif]-->' . "\n";
echo '</body>' . "\n";
echo '</html>';
Exemple #4
0
 /**
  * This function wrap all end of page javascript snippets
  * in a special function "execute_after_loading"
  * The function will be called later by yacs.js when script
  * are ready to be executed
  * This is because you cannot relay on $.ready() for a script loaded asynchroniusly
  * the function has to pay attention about portion of codes that are only declaration of a function or variable
  * they should not be nested in the closure of execute_after_loading
  *
  * @return void
  */
 private static function wrap_footer_scripts()
 {
     global $context;
     $reset = 'delete execute_after_loading;';
     if (!isset($context['javascript']['footer'])) {
         Js_css::insert($reset);
         return;
     }
     // extract code from <script></script> tags
     $scripts = array();
     if (!preg_match_all('/<script.*?>(.*?)<\\/script/sim', $context['javascript']['footer'], $scripts)) {
         return;
     }
     array_shift($scripts);
     // remove matches[0] with all pattern
     // parse array and look for function declarations
     $declare_only = array();
     for ($i = 0; $i < count($scripts[0]); $i++) {
         $matches = array();
         if (preg_match_all('/(function\\ [a-zA-Z_]+\\ ?\\([a-zA-Z0-9_,$\\-\\ ]*\\)\\ ?(\\{ ( (?>[^{}]+) | (?-2) )* \\}) )/simx', $scripts[0][$i], $matches)) {
             // consider matches for the whole pattern
             foreach ($matches[0] as $match) {
                 // store them
                 $declare_only[] = $match;
                 // remove this part of the script
                 $scripts[0][$i] = str_replace($match, '', $scripts[0][$i]);
             }
             // unset if void
             if (!trim($scripts[0][$i])) {
                 unset($scripts[0][$i]);
             }
         }
     }
     $wrapped = implode("\n", $declare_only) . "\n";
     $wrapped .= 'function execute_after_loading() {' . implode("\n", $scripts[0]) . ' Yacs.updateModalBox(true)' . "\n" . '}' . "\n";
     // erase footer
     $context['javascript']['footer'] = '';
     // fill with new wrapped code
     Js_css::insert($wrapped);
     return;
 }