本文整理汇总了PHP中Converter类的典型用法代码示例。如果您正苦于以下问题:PHP Converter类的具体用法?PHP Converter怎么用?PHP Converter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Converter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: toWindows
/**
* @inheritdoc
*/
public function toWindows()
{
$result = array();
foreach ($this->getInput() as $row) {
$rowConverter = new Converter($row, $this->getBaseEncodings());
$result[] = $rowConverter->toWindows();
}
return $result;
}
开发者ID:openworkers,项目名称:components,代码行数:12,代码来源:ArrayConverter.php
示例2: ago
/**
* ==========================================================
* DATE AGO CALCULATOR
* ==========================================================
*
* -- CODE: -------------------------------------------------
*
* $input = '2014-05-30 09:22:42';
*
* var_dump(Date::ago($input));
*
* ----------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ------- | -----------------------------------
* $input | mixed | The date input
* $output | string | Optional to output single data
* $compact | boolean | Remove empty leading offset(s)?
* --------- | ------- | -----------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function ago($input, $output = null, $compact = true)
{
$speak = Config::speak();
$date = new DateTime();
$date->setTimestamp((int) self::format($input, 'U'));
$interval = $date->diff(new DateTime('now'));
$time = $interval->format('%y.%m.%d.%h.%i.%s');
$time = explode('.', $time);
$time = Converter::strEval($time);
$data = array($speak->year . '|' . $speak->years => $time[0], $speak->month . '|' . $speak->months => $time[1], $speak->day . '|' . $speak->days => $time[2], $speak->hour . '|' . $speak->hours => $time[3], $speak->minute . '|' . $speak->minutes => $time[4], $speak->second . '|' . $speak->seconds => $time[5]);
if ($compact) {
foreach ($data as $k => $v) {
if ($offset === 0) {
unset($data[$k]);
} else {
break;
}
}
}
$results = array();
foreach ($data as $k => $v) {
$text = explode('|', $k);
$results[strtolower($text[0])] = $v . ' ' . ($v === 1 ? $text[0] : $text[1]);
}
unset($data);
return !is_null($output) ? $results[$output] : $results;
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:50,代码来源:date.php
示例3: create
protected static function create($array, $indent = "", $FP = "", $i = 0)
{
$c_url = Config::get('url');
$c_url_current = Config::get('url_current');
$c_element = self::$config;
$c_class = $c_element['classes'];
$html = $indent . str_repeat(TAB, $i) . '<' . $c_element[$i === 0 ? 'trunk' : 'branch'] . ($i === 0 ? $c_class['trunk'] !== false ? ' class="' . $c_class['trunk'] . '"' : "" : ($c_class['branch'] !== false ? ' class="' . sprintf($c_class['branch'], $i / 2) . '"' : "")) . '>' . NL;
foreach ($array as $key => $value) {
if (!is_array($value)) {
$url = Converter::url($value);
$hole = $value === "" ? ' ' . $c_class['chink'] : "";
$current = $url === $c_url_current || $url !== $c_url && strpos($c_url_current . '/', $url . '/') === 0 ? ' ' . $c_class['current'] : "";
$c = trim(($c_class['twig'] !== false ? $c_class['twig'] : "") . $hole . $current);
$twig = '<' . $c_element['twig'] . ($c ? ' class="' . $c . '"' : "") . '>';
if ($value !== "") {
// List item without link: `array('foo')`
if (is_int($key)) {
$twig .= Filter::colon($FP . 'anchor', '<span class="a">' . $value . '</span>');
// List item without link: `array('foo' => null)`
} else {
if (is_null($value)) {
$twig .= Filter::colon($FP . 'anchor', '<span class="a">' . $key . '</span>');
// List item with link: `array('foo' => '/')`
} else {
$url = Filter::colon($FP . 'url', $url);
$twig .= Filter::colon($FP . 'anchor', '<a href="' . $url . '">' . $key . '</a>');
}
}
}
$s = explode(' ', $c_element['twig']);
$s = $s[0];
$html .= $indent . str_repeat(TAB, $i + 1) . Filter::colon($FP . 'twig', $twig . '</' . $s . '>', $i + 1) . NL;
} else {
// `text (path/to/url)`
if (preg_match('#^\\s*(.*?)\\s*\\((.*?)\\)\\s*$#', $key, $match)) {
$_key = $match[1];
$_value = trim($match[2]) !== "" ? Converter::url($match[2]) : '#';
} else {
$_key = $key;
$_value = null;
}
$url = Filter::colon($FP . 'url', $_value);
$s = explode(' ', $c_element['branch']);
$s = ' ' . $s[0];
$current = $url === $c_url_current || $url !== $c_url && strpos($c_url_current . '/', $url . '/') === 0 ? ' ' . $c_class['current'] : "";
$c = trim(($c_class['twig'] !== false ? $c_class['twig'] : "") . $current . $s);
$twig = '<' . $c_element['twig'] . ($c ? ' class="' . $c . '"' : "") . '>';
$twig .= NL . $indent . str_repeat(TAB, $i + 2);
$twig .= Filter::colon($FP . 'anchor', $_value !== null ? '<a href="' . $url . '">' . $_key . '</a>' : '<span class="a">' . $_key . '</span>');
$twig .= NL . self::create($value, $indent, $FP, $i + 2);
$twig .= $indent . str_repeat(TAB, $i + 1);
$s = explode(' ', $c_element['twig']);
$s = $s[0];
$html .= $indent . str_repeat(TAB, $i + 1) . Filter::colon($FP . 'twig', $twig . '</' . $s . '>', $i + 1) . NL;
}
}
$s = explode(' ', $c_element[$i === 0 ? 'trunk' : 'branch']);
$s = $s[0];
return Filter::colon($FP . 'branch', rtrim($html, NL) . (!empty($array) ? NL . $indent . str_repeat(TAB, $i) : "") . '</' . $s . '>', $i) . NL;
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:60,代码来源:tree.php
示例4: ago
/**
* ==========================================================
* DATE AGO CALCULATOR
* ==========================================================
*
* -- CODE: -------------------------------------------------
*
* $input = '2014-05-30 09:22:42';
*
* var_dump(Date::ago($input));
*
* ----------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ------- | -----------------------------------
* $input | mixed | The date input
* $output | string | Optional to output single data
* $compact | boolean | Remove empty leading offset(s)?
* --------- | ------- | -----------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function ago($input, $output = null, $compact = true)
{
$speak = Config::speak();
$date = new DateTime();
$date->setTimestamp((int) self::format($input, 'U'));
$interval = $date->diff(new DateTime('now'));
$time = $interval->format('%y.%m.%d.%h.%i.%s');
$time = explode('.', $time);
$time = Converter::strEval($time);
$data = array('year' => $time[0], 'month' => $time[1], 'day' => $time[2], 'hour' => $time[3], 'minute' => $time[4], 'second' => $time[5]);
if ($compact) {
foreach ($data as $k => $v) {
if ($v === 0) {
unset($data[$k]);
} else {
break;
}
}
}
$results = array();
foreach ($data as $k => $v) {
$text = array($speak->{$k}, $speak->{$k . 's'});
$results[$k] = $v . ' ' . ($v === 1 ? $text[0] : $text[1]);
}
unset($data);
return !is_null($output) ? $results[$output] : $results;
}
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:50,代码来源:date.php
示例5: authenticate
public function authenticate()
{
$db = $this->db;
$session = new Zend_Session_Namespace("LeadsChat_Auth");
$username = $this->_request->getPost("username");
$password = $this->_request->getPost("password");
//authenticate using Zend Auth
try {
$this->_auth->setTableName("agents");
$this->_auth->setCredentialTreatment("MD5(?) AND active = 'Y'");
$authResult = $this->_auth->setCredential($password)->setIdentity($username)->authenticate();
$agent = $this->_auth->getResultRowObject(null, "password");
$agent = Converter::object_to_array($agent);
if ($agent) {
$session->agent_id = $agent["agent_id"];
$session->agent = $agent;
//look for available agent availability
$available_agent = $db->fetchRow($db->select()->from("available_agents", array("available_agent_id"))->where("agent_id = ?", $session->agent_id));
if ($available_agent) {
$db->update("available_agents", array("available" => "Y", "currently_served" => 0, "updated" => date("Y-m-d h:i:s")));
} else {
$db->insert("available_agents", array("available" => "Y", "currently_served" => 0, "updated" => date("Y-m-d h:i:s"), "agent_id" => $agent["agent_id"]));
}
return true;
} else {
return false;
}
} catch (Exception $e) {
return false;
}
}
开发者ID:redhattaccoss,项目名称:Leadschat,代码行数:31,代码来源:Auth.php
示例6: toHtml
public function toHtml(array $data)
{
$html = "<div class='row'>";
// echo "<pre>";
// print_r($data);
// die();
foreach ($data['columns'] as $column) {
$html .= "<div class='col-md-" . $column['width'] . "'>";
$converter = new Converter();
$HTMLContent = $converter->toHtml(json_encode(array("data" => $column["blocks"])));
$html .= $HTMLContent;
$html .= "</div>";
}
$html .= "</div>";
return $html;
}
开发者ID:Krucamper,项目名称:Hoosk,代码行数:16,代码来源:ColumnsConverter.php
示例7: do_minify
function do_minify($content)
{
global $config;
$c = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
$url = $config->protocol . $config->host;
// Minify HTML
if (isset($c['html_minifier'])) {
$config->html_minifier = true;
Config::set('html_minifier', $config->html_minifier);
$content = Converter::detractSkeleton($content);
}
// Minify URL
if (isset($c['url_minifier']) && Text::check($content)->has('="' . $url)) {
$content = str_replace(array('="' . $url . '"', '="' . $url . '/', '="' . $url . '?', '="' . $url . '#'), array('="/"', '="/', '="?', '="#'), $content);
}
// Minify Embedded CSS
if (isset($c['css_minifier'])) {
$content = preg_replace_callback('#<style(>| .*?>)([\\s\\S]*?)<\\/style>#i', function ($matches) use($config, $c, $url) {
$css = Converter::detractShell($matches[2]);
if (isset($c['url_minifier'])) {
$css = preg_replace('#(?<=[\\s:])(src|url)\\(' . preg_quote($url, '/') . '#', '$1(', $css);
}
return '<style' . $matches[1] . $css . '</style>';
}, $content);
}
// Minify Embedded JavaScript
if (isset($c['js_minifier'])) {
$content = preg_replace_callback('#<script(>| .*?>)([\\s\\S]*?)<\\/script>#i', function ($matches) {
$js = Converter::detractSword($matches[2]);
return '<script' . $matches[1] . $js . '</script>';
}, $content);
}
return $content;
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:34,代码来源:launch.php
示例8: convertToMo
public static function convertToMo($source, $destination)
{
Converter::admin_clear_cache();
$shellCmd = 'msgfmt -cv -o ' . $destination . ' ' . $source . ' 2>&1';
$result = shell_exec($shellCmd);
CakeLog::write('debug', 'Translation : ' . $result . 'Path : ' . $destination);
}
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:7,代码来源:Converter.php
示例9: actionGetCurrentQuestion
public function actionGetCurrentQuestion()
{
$customer_id = $this->getParam('customer_id');
$flag = $this->getParam('flag');
$current_id = array();
if ($flag == 'today') {
$current_id = 2;
} else {
$current_id = 1;
}
$question = Converter::convertModelToArray(HiQuestion::model()->findByPk($current_id));
$answers = Converter::convertModelToArray(HiQuestionAnswer::model()->with('customer')->findAllByAttributes(array('customer_id' => $customer_id, 'question_id' => $current_id)));
if ($flag == 'today') {
$question['has_answered'] = 0;
$year = date('Y');
foreach ($answers as $k => $v) {
if (strpos('date' . $v['insert_date'], $year)) {
$question['has_answered'] = 1;
}
}
} else {
$question['has_answered'] = 1;
}
$question['answers'] = $answers;
EchoUtility::echoMsgTF($question, '获取问题', $question);
}
开发者ID:Veaer,项目名称:StoryAppendDemo-Server,代码行数:26,代码来源:QuestionController.php
示例10: get
public static function get($param = null, $fallback = false, $str_eval = true)
{
if (is_null($param)) {
return $_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET) && !empty($_GET) ? $str_eval ? Converter::strEval($_GET, false) : $_GET : $fallback;
}
$output = Mecha::GVR($_GET, $param, $fallback);
return $output === '0' || !empty($output) ? $str_eval ? Converter::strEval($output, false) : $output : $fallback;
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:8,代码来源:request.php
示例11: testCheckDigit
public function testCheckDigit()
{
$this->assertEquals(8, Converter::calculateCheckDigit(14080, 12712721));
$this->assertEquals(1, converter::calculateCheckDigit(10000, 81111111));
$this->assertEquals(9, converter::calculateCheckDigit(10000, 80000001));
$this->assertEquals(5, converter::calculateCheckDigit(16150, 12233411));
$this->assertEquals(7, converter::calculateCheckDigit(10001, 10001));
}
开发者ID:sanmai,项目名称:jpb-account-converter,代码行数:8,代码来源:ConverterTest.php
示例12: run
/**
* Run the application to convert files.
*
* @param bool $hack
*/
public function run($hack)
{
$converter = new Converter();
foreach ($this->getIterator() as $fileinfo) {
$fileName = $fileinfo[0];
$file = new File($fileName);
$converter->convert($file, $hack);
if (0 === strpos($fileName, $this->sourceFolder)) {
$path = substr($fileName, strlen($this->sourceFolder));
$destinationFile = $this->destinationFolder . $path;
$destinationFolder = pathinfo($destinationFile, PATHINFO_DIRNAME);
if (!file_exists($destinationFolder)) {
mkdir($destinationFolder, 0777, true);
}
file_put_contents($destinationFile, $file->getCode());
}
}
}
开发者ID:dchesterton,项目名称:phpdoc-to-return,代码行数:23,代码来源:Application.php
示例13: addComponent
/**
* Add a component to this layout
*
* @param array
*/
public function addComponent(array $component)
{
// is this component a numeric or associative array?
if (Converter::isAssociativeArray($component)) {
$this->components[] = $component;
} else {
$this->components = array_merge($this->components, $component);
}
}
开发者ID:candybanana,项目名称:html-to-carbon-json,代码行数:14,代码来源:Layout.php
示例14: actionGetArticleById
public function actionGetArticleById()
{
$article_id = $this->getParam('article_id');
$customer_id = $this->getParam('customer_id');
$article = Converter::convertModelToArray(HiPushArticle::model()->with('sections')->findByPk($article_id));
$c = new CDbCriteria();
$c->addCondition("article_ids LIKE '%\"" . (int) $article_id . "\"%' and customer_id = " . $customer_id);
$article['is_favourite'] = HiPushArticleFavourite::model()->count($c);
EchoUtility::echoMsgTF(1, '获取文章', $article);
}
开发者ID:Veaer,项目名称:StoryAppendDemo-Server,代码行数:10,代码来源:PushArticleController.php
示例15: create
/**
*
* @param string $from_encoding
* @param string $to_encoding
*
* @return EncodingConverter
*/
public static function create($from_encoding, $to_encoding)
{
$from_encoding = (string) $from_encoding;
$to_encoding = (string) $to_encoding;
if (strtolower($from_encoding) == strtolower($to_encoding)) {
return Converter::identity();
} else {
return new self($from_encoding, $to_encoding);
}
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:17,代码来源:encoding_converter.class.php
示例16: do_shortcode_php
function do_shortcode_php($content)
{
if (strpos($content, '{{php}}') === false) {
return $content;
}
global $config, $speak;
return preg_replace_callback('#(?<!`)\\{\\{php\\}\\}(?!`)([\\s\\S]*?)(?<!`)\\{\\{\\/php\\}\\}(?!`)#', function ($matches) use($config, $speak) {
return Converter::phpEval($matches[1], array('config' => $config, 'speak' => $speak));
}, $content);
}
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:10,代码来源:launch.php
示例17: content
public static function content($data = "")
{
if ($data === false) {
$data = "";
}
// Restrict user(s) from inputting the `SEPARATOR` constant
// to prevent mistake(s) in parsing the file content
$data = Converter::ES($data);
self::$bucket_alt = trim(self::$bucket_alt) !== "" && is_null(self::$open) ? trim(self::$bucket_alt) . (trim($data) !== "" ? "\n\n" . SEPARATOR . "\n\n" . $data : "") : $data;
return new static();
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:11,代码来源:page.php
示例18: decode
public static function decode($text, $textType = "")
{
if (is_object($text)) {
return $text;
}
$textType = Converter::initTextType($textType);
if ($textType == Converter::HTML) {
return $text;
}
return String::htmlDecode($text);
}
开发者ID:rasuldev,项目名称:torino,代码行数:11,代码来源:htmlconverter.php
示例19: debug
/**
* Displays the results in human readable format with pre tags, or returns the information.
* @param boolean $return If true, information will be returned rather than printed.
* @return mixed When the <i>return</i> parameter is true, this function will return a string.
*/
public function debug($return = false)
{
$data = array("Runtime" => $this->getTime() . " seconds", "MemoryStartUsage" => Converter::fromBytes($this->getMemoryStartUsage(), 2), "MemoryCurrentUsage" => Converter::fromBytes($this->getMemoryCurrentUsage(), 2), "MemoryPeakUsage" => Converter::fromBytes($this->getMemoryPeakUsage(), 2, "GB"));
if ($return) {
return print_r($data, true);
} else {
echo "<pre>";
print_r($data);
echo "</pre>";
}
}
开发者ID:rolandrajko,项目名称:BREAD,代码行数:16,代码来源:Benchmark.php
示例20: search
public function search($params)
{
$category = new CategoryModel();
$result = $category->request($params);
$output = "";
if (!empty($params["output"])) {
$output = $params["output"];
}
$html = Converter::generate($result, $output);
Header::append($result["status"]["code"]);
Header::append($output);
echo $html;
}
开发者ID:vtlabo,项目名称:vtlabo-training-php-api,代码行数:13,代码来源:CategoryController.php
注:本文中的Converter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论