original_string: public function build(array $data)
      {
          if (is_array($data['asset'])) {
              $type = 'js';
          } else if (strpos($data['asset'], 'http') === 0) {
              $type = 'external';
          } else {
              $type = pathinfo($data['asset'], PATHINFO_EXTENSION);
          }
  
          $data += array(
              'file' => '',
              'key' => null,
              'merge' => '',
              'version' => '',
              'type' => $type,
              'text' => false,
              'condition' => '',
              'position' => 'top'
          );
  
          if (!isset($data['weight'])) {
              $data['weight'] = $this->getNextWeight($data['type'], $data['position']);
          }
  
          if (!in_array($data['type'], array('css', 'js'))) {
              $data['text'] = true;
          }
  
          if (($type !== 'external' && $type != $data['type']) || is_array($data['asset'])) {
              $data['text'] = true; // Arrays will be converted to JSON
          }
  
          if ($data['text']) {
  
              if (!isset($data['key'])) {
                  $data['key'] = 'text.' . md5(json_encode($data['asset']));
              }
  
              return $data;
          }
  
          if (gplcart_path_is_absolute($data['asset'])) {
              $data['file'] = $data['asset'];
              $data['asset'] = gplcart_path_relative($data['asset']);
          } else if ($type !== 'external') {
              $data['file'] = gplcart_path_absolute($data['asset']);
          }
  
          if (!empty($data['file'])) {
  
              if (!file_exists($data['file'])) {
                  return array();
              }
  
              $data['version'] = filemtime($data['file']);
          }
  
          $data['key'] = $data['asset'] = str_replace('\\', '/', $data['asset']);
          return $data;
      }
code: public function build(array $data)
      {
          if (is_array($data['asset'])) {
              $type = 'js';
          } else if (strpos($data['asset'], 'http') === 0) {
              $type = 'external';
          } else {
              $type = pathinfo($data['asset'], PATHINFO_EXTENSION);
          }
  
          $data += array(
              'file' => '',
              'key' => null,
              'merge' => '',
              'version' => '',
              'type' => $type,
              'text' => false,
              'condition' => '',
              'position' => 'top'
          );
  
          if (!isset($data['weight'])) {
              $data['weight'] = $this->getNextWeight($data['type'], $data['position']);
          }
  
          if (!in_array($data['type'], array('css', 'js'))) {
              $data['text'] = true;
          }
  
          if (($type !== 'external' && $type != $data['type']) || is_array($data['asset'])) {
              $data['text'] = true; // Arrays will be converted to JSON
          }
  
          if ($data['text']) {
  
              if (!isset($data['key'])) {
                  $data['key'] = 'text.' . md5(json_encode($data['asset']));
              }
  
              return $data;
          }
  
          if (gplcart_path_is_absolute($data['asset'])) {
              $data['file'] = $data['asset'];
              $data['asset'] = gplcart_path_relative($data['asset']);
          } else if ($type !== 'external') {
              $data['file'] = gplcart_path_absolute($data['asset']);
          }
  
          if (!empty($data['file'])) {
  
              if (!file_exists($data['file'])) {
                  return array();
              }
  
              $data['version'] = filemtime($data['file']);
          }
  
          $data['key'] = $data['asset'] = str_replace('\\', '/', $data['asset']);
          return $data;
      }
code_tokens: public function build ( array $ data ) { if ( is_array ( $ data [ 'asset' ] ) ) { $ type = 'js' ; } else if ( strpos ( $ data [ 'asset' ] , 'http' ) === 0 ) { $ type = 'external' ; } else { $ type = pathinfo ( $ data [ 'asset' ] , PATHINFO_EXTENSION ) ; } $ data += array ( 'file' => '' , 'key' => null , 'merge' => '' , 'version' => '' , 'type' => $ type , 'text' => false , 'condition' => '' , 'position' => 'top' ) ; if ( ! isset ( $ data [ 'weight' ] ) ) { $ data [ 'weight' ] = $ this -> getNextWeight ( $ data [ 'type' ] , $ data [ 'position' ] ) ; } if ( ! in_array ( $ data [ 'type' ] , array ( 'css' , 'js' ) ) ) { $ data [ 'text' ] = true ; } if ( ( $ type !== 'external' && $ type != $ data [ 'type' ] ) || is_array ( $ data [ 'asset' ] ) ) { $ data [ 'text' ] = true ; // Arrays will be converted to JSON } if ( $ data [ 'text' ] ) { if ( ! isset ( $ data [ 'key' ] ) ) { $ data [ 'key' ] = 'text.' . md5 ( json_encode ( $ data [ 'asset' ] ) ) ; } return $ data ; } if ( gplcart_path_is_absolute ( $ data [ 'asset' ] ) ) { $ data [ 'file' ] = $ data [ 'asset' ] ; $ data [ 'asset' ] = gplcart_path_relative ( $ data [ 'asset' ] ) ; } else if ( $ type !== 'external' ) { $ data [ 'file' ] = gplcart_path_absolute ( $ data [ 'asset' ] ) ; } if ( ! empty ( $ data [ 'file' ] ) ) { if ( ! file_exists ( $ data [ 'file' ] ) ) { return array ( ) ; } $ data [ 'version' ] = filemtime ( $ data [ 'file' ] ) ; } $ data [ 'key' ] = $ data [ 'asset' ] = str_replace ( '\\' , '/' , $ data [ 'asset' ] ) ; return $ data ; }
docstring: Builds asset data
  @param array $data
  @return array
docstring_tokens: Builds asset data