コード例 #1
0
ファイル: api-block.php プロジェクト: danaiser/hollandLawns
 public function get_blocks_select_options_for_mirroring()
 {
     $block_type = $this->block['type'];
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     $options = array('' => '– Do Not Mirror –');
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $options;
     }
     foreach ($blocks as $block_id => $layout_id) {
         //Get the block instance
         $block = HeadwayBlocksData::get_block($block_id);
         //If the block is mirrored, skip it
         if (HeadwayBlocksData::is_block_mirrored($block)) {
             continue;
         }
         /* Do not show block that's in a mirrored wrapper */
         if (HeadwayWrappers::get_wrapper_mirror(HeadwayWrappers::get_wrapper(headway_get('wrapper', $block)))) {
             continue;
         }
         //Create the default name by using the block type and ID
         $default_name = HeadwayBlocks::block_type_nice($block['type']) . ' #' . $block['id'];
         //If we can't get a name for the layout, then things probably aren't looking good.  Just skip this block.
         if (!($layout_name = HeadwayLayout::get_name($layout_id))) {
             continue;
         }
         //Make sure the block exists
         if (!HeadwayBlocksData::block_exists($block['id'])) {
             continue;
         }
         $current_layout_suffix = $this->block['layout'] == $layout_id ? ' (Warning: Same Layout)' : null;
         //Get alias if it exists, otherwise use the default name
         $options[$block['id']] = headway_get('alias', $block['settings'], $default_name) . ' – ' . $layout_name . $current_layout_suffix;
     }
     //Remove the current block from the list
     unset($options[$this->block['id']]);
     return $options;
 }