public static function display_blocks($tags, $id, $item, $Page, $Form, $Template, $blocks_link_builder)
 {
     $block_tags = $Template->find_all_tags('block');
     $blocks_index = array();
     if (PerchUtil::count($block_tags)) {
         foreach ($block_tags as $Tag) {
             if ($Tag->is_set('type')) {
                 $blocks_index[$Tag->type] = $Tag;
             }
         }
     }
     $blocks_data = array();
     if (isset($item['_blocks'])) {
         $blocks_data = $item['_blocks'];
     }
     $stamp = time();
     echo '<div class="blocks">';
     if (PerchUtil::count($blocks_data)) {
         $flat_data = array();
         if ($id === null) {
             $flat_data = PerchContent_Util::flatten_details($blocks_data, '_blocks', false, true);
         }
         foreach ($blocks_data as $count => $block_data) {
             if (isset($flat_data[$count])) {
                 $block_data = array_merge($block_data, $flat_data[$count]);
             }
             self::display_block($id, $blocks_index, $block_data, $count, $Page, $Template, $Form, $stamp);
         }
     }
     echo '<div class="master block-add-bar ' . (PerchUtil::count($blocks_data) ? 'hidden' : '') . '" tabindex="0">';
     $qs = array();
     $qs['id'] = PerchUtil::get('id');
     $qs['itm'] = $id;
     foreach ($blocks_index as $BlockTag) {
         $qs['add-block'] = $BlockTag->type();
         $url = call_user_func($blocks_link_builder, $qs);
         echo '<a href="' . PerchUtil::html($url, true) . '" class="icon add" tabindex="0">' . $BlockTag->label() . '</a> ';
     }
     echo '</div>';
     echo '</div>';
     // .blocks
 }
Пример #2
0
    $draft = true;
    if ($Region->regionPage() == '*') {
        $Alert->set('draft', PerchLang::get('You are editing a draft.'));
    } else {
        $path = rtrim($Settings->get('siteURL')->val(), '/');
        if ($Region->get_option('edit_mode') == 'listdetail' && $Region->get_option('searchURL') != '') {
            $search_url = $Region->get_option('searchURL');
            $Region->tmp_url_vars = $details[0];
            $search_url = preg_replace_callback('/{([A-Za-z0-9_\\-]+)}/', array($Region, 'substitute_url_vars'), $search_url);
            $Region->tmp_url_vars = false;
            if (strpos($search_url, '?') !== false) {
                $preview_url = $search_url . '&' . PERCH_PREVIEW_ARG . '=all';
            } else {
                $preview_url = $search_url . '?' . PERCH_PREVIEW_ARG . '=all';
            }
        } else {
            $preview_url = $path . $Region->regionPage() . '?' . PERCH_PREVIEW_ARG . '=all';
        }
        $Alert->set('draft', PerchLang::get('You are editing a draft.') . ' <a href="' . PerchUtil::html($preview_url) . '" class="action draft-preview">' . PerchLang::get('Preview') . '</a>');
    }
} else {
    $draft = false;
}
if (isset($_GET['created'])) {
    $Alert->set('success', PerchLang::get('Content successfully updated and a new item added.'));
}
//$Perch->add_javascript(PERCH_LOGINPATH.'/core/assets/js/repeaters.js?v='.$Perch->version);
//$Perch->add_css(PERCH_LOGINPATH.'/core/assets/css/repeaters.css?v='.$Perch->version);
if (PerchUtil::count($details)) {
    $details = PerchContent_Util::flatten_details($details);
}