本文整理汇总了PHP中_a函数的典型用法代码示例。如果您正苦于以下问题:PHP _a函数的具体用法?PHP _a怎么用?PHP _a使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_a函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$messages = array();
$form = new BootstrapForm('bootstrap');
if ($this->request->isPost()) {
$post = $this->request->getPost();
$form->setData($post);
$messages[] = _a('Form submitted successfully.');
//$rename = 'demo_for_upload_%random%';
$rename = function ($name) {
//$extension = pathinfo($name, PATHINFO_EXTENSION);
$name = 'test_for_upload_' . $name;
return $name;
};
$uploader = new Upload(array('rename' => $rename));
$uploader->setExtension('jpg,png,gif,txt,zip,rar');
//->setRename('tmp.%random%');
//->setImageSize(array('maxWidth' => 600, 'maxHeight' => 500));
if ($uploader->isValid()) {
$uploader->receive();
$file = $uploader->getUploaded('upload_demo');
$messages[] = sprintf(_a('File uploaded and saved as %s'), $file);
}
}
$this->view()->assign(array('form' => $form, 'messages' => $messages));
}
示例2: editAction
/**
* Edit a block
*/
public function editAction()
{
if ($this->request->isPost()) {
$id = $this->request->getPost('id');
} else {
$id = $this->params('id');
}
$widget = $this->getModel('widget')->find($id);
$this->type = $widget->type;
$form = $this->getForm();
if ($this->request->isPost()) {
$status = $this->processPost($form);
if ($status > 0) {
$message = _a('Block data saved successfully.');
$this->jump(array('action' => 'index', 'name' => ''), $message);
return;
} elseif ($status < 0) {
$message = _a('Block data not saved.');
} else {
$message = _a('Invalid data, please check and re-submit.');
}
} else {
$blockRow = Pi::model('block_root')->find($widget->block);
$values = $blockRow->toArray();
$values['id'] = $id;
$values['content'] = $widget->meta;
$form->setData($values);
$message = '';
}
$this->view()->assign('form', $form);
$this->view()->assign('message', $message);
$this->view()->setTemplate('system:component/form');
}
示例3: init
public function init()
{
$this->add(array('name' => 'title', 'options' => array('label' => __('Title')), 'attributes' => array('type' => 'text', 'required' => true)));
$this->add(array('name' => 'name', 'options' => array('label' => __('Unique name')), 'attributes' => array('type' => 'text', 'required' => true)));
$this->add(array('name' => 'description', 'options' => array('label' => __('Description')), 'attributes' => array('type' => 'text')));
$set = '';
switch ($this->contentType) {
case 'html':
$editor = 'html';
break;
case 'markdown':
$editor = 'markitup';
$set = 'markdown';
break;
case 'text':
default:
$editor = 'textarea';
break;
}
$this->add(array('name' => 'content', 'options' => array('label' => __('Content'), 'editor' => $editor, 'set' => $set), 'attributes' => array('type' => 'editor', 'class' => 'span6', 'description' => _a('Tags supported: `%sitename%` - site name; `%siteurl%` - site root URL; `%slogan%` - site slogan'))));
$this->add(array('name' => 'type', 'type' => 'hidden', 'attributes' => array('value' => $this->contentType)));
$this->add(array('name' => 'security', 'type' => 'csrf'));
$this->add(array('name' => 'id', 'type' => 'hidden'));
$this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('value' => __('Submit'))));
}
示例4: get_info
function get_info($sid, $type)
{
$url = 'http://www.xiami.com/song/playlist/id/' . $sid . '/type/' . $type;
$useCookie = $type == 9 ? 1 : null;
$result = curl_http($url, $useCookie);
$data = array();
if ($result) {
$res = str_replace(array('<![CDATA[', ']]>'), array('', ''), $result);
if ($res == $result) {
$data['info'] = '请使用国内代理!';
return $data;
}
$res = preg_replace('/&(?!#?[a-z0-9]+;)/', '&', $res);
$xml = simplexml_load_string($res);
$arr = json_decode(json_encode($xml), true);
$html = '';
$track = $arr['trackList']['track'];
$close = '<div class="close" title="关闭">×</div>';
if ($type == 0) {
$song = 'http://www.xiami.com/song/gethqsong/sid/' . $sid;
$json = curl_http($song, 1);
$location = $json ? json_decode($json)->location : '';
$location = $json ? $json['trackList']['track']['location'] : '';
if ($location) {
$data['src'] = get_location($location);
$data['status'] = 1;
} else {
$data['info'] = '获取歌曲链接失败!';
return $data;
}
$html = '<div class="info-item"><img src="' . $track['pic'] . '"><div><strong>标题:</strong>' . $track['songName'] . '</div><div><strong>艺人:</strong>' . _a($track['artist'], $track['artist_id'], 'artist') . '</div>';
$html .= is_string($track['album_name']) ? '<div><strong>专辑:</strong>' . _a($track['album_name'], $track['album_id'], 'album') . '</div>' : '';
$html .= is_string($track['lyric']) ? '<div><strong>歌词:</strong>' . $track['lyric'] . '</div>' : '';
$html .= '<strong id="song">歌曲:</strong><div id="case"><label id="case-label"><input id="src" onmouseover="this.select()" value="' . $data['src'] . '"></label></div>';
$html .= $close . '</div>';
} else {
$title = $type == 3 ? '精选集曲目:' : '今日歌单曲目:';
$html = '<div class="info-item">';
$html .= $type == 1 ? '<img src="' . $track[0]['pic'] . '"><div><strong>专辑:</strong>' . $track[0]['album_name'] . '</div><div><strong>艺人:</strong>' . _a($track[0]['artist'], $track[0]['artist_id'], 'artist') : '';
$html .= $type == 2 ? '<div><strong>' . $track[0]['artist'] . '的热门曲目:</strong>' : '';
$html .= $type == 3 || $type == 9 ? '<div><strong>' . $title . '</strong>' : '';
$html .= '</div><ol>';
foreach ($track as $item) {
$html .= '<li>' . _a($item['songName'], $item['song_id'], 'song');
$html .= $type == 3 || $type == 9 ? ' - ' . _a($item['artist'], $item['artist_id'], 'artist') : '';
if ($type != 1) {
$html .= ' - 《' . _a($item['album_name'], $item['album_id'], 'album') . '》';
}
$html .= '</li>';
}
$html .= '</ol>' . $close . '</div>';
$data['status'] = 1;
}
$data['info'] = htmlspecialchars($html);
} else {
$data['info'] = '解析失败!';
}
return $data;
}
示例5: init
/**
* {@inheritDoc}
*/
public function init()
{
$this->add(array('name' => 'title', 'options' => array('label' => _a('Title')), 'attributes' => array('type' => 'text')));
$this->add(array('name' => 'icon', 'options' => array('label' => _a('Font-awsome icon')), 'attributes' => array('type' => 'text', 'description' => _a('Check http://fortawesome.github.io/Font-Awesome/icons/'))));
$this->add(array('name' => 'order', 'options' => array('label' => _a('Order')), 'attributes' => array('type' => 'text')));
$this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden')));
$this->add(array('name' => 'op', 'attributes' => array('type' => 'hidden', 'value' => 'save')));
$this->add(array('name' => 'submit', 'type' => 'submit', 'attributes' => array('class' => 'btn btn-primary')));
}
示例6: assignModules
protected function assignModules()
{
$rowset = Pi::model('module')->select(array('active' => 1));
$modules = array();
foreach ($rowset as $row) {
$modules[$row->id] = array('name' => $row->name, 'title' => $row->title);
}
$modules[0] = array('name' => '', 'title' => _a('Custom blocks'));
$this->view()->assign('modules', array_values($modules));
}
示例7: indexAction
/**
* Analysis media data
*
* @return ViewModel
*/
public function indexAction()
{
$module = $this->getModule();
// Get top 10 media resources
$topMedias = Pi::api('stats', $module)->getTopTotal(10);
// Get top submitter
$userSubmitToday = $this->getTopSubmitter(1, 10);
$userSubmit7 = $this->getTopSubmitter(7, 10);
$userSubmit30 = $this->getTopSubmitter(30, 10);
$userSubmitEver = $this->getTopSubmitter(null, 10);
$this->view()->assign(array('title' => _a('Statistic'), 'medias' => $topMedias, 'user' => array('today' => $userSubmitToday, 'week' => $userSubmit7, 'month' => $userSubmit30, 'ever' => $userSubmitEver)));
}
示例8: verifyResult
/**
* {@inheritDoc}
*/
protected function verifyResult(Result $result)
{
if (!$result->isValid()) {
return $result;
}
$adminRoles = Pi::service('user')->getRole($result->getData('id'));
if (!$adminRoles) {
Pi::service('authentication')->clearIdentity();
$result->setCode(-4)->setMessage(_a('Not privileged.'));
}
return $result;
}
示例9: checkAction
/**
* AJAX: Check update availability
*
* @return array
*/
public function checkAction()
{
if ($this->request->isPost()) {
// Type: module, theme
$type = $this->params()->fromPost('type', 'module');
// Names: name of modules to check
$name = $this->params()->fromPost('name');
} else {
// Type: module, theme
$type = $this->params('type', 'module');
// Names: name of modules to check
$name = $this->params('name');
}
if (is_scalar($name)) {
// 1 - update available; 0 - no update; -1 - error occurred
$status = rand(-1, 1);
$version = '1.2.3';
switch ($status) {
case 1:
$message = sprintf(_a('A new version %s is available'), $version);
break;
case 0:
$message = _a('No update available');
break;
case -1:
default:
$message = _a('Error occurred, check later.');
break;
}
$result = array('status' => $status, 'message' => $message);
} else {
foreach ($name as $key) {
// 1 - update available; 0 - no update; -1 - error occurred
$status = rand(-1, 1);
$version = '1.2.3';
switch ($status) {
case 1:
$message = sprintf(_a('A new version %s is available'), $version);
break;
case 0:
$message = _a('No update available');
break;
case -1:
default:
$message = _a('Error occurred, check later.');
break;
}
$result[$key] = array('status' => $status, 'message' => $message);
}
}
return $result;
}
示例10: updateCarousel
/**
* Update carousel blocks
*
* @param Event $e
* @return bool
*/
public function updateCarousel(Event $e)
{
$version = $e->getParam('version');
if (version_compare($version, '1.1.0', '>')) {
return true;
}
$rowset = Pi::model('block_root')->select(array('type' => 'carousel'));
foreach ($rowset as $row) {
$row->config = array('width' => array('title' => _a('Image width'), 'edit' => 'text', 'filter' => 'int'), 'height' => array('title' => _a('Image height'), 'edit' => 'text', 'filter' => 'int'), 'interval' => array('title' => _a('Time interval (ms)'), 'edit' => 'text', 'filter' => 'int', 'value' => 4000), 'pause' => array('title' => _a('Mouse event'), 'description' => _a('Event to pause cycle'), 'edit' => array('type' => 'select', 'options' => array('options' => array('hover' => 'hover'))), 'value' => 'hover'));
$row->save();
}
return true;
}
示例11: modes
/**
* Get admin mode list
*
* @param null|string $mode
*
* @return array
*/
public static function modes($mode = null)
{
$modes = array(array('name' => AdminMode::MODE_ACCESS, 'label' => _a('Operation', 'system:admin'), 'icon' => 'fa fa-wrench'), array('name' => AdminMode::MODE_ADMIN, 'label' => _a('Setting', 'system:admin'), 'icon' => 'fa fa-cogs'), array('name' => AdminMode::MODE_DEPLOYMENT, 'label' => _a('Deployment', 'system:admin'), 'icon' => 'fa fa-cloud-upload', 'link' => ''));
if (AdminMode::MODE_ADMIN == $mode) {
$module = Pi::service('url')->getRouteMatch()->getParam('name');
} else {
$module = Pi::service('module')->current() ?: 'system';
}
array_walk($modes, function (&$config) use($mode, $module) {
$config['active'] = $mode == $config['name'] ? 1 : 0;
if (!isset($config['link'])) {
$config['link'] = Pi::service('url')->assemble('admin', array('module' => 'system', 'controller' => 'dashboard', 'action' => 'mode', 'mode' => $config['name']), array('query' => array('name' => $module)));
}
});
return $modes;
}
示例12: add
/**
* Add a block
*
* @param array $block
* @param string $type
*
* @return array
*/
public function add(array $block, $type = '')
{
$type = $type ?: $block['type'];
switch ($type) {
case 'list':
$block['config'] = array('width' => array('title' => _a('Image width'), 'edit' => 'text', 'filter' => 'int'), 'height' => array('title' => _a('Image height'), 'edit' => 'text', 'filter' => 'int'));
break;
case 'carousel':
$block['config'] = array('width' => array('title' => _a('Image width'), 'edit' => 'text', 'filter' => 'int'), 'height' => array('title' => _a('Image height'), 'edit' => 'text', 'filter' => 'int'), 'interval' => array('title' => _a('Time interval (ms)'), 'edit' => 'text', 'filter' => 'int', 'value' => 4000), 'pause' => array('title' => _a('Mouse event'), 'description' => _a('Event to pause cycle'), 'edit' => array('type' => 'select', 'options' => array('options' => array('hover' => 'hover'))), 'value' => 'hover'));
break;
default:
break;
}
$result = Pi::api('block', 'system')->add($block);
return $result;
}
示例13: indexAction
/**
* Dashboard
*
* @return void
*/
public function indexAction()
{
//$module = $this->params('module');
$module = $this->params('name', $this->moduleName('system'));
// Jump to a specific component if available
$navConfig = Pi::registry('navigation')->read('system-component');
if ($navConfig) {
foreach ($navConfig as $key => $config) {
$page = $config;
break;
}
$this->redirect($page['route'], array('module' => $page['module'], 'controller' => $page['controller'], 'name' => $module));
}
// Display module dashboard
$directory = Pi::service('module')->directory($module);
$callback = sprintf('Module\\%s\\Dashboard::summary', ucfirst($directory));
$summary = '';
if (is_callable($callback)) {
$summary = call_user_func($callback, $module);
}
$modules = Pi::registry('modulelist')->read();
$data = $modules[$module];
$meta = Pi::service('module')->loadMeta($directory, 'meta');
$author = Pi::service('module')->loadMeta($directory, 'author');
$data['description'] = $meta['description'];
$data['author'] = $author;
/*
if (empty($meta['logo'])) {
$data['logo'] = Pi::url('static/image/module.png');
} else {
$data['logo'] = Pi::service('asset')->getModuleAsset(
$meta['logo'],
$module
);
}
*/
if (empty($data['update'])) {
$data['update'] = _a('Never updated.');
} else {
$data['update'] = _date($data['update']);
}
$this->view()->assign('summary', $summary);
$this->view()->assign('data', $data);
$this->view()->assign('title', _a('Dashboard'));
$this->view()->setTemplate('dashboard-module', 'system');
}
示例14: initCategory
/**
* Add a root category, and its child as default category
*
* @param Event $e
*/
public function initCategory(Event $e)
{
// Skip if the initial data is exists
$sqlPath = sprintf('%s/%s', Pi::path('module'), self::INIT_FILE_NAME);
if (file_exists($sqlPath)) {
return true;
}
// Add a root category and its child category
$module = $this->event->getParam('module');
$model = Pi::model('category', $module);
$data = array('id' => null, 'name' => 'root', 'slug' => 'root', 'title' => _a('Root'), 'description' => _a('Module root category'));
$result = $model->add($data);
$defaultCategory = array('id' => null, 'name' => 'default', 'slug' => 'slug', 'title' => _a('Default'), 'description' => _a('The default category can not be delete, but can be modified!'));
$parent = $model->select(array('name' => 'root'))->current();
$model->add($defaultCategory, $parent);
return $result;
}
示例15: flatly_hook_themes_submenu
function flatly_hook_themes_submenu($content = '')
{
global $user_config;
$separator = " ";
$logged_in = $user_config['username'];
$tooltips_logged_in = _('Logged in as') . ' ' . $logged_in;
$credit = $user_config['credit'];
$tooltips_credit = _('Your credit');
$ret = '<div>';
$ret .= '<span class="playsms-icon glyphicon glyphicon-user" alt="' . $tooltips_logged_in . '" title="' . $tooltips_logged_in . '"></span>' . $logged_in;
$ret .= $separator . '<span class="playsms-icon glyphicon glyphicon-usd" alt="' . $tooltips_credit . '" title="' . $tooltips_credit . '"></span><div id="submenu-credit-show">' . $credit . '</div>';
if (auth_login_as_check()) {
$ret .= $separator . _a('index.php?app=main&inc=core_auth&route=logout', _('return'));
}
$ret .= $content;
$ret .= '</div>';
return $ret;
}