Pega o conteúdo de um block
542564
protected function getBlock($name = null)
    {
        return ($name == null) ? $this->block : (isset($this->block[$name]) ? $this->block[$name] : false);
    }
634081
public function checkIpRange($ip, $rangStart, $rangFinish)
    {
        $sub = explode(".", $ip);
        //rotinas para verificar se é um ip válido...
        if (count($sub) != 4) {
            return array(false, "IP Inválido");
        }
        for ($i = 0; $i < count($sub); $i++) {
            if ($sub[$i] < 0 || $sub[$i] > 255 || !is_numeric($sub[$i])) {
                return array(false, "IP Inválido");
            }
        }
        $ini = explode(".", $rangStart);
        //rotinas para verificar se é um ip válido...
        if (count($ini) != 4) {
            return array(false, "Faixa inicial inválida");
        }
        for ($i = 0; $i < count($ini); $i++) {
            if ($ini[$i] < 0 || $ini[$i] > 255 || !is_numeric($ini[$i])) {
                return array(false, "Faixa inicial inválida");
            }
        }
        $fim = explode(".", $rangFinish);
        //rotinas para verificar se é um ip válido...
        if (count($fim) != 4) {
            return array(false, "Faixa final inválida");
        }
        for ($i = 0; $i < count($fim); $i++) {
            if ($fim[$i] < 0 || $fim[$i] > 255 || !is_numeric($fim[$i])) {
                return array(false, "Faixa inicial inválida");
            }
        }
        // verificar se as faixas estao corretas
        if ($ini[0] > $fim[0]) {
            return array(false, "Faixa inicial deve ser menor que faixa final");
        }
        if ($ini[1] > $fim[1] && $ini[0] == $fim[0]) {
            return array(false, "Faixa inicial deve ser menor que faixa final");
        }
        if ($ini[2] > $fim[2] && $ini[0] == $fim[0] && $ini[1] == $fim[1]) {
            return array(false, "Faixa inicial deve ser menor que faixa final");
        }

        if ($ini[3] > $fim[3] && $ini[0] == $fim[0] && $ini[1] == $fim[1] && $ini[2] == $fim[2]) {
            return array(false, "Faixa inicial deve ser menor que faixa final");
        }

        //enfim verifica se o ip passado está dentro desta faixa...
        if ($sub[0] < $ini[0] || $sub[0] > $fim[0]) {
            return array(false, "IP fora da faixa");
        }
        if ($sub[1] < $ini[1] || $sub[1] > $fim[1]) {
            if ($sub[0] > !$fim[0] || $sub[0] < !$ini[0]) {
                return array(false, "IP Fora da Faixa");
            }
        }
        if ($sub[2] < $ini[2] || $sub[2] > $fim[2]) {
            if ($sub[1] > !$fim[1] || $sub[1] < !$ini[1]) {
                if ($sub[0] > !$fim[0] || $sub[0] < !$ini[0]) {
                    return array(false, "IP Fora da Faixa");
                }
            }
        }

        if ($sub[3] < $ini[3] || $sub[3] > $fim[3]) {
            if ($sub[2] > !$fim[2] || $sub[2] < !$ini[2]) {
                if ($sub[1] > !$fim[1] || $sub[1] < !$ini[1]) {
                    if ($sub[0] > !$fim[0] || $sub[0] < !$ini[0]) {
                        return array(false, "IP Fora da Faixa");
                    }
                }
            }
        }

        return array(true);
    }
282242
@Override public void beforeBlock() {
    if (count > 0) {
      try {
        flush();
      } catch (IOException e) {
        logger.log(Level.SEVERE, "Flush from soy failed", e);
      }
    }
  }
1271317
synchronized void deleteBlock(Block block) {
    if (!isInitialized()) {
      return;
    }
    BlockScanInfo info = blockMap.get(block);
    if ( info != null ) {
      delBlockInfo(info);
    }
  }
1327067
private function createCmsBlock($blockData)
    {
        // Check if template filename exists
        $filename = $blockData['filename'];
        $template = $this->getTemplatePath('blocks') . $filename;
        // phpcs:ignore
        if (!file_exists($template)) {
            return;
        }

        // Remove filename from data
        unset($blockData['filename']);

        // Fetch template content
        // phpcs:ignore
        $templateContent = @file_get_contents($template);

        $data = [
            'stores'    => [0],
            'is_active' => 1,
        ];

        // Find title
        if (preg_match('/<!--@title\s*(.*?)\s*@-->/u', $templateContent, $matches)) {
            $data['title'] = $matches[1];
            $templateContent = str_replace($matches[0], '', $templateContent);
        }

        // Remove comment lines
        $content = preg_replace('#\{\*.*\*\}#suU', '', $templateContent);
        $content = trim($content);
        $data['content'] = $content;

        $block = $this->blockFactory->create();
        $block = $block->load($blockData['identifier'], 'identifier');

        if ($block->getId()) {
            $data['block_id'] = $block->getId();
        }

        $data['identifier'] = $blockData['identifier'];
        $block->addData($data);
        $this->blockRepository->save($block);
    }
347561
private function createPublicFiles()
    {
        $moduleNameLower = strtolower($this->getModule());

        /* Criação do arquivo de controller padrão do módulo */
        file_put_contents(PUBLIC_PATH . 'css' . DS . $moduleNameLower . DS . 'style.css', '/**/');
        chmod(PUBLIC_PATH . 'css' . DS . $moduleNameLower . DS . 'style.css', 0644);

        file_put_contents(PUBLIC_PATH . 'css' . DS . $moduleNameLower . DS . "mediaquery.css", '/**/');
        chmod(PUBLIC_PATH . 'css' . DS . $moduleNameLower . DS . 'mediaquery.css', 0644);
    }
98308
public function start($block)
    {
        if ($this->enabled) {
            if (!isset($this->blocks[$block])) {
                $this->blocks[$block] = array();
            }

            $this->blocks[$block]['start'] = microtime(true);
            $this->blocks[$block]['start-line'] = $this->getLineNumber();
        }
    }
300613
def filtra_json(pandoc_json_tree)
      # Exemplo de código:
      
      # {"blocks":[{"t":"OrderedList","c":[[1,{"t":"LowerAlpha"},{"t":"OneParen"}],[[{"t":"Plain","c":[{"t":"Str","c":"item"},{"t":"Space"},{"t":"Str","c":"1."}]}],[{"t":"Plain","c":[{"t":"Str","c":"item"},{"t":"Space"},{"t":"Str","c":"2."}]}],[{"t":"Plain","c":[{"t":"Str","c":"item"},{"t":"Space"},{"t":"Str","c":"3."}]}]]]}],"pandoc-api-version":[1,17,0,4],"meta":{}}
      tree = JSON.parse(pandoc_json_tree)
      meta = tree["meta"]
      blocks = tree["blocks"]
      api = tree["pandoc-api-version"]
      
      filtrados = []
      anterior = nil
      
      if not blocks
        raise ArgumentError, "Problema no argumento passado: #{pandoc_json_tree}"
      end

      blocks.each do |node|
        if (lista?(node)) then
          lista_modificada = processa_items_da_lista(node)
          filtrados << lista_modificada
        else
          filtrados << node
        end
      end
      JSON.generate({"blocks"=>filtrados, "pandoc-api-version" => api, "meta" => meta})
    end
1122696
public function handleBlock()
    {
        if ($id = $this->owner->getRequest()->param('ID')) {
            $blocks = $this->owner->data()->getBlockList(null, true, true, true);
            if ($block = $blocks->find('ID', $id)) {
                return $block->getController();
            }
        }

        return $block->getController();
    }
15385
function markLoneBlock() {
            if (loneBlocks.length === 0) {
                return;
            }

            const block = context.getAncestors().pop();

            if (loneBlocks[loneBlocks.length - 1] === block) {
                loneBlocks.pop();
            }
        }
3048
private static void transposeBlock(DMatrixRBlock A , DMatrixRBlock A_tran,
                                       int indexA , int indexC ,
                                       int width , int height )
    {
        for( int i = 0; i < height; i++ ) {
            int rowIndexC = indexC + i;
            int rowIndexA = indexA + width*i;
            int end = rowIndexA + width;
            for( ; rowIndexA < end; rowIndexC += height, rowIndexA++ ) {
                A_tran.data[ rowIndexC ] = A.data[ rowIndexA ];
            }
        }
    }
553545
function blockSet(BlockInterface $block, $templateFile) {
		$this->_blockStack[]= $block;
		$this->_templateFileStack[]= $templateFile;
	}
1175834
public void blockManagement() {
        Vector dwgObjectsWithoutBlocks = new Vector();
        boolean addingToBlock = false;
        for( int i = 0; i < dwgObjects.size(); i++ ) {
            try {
                DwgObject entity = (DwgObject) dwgObjects.get(i);
                if (entity instanceof DwgArc && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgEllipse && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgCircle && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgPolyline2D && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgPolyline3D && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgLwPolyline && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgSolid && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgLine && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgPoint && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgMText && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgText && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgAttrib && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgAttdef && !addingToBlock) {
                    dwgObjectsWithoutBlocks.add(entity);
                } else if (entity instanceof DwgBlock) {
                    addingToBlock = true;
                } else if (entity instanceof DwgEndblk) {
                    addingToBlock = false;
                } else if (entity instanceof DwgBlockHeader) {
                    addingToBlock = true;
                } else if (entity instanceof DwgInsert && !addingToBlock) {
                    /* double[] p = ((DwgInsert) entity).getInsertionPoint();
                     Point2D point = new Point2D.Double(p[0], p[1]);
                     double[] scale = ((DwgInsert) entity).getScale();
                     double rot = ((DwgInsert) entity).getRotation();
                     int blockHandle = ((DwgInsert) entity).getBlockHeaderHandle();
                     manageInsert(point, scale, rot, blockHandle, i,
                     dwgObjectsWithoutBlocks);*/
                } else {
                    // System.out.println("Detectado dwgObject pendiente de implementar");
                }
            } catch (StackOverflowError e) {
                e.printStackTrace();
                System.out.println("Overflowerror at object: " + i);
            }
        }
        dwgObjects = dwgObjectsWithoutBlocks;
    }
70570
void insertIntoList(BlockInfo head, int headIndex, BlockInfo tail, int tailIndex, int count) {
    if (head == null)
      return;
    
    // connect tail to now-head
    tail.setNext(tailIndex, blockList);
    if (blockList != null)
      blockList.setPrevious(blockList.findDatanode(this), tail);
    
    // create new head
    blockList = head;
    blockList.setPrevious(headIndex, null);
    
    // add new blocks to the count
    numOfBlocks += count;
  }
389682
private void beginMainBlock() {
        int blockNo = registerBlock(null); // =0
        BlockTabRec btr = blockTab[blockNo];
        btr.tPosBegin = 0;
        btr.tPosContentsBegin = 0;
        openBlocksTab[currentNestingLevel] = blockNo;
        currentNestingLevel++;
    }
829304
function(e) {
    var blockA = this.getInputTargetBlock('THEN');
    var blockB = this.getInputTargetBlock('ELSE');
    var parentConnection = this.outputConnection.targetConnection;
    // Disconnect blocks that existed prior to this change if they don't match.
    if ((blockA || blockB) && parentConnection) {
      for (var i = 0; i < 2; i++) {
        var block = (i == 1) ? blockA : blockB;
        if (block && !block.outputConnection.checkType_(parentConnection)) {
          // Ensure that any disconnections are grouped with the causing event.
          Blockly.Events.setGroup(e.group);
          if (parentConnection === this.prevParentConnection_) {
            this.unplug();
            parentConnection.getSourceBlock().bumpNeighbours_();
          } else {
            block.unplug();
            block.bumpNeighbours_();
          }
          Blockly.Events.setGroup(false);
        }
      }
    }
    this.prevParentConnection_ = parentConnection;
  }
382459
private static void multBlockAdd( double []blockA, double []blockB, double []blockC,
                                     final int m, final int n, final int o,
                                     final int blockLength ) {
//        for( int i = 0; i < m; i++ ) {
//            for( int j = 0; j < o; j++ ) {
//                double val = 0;
//                for( int k = 0; k < n; k++ ) {
//                    val += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
//                }
//
//                blockC[ i*blockLength + j] += val;
//            }
//        }

//        int rowA = 0;
//        for( int i = 0; i < m; i++ , rowA += blockLength) {
//            for( int j = 0; j < o; j++ ) {
//                double val = 0;
//                int indexB = j;
//                int indexA = rowA;
//                int end = indexA + n;
//                for( ; indexA != end; indexA++ , indexB += blockLength ) {
//                    val += blockA[ indexA ]*blockB[ indexB ];
//                }
//
//                blockC[ rowA + j] += val;
//            }
//        }

//        for( int k = 0; k < n; k++ ) {
//            for( int i = 0; i < m; i++ ) {
//                for( int j = 0; j < o; j++ ) {
//                    blockC[ i*blockLength + j] += blockA[ i*blockLength + k]*blockB[ k*blockLength + j];
//                }
//            }
//        }

        for( int k = 0; k < n; k++ ) {
            int rowB = k*blockLength;
            int endB = rowB+o;
            for( int i = 0; i < m; i++ ) {
                int indexC = i*blockLength;
                double valA = blockA[ indexC + k];
                int indexB = rowB;
                
                while( indexB != endB ) {
                    blockC[ indexC++ ] += valA*blockB[ indexB++];
                }
            }
        }
    }