Ejemplo n.º 1
0
 /**
  * @param Phalcon\Mvc\ModelInstance $entity
  * @param array $options
  */
 public function initialize($entity = null, $options = null)
 {
     if (!isset($options['edit']) && !isset($options['create'])) {
         $id = new Text('id');
         $id->setLabel('Id');
         $this->add($id);
     }
     $category = new Select('categoriesId', Categories::find(), array('using' => array('id', 'name'), 'useEmpty' => true, 'emptyText' => '...'));
     $category->setLabel('Category');
     $category->addValidator(new PresenceOf(array('message' => 'Category is mandatory')));
     $category->setUserOption('searcheable', true);
     $category->setUserOption('browseable', true);
     $category->setUserOption('relation', 'category');
     $this->add($category);
     $icon = new Text('icon', array('placeholder' => 'Enter a css-icon class name'));
     $icon->setLabel('Icon');
     $icon->addValidator(new PresenceOf(array('message' => 'Icon is mandatory')));
     $this->add($icon);
     $code = new Text('code', array('maxlength' => 10));
     $code->setLabel('Code');
     $code->setUserOption('searcheable', true);
     $code->setUserOption('browseable', true);
     $code->addValidator(new PresenceOf(array('message' => 'Code is mandatory')));
     $this->add($code);
     $name = new Text('name', array('maxlength' => 64));
     $name->setLabel('Name');
     $name->setUserOption('searcheable', true);
     $name->setUserOption('browseable', true);
     $name->addValidator(new PresenceOf(array('message' => 'Name is mandatory')));
     $this->add($name);
     $description = new TextArea('description');
     $description->setLabel('Description');
     $description->addValidator(new PresenceOf(array('message' => 'Description is mandatory')));
     $this->add($description);
     $price = new Text('price');
     $price->setLabel('Price');
     $price->setUserOption('searcheable', true);
     $price->setUserOption('browseable', true);
     $price->addValidator(new PresenceOf(array('message' => 'Price is mandatory')));
     $price->addValidator(new Numericality(array('message' => 'Price must be a number')));
     $this->add($price);
     $stock = new Text('stock');
     $stock->setLabel('Stock');
     $stock->setUserOption('browseable', true);
     $stock->addValidator(new PresenceOf(array('message' => 'Current stock is mandatory')));
     $stock->addValidator(new Numericality(array('message' => 'Current stock must be a number')));
     $this->add($stock);
     if (isset($options['edit'])) {
         $createdAt = new Date('created', array('readonly' => 'readonly'));
         $createdAt->setLabel('Created At');
         if ($entity->createdAt) {
             $entity->created = date('Y-m-d', $entity->createdAt);
         }
         $this->add($createdAt);
     }
 }
Ejemplo n.º 2
0
 /**
  * Init form
  *
  * @param string $data
  */
 public function initialize($data = null)
 {
     $description = new TextArea('description', ['rows' => 5, 'required' => 'required']);
     $this->add($description);
     $bugTrackingType = new Select('bug_tracking_type_id', BugTrackingType::find(['order' => 'ordering']), ['using' => ['id', 'name'], 'useEmpty' => true, 'required' => 'required']);
     $bugTrackingType->addValidator(new PresenceOf(['message' => 'Type is required']));
     $this->add($bugTrackingType);
     $bugTrackingPriority = new Select('bug_tracking_priority_id', BugTrackingPriority::find(['order' => 'ordering']), ['using' => ['id', 'name'], 'useEmpty' => true, 'required' => 'required']);
     $bugTrackingPriority->addValidator(new PresenceOf(['message' => 'Priority is required']));
     $this->add($bugTrackingPriority);
     $notify = new Select('role_id', UserRoles::find(['conditions' => 'location = 1']), ['using' => ['id', 'name'], 'useEmpty' => true, 'required' => 'required']);
     $notify->addValidator(new PresenceOf(['message' => 'Notify is required']));
     $this->add($notify);
 }
Ejemplo n.º 3
0
 /**
  * @param CoreConfigs $data
  */
 public function initialize($data = null)
 {
     $allConfig = CoreConfigs::find()->toArray();
     $isCryptOfAllKey = [];
     foreach ($allConfig as $conf) {
         $isCryptOfAllKey[$conf['key']] = $conf['is_crypt_value'];
     }
     if ($data != null) {
         $allKeyData = get_object_vars($data);
         foreach ($allKeyData as $key => $value) {
             if ($isCryptOfAllKey[$key] == 1) {
                 $data->{$key} = '';
             }
         }
     }
     //Section Website
     $debug = new Select('debug', [0 => __('gb_off'), 1 => __('gb_on')]);
     $debug->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($debug);
     $baseUri = new Text('baseUri');
     $this->add($baseUri);
     $metaDesc = new TextArea("metadesc", ['rows' => 4]);
     $this->add($metaDesc);
     $metaKey = new TextArea("metakey");
     $this->add($metaKey);
     $siteName = new Text("sitename");
     $this->add($siteName);
     $direction = new Select('direction', ['ltr' => 'Left to right', 'rtl' => 'Right to Left']);
     $this->add($direction);
     $timezone = new Select('timezone', array_combine(timezone_identifiers_list(), timezone_identifiers_list()));
     $this->add($timezone);
     //$CoreLanguages = CoreLanguages::find(['columns' => 'language_code, title', 'order' => 'language_code']);
     $CoreLanguages = CoreLanguages::find(['order' => 'language_code']);
     $language = new Select('language', $CoreLanguages, ['using' => ['language_code', 'title']]);
     $this->add($language);
     $limit = new Text('limit');
     $limit->addValidator(new Between(['minimum' => 0, 'maximum' => 100, 'message' => 'm_system_module_message_the_limit_must_be_between_1_100']));
     $this->add($limit);
     $media_limit = new Text('media_limit');
     $media_limit->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_config_message_this_field_must_be_a_number']));
     $media_limit->addValidator(new Between(['minimum' => 0, 'maximum' => 100, 'message' => 'm_system_module_message_the_media_limit_must_be_between_1_100']));
     $this->add($media_limit);
     $feed_limit = new Text('feed_limit');
     $feed_limit->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_config_message_this_field_must_be_a_number']));
     $feed_limit->addValidator(new Between(['minimum' => 0, 'maximum' => 100, 'message' => 'm_system_module_message_the_media_limit_must_be_between_1_100']));
     $this->add($feed_limit);
     //Section memcache
     $mem_cache_status = new Select('mem_cache_status', [0 => __('gb_off'), 1 => __('gb_on')]);
     $mem_cache_status->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($mem_cache_status);
     $mem_cache_host = new Text('mem_cache_host');
     $this->add($mem_cache_host);
     $mem_cache_lifetime = new Text('mem_cache_lifetime');
     $this->add($mem_cache_lifetime);
     $mem_cache_prefix = new Text('mem_cache_prefix');
     $this->add($mem_cache_prefix);
     $mem_cache_port = new Text('mem_cache_port');
     $mem_cache_port->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_memcache_port_must_be_a_number']));
     $this->add($mem_cache_port);
     //Section apc cache
     $apc_prefix = new Text('apc_prefix');
     $this->add($apc_prefix);
     $apc_lifetime = new Text('apc_lifetime');
     $this->add($apc_lifetime);
     $apc_status = new Select('apc_status', [0 => __('gb_off'), 1 => __('gb_on')]);
     $apc_status->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($apc_status);
     //Section Mail
     /**
      * <code>
      * <select id="mail_type" name="mail_type" class="form-control">
      *    <option value="mail">Mail</option>
      *    <option selected="selected" value="smtp">SMTP</option>
      *    <option value="sendmail">SendMail</option>
      * </select>
      * </code>
      */
     $mail_type = new Select('mail_type', ['mail' => __('m_system_config_label_mail_type_value_mail'), 'smtp' => __('m_system_config_label_mail_type_value_smtp'), 'sendmail' => __('m_system_config_label_mail_type_value_sendmail')]);
     $mail_type->addValidator(new InclusionIn(['domain' => ['mail', 'smtp', 'sendmail']]));
     $this->add($mail_type);
     $mail_from = new Text('mail_from');
     $this->add($mail_from);
     $from_name = new Text('from_name');
     $this->add($from_name);
     $send_mail = new Text('send_mail');
     $this->add($send_mail);
     $smtp_user = new Text('smtp_user');
     $this->add($smtp_user);
     $smtp_pass = new Password('smtp_pass');
     $this->add($smtp_pass);
     $smtp_host = new Text('smtp_host');
     $this->add($smtp_host);
     $smtp_secure = new Select('smtp_secure', ['ssl' => 'SSL', 'tsl' => 'TSL']);
     $smtp_secure->addValidator(new InclusionIn(['domain' => ['ssl', 'tsl']]));
     $this->add($smtp_secure);
     $smtp_port = new Text('smtp_port');
     $smtp_port->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_smtp_port_must_be_a_number']));
     $this->add($smtp_port);
     $smtp_auth = new Text('smtp_auth');
     $smtp_auth->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_smtp_auth_must_be_a_number']));
     $this->add($smtp_auth);
     //Section log
     $log = new Select('log', ['0' => __('gb_off'), '1' => __('gb_on')]);
     $log->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($log);
     $log_type = new Select('log_type', ['file' => __('m_system_config_label_database_file'), 'database' => __('m_system_config_label_database')]);
     $log_type->addValidator(new InclusionIn(['domain' => ['file', 'database']]));
     $this->add($log_type);
     $auth_lifetime = new Text('auth_lifetime');
     $auth_lifetime->addValidator(new Regex(['pattern' => '/[0-9]+(\\.[0-9]+)?/', 'message' => 'm_system_module_message_the_auth_lifetime_must_be_a_number']));
     $this->add($auth_lifetime);
     //Section Template
     //Add translation template
     ZTranslate::getInstance()->addTemplateLang(get_child_folder(APP_DIR . '/templates/backend'));
     ZTranslate::getInstance()->addTemplateLang(get_child_folder(APP_DIR . '/templates/frontend'), 'frontend');
     //Backend default template
     $backendTemplateArray = CoreTemplates::find("location = 'backend'")->toArray();
     $backendTemplateBaseName = array_column($backendTemplateArray, 'base_name');
     $backendTemplate = array_combine($backendTemplateBaseName, array_map('__', array_column($backendTemplateArray, 'name')));
     $defaultTemplate = new Select('defaultTemplate', $backendTemplate);
     $defaultTemplate->addValidator(new InclusionIn(['domain' => $backendTemplateBaseName]));
     $this->add($defaultTemplate);
     //Backend compile template
     $compileTemplate = new Select('compileTemplate', ['0' => __('gb_off'), '1' => __('gb_on')]);
     $compileTemplate->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($compileTemplate);
     //Frontend default template
     $frontendTemplateArray = CoreTemplates::find("location = 'frontend'")->toArray();
     $frontendTemplateBaseName = array_column($frontendTemplateArray, 'base_name');
     $frontendTemplate = array_combine($frontendTemplateBaseName, array_map('__', array_column($frontendTemplateArray, 'name')));
     $defaultTemplate = new Select('defaultTemplate', $frontendTemplate);
     $defaultTemplate->addValidator(new InclusionIn(['domain' => $frontendTemplateBaseName]));
     $this->add($defaultTemplate);
     //Frontend compile template
     $compileTemplate = new Select('compileTemplate', ['0' => __('gb_off'), '1' => __('gb_on')]);
     $compileTemplate->addValidator(new InclusionIn(['domain' => ['0', '1']]));
     $this->add($compileTemplate);
     //Shipping
     $shipping = new Text('sender_id');
     $this->add($shipping);
     $shipping = new Text('sender_name');
     $this->add($shipping);
     $shipping = new Text('sender_contact_name');
     $this->add($shipping);
     $shipping = new Text('sender_contact_phone');
     $this->add($shipping);
     $shipping = new Text('sender_address_1');
     $this->add($shipping);
     $shipping = new Text('sender_address_2');
     $this->add($shipping);
     $shipping = new Text('sender_town');
     $this->add($shipping);
     $shipping = new Text('sender_state');
     $this->add($shipping);
     $shipping = new Text('sender_post_code');
     $this->add($shipping);
     $shipping = new Text('sender_country');
     $this->add($shipping);
     $shipping = new Text('toll_slid');
     $this->add($shipping);
     $shipping = new Text('toll_service_name');
     $this->add($shipping);
     $shipping = new Text('toll_service_code');
     $this->add($shipping);
     $shipping = new Text('toll_email_transmission');
     $this->add($shipping);
     $shipping = new Text('toll_system_transmission_id');
     $this->add($shipping);
     $shipping = new Text('line_weight');
     $this->add($shipping);
     $shipping = new Text('charge_account');
     $this->add($shipping);
     //Payment get way
     $merchant_number = new Text('merchant_number');
     $this->add($merchant_number);
     $merchant_number = new Text('merchant_username');
     $this->add($merchant_number);
     $merchant_number = new Password('merchant_password');
     $this->add($merchant_number);
     $merchant_number = new Text('merchant_referrence');
     $this->add($merchant_number);
     $merchant_number = new Text('link_authorize');
     $this->add($merchant_number);
     $merchant_number = new Text('link_pay_request');
     $this->add($merchant_number);
     $merchant_number = new Text('link_verify');
     $this->add($merchant_number);
     $merchant_number = new Text('link_pay_shop');
     $this->add($merchant_number);
     $payment_return_url = new Text('return_url');
     $this->add($payment_return_url);
 }
Ejemplo n.º 4
0
 /**
  * Build SEOForm
  *
  * @param mixed $data
  * @return $this
  */
 protected function buildSEOForm($data = null)
 {
     if ($data != null) {
         $metadataArray = json_decode($data->metadata, true);
         $robots = explode(',', $metadataArray['robots']);
         $data->zcms_seo_title = $metadataArray['title'];
         $data->redirect_301 = $metadataArray['redirect_301'];
         $data->zcms_meta_robot_index = isset($robots[0]) ? $robots[0] : null;
         $data->zcms_meta_robot_follow = isset($robots[1]) ? $robots[1] : null;
     }
     //Title
     $seo_title = new Text('zcms_seo_title');
     $seo_title->addValidator(new StringLength(['min' => 0, 'max' => 255]));
     $this->add($seo_title);
     //Meta description
     $meta_desc = new TextArea('metadesc', ['rows' => 4]);
     $meta_desc->addValidator(new StringLength(['min' => 0, 'max' => 255]));
     $this->add($meta_desc);
     //Meta keywords
     $meta_key = new TextArea('metakey', ['rows' => 4]);
     $meta_key->addValidator(new StringLength(['min' => 0, 'max' => 255]));
     $this->add($meta_key);
     //Meta Robots Index:
     $meta_robot_index = new Select('zcms_meta_robot_index', ['index' => 'Index', 'noindex' => 'NoIndex']);
     $meta_robot_index->addValidator(new InclusionIn(['domain' => ['index', 'noindex']]));
     $this->add($meta_robot_index);
     //Meta Robots Follow
     $meta_robot_follow = new Select('zcms_meta_robot_follow', ['follow' => 'Follow', 'nofollow' => 'NoFollow']);
     $meta_robot_follow->addValidator(new InclusionIn(['domain' => ['follow', 'nofollow']]));
     $this->add($meta_robot_follow);
     //Meta robot advance
     $meta_robot_advance = new Select('zcms_meta_robot_advance', ['none' => 'None', 'noodp' => 'NO ODP', 'noydir' => 'NO YDIR', 'noimageindex' => 'No Image Index', 'noarchive' => 'No Archive', 'nosnippet' => 'No Snippet'], ['multiple' => 'multiple', 'name' => 'zcms_meta_robot_advance[]']);
     //       $meta_robot_advance->addValidator(new InclusionIn([
     //           'domain' => ['none', 'noodp', 'noydir', 'noimageindex', 'noarchive', 'nosnippet']
     //       ]));
     $this->add($meta_robot_advance);
     //Redirect 301
     $redirect301 = new Text('zcms_redirect_301');
     $this->add($redirect301);
     //Add metadata
     $metadata = new TextArea('metadata');
     $this->add($metadata);
     return $this;
 }
Ejemplo n.º 5
-1
 /**
  * Init user form
  *
  * @param \ZCMS\Core\Models\Users $data
  */
 public function initialize($data = null)
 {
     //Add first name
     $firstName = new Text('first_name', ['maxlength' => '32']);
     $firstName->addValidator(new PresenceOf());
     $this->add($firstName);
     //Add last name
     $lastName = new Text('last_name', ['maxlength' => '32']);
     $lastName->addValidator(new PresenceOf());
     $this->add($lastName);
     //Add email
     if ($data = null) {
         $email = new Email('email', ['maxlength' => '128', 'readonly' => 'readonly']);
     } else {
         $email = new Email('email', ['maxlength' => '128']);
     }
     $this->add($email);
     //Add active
     $is_active = new Select('is_active', ['1' => __('gb_yes'), '0' => __('gb_no')]);
     $this->add($is_active);
     //Add password confirmation
     $password_confirmation = new Password('password_confirmation', ['maxlength' => '32']);
     $password_confirmation->addValidator(new StringLength(['min' => 6]));
     $this->add($password_confirmation);
     //Add password
     $password = new Password('password', ['maxlength' => '32']);
     $password->addValidator(new StringLength(['min' => 6]));
     $password->addValidator(new Confirmation(['message' => 'm_system_user_message_password_does_not_match_confirmation', 'with' => 'password_confirmation']));
     $this->add($password);
     //Add role
     $dbRoles = UserRoles::find(['conditions' => 'is_super_admin = 0', 'order' => 'is_default DESC']);
     $role = new Select('role_id', $dbRoles, ['using' => ['role_id', 'name']]);
     $role->addValidator(new InclusionIn(['message' => 'm_system_user_message_please_choose_role', 'domain' => array_column($dbRoles->toArray(), 'role_id')]));
     $this->add($role);
 }