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


PHP block::types方法代码示例

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


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

示例1: 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

示例2: nvweb_blocks

function nvweb_blocks($vars = array())
{
    global $website;
    global $DB;
    global $current;
    global $webgets;
    global $webuser;
    global $theme;
    $webget = 'blocks';
    nvweb_blocks_init();
    $out = '';
    $access = array();
    $access[] = 0;
    if (empty($current['webuser'])) {
        // 1: only signed in users, 2: only NON signed in users, 3: selected web user groups only
        $access[] = 2;
    } else {
        $access[] = 1;
        $access[] = 3;
    }
    // blocks type cache
    if (empty($webgets[$webget]['block_types'])) {
        $webgets[$webget]['block_types'] = block::types();
    }
    $block_types = $webgets[$webget]['block_types'];
    if ($vars['mode'] == 'single') {
        $order_mode = 'single';
    } else {
        // get the index for the block type requested
        $bti = array_multidimensional_search($block_types, array('code' => $vars['type']));
        // how must we process this block type
        $order_mode = @$block_types[$bti]['order'];
        if (empty($order_mode) || $order_mode == 'theme') {
            $order_mode = @$vars['mode'];
        }
    }
    // how many blocks of this type we have to show
    $howmany = @intval($block_types[$bti]['maximum']);
    if (empty($howmany) || $howmany > intval(@$vars['number']) && !empty($vars['number'])) {
        $howmany = intval(@$vars['number']) + 0;
    }
    // which zone of the block we have to return
    if (empty($vars['zone'])) {
        $vars['zone'] = 'block';
    }
    $categories = array();
    if (!empty($vars['categories'])) {
        $categories = explode(',', $vars['categories']);
        $categories = array_filter($categories);
    }
    if (isset($current['object']->category)) {
        $categories[] = $current['object']->category;
    } else {
        $categories[] = $current['category'];
    }
    $blocks = array();
    $categories_query = '';
    $exclusions_query = '';
    if (is_array($categories) && !empty($categories[0])) {
        foreach ($categories as $cq) {
            $categories_query .= " OR INSTR(CONCAT(',', categories, ','), '," . intval($cq) . ",') > 0 ";
            $exclusions_query .= " AND INSTR(CONCAT(',', exclusions, ','), '," . intval($cq) . ",') = 0 ";
        }
        $categories_query = ' AND (categories = "" ' . $categories_query . ') ';
    }
    switch ($order_mode) {
        case 'single':
            $query_type = '';
            if (!empty($vars['type'])) {
                $query_type = ' AND type = ' . protect($vars['type']);
            }
            $DB->query('
                SELECT id, type
                  FROM nv_blocks
                 WHERE enabled = 1
                   ' . $query_type . '
                   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) . ')
                   ' . $categories_query . '
                   ' . $exclusions_query . '
                   AND id = ' . protect($vars['id']));
            $row = $DB->first();
            if (!empty($row)) {
                $blocks[] = $row->id;
                $vars['type'] = $row->type;
            }
            break;
        case 'priority':
        case 'ordered':
            $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) . ')
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:blocks.php

示例3: load_from_resultset

 public function load_from_resultset($rs)
 {
     $main = $rs[0];
     $this->id = $main->id;
     $this->website = $main->website;
     $this->type = $main->type;
     $this->date_published = empty($main->date_published) ? '' : $main->date_published;
     $this->date_unpublish = empty($main->date_unpublish) ? '' : $main->date_unpublish;
     $this->date_modified = empty($main->date_modified) ? '' : $main->date_modified;
     $this->access = $main->access;
     $this->enabled = $main->enabled;
     $this->trigger = mb_unserialize($main->trigger);
     if (is_array($this->trigger['trigger-html'])) {
         foreach ($this->trigger['trigger-html'] as $language => $code) {
             $this->trigger['trigger-html'][$language] = htmlspecialchars_decode($code);
         }
     }
     if (is_array($this->trigger['trigger-content'])) {
         foreach ($this->trigger['trigger-content'] as $language => $code) {
             $this->trigger['trigger-content'][$language] = stripslashes($code);
         }
     }
     $this->action = mb_unserialize($main->action);
     $this->notes = $main->notes;
     $this->dictionary = webdictionary::load_element_strings('block', $this->id);
     // title
     $this->position = $main->position;
     $this->fixed = $main->fixed;
     $this->categories = array_filter(explode(',', $main->categories));
     $this->exclusions = array_filter(explode(',', $main->exclusions));
     $this->elements = json_decode($main->elements, true);
     // to get the array of groups first we remove the "g" character
     $groups = str_replace('g', '', $main->groups);
     $this->groups = explode(',', $groups);
     if (!is_array($this->groups)) {
         $this->groups = array($groups);
     }
     $block_classes = block::types();
     foreach ($block_classes as $bc) {
         if ($bc['code'] == $this->type) {
             $this->class = $bc['type'];
         }
     }
 }
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:44,代码来源:block.class.php

示例4: nvweb_properties

function nvweb_properties($vars = array())
{
    global $website;
    global $DB;
    global $current;
    global $cache;
    global $properties;
    global $webuser;
    $out = '';
    switch (@$vars['mode']) {
        case 'website':
            $wproperty = new property();
            $wproperty->load_from_theme($vars['property']);
            if (!empty($wproperty)) {
                $out = nvweb_properties_render($wproperty, $vars);
            }
            break;
        case 'webuser':
            $wuproperty = new property();
            $wuproperty->load_from_webuser($vars['property']);
            if (!empty($wuproperty)) {
                $out = nvweb_properties_render($wuproperty, $vars);
            }
            break;
        case 'element':
        case 'item':
            // deprecated, may be removed in a future version
            // if item ID is not given and the current object an element or a structure category?
            if (empty($vars['id']) && $current['type'] == 'structure') {
                // find the first embedded element for the current category
                // (because the template code has requested specifically to return the property from an element!)
                $itm = nvweb_content_items($current['object']->id, true, 1, true, 'priority');
                if (!empty($itm) && isset($itm[0])) {
                    $vars['id'] = $itm[0]->id;
                } else {
                    $vars['id'] = 0;
                }
            }
            if (!isset($properties['item-' . $vars['id']]) && !empty($vars['id'])) {
                // load item template
                if (empty($vars['template'])) {
                    $vars['template'] = $DB->query_single('template', 'nv_items', ' id = ' . protect($vars['id']));
                }
                // if template is not defined (embedded element), take its category template
                if (empty($vars['template'])) {
                    $vars['template'] = $DB->query_single('template', 'nv_structure', ' id = (
                            SELECT category
                            FROM nv_items
                            WHERE id = ' . intval($vars['id']) . '
                        )');
                }
                $properties['item-' . $vars['id']] = property::load_properties("item", $vars['template'], 'item', $vars['id']);
            } else {
                if (empty($vars['id'])) {
                    $vars['type'] = $current['object']->template;
                    if ($current['type'] == "item") {
                        $vars['id'] = $current['object']->id;
                    } else {
                        if ($current['type'] == "structure") {
                            // find the first embedded content associated with this structure entry
                            // (because the template code has requested specifically to return the property from an element!)
                            $itm = nvweb_content_items($current['object']->id, true, 1, true, 'priority');
                            if (!empty($itm) && isset($itm[0])) {
                                $vars['id'] = $itm[0]->id;
                            } else {
                                $vars['id'] = 0;
                            }
                        }
                    }
                    if (!isset($properties['item-' . $vars['id']])) {
                        $properties['item-' . $current['object']->id] = property::load_properties("item", $vars['type'], 'item', $vars['id']);
                    }
                }
            }
            $current_properties = $properties['item-' . $vars['id']];
            // now we find the property requested
            if (!is_array($current_properties)) {
                $current_properties = array();
            }
            foreach ($current_properties as $property) {
                if ($property->id == $vars['property'] || $property->name == $vars['property']) {
                    $out = nvweb_properties_render($property, $vars);
                    break;
                }
            }
            break;
        case 'block':
            if (!isset($properties['block-' . $vars['id']])) {
                // load item type
                if (empty($vars['type'])) {
                    $vars['type'] = $DB->query_single('type', 'nv_blocks', ' id = ' . protect($vars['id']));
                    if (empty($cache['block_types'])) {
                        $cache['block_types'] = block::types();
                    }
                    // we need to know if the block is defined in the active theme or in the database (numeric ID)
                    foreach ($cache['block_types'] as $bt) {
                        if ($bt['code'] == $vars['type']) {
                            $vars['type'] = $bt['id'];
                            break;
                        }
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:properties.php


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