Example #1
0
 /**
  * Insert applications defined controllers to local var
  */
 public function before()
 {
     foreach ($this->_apps as $app) {
         $this->_definedControllers[] = (string) $app->sys_name;
     }
     parent::before();
 }
Example #2
0
 /**
  * ContentRatingChange constructor. Pass inside record, type and user object
  * @param Content $record
  * @param string $type
  * @param iUser $user
  */
 public function __construct($record, $type, $user)
 {
     $this->_content = $record;
     $this->_type = $type;
     $this->_user = $user;
     parent::__construct();
 }
Example #3
0
 /**
  * Finish current form.
  * @param bool $validate
  * @return string
  */
 public function finish($validate = true)
 {
     // pre-validate form fields based on model rules and jquery.validation
     if ($validate) {
         App::$Alias->addPlainCode('js', '$().ready(function() { $("#' . $this->name . '").validate(); });');
         App::$Alias->setCustomLibrary('js', '/vendor/bower/jquery-validation/dist/jquery.validate.min.js');
         if (App::$Request->getLanguage() !== 'en') {
             $localeFile = '/vendor/bower/jquery-validation/src/localization/messages_' . App::$Request->getLanguage() . '.js';
             if (File::exist($localeFile)) {
                 App::$Alias->setCustomLibrary('js', $localeFile);
             }
         }
         // if model is not empty - add js error color notification
         if ($this->model !== null) {
             $badAttr = $this->model->getBadAttribute();
             $formName = $this->model->getFormName();
             if (Obj::isArray($badAttr) && count($badAttr) > 0) {
                 foreach ($badAttr as $attr) {
                     $itemId = $formName . '-' . $attr;
                     $render = App::$View->render(static::$structLayer['jsnotify'], ['itemId' => $itemId]);
                     App::$Alias->addPlainCode('js', $render);
                 }
             }
         }
     }
     return '</form>';
 }
Example #4
0
 /**
  * EntityDeleteRoute constructor. Pass parameters from controller
  * @param string|null $type
  * @param string|null $loader
  * @param string|null $source
  */
 public function __construct($type = null, $loader = null, $source = null)
 {
     $this->type = $type;
     $this->loader = $loader;
     $this->source = $source;
     $this->_cfg = App::$Properties->getAll('Routing');
     parent::__construct(true);
 }
Example #5
0
 /**
  * EntityCategoryList constructor. Pass pathway as string and data of multi-category system
  * @param string $path
  * @param array $configs
  * @param int $offset
  * @param string $sort
  */
 public function __construct($path, array $configs, $offset = 0, $sort = 'newest')
 {
     $this->_path = $path;
     $this->_configs = $configs;
     $this->_page = (int) $offset;
     $this->_sort = $sort;
     parent::__construct();
 }
Example #6
0
 /**
  * SearchContainer constructor. Pass string query inside
  * @param string $query
  * @param int $limit
  */
 public function __construct($query, $limit = 10)
 {
     $this->query = $query;
     $this->limit = (int) $limit;
     if ($this->limit < 1) {
         $this->limit = 1;
     }
     parent::__construct();
 }
Example #7
0
 /**
  * Prepare conditions to build content list
  * @throws NotFoundException
  */
 public function before()
 {
     // check length of passed terms
     if (!Obj::isString($this->_terms) || Str::length($this->_terms) < self::MIN_QUERY_LENGTH) {
         throw new NotFoundException(__('Search terms is too short'));
     }
     // lets make active record building
     $this->_records = ContentEntity::whereNotIn('id', $this->_skip)->search($this->_terms)->take(self::MAX_ITEMS)->get();
     $this->buildContent();
     parent::before();
 }
Example #8
0
 /**
  * EntityBuildMap constructor. Pass available languages and data as array inside.
  * @param array|null $langs
  * @param array|null $data
  */
 public function __construct(array $langs = null, array $data = null)
 {
     $this->langs = $langs;
     if ($data !== null && count($data) > 0) {
         foreach ($data as $item) {
             if (!Obj::isArray($item) || !isset($item['uri'], $item['lastmod'])) {
                 continue;
             }
             $this->add($item['uri'], $item['lastmod'], $item['freq'], $item['priority']);
         }
     }
     parent::__construct();
 }
Example #9
0
 /**
  * EntityCommentPostData constructor. Pass inside the model active record object of comment post or answer
  * @param $record
  * @throws JsonException
  */
 public function __construct($record, $calcAnswers = true)
 {
     $this->_record = $record;
     $this->_calcAnswers = (bool) $calcAnswers;
     if ($this->_record instanceof CommentPost) {
         $this->_type = 'post';
     } elseif ($this->_record instanceof CommentAnswer) {
         $this->_type = 'answer';
     } else {
         throw new JsonException('Unknown comment request');
     }
     parent::__construct();
 }
Example #10
0
 /**
  * Set validator options to current properties
  * @param string $name
  * @param array $properties
  */
 private function validatorProperties($name, &$properties)
 {
     // jquery validation quick-build some rules
     $rules = $this->model->getValidationRule($name);
     if (count($rules) > 0) {
         foreach ($rules as $rule_name => $rule_value) {
             switch ($rule_name) {
                 case 'required':
                     $properties['required'] = null;
                     break;
                 case 'length_min':
                     $properties['minlength'] = $rule_value;
                     break;
                 case 'length_max':
                     $properties['maxlength'] = $rule_value;
                     break;
             }
         }
     }
 }
Example #11
0
 /**
  * FormUpdateDatabase constructor. Pass db and script version inside
  * @param string $db
  * @param string $script
  */
 public function __construct($db, $script)
 {
     $this->dbVersion = $db;
     $this->scriptVersion = $script;
     parent::__construct(true);
 }
Example #12
0
 /**
  * EntitySearchMain constructor. Pass query inside
  * @param string $query
  * @param array|null $configs
  */
 public function __construct($query, array $configs = null)
 {
     $this->query = $query;
     $this->_configs = $configs;
     parent::__construct();
 }
Example #13
0
 /**
  * FormContentUpdate constructor. Pass content active record inside
  * @param Content $content
  */
 public function __construct(Content $content)
 {
     $this->_content = $content;
     parent::__construct();
 }
Example #14
0
 /**
  * FormContentRestore constructor. Pass active record object inside
  * @param Content $record
  */
 public function __construct(Content $record)
 {
     $this->_record = $record;
     parent::__construct();
 }
Example #15
0
 /**
  * EntityContentRead constructor. Pass active record objects
  * @param ContentCategory $category
  * @param Content $content
  */
 public function __construct(ContentCategory $category, Content $content)
 {
     $this->_category = $category;
     $this->_content = $content;
     parent::__construct();
 }
Example #16
0
 /**
  * FormIgnoreDelete constructor. Pass current user object and target user id inside
  * @param iUser $user
  * @param int $target_id
  */
 public function __construct(iUser $user, $target_id)
 {
     $this->_user = $user;
     $this->_target_id = $target_id;
     parent::__construct(true);
 }
Example #17
0
 /**
  * FormUserDelete constructor. Pass user ids inside
  * @param array $ids
  */
 public function __construct(array $ids)
 {
     $this->_ids = $ids;
     parent::__construct(true);
 }
Example #18
0
 /**
  * FormCommentDelete constructor. Pass active record and type of comment system inside.
  * @param object $record
  * @param string $type
  */
 public function __construct($record, $type)
 {
     $this->_record = $record;
     $this->_type = $type;
     parent::__construct();
 }
Example #19
0
 /**
  * FormContentGlobDelete constructor. Pass records inside.
  * @param Content[]|Collection $records
  */
 public function __construct($records)
 {
     $this->_records = $records;
     parent::__construct();
 }
Example #20
0
 /**
  * FormCategoryUpdate constructor. Pass record object inside model
  * @param ContentCategory $record
  * @param int|null $dependId
  */
 public function __construct(ContentCategory $record, $dependId = null)
 {
     $this->_record = $record;
     $this->_tmpDependId = $dependId;
     parent::__construct();
 }
Example #21
0
 /**
  * FormUpdateDownload constructor. Pass download url & tag name inside
  * @param bool $url
  * @param $name
  */
 public function __construct($url, $name)
 {
     $this->url = $url;
     $this->name = $name;
     parent::__construct();
 }
Example #22
0
 /**
  * EntityIndexList constructor. Pass current language from controller request
  * @param string|null $currentLang
  */
 public function __construct($currentLang = null)
 {
     $this->_lang = $currentLang;
     parent::__construct();
 }
Example #23
0
 /**
  * EntityAddNotification constructor. Pass target user_id inside the model
  * @param bool $targetId
  */
 public function __construct($targetId)
 {
     $this->_targetId = $targetId;
     parent::__construct();
 }
Example #24
0
 /**
  * FormFeedbackAdd constructor. Pass captcha marker enabled inside
  * @param bool $captcha
  */
 public function __construct($captcha = true)
 {
     $this->_useCaptcha = (bool) $captcha;
     parent::__construct();
 }
Example #25
0
 /**
  * FormRegister constructor. Build model and set maker if captcha is enabled
  * @param bool $captcha
  */
 public function __construct($captcha = false)
 {
     $this->_captcha = $captcha;
     parent::__construct(true);
 }
Example #26
0
 /**
  * Construct FormLogin. Pass is captcha used inside
  * @param bool $captcha
  */
 public function __construct($captcha = false)
 {
     $this->_captcha = $captcha;
     // tell that we shall use csrf protection
     parent::__construct(true);
 }
Example #27
0
 /**
  * Constructor with user object relation
  * @param iUser $user
  */
 public function __construct(iUser $user)
 {
     $this->_user = $user;
     parent::__construct(true);
 }
Example #28
0
 /**
  * FormAnswerAdd constructor. Pass active record of comment post and user id
  * @param $recordPost
  * @param int $userId
  */
 public function __construct($recordPost, $userId = 0)
 {
     $this->_post = $recordPost;
     $this->_userId = (int) $userId;
     parent::__construct();
 }
Example #29
0
 /**
  * FormSettings constructor. Pass configuration inside as factory.
  * @param array $configs
  */
 public function __construct(array $configs = null)
 {
     $this->_configs = $configs;
     parent::__construct();
 }
Example #30
0
 /**
  * FormFieldUpdate constructor. Pass profile field record inside
  * @param ProfileField $record
  */
 public function __construct(ProfileField $record)
 {
     $this->_record = $record;
     parent::__construct();
 }