/**
  * Add product to authenticated user's favorites. (for Smart phone)
  *
  * @param type $objCustomer 
  * @return void
  */
 function doAddFavoriteSphone($objCustomer)
 {
     // ログイン中のユーザが商品をお気に入りにいれる処理(スマートフォン用)
     if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0) {
         $this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
         if (count($this->arrErr) == 0) {
             if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
                 $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
                 $objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
                 print 'true';
                 SC_Response_Ex::actionExit();
             }
         }
         print 'error';
         SC_Response_Ex::actionExit();
     }
 }
Пример #2
0
 /**
  *
  * @param type $phone
  * @return type
  */
 public static function sanitizePhone($phone)
 {
     $num = preg_replace("/[^0-9]/", "", $phone->getValue());
     return intval(substr($num, strlen($num) - 9, 9));
 }
Пример #3
0
 /**
  * Bulk PHP validation.
  *
  * @param type $field Field class instance
  * @param type $value
  * @return \WP_Error|boolean
  * @throws Exception
  */
 public function validateField($field)
 {
     $value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue());
     $rules = $this->_parseRules($field->getValidationData(), $value);
     // If not required but empty - skip
     if (!isset($rules['required']) && (is_null($value) || $value === false || $value === '')) {
         return true;
     }
     try {
         $errors = array();
         foreach ($rules as $rule => $args) {
             if (!$this->validate($rule, $args['args'])) {
                 $errors[] = $field->getTitle() . ' ' . $args['message'];
             }
         }
         if (!empty($errors)) {
             throw new Exception();
         }
     } catch (Exception $e) {
         return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors);
     }
     return true;
 }
 /**
  * Bulk PHP validation.
  * 
  * @param type $field Field class instance
  * @param type $value
  * @return \WP_Error|boolean
  * @throws Exception
  */
 public function validateField($field)
 {
     $rules = $field->getValidationData();
     $value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue());
     // If not required but empty - skip
     if (!isset($rules['required']) && (is_null($value) || $value === false || $value === '')) {
         return true;
     }
     try {
         $errors = array();
         foreach ($rules as $rule => $args) {
             $rule = apply_filters('wptoolset_validation_rule_php', $rule);
             $args['args'] = apply_filters('wptoolset_validation_args_php', $args['args'], $rule);
             // Set value in args - search string '$value' or replace first element
             $replace = array_search('$value', $args['args']);
             if ($replace !== false) {
                 $args['args'][$replace] = $value;
             } else {
                 $args['args'][0] = $value;
             }
             if (!$this->validate($rule, $args['args'])) {
                 $errors[] = $args['message'];
             }
         }
         if (!empty($errors)) {
             throw new Exception();
         }
     } catch (Exception $e) {
         return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors);
     }
     return true;
 }
Пример #5
0
 /**
  * add the simpleAssociableChoiceTag.
  *
  *
  * @param type $label
  * @param type $numberLabel
  * @param type $elementLabel
  */
 protected function simpleMatchSetTagLabel($label, $numberLabel, $elementLabel)
 {
     if ($this->cardinality == 'multiple') {
         $w = 0;
         foreach ($this->interactionmatching->getProposals() as $pr) {
             ++$w;
         }
         $maxAssociation = $w;
     } else {
         $maxAssociation = 1;
     }
     if ($label->getPositionForce() == 1) {
         $positionForced = 'true';
     } else {
         $positionForced = 'false';
     }
     $simpleLabel = $this->document->CreateElement('simpleAssociableChoice');
     $simpleLabel->setAttribute('identifier', 'right' . $numberLabel);
     $simpleLabel->setAttribute('fixed', $positionForced);
     $simpleLabel->setAttribute('matchMax', $maxAssociation);
     $this->matchInteraction->appendChild($simpleLabel);
     $this->getDomEl($simpleLabel, $label->getValue());
     $elementLabel->appendChild($simpleLabel);
     if ($label->getFeedback() != null && $label->getFeedback() != '') {
         $feedbackInline = $this->document->CreateElement('feedbackInline');
         $feedbackInline->setAttribute('outcomeIdentifier', 'FEEDBACK');
         $feedbackInline->setAttribute('identifier', 'Choice' . $numberLabel);
         $feedbackInline->setAttribute('showHide', 'show');
         $this->getDomEl($feedbackInline, $label->getFeedback());
         $simpleLabel->appendChild($feedbackInline);
     }
 }
Пример #6
0
 /**
  * Bulk PHP validation.
  *
  * @param type $field Field class instance
  * @param type $value
  * @return \WP_Error|boolean
  * @throws Exception
  */
 public function validateField($field)
 {
     $value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue());
     $rules = $this->_parseRules($field->getValidationData(), $value);
     // If not required but empty - skip
     if (!isset($rules['required']) && (is_null($value) || $value === false || $value === '')) {
         return true;
     }
     try {
         $errors = array();
         foreach ($rules as $rule => $args) {
             if (!$this->validate($rule, $args['args'])) {
                 /**
                  * Allow turn off field name.
                  *
                  * Allow turn off field name from error message.
                  *
                  * @since x.x.x
                  *
                  * @param boolean $var show field title in message, * default true.
                  */
                 if (apply_filters('toolset_common_validation_add_field_name_to_error', true)) {
                     $errors[] = $field->getTitle() . ' ' . $args['message'];
                 } else {
                     $errors[] = $args['message'];
                 }
             }
         }
         if (!empty($errors)) {
             throw new Exception();
         }
     } catch (Exception $e) {
         return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors);
     }
     return true;
 }
Пример #7
0
 /**
  * add the simpleAssociableChoiceTag
  *
  * @access protected
  *
  * @param type $label
  * @param type $numberLabel
  * @param type $elementLabel
  */
 protected function simpleMatchSetTagLabel($label, $numberLabel, $elementLabel)
 {
     if ($this->cardinality == "multiple") {
         $w = 0;
         foreach ($this->interactionmatching->getProposals() as $pr) {
             $w++;
         }
         $maxAssociation = $w;
     } else {
         $maxAssociation = 1;
     }
     if ($label->getPositionForce() == 1) {
         $positionForced = 'true';
     } else {
         $positionForced = 'false';
     }
     $simpleLabel = $this->document->CreateElement('simpleAssociableChoice');
     $simpleLabel->setAttribute("identifier", "right" . $numberLabel);
     $simpleLabel->setAttribute("fixed", $positionForced);
     $simpleLabel->setAttribute("matchMax", $maxAssociation);
     $this->matchInteraction->appendChild($simpleLabel);
     $simpleLabeltxt = $this->document->CreateTextNode($label->getValue());
     $simpleLabel->appendChild($simpleLabeltxt);
     $elementLabel->appendChild($simpleLabel);
     if ($label->getFeedback() != Null && $label->getFeedback() != "") {
         $feedbackInline = $this->document->CreateElement('feedbackInline');
         $feedbackInline->setAttribute("outcomeIdentifier", "FEEDBACK");
         $feedbackInline->setAttribute("identifier", "Choice" . $numberLabel);
         $feedbackInline->setAttribute("showHide", "show");
         $feedbackInlinetxt = $this->document->CreateTextNode($label->getFeedback());
         $feedbackInline->appendChild($feedbackInlinetxt);
         $simpleLabel->appendChild($feedbackInline);
     }
 }