codeigniter-basic-helper

CodeIgniter - Basic Helper - Maintain by @nguyenanhung

GPL-3.0 License

Downloads
25.7K
Stars
4
Committers
2

CodeIgniter Basic Helper

Summary

1 vi helper c bn khi s dng vi CodeIgniter 3.

C th a vo nhiu b code hay framework khc, tuy nhin c 1 s function require framework CodeIgniter, tuy nhin khng nh hng ti hiu sut s dng

Trong trng hp tch hp gi ny vo cc framework, source khc ngoi CodeIgniter, bn cn ci km thm gi nguyenanhung/polyfill-codeigniter-built-in s dng tt nht

1 vi framework ti cng thng dng vi gi ny l

  • CodeIgniter
  • Slim framework
  • FuelPHP
  • PhalconPHP
  • Laravel

Table of Contents

1 s helper c h tr sn

Di y l danh sch cc Helper c h tr trong b th vin ny

AlphaID Helper

  • Helper Function: generateAlphaId - Hm gip to 1 Id unique 4ew68i32xc da trn 1 int u vo nh 1234

Array Helper

  • Helper Function: arrayToObject - Hm gip chuyn 1 array thnh 1 object
  • Helper Function: to_array - Converts a string or an object to an array.
  • Helper Function: arrayToXml - Hm gip chuyn array thnh 1 chui XML
  • Helper Function: removeArrayElementWithValue - Loi b 1 gi tr trong array theo key v value
  • Helper Function: arrayRecursiveDiff - Diff 2 array bng quy
  • Helper Function: arrayIsAssoc - Detects if the given value is an associative array.
  • Helper Function: arrayFirstElement - Returns the first element of an array.
  • Helper Function: arrayLastElement - Returns the last element of an array.
  • Helper Function: arrayGetElement - Gets a value in an array by dot notation for the keys.
  • Helper Function: arraySetElement - Sets a value in an array using the dot notation.

Assets Helper

  • Helper Function: assets_url - Hm ly ra Assets Url, iu kin tn ti th mc assets trong th mc public/.
    Trong trng hp trong file config.php tn ti bin assets_version s t ng thm version vo ng sau cc file
    CSS, JS
  • Helper Function: static_url - Hm ly ra Static Resource Url, iu kin tn ti cu
    hnh config_item('static_url') trong config ca website. Trong trng hp trong file config.php tn ti
    bin assets_version s t ng thm version vo
    ng sau cc file CSS, JS
  • Helper Function: templates_url - Hm ly ra Assets Url, iu kin tn ti th mc templates trong th
    mc public/. Trong trng hp trong file config.php tn ti bin assets_version s t ng thm version vo ng
    sau cc file CSS,
    JS
  • Helper Function: editor_url - Hm ly ra Assets Url, iu kin tn ti th mc assets/editors/ trong th
    mc public/. Trong trng hp trong file config.php tn ti bin assets_version s t ng thm version vo ng
    sau cc file
    CSS, JS
  • Helper Function: favicon_url- Hm ly ra Assets Url, iu kin tn ti th mc assets/favicon/ trong th
    mc public/. Trong trng hp trong file config.php tn ti bin assets_version s t ng thm version vo ng
    sau cc file
    CSS, JS
  • Helper Function: favicon_html_tag- Hm ly ra on HTML th hin Favicon da vo URL folder favicon u vo
  • Helper Function: storage_url - Need config storage_url item in config.php file.
    VD: $config['storage_url'] = 'https://storage.nguyenanhung.com/';
  • Helper Function: go_url - Need config go_url item in config.php file.
    VD: $config['go_url'] = 'https://go.nguyenanhung.com/';
  • Helper Function: assets_mobile - Ly ra ng dn assets ca giao din mobile (thc t t dng, duy tr cho cc
    d n c)
  • Helper Function: assets_themes - Ly ra ng dn assets ca giao din pc (thc t t dng, duy tr cho cc d
    n c)
  • Helper Function: assets_themes_dashboard - Ly ra ng dn assets ca giao din dashboard (thc t t dng, duy
    tr cho cc d n c)
  • Helper Function: assets_themes_comingsoon - Ly ra ng dn assets ca giao din coming soon (thc t t dng,
    duy tr cho cc d n c)
  • Helper Function: assets_themes_error - Ly ra ng dn assets ca giao din error (thc t t dng, duy tr cho
    cc d n c)
  • Helper Function: cdn_js_url - Resource JS, CSS t CDN ca Cloudflare
  • Helper Function: google_fonts_url - Resource Google Font
  • Helper Function: bootstrapcdn_url - Resource CDN t Bootstrap

Blogspot Helper

  • Helper Function: blogspotDescSortWithPublishedTime - Sp xp d liu feed t blogspot theo Published Time
  • Helper Function: blogspotUSort - Sp xp d liu feed t blogspot theo USort v Published Time theo DESC
  • Helper Function: blogspotFormatInformationItem - Format d liu u vo blogspot item

Bytes Helper

  • Helper Function: bytesHumanFormat - Hin th format ni dung d c t byte d liu

Chart Render Helper

  • Helper Function: bear_framework_default_get_data_chart
  • Helper Function: bear_framework_default_get_data_chart_report

Common Helper

  • Helper Function: isEmpty - Kim tra 1 input u vo xem c phi l rng hay khng
  • Helper Function: defaultCompressHtmlOutput - Compress HTML output, default configure
  • Helper Function: generateRandomUniqueId - To 1 chui Unique ID ngu nhin, s dng UUID
  • Helper Function: generateRandomNanoUniqueId - To 1 chui Unique ID ngu nhin, s dng NanoID

Database Helper

  • Helper Function: generate_list_id_with_parent_id - To 1 list cc ID, trong cha cc tp con ph thuc ca
    ID . VD: Dng trong trng hp mun hin th ni dung ca category cha v cc category con trong cng 1 page content

Date Helper

  • Helper Function: dayFloor - Hm ly ra khong cch gia 2 ngy
  • Helper Function: getZuluTime - Hm ly ra tham s date theo Zulu time
  • Helper Function: iso_8601_utc_time - tng t hm getZuluTime
  • Helper Function: getYesterday - Hm y ra ngy trc lin k
  • Helper Function: smart_bear_date_range - Ly ra 1 mng d liu cha cc ngy theo khong cch
  • Helper Function: format_datetime_vn - Format li thng tin ngy theo kiu Vit Nam
  • Helper Function: get_start_and_end_date_for_week - Ly ra ngy u v ngy cui ca 1 tun

Debug Helper

Cc hm ny dng debug

  • Helper Function: dd
  • Helper Function: ddd
  • Helper Function: dump

ENV Helper

  • Helper Function: bear_get_env - Hm ly gi tr t file .env

Escape Helper

  • Helper Function: bear_framework_basic_clean_str - Simple Clean Input String

Facebook Helper

  • Helper Function: widget_facebook_div_init - Hm to ra <div id="fb-root"></div>
  • Helper Function: widget_facebook_script_init - Hm to ra on script init trong trng hp cn nhng JS
    Facebook
  • Helper Function: widget_facebook_comments - Hm to ra khung comment facebook
  • Helper Function: widget_facebook_share_button - Hm to ra nt share facebook
  • Helper Function: widget_facebook_like_button - Hm to ra nt like facebook
  • Helper Function: widget_facebook_save_button - Hm to ra nt lu ni dung vo facebook

File Helper

  • Helper Function: formatSizeUnits - Hm format 1 int u vo thnh 1 format d c dung lng file
  • Helper Function: generateFileIndex - T ng to ni dung file index.html
  • Helper Function: generateFileHtaccess - T ng to ni dung file .htaccess
  • Helper Function: generateFileReadme - T ng to ni dung file README.md
  • Helper Function: makeNewFolder - Hm to 1 th mc mi v generate sn trong 3 file: README.md, index.html
    , .htaccess. To thm file .gitkeep nu tham s th 2 c truyn l true
  • Helper Function: new_folder - Chc nng tng t vi hm makeNewFolder
  • Helper Function: scan_folder - Qut v ly ra danh sch cc thng tin d liu trong folder
  • Helper Function: getAllFileSizeInFolder - Get all File size in Folder
  • Helper Function: getAllFileInFolder - Get all File in Folder

Form Helper

  • Helper Function: join_value_multiple - Join Value Multiple

Gravatar Helper

  • Helper Function: bear_framework_show_gravatar - Show Gravatar URL with Custom Size and Username

HTML Helper

  • Helper Function: meta_dns_prefetch
  • Helper Function: meta_property
  • Helper Function: tachPage
  • Helper Function: stripHtmlTag
  • Helper Function: strip_only_tags
  • Helper Function: tracking_google_analytics
  • Helper Function: tracking_google_gtag_analytics_default
  • Helper Function: bear_framework_show_jsonld_script

Image Helper

  • Helper Function: google_image_resize - Resize Image s dng Google Gadget Proxy
  • Helper Function: google_image_proxy_dns_prefetch - Hm cung cp DNS Prefetch trong trng hp s
    dng google_image_resize
  • Helper Function: wordpress_proxy - Resize & Cache Image s dng WordPress Proxy
  • Helper Function: wordpress_proxy_dns_prefetch - Hm cung cp DNS Prefetch trong trng hp s
    dng wordpress_proxy
  • Helper Function: bear_framework_image_url - Hm format Image Url - dnh ring cho BEAR framework
  • Helper Function: create_image_thumbnail - Hm create thumbnail - dnh ring cho BEAR framework

IP Helper

  • Helper Function: getIPAddress - Hm ly ra a ch IP thc t ca ngi dng
  • Helper Function: getIPAddressByHaProxy - Hm ly ra a ch IP thc t ca ngi dng nhng server c chy Ha
    Proxy, thng qua bin HTTP_X_FORWARDED_FOR
  • Helper Function: validateIP - Hm validate 1 string c phi IP ko. TRUE nu l IP
  • Helper Function: validateIPV4 - Hm validate 1 string c phi IP v4 ko. TRUE nu l IP
  • Helper Function: validateIPV6 - Hm validate 1 string c phi IP v6 ko. TRUE nu l IP
  • Helper Function: getIpInformation - Khi to 1 request n IP-API ly thng tin ca a ch IP

Meta Helper

  • Helper Function: setupMetaDnsPrefetch - Hm h tr gen ra 1 on HTML Dns Prefetch tng
    t <link href='//data.nguyenanhung.com/' rel='dns-prefetch' />

Money Helper

  • Helper Function: money_number_format - format money currency will detect the current locale

NanoID Helper

Helper ny s dng gi hidehalo/nanoid-php gen ra 1 m random Id nh, nh v an ton hn nhiu so vi UUID.

Hin ti vic s dng nanoid ang l xu hng so vi uuid truyn thng

s dng c gi ny, cn ci packages nguyenanhung/nanoid-helper bng lnh composer require nguyenanhung/nanoid-helper

  • Helper Function: randomNanoId

Number Helper

  • Helper Function: convertNumberToWords - Tc dng convert 1 s thnh ch, v d 123
    thnh One Hundred Twenty Three

Paging Helper

  • Helper Function: view_paginations
  • Helper Function: view_more
  • Helper Function: select_page
  • Helper Function: get_paginations_title
  • Helper Function: get_paginations_number
  • Helper Function: bear_framework_news_view_pagination - Hm phn trang ch ring cho BEAR Project

PlaceHolder Helper

  • Helper Function: placeholder_img

Request Helper

  • Helper Function: sendSimpleGetRequest - Tin hnh thc thi 1 request n gin s dng CURL vi phng thc GET
  • Helper Function: sendSimpleRestfulExecuteRequest - Thc thi 1 simple request ti Restful API s dng CURL
  • Helper Function: bear_post_async_request - Make an asynchronous POST request - Thc hin yu cu POST khng ng
    b trong ni b site m khng cn ch phn hi => Khng nh hng, khng tr hon tin trnh ang chy
  • Helper Function: get_http_response_code - Get HTTP Response Code with get_headers

Security Helper

  • Helper Function: xssValidation - Validation d liu u vo c b dnh li XSS hay khng. Hm ny khng c tc
    dng escape, nu mun, hy ci thm packages nguyenanhung/security

Sentry Helper

  • Helper Function: log_to_sentry - Logging ln Sentry thng qua Monolog Handler

String Helper

  • Helper Function: countStringsInText - Hm m s t trong on vn bn
  • Helper Function: findMiddleInString - Hm ly chui gia chui bt u v chui kt thc
  • Helper Function: str_insert - Inserts one or more strings into another string on a defined position.
  • Helper Function: str_between - Return the content in a string between a left and right element.
  • Helper Function: str_after - Return the part of a string after a given value.
  • Helper Function: str_before - Get the part of a string before a given value.
  • Helper Function: str_limit_words - Limit the number of words in a string. Put value of $end to the string end.
  • Helper Function: str_limit_characters - Limit the number of characters in a string. Put value of $end to the
    string end.
  • Helper Function: str_contains - Tests if a string contains a given element
  • Helper Function: str_ignore_contains - Tests if a string contains a given element. Ignore case sensitivity.
  • Helper Function: str_starts_with - Determine if a given string starts with a given substring.
  • Helper Function: str_ignore_starts_with - Determine if a given string starts with a given substring. Ignore case
    sensitivity.
  • Helper Function: str_ends_with - Determine if a given string ends with a given substring.
  • Helper Function: str_ignore_ends_with - Determine if a given string ends with a given substring. Ignore case
    sensitivity.
  • Helper Function: str_after_last - Return the part of a string after the last occurrence of a given search value.
  • Helper Function: hide_characters - Convert nguyenanhung to ngxyexanxunx, acts as a very simple and
    predictable character encoding function but is necessary to hide something simple

Text Helper

  • Helper Function: convert_string_utf8_to_vietnamese
  • Helper Function: clean_allowfullscreen
  • Helper Function: clean_text
  • Helper Function: clean_title
  • Helper Function: clean_text_mobile
  • Helper Function: bodautru
  • Helper Function: bodaunhay
  • Helper Function: searchs_snippets
  • Helper Function: tags_snippets
  • Helper Function: tags_clean
  • Helper Function: highlight_keyword_phrase - Highlights a keyword within a text string
  • Helper Function: format_keyword_highlight_phrase - Format Keyword for Function highlight_keyword_phrase

TinyUrl Helper

  • Helper Function: short_url_with_tinyurl - Hm h tr shortUrl da trn API ca TinyURL

URL Helper

  • Helper Function: encodeId_Url_byHungDEV
  • Helper Function: decodeId_Url_byHungDEV
  • Helper Function: convertToLatin
  • Helper Function: specialCharToNormalChar
  • Helper Function: alphabetOnly
  • Helper Function: boDauTiengViet
  • Helper Function: removeSpecialChar
  • Helper Function: getPermalinksSEO
  • Helper Function: share_url - Create ra URL share chun cho cc MXH, h tr rt tt cho SEO
  • Helper Function: private_url - Hm customize dnh ring cho framework CodeIgniter
  • Helper Function: private_api_url - Hm customize dnh ring cho framework CodeIgniter
  • Helper Function: cdn_url - Hm customize dnh ring cho framework CodeIgniter
  • Helper Function: images_url - Hm customize dnh ring cho framework CodeIgniter
  • Helper Function: audio_url - Hm customize dnh ring cho framework CodeIgniter
  • Helper Function: append_params_into_url - Append parameters to URL
  • Helper Function: append_query_string_to_current_url - Get current URL including query string - Hm customize
    dnh ring cho framework CodeIgniter

UUID Helper

  • Helper Function: generate_uuid_v4 - Hm to ra 1 chui UUID v4 ngu nhin

VN Province Helper

  • Helper Function: check_vn_province_code - Check Provin Code ca 1 s tnh thnh Vit Nam

Video Embed Helper

  • Helper Function: convert_video_embed_vimeo - Convert Video URL to Embed Vimeo (t dng, lu ti y v cn nhiu
    project c ang s dng)
  • Helper Function: convert_video_embed_dailymotion - Convert Video URL to Embed DailyMotion (t dng, lu ti y
    v cn nhiu project c ang s dng)
  • Helper Function: convert_video_embed_youtube - Convert Video URL to Embed YouTube (t dng, lu ti y v cn
    nhiu project c ang s dng)
  • Helper Function: convert_video_v_embed_youtube - Convert Video URL to Embed YouTube (t dng, lu ti y v cn
    nhiu project c ang s dng)
  • Helper Function: youtube_image_thumbnail - Convert YoutubeID to Youtube Thumbnail URL

XML Helper

  • Helper Function: parse_sitemap - Hm h tr render ra ni dung cho Sitemap
  • Helper Function: parse_sitemap_index - Hm h tr render ra ni dung cho Sitemap Index
  • Helper Function: xml_convert - Convert Reserved XML characters to Entities
  • Helper Function: xml_get_value - Get Value from XML string
  • Helper Function: xml_to_json - Convert XML string to JSON

Simple RESTful Helper

Class cung cp phng thc nhanh gn gi ti cc API tun chun RESTful

  • Execute request to RESTful API Service: SimpleRestful::execute($url, $type, $data)

Simple cURL Helper

Class cung cp phng thc nhanh gn gi thc hin cc request ra bn ngoi, s dng Curl n gin, v d

<?php
use nguyenanhung\CodeIgniter\BasicHelper\SimpleCurl;

$curl = new SimpleCurl();
$curl->setUrl('https://example.com')
    ->setPost(array('field1'=>'value1'))
    ->createCurl();

$response = $curl->getResponse();

Simple Image Library

Class cung cp 1 s phng thc gip x l hnh nh

  • Method googleGadgetsProxy - To URL Resize s dng Google Gadgets Proxy
  • Method googleGadgetsProxyDnsPrefetch - Setup DNS Prefetch cho Google Gadgets Proxy, nhm tng tc truy vn
  • Method wordpressProxy - To URL Resize s dng WordPress Proxy
  • Method wordpressProxyDnsPrefetch - Setup DNS Prefetch cho WordPress Proxy, nhm tng tc truy vn
  • Method createThumbnail - Hm to Thumbnail, s dng cn ci thm gi nguyenanhung/image
  • Method createThumbnailWithCodeIgniterCache - Hm to Thumbnail kt hp th vin Cache ca CodeIgniter, s
    dng cn ci thm gi nguyenanhung/image

Maintainer & Supporter

STT Name Email Website Github
1 Hung Nguyen [email protected] https://nguyenanhung.com @nguyenanhung