Exemplo n.º 1
0
 /**
  * 
  * cria uma url para chamar um arquivo CSS
  * 
  * @param string $url
  * @param array $options
  * @return string
  */
 public function image($url, $options = [])
 {
     $id = 'img-' . \Core\Inflector::underscore(\Core\Inflector::camelize(str_replace('/', '/', $url)));
     $default = ['src' => $this->request->url($url), 'alt' => '', 'title' => '', 'id' => $id];
     return $this->tags('img', \Core\Hash::merge($default, $options), false);
 }
Exemplo n.º 2
0
 /**
  * 
  * função que faz um pre tratamento nas condições de consulta na tabela do banco de dados.
  * 
  * @param string $campos
  * @param array $arguments
  * @return string
  */
 private function _argumentos($campos, $arguments, $tipo = '=')
 {
     $type = 'AND';
     if (stripos($campos, 'And') !== false) {
         $campos = explode('And', $campos);
     } elseif (stripos($campos, 'Or') !== false) {
         $campos = explode('Or', $campos);
         $type = 'OR';
     } else {
         $campos = [$campos];
     }
     foreach ($campos as $key => $value) {
         $this->where(strtolower(\Core\Inflector::underscore($value)), $arguments[$key], $tipo, $type);
     }
 }
Exemplo n.º 3
0
 /**
  * 
  * Padroniza o nome
  * 
  * @param string $name
  * @param string|null $prefix
  * @return string
  */
 public function getNameChave($name)
 {
     $ex = explode('.', $name);
     foreach ($ex as $key => $value) {
         $ex[$key] = str_replace('-', '_', Inflector::underscore($value));
     }
     $index = $ex[0];
     unset($ex[0]);
     $name = '';
     if (!empty($ex)) {
         $name = '[' . implode('][', $ex) . ']';
     }
     return $index . $name;
 }
Exemplo n.º 4
0
 public function prepareUrl($url)
 {
     $defautl = ['action' => $this->action, 'controller' => $this->controller, 'path' => $this->path, 'params' => '', 'query' => []];
     $url = array_merge($defautl, $url);
     if (!empty($url['path'])) {
         if (is_array($url['path'])) {
             foreach ($url['path'] as $key => $value) {
                 $url['path'][$key] = Inflector::underscore(Inflector::camelize($value));
             }
         } else {
             $url['path'] = Inflector::underscore(Inflector::camelize($url['path']));
         }
     }
     if (!empty($url['params'])) {
         foreach ($url['params'] as $key => $value) {
             $url['params'][$key] = Inflector::slug($value);
         }
     }
     $oldUrl = $url;
     unset($oldUrl['action'], $oldUrl['controller'], $oldUrl['path'], $oldUrl['params'], $oldUrl['query'], $oldUrl['?']);
     if (!empty($oldUrl)) {
         //$url['params'] = array_merge($url['params'], $oldUrl);
         foreach ($oldUrl as $key => $value) {
             unset($url[$key]);
             $url['params'][$key] = $value;
         }
     }
     if (!empty($url['?'])) {
         $url['query'] = Hash::merge($url['query'], $url['?']);
         unset($url['?']);
     }
     $_url = [];
     if (!empty($url['path'])) {
         if (is_array($url['path'])) {
             $_url['path'] = implode('/', $url['path']);
         } else {
             $_url['path'] = $url['path'];
         }
     }
     if (!empty($url['controller'])) {
         $_url['controller'] = Inflector::underscore($url['controller']);
     }
     if (!empty($url['action'])) {
         $_url['action'] = Inflector::underscore($url['action']);
     }
     if (!empty($url['params']) and is_array($url['params'])) {
         $_url['params'] = implode('/', $url['params']);
     }
     if (!empty($url['query']) and is_array($url['query'])) {
         $_url['query'] = '?' . http_build_query($url['query']);
     }
     return $_url;
 }