/**
 * Function to get image source
 *
 * This function get image source based on the parameter and return the result
 * 
 *
 * @param $params variable that contains the image that want to be generated the source
 * @param $template to associate source
 *
 * @return string the source of the image
 */
function smarty_function_sirclo_get_imgsrc($params, $template)
{
    $s = '';
    if (isset($params['str'])) {
        $s = Helper_String::getImgSrc($params['str']);
    }
    return $s;
}
Esempio n. 2
0
 static function getSegmentsFromUri($uri, $suff = NULL, $start = NULL)
 {
     $parsedUri = parse_url($uri);
     $path = '';
     if (isset($parsedUri['path'])) {
         $path = $parsedUri['path'];
         if ($suff) {
             $path = Helper_String::removeSuffix($parsedUri['path'], $suff);
         }
     }
     $segments = array_map(function ($x) {
         return rawurldecode($x);
     }, explode('/', $path));
     if ($start) {
         $segments = array_slice($segments, $start);
     }
     return $segments;
 }
Esempio n. 3
0
 static function getWishObjsOfMember($controller, $member, $key_pl)
 {
     $ids = Helper_String::commaStrToArr($member->getWishProductIdStr());
     $objs = $controller->_indicesToObjects($ids, $key_pl, 'getActiveItemById');
     return $objs;
 }
Esempio n. 4
0
 public function getQueryx($key = null, $default = null)
 {
     return Helper_String::deepFilterDatas($this->getQuery($key, $default), array('strip_tags', 'trim'));
 }
Esempio n. 5
0
 static function getFriendlyItemTitle($title)
 {
     $friendly = $title;
     /*
     preg_match('/(.*?) \((.*)\)/', $title, $matches);
     $name = $matches[1];
     $options = array();
     if (isset($matches[2])) {
         $options = explode(', ', $matches[2]);
     }
     */
     $options = array();
     $last = Helper_String::getLastParenth($title);
     $name = $last['lead'];
     if ($last['last']) {
         $options = explode(', ', $last['last']);
     }
     if (count($options) > 2) {
         $optionStr = implode(', <br />', $options);
         $friendly = "{$name}(<br />" . $optionStr . "<br />)";
     }
     return $friendly;
 }
Esempio n. 6
0
 static function sircloRenderPaymentNotifForm($params)
 {
     $_order_id = !empty($params['order_id']) ? $params['order_id'] : '';
     $_order_email = !empty($params['order_email']) ? $params['order_email'] : '';
     $_btn_class = !empty($params['btn_class']) ? $params['btn_class'] : 'btn-flat';
     $_lang = !empty($params['lang']) ? $params['lang'] : "en";
     $_label_order_id = $_lang == "id" ? "Order ID" : "Order ID";
     $_label_transaction_date = $_lang == "id" ? "Tanggal Transaksi" : "Transaction Date";
     $_label_transaction_ref = $_lang == "id" ? "Nama Pengirim" : "Sender Name";
     $_label_amount_transferred = $_lang == "id" ? "Jumlah Ditransfer" : "Amount Transferred";
     $_label_email = $_lang == "id" ? "E-mail" : "Email";
     $_label_confirm_payment = $_lang == "id" ? "Konfirmasi Pembayaran" : "Confirm Payment";
     $_label_bank_to = $_lang == "id" ? "Pembayaran ke Bank" : "Payment to";
     $_label_receipt_file = $_lang == "id" ? "Bukti Transfer (opsional)" : "Receipt File (optional)";
     if (!empty($params['bank_accounts'])) {
         $_bank_accounts = array_map(function ($acc) {
             return $acc['title'];
         }, $params['bank_accounts']);
     } else {
         if (!empty($params['configs']['theme_bank_accounts'])) {
             $_bank_accounts = Helper_String::commaStrToArr($params['configs']['theme_bank_accounts']);
         }
     }
     if (!empty($_bank_accounts)) {
         $_bank_accounts_options = array(array('title' => '-- Select Bank Account --', 'value' => ''));
         foreach ($_bank_accounts as $_ba) {
             $_bank_accounts_options[] = array('title' => trim($_ba), 'value' => trim($_ba));
         }
         $_bank_account_form = array('name' => 'bank_to', 'type' => 'dropdown', 'value' => '', 'label' => $_label_bank_to, 'attribute' => 'required', 'options' => $_bank_accounts_options);
         $params['fields'] = array(array('name' => 'order_id', 'type' => 'text', 'value' => $_order_id, 'label' => $_label_order_id, 'attribute' => 'required'), array('name' => 'transaction_date', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_date, 'attribute' => 'required'), array('name' => 'transaction_reference', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_ref, 'attribute' => 'required'), array('name' => 'amount_transfered', 'type' => 'text', 'value' => '', 'label' => $_label_amount_transferred, 'attribute' => 'required'), $_bank_account_form, array('name' => 'email', 'type' => 'email', 'value' => $_order_email, 'label' => $_label_email, 'attribute' => 'required'), array('name' => 'attachment', 'type' => 'file', 'label' => $_label_receipt_file), array('name' => '', 'type' => 'submit', 'value' => $_label_confirm_payment, 'label' => '', 'attribute' => 'class="' . $_btn_class . '"'));
     } else {
         $params['fields'] = array(array('name' => 'order_id', 'type' => 'text', 'value' => $_order_id, 'label' => $_label_order_id, 'attribute' => 'required'), array('name' => 'transaction_date', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_date, 'attribute' => 'required'), array('name' => 'transaction_reference', 'type' => 'text', 'value' => '', 'label' => $_label_transaction_ref, 'attribute' => 'required'), array('name' => 'amount_transfered', 'type' => 'text', 'value' => '', 'label' => $_label_amount_transferred, 'attribute' => 'required'), array('name' => 'email', 'type' => 'email', 'value' => $_order_email, 'label' => $_label_email, 'attribute' => 'required'), array('name' => 'attachment', 'type' => 'file', 'label' => $_label_receipt_file), array('name' => '', 'type' => 'submit', 'value' => $_label_confirm_payment, 'label' => '', 'attribute' => 'class="' . $_btn_class . '"'));
     }
     $_html = Helper_Renderer::renderForm($params);
     return $_html;
 }
Esempio n. 7
0
 static function getPointsEarned($controller, $cart)
 {
     $pointRule = $controller->getPointRule();
     if ($pointRule) {
         if (is_callable($pointRule)) {
             $points = $pointRule($controller, $cart);
             return $points;
         }
         $isEligible = TRUE;
         if ($isEligibleFunc = Helper_Structure::getArrayValue($pointRule, 'is_earn_eligible')) {
             $isEligible = $isEligibleFunc($controller, $cart);
         }
         if ($eligibleMemberTypes = Helper_Structure::getArrayValue($pointRule, 'eligible_member_types')) {
             $isEligible = self::isMemberEligible($controller, Helper_String::commaStrToArr($eligibleMemberTypes));
         }
         if ($isEligible) {
             $spent = Helper_Cart::getAmountSpent($cart);
             if (!empty($pointRule['with_exclude_sale_items'])) {
                 $saleItems = array_filter($cart['items'], function ($x) {
                     return !empty($x['is_sale']);
                 });
                 $saleTotal = self::getItemTotal($saleItems);
                 $spent = max($spent - $saleTotal, 0);
             }
             return self::getPointsEarnedByAmountSpent($controller, $spent);
         }
     }
     return 0;
 }
Esempio n. 8
0
 static function bannerToArr($controller, $obj)
 {
     $prefix = '_med';
     if ($controller->getKrcoConfigVersion() >= 1) {
         $prefix = '';
     }
     $image = Helper_File::addSuffix($obj->getImage(), $prefix);
     $youtubeId = Helper_String::extractYoutubeId($obj->getYoutubeLink());
     $arr = array('title' => $obj->getTitle($controller->lang), 'description' => self::markdownMark($obj->getDescription($controller->lang)), 'image' => $controller->composeResource("/content/banners/" . rawurlencode($image)), 'link' => $obj->getLink(), 'youtube_id' => $youtubeId, 'cta_text' => $obj->getButtonText());
     return $arr;
 }
Esempio n. 9
0
 static function _setObjProp($obj, $val, $lang, $method)
 {
     $method_name = '';
     $newVal = $val;
     if (is_string($method)) {
         $method_name = 'set' . $method;
         if (strpos($method, 'Array') === 0 && is_string($val)) {
             $newVal = Helper_String::commaStrToArr($val);
         }
     } else {
         if (is_array($method)) {
             if (!empty($method['attr'])) {
                 $obj->setAttr($method['attr'], $val);
                 return;
             } else {
                 if (!empty($method['extra_attribute'])) {
                     $extra = $obj->getExtraAttribute();
                     if ($extra) {
                         $setMethod = 'set' . $method['extra_attribute'];
                         $extra->{$setMethod}($val);
                     }
                     return;
                 } else {
                     $method_name = 'set' . $method['method'];
                     $newVal = $method['filter']($val);
                 }
             }
         } else {
             if (is_callable($method)) {
                 $method($obj, $val, $lang);
                 return;
             }
         }
     }
     $obj->{$method_name}($newVal, $lang);
 }