Пример #1
0
 public static function set_position($position)
 {
     if (self::$blocks == null) {
         //load all blocks data from database
         $db = new cls_database();
         $query_string = "SELECT b.name AS 'b.name',";
         $query_string .= "b.position AS 'b.position', b.permissions AS 'b.permissions', ";
         $query_string .= "b.pages AS 'b.pages', b.show_header AS 'b.show_header', b.plugin AS 'b.plugin', p.id AS 'p.id', p.name AS 'p.name', b.rank FROM blocks b INNER JOIN plugins p ON b.plugin = p.id ORDER BY b.rank DESC;";
         $db->do_query($query_string);
         self::$blocks = $db->get_array();
         self::$plugin = new cls_plugin();
     }
     //search blocks for position matched
     //if add 'MAIN' to cls_router::show_content that's show like main content that come with url
     //and if add 'BLOCK' tag , sarkesh show that content like block
     //and if Send 'NONE' sarkesh do not show that(just run without view
     foreach (self::$blocks as $block) {
         if ($block['b.position'] == $position) {
             //going to process block
             if ($block['p.name'] == 'core') {
                 //going to show content;
                 $obj_router = new cls_router();
                 $obj_router->show_content();
             } else {
                 //checking that plugin is enabled
                 if (self::$plugin->is_enabled($block['p.name'])) {
                     $plugin = new $block['p.name']();
                     //run action method for show block
                     //all blocks name should be like  'blk_blockname'
                     $content = call_user_func(array($plugin, $block['b.name']), $position);
                     echo self::show_block($content[0], $content[1], 'BLOCK');
                 }
             }
         }
     }
 }