当前位置: 首页>>代码示例>>PHP>>正文


PHP block::load方法代码示例

本文整理汇总了PHP中block::load方法的典型用法代码示例。如果您正苦于以下问题:PHP block::load方法的具体用法?PHP block::load怎么用?PHP block::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在block的用法示例。


在下文中一共展示了block::load方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render_region

 public function render_region($region)
 {
     // Fetch regions (how?) and render them (like _page and _node)
     global $db;
     $blocks = $db->select('regions r, regioned_blocks rb, blocks b', "r.region_name = " . $db->escapeAndQuote($region) . " AND r.id = rb.region_id AND rb.block_id = b.id");
     foreach ($blocks as $block) {
         $block = block::load($block);
         if ($block->available($GLOBALS['url_path'])) {
             $block->render();
         }
     }
 }
开发者ID:rudiedirkx,项目名称:CMS2,代码行数:12,代码来源:inc.cls.page.php

示例2: export_sample

 public static function export_sample($a_categories, $a_items, $a_block_groups, $a_blocks, $a_comments, $folder)
 {
     global $website;
     global $theme;
     global $DB;
     @set_time_limit(0);
     $categories = array();
     $items = array();
     $blocks = array();
     $block_groups = array();
     $comments = array();
     $properties = array();
     $files = array();
     $settings = array();
     // structure
     for ($c = 0; $c < count($a_categories); $c++) {
         $tmp = new structure();
         $tmp->load($a_categories[$c]);
         //$properties['structure'][$tmp->id] = property::load_properties_associative('structure', $tmp->template, 'structure', $tmp->id);
         $properties['structure'][$tmp->id] = property::load_properties('structure', $tmp->template, 'structure', $tmp->id);
         $categories[$tmp->id] = $tmp;
         // add files referenced in properties
         if (is_array($properties['structure'][$tmp->id])) {
             foreach ($properties['structure'][$tmp->id] as $property) {
                 if ($property->type == 'image' || $property->type == 'file') {
                     $files[] = $property->value;
                 }
             }
         }
     }
     // comments
     for ($c = 0; $c < count($a_comments); $c++) {
         $tmp = new comment();
         $tmp->load($a_comments[$c]);
         $comments[$tmp->id] = $tmp;
     }
     // items
     for ($i = 0; $i < count($a_items); $i++) {
         $tmp = new item();
         $tmp->load($a_items[$i]);
         $template_id = $tmp->template;
         if ($tmp->association != "free" && $tmp->embedding == 1) {
             // we have to get the template set in the category of the item
             $template_id = $DB->query_single('template', 'nv_structure', ' id = ' . protect($tmp->category) . ' AND website = ' . $website->id);
         }
         $properties['item'][$tmp->id] = property::load_properties('item', $template_id, 'item', $tmp->id);
         list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files);
         // add files referenced in properties
         if (is_array($properties['item'][$tmp->id])) {
             foreach ($properties['item'][$tmp->id] as $property) {
                 if ($property->type == 'image' || $property->type == 'file') {
                     $files[] = $property->value;
                 }
             }
         }
         // add files referenced in gallery
         if (is_array($tmp->galleries[0])) {
             $gallery_images = array_keys($tmp->galleries[0]);
             $files = array_merge($files, $gallery_images);
         }
         $items[$tmp->id] = $tmp;
     }
     // block_groups
     for ($i = 0; $i < count($a_block_groups); $i++) {
         $tmp = new block_group();
         $tmp->load($a_block_groups[$i]);
         $block_groups[$tmp->id] = $tmp;
         if (is_array($tmp->blocks)) {
             foreach ($tmp->blocks as $bgb) {
                 if ($bgb['type'] == 'block_group_block') {
                     $properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties($bgb['id'], $tmp->code, 'block_group_block', $bgb['id'], $bgb['uid']);
                 } else {
                     if ($bgb['type'] == 'extension') {
                         $properties['block_group_block'][$a_block_groups[$i]][$bgb['uid']] = property::load_properties(NULL, $bgb['id'], "extension_block", NULL, $bgb['uid']);
                     }
                 }
             }
         }
         // note: maybe not all blocks in the group have been selected in the "blocks" tab
         // here we only export the block group definition, the block group blocks properties and the extension blocks properties, not adding anything else to export
     }
     // blocks
     for ($i = 0; $i < count($a_blocks); $i++) {
         $tmp = new block();
         $tmp->load($a_blocks[$i]);
         $properties['block'][$tmp->id] = property::load_properties('block', $tmp->type, 'block', $tmp->id);
         list($tmp->dictionary, $files) = theme::export_sample_parse_dictionary($tmp->dictionary, $files);
         list($tmp->trigger['trigger-content'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-content'], $files);
         list($tmp->trigger['trigger-html'], $files) = theme::export_sample_parse_array($tmp->trigger['trigger-html'], $files);
         if (!empty($tmp->trigger['trigger-image'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-image']));
         }
         if (!empty($tmp->trigger['trigger-rollover'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-rollover']));
         }
         if (!empty($tmp->trigger['trigger-rollover-active'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-rollover-active']));
         }
         if (!empty($tmp->trigger['trigger-flash'])) {
             $files = array_merge($files, array_values($tmp->trigger['trigger-flash']));
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:theme.class.php

示例3: nvweb_blocks


//.........这里部分代码省略.........
            $DB->query('
			    SELECT *
                  FROM nv_blocks
                 WHERE type = ' . protect($vars['type']) . '
                   AND enabled = 1
                   AND website = ' . $website->id . '
                   AND (date_published = 0 OR date_published < ' . core_time() . ')
                   AND (date_unpublish = 0 OR date_unpublish > ' . core_time() . ')
                   AND access IN(' . implode(',', $access) . ')
                   AND id NOT IN(' . implode(",", $fixed_rows_ids) . ')
                   ' . $categories_query . '
                   ' . $exclusions_query . '
                 ORDER BY RAND()
            ');
            $random_rows = $DB->result();
            // mix rows (fixed and random)
            // fixed position rows
            foreach ($fixed_rows as $fr) {
                if (!nvweb_block_enabled($fr)) {
                    continue;
                }
                $blocks[$fr->position] = $fr->id;
            }
            // random position rows
            $pos = 0;
            foreach ($random_rows as $rr) {
                if (!nvweb_block_enabled($rr)) {
                    continue;
                }
                // find next free position
                $free = false;
                while (!$free) {
                    $free = empty($blocks[$pos]);
                    if (!$free) {
                        $pos++;
                    }
                }
                $blocks[$pos] = $rr->id;
            }
            // sort array by key
            ksort($blocks);
            break;
    }
    // render the blocks found
    $shown = 0;
    $position = 1;
    $block_objects = array();
    foreach ($blocks as $id) {
        if ($howmany > 0 && $shown >= $howmany) {
            break;
        }
        $block = new block();
        $block->load($id);
        $bt = 'block';
        for ($bti = 0; $bti < count($block_types); $bti++) {
            if ($block->type == $block_types[$bti]['code']) {
                $bt = $block_types[$bti]['type'];
                break;
            }
        }
        // SKIP all blocks until a certain position
        if (isset($vars['position']) && $vars['position'] != $position) {
            $position++;
            continue;
        }
        // RENDER block zone
        switch ($vars['zone']) {
            case 'object':
                $block_objects[] = clone $block;
                break;
            case 'title':
                $out .= '<span class="block-' . $vars['type'] . '-title" zone="title" ng-block-id="' . $block->id . '">' . $block->dictionary[$current['lang']]['title'] . '</span>';
                break;
            case 'content':
            case 'block':
            default:
                if ($bt == 'theme') {
                    $fn = 'nvweb_' . $website->theme . '_blocks_render';
                    $out .= '<div class="block-' . $vars['type'] . '" ng-block-id="' . $block->id . '">';
                    $out .= $fn($block, $vars);
                    $out .= '</div>' . "\n";
                } else {
                    $out .= '<div class="block-' . $vars['type'] . '" ng-block-id="' . $block->id . '">';
                    $out .= nvweb_blocks_render($vars['type'], $block->trigger, $block->action, $vars['zone'], $block, $vars);
                    $out .= '</div>' . "\n";
                }
                break;
        }
        // the block requested at a CERTAIN POSITION was this, we've finished
        if (isset($vars['position']) && $vars['position'] == $position) {
            break;
        }
        $shown++;
        $position++;
    }
    if ($vars['zone'] == 'object') {
        $out = array($block_objects, count($block_objects));
    }
    return $out;
}
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:blocks.php

示例4: block_group_form

function block_group_form($item)
{
    global $DB;
    global $website;
    global $layout;
    global $theme;
    global $current_version;
    $navibars = new navibars();
    $naviforms = new naviforms();
    if (empty($item->id)) {
        $navibars->title(t(23, 'Blocks') . ' / ' . t(506, 'Groups') . ' / ' . t(38, 'Create'));
    } else {
        $navibars->title(t(23, 'Blocks') . ' / ' . t(506, 'Groups') . ' / ' . t(170, 'Edit') . ' [' . $item->id . ']');
    }
    if (empty($item->id)) {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>'));
    } else {
        $navibars->add_actions(array('<a href="#" onclick="navigate_tabform_submit(0);"><img height="16" align="absmiddle" width="16" src="img/icons/silk/accept.png"> ' . t(34, 'Save') . '</a>', '<a href="#" onclick="navigate_delete_dialog();"><img height="16" align="absmiddle" width="16" src="img/icons/silk/cancel.png"> ' . t(35, 'Delete') . '</a>'));
        $layout->add_script('
            function navigate_delete_dialog()
            {
                navigate_confirmation_dialog(
                    function() { window.location.href = "?fid=blocks&act=block_group_delete&id=' . $item->id . '"; }, 
                    null, null, "' . t(35, 'Delete') . '"
                );
            }
        ');
    }
    $navibars->add_actions(array('<a href="?fid=' . $_REQUEST['fid'] . '&act=0"><img height="16" align="absmiddle" width="16" src="img/icons/silk/brick.png"> ' . t(23, 'Blocks') . '</a>', '<a href="?fid=' . $_REQUEST['fid'] . '&act=block_types_list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/brick_edit.png"> ' . t(167, 'Types') . '</a>'));
    if (!empty($item->id)) {
        $notes = grid_notes::comments('block_group', $item->id);
        $navibars->add_actions(array('<a href="#" onclick="javascript: navigate_display_notes_dialog();"><span class="navigate_grid_notes_span" style=" width: 20px; line-height: 16px; ">' . count($notes) . '</span><img src="img/skins/badge.png" width="20px" height="18px" style="margin-top: -2px;" class="grid_note_edit" align="absmiddle" /> ' . t(168, 'Notes') . '</a>'));
    }
    $navibars->add_actions(array(!empty($item->id) ? '<a href="?fid=' . $_REQUEST['fid'] . '&act=block_group_edit"><img height="16" align="absmiddle" width="16" src="img/icons/silk/add.png"> ' . t(38, 'Create') . '</a>' : '', '<a href="?fid=' . $_REQUEST['fid'] . '&act=block_groups_list"><img height="16" align="absmiddle" width="16" src="img/icons/silk/application_view_list.png"> ' . t(39, 'List') . '</a>'));
    $navibars->form();
    if (!empty($item->id)) {
        $navibars->add_tab(t(23, "Blocks"));
        $allowed_types = array();
        if (!empty($item->code)) {
            for ($bg = 0; $bg < count($theme->block_groups); $bg++) {
                if ($theme->block_groups[$bg]->id == $item->code) {
                    if (isset($theme->block_groups[$bg]->allowed_types)) {
                        $allowed_types = $theme->block_groups[$bg]->allowed_types;
                    }
                    break;
                }
            }
        }
        $blocks_selected = array();
        if (!is_array($item->blocks)) {
            $item->blocks = array();
        }
        $navibars->add_tab_content($naviforms->hidden('blocks_group_selection', json_encode($item->blocks)));
        $navibars->add_tab_content($naviforms->hidden('blocks-order', ""));
        $block_types = block::types();
        $lang = $website->languages_published[0];
        $extensions_blocks = extension::blocks();
        for ($p = 0; $p < count($item->blocks); $p++) {
            unset($block);
            switch ($item->blocks[$p]['type']) {
                case "block":
                    $block = new block();
                    $block->load($item->blocks[$p]['id']);
                    if (empty($block) || empty($block->type)) {
                        continue;
                    }
                    $blocks_selected[] = '
                        <div class="block_group_block ui-state-default" data-block-id="' . $block->id . '" data-block-type="block" data-block-uid="' . $item->blocks[$p]['uid'] . '">
                            <div class="actions">
                                <a href="?fid=blocks&act=edit&id=' . $block->id . '"><img src="' . NAVIGATE_URL . '/img/icons/silk/pencil.png" /></a>
                                <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                            </div>
                            <div class="title">' . $block->dictionary[$lang]['title'] . '</div>
                            <div class="subcomment"><span style="float: right;">ID ' . $block->id . '</span><img src="img/icons/silk/brick.png" /> ' . $theme->t($block->type) . '</div>
                        </div>
                    ';
                    break;
                case "block_type":
                    for ($bt = 0; $bt < count($block_types); $bt++) {
                        if ($block_types[$bt]['id'] == $item->blocks[$p]['id']) {
                            $block = $block_types[$bt];
                            break;
                        }
                    }
                    $blocks_selected[] = '
                        <div class="block_group_block ui-state-default" data-block-id="' . $block['code'] . '" data-block-type="block_type" data-block-uid="' . $item->blocks[$p]['uid'] . '">
                            <div class="actions">
                                <a href="#" data-block-group="' . $block['block_group'] . '" data-block-type-code="' . $block['code'] . '" data-block-type-title="(span)" onclick="navigate_blocks_block_type_title(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/text_horizontalrule.png" /><span class="hidden">' . $item->blocks[$p]['title'] . '</span></a>
                                <a href="#" onclick="navigate_blocks_selection_remove(this);"><img src="' . NAVIGATE_URL . '/img/icons/silk/cancel.png" /></a>
                            </div>
                            <div class="title" title="' . $block['description'] . '">' . $block['title'] . '</div>
                            <div class="subcomment">
                                <span style="float: right;">ID ' . $block['code'] . '</span>
                                <img src="img/icons/silk/brick_link.png" /> ' . $block['count'] . ' ' . ($block['count'] == 1 ? t(437, "Block") : t(23, "Blocks")) . '
                            </div>
                        </div>
                    ';
                    break;
                case "block_group_block":
                    if (is_array($theme->block_groups)) {
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:blocks.php

示例5: nvweb_list


//.........这里部分代码省略.........
        $total = $DB->foundRows();
    } else {
        if ($vars['source'] == 'block') {
            list($rs, $total) = nvweb_blocks(array('type' => $vars['type'], 'number' => $vars['items'], 'mode' => $order == 'random' ? 'random' : 'ordered', 'zone' => 'object'));
        } else {
            if ($vars['source'] == 'block_link') {
                // only useful if this nvlist is inside another nv list of source="block"
                $block_links = $vars['nvlist_parent_item']->trigger['trigger-links'][$current['lang']];
                $rs = array();
                if (!is_array($block_links)) {
                    $block_links = array();
                }
                foreach ($block_links as $b_key => $b_data) {
                    if (!is_array($b_data)) {
                        $b_data = array();
                    }
                    $b_i = 0;
                    foreach ($b_data as $b_ref => $b_value) {
                        if (!isset($rs[$b_i])) {
                            $rs[$b_i] = new stdClass();
                        }
                        if (!isset($rs[$b_i]->id)) {
                            $rs[$b_i]->id = $b_ref;
                        }
                        $rs[$b_i]->{$b_key} = $b_value;
                        $b_i++;
                    }
                }
                $total = count($rs);
            } else {
                if ($vars['source'] == 'block_group') {
                    $bg = new block_group();
                    if (!empty($vars['type'])) {
                        $bg->load_by_code($vars['type']);
                    }
                    if (!empty($bg) && !empty($bg->blocks)) {
                        $rs = array();
                        foreach ($bg->blocks as $bgb) {
                            unset($bgbo);
                            switch ($bgb['type']) {
                                case 'block':
                                    $bgbo = new block();
                                    $bgbo->load($bgb['id']);
                                    if (empty($bgbo) || empty($bgbo->type)) {
                                        continue;
                                    }
                                    // check if we can display this block
                                    if (nvweb_object_enabled($bgbo)) {
                                        // check categories / exclusions
                                        if (!empty($bgbo->categories)) {
                                            $bgbo_cat_found = false;
                                            foreach ($categories as $list_cat) {
                                                if (in_array($list_cat, $bgbo->categories)) {
                                                    $bgbo_cat_found = true;
                                                }
                                            }
                                            if (!$bgbo_cat_found) {
                                                // block categories don't match the current list categories, skip this block
                                                continue;
                                            }
                                        }
                                        if (!empty($bgbo->exclusions)) {
                                            foreach ($categories as $list_cat) {
                                                if (in_array($list_cat, $bgbo->exclusions)) {
                                                    continue;
                                                }
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:67,代码来源:list.php


注:本文中的block::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。