/** * Render extjs text form field * * @param \Engine\Crud\Form\Field $field * @return string */ public static function _(Field\PasswordConfirm $field) { $fieldCode = []; if ($field->isHidden()) { $fieldCode[] = "xtype: 'hiddenfield'"; } else { $fieldCode[] = "xtype: 'textfield'"; } $fieldCode[] = "name: '" . $field->getKey() . "'"; $fieldCode[] = "inputType: 'password'"; $fieldCode[] = "allowBlank: " . ($field->isRequire() ? "false" : "true"); $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $confirmKey = $field->getConfirmKey(); $fieldCode[] = "validator: function(value) {\n var password1 = this.previousSibling('[name=" . $confirmKey . "]');\n return (value === password1.getValue()) ? true : 'Passwords do not match.'\n }"; return forward_static_call(['self', '_implode'], $fieldCode); }
/** * Run cron task. Attention - this method is too 'fat' to run from any app's * @return array|null */ public function run() { // check if cron instances is defined if (!isset($this->configs['instances']) || !Obj::isArray($this->configs['instances'])) { return null; } // get timestamp $time = time(); $log = []; // each every one instance foreach ($this->configs['instances'] as $callback => $delay) { if ((int) $this->configs['log'][$callback] + $delay <= $time) { // prepare cron initializing list($class, $method) = explode('::', $callback); if (class_exists($class) && method_exists($class, $method)) { // make static callback forward_static_call([$class, $method]); $log[] = $callback; } // update log information $this->configs['log'][$callback] = $time + $delay; } } // write updated configs App::$Properties->writeConfig('Cron', $this->configs); return $log; }
/** * Render extjs number form field * * @param \Engine\Crud\Form\Field $field * @return string */ public static function _(Field\Numeric $field) { $fieldCode = []; if ($field->isHidden()) { $fieldCode[] = "xtype: 'hiddenfield'"; } else { $fieldCode[] = "xtype: 'numberfield'"; } if ($field->isNotEdit()) { $fieldCode[] = "readOnly: true"; } $fieldCode[] = "name: '" . $field->getKey() . "'"; $fieldCode[] = "allowBlank: " . ($field->isRequire() ? "false" : "true"); $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $minValue = $field->getMinValue(); $maxValue = $field->getMaxValue(); if ($minValue !== null && $minValue !== false) { $fieldCode[] = " minValue: '" . $minValue . "'"; } if ($maxValue !== null && $maxValue !== false) { $fieldCode[] = " maxValue: '" . $maxValue . "'"; } return forward_static_call(['self', '_implode'], $fieldCode); }
public function getValue($param = null) { if ($this->_value != null) { return parent::getValue(); } if (!$this->getParent()) { throw new Exception(sprintf("Meta property '%s' missing a parent reference", $this->_id)); } $property = $this->getParent()->getRecursiveProperty($this->getParameter('property')); if ($property instanceof CollectionProperty) { $subParts = explode('.', $this->getParameter('action')); $collection = $property->getValue(); return $collection->{$subParts[0]}(isset($subParts[1]) ? $subParts[1] : null); } else { if ($property instanceof ObjectProperty) { $subParts = explode('.', $this->getParameter('action')); $object = $property->getValue(ObjectModel::MODEL); return $object instanceof BaseObject ? $object->{$subParts[0]}(isset($subParts[1]) ? $subParts[1] : null) : null; } else { $class = $this->_parent->getClass(); $action = $this->getParameter('action'); $array = array($this->_parent->getClass(), $this->getParameter('action')); try { $val = forward_static_call($array, $this->_parent); } catch (\Exception $e) { throw new Exception($e->getMessage()); } return $val; } } }
/** * Render extjs mail form field * * @param \Engine\Crud\Form\Field $field * @return string */ public static function _(Field $field) { $fieldCode = []; if ($field->isHidden()) { $fieldCode[] = "xtype: 'hiddenfield'"; } else { $fieldCode[] = "xtype: 'textfield'"; } if ($field->isNotEdit()) { $fieldCode[] = "readOnly: true"; } $fieldCode[] = "name: '" . $field->getKey() . "'"; $fieldCode[] = "allowBlank: " . ($field->isRequire() ? "false" : "true"); $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $fieldCode[] = "vtype: 'email'"; return forward_static_call(['self', '_implode'], $fieldCode); }
/** * Render extjs image file uplaod form field * * @param \Engine\Crud\Form\Field $field * @return string */ public static function _(Field\Image $field) { $fieldCode = []; if ($field->isHidden()) { $fieldCode[] = "xtype: 'hiddenfield'"; } else { $fieldCode[] = "xtype: 'filefield'"; } if ($field->isNotEdit()) { $fieldCode[] = "readOnly: true"; } $fieldCode[] = "name: '" . $field->getKey() . "'"; $fieldCode[] = "allowBlank: " . ($field->isRequire() ? "false" : "true"); $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $fieldCode[] = "emptyText: 'Select an image'"; $fieldCode[] = "buttonText: ''"; $fieldCode[] = "buttonConfig: {iconCls: 'icon-upload'}"; return forward_static_call(['self', '_implode'], $fieldCode); }
/** * Gets, and creates if neccessary, a store object * * @return AbstractData */ private function _getStore() { if ($this->_store === null) { $this->_store = forward_static_call('PrivateBin\\Data\\' . $this->_conf->getKey('class', 'model') . '::getInstance', $this->_conf->getSection('model_options')); } return $this->_store; }
/** * Render extjs password form field * * @param \Engine\Crud\Form\Field $field * @return string */ public static function _(Field\Password $field) { $fieldCode = []; if ($field->isHidden()) { $fieldCode[] = "xtype: 'hiddenfield'"; } else { $fieldCode[] = "xtype: 'textfield'"; } $fieldCode[] = "name: '" . $field->getKey() . "'"; $fieldCode[] = "inputType: 'password'"; $fieldCode[] = "allowBlank: " . ($field->isRequire() ? "false" : "true"); $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $minLength = $field->getMinLength(); $fieldCode[] = "minLength: " . $minLength; return forward_static_call(['self', '_implode'], $fieldCode); }
/** * @param $slug string * @return string|null */ protected function findVariable($slug) { /** @var $modelQuery \yii\db\ActiveQuery */ $modelQuery = forward_static_call([\Yii::createObject(VariableModel::class), 'find']); $variable = $modelQuery->where(['slug' => $slug])->one(); return $variable ? $variable['content'] : null; }
/** * Gets, and creates if neccessary, a store object */ private function _getStore() { if ($this->_store === null) { $this->_store = forward_static_call(array($this->_conf->getKey('class', 'model'), 'getInstance'), $this->_conf->getSection('model_options')); } return $this->_store; }
/** * Register auth model observers. * * @return void */ protected function registerObserver() { $config = $this->app['config']; $model = $config->get('laravie/warden::model', $config->get('auth.model')); $observer = new UserObserver($this->app->make('laravie.warden'), $config->get('laravie/warden', [])); forward_static_call([$model, 'observe'], $observer); }
/** * Render extjs number filter field * * @param \Engine\Crud\Grid\Filter\Field $field * @return string */ public static function _(Field\Numeric $field) { $fieldCode = []; $fieldCode[] = "xtype: 'numberfield'"; $fieldCode[] = "name: '" . $field->getKey() . "'"; $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $minValue = $field->getMinValue(); $maxValue = $field->getMaxValue(); if ($minValue !== null && $minValue !== false) { $fieldCode[] = " minValue: '" . $minValue . "'"; } if ($maxValue !== null && $maxValue !== false) { $fieldCode[] = " maxValue: '" . $maxValue . "'"; } return forward_static_call(['self', '_implode'], $fieldCode); }
/** * Render extjs combobox filter field * * @param \Engine\Crud\Grid\Filter\Field $field * @return string */ public static function _(Field\ArrayToSelect $field) { $fieldCode = []; $fieldCode[] = "xtype: 'combobox'"; $fieldCode[] = "name: '" . $field->getKey() . "'"; $label = $field->getLabel(); if ($label) { $fieldCode[] = "fieldLabel: '" . $label . "'"; } $desc = $field->getDesc(); if ($desc) { $fieldCode[] = "boxLabel: '" . $desc . "'"; } $width = $field->getWidth(); if ($width) { $fieldCode[] = "width: " . $width; } $fieldCode[] = "typeAhead: true"; $fieldCode[] = "triggerAction: 'all'"; $fieldCode[] = "selectOnTab: true"; $fieldCode[] = "lazyRender: true"; $fieldCode[] = "listClass: 'x-combo-list-small'"; $fieldCode[] = "queryMode: 'local'"; $fieldCode[] = "displayField: 'name'"; $fieldCode[] = "valueField: 'id'"; $fieldCode[] = "valueNotFoundText: 'Nothing found'"; $store = forward_static_call(['static', '_getStore'], $field); $fieldCode[] = "store: " . $store; return forward_static_call(['static', '_implode'], $fieldCode); }
/** * Eloquent will call this on model boot */ public static function bootEloquentValidatingTrait() { // Calling Model::saving() and asking it to execute assertIsValid() before model is saved into database $savingCallable = [static::class, 'saving']; $validationCallable = [static::class, 'assertIsValid']; forward_static_call($savingCallable, $validationCallable); }
/** * @param Job $syncJob Laravel queue job * @param $arguments * @return bool * @throws \Unifact\Connector\Exceptions\HandlerException */ public function fire(Job $syncJob, $arguments) { try { $job = $this->jobRepo->findById($arguments['job_id']); $job->setPreviousStatus($arguments['previous_status']); $handler = forward_static_call([$job->handler, 'make']); $this->logger->debug("Preparing Job.."); if (!$handler->prepare()) { $this->logger->error('Handler returned FALSE in prepare() method, see log for details'); // delete Laravel queue job $syncJob->delete(); return false; } $this->logger->debug("Handling Job.."); if ($handler->handle($job) === false) { $this->logger->error('Handler returned FALSE in handle() method, see log for details'); // delete Laravel queue job $syncJob->delete(); return false; } $this->logger->debug("Completing Job.."); $handler->complete(); $this->logger->info('Finished Job successfully'); } catch (\Exception $e) { $this->oracle->exception($e); $this->logger->error('Exception was thrown in JobQueueHandler::fire method.'); $this->jobRepo->update($arguments['job_id'], ['status' => 'error']); // delete Laravel queue job $syncJob->delete(); return false; } // delete Laravel queue job $syncJob->delete(); return true; }
public static function run($base64_png_data, $program = null) { self::init(); $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('OCR_') . '.png'; file_put_contents($filename, base64_decode($base64_png_data)); $programs = array(); if ($program !== null) { if (in_array($program, self::$installed_ocr_programs)) { $programs[] = $program; } else { throw new Exception("OCR program {$program} is not available."); } } else { $programs = self::$installed_ocr_programs; } $class = get_called_class(); $results = array(); foreach ($programs as $program) { $method = "run_{$program}"; if (method_exists($class, $method)) { $results[$program] = ''; foreach (forward_static_call(array($class, $method), $filename) as $line) { $line = trim($line); if ($line) { $results[$program] .= "{$line}\n"; } } } else { throw new Exception("Unknown OCR method {$method}"); } } @unlink($filename); return $results; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $id_parent) { $module = Module::getInst(); $pageTable = static::tableName(); $pageLangTable = forward_static_call(array($module->manager->pageLangClass, 'tableName')); $query = static::find()->from(['p' => $pageTable])->innerJoin(['l' => $pageLangTable], 'l.page_id=p.id AND l.language_id=:language_id', [':language_id' => Yii::$app->getI18n()->getId()]); $loadParams = $this->load($params); if ($this->id_parent) { $query->innerJoin(['l2' => $pageLangTable], 'l2.page_id=p.id_parent AND l2.language_id=:language_id', [':language_id' => Yii::$app->getI18n()->getId()]); } $query->with(['parent', 'translations']); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['weight' => SORT_ASC]]]); if ($id_parent !== false) { if (empty($id_parent)) { $query->where(['id_parent' => null]); } else { $query->where(['id_parent' => $id_parent]); } } if (!($loadParams && $this->validate())) { return $dataProvider; } $dataProvider->sort->attributes['name']['asc'] = ['l.name' => SORT_ASC]; $dataProvider->sort->attributes['name']['desc'] = ['l.name' => SORT_DESC]; $dataProvider->sort->attributes['title']['asc'] = ['l.title' => SORT_ASC]; $dataProvider->sort->attributes['title']['desc'] = ['l.title' => SORT_DESC]; $dataProvider->sort->attributes['alias']['asc'] = ['l.alias' => SORT_ASC]; $dataProvider->sort->attributes['alias']['desc'] = ['l.alias' => SORT_DESC]; $query->andFilterWhere(['p.id' => $this->id, 'p.weight' => $this->weight, 'p.layout' => $this->layout, 'p.type' => $this->type, 'p.visible' => $this->visible, 'p.active' => $this->active]); $query->andFilterWhere(['like', 'l.name', $this->name])->andFilterWhere(['like', 'l.title', $this->title])->andFilterWhere(['like', 'l.alias', $this->alias]); if ($this->id_parent) { $query->andFilterWhere(['like', 'l2.name', $this->id_parent]); } return $dataProvider; }
/** * Boot all of the bootable traits on the model. * * @return void */ protected static function bootTraits() { foreach (class_uses_recursive(get_called_class()) as $trait) { if (method_exists(get_called_class(), $method = 'boot' . class_basename($trait))) { forward_static_call([get_called_class(), $method]); } } }
/** * @return mixed */ public function nestableGrid() { if (!is_array($this->nestable)) { $this->nestable = []; } $nestable = ArrayHelper::merge(['class' => $this->nestableClass, 'grid' => $this], $this->nestable); return forward_static_call([$nestable['class'], 'widget'], $nestable); }
protected function call($format, $method) { $class = __NAMESPACE__ . "\\" . $format; if (!class_exists($class)) { throw new SerialException("Unrecognised format " . $format); } $this->data = forward_static_call([$class, $method], $this->data); }
/** * @return mixed */ public function nestableGrid() { if (!is_array($this->nestable)) { $this->nestable = []; } $nestable = ArrayHelper::merge(['class' => '\\pavlinter\\adm\\widgets\\GridNestable', 'grid' => $this], $this->nestable); return forward_static_call([$nestable['class'], 'widget'], $nestable); }
/** * @author Damien Lasserre <*****@*****.**> * @param string $_database * @param string $_name * @return orm */ public function getAdapter($_database = null, $_name = 'mysql') { $_param = $this->_name; if (null !== $_database) { $_param = $_database . '.' . $this->_name; } /** @var mysql ${$_name} */ return forward_static_call(array('library\\uranium\\library\\core\\orm\\' . $_name, 'getInstance'), $_param); }
/** * Returns all CMS objects for the set theme * @return CmsObjectCollection */ public function all() { if (!$this->theme) { $this->inEditTheme(); } $collection = forward_static_call([$this->cmsObject, 'listInTheme'], $this->theme, !$this->useCache); $collection = new CmsObjectCollection($collection); return $collection; }
public static function get($element) { $func = 'get' . $element; if (method_exists(get_class(), $func)) { forward_static_call(get_class() . '::' . $func); } else { throw new \Exception('Function ' . $func . '() does not exist.'); } }
/** * @Route("/json/{crudModule:[a-z,-]+}/{crudForm:[a-z,-]+}", methods={"GET"}, name="grid-json") */ public function jsonAction($module, $model) { $modelName = $this->_getModel($module, $model); $result = forward_static_call([$modelName, 'find']); $result = $result->toArray(); $result = \Engine\Tools\Arrays::resultArrayToJsonType($result, 'id', 'name'); echo json_encode([$model => $result]); $this->view->setRenderLevel(View::LEVEL_NO_RENDER); }
/** * For each root of the whole nested set tree structure, checks that their * `lft` and `rgt` bounds are properly set. * * @return boolean */ protected function validateRoots() { $roots = forward_static_call(array(get_class($this->node), 'roots'))->get(); // If a scope is defined in the model we should check that the roots are // valid *for each* value in the scope columns. if ($this->node->isScoped()) { return $this->validateRootsByScope($roots); } return $this->isEachRootValid($roots); }
protected function init() { foreach ($this->getClassParents(get_class($this)) as $class) { $method = 'init' . basename(str_replace('\\', '/', $class)); if (method_exists($class, $method)) { forward_static_call([$this, $method]); } } static::$column_cache[get_class($this)] = array_fill_keys(array_merge(static::$fields, array_keys(static::$relations)), true); }
public function getPreparers(Entity $entity) { $preparers = array(); foreach (self::$registry as $class_name) { if (forward_static_call(array($class_name, 'handlesEntity'), $entity) === true) { $preparers[] = $class_name; } } return $preparers; }
/** * Get the classes that should be combined and compiled. * * @return array */ protected function getClassFiles() { $app = $this->laravel; $core = (require __DIR__ . '/Optimize/config.php'); $files = array_merge($core, $this->laravel['config']->get('compile.files', [])); foreach ($this->laravel['config']->get('compile.providers', []) as $provider) { $files = array_merge($files, forward_static_call([$provider, 'compiles'])); } return $files; }
/** * @param string $data * @return Node */ public function map($data, $class = null) { $node = $data; if (!$data instanceof Node) { $node = Node::ofData(json_decode($data)); } if (is_null($class)) { $class = '\\Commercetools\\Commons\\JsonObject'; } return forward_static_call([$class, 'ofNode'], $node); }