コード例 #1
0
 /**
  * Get an array of all of the installed blocks.
  *
  * @return array contents of the block table.
  */
 public function get_installed_blocks()
 {
     global $DB, $COURSE, $CFG;
     /*********** local_contextadmin Modification ************
             First Author:  Greg Gibeau
             Initial Date:  February 2nd 2012
             Last Author:   Greg Gibeau
             Date Changed:  May 5, 2014
     
             Extra Comments: Performance may need to be looked at.  Possible caching could be useful.
              ************/
     /**
      * Retrieves the list of installed blocks based off of category administration.
      * If the category administration module is not installed, core functionality is used.
      */
     if (file_exists($CFG->dirroot . '/local/contextadmin/locallib.php')) {
         require_once $CFG->dirroot . '/local/contextadmin/locallib.php';
         $context = $this->page->context;
         if ($context->contextlevel == CONTEXT_COURSECAT) {
             $catid = $context->instanceid;
             return $this->allblocks = get_all_blocks($catid);
         } else {
             if ($context->contextlevel > CONTEXT_COURSECAT && isset($COURSE) && isset($COURSE->category)) {
                 $catid = $COURSE->category;
                 return $this->allblocks = get_all_blocks($catid);
             }
         }
     }
     /*********** End local_contextadmin Modification ********/
     if (is_null($this->allblocks)) {
         $this->allblocks = $DB->get_records('block');
     }
     return $this->allblocks;
 }
コード例 #2
0
ファイル: create_template.php プロジェクト: bsebi/xproject
}
$html_block = '';
$javascript_content = '';
$css_content = '';
print "Loading html file...\n";
$html_content = file_get_contents($html_file);
$body_tag_pattern = '/<body.*>/';
$body_endtag_pattern = '/<\\/body>/';
$html_block = get_block($html_content, $body_tag_pattern, $body_endtag_pattern);
print "Parsing javascript code out of the html file...\n";
$script_tag_pattern = '/<script.*>/';
$script_endtag_pattern = '/<\\/script>/';
$javascript_content = get_all_blocks($html_content, $script_tag_pattern, $script_endtag_pattern, True);
print "Parsing css code out of the html file...\n";
$style_tag_pattern = '/<style.*>/';
$style_endtag_pattern = '/<\\/style>/';
$css_content = get_all_blocks($html_content, $style_tag_pattern, $style_endtag_pattern, True);
$link_tag_pattern = '/<link.*\\>/';
$link_endtag_pattern = '/\\/>/';
$css_content .= get_all_blocks($html_content, $link_tag_pattern, '', True);
print "Loading javascript file...\n";
$javascript_content .= '<script>' . file_get_contents($javascript_file) . '</script>';
print "Loading css file...\n";
$css_content .= '<style>' . file_get_contents($css_file) . '</style>';
$template = "";
$template .= "{% extends 'base.html.twig' %}";
$template .= "{% block javascript %}" . $javascript_content . "{% endblock %}";
$template .= "{% block stylesheets %}" . $css_content . "{% endblock %}";
$template .= "{% block body %}" . $html_block . "{% endblock %}";
print "Saving template at " . $output_file;
file_put_contents($output_file, $template);