当前位置: 首页>>代码示例>>PHP>>正文


PHP Division::_addNames方法代码示例

本文整理汇总了PHP中Division::_addNames方法的典型用法代码示例。如果您正苦于以下问题:PHP Division::_addNames方法的具体用法?PHP Division::_addNames怎么用?PHP Division::_addNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Division的用法示例。


在下文中一共展示了Division::_addNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 function edit()
 {
     $id = $this->_arg('league');
     if (!$id && empty($this->data)) {
         $this->Session->setFlash(sprintf(__('Invalid %s', true), __('league', true)), 'default', array('class' => 'info'));
         $this->redirect(array('action' => 'index'));
     }
     if (!empty($this->data)) {
         Configure::load("sport/{$this->data['League']['sport']}");
         $this->Configuration->loadAffiliate($this->data['League']['affiliate_id']);
         if (array_key_exists('Day', $this->data['League'])) {
             $this->data['Day'] = $this->data['League']['Day'];
         }
         $transaction = new DatabaseTransaction($this->League);
         // Division->saveAll needs to not have League data in it
         if (array_key_exists('Division', $this->data)) {
             $division = $this->data;
             unset($division['League']);
         }
         if (isset($division) && $division['Division']['schedule_type'] != 'none' && (empty($this->data['Day']) || empty($this->data['Day'][0]))) {
             $this->League->save($this->data, array('validate' => 'only'));
             $this->League->Division->saveAll($division, array('validate' => 'only'));
             $this->League->validationErrors['Day'] = sprintf(__('You must select at least one %s!', true), __('day', true));
         } else {
             if ($this->League->save($this->data) && (!isset($division) || $this->League->Division->saveAll($division))) {
                 // Any time that this is called, the division seeding might change.
                 // We just reset it here, and it will be recalculated as required elsewhere.
                 if (isset($division)) {
                     $divisions = array($this->data['Division']['id']);
                 } else {
                     $divisions = $this->League->divisions($id);
                 }
                 $this->League->Division->Team->updateAll(array('seed' => 0), array('Team.division_id' => $divisions));
                 foreach ($divisions as $division) {
                     Cache::delete("division/{$division}/standings", 'long_term');
                     Cache::delete("division/{$division}/schedule", 'long_term');
                 }
                 Cache::delete("league/{$id}/standings", 'long_term');
                 Cache::delete("league/{$id}/schedule", 'long_term');
                 $transaction->commit();
                 $this->Session->setFlash(sprintf(__('The %s has been saved', true), __('league', true)), 'default', array('class' => 'success'));
                 $this->redirect(array('action' => 'index'));
             }
         }
         $this->Session->setFlash(sprintf(__('The %s could not be saved. Please correct the errors below and try again.', true), __('league', true)), 'default', array('class' => 'warning'));
         $this->Configuration->loadAffiliate($this->League->affiliate($id));
     }
     // Very likely that we need to read existing league information for menu purposes
     $this->League->contain(array('Division' => array('Person', 'Day' => array('order' => 'day_id')), 'StatType'));
     $v = $this->League->validationErrors;
     $this->League->read(null, $id);
     $this->League->validationErrors = $v;
     if (!$this->League->data) {
         $this->Session->setFlash(sprintf(__('Invalid %s', true), __('league', true)), 'default', array('class' => 'info'));
         $this->redirect(array('action' => 'index'));
     }
     foreach (array_keys($this->League->data['Division']) as $key) {
         Division::_addNames($this->League->data['Division'][$key], $this->League->data['League']);
     }
     $this->_addLeagueMenuItems($this->League->data);
     $this->Configuration->loadAffiliate($this->League->data['League']['affiliate_id']);
     if (count($this->League->data['Division']) == 1) {
         // Adjust loaded data
         $this->League->data['Division'] = array_pop($this->League->data['Division']);
         $this->League->data['Day'] = $this->League->data['Division']['Day'];
         $this->set('league_obj', $this->_getComponent('LeagueType', $this->League->data['Division']['schedule_type'], $this));
         $this->set('is_coordinator', false);
     }
     if (empty($this->data)) {
         $this->data = $this->League->data;
         Configure::load("sport/{$this->data['League']['sport']}");
     }
     $this->set('days', $this->League->Division->Day->find('list'));
     $this->set('sport', $this->data['League']['sport']);
     $this->set('stat_types', $this->League->StatType->find('all', array('conditions' => array('sport' => $this->data['League']['sport']))));
     $this->set('affiliates', $this->_applicableAffiliates(true));
     if (Configure::read('feature.tiny_mce')) {
         $this->helpers[] = 'TinyMce.TinyMce';
     }
 }
开发者ID:roboshed,项目名称:Zuluru,代码行数:80,代码来源:leagues_controller.php

示例2: _addDivisionMenuItems

 /**
  * Add all the links for a division to the menu.
  */
 function _addDivisionMenuItems($division, $league, $id = null, $name = null)
 {
     Configure::load("sport/{$league['sport']}");
     if ($id) {
         $path = array(__('Leagues', true), $name);
     } else {
         $path = array(__('Leagues', true));
     }
     if (!array_key_exists('league_name', $division)) {
         Division::_addNames($division, $league);
     }
     $is_coordinator = in_array($division['id'], $this->UserCache->read('DivisionIDs'));
     $is_manager = $this->is_manager && in_array($league['affiliate_id'], $this->UserCache->read('ManagedAffiliateIDs'));
     if (array_key_exists('Division', $league)) {
         $division_count = count($league['Division']);
     } else {
         $division_count = $this->requestAction(array('controller' => 'leagues', 'action' => 'division_count'), array('named' => array('league' => $league['id'])));
     }
     if ($division_count == 1) {
         $this->_addMenuItem($division['league_name'], array('controller' => 'leagues', 'action' => 'view', 'league' => $league['id']), $path);
         $path[] = $division['league_name'];
     } else {
         $this->_addMenuItem($league['name'], array('controller' => 'leagues', 'action' => 'view', 'league' => $league['id']), $path);
         $path[] = $league['name'];
         if (!empty($division['name'])) {
             $this->_addMenuItem($division['name'], array('controller' => 'divisions', 'action' => 'view', 'division' => $division['id']), $path);
             $path[] = $division['name'];
         }
     }
     $this->_addMenuItem(__('Schedule', true), array('controller' => 'divisions', 'action' => 'schedule', 'division' => $division['id']), $path);
     $this->_addMenuItem(__('Standings', true), array('controller' => 'divisions', 'action' => 'standings', 'division' => $division['id']), $path);
     if ($this->is_logged_in) {
         if ($division['schedule_type'] != 'competition') {
             $this->_addMenuItem(__('Scores', true), array('controller' => 'divisions', 'action' => 'scores', 'division' => $division['id']), $path);
         }
         if (League::hasStats($league)) {
             $this->_addMenuItem(__('Stats', true), array('controller' => 'divisions', 'action' => 'stats', 'division' => $division['id']), $path);
         }
     }
     if ($this->is_admin || $is_manager || $is_coordinator) {
         $this->_addMenuItem(__('Add Games', true), array('controller' => 'schedules', 'action' => 'add', 'division' => $division['id']), array_merge($path, array('Schedule')));
         if ($division['schedule_type'] != 'competition') {
             $this->_addMenuItem(__('Approve scores', true), array('controller' => 'divisions', 'action' => 'approve_scores', 'division' => $division['id']), $path);
         }
         if ($division_count == 1) {
             $this->_addMenuItem(__('Edit', true), array('controller' => 'leagues', 'action' => 'edit', 'league' => $league['id']), $path);
         } else {
             $this->_addMenuItem(__('Edit', true), array('controller' => 'divisions', 'action' => 'edit', 'division' => $division['id']), $path);
         }
         $this->_addMenuItem(sprintf(__('%s distribution', true), __(Configure::read('sport.field_cap'), true)), array('controller' => 'divisions', 'action' => 'fields', 'division' => $division['id']), $path);
         $this->_addMenuItem(sprintf(__('%s availability', true), __(Configure::read('sport.field_cap'), true)), array('controller' => 'divisions', 'action' => 'slots', 'division' => $division['id']), $path);
         $this->_addMenuItem(__('Status report', true), array('controller' => 'divisions', 'action' => 'status', 'division' => $division['id']), $path);
         if (Configure::read('scoring.allstars') && $division['allstars'] != 'never') {
             $this->_addMenuItem(__('All stars', true), array('controller' => 'divisions', 'action' => 'allstars', 'division' => $division['id']), $path);
         }
         $this->_addMenuItem(__('Captain emails', true), array('controller' => 'divisions', 'action' => 'emails', 'division' => $division['id']), $path);
         if (League::hasSpirit($league)) {
             $this->_addMenuItem(__('Spirit Report', true), array('controller' => 'divisions', 'action' => 'spirit', 'division' => $division['id']), $path);
             $this->_addMenuItem(__('Download', true), array('controller' => 'divisions', 'action' => 'spirit', 'division' => $division['id'], 'ext' => 'csv'), array_merge($path, array('Spirit Report')));
         }
         $this->_addMenuItem(__('Adjust seeds', true), array('controller' => 'divisions', 'action' => 'seeds', 'division' => $division['id']), $path);
     }
     if ($this->is_admin) {
         $this->_addMenuItem(__('Add coordinator', true), array('controller' => 'divisions', 'action' => 'add_coordinator', 'division' => $division['id']), $path);
     }
     // Some items are only applicable depending on league configuration
     if (!empty($division['schedule_type'])) {
         $league_obj = $this->_getComponent('LeagueType', $division['schedule_type'], $this);
         $league_obj->addMenuItems($division, $path, $is_coordinator || $is_manager);
     }
 }
开发者ID:roboshed,项目名称:Zuluru,代码行数:74,代码来源:app_controller.php


注:本文中的Division::_addNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。