Esempio n. 1
0
 public function test_set()
 {
     $controller = new Controller('');
     $controller->set('foo', 100);
     $controller->set('bar', array(1, 2));
     $this->assertEquals(100, $controller->view->vars['foo']);
     $this->assertEquals(array(1, 2), $controller->view->vars['bar']);
     $controller->set(array('foo' => 200));
     $this->assertEquals(200, $controller->view->vars['foo']);
 }
Esempio n. 2
0
 /**
  * グループ一覧・グループユーザを設定
  *
  * @param Controller $controller コントローラー
  * @param array $query find条件
  * @return void
  */
 public function setGroupList(Controller $controller, $query = array())
 {
     $groups = $controller->Group->getGroupList($query);
     $controller->set('groups', $groups);
     $userIdArr = Hash::extract($groups, '{n}.GroupsUser.{n}.user_id');
     $userIdArr = array_unique($userIdArr);
     // 重複した値をまとめる
     $groupUsers = $controller->GroupsUser->getGroupUsers($userIdArr);
     $controller->set('users', $groupUsers);
 }
Esempio n. 3
0
 /**
  * List users with filter capability as defined in User::$filterArgs
  *
  * This will be useful for ajax autocompletion
  */
 public function lookup(Controller $controller)
 {
     $request = $controller->request;
     $controller->Prg->commonProcess();
     $controller->User->Behaviors->attach('Users.UserApiResultFormatter');
     $controller->paginate = array('fields' => array('id', 'username', 'name', 'website', 'image', 'bio', 'timezone', 'status', 'created', 'updated'), 'contain' => array('Role' => array('fields' => array('id', 'title', 'alias'))), 'conditions' => $controller->User->parseCriteria($request->query));
     $users = $controller->paginate();
     $controller->set('_rootNode', 'users');
     $controller->set('user', $users);
     $controller->set('_serialize', 'user');
 }
 /**
  * Called after the Controller::beforeFilter() and before the controller action
  *
  * @param Controller $controller Controller with components to startup
  * @return void
  * @link http://book.cakephp.org/2.0/ja/controllers/components.html#Component::startup
  */
 public function startup(Controller $controller)
 {
     $permissions = $controller->Workflow->getBlockRolePermissions($this->permission);
     $controller->set('permissions', $permissions);
     $controller->set('roles', $controller->viewVars['permissions']['Roles']);
     if ($controller->request->is('get')) {
         /** @see MailSetting::getMailSettingPlugin() */
         $mailSettingPlugin = $controller->MailSetting->getMailSettingPlugin(null, $this->typeKeys);
         $controller->set('mailSettingPlugin', $mailSettingPlugin);
     }
 }
Esempio n. 5
0
 function error($message)
 {
     if (!headers_sent()) {
         header("HTTP/1.0 404 Not Found");
     }
     $controller = new Controller($this->request);
     $controller->getMenu = $controller->renderMenu('menu');
     $controller->set('content_for_menu', $controller->getMenu);
     $controller->set('message', $message);
     $controller->render('/errors/404');
 }
Esempio n. 6
0
 /**
  * List nodes with filter capability as defined in Node::$filterArgs
  *
  * This will be useful for ajax autocompletion
  */
 public function lookup(Controller $controller)
 {
     $request = $controller->request;
     $controller->Prg->commonProcess();
     $Node = $controller->{$controller->modelClass};
     $Node->Behaviors->attach('Nodes.NodeApiResultFormatter');
     $controller->paginate = array('fields' => array('id', 'parent_id', 'type', 'user_id', 'title', 'slug', 'body', 'excerpt', 'status', 'promote', 'path', 'terms', 'created', 'updated', 'publish_start', 'publish_end'), 'contain' => array('User', 'Meta', 'Taxonomy'), 'conditions' => $Node->parseCriteria($request->query));
     $nodes = $controller->paginate();
     $controller->set('_rootNode', 'nodes');
     $controller->set('node', $nodes);
     $controller->set('_serialize', 'node');
 }
Esempio n. 7
0
 /**
  * Hook admin menu element to set role parent
  */
 protected function _setupRole()
 {
     $title = __d('croogo', 'Parent Role');
     $element = 'Acl.admin/parent_role';
     Croogo::hookAdminTab('Roles/admin_add', $title, $element);
     Croogo::hookAdminTab('Roles/admin_edit', $title, $element);
     $this->_controller->Role->bindAro();
     $id = null;
     if (!empty($this->_controller->request->params['pass'][0])) {
         $id = $this->_controller->request->params['pass'][0];
     }
     $this->_controller->set('parents', $this->_controller->Role->allowedParents($id));
 }
Esempio n. 8
0
 /**
  * Store referer data in view $referer variable
  *
  * @param string $default
  */
 public function setReferer($default = null)
 {
     if (empty($this->Controller->request->data['Data']['referer'])) {
         $referer = $this->Controller->request->referer();
         if ($referer == '/' && !empty($default)) {
             $referer = $default;
             if (is_array($referer)) {
                 $referer = Router::url($referer);
             }
         }
     } else {
         $referer = $this->Controller->request->data['Data']['referer'];
     }
     $this->Controller->set(compact('referer'));
 }
 /**
  * An action or view is being overridden, so prepare the layout and environment.
  * Bind any other data that should be present.
  *
  * @param Controller $controller
  */
 public function beforeRender(Controller $controller)
 {
     $badges = array();
     foreach (Configure::read('Admin.menu') as $section => $menu) {
         $badges[$section] = $menu['count'];
     }
     $controller->set('badgeCounts', $badges);
     if (isset($controller->Model)) {
         $controller->set('model', $controller->Model);
     }
     if (isset($controller->request->params['override'])) {
         $controller->layout = 'Admin.admin';
         $controller->request->params['action'] = str_replace('admin_', '', $controller->action);
     }
 }
Esempio n. 10
0
 public function startup(Controller $controller)
 {
     if (!isset($controller->request->params['named']['CakeUILocalStorageName'])) {
         return;
     }
     $options = $controller->request->data['CakeUILocalStorage'];
     $model = $options['model'];
     if ($controller->request->params['named']['CakeUIOperation'] == 1) {
         //Display modal window
         if (isset($controller->request->data[$model])) {
             $data[$model] = $controller->request->data[$model][$controller->request->params['named']["CakeUIRowId"]];
             $controller->request->data = $data;
             $controller->request->data['CakeUITemp']['key'] = $controller->request->params['named']["CakeUIRowId"];
         }
         $controller->set(compact('options'));
         // $controller->set("cakeUICookie",$controller->request->params['named']["CakeUICookie"]);
         $controller->set("CakeUILocalStorageName", $controller->request->params['named']['CakeUILocalStorageName']);
         echo $controller->render($options["element"]);
         die;
     } else {
         if ($controller->request->params['named']['CakeUIOperation'] == 2) {
             //Add or update
             $controller->set(compact('options'));
             $controller->set("CakeUILocalStorageName", $controller->request->params['named']['CakeUILocalStorageName']);
             if ($this->model->{$model}->saveAll($controller->request->data, array('validate' => 'only'))) {
                 $controller->set('requestData', $controller->request->data);
                 echo $controller->render($options["return_element"]);
             } else {
                 $controller->Session->setFlash(__('Não foi possível adicionar este item'), 'default', array('class' => 'alert alert-danger'), 'modalMsg');
                 echo $controller->render($options["element"]);
             }
             die;
         } else {
             if ($controller->request->params['named']['CakeUIOperation'] == 3) {
                 //Delete
                 $id = $controller->request->params['named']["CakeUIRecordId"];
                 $this->model->{$model}->id = $id;
                 if (!$this->model->{$model}->exists()) {
                     throw new NotFoundException(__('Item inválido 1'));
                 }
                 if ($this->model->{$model}->delete($id, true)) {
                     die;
                 }
                 throw new NotFoundException(__('Item inválido 2'));
             }
         }
     }
 }
 public function respond()
 {
     $this->Controller->layout = "empty";
     $this->Controller->viewClass = "Media.Json";
     $this->Controller->set('uploadResponse', $this->Upload->toArray());
     $this->Controller->set('json', 'uploadResponse');
 }
 /**
  * 会員項目のレイアウトに必要なデータを取得し、viewにセットする
  *
  * @param Controller $controller コントローラ
  * @return void
  * @link http://book.cakephp.org/2.0/ja/controllers/components.html#Component::startup Component::startup
  */
 public function startup(Controller $controller)
 {
     //RequestActionの場合、スキップする
     if (!empty($controller->request->params['requested'])) {
         return;
     }
     //Modelの呼び出し
     $controller->UserAttributeLayout = ClassRegistry::init('UserAttributes.UserAttributeLayout');
     $controller->UserAttribute = ClassRegistry::init('UserAttributes.UserAttribute');
     //UserAttributeデータセット
     $userAttributes = $controller->UserAttribute->getUserAttributesForLayout();
     $controller->set('userAttributes', $userAttributes);
     //UserAttributeLayoutデータセット
     $userAttributeLayouts = $controller->UserAttributeLayout->find('all', array('fields' => array('id', 'col'), 'recursive' => -1, 'order' => array('id' => 'asc')));
     $controller->set('userAttributeLayouts', $userAttributeLayouts);
 }
 /**
  * Generic view action
  *
  * Triggers the following callbacks
  *	- Crud.init
  *	- Crud.beforeFind
  *	- Crud.recordNotFound
  *	- Crud.afterFind
  *	- Crud.beforeRender
  *
  * @param string $id
  * @return void
  */
 protected function _viewAction($id = null)
 {
     if (empty($id)) {
         $id = $this->getIdFromRequest();
     }
     $this->_validateId($id);
     // Build conditions
     $query = array();
     $query['conditions'] = array($this->_model->escapeField() => $id);
     $findMethod = $this->_getFindMethod(null, 'first');
     $subject = $this->trigger('beforeFind', compact('id', 'query', 'findMethod'));
     $query = $subject->query;
     // Try and find the database record
     $item = $this->_model->find($subject->findMethod, $query);
     // We could not find any record match the conditions in query
     if (empty($item)) {
         $subject = $this->trigger('recordNotFound', compact('id'));
         $this->_setFlash('find.error');
         return $this->_redirect($subject, array('action' => 'index'));
     }
     // We found a record, trigger an afterFind
     $subject = $this->trigger('afterFind', compact('id', 'item'));
     $item = $subject->item;
     // Push it to the view
     $this->_controller->set(compact('item'));
     // Trigger a beforeRender
     $this->trigger('beforeRender', compact('id', 'item'));
 }
 public function initialize(Controller $controller)
 {
     if ($controller->request->params['controller'] == "nodes") {
         switch ($controller->request->params['action']) {
             case 'admin_edit':
                 $compare = true;
                 $compare = is_numeric($controller->request->params['pass'][0]);
                 if ($compare) {
                     $rq = $controller->Node->findById($controller->request->params['pass'][0]);
                     $controller->set(array('Multiattach' => $rq['Multiattach']));
                     $controller->set(array('node_id' => $controller->request->params['pass'][0]));
                 }
                 break;
         }
     }
 }
	public function index($params){
		
		$bookings = $this->db->getOnlineBooking();
		
		parent::set('bookings', $bookings);
		parent::set('active', 'online_booking');
	}
Esempio n. 16
0
	public function index($params){
		
		parent::set('onHome', $this->db->getHome());
		
		parent::set('active', 'pocetna');
		
	}
Esempio n. 17
0
	public function details($params){
		//Set top carousel
		$carousel = $this->db->getGroupsCarouselDetails($params['detail']);
		parent::set('carouselImage', $carousel);
		parent::set('carouselFolder', 'accomodation');
		parent::set('carouselAction', 'winter');
		parent::set('carouselPage', 'accomodation_id');
		
		//Main table
		if(!Cache::get(array('key' => 'accType'.$params['group']))){
			$output = $this->db->getAccType($params);
			Cache::set(array('key' => 'accType'.$params['group'], 'data' => $output));
		}else $output = Cache::get(array('key' => 'accType'.$params['group']));
		parent::set('accType', $output);
		
		//Accomodation
		if(!Cache::get(array('key' => 'oneAccom'.$params['detail']))){
			$output = $this->db->getOneAcc($params);
			Cache::set(array('key' => 'oneAccom'.$params['detail'], 'data' => $output));
		}else $output = Cache::get(array('key' => 'oneAccom'.$params['detail']));
		parent::set('accom', $output);
		
		//Active page
		parent::set('active', 'zimovanja');
		//Params
		parent::set('params', $params);

		parent::set('front', $this->db->getDescriptionAndKeywords('accomodations', $params['detail']));
	} 
Esempio n. 18
0
    public function editAction($params)
    {
       
        if(!empty($params['submit'])){
            //Data submited

            if($this->db->updateCarousel($params['carousel'])){
                //If image uploaded add it
                
                if(0 == $params['image']['error']){
                    
                    $data = $this->db->getImageName($params['carousel']['id']);
                    $oldImageName = $data['image_name'];
                    
                    $newImageName = $params['carousel']['id'].'-'.$params['image']['name'];
                    $this->db->setImageName($params['carousel']['id'], $newImageName);
                    $this->reUploadImage($oldImageName, $newImageName, $params['image'], 'carousel');
                }
                parent::redirect ('cms'.DS.'carousel', 'success');
            }else{
                parent::redirect ('cms'.DS.'carousel'.DS.'edit'.DS.$params['id'], 'error');
            }
        }
        parent::set('carousel', $this->db->findCarousel($params['id']));
    }
Esempio n. 19
0
 /**
  * Identifica o meio de passagem e o valor passado para filtragem
  * e o seta ao atributo de classe equivalente
  * 
  * @return string $query
  */
 public function setQuery()
 {
     // caso seja uma requisição post e tenha dados do filtro setado
     if ($this->RequestHandler->isPost() && strtolower($this->settings['method']) == 'post' && !empty($this->Controller->data[$this->settings['inputModel']])) {
         // recupera os dados setados
         $data = $this->Controller->data[$this->settings['inputModel']][$this->settings['inputName']];
     } else {
         if ($this->RequestHandler->isGet() && !empty($this->Controller->passedArgs[$this->settings['inputName']])) {
             $data = Sanitize::escape($this->Controller->passedArgs[$this->settings['inputName']]);
         } else {
             if ($this->RequestHandler->isGet() && !empty($this->Controller->params['url'][$this->settings['inputName']])) {
                 $data = Sanitize::escape($this->Controller->params['url'][$this->settings['inputName']]);
             }
         }
     }
     // caso não tenha nenhum dado para filtrar, retorna uma string vazia
     if (empty($data)) {
         $data = '';
     }
     // seta o atributo da classe com o valor identificado
     $this->query = $data;
     if (isset($this->settings['cleanupQuery']) && $this->settings['cleanupQuery'] === true) {
         $this->__clenupQuery();
     }
     // seta para a view
     $this->Controller->set('search_query', $this->query);
     return $data;
 }
 public function beforeRender(Controller $controller)
 {
     if ($this->isBrwPanel) {
         $controller->set(array('companyName' => Configure::read('brwSettings.companyName'), 'brwHideMenu' => $controller->Session->read('brw.hideMenu')));
     }
     $this->controller->set('brwSettings', Configure::read('brwSettings'));
 }
Esempio n. 21
0
 public function run($data)
 {
     $this->Controller =& new Controller();
     $this->Email =& new EmailComponent(null);
     $this->Email->initialize($this->Controller, $this->defaults);
     if (array_key_exists('settings', $data)) {
         $this->Email->_set(array_filter(am($this->defaults, $data['settings'])));
         if (array_key_exists('vars', $data)) {
             foreach ($data['vars'] as $name => $var) {
                 $this->Controller->set($name, $var);
             }
         }
         return $this->Email->send();
     }
     $this->err('Queue Email task called without settings data.');
     return false;
 }
Esempio n. 22
0
 /**
  * Convenience method to display a PDOException.
  *
  * @param PDOException $error
  * @return void
  */
 public function pdoError(PDOException $error)
 {
     $url = $this->controller->request->here();
     $code = 500;
     $this->controller->response->statusCode($code);
     $this->controller->set(array('code' => $code, 'url' => h($url), 'name' => h($error->getMessage()), 'error' => $error, '_serialize' => array('code', 'url', 'name', 'error')));
     $this->_outputMessage($this->template);
 }
	public function index($params){
		
		parent::set('active', 'rezervacije');
		parent::set('at', $this->db->getAccomodationTypes());
		
		parent::defaultJs(array('online_booking', 'ui.datepicker'));
		parent::defaultCss(array('datepicker'));
	}
Esempio n. 24
0
 function error($message)
 {
     header("HTTP/1.0 404 Not Found");
     $controller = new Controller($this->request);
     $controller->set('message', $message);
     $controller->render('/errors/404');
     die;
 }
Esempio n. 25
0
	public function index($params){
		
		parent::set('active', 'zaposlenje');
		
		parent::set('pos', $this->db->getPositions());
		
		parent::defaultJs(array('carriere'));
	}
Esempio n. 26
0
 /**
  * Convenience method to display a 500 page.
  *
  * @param array $params Parameters for controller
  */
 public function error500($error)
 {
     $url = $this->controller->request->here();
     $code = $error->getCode() > 500 ? $error->getCode() : 500;
     $this->controller->response->statusCode($code);
     $this->controller->set(array('name' => __('An Internal Error Has Occurred'), 'message' => h($url), 'error' => $error));
     $this->_outputMessage('error500');
 }
	public function index($params){
		
		//Check session user
		parent::userInfoAndSession();
		$cond = $this->db->getConditions();
		parent::set('cond', $cond);
		parent::set('active', 'carriere');
	}
Esempio n. 28
0
 /**
  * Generic handler for the internal framework errors CakePHP can generate.
  *
  * @param CakeException $error The exception to render.
  * @return void
  */
 protected function _cakeError(CakeException $error)
 {
     $url = $this->controller->request->here();
     $code = $error->getCode() >= 400 && $error->getCode() < 506 ? $error->getCode() : 500;
     $this->controller->response->statusCode($code);
     $this->controller->set(array('code' => $code, 'name' => h($error->getMessage()), 'message' => h($error->getMessage()), 'url' => h($url), 'error' => $error, '_serialize' => array('code', 'name', 'message', 'url')));
     $this->controller->set($error->getAttributes());
     $this->_outputMessage($this->template);
 }
Esempio n. 29
0
 /**
  * beforeRender
  *
  * @param object $controller instance of controller
  * @return void
  */
 public function beforeRender(Controller $controller)
 {
     $this->controller = $controller;
     $this->controller->set('blocks_for_layout', $this->blocks_for_layout);
     $this->controller->set('menus_for_layout', $this->menus_for_layout);
     $this->controller->set('vocabularies_for_layout', $this->vocabularies_for_layout);
     $this->controller->set('types_for_layout', $this->types_for_layout);
     $this->controller->set('nodes_for_layout', $this->nodes_for_layout);
 }
Esempio n. 30
0
	public function edit($params){
		//Check session user
		parent::userInfoAndSession();
		
		parent::set('contact', $this->db->getLocation($params));
		
		//Set page
		parent::set('active', 'contact');
	}