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


PHP block::block_group_block_by_property方法代码示例

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


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

示例1: save_properties_from_array

    public static function save_properties_from_array($object_type, $object_id, $template, $properties_assoc = array(), $ws = null, $node_uid = "")
    {
        global $DB;
        global $website;
        global $theme;
        if (empty($ws)) {
            $ws = $website;
        }
        $dictionary = array();
        $property_object_type = $object_type;
        // object_type: item, structure, block, block_group_block
        if ($object_type == 'block_group_block') {
            // we have to identify the block subtype: block, block_type, block_group_block or extension_block
            // so we can get its properties definition
            if (!is_numeric($object_id)) {
                // assume there can only be one block group of the same type
                $block_group_id = $DB->query_single('MAX(id)', 'nv_block_groups', ' code = ' . protect($template) . ' AND website = ' . $ws->id);
                $object_id = $block_group_id;
                if (empty($block_group_id)) {
                    $object_id = 0;
                }
            }
            if (!empty($node_uid)) {
                $bg = new block_group();
                $bg->load($object_id);
                for ($b = 0; $b < count($bg->blocks); $b++) {
                    if ($bg->blocks[$b]['uid'] == $node_uid) {
                        $block_id = $bg->blocks[$b]['id'];
                        if ($bg->blocks[$b]['type'] == 'extension') {
                            // an extension block
                            $property_object_type = 'block_group-extension-block';
                            // load the extension, if installed in this instance
                            $extension = new extension();
                            $extension->load($bg->blocks[$b]['extension']);
                            // find the property declaration in the extension definition
                            if (isset($extension->definition->blocks)) {
                                for ($eb = 0; $eb < count($extension->definition->blocks); $eb++) {
                                    if ($extension->definition->blocks[$eb]->id == $block_id) {
                                        $block = $extension->definition->blocks[$eb];
                                        break;
                                    }
                                }
                            } else {
                                // ignore this property, extension is not installed or it does not have the requested block definition
                                continue;
                            }
                        } else {
                            // a block group block
                            $property_object_type = 'block_group_block';
                            $block = block::block_group_block($template, $block_id);
                        }
                        // note: standard blocks don't "embed" their properties in a block group,
                        // they have their own separate values
                        break;
                    }
                }
            } else {
                // compatibility with < Navigate 2.1 themes (to be removed)
                $properties_names = array_keys($properties_assoc);
                $block = block::block_group_block_by_property($properties_names[0]);
            }
            if (!isset($block->properties) || empty($block->properties)) {
                return false;
            }
            $properties = $block->properties;
        } else {
            $properties = property::elements($template, $object_type);
        }
        if (!is_array($properties)) {
            $properties = array();
        }
        foreach ($properties as $property) {
            if (!isset($properties_assoc[$property->name]) && !isset($properties_assoc[$property->id])) {
                continue;
            }
            $values_dict = array();
            $value = '';
            // we try to find the property value by "property name", if empty then we try to find it via "property id"
            if (isset($properties_assoc[$property->name])) {
                $value = $properties_assoc[$property->name];
            }
            if (empty($value)) {
                $value = $properties_assoc[$property->id];
            }
            // multilanguage property?
            if (in_array($property->type, array('text', 'textarea', 'link', 'rich_textarea')) || @$property->multilanguage == 'true' || @$property->multilanguage === true) {
                if (isset($properties_assoc[$property->name])) {
                    $values_dict = $properties_assoc[$property->name];
                }
                if (empty($values_dict)) {
                    $values_dict = $properties_assoc[$property->id];
                }
                $value = '[dictionary]';
            }
            if ($property->type == 'coordinates') {
                if (is_array($value)) {
                    $value = $value['latitude'] . '#' . $value['longitude'];
                }
                // if it isn't an array, then we suppose it already has the right format
            }
//.........这里部分代码省略.........
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:101,代码来源:property.class.php

示例2: nvweb_properties


//.........这里部分代码省略.........
                    $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;
                        }
                    }
                }
                $properties['block-' . $vars['id']] = property::load_properties("block", $vars['type'], 'block', $vars['id']);
            }
            $current_properties = $properties['block-' . $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_group_block':
            // find block_group block definition
            $block_group = null;
            // unknown
            $block_code = $vars['id'];
            $block_uid = $vars['uid'];
            if (empty($block_code)) {
                $block = block::block_group_block_by_property($vars['property']);
                $block_code = $block->type;
            } else {
                // find the block group block by its type
                $block = block::block_group_block($block_group, $block_code);
            }
            $properties = $block->properties;
            $current_properties = property::load_properties($block_code, $block->_block_group_id, 'block_group_block', $block_code, $block_uid);
            // 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 'structure':
            if (empty($vars['id'])) {
                if ($current['type'] == 'structure') {
                    $vars['id'] = $current['id'];
                } else {
                    $vars['id'] = $current['object']->category;
                }
            }
            if (!isset($properties['structure-' . $vars['id']])) {
                // load category template
                $category_template = $DB->query_single('template', 'nv_structure', ' id = ' . protect($vars['id']));
                if (!empty($category_template)) {
                    $properties['structure-' . $vars['id']] = property::load_properties("structure", $category_template, 'structure', $vars['id']);
                }
开发者ID:NavigateCMS,项目名称:Navigate-CMS,代码行数:67,代码来源:properties.php


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