public function generateAllCollection() { $data = classRegistry::init('Paint')->{$this}->Paginate('all', array('order' => 'Paint.created DESC', 'limit' => 3)); $data = $this->paginate('Paint'); pr($data); exit; return $data; }
public function afterSave(Model $Model, $created, $options = array()) { if (!empty($Model->data[$Model->alias]['file'])) { $data = $Model->data[$Model->alias]; $uploadType = $Model->alias == 'BrwFile' ? 'files' : 'images'; $uploadsPath = classRegistry::init($data['model'])->brwConfig[$uploadType][$data['category_code']]['path']; $dest_dir = $uploadsPath . DS . $data['model'] . DS . $data['record_id']; if (!$created) { $this->_deleteFiles($uploadsPath, $data['model'], $data['record_id'], $Model->data['name_prev']); } if (!is_dir($dest_dir)) { if (!mkdir($dest_dir, 0777, true)) { $this->log('BrowniePHP: unable to create dir ' . $dest_dir); } else { chmod($dest_dir, 0777); } } $this->_copy($Model, $data['file'], $dest_dir . DS . $data['name']); } }
function bind($modelNames, $options = array()) { $defaultOptions = array('form' => 'form', 'inline' => true, 'root' => Router::url('/'), 'watch' => array(), 'catch' => true); $options = am($defaultOptions, $options); $pluginOptions = array_intersect_key($options, array('messageId' => true, 'root' => true, 'watch' => true)); //load the whitelist $this->whitelist = Configure::read('javascriptValidationWhitelist'); $validation = array(); if (!is_array($modelNames)) { $modelNames = array($modelNames); } //filter the rules to those that can be handled with JavaScript foreach ($modelNames as $modelName) { $model = classRegistry::init($modelName); foreach ($model->validate as $field => $validators) { if (array_intersect(array('rule', 'allowEmpty', 'on', 'message', 'last'), array_keys($validators))) { $validators = array($validators); } foreach ($validators as $key => $validator) { $rule = null; if (!is_array($validator)) { $validator = array('rule' => $validator); } //skip rules that are applied only on created or updates if (!empty($validator['on'])) { continue; } if (!isset($validator['message'])) { $message = sprintf(__($key, true), __($field, true)); if ($key != $message) { $validator['message'] = $message; } else { $validator['message'] = sprintf('%s %s', __('There was a problem with the field', true), Inflector::humanize($field)); } } if (!empty($validator['rule'])) { $rule = $this->__convertRule($validator['rule']); } if ($rule) { $temp = array('rule' => $rule, 'message' => __($validator['message'], true)); if (isset($validator['last']) && $validator['last'] === true) { $temp['last'] = true; } if (isset($validator['allowEmpty']) && $validator['allowEmpty'] === true) { $temp['allowEmpty'] = true; } if (in_array($validator['rule'], array('blank'))) { //Cake Validation::_check returning true is actually false for blank //add a "!" so that JavaScript knows $temp['negate'] = true; } $validation[$modelName . Inflector::camelize($field)][] = $temp; } } } if (!empty($pluginOptions['watch'])) { $pluginOptions['watch'] = $this->__fixWatch($modelName, $pluginOptions['watch']); } } if ($options['form']) { if ($options['catch']) { $js = sprintf('$(function() { $("%s").validate(%s, %s) });', $options['form'], $this->Javascript->object($validation), $this->Javascript->object($pluginOptions)); } else { $js = sprintf('$(function() { $("%s").data("validation", %s) });', $options['form'], $this->Javascript->object($validation)); } } else { return $this->Javascript->object($validation); } if ($options['inline']) { return sprintf($this->Javascript->tags['javascriptblock'], $js); } else { $this->Javascript->codeBlock($js, array('inline' => false)); } return; }
/** * Check where to redirect after submitting the checkout form */ public function process($data) { $cart = $this->cart_contents(); $data = array_merge($cart['Order'], $data['Order']); $processor = $this->PaymentMethod->getProcessor($data['payment_method_id']); if (isset($processor['model'])) { $error = classRegistry::init('Payment.' . $processor['model'])->chargeCard($data); if (!$error) { $this->redirect(array('action' => 'success')); } } else { $this->redirect(array('plugin' => 'payment', 'controller' => $processor['name'], 'action' => 'index')); } }
public function __construct($request = null, $response = null) { parent::__construct($request, $response); $this->User = ClassRegistry::init('AppUser'); $this->User->UserDetail = classRegistry::init('AppUserDetail'); }
public function generateHotCollection() { $data = classRegistry::init('Paint')->find('all', array('conditions' => array('Paint.featured' => 0), 'order' => 'Paint.created DESC')); return $data; }
public function generateSlider() { $data = classRegistry::init('SliderContent')->find('all', array('conditions' => array('SliderContent.status' => 'active'))); //pr($data);die(); return $data; }
public function generateLatestNews() { $data = classRegistry::init('New')->find('all', array('order' => 'New.created DESC')); return $data; }