本文整理汇总了PHP中am函数的典型用法代码示例。如果您正苦于以下问题:PHP am函数的具体用法?PHP am怎么用?PHP am使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了am函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalizeAllowedConfig
/**
* Cambia las abreviaturas del configuracion allowed por los tipos correctos
* @param array $config configuraciones del modelo
* @return array $config configuraciones modificadas
*/
function normalizeAllowedConfig($config)
{
$abbreviations = Configure::read("Media.abbreviations");
$mime_types = Configure::read("Media.mime_types");
//log($config, 'debug');
#pr($config);
$config['extensions'] = array();
foreach ($config['allowed'] as $key => $allowed) {
if (isset($abbreviations[$allowed])) {
foreach ($abbreviations[$allowed] as $extencion) {
if (!in_array($mime_types[$extencion], $config['allowed'])) {
$config['allowed'][] = $mime_types[$extencion];
}
}
$config['extensions'] = am($config['extensions'], $abbreviations[$allowed]);
unset($config['allowed'][$key]);
} else {
if (isset($mime_types[$allowed])) {
$config['allowed'][] = $mime_types[$allowed];
$config['extensions'][] = $allowed;
}
}
}
return $config;
}
示例2: view
/**
* Lists posts for a category
* @param string $slug Category slug
* @return \Cake\Network\Response|null|void
* @throws RecordNotFoundException
*/
public function view($slug = null)
{
//The category can be passed as query string, from a widget
if ($this->request->query('q')) {
return $this->redirect([$this->request->query('q')]);
}
$page = $this->request->query('page') ? $this->request->query('page') : 1;
//Sets the cache name
$cache = sprintf('category_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page);
//Tries to get data from the cache
list($posts, $paging) = array_values(Cache::readMany([$cache, sprintf('%s_paging', $cache)], $this->PostsCategories->cache));
//If the data are not available from the cache
if (empty($posts) || empty($paging)) {
$query = $this->PostsCategories->Posts->find('active')->select(['id', 'title', 'subtitle', 'slug', 'text', 'created'])->contain(['Categories' => function ($q) {
return $q->select(['id', 'title', 'slug']);
}, 'Tags' => function ($q) {
return $q->order(['tag' => 'ASC']);
}, 'Users' => function ($q) {
return $q->select(['first_name', 'last_name']);
}])->where(['Categories.slug' => $slug])->order([sprintf('%s.created', $this->PostsCategories->Posts->alias()) => 'DESC']);
if ($query->isEmpty()) {
throw new RecordNotFoundException(__d('me_cms', 'Record not found'));
}
$posts = $this->paginate($query)->toArray();
//Writes on cache
Cache::writeMany([$cache => $posts, sprintf('%s_paging', $cache) => $this->request->param('paging')], $this->PostsCategories->cache);
//Else, sets the paging parameter
} else {
$this->request->params['paging'] = $paging;
}
$this->set(am(['category' => $posts[0]->category], compact('posts')));
}
示例3: blogPosts
/**
* ブログ記事一覧出力
* ページ編集画面等で利用する事ができる。
* 利用例: <?php $baser->blogPosts('news', 3) ?>
* ビュー: app/webroot/themed/{テーマ名}/blog/{コンテンツテンプレート名}/posts.ctp
*
* @param int $contentsName
* @param int $num
* @param array $options
* @param mixid $mobile '' / boolean
* @return void
* @access public
*/
function blogPosts($contentsName, $num = 5, $options = array())
{
$_options = array('category' => null, 'tag' => null, 'year' => null, 'month' => null, 'day' => null, 'id' => null, 'keyword' => null, 'template' => null);
$options = am($_options, $options);
$BlogContent = ClassRegistry::init('Blog.BlogContent');
$id = $BlogContent->field('id', array('BlogContent.name' => $contentsName));
$url = array('plugin' => 'blog', 'controller' => 'blog', 'action' => 'posts');
$settings = Configure::read('AgentSettings');
foreach ($settings as $key => $setting) {
if (isset($options[$key])) {
$agentOn = $options[$key];
unset($options[$key]);
} else {
$agentOn = Configure::read('AgentPrefix.currentAgent') == $key;
}
if ($agentOn) {
$url['prefix'] = $setting['prefix'];
break;
}
}
if (isset($options['templates'])) {
$templates = $options['templates'];
} else {
$templates = 'posts';
}
unset($options['templates']);
echo $this->requestAction($url, array('return', 'pass' => array($id, $num, $templates), 'named' => $options));
}
示例4: ajax_menu_add
function ajax_menu_add($pid = null, $edit = false)
{
$this->loadModel('Link');
if (!empty($this->data)) {
Configure::write('debug', 0);
$this->RequestHandler->setContent('json', 'text/x-json');
if ($this->data['Link']['path']) {
$path = explode('/', $this->data['Link']['path']);
$this->data['Link']['controller'] = $path[0];
$this->data['Link']['action'] = $path[1];
}
if ($this->Link->save($this->data)) {
$response['error'] = array("code" => 0);
$response['redirect'] = array('action' => 'menu');
} else {
$errorMessages = $this->validateErrors($this->Link);
$response['error'] = array("code" => 1, "messages" => $errorMessages);
$response['redirect'] = array('action' => 'menu');
}
$this->set(compact("response"));
$this->render('message');
} else {
$reservedLinks = $this->Link->find('all', array('recursive' => -1));
$actions = $this->JvUtil->listActions($reservedLinks);
$path = "";
if ($edit) {
$this->data = $this->Link->read(null, $pid);
$pid = $this->data['Link']['parent_id'];
$path = $this->data['Link']['controller'] . "/" . $this->data['Link']['action'];
$actions = am($actions, array($path => $path));
}
$this->set(compact("pid", "actions", "edit", "path"));
}
}
示例5: view
function view($id = null)
{
if (!$id) {
$this->Session->setFlash('Invalid Customer.');
$this->redirect('/customers/');
}
$conditions = am(array('Customer.id' => $id), $this->generateConditions($this->Customer, null, null, null, 'findWithService'));
if ($this->permissionsStatus['admin']) {
$customer = $this->Customer->findWithService($conditions);
} elseif ($this->permissionsStatus['owner']) {
$customer = $this->Customer->findWithService($conditions);
} else {
$this->viewPath = 'errors';
$this->render('not_authorised');
return true;
}
if (!empty($customer)) {
$this->set('customer', $customer);
$this->pageTitle = "{$customer['Customer']['company_name']} | Customer";
} else {
$this->viewPath = 'errors';
$this->render('not_found');
return true;
}
}
示例6: beforeRender
function beforeRender()
{
$user = $this->ZTAuth->user();
$group = $this->Group->findById($user['User']['group_id']);
if (!empty($user)) {
$this->set('logined', '1');
$this->set('group', $group['Group']['user_status']);
$this->set('group_style', $group['Group']['status_style']);
$this->set('username', $user['User']['username']);
$this->set('avatar', $user['User']['avatar']);
$this->set('uploaded', $user['User']['uploaded']);
$this->set('downloaded', $user['User']['downloaded']);
$this->User->save(array('id' => $user['User']['id'], 'last_access' => date("Y-m-d H:i:s")));
} else {
$this->set('logined', '0');
}
if ($this->name != 'CakeError') {
$this->set('UserMenu', $this->Sideblock->fetchUserMenu());
$this->set('OnlineUsers', $this->Onlineblock->fetchOnlineBlock());
$this->set('Stats', $this->Sideblock->fetchStats());
$this->data = am($this->data, array('Menu' => $this->Menu->fetchData(&$this)));
} else {
$this->layout = '2col_layout';
}
}
示例7: admin_index
/**
* undocumented function
*
* @return void
* @access public
*/
function admin_index()
{
Assert::true(User::allowed($this->name, $this->action), '403');
$defaults = array('model' => null, 'user_id' => null, 'my_limit' => 20, 'custom_limit' => false, 'start_date_day' => '01', 'start_date_year' => date('Y'), 'start_date_month' => '01', 'end_date_day' => '31', 'end_date_year' => date('Y'), 'end_date_month' => '12');
$params = am($defaults, $this->params['url'], $this->params['named']);
unset($params['ext']);
unset($params['url']);
if (is_numeric($params['custom_limit'])) {
if ($params['custom_limit'] > 75) {
$params['custom_limit'] = 75;
}
if ($params['custom_limit'] == 0) {
$params['custom_limit'] = 50;
}
$params['my_limit'] = $params['custom_limit'];
}
$conditions = array();
if (!empty($params['model'])) {
$conditions['Log.model'] = $params['model'];
}
if (!empty($params['user_id'])) {
$conditions['Log.user_id'] = $params['user_id'];
}
$conditions = $this->Log->dateRange($conditions, $params, 'created');
$this->Session->write('logs_filter_conditions', $conditions);
$userOptions = ClassRegistry::init('User')->find('list', array('conditions' => array('User.office_id' => $this->Session->read('Office.id'))));
$this->paginate['Log'] = array('conditions' => $conditions, 'contain' => array('User', 'Gift', 'Transaction'), 'limit' => $params['my_limit'], 'order' => array('Log.continuous_id' => 'desc'));
$logs = $this->paginate($this->Log);
$this->set(compact('logs', 'params', 'userOptions'));
}
示例8: initialize
/**
* initialize
*
* @param &$controller
* @param $settings
* @return
*/
function initialize(&$controller, $settings = array())
{
$this->settings = am($this->settings, $settings);
$this->params = $controller->params;
$this->emoji = HTML_Emoji::getInstance();
$this->emoji->setImageUrl(Router::url('/') . 'yak/img/');
if (!Configure::read('Yak.save')) {
Configure::write('Yak.save', Configure::read('Session.save'));
}
if ($this->settings['enabled']) {
$path = '../plugins/yak/config/session';
do {
$config = CONFIGS . $path . '.php';
if (is_file($config)) {
break;
}
$path = '../../plugins/yak/config/session';
$config = CONFIGS . $path . '.php';
if (is_file($config)) {
break;
}
trigger_error(__("Can't find yak session file.", true), E_USER_ERROR);
} while (false);
Configure::write('Session.save', $path);
}
}
示例9: __resortLangs
/**
*
*/
function __resortLangs()
{
$langs = Configure::read('I18n.Langs');
$locale = Configure::read("I18n.Locale");
$ordered[$locale] = $langs[$locale];
Configure::write("I18n.Langs", am($ordered, array_diff($langs, $ordered)));
}
示例10: send
/**
* Envía un mensaje de notificación al view.
*
* @param string $message Mensaje de notificación que se envía.
* @param string $type Tipo de mensaje (info,warning,success,error).
* @param array $options Lista de opciones HTML
* @access public
* @return void
*/
function send($message, $type = null, $options = array())
{
if (is_array($type)) {
$options = $type;
if (isset($options['type'])) {
$type = $options['type'];
unset($options['type']);
} else {
$type = null;
}
}
if (empty($type)) {
$type = 'info';
}
$options['class'] = empty($options['class']) ? $type : $options['class'] . ' ' . $type;
if ($this->RequestHandler->isAjax()) {
$id = 'flashMessage';
$options = am($options, compact('message', 'type', 'id'));
$notice = array();
foreach ($options as $key => $value) {
$notice[] = "'{$key}':'{$value}'";
}
header(sprintf('X-Notifier: {%s}', implode(',', $notice)));
} else {
$this->Session->setFlash($message, 'notifier', $options);
}
}
示例11: setup
/**
* Setup
*
* @param AppModel $model
* @param array $settings
*/
public function setup(&$model, $settings = array())
{
if (!isset($this->settings[$model->alias])) {
$this->settings[$model->alias] = $this->defaults;
}
$this->settings[$model->alias] = am($this->settings[$model->alias], empty(is_array($settings)) ? $settings : array());
}
示例12: beforeFilter
public function beforeFilter()
{
SlConfigure::setCollections();
if (isset($this->data[$this->modelClass]['id'])) {
$this->id = $this->data[$this->modelClass]['id'];
} elseif (isset($this->params['pass'][0])) {
$this->id = $this->params['pass'][0];
}
if (!empty($this->params['named']['ref'])) {
SlSession::write('Routing.ref', base64_decode($this->params['named']['ref']));
}
// Make AJAX errors and warnings readable
if (class_exists('Debugger')) {
if ($this->RequestHandler->isAjax()) {
Debugger::output('base');
}
}
// update current language
if (!empty($this->params['named']['lang'])) {
$this->params['lang'] =& $this->params['named']['lang'];
}
if (!empty($this->params['lang'])) {
Sl::setLocale($this->params['lang'], true);
}
$languages = SlConfigure::read('I18n.languages');
$currLang = SlConfigure::read('I18n.lang');
$languageLinks = array();
foreach ($languages as $lang => $language) {
$languageLinks[$lang] = array('title' => $language, 'active' => $lang == $currLang, 'url' => am($this->passedArgs, array('action' => $this->action, 'lang' => $lang)));
}
SlConfigure::write('Navigation.languages', $languageLinks);
}
示例13: connectButton
/**
* Create Login Button
*
* @param $elementId
* @param $options
* @deprecated
* TODO: not testing
*/
public function connectButton($elementId = 'login', $options = array())
{
$defaults = array('size' => 'large', 'createElement' => true, 'authComplete' => 'location.reload();', 'signOut' => '', 'callbackUrl' => null);
extract(am($defaults, $options));
$out = '';
// -- create element
if ($createElement) {
$out = $this->Html->tag('span', '', array('id' => $elementId));
}
// -- modifiy callback functions
$authComplete = trim($authComplete);
if (!preg_match('/^function/', $authComplete)) {
$authComplete = "function (user) { {$authComplete} }";
}
$signOut = trim($signOut);
if (!preg_match('/^function/', $signOut)) {
$signOut = "function () { {$signOut} }";
}
// -- modify callback Url
if (!empty($callbackUrl)) {
$callbackUrl = "twttr.anywhere.config({ callbackURL: '{$this->url($callbackUrl, true)}' });";
}
/// -- logout
if (empty($logout)) {
$logout = '<button type="button">Logout</button>';
}
$out .= $this->Html->scriptBlock("\n twttr.anywhere(function (T) {\n\n {$callbackUrl}\n\n if (T.isConnected()) {\n \$('#{$elementId}').html('{$logout}');\n \$('#{$elementId}').children().click(function(){ twttr.anywhere.signOut(); location.reload(); return false; });\n } else {\n T('#{$elementId}').connectButton({\n size: '{$size}',\n authComplete: {$authComplete},\n signOut: {$signOut}\n });\n }\n });\n ");
return $out;
}
示例14: __construct
function __construct($options = array())
{
parent::__construct($options);
$defaultOptions = array('type' => 'max', 'size' => 4 * MB);
$options = am($defaultOptions, $options);
$this->options = $options;
}
示例15: getSellers
function getSellers($options = null)
{
$_options = array('conditions' => array('active' => 1), 'fields' => array('id', 'name'), 'contain' => array());
$options = am($_options, $options);
$sellers = $this->find('all', $options);
return $sellers;
}