Esempio n. 1
0
 /**
  * Instantiate a Merchant_Billing_CreditCard object
  *
  * @param  KConfig $data
  * @return Merchant_Billing_CreditCard
  */
 protected function _instantiateCreditCard($data)
 {
     if ($data->token) {
         unset($data['creditcard']);
         unset($data['contact']);
         return;
     }
     $data->append(array('creditcard' => new KConfig()));
     $creditcard = $data->creditcard;
     $name = trim($creditcard->name);
     $space = KHelperString::strpos($name, ' ');
     $creditcard_data = array('type' => $creditcard->type, "first_name" => KHelperString::ucwords(KHelperString::substr($name, 0, $space)), "last_name" => KHelperString::ucwords(KHelperString::substr($name, $space + 1)), "number" => $creditcard->number, "month" => $creditcard->month, "year" => $creditcard->year, "verification_value" => $creditcard->csv);
     $creditcard = new Merchant_Billing_CreditCard($creditcard_data);
     $this->creditcard = $creditcard;
     $contact = $this->_instantiateContact($data);
     $this->order->setPaymentMethod(new ComSubscriptionsDomainPaymentMethodCreditcard($creditcard, $contact));
     return $creditcard;
 }
Esempio n. 2
0
 /**
  * returns substring of characters around a searchword.
  *
  * @param string The source string
  * @param int Number of chars to return
  * @param string The searchword to select around
  *
  * @return string
  */
 public function substring($text, $searchword, $length = 200)
 {
     $textlen = KHelperString::strlen($text);
     $lsearchword = KHelperString::strtolower($searchword);
     $wordfound = false;
     $pos = 0;
     while ($wordfound === false && $pos < $textlen) {
         if (($wordpos = @KHelperString::strpos($text, ' ', $pos + $length)) !== false) {
             $chunk_size = $wordpos - $pos;
         } else {
             $chunk_size = $length;
         }
         $chunk = KHelperString::substr($text, $pos, $chunk_size);
         $wordfound = KHelperString::strpos(KHelperString::strtolower($chunk), $lsearchword);
         if ($wordfound === false) {
             $pos += $chunk_size + 1;
         }
     }
     //while
     if ($wordfound !== false) {
         return ($pos > 0 ? '...&nbsp;' : '') . $chunk . '&nbsp;...';
     } else {
         if (($wordpos = @KHelperString::strpos($text, ' ', $length)) !== false) {
             return KHelperString::substr($text, 0, $wordpos) . '&nbsp;...';
         } else {
             return KHelperString::substr($text, 0, $length);
         }
     }
 }