当前位置: 首页>>代码示例>>PHP>>正文


PHP Env::path方法代码示例

本文整理汇总了PHP中Env::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Env::path方法的具体用法?PHP Env::path怎么用?PHP Env::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Env的用法示例。


在下文中一共展示了Env::path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find_cinemas_brazil

function find_cinemas_brazil()
{
    $start = microtime(true);
    $cinemas_br = Env::path('temp/brasil.json');
    $cinemas_br = file_get_contents($cinemas_br);
    $cinemas_br = json_decode($cinemas_br);
    //loop em todos os estados e cidades do estado
    $new_cinemas = array();
    $invalid_cinemas = array();
    foreach ($cinemas_br as $value) {
        $estado = $value->nome;
        $uf = $value->codigo;
        $cidades = $value->cidades;
        $cinema_finder = new CinemaFinder('br', $uf, $cidades);
        $cinemas = $cinema_finder->get_all_cinemas();
        $template = new CinemaTemplate();
        foreach ($cinemas as $cinema) {
            $base_dir = "cinema/br/";
            //passa o codigo do estado temporariamente para depois alterar e verificar se o cinema é realmente desse local
            $cinema->state_code = $uf;
            $template->create($base_dir, $cinema);
        }
        $new_cinemas = array_merge($new_cinemas, $template->get_new_cinemas());
        $invalid_cinemas = array_merge($invalid_cinemas, $template->get_invalid_cinemas());
    }
    $total = Helper::elapsed_time($start);
    Log::write("Tempo total procurando cinemas: {$total}");
    Sendmail::to_admin(count($new_cinemas) . " cinemas novos", $new_cinemas);
    Sendmail::to_admin(count($invalid_cinemas) . " cinemas sem cidade", $invalid_cinemas);
}
开发者ID:xxdf,项目名称:showtimes,代码行数:30,代码来源:discover-cinemas.php

示例2: update_showtimes

function update_showtimes()
{
    $start = microtime(true);
    $path = Env::path() . 'cinema/br';
    $cinemas = Helper::get_file_list($path);
    $updated = array();
    $invalid = array();
    $erros = array();
    foreach ($cinemas as $value) {
        $classname = basename($value, '.php');
        try {
            if (class_exists($classname)) {
                $cinema_class = new $classname();
                $cinema = $cinema_class->update();
                if (!empty($cinema)) {
                    $updated[] = $cinema;
                    if ($cinema->status == 'INVALID') {
                        $invalid[] = $cinema;
                    }
                }
            }
        } catch (Exception $e) {
            $erros[] = $classname . ' - ' . $e->getMessage();
        }
    }
    if (count($updated) > 0) {
        callback_subscribers($updated);
        Sendmail::to_admin(count($updated) . " cinemas atualizados", $updated);
    }
    Sendmail::to_admin(count($invalid) . " cinemas invalidos", $invalid);
    Sendmail::to_admin(count($erros) . " erros atualizando cinemas", $erros);
    $total = Helper::elapsed_time($start);
    Log::write("Tempo total atualizando cinemas: {$total}");
}
开发者ID:xxdf,项目名称:showtimes,代码行数:34,代码来源:update-showtimes.php

示例3: xtest_get_file_list

 function xtest_get_file_list()
 {
     $path = Env::path() . 'cinema/br';
     $files = Helper::get_file_list($path);
     echo "<pre>";
     print_r($files);
     echo "</pre>";
 }
开发者ID:xxdf,项目名称:showtimes,代码行数:8,代码来源:BasicTest.php

示例4: test_find

 public function test_find()
 {
     // $cinema_finder = new CinemaFinder('br','SP', array('Bauru'));
     // $cinemas =  $cinema_finder->get_all_cinemas();
     $dir = Env::path("cinema/br/");
     echo $dir;
     if (Helper::recursive_file_exists('cine_araujo_bauru.php', $dir)) {
         echo "existe";
     }
     // echo "<pre>";
     // print_r($cinemas);
     // echo "</pre>";
     //1. gera cinemas por todo o brasil com fallback para o google
     //
     //pega o json das cidades e faz loop em todas as cidades
     //no resultado de cada find cria a estrutura de diretorios se NÃO existir
     //para cada cinema gerar um class que é o fallback para o google movies...
     //cada classe de cinema tem q se registrar no couchdb para rodar via loop sem precisar navegar na estrutura
     //sempre que um cinema for chamado, browser ou via polling cron atualizar seu status no couchdb.
     //se no update executar e não tiver cinema remover do couchdb
     // $dir = "/cinema/br/sc/florianopolis/";
     //
     // $template = new CinemaTemplate();
     //
     // $arr = array("nome" => "GNC Iguatémi", "id" => "123", "endereco" => "endereco", "url" => "http://www.google.com.br/movies?near=porto+alegre,+rs,+bra&tid=8731d7134e5b461a");
     //
     // $template->create($dir, $arr);
     // echo $file;
     //
     // file_put_contents($file, "ssss");
     // $fh = fopen($myFile, 'w') or die("can't open file");
     // $stringData = "Subject\n";
     // fwrite($fh, $stringData);
     // $stringData = "Message\n";
     // fwrite($fh, $stringData);
     // fclose($fh);
     //$template_class = file_get_contents($url_template);
     // $cinema_finder = new CinemaFinder('br','RS', 'Florianópolis');
     // 		echo $cinema_finder->find();
     //2. rotina de polling - update de horarios
     //loop em todos os cinemas registrados no couchdb, so rodar a classe dinamica...
     //gerar e armazenar hash md5 do cinema e horarios para comparar e so fazer push para clientes com novidades.
     //no couch guardar id do cinema como array [pais, estado, cidade] ou ver como filtrar por estrutura... TALVEZ...
     //chamar callback do cliente registrado passando a lista de cinemas com horarios novos
     //controle de erros quando cinema não retornar horarios, pensar em outras..
     //3. Diariamente rodar o CinemaFinder usando o arquivo json de cidades para encontrar novos cinemas
     //para cada lista de cinemas por cidade retornada comparar com a ja existente no couchdb verificando o tid com o cinema do google e fazendo
     //reflexao para so validar os que implementar o googlemoviesadapter. o resultado disso cria a estrutura de dir e template como cinema novo e
     //notifica por email
     //quando pegar o cinema para gravar armazenar como literal estatico, tid do cinema, nome, endereco, e gps do endereco
 }
开发者ID:xxdf,项目名称:showtimes,代码行数:51,代码来源:CinemaFinderTest.php

示例5: transliterate

 public static function transliterate($string)
 {
     static $i18n_loaded = false;
     static $translations = array();
     if (!$i18n_loaded) {
         $path = Env::path('helper/i18n-ascii.txt');
         if (is_file($path)) {
             $translations = parse_ini_file($path);
         }
         $i18n_loaded = true;
     }
     return strtr($string, $translations);
 }
开发者ID:xxdf,项目名称:showtimes,代码行数:13,代码来源:Helper.php

示例6: img

 /**
  * Automatically resize and create images on the fly.
  * If the image already exists then it's path is just passed back.
  *
  * $options:
  * - string "path" The path that the images reside in (default: "images/img")
  * - string "basename" The filename, without extension, of the image, the extension will be automatically established and appended
  * - string "filename" The filename, including extension, of the image. Either this or "basename" must be set
  * - int "width" The maximum width that the image can be, if the image is wider it will be resized (maintaining the same aspect ratio)
  * - int "height" The maximum height that the image can be, if the image is taller it will be resized (maintaining the same aspect ratio)
  *
  * @param array $options An array of options (see above)
  *
  * @return string
  */
 public static function img($options = null)
 {
     $options = Helper::getOptions($options, ["path" => "images/img", "basename" => null, "filename" => null, "width" => null, "height" => null]);
     $path = $options["path"];
     if ($path[0] == "/") {
         $fullpath = $path;
     } else {
         $fullpath = Env::path($path, Env::PATH_DOCUMENT_ROOT);
     }
     $filename = $options["filename"];
     if ($basename = $options["basename"]) {
         $original = $fullpath . "/original/" . $basename;
         if (file_exists($original)) {
             if ($ext = static::getExtension($original)) {
                 $filename = $basename . "." . $ext;
                 copy($original, $fullpath . "/original/" . $filename);
             }
         }
     }
     if (!$filename) {
         throw new \Exception("No image filename provided to use");
     }
     $original = $fullpath . "/original/" . $filename;
     if (!file_exists($original)) {
         throw new \Exception("Original image file does not exist (" . $original . ")");
     }
     $w = $options["width"];
     $h = $options["height"];
     if (!$w && !$h) {
         return $path . "/original/" . $filename;
     }
     if ($w && $h) {
         $dir = "max" . $w . "x" . $h;
     } elseif ($w) {
         $dir = "width" . $w;
     } elseif ($h) {
         $dir = "height" . $h;
     }
     $fullpath .= "/" . $dir;
     $newfile = $fullpath . "/" . $filename;
     $newpath = $path . "/" . $dir . "/" . $filename;
     if (file_exists($newfile)) {
         return $newpath;
     }
     if (!is_dir($fullpath)) {
         mkdir($fullpath, 0777, true);
     }
     static::resize(["fromPath" => $original, "toPath" => $newfile, "width" => $w, "height" => $h]);
     return $newpath;
 }
开发者ID:Masterfion,项目名称:plugin-sonos,代码行数:65,代码来源:Image.php

示例7: new_template

 private function new_template($dir, Cinema $cinema)
 {
     $nome = $cinema->name;
     $class = Helper::clean_string($nome, -1, '_');
     $file = $class . '.php';
     $tid = $cinema->id;
     //se ja tem uma classe para o cinema descarta entao
     //pesquisa classe com mesmo nome recursivo a partir do diretorio do estado...
     if (!Helper::recursive_file_exists($file, $dir)) {
         $temp_uf = $cinema->state_code;
         $cinema = $this->geo_cinema($cinema);
         $endereco = $cinema->address;
         $telefone = $cinema->phone;
         $url = $cinema->url;
         $lat = $cinema->lat;
         $long = $cinema->long;
         $cidade = $cinema->city;
         $estado = $cinema->state;
         $uf = $cinema->state_code;
         //esse if deve evitar o compartamente do google de procurar cinemas proximos tipo colocar volta redonda dentro de sp
         if (empty($uf)) {
             //se caiu aqui é pq o geocode do endereco do cine falhou entao usa a uf temp pelo menos para colocar o cine no dir correto
             $uf = $temp_uf;
             $path = $dir . $uf . '/';
         } else {
             //bug do google maps
             if (Helper::clean_string($uf) == 'sao-paulo') {
                 $uf = 'SP';
             }
             $path = $dir . $uf . '/' . Helper::clean_string($cinema->city);
         }
         $path = strtolower($path);
         $this->create_dir($path);
         $tpl = Env::path('helper/CinemaClass.tpl');
         if (!is_file($tpl)) {
             Log::write("Não achou {$tpl}");
             exit(1);
         }
         //a classe do cinema fica sempre em cinema/uf/cidade/file.php
         $file = $path . '/' . $file;
         $handle = fopen($file, 'w');
         if ($handle == false) {
             Log::write("Erro criando {$file}");
             exit(1);
         }
         $cinema_class = file_get_contents($tpl);
         $content = str_replace("%class", $class, $cinema_class);
         $content = str_replace("%nome", $nome, $content);
         $content = str_replace("%id", $tid, $content);
         $content = str_replace("%endereco", $endereco, $content);
         $content = str_replace("%telefone", $telefone, $content);
         $content = str_replace("%cidade", $cidade, $content);
         $content = str_replace("%estado", $estado, $content);
         $content = str_replace("%uf", $uf, $content);
         $content = str_replace("%lat", $lat, $content);
         $content = str_replace("%long", $long, $content);
         $content = str_replace("%url", $url, $content);
         fwrite($handle, $content);
         fclose($handle);
         //guarda todos os novos cinemas criados para depois notificar via email para o admin controlar...
         //se não achou a cidade do cinema via geolocation vai colocar em um lugar errado, entao tem q notificar...
         $cinema_path = str_replace(Env::path(), "", $file);
         if (empty($cidade)) {
             $this->invalid_cinemas[] = $cinema_path;
         } else {
             $this->new_cinemas[] = $cinema_path;
         }
     }
 }
开发者ID:xxdf,项目名称:showtimes,代码行数:69,代码来源:CinemaTemplate.php


注:本文中的Env::path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。