本文整理汇总了PHP中nnText::dateToDateFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP nnText::dateToDateFormat方法的具体用法?PHP nnText::dateToDateFormat怎么用?PHP nnText::dateToDateFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nnText
的用法示例。
在下文中一共展示了nnText::dateToDateFormat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInput
protected function getInput()
{
$this->params = $this->element->attributes();
$label = $this->get('label');
$format = $this->get('format');
$date = JFactory::getDate();
$tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
$date->setTimeZone($tz);
if ($format)
{
if (strpos($format, '%') !== false)
{
require_once JPATH_PLUGINS . '/system/nnframework/helpers/text.php';
$format = nnText::dateToDateFormat($format);
}
$html = $date->format($format, 1);
}
else
{
$html = $date->format('', 1);
}
if ($label)
{
$html = JText::sprintf($label, $html);
}
return '<div class="nn_block nn_title">' . $html . '</div>';
}
示例2: dateToDateFormat
static function dateToDateFormat($dateFormat)
{
require_once __DIR__ . '/text.php';
return nnText::dateToDateFormat($dateFormat);
}
示例3: convertDateToString
public function convertDateToString($string, $extra)
{
// Check if string could be a date
if (strpos($string, '-') == false || preg_match('#[a-z]#i', $string) || !strtotime($string)) {
return $string;
}
if (!$extra) {
$extra = JText::_('DATE_FORMAT_LC2');
}
if (strpos($extra, '%') !== false) {
$extra = nnText::dateToDateFormat($extra);
}
return JHtml::_('date', $string, $extra);
}
示例4: replaceVars
function replaceVars(&$str)
{
if (!(strpos($str, '[[user:') === false)) {
if (preg_match_all('#\\[\\[user\\:([^\\]]+)\\]\\]#', $str, $matches, PREG_SET_ORDER) > 0) {
$user = JFactory::getUser();
$contact = null;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
foreach ($matches as $match) {
if ($match['1'] == 'password' || $match['1']['0'] == '_') {
$str = str_replace($match['0'], '', $str);
} else {
if (isset($user->{$match['1']})) {
$str = str_replace($match['0'], $user->{$match['1']}, $str);
} else {
if (!$contact) {
$query->clear()->select('c.*')->from('#__' . $this->_config->contact_table . ' as c')->where('c.user_id = ' . (int) $user->id);
$db->setQuery($query);
$contact = $db->loadObject();
}
if (isset($contact->{$match['1']})) {
$str = str_replace($match['0'], $contact->{$match['1']}, $str);
} else {
$str = str_replace($match['0'], '', $str);
}
}
}
}
}
}
if (!(strpos($str, '[[date:') === false)) {
if (preg_match_all('#\\[\\[date\\:([^\\]]+)\\]\\]#', $str, $matches, PREG_SET_ORDER) > 0) {
require_once JPATH_PLUGINS . '/system/nnframework/helpers/text.php';
foreach ($matches as $match) {
if ($match['1'] && !(strpos($match['1'], '%') === false)) {
$match['1'] = nnText::dateToDateFormat($match['1']);
}
$replace = JHtml::_('date', time(), $match['1']);
$str = str_replace($match['0'], $replace, $str);
}
}
}
if (!(strpos($str, '[[random:') === false)) {
while (preg_match('#\\[\\[random\\:([0-9]+)-([0-9]+)\\]\\]#', $str, $match)) {
$search = '#' . preg_quote($match['0'], "#") . '#';
$replace = rand((int) $match['1'], (int) $match['2']);
$str = preg_replace($search, $replace, $str, 1);
}
}
}