コード例 #1
0
 /**
  * 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);
 }
コード例 #2
0
ファイル: CronManager.php プロジェクト: phpffcms/ffcms-core
 /**
  * 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;
 }
コード例 #3
0
ファイル: Numeric.php プロジェクト: tashik/phalcon_core
 /**
  * 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);
 }
コード例 #4
0
ファイル: MetaProperty.php プロジェクト: crapougnax/t41
 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;
         }
     }
 }
コード例 #5
0
ファイル: Mail.php プロジェクト: tashik/phalcon_core
 /**
  * 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);
 }
コード例 #6
0
ファイル: Image.php プロジェクト: tashik/phalcon_core
 /**
  * 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);
 }
コード例 #7
0
ファイル: Model.php プロジェクト: privatebin/privatebin
 /**
  * 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;
 }
コード例 #8
0
ファイル: Password.php プロジェクト: tashik/phalcon_core
 /**
  * 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);
 }
コード例 #9
0
ファイル: Variable.php プロジェクト: roboapp/variable
 /**
  * @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;
 }
コード例 #10
0
ファイル: model.php プロジェクト: kolobus/ZeroBin
 /**
  * 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;
 }
コード例 #11
0
 /**
  * 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);
 }
コード例 #12
0
ファイル: Numeric.php プロジェクト: tashik/phalcon_core
 /**
  * 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);
 }
コード例 #13
0
ファイル: Combobox.php プロジェクト: tashik/phalcon_core
 /**
  * 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);
 }
コード例 #14
0
 /**
  * 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);
 }
コード例 #15
0
ファイル: JobQueueHandler.php プロジェクト: unifact/connector
 /**
  * @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;
 }
コード例 #16
0
ファイル: OCR.php プロジェクト: ImangazalievForks/ocr-wrapper
 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;
 }
コード例 #17
0
ファイル: PageSearch.php プロジェクト: pavlinter/yii2-adm-app
 /**
  * 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;
 }
コード例 #18
0
ファイル: Bootable.php プロジェクト: laradic/support
 /**
  * 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]);
         }
     }
 }
コード例 #19
0
ファイル: GridView.php プロジェクト: pavlinter/yii2-adm
 /**
  * @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);
 }
コード例 #20
0
ファイル: Serial.php プロジェクト: Masterfion/plugin-sonos
 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);
 }
コード例 #21
0
ファイル: GridView.php プロジェクト: richardcj/yii2-adm
 /**
  * @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);
 }
コード例 #22
0
ファイル: table.php プロジェクト: dlasserre/uranium
 /**
  * @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);
 }
コード例 #23
0
 /**
  * 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;
 }
コード例 #24
0
ファイル: application.php プロジェクト: eepletnev/way-cup-erp
 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.');
     }
 }
コード例 #25
0
 /**
  * @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);
 }
コード例 #26
0
ファイル: SetValidator.php プロジェクト: neilcrookes/baum
 /**
  * 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);
 }
コード例 #27
0
 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);
 }
コード例 #28
0
 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;
 }
コード例 #29
0
 /**
  * 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;
 }
コード例 #30
0
ファイル: JsonMapper.php プロジェクト: jayS-de/JsonMapper
 /**
  * @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);
 }