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; }
/** * global function used to access language-strings. returns warning-string if key does not exist * @param string $msgId name of the language-string to return * @param array $msgArgs any parameters for printf if you have * @parma bool $safe true if you want no error to be thrown * @return string */ function __($msgId, $msgArgs = NULL, $safe = false) { if (null == $GLOBALS['__cachedLocaleComponent']) { $GLOBALS['__cachedLocaleComponent'] = classRegistry::getObject('LocaleComponent'); } if ($safe) { return $GLOBALS['__cachedLocaleComponent']->safeGetString($msgId, $msgArgs); } return $GLOBALS['__cachedLocaleComponent']->getString($msgId, $msgArgs); }
/** * destructor, outputs Total Render time if DEBUG>0 */ function __destruct() { if (DEBUG > 0) { kataDebugOutput('Total Render Time (including Models) ' . (microtime(true) - $this->starttime) . ' secs'); kataDebugOutput('Memory used ' . number_format(memory_get_usage(true)) . ' bytes'); kataDebugOutput('Parameters ' . print_R($this->params, true)); if (function_exists('xdebug_get_profiler_filename')) { $fn = xdebug_get_profiler_filename(); if (false !== $fn) { kataDebugOutput('profilefile:' . $fn); } } kataDebugOutput('Loaded classes: ' . implode(' ', array_keys(classRegistry::getLoadedClasses()))); } }
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']); } }
/** * return class-handle of a utility-class * You always get the same object, singleton-alike. * * @param string $name name of the utility * @return object class-handle */ function getUtil($name) { if (file_exists(LIB . 'utilities' . DS . strtolower($name) . '.php')) { require_once LIB . 'utilities' . DS . strtolower($name) . '.php'; } else { require_once APP . 'utilities' . DS . strtolower($name) . '.php'; } $classname = $name . 'Utility'; return classRegistry::getObject($classname); }
/** * returns initialized class of other helpers. you have to take care of initialization order! * * @param string $name name of helper you need access to * @return object */ function getHelper($name) { $classname = ucfirst(strtolower($name)) . 'Helper'; if (!classRegistry::hasObject($classname)) { throw new RuntimeException("Helper {$name} not initialized yet. Wrong initialization order?"); } return classRegistry::getObject($classname); }
/** * return class-handle of a utility-class * You always get the same object, singleton-alike. * * @param string $name name of the utility * @return object class-handle */ function getUtil($name) { require_once APP . 'models' . DS . strtolower($name) . '.php'; $classname = $name . 'Utility'; return classRegistry::getObject($classname); }
protected function _initHelper($name) { $name = strtolower($name); $classname = ucfirst(strtolower($name)) . 'Helper'; $h = classRegistry::getObject($classname); $h->view = $this; $h->action = $this->action; $h->params = $this->controller->params; $h->base = $this->base; $h->basePath = $this->basePath; $h->vars = $this->controller->viewVars; return $h; }
public function generateSlider() { $data = classRegistry::init('SliderContent')->find('all', array('conditions' => array('SliderContent.status' => 'active'))); //pr($data);die(); return $data; }
/** * 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'); }
function onPrepareContent(&$article, &$params) { if (!class_exists('cmsFramework') || !class_exists('Sanitize')) { return; } // Check whether to perform the replacement or not $option = Sanitize::getString($_REQUEST, 'option', ''); $view = Sanitize::getString($_REQUEST, 'view', ''); $layout = Sanitize::getString($_REQUEST, 'layout', ''); $id = Sanitize::getInt($_REQUEST, 'id'); if ($option == 'com_content' && in_array($view, array('article', 'category', 'section', 'frontpage')) && ($layout != '' || in_array($view, array('article', 'frontpage')))) { $row =& $article; if (($this->cms_version >= 1.6 || (isset($row->params) || isset($row->parameters))) && isset($row->id) && $row->id > 0 && isset($row->catid) && $row->catid > 0 && ($this->cms_version >= 1.6 || isset($row->sectionid) && $row->sectionid > 0)) { $Dispatcher = new S2Dispatcher('jreviews', true); if ($option == 'com_content' && $view == 'article' & $id > 0) { $_GET['url'] = 'com_content/com_content_view'; } elseif ($option == 'com_content' && (($layout == 'blog' || $layout == 'blogfull') && ($view == 'category' || $view == 'section') || $view == 'frontpage')) { $_GET['url'] = 'com_content/com_content_blog'; } $passedArgs = array('params' => $params, 'row' => $row, 'component' => 'com_content'); $passedArgs['cat'] = $row->catid; isset($row->sectionid) and $passedArgs['section'] = $row->sectionid; $passedArgs['listing_id'] = $row->id; $output = $Dispatcher->dispatch($passedArgs); if ($output) { $row =& $output['row']; unset($params); $params =& $output['params']; } /** * Store a copy of the $listing and $crumbs arrays in memory for use in the onBeforeDisplayContent method */ classRegistry::setObject(array('listing' => &$output['listing'], 'crumbs' => &$output['crumbs']), 'jreviewsplugin'); // Destroy pathway if (!empty($output['crumbs'])) { cmsFramework::setPathway(array()); } unset($output, $passedArgs, $Dispatcher); } } }
/** * loads all models this controller needs */ function _constructClasses() { if (!is_array($this->uses)) { throw new InvalidArgumentException('$uses must be an array'); } //models require_once LIB . 'model.php'; foreach ($this->uses as $u) { $this->{$u} = getModel($u); } //components if (!is_array($this->components)) { throw new InvalidArgumentException('$components must be an array'); } require_once LIB . 'component.php'; foreach ($this->components as $comname) { require_once APP . 'controllers' . DS . 'components' . DS . strtolower($comname); $classname = $comname . 'Component'; $this->{$comname} = classRegistry::getObject($classname); $this->{$comname}->startup($this); } }
public function generateHotCollection() { $data = classRegistry::init('Paint')->find('all', array('conditions' => array('Paint.featured' => 0), 'order' => 'Paint.created DESC')); return $data; }
/** * construct all helpers we found in our helpers property */ protected function constructHelpers() { if ($this->didConstructHelpers) { return; } require_once LIB . 'helper.php'; foreach ($this->helpers as $name) { $name = strtolower($name); $classname = ucfirst(strtolower($name)) . 'Helper'; $h = classRegistry::getObject($classname); $h->action = $this->action; $h->params = $this->controller->params; $h->base = $this->base; $h->basePath = $this->basePath; $h->vars = $this->controller->viewVars; $this->helperClasses[$name] = $h; } $this->didConstructHelpers = true; }
/** * load dbo-class, give dbconfig to class * * @param string $connName name of the connection to use */ protected function setupDbo($connName) { require_once ROOT . 'config' . DS . 'database.php'; if (!class_exists('DATABASE_CONFIG')) { throw new Exception('Incorrect config/database.php'); } $dbvars = get_class_vars('DATABASE_CONFIG'); if (empty($dbvars[$connName])) { throw new DatabaseConnectException("Cant find configdata for database-connection '{$connName}'"); } $dboname = 'dbo_' . $dbvars[$connName]['driver']; if (!class_exists($dboname)) { require_once LIB . 'dbo' . DS . $dboname . '.php'; } //for evil people modifying the connection-parameters $connHandle = $connName . implode('|', $dbvars[$connName]); $this->dboClass = classRegistry::getObject($dboname, $connHandle); $this->dboClass->setConfig($dbvars[$connName]); }
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; }
public function generateLatestNews() { $data = classRegistry::init('New')->find('all', array('order' => 'New.created DESC')); return $data; }