本文整理汇总了PHP中Thin\Inflector::urlize方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::urlize方法的具体用法?PHP Inflector::urlize怎么用?PHP Inflector::urlize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thin\Inflector
的用法示例。
在下文中一共展示了Inflector::urlize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($db)
{
$this->orm = $db;
$this->db = $db->db();
$this->table = $db->table();
$dir = Config::get('dir.blizz.store', session_save_path());
if (!is_dir($dir)) {
File::mkdir($dir);
}
$dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
if (!is_dir($dir)) {
File::mkdir($dir);
}
$this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
if (!is_dir($this->dir)) {
File::mkdir($this->dir);
}
$file = $this->dir . DS . 'data.db';
$new = false;
if (!is_file($file)) {
File::create($file);
$new = true;
File::put($this->dir . DS . 'age.blizz', '');
}
$link = new SQLite3($file);
Now::set("blizz.link.{$this->db}.{$this->table}", $link);
if ($new) {
$this->init();
}
}
示例2: import
public function import(array $array, $erase = false)
{
if (count($array)) {
$data = [];
$i = 1;
foreach ($array as $row) {
if (Arrays::is($row) && Arrays::assoc($row)) {
foreach ($row as $key => $value) {
$newRow[Inflector::urlize($key, '_')] = $value;
}
array_push($data, $newRow);
$i++;
}
}
if (count($data)) {
$file = $this->dir . DS . 'data.db';
if (true === $erase) {
File::delete($file);
}
foreach ($data as $row) {
$this->save($row);
}
}
}
return $this;
}
示例3: __construct
public function __construct($db = null, $table = null)
{
$this->db = is_null($db) ? SITE_NAME : $db;
$this->table = is_null($table) ? 'core' : $table;
$this->store = Config::get('dir.flight.store');
$this->db = Inflector::urlize($this->db, '');
$this->table = Inflector::urlize($this->table, '');
if (!$this->store) {
throw new Exception("You must defined in config a dir store for JDB.");
}
if (!is_dir($this->store)) {
File::mkdir($this->store);
}
$this->dir = $this->store . DS . $this->db;
if (!is_dir($this->dir)) {
File::mkdir($this->dir);
}
$this->ids = $this->dir . DS . 'ids.' . $this->table;
if (!file_exists($this->ids)) {
File::put($this->ids, 1);
}
$this->dir .= DS . $this->table;
if (!is_dir($this->dir)) {
File::mkdir($this->dir);
}
$this->age = filemtime($this->dir);
$this->tuplesDir = $this->dir . DS . 'tuples';
if (!is_dir($this->tuplesDir)) {
File::mkdir($this->tuplesDir);
}
$this->cacheDir = $this->dir . DS . 'cache';
if (!is_dir($this->cacheDir)) {
File::mkdir($this->cacheDir);
}
$this->indicesDir = $this->dir . DS . 'indices';
if (!is_dir($this->indicesDir)) {
File::mkdir($this->indicesDir);
}
$this->relationsDir = $this->dir . DS . 'relations';
if (!is_dir($this->relationsDir)) {
File::mkdir($this->relationsDir);
}
}
示例4: __construct
public function __construct($db = null, $table = null)
{
$this->db = is_null($db) ? SITE_NAME : $db;
$this->table = is_null($table) ? 'core' : $table;
$dir = Config::get('dir.blizz.store', session_save_path());
if (!is_dir($dir)) {
File::mkdir($dir);
}
$dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
if (!is_dir($dir)) {
File::mkdir($dir);
}
$this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
if (!is_dir($this->dir)) {
File::mkdir($this->dir);
}
$store = lib('blizzstore', [$this]);
Now::set("blizz.store.{$this->db}.{$this->table}", $store);
$this->cursor = lib('blizzcursor', [$this]);
}
示例5: __construct
public function __construct($db = null, $table = null)
{
$this->db = is_null($db) ? SITE_NAME : $db;
$this->table = is_null($table) ? 'core' : $table;
$dir = Config::get('dir.flat.store', session_save_path());
if (!is_dir($dir)) {
File::mkdir($dir);
}
$dir .= DS . Inflector::urlize(Inflector::uncamelize($this->db));
if (!is_dir($dir)) {
File::mkdir($dir);
}
$this->dir = $dir . DS . Inflector::urlize(Inflector::uncamelize($this->table));
if (!is_dir($this->dir)) {
File::mkdir($this->dir);
}
if (!is_file($this->dir . DS . 'age.blazz')) {
File::put($this->dir . DS . 'age.blazz', '');
}
$this->cursor = core('cursor', [$this]);
}
示例6: flush
public static function flush($db = null, $table = null, $name = null)
{
$db = is_null($db) ? '*' : $db;
$table = is_null($table) ? '*' : $table;
$name = is_null($name) ? '*' : Inflector::urlize($name, '.');
if ($db != '*' && $table != '*') {
$cache = Database::instance($db, $table)->cache();
} else {
$cache = Database::instance('auth', 'user')->cache();
}
$hashes = $cache->keys("dbjson::cachedQueries::{$db}::{$table}");
$ages = $cache->keys("dbjson::cachedQueries::{$db}::{$table}::{$name}::age");
if (count($hashes)) {
foreach ($hashes as $hash) {
$cache->del($hash);
}
}
if (count($ages)) {
foreach ($ages as $age) {
$cache->del($age);
}
}
}
示例7: check
public function check($id, $html)
{
require_once APPLICATION_PATH . DS . '..' . '/public/vendeur/lib/simple_html_dom.php';
$str = str_get_html($html);
$segLangs = $str->find('lang');
foreach ($segLangs as $segLang) {
$default = $segLang->innertext;
$args = $segLang->args;
if (!empty($args)) {
$replace = "<lang args=\"{$args}\">{$default}</lang>";
} else {
$args = '[]';
$replace = "<lang>{$default}</lang>";
}
$by = '<?php __(\'' . $default . '\', \'' . $id . '.' . Inflector::urlize($default, '-') . '\', ' . $args . '); ?>';
$html = str_replace($replace, $by, $html);
}
return $html;
}
示例8: searchNearByAddress
public function searchNearByAddress($address, $query)
{
$collection = lib('collection');
$coords = lib('geo')->getCoords($address);
$url = 'http://search.mappy.net/search/1.0/find?extend_bbox=1&bbox=' . $coords['lat1'] . ',' . $coords['lng1'] . ',' . $coords['lat2'] . ',' . $coords['lng2'] . '&q=' . urlencode($query) . '&favorite_country=' . $coords['country_id'] . '&language=FRE&&max_results=199';
dd($url);
$key = 'serach.near.' . sha1($url);
$json = redis()->get($key);
if (!$json) {
$json = dwn($url);
redis()->set($key, $json);
}
$data = json_decode($json, true);
$pois = isAke($data, 'pois', []);
foreach ($pois as $service) {
$dbService = rdb('geo', 'service')->where(['code', '=', $service['rubricId']])->first(true);
if ($dbService) {
$id = $dbService->id;
} else {
if (isset($service['allRubrics'])) {
if (count($service['allRubrics'])) {
foreach ($service['allRubrics'] as $rubrikA) {
$idr = isAke($rubrikA, 'id');
$lr = isAke($rubrikA, 'label');
$pr = isAke($rubrikA, 'rubricParentId');
if ($idr == $service['rubricId']) {
$spi = rdb('geo', 'service')->firstOrCreate(['code' => $idr])->setLabel($lr)->setFamily($pr)->save();
$id = $spi->id;
}
}
}
}
}
$serviceproxIds = $supplements = [];
$serviceproxIds[] = $id;
$poi = $service['id'];
$checkEtab = rdb('geo', 'etablissement')->where(['poi', '=', (string) $poi])->first(true);
$add = $checkEtab ? false : true;
unset($service['id']);
if (false === $add) {
$service['id'] = $checkEtab->id;
}
unset($service['offer']);
unset($service['prov']);
unset($service['pjBlocId']);
unset($service['thematicId']);
if (isset($service['tabs'])) {
if (count($service['tabs'])) {
foreach ($service['tabs'] as $tmp) {
$tmpUrl = isAke($tmp, 'url', false);
$tmpId = isAke($tmp, 'appId', false);
if (false !== $tmpUrl && false !== $tmpId) {
$key = 'inf.' . $poi . '.' . $tmpId;
if ($tmpId == 'pj') {
$inf = redis()->get($key);
if (empty($inf)) {
$infHtml = dwn($tmpUrl);
$inf = substr($infHtml, strlen('callback('), -1);
redis()->set($key, $inf);
}
$inf = json_decode($inf, true);
$t = isAke($inf, 'tabs', []);
if (!empty($t)) {
foreach ($t as $tmpT) {
$b = isAke($tmpT, 'blocks', []);
$t = isAke($tmpT, 'tags', []);
if (!empty($b)) {
for ($ti = 0; $ti < count($b); $ti += 2) {
$seg = $b[$ti];
$seg2 = $b[$ti + 1];
if (is_array($seg) && is_array($seg2)) {
$title = isAke($seg, 'title', false);
$kv = isAke($seg2, 'keyValue', false);
if (false !== $title && false !== $kv) {
$title = Inflector::urlize($title);
foreach ($kv as $tmpRow) {
$supplements[$title][] = [$tmpRow['key'] => $tmpRow['value']];
}
}
}
}
}
}
}
} elseif ($tmpId == 'indoor') {
} elseif ($tmpId == 'localbusinesspremium') {
} elseif ($tmpId == 'total') {
} elseif ($tmpId == 'totalaccess') {
} elseif ($tmpId == 'darty') {
} elseif ($tmpId == 'eleclerc') {
} elseif ($tmpId == 'moteurproduitpromo') {
} elseif ($tmpId == 'mappyshopping') {
} elseif ($tmpId == 'booking') {
$inf = redis()->get($key);
if (empty($inf)) {
$infHtml = dwn($tmpUrl);
$inf = substr($infHtml, strlen('callback('), -1);
redis()->set($key, $inf);
}
$inf = json_decode($inf, true);
//.........这里部分代码省略.........
示例9: import
public function import(array $array)
{
if (!empty($array)) {
$data = [];
foreach ($array as $row) {
if (Arrays::is($row) && Arrays::isAssoc($row)) {
foreach ($row as $key => $value) {
$newRow[Inflector::urlize($key, '_')] = str_replace('[NL]', "\n", $value);
}
array_push($data, $newRow);
}
}
if (!empty($data)) {
foreach ($data as $row) {
$this->save($row);
}
}
}
return $this;
}
示例10: check
public function check($id, $html)
{
require_once __DIR__ . DS . 'dom.php';
$str = str_get_html($html);
$segLangs = $str->find('lang');
foreach ($segLangs as $segLang) {
$default = $segLang->innertext;
$args = $segLang->args;
if (!empty($args)) {
$controller = Now::get('instance.controller');
$replace = "<lang args=\"{$args}\">{$default}</lang>";
$file = path('cache') . DS . sha1(serialize($args)) . '.display';
File::put($file, '<?php namespace Thin; ?>' . $args);
ob_start();
include $file;
$args = ob_get_contents();
ob_end_clean();
File::delete($file);
} else {
$args = '[]';
$replace = "<lang>{$default}</lang>";
}
$by = '<?php __(\'' . $default . '\', \'' . $id . '.' . Inflector::urlize($default, '-') . '\', ' . $args . '); ?>';
$html = str_replace($replace, $by, $html);
}
return $html;
}
示例11: htmlToPng
function htmlToPng($html, $name = null, $orientation = null, $count = 0)
{
$name = is_null($name) ? 'doc.pdf' : Inflector::urlize($name) . '.pdf';
$orientation = is_null($orientation) ? 'portrait' : $orientation;
$file = TMP_PUBLIC_PATH . DS . sha1(serialize(func_get_args())) . '.html';
files()->put($file, $html);
$pdf = str_replace('.html', '.pdf', $file);
// $keep = lib('keep')->instance();
$url = URLSITE . 'tmp/' . Arrays::last(explode('/', $file));
$this->urlToPng($url);
}
示例12: lng
public static function lng($content)
{
$tab = array_merge(explode('<t ', $content), explode('<t>', $content));
if (count($tab)) {
array_shift($tab);
foreach ($tab as $row) {
$id = Utils::cut('id="', '"', trim($row));
$args = Utils::cut('args=[', ']', trim($row));
$default = Utils::cut('">', '</t>', trim($row));
$default = !strlen($default) ? Utils::cut(']>', '</t>', trim($row)) : $default;
if (!strlen($default)) {
if (!strstr($row, '</t>')) {
continue;
} else {
list($default, $dummy) = explode('</t>', $row, 2);
}
}
if (strlen($args)) {
if (strlen($id)) {
$content = repl('<t id="' . $id . '" args=[' . $args . ']>' . $default . '</t>', '<?php echo trad("' . repl('"', '\\"', $id) . '", "' . repl('"', '\\"', $default) . '", "' . repl('"', '\\"', $args) . '"); ?>', $content);
} else {
$id = Inflector::urlize($default);
$content = repl('<t args=[' . $args . ']>' . $default . '</t>', '<?php echo trad("' . $id . '", "' . repl('"', '\\"', $default) . '", "' . repl('"', '\\"', $args) . '"); ?>', $content);
}
} else {
if (strlen($id)) {
$content = repl('<t id="' . $id . '">' . $default . '</t>', '<?php echo trad("' . repl('"', '\\"', $id) . '", "' . repl('"', '\\"', $default) . '"); ?>', $content);
} else {
$id = Inflector::urlize($default);
$content = repl('<t>' . $default . '</t>', '<?php echo trad("' . $id . '", "' . repl('"', '\\"', $default) . '"); ?>', $content);
}
}
}
}
return $content;
}
示例13: getPoisArticle
public function getPoisArticle($art)
{
$article = null;
if (is_array($art)) {
$article = $art;
} elseif (is_object($art) || is_string($art)) {
$article = $this->native($art);
}
if (is_array($article)) {
$key = 'getPoisArticles.' . (string) $article['_id'];
// getCached($key, function () use ($article) {
$ll = lib('clipp')->getLatLng($article);
$ida = (string) $article['_id'];
$lat = isAke($ll, 'lat', 0);
$lng = isAke($ll, 'lng', 0);
if ($lat != 0 && $lng != 0) {
$pois = lib('geo')->poisTouristic(floatval($lat), floatval($lng));
$key = 'getPoisArticle.' . sha1((string) $article['_id'] . floatval($lat) . floatval($lng));
$db = lib('clipp')->em('nodes');
foreach ($pois as $poi) {
$ds = isAke($poi, 'datasheets', []);
if (!empty($ds)) {
$row = current($ds);
$count = $db->find(['permalink' => '/poi/' . Inflector::urlize($row['name'])])->count();
if ($count == 0) {
$obj = ['__v' => 0, 'history' => [], 'key' => isAke($poi, 'poi_id', null), 'type' => 'poi', 'status' => 2, 'lang' => 'fr_fr', 'title' => $row['name'], 'description' => $row['description'], 'medias' => $row['medias'], 'permalink' => '/poi/' . Inflector::urlize($row['name']), 'search' => Inflector::urlize($row['description'], ' '), 'updated_at' => new \MongoDate(), 'created_at' => new \MongoDate()];
$location = new \stdclass();
$location->address = new \stdclass();
$location->address->area = isAke($row, 'area', null);
$location->address->country = isAke($row, 'country', null);
$location->address->city = isAke($row, 'city', null);
$location->address->ref = isAke($row, 'ref_lieu', null);
$location->address->street = isAke($row, 'address', null);
$location->address->zip = isAke($row, 'postcode', null);
$location->formatted_address = isAke($row, 'formated_address_line', null);
$location->formatted_city = isAke($row, 'formated_city_line', null);
$location->type = 'Point';
$location->coordinates = [floatval(isAke($row, 'longitude', 0)), floatval(isAke($row, 'latitude', 0))];
$obj['location'] = $location;
$db->insert($obj, ['fsync' => true]);
$idp = (string) $obj['_id'];
// Model::PoiAssoc()->create([
// 'id_node' => $ida,
// 'id_poi' => $idp
// ])->save();
}
// else {
// if ($count == 1) {
// $row = $db->findOne([
// 'permalink' => '/poi/' . Inflector::urlize($row['name'])
// ]);
// $idp = (string) $row['_id'];
// Model::PoiAssoc()->create([
// 'id_node' => $ida,
// 'id_poi' => $idp
// ])->save();
// }
// }
}
}
}
return true;
// });
}
}
示例14: prepareFulltext
private static function prepareFulltext($text)
{
$text = Inflector::urlize(strip_tags(Blog::parse($text)));
return explode('-', $text);
}
示例15: pdfFile
function pdfFile($html, $name = null, $orientation = null, $count = 0)
{
$name = is_null($name) ? 'doc.pdf' : Inflector::urlize($name) . '.pdf';
$orientation = is_null($orientation) ? 'portrait' : $orientation;
$file = TMP_PUBLIC_PATH . DS . sha1(serialize(func_get_args())) . '.html';
files()->put($file, $html);
$pdf = str_replace('.html', '.pdf', $file);
// $keep = lib('keep')->instance();
$url = 'http://www.zelift.com/tmp/' . Arrays::last(explode('/', $file));
$cnt = dwn('http://apphuge.uk/pdf.php?url=' . urlencode($url) . '&orientation=' . $orientation);
// if (!strlen($cnt) && $count < 5) {
// return pdfFile($html, $name, $orientation, $count++);
// }
// if (!strlen($cnt) && $count >= 5) {
// exception('pdf', 'Le pdf est erroné et ne peut être créé.');
// }
files()->delete($file);
return $cnt;
}