예제 #1
0
 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;
 }
예제 #2
0
 static function get_blocks_select_options_for_mirroring($block_type)
 {
     $return = '';
     $blocks = HeadwayBlocksData::get_blocks_by_type($block_type);
     //If there are no blocks, then just return the Do Not Mirror option.
     if (!isset($blocks) || !is_array($blocks)) {
         return $return;
     }
     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 (headway_get('mirror-block', $block['settings'], false)) {
             continue;
         }
         //If the block is in the same layout as the current block, then do not allow it to be used as a block to mirror.
         if ($layout_id == headway_post('layout')) {
             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;
         }
         //Get alias if it exists, otherwise use the default name
         $return .= '<option value="' . $block['id'] . '">' . headway_get('alias', $block['settings'], $default_name) . ' &ndash; ' . $layout_name . '</option>';
     }
     return $return;
 }