repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.update_nag
function update_nag() { $theme = wp_get_theme( $this->product->get_slug() ); $api_response = get_transient( $this->product_key ); if ( false === $api_response ) { return; } $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() ); $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' ); $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { echo '<div id="update-nag">'; printf( '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.', $theme->get( 'Name' ), $api_response->new_version, '#TB_inline?width=640&amp;inlineId=' . $this->product->get_version() . '_changelog', $theme->get( 'Name' ), $update_url, $update_onclick ); echo '</div>'; echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">'; echo wpautop( $api_response->sections['changelog'] ); echo '</div>'; } }
php
function update_nag() { $theme = wp_get_theme( $this->product->get_slug() ); $api_response = get_transient( $this->product_key ); if ( false === $api_response ) { return; } $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() ); $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' ); $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { echo '<div id="update-nag">'; printf( '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.', $theme->get( 'Name' ), $api_response->new_version, '#TB_inline?width=640&amp;inlineId=' . $this->product->get_version() . '_changelog', $theme->get( 'Name' ), $update_url, $update_onclick ); echo '</div>'; echo '<div id="' . $this->product->get_slug() . '_' . 'changelog" style="display:none;">'; echo wpautop( $api_response->sections['changelog'] ); echo '</div>'; } }
[ "function", "update_nag", "(", ")", "{", "$", "theme", "=", "wp_get_theme", "(", "$", "this", "->", "product", "->", "get_slug", "(", ")", ")", ";", "$", "api_response", "=", "get_transient", "(", "$", "this", "->", "product_key", ")", ";", "if", "(", ...
Alter the nag for themes update.
[ "Alter", "the", "nag", "for", "themes", "update", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L445-L470
train
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.theme_update_transient
function theme_update_transient( $value ) { $update_data = $this->check_for_update(); if ( $update_data ) { $value->response[ $this->product->get_slug() ] = $update_data; } return $value; }
php
function theme_update_transient( $value ) { $update_data = $this->check_for_update(); if ( $update_data ) { $value->response[ $this->product->get_slug() ] = $update_data; } return $value; }
[ "function", "theme_update_transient", "(", "$", "value", ")", "{", "$", "update_data", "=", "$", "this", "->", "check_for_update", "(", ")", ";", "if", "(", "$", "update_data", ")", "{", "$", "value", "->", "response", "[", "$", "this", "->", "product", ...
Alter update transient. @param mixed $value The transient data. @return mixed
[ "Alter", "update", "transient", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L479-L486
train
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.check_for_update
function check_for_update() { $update_data = get_transient( $this->product_key ); if ( false === $update_data ) { $failed = false; $update_data = $this->get_version_data(); if ( empty( $update_data ) ) { $failed = true; } // If the response failed, try again in 30 minutes. if ( $failed ) { $data = new \stdClass(); $data->new_version = $this->product->get_version(); set_transient( $this->product_key, $data, 30 * MINUTE_IN_SECONDS ); return false; } $update_data->sections = maybe_unserialize( $update_data->sections ); set_transient( $this->product_key, $update_data, 12 * HOUR_IN_SECONDS ); } if ( ! isset( $update_data->new_version ) ) { return false; } if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) { return false; } return (array) $update_data; }
php
function check_for_update() { $update_data = get_transient( $this->product_key ); if ( false === $update_data ) { $failed = false; $update_data = $this->get_version_data(); if ( empty( $update_data ) ) { $failed = true; } // If the response failed, try again in 30 minutes. if ( $failed ) { $data = new \stdClass(); $data->new_version = $this->product->get_version(); set_transient( $this->product_key, $data, 30 * MINUTE_IN_SECONDS ); return false; } $update_data->sections = maybe_unserialize( $update_data->sections ); set_transient( $this->product_key, $update_data, 12 * HOUR_IN_SECONDS ); } if ( ! isset( $update_data->new_version ) ) { return false; } if ( version_compare( $this->product->get_version(), $update_data->new_version, '>=' ) ) { return false; } return (array) $update_data; }
[ "function", "check_for_update", "(", ")", "{", "$", "update_data", "=", "get_transient", "(", "$", "this", "->", "product_key", ")", ";", "if", "(", "false", "===", "$", "update_data", ")", "{", "$", "failed", "=", "false", ";", "$", "update_data", "=", ...
Check for updates @return array|bool Either the update data or false in case of failure.
[ "Check", "for", "updates" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L493-L522
train
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.get_version_data
private function get_version_data() { $api_params = array( 'edd_action' => 'get_version', 'version' => $this->product->get_version(), 'license' => $this->license_key, 'name' => $this->product->get_name(), 'slug' => $this->product->get_slug(), 'author' => $this->get_distributor_name(), 'url' => rawurlencode( home_url() ), ); $response = wp_remote_get( $this->get_api_url(), array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params, ) ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { return false; } $update_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $update_data ) ) { return false; } return $update_data; }
php
private function get_version_data() { $api_params = array( 'edd_action' => 'get_version', 'version' => $this->product->get_version(), 'license' => $this->license_key, 'name' => $this->product->get_name(), 'slug' => $this->product->get_slug(), 'author' => $this->get_distributor_name(), 'url' => rawurlencode( home_url() ), ); $response = wp_remote_get( $this->get_api_url(), array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params, ) ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { return false; } $update_data = json_decode( wp_remote_retrieve_body( $response ) ); if ( ! is_object( $update_data ) ) { return false; } return $update_data; }
[ "private", "function", "get_version_data", "(", ")", "{", "$", "api_params", "=", "array", "(", "'edd_action'", "=>", "'get_version'", ",", "'version'", "=>", "$", "this", "->", "product", "->", "get_version", "(", ")", ",", "'license'", "=>", "$", "this", ...
Check remote api for latest version. @return bool|mixed Update api response.
[ "Check", "remote", "api", "for", "latest", "version", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L529-L556
train
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.http_request_args
function http_request_args( $args, $url ) { // If it is an https request and we are performing a package download, disable ssl verification. if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { $args['sslverify'] = false; } return $args; }
php
function http_request_args( $args, $url ) { // If it is an https request and we are performing a package download, disable ssl verification. if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { $args['sslverify'] = false; } return $args; }
[ "function", "http_request_args", "(", "$", "args", ",", "$", "url", ")", "{", "// If it is an https request and we are performing a package download, disable ssl verification.", "if", "(", "strpos", "(", "$", "url", ",", "'https://'", ")", "!==", "false", "&&", "strpos"...
Disable SSL verification in order to prevent download update failures. @param array $args Http args. @param string $url Url to check. @return array $array
[ "Disable", "SSL", "verification", "in", "order", "to", "prevent", "download", "update", "failures", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L637-L644
train
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.can_load
public function can_load( $product ) { if ( $product->is_wordpress_available() ) { return false; } return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true ); }
php
public function can_load( $product ) { if ( $product->is_wordpress_available() ) { return false; } return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true ); }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "product", "->", "is_wordpress_available", "(", ")", ")", "{", "return", "false", ";", "}", "return", "(", "apply_filters", "(", "$", "product", "->", "get_key", "(", ")", ...
Check if we should load the module for this product. @param Product $product Product data. @return bool Should we load the module?
[ "Check", "if", "we", "should", "load", "the", "module", "for", "this", "product", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L653-L661
train
Codeinwp/themeisle-sdk
src/Modules/Licenser.php
Licenser.register_license_hooks
public function register_license_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'activate_license' ) ); add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 ); add_action( 'admin_notices', array( $this, 'show_notice' ) ); add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) ); }
php
public function register_license_hooks() { add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_init', array( $this, 'activate_license' ) ); add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 ); add_action( 'admin_notices', array( $this, 'show_notice' ) ); add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) ); }
[ "public", "function", "register_license_hooks", "(", ")", "{", "add_action", "(", "'admin_init'", ",", "array", "(", "$", "this", ",", "'register_settings'", ")", ")", ";", "add_action", "(", "'admin_init'", ",", "array", "(", "$", "this", ",", "'activate_lice...
Register license fields for the products.
[ "Register", "license", "fields", "for", "the", "products", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Licenser.php#L712-L718
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.show_notification
public static function show_notification() { $current_notification = self::get_last_notification(); $notification_details = []; // Check if the saved notification is still present among the possible ones. if ( ! empty( $current_notification ) ) { $notification_details = self::get_notification_details( $current_notification ); if ( empty( $notification_details ) ) { $current_notification = []; } } // Check if the notificatin is expired. if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) { update_option( $current_notification['id'], 'no' ); self::set_last_active_notification_timestamp(); $current_notification = []; } // If we don't have any saved notification, get a new one. if ( empty( $current_notification ) ) { $notification_details = self::get_random_notification(); if ( empty( $notification_details ) ) { return; } self::set_active_notification( [ 'id' => $notification_details['id'], 'display_at' => time(), ] ); } if ( empty( $notification_details ) ) { return; } $notification_html = self::get_notification_html( $notification_details ); do_action( $notification_details['id'] . '_before_render' ); echo $notification_html; do_action( $notification_details['id'] . '_after_render' ); self::render_snippets(); }
php
public static function show_notification() { $current_notification = self::get_last_notification(); $notification_details = []; // Check if the saved notification is still present among the possible ones. if ( ! empty( $current_notification ) ) { $notification_details = self::get_notification_details( $current_notification ); if ( empty( $notification_details ) ) { $current_notification = []; } } // Check if the notificatin is expired. if ( ! empty( $current_notification ) && self::is_notification_expired( $current_notification ) ) { update_option( $current_notification['id'], 'no' ); self::set_last_active_notification_timestamp(); $current_notification = []; } // If we don't have any saved notification, get a new one. if ( empty( $current_notification ) ) { $notification_details = self::get_random_notification(); if ( empty( $notification_details ) ) { return; } self::set_active_notification( [ 'id' => $notification_details['id'], 'display_at' => time(), ] ); } if ( empty( $notification_details ) ) { return; } $notification_html = self::get_notification_html( $notification_details ); do_action( $notification_details['id'] . '_before_render' ); echo $notification_html; do_action( $notification_details['id'] . '_after_render' ); self::render_snippets(); }
[ "public", "static", "function", "show_notification", "(", ")", "{", "$", "current_notification", "=", "self", "::", "get_last_notification", "(", ")", ";", "$", "notification_details", "=", "[", "]", ";", "// Check if the saved notification is still present among the poss...
Show notification data.
[ "Show", "notification", "data", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L50-L91
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.get_notification_details
private static function get_notification_details( $notification ) { $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); return ! empty( $notifications ) ? reset( $notifications ) : []; }
php
private static function get_notification_details( $notification ) { $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); return ! empty( $notifications ) ? reset( $notifications ) : []; }
[ "private", "static", "function", "get_notification_details", "(", "$", "notification", ")", "{", "$", "notifications", "=", "array_filter", "(", "self", "::", "$", "notifications", ",", "function", "(", "$", "value", ")", "use", "(", "$", "notification", ")", ...
Check if the notification is still possible. @param array $notification Notification to check. @return array Either is still active or not.
[ "Check", "if", "the", "notification", "is", "still", "possible", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L130-L143
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.is_notification_expired
private static function is_notification_expired( $notification ) { if ( ! isset( $notification['display_at'] ) ) { return true; } $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); if ( empty( $notifications ) ) { return true; } $notification_definition = reset( $notifications ); $when_to_expire = isset( $notification_definition['expires_at'] ) ? $notification_definition['expires_at'] : ( isset( $notification_definition['expires'] ) ? ( $notification['display_at'] + $notification_definition['expires'] ) : ( $notification['display_at'] + self::MAX_TIME_TO_LIVE * DAY_IN_SECONDS ) ); return ( $when_to_expire - time() ) < 0; }
php
private static function is_notification_expired( $notification ) { if ( ! isset( $notification['display_at'] ) ) { return true; } $notifications = array_filter( self::$notifications, function ( $value ) use ( $notification ) { if ( isset( $value['id'] ) && isset( $notification['id'] ) && $value['id'] === $notification['id'] ) { return true; } return false; } ); if ( empty( $notifications ) ) { return true; } $notification_definition = reset( $notifications ); $when_to_expire = isset( $notification_definition['expires_at'] ) ? $notification_definition['expires_at'] : ( isset( $notification_definition['expires'] ) ? ( $notification['display_at'] + $notification_definition['expires'] ) : ( $notification['display_at'] + self::MAX_TIME_TO_LIVE * DAY_IN_SECONDS ) ); return ( $when_to_expire - time() ) < 0; }
[ "private", "static", "function", "is_notification_expired", "(", "$", "notification", ")", "{", "if", "(", "!", "isset", "(", "$", "notification", "[", "'display_at'", "]", ")", ")", "{", "return", "true", ";", "}", "$", "notifications", "=", "array_filter",...
Check if the notification is expired. @param array $notification Notification to check. @return bool Either the notification is due.
[ "Check", "if", "the", "notification", "is", "expired", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L152-L181
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.get_random_notification
public static function get_random_notification() { if ( ( time() - self::get_last_active_notification_timestamp() ) < self::TIME_BETWEEN_NOTIFICATIONS * DAY_IN_SECONDS ) { return []; } $notifications = self::$notifications; $notifications = array_filter( $notifications, function ( $value ) { if ( isset( $value['sticky'] ) && true === $value['sticky'] ) { return true; } return false; } ); // No priority notifications, use all. if ( empty( $notifications ) ) { $notifications = self::$notifications; } if ( empty( $notifications ) ) { return []; } $notifications = array_values( $notifications ); return $notifications[ array_rand( $notifications, 1 ) ]; }
php
public static function get_random_notification() { if ( ( time() - self::get_last_active_notification_timestamp() ) < self::TIME_BETWEEN_NOTIFICATIONS * DAY_IN_SECONDS ) { return []; } $notifications = self::$notifications; $notifications = array_filter( $notifications, function ( $value ) { if ( isset( $value['sticky'] ) && true === $value['sticky'] ) { return true; } return false; } ); // No priority notifications, use all. if ( empty( $notifications ) ) { $notifications = self::$notifications; } if ( empty( $notifications ) ) { return []; } $notifications = array_values( $notifications ); return $notifications[ array_rand( $notifications, 1 ) ]; }
[ "public", "static", "function", "get_random_notification", "(", ")", "{", "if", "(", "(", "time", "(", ")", "-", "self", "::", "get_last_active_notification_timestamp", "(", ")", ")", "<", "self", "::", "TIME_BETWEEN_NOTIFICATIONS", "*", "DAY_IN_SECONDS", ")", "...
Return notification to show. @return array Notification data.
[ "Return", "notification", "to", "show", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L197-L224
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.get_notification_html
public static function get_notification_html( $notification_details ) { $default = [ 'id' => '', 'heading' => '', 'message' => '', 'ctas' => [ 'confirm' => [ 'link' => '#', 'text' => '', ], 'cancel' => [ 'link' => '#', 'text' => '', ], ], ]; $notification_details = wp_parse_args( $notification_details, $default ); $notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">'; if ( ! empty( $notification_details['heading'] ) ) { $notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) ); } if ( ! empty( $notification_details['message'] ) ) { $notification_html .= wp_kses_post( $notification_details['message'] ); } $notification_html .= '<div class="actions">'; if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" target="_blank" class=" button button-primary %s" data-confirm="yes" >%s</a>', esc_url( $notification_details['ctas']['confirm']['link'] ), esc_attr( $notification_details['id'] . '_confirm' ), wp_kses_post( $notification_details['ctas']['confirm']['text'] ) ); } if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" class=" button %s" data-confirm="no">%s</a>', esc_url( $notification_details['ctas']['cancel']['link'] ), esc_attr( $notification_details['id'] ) . '_cancel', wp_kses_post( $notification_details['ctas']['cancel']['text'] ) ); } $notification_html .= '</div>'; $notification_html .= ' </div>'; $notification_html .= ' </div>'; return $notification_html; }
php
public static function get_notification_html( $notification_details ) { $default = [ 'id' => '', 'heading' => '', 'message' => '', 'ctas' => [ 'confirm' => [ 'link' => '#', 'text' => '', ], 'cancel' => [ 'link' => '#', 'text' => '', ], ], ]; $notification_details = wp_parse_args( $notification_details, $default ); $notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">'; if ( ! empty( $notification_details['heading'] ) ) { $notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) ); } if ( ! empty( $notification_details['message'] ) ) { $notification_html .= wp_kses_post( $notification_details['message'] ); } $notification_html .= '<div class="actions">'; if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" target="_blank" class=" button button-primary %s" data-confirm="yes" >%s</a>', esc_url( $notification_details['ctas']['confirm']['link'] ), esc_attr( $notification_details['id'] . '_confirm' ), wp_kses_post( $notification_details['ctas']['confirm']['text'] ) ); } if ( ! empty( $notification_details['ctas']['cancel']['text'] ) ) { $notification_html .= sprintf( '<a href="%s" class=" button %s" data-confirm="no">%s</a>', esc_url( $notification_details['ctas']['cancel']['link'] ), esc_attr( $notification_details['id'] ) . '_cancel', wp_kses_post( $notification_details['ctas']['cancel']['text'] ) ); } $notification_html .= '</div>'; $notification_html .= ' </div>'; $notification_html .= ' </div>'; return $notification_html; }
[ "public", "static", "function", "get_notification_html", "(", "$", "notification_details", ")", "{", "$", "default", "=", "[", "'id'", "=>", "''", ",", "'heading'", "=>", "''", ",", "'message'", "=>", "''", ",", "'ctas'", "=>", "[", "'confirm'", "=>", "[",...
Get notification html. @param array $notification_details Notification details. @return string Html for notice.
[ "Get", "notification", "html", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L255-L306
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.dismiss
static function dismiss() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : ''; $confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no'; if ( empty( $id ) ) { wp_send_json( [] ); } self::set_last_active_notification_timestamp(); update_option( $id, $confirm ); do_action( $id . '_process_confirm', $confirm ); wp_send_json( [] ); }
php
static function dismiss() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : ''; $confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no'; if ( empty( $id ) ) { wp_send_json( [] ); } self::set_last_active_notification_timestamp(); update_option( $id, $confirm ); do_action( $id . '_process_confirm', $confirm ); wp_send_json( [] ); }
[ "static", "function", "dismiss", "(", ")", "{", "check_ajax_referer", "(", "(", "string", ")", "__CLASS__", ",", "'nonce'", ")", ";", "$", "id", "=", "isset", "(", "$", "_POST", "[", "'id'", "]", ")", "?", "sanitize_text_field", "(", "$", "_POST", "[",...
Dismiss the notification.
[ "Dismiss", "the", "notification", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L368-L381
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! current_user_can( 'manage_options' ) ) { return false; } if ( ( time() - $product->get_install_time() ) < ( self::MIN_INSTALL_TIME * HOUR_IN_SECONDS ) ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! current_user_can( 'manage_options' ) ) { return false; } if ( ( time() - $product->get_install_time() ) < ( self::MIN_INSTALL_TIME * HOUR_IN_SECONDS ) ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "current_user_can", "(", "'manage_options'", ")", ")", "{...
Check if we should load the notification module. @param Product $product Product to check. @return bool Should we load this?
[ "Check", "if", "we", "should", "load", "the", "notification", "module", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L390-L403
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.setup_notifications
public static function setup_notifications() { $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; }
php
public static function setup_notifications() { $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; }
[ "public", "static", "function", "setup_notifications", "(", ")", "{", "$", "notifications", "=", "apply_filters", "(", "'themeisle_sdk_registered_notifications'", ",", "[", "]", ")", ";", "$", "notifications", "=", "array_filter", "(", "$", "notifications", ",", "...
Setup notifications queue.
[ "Setup", "notifications", "queue", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L408-L424
train
Codeinwp/themeisle-sdk
src/Modules/Notification.php
Notification.load
public function load( $product ) { $this->product = $product; $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) ); add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) ); add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) ); return $this; }
php
public function load( $product ) { $this->product = $product; $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); $notifications = array_filter( $notifications, function ( $value ) { if ( ! isset( $value['id'] ) ) { return false; } if ( get_option( $value['id'], '' ) !== '' ) { return false; } return apply_filters( $value['id'] . '_should_show', true ); } ); self::$notifications = $notifications; add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) ); add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) ); add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) ); return $this; }
[ "public", "function", "load", "(", "$", "product", ")", "{", "$", "this", "->", "product", "=", "$", "product", ";", "$", "notifications", "=", "apply_filters", "(", "'themeisle_sdk_registered_notifications'", ",", "[", "]", ")", ";", "$", "notifications", "...
Load the module logic. @param Product $product Product to load the module for. @return Notification Module instance.
[ "Load", "the", "module", "logic", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Notification.php#L432-L455
train
Codeinwp/themeisle-sdk
src/Modules/Logger.php
Logger.setup_actions
public function setup_actions() { if ( ! $this->is_logger_active() ) { return; } $action_key = $this->product->get_key() . '_log_activity'; if ( ! wp_next_scheduled( $action_key ) ) { wp_schedule_single_event( time() + ( rand( 1, 24 ) * 3600 ), $action_key ); } add_action( $action_key, array( $this, 'send_log' ) ); }
php
public function setup_actions() { if ( ! $this->is_logger_active() ) { return; } $action_key = $this->product->get_key() . '_log_activity'; if ( ! wp_next_scheduled( $action_key ) ) { wp_schedule_single_event( time() + ( rand( 1, 24 ) * 3600 ), $action_key ); } add_action( $action_key, array( $this, 'send_log' ) ); }
[ "public", "function", "setup_actions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_logger_active", "(", ")", ")", "{", "return", ";", "}", "$", "action_key", "=", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_log_activity'"...
Setup tracking actions.
[ "Setup", "tracking", "actions", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Logger.php#L75-L85
train
Codeinwp/themeisle-sdk
src/Modules/Logger.php
Logger.is_logger_active
private function is_logger_active() { if ( ! $this->product->is_wordpress_available() ) { return true; } $pro_slug = $this->product->get_pro_slug(); if ( ! empty( $pro_slug ) ) { $all_products = Loader::get_products(); if ( isset( $all_products[ $pro_slug ] ) ) { return true; } } return ( get_option( $this->product->get_key() . '_logger_flag', 'no' ) === 'yes' ); }
php
private function is_logger_active() { if ( ! $this->product->is_wordpress_available() ) { return true; } $pro_slug = $this->product->get_pro_slug(); if ( ! empty( $pro_slug ) ) { $all_products = Loader::get_products(); if ( isset( $all_products[ $pro_slug ] ) ) { return true; } } return ( get_option( $this->product->get_key() . '_logger_flag', 'no' ) === 'yes' ); }
[ "private", "function", "is_logger_active", "(", ")", "{", "if", "(", "!", "$", "this", "->", "product", "->", "is_wordpress_available", "(", ")", ")", "{", "return", "true", ";", "}", "$", "pro_slug", "=", "$", "this", "->", "product", "->", "get_pro_slu...
Check if the logger is active. @return bool Is logger active?
[ "Check", "if", "the", "logger", "is", "active", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Logger.php#L92-L106
train
Codeinwp/themeisle-sdk
src/Modules/Logger.php
Logger.send_log
public function send_log() { $environment = array(); $theme = wp_get_theme(); $environment['theme'] = array(); $environment['theme']['name'] = $theme->get( 'Name' ); $environment['theme']['author'] = $theme->get( 'Author' ); $environment['plugins'] = get_option( 'active_plugins' ); global $wp_version; wp_remote_post( self::TRACKING_ENDPOINT, array( 'method' => 'POST', 'timeout' => 3, 'redirection' => 5, 'headers' => array( 'X-ThemeIsle-Event' => 'log_site', ), 'body' => array( 'site' => get_site_url(), 'slug' => $this->product->get_slug(), 'version' => $this->product->get_version(), 'wp_version' => $wp_version, 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ), 'environment' => $environment, 'license' => apply_filters( $this->product->get_key() . '_license_status', '' ), ), ) ); }
php
public function send_log() { $environment = array(); $theme = wp_get_theme(); $environment['theme'] = array(); $environment['theme']['name'] = $theme->get( 'Name' ); $environment['theme']['author'] = $theme->get( 'Author' ); $environment['plugins'] = get_option( 'active_plugins' ); global $wp_version; wp_remote_post( self::TRACKING_ENDPOINT, array( 'method' => 'POST', 'timeout' => 3, 'redirection' => 5, 'headers' => array( 'X-ThemeIsle-Event' => 'log_site', ), 'body' => array( 'site' => get_site_url(), 'slug' => $this->product->get_slug(), 'version' => $this->product->get_version(), 'wp_version' => $wp_version, 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ), 'environment' => $environment, 'license' => apply_filters( $this->product->get_key() . '_license_status', '' ), ), ) ); }
[ "public", "function", "send_log", "(", ")", "{", "$", "environment", "=", "array", "(", ")", ";", "$", "theme", "=", "wp_get_theme", "(", ")", ";", "$", "environment", "[", "'theme'", "]", "=", "array", "(", ")", ";", "$", "environment", "[", "'theme...
Send the statistics to the api endpoint.
[ "Send", "the", "statistics", "to", "the", "api", "endpoint", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Logger.php#L148-L176
train
Codeinwp/themeisle-sdk
src/Common/Module_factory.php
Module_Factory.attach
public static function attach( $product, $modules ) { if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) { self::$modules_attached[ $product->get_slug() ] = []; } foreach ( $modules as $module ) { $class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ); /** * Module object. * * @var Abstract_Module $module_object Module instance. */ $module_object = new $class( $product ); if ( ! $module_object->can_load( $product ) ) { continue; } self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product ); } }
php
public static function attach( $product, $modules ) { if ( ! isset( self::$modules_attached[ $product->get_slug() ] ) ) { self::$modules_attached[ $product->get_slug() ] = []; } foreach ( $modules as $module ) { $class = 'ThemeisleSDK\\Modules\\' . ucwords( $module, '_' ); /** * Module object. * * @var Abstract_Module $module_object Module instance. */ $module_object = new $class( $product ); if ( ! $module_object->can_load( $product ) ) { continue; } self::$modules_attached[ $product->get_slug() ][ $module ] = $module_object->load( $product ); } }
[ "public", "static", "function", "attach", "(", "$", "product", ",", "$", "modules", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "modules_attached", "[", "$", "product", "->", "get_slug", "(", ")", "]", ")", ")", "{", "self", "::", "$...
Load availabe modules for the selected product. @param Product $product Loaded product. @param array $modules List of modules.
[ "Load", "availabe", "modules", "for", "the", "selected", "product", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Common/Module_factory.php#L78-L98
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! apply_filters( $product->get_slug() . '_load_dashboard_widget', true ) ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( ! apply_filters( $product->get_slug() . '_load_dashboard_widget', true ) ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "apply_filters", "(", "$", "product", "->", "get_slug", ...
Should we load this module. @param Product $product Product object. @return bool
[ "Should", "we", "load", "this", "module", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L55-L65
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.load
public function load( $product ) { $this->product = $product; $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' ); $this->feeds = apply_filters( 'themeisle_sdk_dashboard_widget_feeds', [ 'https://themeisle.com/blog/feed', ] ); add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) ); add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) ); add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) ); return $this; }
php
public function load( $product ) { $this->product = $product; $this->dashboard_name = apply_filters( 'themeisle_sdk_dashboard_widget_name', 'WordPress Guides/Tutorials' ); $this->feeds = apply_filters( 'themeisle_sdk_dashboard_widget_feeds', [ 'https://themeisle.com/blog/feed', ] ); add_action( 'wp_dashboard_setup', array( &$this, 'add_widget' ) ); add_action( 'wp_network_dashboard_setup', array( &$this, 'add_widget' ) ); add_filter( 'themeisle_sdk_recommend_plugin_or_theme', array( &$this, 'recommend_plugin_or_theme' ) ); return $this; }
[ "public", "function", "load", "(", "$", "product", ")", "{", "$", "this", "->", "product", "=", "$", "product", ";", "$", "this", "->", "dashboard_name", "=", "apply_filters", "(", "'themeisle_sdk_dashboard_widget_name'", ",", "'WordPress Guides/Tutorials'", ")", ...
Registers the hooks. @param Product $product Product to load. @return Dashboard_Widget Module instance.
[ "Registers", "the", "hooks", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L74-L89
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.setup_feeds
private function setup_feeds() { if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { // Load SimplePie Instance. $feed = fetch_feed( $this->feeds ); // TODO report error when is an error loading the feed. if ( is_wp_error( $feed ) ) { return; } $items = $feed->get_items( 0, 5 ); foreach ( (array) $items as $item ) { $items_normalized[] = array( 'title' => $item->get_title(), 'date' => $item->get_date( 'U' ), 'link' => $item->get_permalink(), ); } set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS ); } $this->items = $items_normalized; }
php
private function setup_feeds() { if ( false === ( $items_normalized = get_transient( 'themeisle_sdk_feed_items' ) ) ) { // Load SimplePie Instance. $feed = fetch_feed( $this->feeds ); // TODO report error when is an error loading the feed. if ( is_wp_error( $feed ) ) { return; } $items = $feed->get_items( 0, 5 ); foreach ( (array) $items as $item ) { $items_normalized[] = array( 'title' => $item->get_title(), 'date' => $item->get_date( 'U' ), 'link' => $item->get_permalink(), ); } set_transient( 'themeisle_sdk_feed_items', $items_normalized, 48 * HOUR_IN_SECONDS ); } $this->items = $items_normalized; }
[ "private", "function", "setup_feeds", "(", ")", "{", "if", "(", "false", "===", "(", "$", "items_normalized", "=", "get_transient", "(", "'themeisle_sdk_feed_items'", ")", ")", ")", "{", "// Load SimplePie Instance.", "$", "feed", "=", "fetch_feed", "(", "$", ...
Setup feed items.
[ "Setup", "feed", "items", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L305-L325
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.remove_current_products
public function remove_current_products( $val ) { if ( 'theme' === $val['type'] ) { $exist = wp_get_theme( $val['slug'] ); return ! $exist->exists(); } else { $all_plugins = array_keys( get_plugins() ); foreach ( $all_plugins as $slug ) { if ( strpos( $slug, $val['slug'] ) !== false ) { return false; } } return true; } }
php
public function remove_current_products( $val ) { if ( 'theme' === $val['type'] ) { $exist = wp_get_theme( $val['slug'] ); return ! $exist->exists(); } else { $all_plugins = array_keys( get_plugins() ); foreach ( $all_plugins as $slug ) { if ( strpos( $slug, $val['slug'] ) !== false ) { return false; } } return true; } }
[ "public", "function", "remove_current_products", "(", "$", "val", ")", "{", "if", "(", "'theme'", "===", "$", "val", "[", "'type'", "]", ")", "{", "$", "exist", "=", "wp_get_theme", "(", "$", "val", "[", "'slug'", "]", ")", ";", "return", "!", "$", ...
Either the current product is installed or not. @param array $val The current recommended product. @return bool Either we should exclude the plugin or not.
[ "Either", "the", "current", "product", "is", "installed", "or", "not", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L334-L349
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.get_product_from_api
function get_product_from_api() { if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { $products = array(); $all_themes = $this->get_themes_from_wporg( 'themeisle' ); $all_plugins = $this->get_plugins_from_wporg( 'themeisle' ); static $allowed_products = [ 'hestia' => true, 'neve' => true, 'visualizer' => true, 'feedzy-rss-feeds' => true, 'wp-product-review' => true, 'otter-blocks' => true, 'themeisle-companion' => true, ]; foreach ( $all_themes as $theme ) { if ( $theme->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $theme->slug ] ) ) { continue; } $products[] = array( 'name' => $theme->name, 'type' => 'theme', 'slug' => $theme->slug, 'installs' => $theme->active_installs, ); } foreach ( $all_plugins as $plugin ) { if ( $plugin->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $plugin->slug ] ) ) { continue; } $products[] = array( 'name' => $plugin->name, 'type' => 'plugin', 'slug' => $plugin->slug, 'installs' => $plugin->active_installs, ); } set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS ); } return $products; }
php
function get_product_from_api() { if ( false === ( $products = get_transient( 'themeisle_sdk_products' ) ) ) { $products = array(); $all_themes = $this->get_themes_from_wporg( 'themeisle' ); $all_plugins = $this->get_plugins_from_wporg( 'themeisle' ); static $allowed_products = [ 'hestia' => true, 'neve' => true, 'visualizer' => true, 'feedzy-rss-feeds' => true, 'wp-product-review' => true, 'otter-blocks' => true, 'themeisle-companion' => true, ]; foreach ( $all_themes as $theme ) { if ( $theme->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $theme->slug ] ) ) { continue; } $products[] = array( 'name' => $theme->name, 'type' => 'theme', 'slug' => $theme->slug, 'installs' => $theme->active_installs, ); } foreach ( $all_plugins as $plugin ) { if ( $plugin->active_installs < 4999 ) { continue; } if ( ! isset( $allowed_products[ $plugin->slug ] ) ) { continue; } $products[] = array( 'name' => $plugin->name, 'type' => 'plugin', 'slug' => $plugin->slug, 'installs' => $plugin->active_installs, ); } set_transient( 'themeisle_sdk_products', $products, 6 * HOUR_IN_SECONDS ); } return $products; }
[ "function", "get_product_from_api", "(", ")", "{", "if", "(", "false", "===", "(", "$", "products", "=", "get_transient", "(", "'themeisle_sdk_products'", ")", ")", ")", "{", "$", "products", "=", "array", "(", ")", ";", "$", "all_themes", "=", "$", "thi...
Fetch products from the recomended section. @return array|mixed The list of products to use in recomended section.
[ "Fetch", "products", "from", "the", "recomended", "section", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L375-L421
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.get_themes_from_wporg
function get_themes_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->themes ) ? $products->themes : array(); } else { $products = array(); } return (array) $products; }
php
function get_themes_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]=' . $author . '&request[per_page]=30&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->themes ) ? $products->themes : array(); } else { $products = array(); } return (array) $products; }
[ "function", "get_themes_from_wporg", "(", "$", "author", ")", "{", "$", "products", "=", "wp_remote_get", "(", "'https://api.wordpress.org/themes/info/1.1/?action=query_themes&request[author]='", ".", "$", "author", ".", "'&request[per_page]=30&request[fields][active_installs]=true...
Fetch themes from wporg api. @param string $author The author name. @return array The list of themes.
[ "Fetch", "themes", "from", "wporg", "api", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L430-L442
train
Codeinwp/themeisle-sdk
src/Modules/Dashboard_widget.php
Dashboard_Widget.get_plugins_from_wporg
function get_plugins_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->plugins ) ? $products->plugins : array(); } else { $products = array(); } return (array) $products; }
php
function get_plugins_from_wporg( $author ) { $products = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]=' . $author . '&request[per_page]=40&request[fields][active_installs]=true' ); $products = json_decode( wp_remote_retrieve_body( $products ) ); if ( is_object( $products ) ) { $products = isset( $products->plugins ) ? $products->plugins : array(); } else { $products = array(); } return (array) $products; }
[ "function", "get_plugins_from_wporg", "(", "$", "author", ")", "{", "$", "products", "=", "wp_remote_get", "(", "'https://api.wordpress.org/plugins/info/1.1/?action=query_plugins&request[author]='", ".", "$", "author", ".", "'&request[per_page]=40&request[fields][active_installs]=t...
Fetch plugin from wporg api. @param string $author The author slug. @return array The list of plugins for the selected author.
[ "Fetch", "plugin", "from", "wporg", "api", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Dashboard_widget.php#L451-L463
train
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.load_resources
function load_resources() { add_thickbox(); $id = $this->product->get_key() . '_deactivate'; $this->add_css( $this->product->get_type(), $this->product->get_key() ); $this->add_js( $this->product->get_type(), $this->product->get_key(), '#TB_inline?' . apply_filters( $this->product->get_key() . '_feedback_deactivate_attributes', 'width=600&height=550' ) . '&inlineId=' . $id ); echo '<div id="' . $id . '" style="display:none;" class="themeisle-deactivate-box">' . $this->get_html( $this->product->get_type(), $this->product->get_key() ) . '</div>'; }
php
function load_resources() { add_thickbox(); $id = $this->product->get_key() . '_deactivate'; $this->add_css( $this->product->get_type(), $this->product->get_key() ); $this->add_js( $this->product->get_type(), $this->product->get_key(), '#TB_inline?' . apply_filters( $this->product->get_key() . '_feedback_deactivate_attributes', 'width=600&height=550' ) . '&inlineId=' . $id ); echo '<div id="' . $id . '" style="display:none;" class="themeisle-deactivate-box">' . $this->get_html( $this->product->get_type(), $this->product->get_key() ) . '</div>'; }
[ "function", "load_resources", "(", ")", "{", "add_thickbox", "(", ")", ";", "$", "id", "=", "$", "this", "->", "product", "->", "get_key", "(", ")", ".", "'_deactivate'", ";", "$", "this", "->", "add_css", "(", "$", "this", "->", "product", "->", "ge...
Loads the additional resources
[ "Loads", "the", "additional", "resources" ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L129-L138
train
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.randomize_options
function randomize_options( $options ) { $new = array(); $keys = array_keys( $options ); shuffle( $keys ); foreach ( $keys as $key ) { $new[ $key ] = $options[ $key ]; } return $new; }
php
function randomize_options( $options ) { $new = array(); $keys = array_keys( $options ); shuffle( $keys ); foreach ( $keys as $key ) { $new[ $key ] = $options[ $key ]; } return $new; }
[ "function", "randomize_options", "(", "$", "options", ")", "{", "$", "new", "=", "array", "(", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "options", ")", ";", "shuffle", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", ...
Randomizes the options array. @param array $options The options array.
[ "Randomizes", "the", "options", "array", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L604-L614
train
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.post_deactivate
function post_deactivate() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $this->post_deactivate_or_cancel(); if ( empty( $_POST['id'] ) ) { wp_send_json( [] ); return; } $this->call_api( array( 'type' => 'deactivate', 'id' => $_POST['id'], 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', ) ); wp_send_json( [] ); }
php
function post_deactivate() { check_ajax_referer( (string) __CLASS__, 'nonce' ); $this->post_deactivate_or_cancel(); if ( empty( $_POST['id'] ) ) { wp_send_json( [] ); return; } $this->call_api( array( 'type' => 'deactivate', 'id' => $_POST['id'], 'comment' => isset( $_POST['msg'] ) ? $_POST['msg'] : '', ) ); wp_send_json( [] ); }
[ "function", "post_deactivate", "(", ")", "{", "check_ajax_referer", "(", "(", "string", ")", "__CLASS__", ",", "'nonce'", ")", ";", "$", "this", "->", "post_deactivate_or_cancel", "(", ")", ";", "if", "(", "empty", "(", "$", "_POST", "[", "'id'", "]", ")...
Called when the deactivate button is clicked.
[ "Called", "when", "the", "deactivate", "button", "is", "clicked", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L619-L639
train
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.can_load
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) { return false; } if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return true; } global $pagenow; if ( ! isset( $pagenow ) || empty( $pagenow ) ) { return false; } if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) { return false; } if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) { return false; } return true; }
php
public function can_load( $product ) { if ( $this->is_from_partner( $product ) ) { return false; } if ( $product->is_theme() && ( false !== get_transient( 'ti_sdk_pause_' . $product->get_key(), false ) ) ) { return false; } if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { return true; } global $pagenow; if ( ! isset( $pagenow ) || empty( $pagenow ) ) { return false; } if ( $product->is_plugin() && 'plugins.php' !== $pagenow ) { return false; } if ( $product->is_theme() && 'theme-install.php' !== $pagenow ) { return false; } return true; }
[ "public", "function", "can_load", "(", "$", "product", ")", "{", "if", "(", "$", "this", "->", "is_from_partner", "(", "$", "product", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "product", "->", "is_theme", "(", ")", "&&", "(", "fa...
Should we load this object?. @param Product $product Product object. @return bool Should we load the module?
[ "Should", "we", "load", "this", "object?", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L686-L712
train
Codeinwp/themeisle-sdk
src/Modules/Uninstall_feedback.php
Uninstall_Feedback.load
public function load( $product ) { $this->product = $product; add_action( 'admin_head', array( $this, 'load_resources' ) ); add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) ); return $this; }
php
public function load( $product ) { $this->product = $product; add_action( 'admin_head', array( $this, 'load_resources' ) ); add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) ); return $this; }
[ "public", "function", "load", "(", "$", "product", ")", "{", "$", "this", "->", "product", "=", "$", "product", ";", "add_action", "(", "'admin_head'", ",", "array", "(", "$", "this", ",", "'load_resources'", ")", ")", ";", "add_action", "(", "'wp_ajax_'...
Loads module hooks. @param Product $product Product details. @return Uninstall_Feedback Current module instance.
[ "Loads", "module", "hooks", "." ]
7ead6c057d783ea6c827d5b5de52a25c0e72de58
https://github.com/Codeinwp/themeisle-sdk/blob/7ead6c057d783ea6c827d5b5de52a25c0e72de58/src/Modules/Uninstall_feedback.php#L721-L727
train
TypiCMS/Core
src/Commands/Create.php
Create.renameModelsAndRepositories
public function renameModelsAndRepositories() { $moduleDir = base_path('Modules/'.$this->module); $paths = [ $moduleDir.'/Models/Object.php', $moduleDir.'/Facades/Objects.php', $moduleDir.'/Repositories/EloquentObject.php', $moduleDir.'/resources/scss/public/_object.scss', $moduleDir.'/resources/scss/public/_object-list.scss', ]; foreach ($paths as $path) { $this->files->move($path, $this->transformFilename($path)); } }
php
public function renameModelsAndRepositories() { $moduleDir = base_path('Modules/'.$this->module); $paths = [ $moduleDir.'/Models/Object.php', $moduleDir.'/Facades/Objects.php', $moduleDir.'/Repositories/EloquentObject.php', $moduleDir.'/resources/scss/public/_object.scss', $moduleDir.'/resources/scss/public/_object-list.scss', ]; foreach ($paths as $path) { $this->files->move($path, $this->transformFilename($path)); } }
[ "public", "function", "renameModelsAndRepositories", "(", ")", "{", "$", "moduleDir", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ")", ";", "$", "paths", "=", "[", "$", "moduleDir", ".", "'/Models/Object.php'", ",", "$", "moduleDir...
Rename models and repositories.
[ "Rename", "models", "and", "repositories", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L139-L152
train
TypiCMS/Core
src/Commands/Create.php
Create.publishViews
public function publishViews() { $from = base_path('Modules/'.$this->module.'/resources/views'); $to = resource_path('views/vendor/'.strtolower($this->module)); $this->publishDirectory($from, $to); }
php
public function publishViews() { $from = base_path('Modules/'.$this->module.'/resources/views'); $to = resource_path('views/vendor/'.strtolower($this->module)); $this->publishDirectory($from, $to); }
[ "public", "function", "publishViews", "(", ")", "{", "$", "from", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ".", "'/resources/views'", ")", ";", "$", "to", "=", "resource_path", "(", "'views/vendor/'", ".", "strtolower", "(", "...
Publish views.
[ "Publish", "views", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L157-L162
train
TypiCMS/Core
src/Commands/Create.php
Create.publishScssFiles
public function publishScssFiles() { $from = base_path('Modules/'.$this->module.'/resources/scss/public'); $to = resource_path('scss/public'); $this->publishDirectory($from, $to); }
php
public function publishScssFiles() { $from = base_path('Modules/'.$this->module.'/resources/scss/public'); $to = resource_path('scss/public'); $this->publishDirectory($from, $to); }
[ "public", "function", "publishScssFiles", "(", ")", "{", "$", "from", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ".", "'/resources/scss/public'", ")", ";", "$", "to", "=", "resource_path", "(", "'scss/public'", ")", ";", "$", "t...
Publish scss files.
[ "Publish", "scss", "files", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L167-L172
train
TypiCMS/Core
src/Commands/Create.php
Create.moveMigrationFile
public function moveMigrationFile() { $from = base_path('Modules/'.$this->module.'/database/migrations/2016_01_04_225000_create_objects_table.php'); $to = base_path('database/migrations/'.date('Y_m_d_His').'_create_'.strtolower($this->module).'_table.php'); $this->files->move($from, $to); }
php
public function moveMigrationFile() { $from = base_path('Modules/'.$this->module.'/database/migrations/2016_01_04_225000_create_objects_table.php'); $to = base_path('database/migrations/'.date('Y_m_d_His').'_create_'.strtolower($this->module).'_table.php'); $this->files->move($from, $to); }
[ "public", "function", "moveMigrationFile", "(", ")", "{", "$", "from", "=", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ".", "'/database/migrations/2016_01_04_225000_create_objects_table.php'", ")", ";", "$", "to", "=", "base_path", "(", "'da...
Rename and move migration file.
[ "Rename", "and", "move", "migration", "file", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L177-L182
train
TypiCMS/Core
src/Commands/Create.php
Create.transformFilename
public function transformFilename($path) { $pathTransformed = str_replace('object', strtolower(Str::singular($this->module)), $path); $pathTransformed = str_replace('Object', Str::singular($this->module), $pathTransformed); return $pathTransformed; }
php
public function transformFilename($path) { $pathTransformed = str_replace('object', strtolower(Str::singular($this->module)), $path); $pathTransformed = str_replace('Object', Str::singular($this->module), $pathTransformed); return $pathTransformed; }
[ "public", "function", "transformFilename", "(", "$", "path", ")", "{", "$", "pathTransformed", "=", "str_replace", "(", "'object'", ",", "strtolower", "(", "Str", "::", "singular", "(", "$", "this", "->", "module", ")", ")", ",", "$", "path", ")", ";", ...
Rename file in path. @param string $path @return string
[ "Rename", "file", "in", "path", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L209-L215
train
TypiCMS/Core
src/Commands/Create.php
Create.moduleExists
public function moduleExists() { $location1 = $this->files->isDirectory(base_path('Modules/'.$this->module)); $location2 = $this->files->isDirectory(base_path('vendor/typicms/'.strtolower($this->module))); return $location1 || $location2; }
php
public function moduleExists() { $location1 = $this->files->isDirectory(base_path('Modules/'.$this->module)); $location2 = $this->files->isDirectory(base_path('vendor/typicms/'.strtolower($this->module))); return $location1 || $location2; }
[ "public", "function", "moduleExists", "(", ")", "{", "$", "location1", "=", "$", "this", "->", "files", "->", "isDirectory", "(", "base_path", "(", "'Modules/'", ".", "$", "this", "->", "module", ")", ")", ";", "$", "location2", "=", "$", "this", "->",...
Check if the module exists. @return bool
[ "Check", "if", "the", "module", "exists", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Create.php#L277-L283
train
TypiCMS/Core
src/Commands/Database.php
Database.getKeyFile
protected function getKeyFile() { return $this->files->exists('.env') ? $this->files->get('.env') : $this->files->get('.env.example'); }
php
protected function getKeyFile() { return $this->files->exists('.env') ? $this->files->get('.env') : $this->files->get('.env.example'); }
[ "protected", "function", "getKeyFile", "(", ")", "{", "return", "$", "this", "->", "files", "->", "exists", "(", "'.env'", ")", "?", "$", "this", "->", "files", "->", "get", "(", "'.env'", ")", ":", "$", "this", "->", "files", "->", "get", "(", "'....
Get the key file and return its content. @return string
[ "Get", "the", "key", "file", "and", "return", "its", "content", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Database.php#L140-L143
train
TypiCMS/Core
src/Http/Controllers/BaseAdminController.php
BaseAdminController.redirect
protected function redirect($request, $model) { if (is_array($model)) { $model = end($model); } $redirectUrl = $request->get('exit') ? $model->indexUrl() : $model->editUrl(); return redirect($redirectUrl); }
php
protected function redirect($request, $model) { if (is_array($model)) { $model = end($model); } $redirectUrl = $request->get('exit') ? $model->indexUrl() : $model->editUrl(); return redirect($redirectUrl); }
[ "protected", "function", "redirect", "(", "$", "request", ",", "$", "model", ")", "{", "if", "(", "is_array", "(", "$", "model", ")", ")", "{", "$", "model", "=", "end", "(", "$", "model", ")", ";", "}", "$", "redirectUrl", "=", "$", "request", "...
Redirect after a form is saved. @param $request @param $model @return \Illuminate\Http\RedirectResponse
[ "Redirect", "after", "a", "form", "is", "saved", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Http/Controllers/BaseAdminController.php#L25-L33
train
TypiCMS/Core
src/Models/Base.php
Base.scopePublished
public function scopePublished(Builder $query) { $field = 'status'; if (in_array($field, (array) $this->translatable)) { $field .= '->'.config('app.locale'); } return $query->where($field, '1'); }
php
public function scopePublished(Builder $query) { $field = 'status'; if (in_array($field, (array) $this->translatable)) { $field .= '->'.config('app.locale'); } return $query->where($field, '1'); }
[ "public", "function", "scopePublished", "(", "Builder", "$", "query", ")", "{", "$", "field", "=", "'status'", ";", "if", "(", "in_array", "(", "$", "field", ",", "(", "array", ")", "$", "this", "->", "translatable", ")", ")", "{", "$", "field", ".="...
Get published models. @param Builder $query @return Builder $query
[ "Get", "published", "models", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Models/Base.php#L51-L59
train
TypiCMS/Core
src/Models/Base.php
Base.scopeOrder
public function scopeOrder(Builder $query) { if ($order = config('typicms.'.$this->getTable().'.order')) { foreach ($order as $column => $direction) { $query->orderBy($column, $direction); } } return $query; }
php
public function scopeOrder(Builder $query) { if ($order = config('typicms.'.$this->getTable().'.order')) { foreach ($order as $column => $direction) { $query->orderBy($column, $direction); } } return $query; }
[ "public", "function", "scopeOrder", "(", "Builder", "$", "query", ")", "{", "if", "(", "$", "order", "=", "config", "(", "'typicms.'", ".", "$", "this", "->", "getTable", "(", ")", ".", "'.order'", ")", ")", "{", "foreach", "(", "$", "order", "as", ...
Order items. @param Builder $query @return Builder $query
[ "Order", "items", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Models/Base.php#L68-L77
train
TypiCMS/Core
src/Observers/FileObserver.php
FileObserver.deleted
public function deleted(Model $model) { try { Croppa::delete('storage/'.$model->getOriginal('path')); } catch (Exception $e) { Log::error($e->getMessage()); } }
php
public function deleted(Model $model) { try { Croppa::delete('storage/'.$model->getOriginal('path')); } catch (Exception $e) { Log::error($e->getMessage()); } }
[ "public", "function", "deleted", "(", "Model", "$", "model", ")", "{", "try", "{", "Croppa", "::", "delete", "(", "'storage/'", ".", "$", "model", "->", "getOriginal", "(", "'path'", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", ...
On delete, unlink files and thumbs. @param Model $model eloquent @return mixed false or void
[ "On", "delete", "unlink", "files", "and", "thumbs", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Observers/FileObserver.php#L28-L35
train
TypiCMS/Core
src/Observers/FileObserver.php
FileObserver.creating
public function creating(Model $model) { if (request()->hasFile('name')) { // delete prev image $file = $this->fileUploader->handle(request()->file('name')); $model->name = $file['filename']; $model->fill(Arr::except($file, 'filename')); } else { if ($model->type !== 'f') { return false; } } }
php
public function creating(Model $model) { if (request()->hasFile('name')) { // delete prev image $file = $this->fileUploader->handle(request()->file('name')); $model->name = $file['filename']; $model->fill(Arr::except($file, 'filename')); } else { if ($model->type !== 'f') { return false; } } }
[ "public", "function", "creating", "(", "Model", "$", "model", ")", "{", "if", "(", "request", "(", ")", "->", "hasFile", "(", "'name'", ")", ")", "{", "// delete prev image", "$", "file", "=", "$", "this", "->", "fileUploader", "->", "handle", "(", "re...
On save, upload files. @param Model $model eloquent @return mixed false or void
[ "On", "save", "upload", "files", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Observers/FileObserver.php#L44-L56
train
TypiCMS/Core
src/Providers/ModuleProvider.php
ModuleProvider.registerModuleRoutes
private function registerModuleRoutes() { $this->app->singleton('typicms.routes', function (Application $app) { try { return $app->make('Pages')->with('files')->getForRoutes(); } catch (Exception $e) { return []; } }); }
php
private function registerModuleRoutes() { $this->app->singleton('typicms.routes', function (Application $app) { try { return $app->make('Pages')->with('files')->getForRoutes(); } catch (Exception $e) { return []; } }); }
[ "private", "function", "registerModuleRoutes", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'typicms.routes'", ",", "function", "(", "Application", "$", "app", ")", "{", "try", "{", "return", "$", "app", "->", "make", "(", "'Pages'", ...
Get routes from pages. @return array
[ "Get", "routes", "from", "pages", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Providers/ModuleProvider.php#L153-L162
train
TypiCMS/Core
src/Observers/SlugObserver.php
SlugObserver.slugExists
private function slugExists(Model $model, $locale) { $query = $model::where('slug->'.$locale, $model->getTranslation('slug', $locale)); if ($model->id) { $query->where('id', '!=', $model->id); } return (bool) $query->count(); }
php
private function slugExists(Model $model, $locale) { $query = $model::where('slug->'.$locale, $model->getTranslation('slug', $locale)); if ($model->id) { $query->where('id', '!=', $model->id); } return (bool) $query->count(); }
[ "private", "function", "slugExists", "(", "Model", "$", "model", ",", "$", "locale", ")", "{", "$", "query", "=", "$", "model", "::", "where", "(", "'slug->'", ".", "$", "locale", ",", "$", "model", "->", "getTranslation", "(", "'slug'", ",", "$", "l...
Search for item with same slug. @param mixed $model @return bool
[ "Search", "for", "item", "with", "same", "slug", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Observers/SlugObserver.php#L40-L48
train
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.enabledLocales
public function enabledLocales() { $locales = []; foreach (locales() as $locale) { if (config('typicms.'.$locale.'.status')) { $locales[] = $locale; } } return $locales; }
php
public function enabledLocales() { $locales = []; foreach (locales() as $locale) { if (config('typicms.'.$locale.'.status')) { $locales[] = $locale; } } return $locales; }
[ "public", "function", "enabledLocales", "(", ")", "{", "$", "locales", "=", "[", "]", ";", "foreach", "(", "locales", "(", ")", "as", "$", "locale", ")", "{", "if", "(", "config", "(", "'typicms.'", ".", "$", "locale", ".", "'.status'", ")", ")", "...
Return enabled public locales. @return array
[ "Return", "enabled", "public", "locales", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L31-L41
train
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.permissions
public function permissions() { $permissions = []; foreach (config('typicms.permissions') as $module => $perms) { $key = __(ucfirst($module)); $permissions[$key] = $perms; } ksort($permissions, SORT_LOCALE_STRING); return $permissions; }
php
public function permissions() { $permissions = []; foreach (config('typicms.permissions') as $module => $perms) { $key = __(ucfirst($module)); $permissions[$key] = $perms; } ksort($permissions, SORT_LOCALE_STRING); return $permissions; }
[ "public", "function", "permissions", "(", ")", "{", "$", "permissions", "=", "[", "]", ";", "foreach", "(", "config", "(", "'typicms.permissions'", ")", "as", "$", "module", "=>", "$", "perms", ")", "{", "$", "key", "=", "__", "(", "ucfirst", "(", "$...
Get all permissions registered. @return array
[ "Get", "all", "permissions", "registered", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L90-L100
train
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.getPagesLinkedToModule
public function getPagesLinkedToModule($module = null) { $module = strtolower($module); $routes = app('typicms.routes'); $pages = []; foreach ($routes as $page) { if ($page->module == $module) { $pages[] = $page; } } return $pages; }
php
public function getPagesLinkedToModule($module = null) { $module = strtolower($module); $routes = app('typicms.routes'); $pages = []; foreach ($routes as $page) { if ($page->module == $module) { $pages[] = $page; } } return $pages; }
[ "public", "function", "getPagesLinkedToModule", "(", "$", "module", "=", "null", ")", "{", "$", "module", "=", "strtolower", "(", "$", "module", ")", ";", "$", "routes", "=", "app", "(", "'typicms.routes'", ")", ";", "$", "pages", "=", "[", "]", ";", ...
Return an array of pages linked to a module. @param string $module @return array
[ "Return", "an", "array", "of", "pages", "linked", "to", "a", "module", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L153-L166
train
TypiCMS/Core
src/Services/TypiCMS.php
TypiCMS.templates
public function templates() { try { $directory = $this->getTemplateDir(); $files = File::files($directory); } catch (Exception $e) { $files = File::files(base_path('vendor/typicms/pages/src/resources/views/public')); } $templates = []; foreach ($files as $file) { $filename = File::name($file); if ($filename === 'default.blade') { continue; } $name = str_replace('.blade', '', $filename); if ($name[0] != '_' && $name != 'master') { $templates[$name] = ucfirst($name); } } return ['' => 'Default'] + $templates; }
php
public function templates() { try { $directory = $this->getTemplateDir(); $files = File::files($directory); } catch (Exception $e) { $files = File::files(base_path('vendor/typicms/pages/src/resources/views/public')); } $templates = []; foreach ($files as $file) { $filename = File::name($file); if ($filename === 'default.blade') { continue; } $name = str_replace('.blade', '', $filename); if ($name[0] != '_' && $name != 'master') { $templates[$name] = ucfirst($name); } } return ['' => 'Default'] + $templates; }
[ "public", "function", "templates", "(", ")", "{", "try", "{", "$", "directory", "=", "$", "this", "->", "getTemplateDir", "(", ")", ";", "$", "files", "=", "File", "::", "files", "(", "$", "directory", ")", ";", "}", "catch", "(", "Exception", "$", ...
List templates files from directory. @return array
[ "List", "templates", "files", "from", "directory", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/TypiCMS.php#L173-L194
train
TypiCMS/Core
src/Services/FileUploader.php
FileUploader.handle
public function handle(UploadedFile $file, $path = 'files') { $filesize = $file->getClientSize(); $mimetype = $file->getClientMimeType(); $extension = strtolower($file->getClientOriginalExtension()); $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)); $filename = $fileName.'.'.$extension; list($width, $height) = getimagesize($file); $filecounter = 1; while (Storage::has($path.'/'.$filename)) { $filename = $fileName.'_'.$filecounter++.'.'.$extension; } $path = $file->storeAs($path, $filename); $type = Arr::get(config('file.types'), $extension, 'd'); return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type'); }
php
public function handle(UploadedFile $file, $path = 'files') { $filesize = $file->getClientSize(); $mimetype = $file->getClientMimeType(); $extension = strtolower($file->getClientOriginalExtension()); $fileName = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)); $filename = $fileName.'.'.$extension; list($width, $height) = getimagesize($file); $filecounter = 1; while (Storage::has($path.'/'.$filename)) { $filename = $fileName.'_'.$filecounter++.'.'.$extension; } $path = $file->storeAs($path, $filename); $type = Arr::get(config('file.types'), $extension, 'd'); return compact('filesize', 'mimetype', 'extension', 'filename', 'width', 'height', 'path', 'type'); }
[ "public", "function", "handle", "(", "UploadedFile", "$", "file", ",", "$", "path", "=", "'files'", ")", "{", "$", "filesize", "=", "$", "file", "->", "getClientSize", "(", ")", ";", "$", "mimetype", "=", "$", "file", "->", "getClientMimeType", "(", ")...
Handle the file upload. Returns the array on success, or false on failure. @param \Symfony\Component\HttpFoundation\File\UploadedFile $file @param string $path where to upload file @return array|bool
[ "Handle", "the", "file", "upload", ".", "Returns", "the", "array", "on", "success", "or", "false", "on", "failure", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/FileUploader.php#L21-L38
train
TypiCMS/Core
src/Http/Controllers/LocaleController.php
LocaleController.setContentLocale
public function setContentLocale($locale) { Session::put('allLocalesInForm', false); if ($locale === 'all') { Session::put('allLocalesInForm', true); } else { Session::put('locale', $locale); } }
php
public function setContentLocale($locale) { Session::put('allLocalesInForm', false); if ($locale === 'all') { Session::put('allLocalesInForm', true); } else { Session::put('locale', $locale); } }
[ "public", "function", "setContentLocale", "(", "$", "locale", ")", "{", "Session", "::", "put", "(", "'allLocalesInForm'", ",", "false", ")", ";", "if", "(", "$", "locale", "===", "'all'", ")", "{", "Session", "::", "put", "(", "'allLocalesInForm'", ",", ...
Change content locale. @return null
[ "Change", "content", "locale", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Http/Controllers/LocaleController.php#L14-L22
train
TypiCMS/Core
src/Services/Dates.php
Dates.concat
public static function concat($startingDate, $endingDate) { $startingDateArray = explode('-', $startingDate); $endingDateArray = explode('-', $endingDate); $endingDateFormat = '%A %d %B %Y'; if ($startingDate == $endingDate) { $startingDateFormat = '%A %d %B %Y'; return Carbon::createFromFormat('Y-m-d', $startingDate)->formatLocalized($startingDateFormat); } if ($startingDateArray[1] == $endingDateArray[1]) { // mois égaux $startingDateFormat = '%A %d'; } elseif ($startingDateArray[0] == $endingDateArray[0]) { // annee égales $startingDateFormat = '%A %d %B'; } else { $startingDateFormat = '%A %d %B %Y'; } return Carbon::createFromFormat('Y-m-d', $startingDate) ->formatLocalized($startingDateFormat).' to '.Carbon::createFromFormat('Y-m-d', $endingDate) ->formatLocalized($endingDateFormat); }
php
public static function concat($startingDate, $endingDate) { $startingDateArray = explode('-', $startingDate); $endingDateArray = explode('-', $endingDate); $endingDateFormat = '%A %d %B %Y'; if ($startingDate == $endingDate) { $startingDateFormat = '%A %d %B %Y'; return Carbon::createFromFormat('Y-m-d', $startingDate)->formatLocalized($startingDateFormat); } if ($startingDateArray[1] == $endingDateArray[1]) { // mois égaux $startingDateFormat = '%A %d'; } elseif ($startingDateArray[0] == $endingDateArray[0]) { // annee égales $startingDateFormat = '%A %d %B'; } else { $startingDateFormat = '%A %d %B %Y'; } return Carbon::createFromFormat('Y-m-d', $startingDate) ->formatLocalized($startingDateFormat).' to '.Carbon::createFromFormat('Y-m-d', $endingDate) ->formatLocalized($endingDateFormat); }
[ "public", "static", "function", "concat", "(", "$", "startingDate", ",", "$", "endingDate", ")", "{", "$", "startingDateArray", "=", "explode", "(", "'-'", ",", "$", "startingDate", ")", ";", "$", "endingDateArray", "=", "explode", "(", "'-'", ",", "$", ...
Concat two dates. @param string $startingDate @param string $endingDate @return string
[ "Concat", "two", "dates", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Services/Dates.php#L17-L42
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.datetimeOrNow
public function datetimeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d\TH:i'); }
php
public function datetimeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d\TH:i'); }
[ "public", "function", "datetimeOrNow", "(", "$", "column", "=", "'date'", ")", "{", "$", "date", "=", "$", "this", "->", "entity", "->", "$", "column", "?", ":", "Carbon", "::", "now", "(", ")", ";", "return", "$", "date", "->", "format", "(", "'Y-...
Return resource's datetime or curent date and time if empty. @param string $column @return Carbon
[ "Return", "resource", "s", "datetime", "or", "curent", "date", "and", "time", "if", "empty", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L76-L81
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.dateOrNow
public function dateOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d'); }
php
public function dateOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('Y-m-d'); }
[ "public", "function", "dateOrNow", "(", "$", "column", "=", "'date'", ")", "{", "$", "date", "=", "$", "this", "->", "entity", "->", "$", "column", "?", ":", "Carbon", "::", "now", "(", ")", ";", "return", "$", "date", "->", "format", "(", "'Y-m-d'...
Return resource's date or curent date if empty. @param string $column @return Carbon
[ "Return", "resource", "s", "date", "or", "curent", "date", "if", "empty", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L90-L95
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.timeOrNow
public function timeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('H:i'); }
php
public function timeOrNow($column = 'date') { $date = $this->entity->$column ?: Carbon::now(); return $date->format('H:i'); }
[ "public", "function", "timeOrNow", "(", "$", "column", "=", "'date'", ")", "{", "$", "date", "=", "$", "this", "->", "entity", "->", "$", "column", "?", ":", "Carbon", "::", "now", "(", ")", ";", "return", "$", "date", "->", "format", "(", "'H:i'",...
Return resource's time or curent time if empty. @param string $column @return Carbon
[ "Return", "resource", "s", "time", "or", "curent", "time", "if", "empty", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L104-L109
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.getImageUrlOrDefault
protected function getImageUrlOrDefault() { $file = ''; if (is_object($this->entity->image)) { $file = $this->entity->image->path; } if (!Storage::exists($file)) { $file = $this->imgNotFound(); } return Storage::url($file); }
php
protected function getImageUrlOrDefault() { $file = ''; if (is_object($this->entity->image)) { $file = $this->entity->image->path; } if (!Storage::exists($file)) { $file = $this->imgNotFound(); } return Storage::url($file); }
[ "protected", "function", "getImageUrlOrDefault", "(", ")", "{", "$", "file", "=", "''", ";", "if", "(", "is_object", "(", "$", "this", "->", "entity", "->", "image", ")", ")", "{", "$", "file", "=", "$", "this", "->", "entity", "->", "image", "->", ...
Get the path of the first image linked to this model or the path to the default image. @return string path
[ "Get", "the", "path", "of", "the", "first", "image", "linked", "to", "this", "model", "or", "the", "path", "to", "the", "default", "image", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L141-L154
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.image
public function image($width = null, $height = null, array $options = []) { $url = $this->getImageUrlOrDefault(); if (pathinfo($url, PATHINFO_EXTENSION) === 'svg') { return $url; } return url(Croppa::url($url, $width, $height, $options)); }
php
public function image($width = null, $height = null, array $options = []) { $url = $this->getImageUrlOrDefault(); if (pathinfo($url, PATHINFO_EXTENSION) === 'svg') { return $url; } return url(Croppa::url($url, $width, $height, $options)); }
[ "public", "function", "image", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "getImageUrlOrDefault", "(", ")", ";", "if", "(", "pathinfo",...
Return src string of a resized or cropped image. @param int $width width of image, null for auto @param int $height height of image, null for auto @param array $options see Croppa doc for options (https://github.com/BKWLD/croppa) @return string
[ "Return", "src", "string", "of", "a", "resized", "or", "cropped", "image", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L165-L174
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.imgNotFound
public function imgNotFound() { $file = 'img-not-found.png'; if (!Storage::exists($file)) { Storage::put($file, File::get(public_path('img/'.$file))); } return $file; }
php
public function imgNotFound() { $file = 'img-not-found.png'; if (!Storage::exists($file)) { Storage::put($file, File::get(public_path('img/'.$file))); } return $file; }
[ "public", "function", "imgNotFound", "(", ")", "{", "$", "file", "=", "'img-not-found.png'", ";", "if", "(", "!", "Storage", "::", "exists", "(", "$", "file", ")", ")", "{", "Storage", "::", "put", "(", "$", "file", ",", "File", "::", "get", "(", "...
Get default image when not found. @return string
[ "Get", "default", "image", "when", "not", "found", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L181-L189
train
TypiCMS/Core
src/Presenters/Presenter.php
Presenter.body
public function body() { $text = $this->entity->body; preg_match_all('/{!! ([a-z]+):([0-9]+) !!}/', $text, $matches, PREG_SET_ORDER); $patterns = []; $replacements = []; $lang = config('app.locale'); if (is_array($matches)) { foreach ($matches as $match) { $patterns[] = $match[0]; $module = $match[1]; $repository = app('TypiCMS\Modules\\'.ucfirst(Str::plural($module)).'\Repositories\Eloquent'.ucfirst($module)); $model = $repository->published()->find($match[2]); if (!$model) { continue; } if ($module == 'page') { $replacements[] = url($model->uri($lang)); } else { if (Route::has($lang.'::'.$module)) { $replacements[] = route($lang.'::'.$module, $model->slug); } else { $replacements[] = ''; } } } } return str_replace($patterns, $replacements, $text); }
php
public function body() { $text = $this->entity->body; preg_match_all('/{!! ([a-z]+):([0-9]+) !!}/', $text, $matches, PREG_SET_ORDER); $patterns = []; $replacements = []; $lang = config('app.locale'); if (is_array($matches)) { foreach ($matches as $match) { $patterns[] = $match[0]; $module = $match[1]; $repository = app('TypiCMS\Modules\\'.ucfirst(Str::plural($module)).'\Repositories\Eloquent'.ucfirst($module)); $model = $repository->published()->find($match[2]); if (!$model) { continue; } if ($module == 'page') { $replacements[] = url($model->uri($lang)); } else { if (Route::has($lang.'::'.$module)) { $replacements[] = route($lang.'::'.$module, $model->slug); } else { $replacements[] = ''; } } } } return str_replace($patterns, $replacements, $text); }
[ "public", "function", "body", "(", ")", "{", "$", "text", "=", "$", "this", "->", "entity", "->", "body", ";", "preg_match_all", "(", "'/{!! ([a-z]+):([0-9]+) !!}/'", ",", "$", "text", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "$", "patterns", ...
Return body content with dynamic links. @return string
[ "Return", "body", "content", "with", "dynamic", "links", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Presenters/Presenter.php#L196-L225
train
TypiCMS/Core
src/Commands/Install.php
Install.guessDatabaseName
public function guessDatabaseName() { try { $segments = array_reverse(explode(DIRECTORY_SEPARATOR, app_path())); $name = explode('.', $segments[1])[0]; return Str::slug($name); } catch (Exception $e) { return ''; } }
php
public function guessDatabaseName() { try { $segments = array_reverse(explode(DIRECTORY_SEPARATOR, app_path())); $name = explode('.', $segments[1])[0]; return Str::slug($name); } catch (Exception $e) { return ''; } }
[ "public", "function", "guessDatabaseName", "(", ")", "{", "try", "{", "$", "segments", "=", "array_reverse", "(", "explode", "(", "DIRECTORY_SEPARATOR", ",", "app_path", "(", ")", ")", ")", ";", "$", "name", "=", "explode", "(", "'.'", ",", "$", "segment...
Guess database name from app folder. @return string
[ "Guess", "database", "name", "from", "app", "folder", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Install.php#L101-L111
train
TypiCMS/Core
src/Commands/Install.php
Install.createSuperUser
private function createSuperUser() { $this->info('Creating a Super User...'); $firstname = $this->ask('Enter your first name'); $lastname = $this->ask('Enter your last name'); $email = $this->ask('Enter your email address'); $password = $this->secret('Enter a password'); $data = [ 'first_name' => $firstname, 'last_name' => $lastname, 'email' => $email, 'superuser' => 1, 'activated' => 1, 'password' => Hash::make($password), 'email_verified_at' => Carbon::now(), ]; try { User::create($data); $this->info('Superuser created.'); } catch (Exception $e) { $this->error('User could not be created.'); } $this->line('------------------'); }
php
private function createSuperUser() { $this->info('Creating a Super User...'); $firstname = $this->ask('Enter your first name'); $lastname = $this->ask('Enter your last name'); $email = $this->ask('Enter your email address'); $password = $this->secret('Enter a password'); $data = [ 'first_name' => $firstname, 'last_name' => $lastname, 'email' => $email, 'superuser' => 1, 'activated' => 1, 'password' => Hash::make($password), 'email_verified_at' => Carbon::now(), ]; try { User::create($data); $this->info('Superuser created.'); } catch (Exception $e) { $this->error('User could not be created.'); } $this->line('------------------'); }
[ "private", "function", "createSuperUser", "(", ")", "{", "$", "this", "->", "info", "(", "'Creating a Super User...'", ")", ";", "$", "firstname", "=", "$", "this", "->", "ask", "(", "'Enter your first name'", ")", ";", "$", "lastname", "=", "$", "this", "...
Create a superuser.
[ "Create", "a", "superuser", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Install.php#L116-L143
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.next
public function next($model, $category_id = null, array $with = [], $all = false) { return $this->adjacent(1, $model, $category_id, $with, $all); }
php
public function next($model, $category_id = null, array $with = [], $all = false) { return $this->adjacent(1, $model, $category_id, $with, $all); }
[ "public", "function", "next", "(", "$", "model", ",", "$", "category_id", "=", "null", ",", "array", "$", "with", "=", "[", "]", ",", "$", "all", "=", "false", ")", "{", "return", "$", "this", "->", "adjacent", "(", "1", ",", "$", "model", ",", ...
Get next model. @param Model $model @param int $category_id @param array $with @param bool $all @return Model|null
[ "Get", "next", "model", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L24-L27
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.adjacent
public function adjacent($direction, $model, $category_id = null, array $with = [], $all = false) { $currentModel = $model; if ($category_id !== null) { $models = $this->with('category')->findWhere(['category_id', $category_id], ['id', 'category_id', 'slug']); } else { $models = $this->all(['id', 'slug']); } foreach ($models as $key => $model) { if ($currentModel->id == $model->id) { $adjacentKey = $key + $direction; return isset($models[$adjacentKey]) ? $models[$adjacentKey] : null; } } }
php
public function adjacent($direction, $model, $category_id = null, array $with = [], $all = false) { $currentModel = $model; if ($category_id !== null) { $models = $this->with('category')->findWhere(['category_id', $category_id], ['id', 'category_id', 'slug']); } else { $models = $this->all(['id', 'slug']); } foreach ($models as $key => $model) { if ($currentModel->id == $model->id) { $adjacentKey = $key + $direction; return isset($models[$adjacentKey]) ? $models[$adjacentKey] : null; } } }
[ "public", "function", "adjacent", "(", "$", "direction", ",", "$", "model", ",", "$", "category_id", "=", "null", ",", "array", "$", "with", "=", "[", "]", ",", "$", "all", "=", "false", ")", "{", "$", "currentModel", "=", "$", "model", ";", "if", ...
Get prev model. @param int $direction @param Model $model @param int $category_id @param array $with @param bool $all @return Model|null
[ "Get", "prev", "model", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L55-L70
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.bySlug
public function bySlug($slug, $attributes = ['*']) { if (!request('preview')) { $this->published(); } $model = $this->findBy(column('slug'), $slug, $attributes); if (is_null($model)) { abort(404); } return $model; }
php
public function bySlug($slug, $attributes = ['*']) { if (!request('preview')) { $this->published(); } $model = $this->findBy(column('slug'), $slug, $attributes); if (is_null($model)) { abort(404); } return $model; }
[ "public", "function", "bySlug", "(", "$", "slug", ",", "$", "attributes", "=", "[", "'*'", "]", ")", "{", "if", "(", "!", "request", "(", "'preview'", ")", ")", "{", "$", "this", "->", "published", "(", ")", ";", "}", "$", "model", "=", "$", "t...
Get single model by Slug. @param string $slug @param array $attributes @return mixed
[ "Get", "single", "model", "by", "Slug", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L80-L92
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.allFiltered
public function allFiltered($columns = [], array $with = []) { $params = request()->all(); $data = $this->with($with)->select($columns); $orderBy = $params['orderBy'] ?? null; $query = $params['query'] ?? null; $limit = $params['limit'] ?? null; $page = $params['page'] ?? 1; $ascending = $params['ascending'] ?? 1; $byColumn = $params['byColumn'] ?? 0; if ($query !== null) { $data = $byColumn == 1 ? $this->filterByColumn($data, $query) : $this->filter($data, $query, $columns); } $count = $data->count(); if ($limit !== null) { $data->limit($limit)->skip($limit * ($page - 1)); } if ($orderBy !== null) { $orderBy .= $this->translatableOperator($orderBy); $direction = $ascending == 1 ? 'ASC' : 'DESC'; $data->orderBy($orderBy, $direction); } $results = $data->get() ->translate(config('typicms.content_locale')); return [ 'data' => $results, 'count' => $count, ]; }
php
public function allFiltered($columns = [], array $with = []) { $params = request()->all(); $data = $this->with($with)->select($columns); $orderBy = $params['orderBy'] ?? null; $query = $params['query'] ?? null; $limit = $params['limit'] ?? null; $page = $params['page'] ?? 1; $ascending = $params['ascending'] ?? 1; $byColumn = $params['byColumn'] ?? 0; if ($query !== null) { $data = $byColumn == 1 ? $this->filterByColumn($data, $query) : $this->filter($data, $query, $columns); } $count = $data->count(); if ($limit !== null) { $data->limit($limit)->skip($limit * ($page - 1)); } if ($orderBy !== null) { $orderBy .= $this->translatableOperator($orderBy); $direction = $ascending == 1 ? 'ASC' : 'DESC'; $data->orderBy($orderBy, $direction); } $results = $data->get() ->translate(config('typicms.content_locale')); return [ 'data' => $results, 'count' => $count, ]; }
[ "public", "function", "allFiltered", "(", "$", "columns", "=", "[", "]", ",", "array", "$", "with", "=", "[", "]", ")", "{", "$", "params", "=", "request", "(", ")", "->", "all", "(", ")", ";", "$", "data", "=", "$", "this", "->", "with", "(", ...
Get all models sorted, filtered and paginated. @param array $columns @param array $with @return array
[ "Get", "all", "models", "sorted", "filtered", "and", "paginated", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L200-L235
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.sort
public function sort(array $data) { foreach ($data['item'] as $position => $item) { $page = $this->find($item['id']); $sortData = $this->getSortData($position + 1, $item); $page->update($sortData); if ($data['moved'] == $item['id']) { $this->fireResetChildrenUriEvent($page); } } $this->forgetCache(); }
php
public function sort(array $data) { foreach ($data['item'] as $position => $item) { $page = $this->find($item['id']); $sortData = $this->getSortData($position + 1, $item); $page->update($sortData); if ($data['moved'] == $item['id']) { $this->fireResetChildrenUriEvent($page); } } $this->forgetCache(); }
[ "public", "function", "sort", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "[", "'item'", "]", "as", "$", "position", "=>", "$", "item", ")", "{", "$", "page", "=", "$", "this", "->", "find", "(", "$", "item", "[", "'id'", ...
Sort models. @param array $data updated data @return null
[ "Sort", "models", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L288-L302
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.detachFile
public function detachFile($page, $file) { $filesIds = $page->files->pluck('id')->toArray(); $pivotData = []; $position = 1; foreach ($filesIds as $fileId) { if ($fileId != $file->id) { $pivotData[$fileId] = ['position' => $position++]; } } $page->files()->sync($pivotData); $this->forgetCache(); }
php
public function detachFile($page, $file) { $filesIds = $page->files->pluck('id')->toArray(); $pivotData = []; $position = 1; foreach ($filesIds as $fileId) { if ($fileId != $file->id) { $pivotData[$fileId] = ['position' => $position++]; } } $page->files()->sync($pivotData); $this->forgetCache(); }
[ "public", "function", "detachFile", "(", "$", "page", ",", "$", "file", ")", "{", "$", "filesIds", "=", "$", "page", "->", "files", "->", "pluck", "(", "'id'", ")", "->", "toArray", "(", ")", ";", "$", "pivotData", "=", "[", "]", ";", "$", "posit...
Remove files from model.
[ "Remove", "files", "from", "model", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L307-L319
train
TypiCMS/Core
src/Repositories/EloquentRepository.php
EloquentRepository.attachFiles
public function attachFiles($model, Request $request) { // Get the collection of files to add. $fileIds = $request->only('files')['files']; $files = File::whereIn('id', $fileIds)->get(); // Empty collection that will contain files that are in selected directories. $subFiles = collect(); // Remove folders and build array of ids. $newFiles = $files->each(function (Model $item) use ($subFiles) { if ($item->type === 'f') { foreach ($item->children as $file) { if ($file->type !== 'f') { // Add files in this directory to collection of SubFiles $subFiles->push($file); } } } })->reject(function (Model $item) { return $item->type === 'f'; }) ->pluck('id') ->toArray(); // Transform subfiles collection to array of ids. $subFiles = $subFiles->pluck('id')->toArray(); // Merge files with files in directory. $newFiles = array_merge($newFiles, $subFiles); // Get files that are already in the gallery. $filesIds = $model->files->pluck('id')->toArray(); // Merge with new files. $files = array_unique(array_merge($filesIds, $newFiles)); $number = count($files) - count($filesIds); // Prepare synchronisation. $pivotData = []; $position = 1; foreach ($files as $fileId) { $pivotData[$fileId] = ['position' => $position++]; } // Sync. $model->files()->sync($pivotData); $this->forgetCache(); return response()->json([ 'number' => $number, 'message' => __(':number items were added.', compact('number')), 'models' => $model->files()->get(), ]); }
php
public function attachFiles($model, Request $request) { // Get the collection of files to add. $fileIds = $request->only('files')['files']; $files = File::whereIn('id', $fileIds)->get(); // Empty collection that will contain files that are in selected directories. $subFiles = collect(); // Remove folders and build array of ids. $newFiles = $files->each(function (Model $item) use ($subFiles) { if ($item->type === 'f') { foreach ($item->children as $file) { if ($file->type !== 'f') { // Add files in this directory to collection of SubFiles $subFiles->push($file); } } } })->reject(function (Model $item) { return $item->type === 'f'; }) ->pluck('id') ->toArray(); // Transform subfiles collection to array of ids. $subFiles = $subFiles->pluck('id')->toArray(); // Merge files with files in directory. $newFiles = array_merge($newFiles, $subFiles); // Get files that are already in the gallery. $filesIds = $model->files->pluck('id')->toArray(); // Merge with new files. $files = array_unique(array_merge($filesIds, $newFiles)); $number = count($files) - count($filesIds); // Prepare synchronisation. $pivotData = []; $position = 1; foreach ($files as $fileId) { $pivotData[$fileId] = ['position' => $position++]; } // Sync. $model->files()->sync($pivotData); $this->forgetCache(); return response()->json([ 'number' => $number, 'message' => __(':number items were added.', compact('number')), 'models' => $model->files()->get(), ]); }
[ "public", "function", "attachFiles", "(", "$", "model", ",", "Request", "$", "request", ")", "{", "// Get the collection of files to add.", "$", "fileIds", "=", "$", "request", "->", "only", "(", "'files'", ")", "[", "'files'", "]", ";", "$", "files", "=", ...
Attach files to a model. @param \Illuminate\Database\Eloquent\Model $model @param \Illuminate\Http\Request $request @return null
[ "Attach", "files", "to", "a", "model", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Repositories/EloquentRepository.php#L329-L384
train
TypiCMS/Core
src/Commands/Publish.php
Publish.uninstallFromComposer
private function uninstallFromComposer() { $uninstallCommand = 'composer remove typicms/'.$this->module; if (function_exists('system')) { system($uninstallCommand); } else { $this->line('You can now run '.$uninstallCommand.'.'); } }
php
private function uninstallFromComposer() { $uninstallCommand = 'composer remove typicms/'.$this->module; if (function_exists('system')) { system($uninstallCommand); } else { $this->line('You can now run '.$uninstallCommand.'.'); } }
[ "private", "function", "uninstallFromComposer", "(", ")", "{", "$", "uninstallCommand", "=", "'composer remove typicms/'", ".", "$", "this", "->", "module", ";", "if", "(", "function_exists", "(", "'system'", ")", ")", "{", "system", "(", "$", "uninstallCommand"...
Remove the module from composer.
[ "Remove", "the", "module", "from", "composer", "." ]
6d312499aa1ade5992780d5fb7b66fc62c7b1071
https://github.com/TypiCMS/Core/blob/6d312499aa1ade5992780d5fb7b66fc62c7b1071/src/Commands/Publish.php#L165-L173
train
hiqdev/hipanel-core
src/widgets/Box.php
Box.beginHeader
public function beginHeader() { echo Html::beginTag('div', $this->headerOptions) . "\n"; if ($this->title !== null) { echo Html::tag('h3', $this->title, ['class' => 'box-title']); } if ($this->collapsable) { echo '<div class="box-tools pull-right"> <button class="btn btn-box-tool" data-widget="collapse"> <i class="fa fa-' . ($this->collapsed ? 'plus' : 'minus') . '"></i> </button> </div>'; } }
php
public function beginHeader() { echo Html::beginTag('div', $this->headerOptions) . "\n"; if ($this->title !== null) { echo Html::tag('h3', $this->title, ['class' => 'box-title']); } if ($this->collapsable) { echo '<div class="box-tools pull-right"> <button class="btn btn-box-tool" data-widget="collapse"> <i class="fa fa-' . ($this->collapsed ? 'plus' : 'minus') . '"></i> </button> </div>'; } }
[ "public", "function", "beginHeader", "(", ")", "{", "echo", "Html", "::", "beginTag", "(", "'div'", ",", "$", "this", "->", "headerOptions", ")", ".", "\"\\n\"", ";", "if", "(", "$", "this", "->", "title", "!==", "null", ")", "{", "echo", "Html", "::...
Start header section, render title if not exist.
[ "Start", "header", "section", "render", "title", "if", "not", "exist", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/Box.php#L127-L140
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/Formats.php
Formats.suffixToContentType
static public function suffixToContentType($suffix) { $types = self::bySuffix(); return isset($types[$suffix]) ? $types[$suffix]['content-type'] : null; }
php
static public function suffixToContentType($suffix) { $types = self::bySuffix(); return isset($types[$suffix]) ? $types[$suffix]['content-type'] : null; }
[ "static", "public", "function", "suffixToContentType", "(", "$", "suffix", ")", "{", "$", "types", "=", "self", "::", "bySuffix", "(", ")", ";", "return", "isset", "(", "$", "types", "[", "$", "suffix", "]", ")", "?", "$", "types", "[", "$", "suffix"...
Obtain Suffix for given content @param string $suffix @return string
[ "Obtain", "Suffix", "for", "given", "content" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Formats.php#L97-L101
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/Formats.php
Formats.contentTypeToSuffix
static public function contentTypeToSuffix($contentType) { $types = self::byContentType(); return isset($types[$contentType]) ? $types[$contentType]['suffix'] : null; }
php
static public function contentTypeToSuffix($contentType) { $types = self::byContentType(); return isset($types[$contentType]) ? $types[$contentType]['suffix'] : null; }
[ "static", "public", "function", "contentTypeToSuffix", "(", "$", "contentType", ")", "{", "$", "types", "=", "self", "::", "byContentType", "(", ")", ";", "return", "isset", "(", "$", "types", "[", "$", "contentType", "]", ")", "?", "$", "types", "[", ...
Obtain Content-Type for given suffix @param string $contentType @return string
[ "Obtain", "Content", "-", "Type", "for", "given", "suffix" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Formats.php#L109-L113
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/RadaPokladniPohyb.php
RadaPokladniPohyb.getNextRecordCode
public function getNextRecordCode($code = null) { if (is_null($code)) { $code = $this->getMyKey(); } $crID = null; if (is_string($code)) { $sro = $this->performRequest($this->evidence.'/(kod=\''.$code.'\').json'); if (count($sro[$this->evidence])) { $crID = current(current($sro[$this->evidence])); } } else { $crID = $code; } $cr = $this->performRequest($this->evidence.'/'.$crID.'.json'); $radaPokladniPohyb = current($cr[$this->evidence]); $crInfo = end($radaPokladniPohyb['polozkyRady']); $cislo = $crInfo['cisAkt'] + 1; if ($crInfo['zobrazNuly'] == 'true') { return $crInfo['prefix'].sprintf('%\'.0'.$crInfo['cisDelka'].'d', $cislo).'/'.date('y'); } else { return $crInfo['prefix'].$cislo.'/'.date('y'); } }
php
public function getNextRecordCode($code = null) { if (is_null($code)) { $code = $this->getMyKey(); } $crID = null; if (is_string($code)) { $sro = $this->performRequest($this->evidence.'/(kod=\''.$code.'\').json'); if (count($sro[$this->evidence])) { $crID = current(current($sro[$this->evidence])); } } else { $crID = $code; } $cr = $this->performRequest($this->evidence.'/'.$crID.'.json'); $radaPokladniPohyb = current($cr[$this->evidence]); $crInfo = end($radaPokladniPohyb['polozkyRady']); $cislo = $crInfo['cisAkt'] + 1; if ($crInfo['zobrazNuly'] == 'true') { return $crInfo['prefix'].sprintf('%\'.0'.$crInfo['cisDelka'].'d', $cislo).'/'.date('y'); } else { return $crInfo['prefix'].$cislo.'/'.date('y'); } }
[ "public", "function", "getNextRecordCode", "(", "$", "code", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "code", ")", ")", "{", "$", "code", "=", "$", "this", "->", "getMyKey", "(", ")", ";", "}", "$", "crID", "=", "null", ";", "if", ...
Obtain code for new Record @param string $code @return string
[ "Obtain", "code", "for", "new", "Record" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/RadaPokladniPohyb.php#L29-L55
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/Kontakt.php
Kontakt.authenticate
public function authenticate($login, $password) { $defaultHttpHeaders = $this->defaultHttpHeaders; $this->defaultHttpHeaders['Content-Type'] = 'application/x-www-form-urlencoded'; $this->setPostFields(http_build_query(['username' => $login, 'password' => $password])); $result = $this->performRequest('authenticate', 'POST', 'xml'); $this->defaultHttpHeaders = $defaultHttpHeaders; if (!empty($result['message'])) { $this->addStatusMessage($result['message'], $result['success'] == 'true' ? 'success' : 'warning' ); } return array_key_exists('success', $result) && $result['success'] == 'true'; }
php
public function authenticate($login, $password) { $defaultHttpHeaders = $this->defaultHttpHeaders; $this->defaultHttpHeaders['Content-Type'] = 'application/x-www-form-urlencoded'; $this->setPostFields(http_build_query(['username' => $login, 'password' => $password])); $result = $this->performRequest('authenticate', 'POST', 'xml'); $this->defaultHttpHeaders = $defaultHttpHeaders; if (!empty($result['message'])) { $this->addStatusMessage($result['message'], $result['success'] == 'true' ? 'success' : 'warning' ); } return array_key_exists('success', $result) && $result['success'] == 'true'; }
[ "public", "function", "authenticate", "(", "$", "login", ",", "$", "password", ")", "{", "$", "defaultHttpHeaders", "=", "$", "this", "->", "defaultHttpHeaders", ";", "$", "this", "->", "defaultHttpHeaders", "[", "'Content-Type'", "]", "=", "'application/x-www-f...
Authenticate by contact @link https://www.flexibee.eu/api/dokumentace/ref/autentizace-kontaktu/ Contact Auth @param string $login @param string $password @return boolean
[ "Authenticate", "by", "contact" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Kontakt.php#L37-L50
train
hiqdev/hipanel-core
src/base/Controller.php
Controller.getActionUrl
public static function getActionUrl($action = 'index', $params = []) { $params = is_array($params) ? $params : ['id' => $params]; return array_merge([implode('/', ['', static::moduleId(), static::controllerId(), $action])], $params); }
php
public static function getActionUrl($action = 'index', $params = []) { $params = is_array($params) ? $params : ['id' => $params]; return array_merge([implode('/', ['', static::moduleId(), static::controllerId(), $action])], $params); }
[ "public", "static", "function", "getActionUrl", "(", "$", "action", "=", "'index'", ",", "$", "params", "=", "[", "]", ")", "{", "$", "params", "=", "is_array", "(", "$", "params", ")", "?", "$", "params", ":", "[", "'id'", "=>", "$", "params", "]"...
Prepares array for building url to action based on given action id and parameters. @param string $action action id @param string|int|array $params ID of object to be action'ed or array of parameters @return array array suitable for Url::to
[ "Prepares", "array", "for", "building", "url", "to", "action", "based", "on", "given", "action", "id", "and", "parameters", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/base/Controller.php#L241-L246
train
hiqdev/hipanel-core
src/behaviors/File.php
File.processFiles
public function processFiles($event = null) { /** @var Model $model */ $model = $this->owner; $ids = []; if (in_array($model->scenario, $this->scenarios, true)) { $files = UploadedFile::getInstances($model, $this->attribute); foreach ($files as $file) { $model = $this->uploadFile($file); $ids[] = $model->id; } if (!empty($ids)) { $this->owner->{$this->targetAttribute} = implode(',', $ids); } else { // Protect attribute $model->{$this->attribute} = null; } } }
php
public function processFiles($event = null) { /** @var Model $model */ $model = $this->owner; $ids = []; if (in_array($model->scenario, $this->scenarios, true)) { $files = UploadedFile::getInstances($model, $this->attribute); foreach ($files as $file) { $model = $this->uploadFile($file); $ids[] = $model->id; } if (!empty($ids)) { $this->owner->{$this->targetAttribute} = implode(',', $ids); } else { // Protect attribute $model->{$this->attribute} = null; } } }
[ "public", "function", "processFiles", "(", "$", "event", "=", "null", ")", "{", "/** @var Model $model */", "$", "model", "=", "$", "this", "->", "owner", ";", "$", "ids", "=", "[", "]", ";", "if", "(", "in_array", "(", "$", "model", "->", "scenario", ...
Event handler for beforeInsert and beforeUpdate actions. @param \yii\base\ModelEvent $event
[ "Event", "handler", "for", "beforeInsert", "and", "beforeUpdate", "actions", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/behaviors/File.php#L53-L74
train
hiqdev/hipanel-core
src/behaviors/File.php
File.uploadFile
private function uploadFile(UploadedFile $file) { /** @var FileStorage $fileStorage */ $fileStorage = Yii::$app->get('fileStorage'); $filename = $fileStorage->saveUploadedFile($file); return $fileStorage->put($filename, $file->name); }
php
private function uploadFile(UploadedFile $file) { /** @var FileStorage $fileStorage */ $fileStorage = Yii::$app->get('fileStorage'); $filename = $fileStorage->saveUploadedFile($file); return $fileStorage->put($filename, $file->name); }
[ "private", "function", "uploadFile", "(", "UploadedFile", "$", "file", ")", "{", "/** @var FileStorage $fileStorage */", "$", "fileStorage", "=", "Yii", "::", "$", "app", "->", "get", "(", "'fileStorage'", ")", ";", "$", "filename", "=", "$", "fileStorage", "-...
Uploads file to the API server. @param UploadedFile $file @return \hipanel\models\File
[ "Uploads", "file", "to", "the", "API", "server", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/behaviors/File.php#L82-L90
train
hiqdev/hipanel-core
src/widgets/HiBox.php
HiBox.initBoxTools
protected function initBoxTools() { parent::initBoxTools(); if (!isset($this->boxTools['collapse'])) { $this->boxTools['collapse'] = [ 'icon' => 'fa-minus', 'options' => [ 'class' => 'btn-default', 'title' => Yii::t('hipanel', 'collapse'), 'data-widget' => 'collapse', ], ]; } if (!isset($this->boxTools['remove'])) { $this->boxTools['remove'] = [ 'icon' => 'fa-times', 'options' => [ 'class' => 'btn-default', 'title' => Yii::t('hipanel', 'remove'), 'data-widget' => 'remove', ], ]; } }
php
protected function initBoxTools() { parent::initBoxTools(); if (!isset($this->boxTools['collapse'])) { $this->boxTools['collapse'] = [ 'icon' => 'fa-minus', 'options' => [ 'class' => 'btn-default', 'title' => Yii::t('hipanel', 'collapse'), 'data-widget' => 'collapse', ], ]; } if (!isset($this->boxTools['remove'])) { $this->boxTools['remove'] = [ 'icon' => 'fa-times', 'options' => [ 'class' => 'btn-default', 'title' => Yii::t('hipanel', 'remove'), 'data-widget' => 'remove', ], ]; } }
[ "protected", "function", "initBoxTools", "(", ")", "{", "parent", "::", "initBoxTools", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "boxTools", "[", "'collapse'", "]", ")", ")", "{", "$", "this", "->", "boxTools", "[", "'collapse'",...
Buttons render.
[ "Buttons", "render", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/HiBox.php#L21-L44
train
hiqdev/hipanel-core
src/widgets/HiBox.php
HiBox.renderButtons
protected function renderButtons() { // Box tools if ($this->buttonsTemplate !== null && !empty($this->boxTools)) { // Begin box tools echo Html::beginTag('div', ['class' => 'box-tools pull-right']); echo preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) { $name = $matches[1]; if (isset($this->boxTools[$name])) { $label = isset($this->boxTools[$name]['label']) ? $this->boxTools[$name]['label'] : ''; $icon = isset($this->boxTools[$name]['icon']) ? Html::tag('i', '', ['class' => 'fa ' . $this->boxTools[$name]['icon']]) : ''; $label = $icon . ' ' . $label; $this->boxTools[$name]['options']['class'] = isset($this->boxTools[$name]['options']['class']) ? 'btn btn-sm ' . $this->boxTools[$name]['options']['class'] : 'btn btn-sm'; return Html::button($label, $this->boxTools[$name]['options']); } else { return ''; } }, $this->buttonsTemplate); // End box tools echo Html::endTag('div'); } }
php
protected function renderButtons() { // Box tools if ($this->buttonsTemplate !== null && !empty($this->boxTools)) { // Begin box tools echo Html::beginTag('div', ['class' => 'box-tools pull-right']); echo preg_replace_callback('/\\{([\w\-\/]+)\\}/', function ($matches) { $name = $matches[1]; if (isset($this->boxTools[$name])) { $label = isset($this->boxTools[$name]['label']) ? $this->boxTools[$name]['label'] : ''; $icon = isset($this->boxTools[$name]['icon']) ? Html::tag('i', '', ['class' => 'fa ' . $this->boxTools[$name]['icon']]) : ''; $label = $icon . ' ' . $label; $this->boxTools[$name]['options']['class'] = isset($this->boxTools[$name]['options']['class']) ? 'btn btn-sm ' . $this->boxTools[$name]['options']['class'] : 'btn btn-sm'; return Html::button($label, $this->boxTools[$name]['options']); } else { return ''; } }, $this->buttonsTemplate); // End box tools echo Html::endTag('div'); } }
[ "protected", "function", "renderButtons", "(", ")", "{", "// Box tools", "if", "(", "$", "this", "->", "buttonsTemplate", "!==", "null", "&&", "!", "empty", "(", "$", "this", "->", "boxTools", ")", ")", "{", "// Begin box tools", "echo", "Html", "::", "beg...
Render widget tools button.
[ "Render", "widget", "tools", "button", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/HiBox.php#L49-L72
train
hiqdev/hipanel-core
src/widgets/AdvancedSearch.php
AdvancedSearch.init
public function init() { $this->registerMyJs(); $display_none = ''; if (ArrayHelper::remove($this->options, 'displayNone', true) === true) { $display_none = Yii::$app->request->get($this->model->formName())['search_form'] ? '' : 'display:none'; } if ($this->submitButtonWrapperOptions !== false) { $this->submitButtonWrapperOptions = ArrayHelper::merge([ 'class' => 'col-md-12', ], $this->submitButtonWrapperOptions); } $tag = ArrayHelper::remove($this->options, 'tag', 'div'); echo Html::beginTag($tag, ArrayHelper::merge([ 'id' => $this->getDivId(), 'class' => 'row', 'style' => 'margin-bottom: 1rem; margin-top: 1rem; ' . $display_none, ], $this->options)); $this->_form = ActiveForm::begin([ 'id' => 'form-' . $this->getDivId(), 'action' => $this->action, 'method' => $this->method, 'options' => $this->formOptions, 'fieldClass' => AdvancedSearchActiveField::class, ]); echo Html::hiddenInput(Html::getInputName($this->model, 'search_form'), 1); }
php
public function init() { $this->registerMyJs(); $display_none = ''; if (ArrayHelper::remove($this->options, 'displayNone', true) === true) { $display_none = Yii::$app->request->get($this->model->formName())['search_form'] ? '' : 'display:none'; } if ($this->submitButtonWrapperOptions !== false) { $this->submitButtonWrapperOptions = ArrayHelper::merge([ 'class' => 'col-md-12', ], $this->submitButtonWrapperOptions); } $tag = ArrayHelper::remove($this->options, 'tag', 'div'); echo Html::beginTag($tag, ArrayHelper::merge([ 'id' => $this->getDivId(), 'class' => 'row', 'style' => 'margin-bottom: 1rem; margin-top: 1rem; ' . $display_none, ], $this->options)); $this->_form = ActiveForm::begin([ 'id' => 'form-' . $this->getDivId(), 'action' => $this->action, 'method' => $this->method, 'options' => $this->formOptions, 'fieldClass' => AdvancedSearchActiveField::class, ]); echo Html::hiddenInput(Html::getInputName($this->model, 'search_form'), 1); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "registerMyJs", "(", ")", ";", "$", "display_none", "=", "''", ";", "if", "(", "ArrayHelper", "::", "remove", "(", "$", "this", "->", "options", ",", "'displayNone'", ",", "true", ")", "...
Renders the starting div.
[ "Renders", "the", "starting", "div", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/AdvancedSearch.php#L87-L117
train
hiqdev/hipanel-core
src/actions/RenderAction.php
RenderAction.getParams
public function getParams() { $res = []; if ($this->_params instanceof Closure) { $res = call_user_func($this->_params, $this); } else { foreach ($this->_params as $k => $v) { $res[$k] = $v instanceof Closure ? call_user_func($v, $this, $this->getModel()) : $v; } } return array_merge($res, $this->prepareData($res)); }
php
public function getParams() { $res = []; if ($this->_params instanceof Closure) { $res = call_user_func($this->_params, $this); } else { foreach ($this->_params as $k => $v) { $res[$k] = $v instanceof Closure ? call_user_func($v, $this, $this->getModel()) : $v; } } return array_merge($res, $this->prepareData($res)); }
[ "public", "function", "getParams", "(", ")", "{", "$", "res", "=", "[", "]", ";", "if", "(", "$", "this", "->", "_params", "instanceof", "Closure", ")", "{", "$", "res", "=", "call_user_func", "(", "$", "this", "->", "_params", ",", "$", "this", ")...
Prepares params for rendering, executing callable functions. @return array
[ "Prepares", "params", "for", "rendering", "executing", "callable", "functions", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/RenderAction.php#L38-L50
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/Zurnal.php
Zurnal.getAllChanges
public function getAllChanges($object) { $changesArray = []; $evidence = $object->getEvidence(); if (array_key_exists($evidence, self::$evidenceToDb)) { $dbTable = self::$evidenceToDb[$evidence]; $changes = $this->getColumnsFromFlexibee('*', ['tabulka' => $dbTable, 'idZaznamu' => $object->getMyKey()]); foreach ($changes as $change) { $changesArray[$change['datCas']][$change['sloupec']] = $change; } } return $changesArray; }
php
public function getAllChanges($object) { $changesArray = []; $evidence = $object->getEvidence(); if (array_key_exists($evidence, self::$evidenceToDb)) { $dbTable = self::$evidenceToDb[$evidence]; $changes = $this->getColumnsFromFlexibee('*', ['tabulka' => $dbTable, 'idZaznamu' => $object->getMyKey()]); foreach ($changes as $change) { $changesArray[$change['datCas']][$change['sloupec']] = $change; } } return $changesArray; }
[ "public", "function", "getAllChanges", "(", "$", "object", ")", "{", "$", "changesArray", "=", "[", "]", ";", "$", "evidence", "=", "$", "object", "->", "getEvidence", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "evidence", ",", "self", "::...
obtain all record changes array Note: Do not use this method in production environment! If you have no other choice pleas add indexes into wzurnal postgesql table: CREATE INDEX CONCURRENTLY tname_index ON wzurnal (tabulka); CREATE INDEX CONCURRENTLY rid_index ON wzurnal (idZaznamu); @param FlexiBeeRO $object @return array changes history
[ "obtain", "all", "record", "changes", "array" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Zurnal.php#L62-L77
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/Zurnal.php
Zurnal.getLastChange
public function getLastChange($object) { $lastChange = null; $allChanges = $this->getAllChanges($object); if (count($allChanges)) { $lastChange = end($allChanges); } return $lastChange; }
php
public function getLastChange($object) { $lastChange = null; $allChanges = $this->getAllChanges($object); if (count($allChanges)) { $lastChange = end($allChanges); } return $lastChange; }
[ "public", "function", "getLastChange", "(", "$", "object", ")", "{", "$", "lastChange", "=", "null", ";", "$", "allChanges", "=", "$", "this", "->", "getAllChanges", "(", "$", "object", ")", ";", "if", "(", "count", "(", "$", "allChanges", ")", ")", ...
obtain last change array @param FlexiBeeRO $object @return array Old/New values pairs
[ "obtain", "last", "change", "array" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/Zurnal.php#L85-L93
train
hiqdev/hipanel-core
src/actions/SwitchRule.php
SwitchRule.setAction
public function setAction($action, $postfix = null) { if (!$action) { return; } if (!isset($action['parent'])) { $action['parent'] = $this->switch; } $this->switch->controller->setInternalAction($this->getId($postfix), $action); }
php
public function setAction($action, $postfix = null) { if (!$action) { return; } if (!isset($action['parent'])) { $action['parent'] = $this->switch; } $this->switch->controller->setInternalAction($this->getId($postfix), $action); }
[ "public", "function", "setAction", "(", "$", "action", ",", "$", "postfix", "=", "null", ")", "{", "if", "(", "!", "$", "action", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "action", "[", "'parent'", "]", ")", ")", "{", "$...
Setter for action. Saves the action to the controller. @param mixed $action action config @param null $postfix
[ "Setter", "for", "action", ".", "Saves", "the", "action", "to", "the", "controller", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/actions/SwitchRule.php#L96-L105
train
hiqdev/hipanel-core
src/components/FileStorage.php
FileStorage.getTemporaryViewUrl
protected function getTemporaryViewUrl($filename) { return Url::to([$this->temporaryViewRoute, 'filename' => $filename, 'key' => $this->buildHash($filename)], true); }
php
protected function getTemporaryViewUrl($filename) { return Url::to([$this->temporaryViewRoute, 'filename' => $filename, 'key' => $this->buildHash($filename)], true); }
[ "protected", "function", "getTemporaryViewUrl", "(", "$", "filename", ")", "{", "return", "Url", "::", "to", "(", "[", "$", "this", "->", "temporaryViewRoute", ",", "'filename'", "=>", "$", "filename", ",", "'key'", "=>", "$", "this", "->", "buildHash", "(...
Return URL to the route that provides access to the temporary file. @param string $filename the file name @return string URL @see temporaryViewRoute
[ "Return", "URL", "to", "the", "route", "that", "provides", "access", "to", "the", "temporary", "file", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/components/FileStorage.php#L253-L256
train
hiqdev/hipanel-core
src/widgets/BlockModalButton.php
BlockModalButton.modalBegin
protected function modalBegin() { $config = ArrayHelper::merge([ 'class' => ModalButton::class, 'model' => $this->model, 'scenario' => $this->scenario, 'button' => $this->button, 'form' => [ 'enableAjaxValidation' => true, 'validationUrl' => $this->validationUrl, ], 'modal' => [ 'header' => Html::tag(ArrayHelper::remove($this->header, 'tag', 'h4'), ArrayHelper::remove($this->header, 'label')), 'headerOptions' => $this->header, 'footer' => $this->footer, ], ], $this->modal); $this->modal = call_user_func([ArrayHelper::remove($config, 'class'), 'begin'], $config); }
php
protected function modalBegin() { $config = ArrayHelper::merge([ 'class' => ModalButton::class, 'model' => $this->model, 'scenario' => $this->scenario, 'button' => $this->button, 'form' => [ 'enableAjaxValidation' => true, 'validationUrl' => $this->validationUrl, ], 'modal' => [ 'header' => Html::tag(ArrayHelper::remove($this->header, 'tag', 'h4'), ArrayHelper::remove($this->header, 'label')), 'headerOptions' => $this->header, 'footer' => $this->footer, ], ], $this->modal); $this->modal = call_user_func([ArrayHelper::remove($config, 'class'), 'begin'], $config); }
[ "protected", "function", "modalBegin", "(", ")", "{", "$", "config", "=", "ArrayHelper", "::", "merge", "(", "[", "'class'", "=>", "ModalButton", "::", "class", ",", "'model'", "=>", "$", "this", "->", "model", ",", "'scenario'", "=>", "$", "this", "->",...
Begins modal. @throws \yii\base\InvalidConfigException
[ "Begins", "modal", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/widgets/BlockModalButton.php#L197-L217
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.assignResultIDs
public function assignResultIDs($candidates) { foreach ($this->chained as $chid => $chained) { $chainedEvidence = $chained->getEvidence(); $chainedExtid = $chained->getRecordID(); if (is_array($chainedExtid)) { //if there are more IDs foreach ($chainedExtid as $extId) { //find external ID in format ext:..... if (stripos($extId, 'ext:') === 0) { $chainedExtid = $extId; break; } } } $chained->getData(); if (isset($candidates[$chainedEvidence][$chainedExtid])) { $chained->setMyKey($candidates[$chainedEvidence][$chainedExtid]); $chained->setDataValue('external-ids', [$chainedExtid]); } if (count($this->chained[$chid]->chained)) { $this->chained[$chid]->assignResultIDs($candidates); } } }
php
public function assignResultIDs($candidates) { foreach ($this->chained as $chid => $chained) { $chainedEvidence = $chained->getEvidence(); $chainedExtid = $chained->getRecordID(); if (is_array($chainedExtid)) { //if there are more IDs foreach ($chainedExtid as $extId) { //find external ID in format ext:..... if (stripos($extId, 'ext:') === 0) { $chainedExtid = $extId; break; } } } $chained->getData(); if (isset($candidates[$chainedEvidence][$chainedExtid])) { $chained->setMyKey($candidates[$chainedEvidence][$chainedExtid]); $chained->setDataValue('external-ids', [$chainedExtid]); } if (count($this->chained[$chid]->chained)) { $this->chained[$chid]->assignResultIDs($candidates); } } }
[ "public", "function", "assignResultIDs", "(", "$", "candidates", ")", "{", "foreach", "(", "$", "this", "->", "chained", "as", "$", "chid", "=>", "$", "chained", ")", "{", "$", "chainedEvidence", "=", "$", "chained", "->", "getEvidence", "(", ")", ";", ...
Assign result IDs to its source objects @param array $candidates FlexiBee insert IDs prepared by extractResultIDs()
[ "Assign", "result", "IDs", "to", "its", "source", "objects" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L127-L149
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.extractResultIDs
public function extractResultIDs($resultInfo) { $candidates = []; foreach ($resultInfo as $insertResult) { $newID = $insertResult['id']; if (array_key_exists('request-id', $insertResult)) { $extid = $insertResult['request-id']; } else { $extid = null; } $evidence = explode('/', $insertResult['ref'])[3]; $candidates[$evidence][$extid] = $newID; } return $candidates; }
php
public function extractResultIDs($resultInfo) { $candidates = []; foreach ($resultInfo as $insertResult) { $newID = $insertResult['id']; if (array_key_exists('request-id', $insertResult)) { $extid = $insertResult['request-id']; } else { $extid = null; } $evidence = explode('/', $insertResult['ref'])[3]; $candidates[$evidence][$extid] = $newID; } return $candidates; }
[ "public", "function", "extractResultIDs", "(", "$", "resultInfo", ")", "{", "$", "candidates", "=", "[", "]", ";", "foreach", "(", "$", "resultInfo", "as", "$", "insertResult", ")", "{", "$", "newID", "=", "$", "insertResult", "[", "'id'", "]", ";", "i...
Extract IDs from FlexiBee response Array @param array $resultInfo FlexiBee response @return array List of [ 'evidence1'=>[ 'original-id'=>numericID,'original-id2'=>numericID2 ], 'evidence2'=> ... ]
[ "Extract", "IDs", "from", "FlexiBee", "response", "Array" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L158-L172
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.takeData
public function takeData($data) { if ($this->debug === true) { $fbRelations = []; $fbColumns = $this->getColumnsInfo(); foreach ($this->getRelationsInfo() as $relation) { if (is_array($relation) && isset($relation['url'])) { $fbRelations[$relation['url']] = $relation['url']; } } if (count($fbColumns)) { foreach ($data as $key => $value) { if (!array_key_exists($key, $fbColumns)) { if (!array_key_exists($key, $fbRelations)) { $this->addStatusMessage(sprintf('unknown column %s for evidence %s', $key, $this->getEvidence()), 'warning'); } else { if (!is_array($value)) { $this->addStatusMessage(sprintf('subevidence %s in evidence %s must bee an array', $key, $this->getEvidence()), 'warning'); } } } } } } return parent::takeData($data); }
php
public function takeData($data) { if ($this->debug === true) { $fbRelations = []; $fbColumns = $this->getColumnsInfo(); foreach ($this->getRelationsInfo() as $relation) { if (is_array($relation) && isset($relation['url'])) { $fbRelations[$relation['url']] = $relation['url']; } } if (count($fbColumns)) { foreach ($data as $key => $value) { if (!array_key_exists($key, $fbColumns)) { if (!array_key_exists($key, $fbRelations)) { $this->addStatusMessage(sprintf('unknown column %s for evidence %s', $key, $this->getEvidence()), 'warning'); } else { if (!is_array($value)) { $this->addStatusMessage(sprintf('subevidence %s in evidence %s must bee an array', $key, $this->getEvidence()), 'warning'); } } } } } } return parent::takeData($data); }
[ "public", "function", "takeData", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "debug", "===", "true", ")", "{", "$", "fbRelations", "=", "[", "]", ";", "$", "fbColumns", "=", "$", "this", "->", "getColumnsInfo", "(", ")", ";", "foreac...
Control for existing column names in evidence and take data @param array $data Data to keep @return int number of records taken
[ "Control", "for", "existing", "column", "names", "in", "evidence", "and", "take", "data" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L210-L238
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.controlMandatoryColumns
public function controlMandatoryColumns($data = null) { if (is_null($data)) { $data = $this->getData(); } $missingMandatoryColumns = []; if (!empty($data) && count($data)) { $fbColumns = $this->getColumnsInfo(); if (count($fbColumns)) { foreach ($fbColumns as $columnName => $columnInfo) { $mandatory = ($columnInfo['mandatory'] == 'true'); if ($mandatory && !array_key_exists($columnName, $data)) { $missingMandatoryColumns[$columnName] = $columnInfo['name']; } } } } return $missingMandatoryColumns; }
php
public function controlMandatoryColumns($data = null) { if (is_null($data)) { $data = $this->getData(); } $missingMandatoryColumns = []; if (!empty($data) && count($data)) { $fbColumns = $this->getColumnsInfo(); if (count($fbColumns)) { foreach ($fbColumns as $columnName => $columnInfo) { $mandatory = ($columnInfo['mandatory'] == 'true'); if ($mandatory && !array_key_exists($columnName, $data)) { $missingMandatoryColumns[$columnName] = $columnInfo['name']; } } } } return $missingMandatoryColumns; }
[ "public", "function", "controlMandatoryColumns", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "}", "$", "missingMandatoryColumns", "=", ...
Control data for mandatory columns presence. @deprecated since version 1.8.7 @param array $data @return array List of missing columns. Empty if all is ok
[ "Control", "data", "for", "mandatory", "columns", "presence", "." ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L249-L267
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.controlReadOnlyColumns
public function controlReadOnlyColumns($data = null) { if (is_null($data)) { $data = $this->getData(); } $readonlyColumns = []; $fbColumns = $this->getColumnsInfo(); if (!empty($fbColumns) && count($fbColumns)) { foreach ($fbColumns as $columnName => $columnInfo) { $writable = ($columnInfo['isWritable'] == 'true'); if (!$writable && !array_key_exists($columnName, $data)) { $readonlyColumns[$columnName] = $columnInfo['name']; } } } return $readonlyColumns; }
php
public function controlReadOnlyColumns($data = null) { if (is_null($data)) { $data = $this->getData(); } $readonlyColumns = []; $fbColumns = $this->getColumnsInfo(); if (!empty($fbColumns) && count($fbColumns)) { foreach ($fbColumns as $columnName => $columnInfo) { $writable = ($columnInfo['isWritable'] == 'true'); if (!$writable && !array_key_exists($columnName, $data)) { $readonlyColumns[$columnName] = $columnInfo['name']; } } } return $readonlyColumns; }
[ "public", "function", "controlReadOnlyColumns", "(", "$", "data", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "}", "$", "readonlyColumns", "=", "[", "]...
Control data for readonly columns presence. @param array $data @return array List of ReadOnly columns. Empty if all is ok
[ "Control", "data", "for", "readonly", "columns", "presence", "." ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L276-L294
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.timestampToFlexiDate
public static function timestampToFlexiDate($timpestamp = null) { $flexiDate = null; if (!is_null($timpestamp)) { $date = new \DateTime(); $date->setTimestamp($timpestamp); $flexiDate = $date->format('Y-m-d'); } return $flexiDate; }
php
public static function timestampToFlexiDate($timpestamp = null) { $flexiDate = null; if (!is_null($timpestamp)) { $date = new \DateTime(); $date->setTimestamp($timpestamp); $flexiDate = $date->format('Y-m-d'); } return $flexiDate; }
[ "public", "static", "function", "timestampToFlexiDate", "(", "$", "timpestamp", "=", "null", ")", "{", "$", "flexiDate", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "timpestamp", ")", ")", "{", "$", "date", "=", "new", "\\", "DateTime", "(",...
Convert Timestamp to FlexiBee Date format. @param int $timpestamp @return string FlexiBee Date or NULL
[ "Convert", "Timestamp", "to", "FlexiBee", "Date", "format", "." ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L303-L312
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.timestampToFlexiDateTime
public static function timestampToFlexiDateTime($timpestamp = null) { $flexiDateTime = null; if (!is_null($timpestamp)) { $date = new \DateTime(); $date->setTimestamp($timpestamp); $flexiDateTime = $date->format('Y-m-dTH:i:s'); } return $flexiDateTime; }
php
public static function timestampToFlexiDateTime($timpestamp = null) { $flexiDateTime = null; if (!is_null($timpestamp)) { $date = new \DateTime(); $date->setTimestamp($timpestamp); $flexiDateTime = $date->format('Y-m-dTH:i:s'); } return $flexiDateTime; }
[ "public", "static", "function", "timestampToFlexiDateTime", "(", "$", "timpestamp", "=", "null", ")", "{", "$", "flexiDateTime", "=", "null", ";", "if", "(", "!", "is_null", "(", "$", "timpestamp", ")", ")", "{", "$", "date", "=", "new", "\\", "DateTime"...
Convert Timestamp to Flexi DateTime format. @param int $timpestamp @return string FlexiBee DateTime or NULL
[ "Convert", "Timestamp", "to", "Flexi", "DateTime", "format", "." ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L321-L330
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.sync
public function sync($data = null) { $this->insertToFlexiBee($data); $insertResult = $this->lastResponseCode; if ($insertResult == 201) { $this->reload(); } $loadResult = $this->lastResponseCode; return ($insertResult + $loadResult) == 401; }
php
public function sync($data = null) { $this->insertToFlexiBee($data); $insertResult = $this->lastResponseCode; if ($insertResult == 201) { $this->reload(); } $loadResult = $this->lastResponseCode; return ($insertResult + $loadResult) == 401; }
[ "public", "function", "sync", "(", "$", "data", "=", "null", ")", "{", "$", "this", "->", "insertToFlexiBee", "(", "$", "data", ")", ";", "$", "insertResult", "=", "$", "this", "->", "lastResponseCode", ";", "if", "(", "$", "insertResult", "==", "201",...
Insert current data into FlexiBee and load actual record data back @param array $data Initial data to save @return boolean Operation success
[ "Insert", "current", "data", "into", "FlexiBee", "and", "load", "actual", "record", "data", "back" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L455-L464
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.copy
public function copy($source, $overrides = []) { $this->sourceId = $source; return $this->sync($overrides) ? $this : null; }
php
public function copy($source, $overrides = []) { $this->sourceId = $source; return $this->sync($overrides) ? $this : null; }
[ "public", "function", "copy", "(", "$", "source", ",", "$", "overrides", "=", "[", "]", ")", "{", "$", "this", "->", "sourceId", "=", "$", "source", ";", "return", "$", "this", "->", "sync", "(", "$", "overrides", ")", "?", "$", "this", ":", "nul...
Make Copy of given record with optional modifiactions !!!Experimental Feature!!! @param int $source @param array $overrides @return FlexiBeeRW|null copied record object or null in case of failure
[ "Make", "Copy", "of", "given", "record", "with", "optional", "modifiactions" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L476-L480
train
Spoje-NET/FlexiPeeHP
src/FlexiPeeHP/FlexiBeeRW.php
FlexiBeeRW.changeExternalID
public function changeExternalID($selector, $newValue, $forID = null) { $change['@removeExternalIds'] = 'ext:'.$selector.':'; $change['id'] = [is_null($forID) ? $this->getRecordID() : $forID, 'ext:'.$selector.':'.$newValue]; return $this->insertToFlexiBee($change); }
php
public function changeExternalID($selector, $newValue, $forID = null) { $change['@removeExternalIds'] = 'ext:'.$selector.':'; $change['id'] = [is_null($forID) ? $this->getRecordID() : $forID, 'ext:'.$selector.':'.$newValue]; return $this->insertToFlexiBee($change); }
[ "public", "function", "changeExternalID", "(", "$", "selector", ",", "$", "newValue", ",", "$", "forID", "=", "null", ")", "{", "$", "change", "[", "'@removeExternalIds'", "]", "=", "'ext:'", ".", "$", "selector", ".", "':'", ";", "$", "change", "[", "...
Change Value of external id identified by selector. Add new if not exists @param string $selector ext:$selector:$newValue @param string|int $newValue string or number @param string|int $forID Other than current record id @return array operation result
[ "Change", "Value", "of", "external", "id", "identified", "by", "selector", ".", "Add", "new", "if", "not", "exists" ]
8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73
https://github.com/Spoje-NET/FlexiPeeHP/blob/8c1d8d39e6d2d23a85ec5ef7afbb9f040fbaba73/src/FlexiPeeHP/FlexiBeeRW.php#L552-L558
train
hiqdev/hipanel-core
src/logic/Impersonator.php
Impersonator.buildAuthUrl
public function buildAuthUrl($user_id) { return $this->getClient()->buildAuthUrl([ 'redirect_uri' => Url::toRoute(['/site/impersonate-auth', 'authclient' => $this->defaultAuthClient], true), 'user_id' => $user_id, ]); }
php
public function buildAuthUrl($user_id) { return $this->getClient()->buildAuthUrl([ 'redirect_uri' => Url::toRoute(['/site/impersonate-auth', 'authclient' => $this->defaultAuthClient], true), 'user_id' => $user_id, ]); }
[ "public", "function", "buildAuthUrl", "(", "$", "user_id", ")", "{", "return", "$", "this", "->", "getClient", "(", ")", "->", "buildAuthUrl", "(", "[", "'redirect_uri'", "=>", "Url", "::", "toRoute", "(", "[", "'/site/impersonate-auth'", ",", "'authclient'", ...
Method should be called to generate URL for user redirect. @param string $user_id @return string
[ "Method", "should", "be", "called", "to", "generate", "URL", "for", "user", "redirect", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/logic/Impersonator.php#L48-L54
train
hiqdev/hipanel-core
src/logic/Impersonator.php
Impersonator.impersonateUser
public function impersonateUser(HiamClient $client) { $attributes = $client->getUserAttributes(); $identity = new User(); foreach ($identity->attributes() as $k) { if (isset($attributes[$k])) { $identity->{$k} = $attributes[$k]; } } if ($this->user->getId() === $identity->getId()) { return; } $identity->save(); $this->session->set('__realId', $this->user->getId()); $this->user->setIdentity($identity); $this->session->set($this->user->idParam, $this->user->getId()); }
php
public function impersonateUser(HiamClient $client) { $attributes = $client->getUserAttributes(); $identity = new User(); foreach ($identity->attributes() as $k) { if (isset($attributes[$k])) { $identity->{$k} = $attributes[$k]; } } if ($this->user->getId() === $identity->getId()) { return; } $identity->save(); $this->session->set('__realId', $this->user->getId()); $this->user->setIdentity($identity); $this->session->set($this->user->idParam, $this->user->getId()); }
[ "public", "function", "impersonateUser", "(", "HiamClient", "$", "client", ")", "{", "$", "attributes", "=", "$", "client", "->", "getUserAttributes", "(", ")", ";", "$", "identity", "=", "new", "User", "(", ")", ";", "foreach", "(", "$", "identity", "->...
Method should be called when authentication succeeded. @param HiamClient $client
[ "Method", "should", "be", "called", "when", "authentication", "succeeded", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/logic/Impersonator.php#L68-L85
train
hiqdev/hipanel-core
src/logic/Impersonator.php
Impersonator.unimpersonateUser
public function unimpersonateUser() { $realId = $this->session->remove('__realId'); if ($realId !== null) { $this->user->identity->remove(); $this->session->set($this->user->idParam, $realId); $identity = User::findOne($realId); $this->user->setIdentity($identity); $this->restoreBackedUpToken(); } }
php
public function unimpersonateUser() { $realId = $this->session->remove('__realId'); if ($realId !== null) { $this->user->identity->remove(); $this->session->set($this->user->idParam, $realId); $identity = User::findOne($realId); $this->user->setIdentity($identity); $this->restoreBackedUpToken(); } }
[ "public", "function", "unimpersonateUser", "(", ")", "{", "$", "realId", "=", "$", "this", "->", "session", "->", "remove", "(", "'__realId'", ")", ";", "if", "(", "$", "realId", "!==", "null", ")", "{", "$", "this", "->", "user", "->", "identity", "...
Method should be called when user should be unimpersonated.
[ "Method", "should", "be", "called", "when", "user", "should", "be", "unimpersonated", "." ]
090eb4b95dd731b338cd661b569f6b9b999f95e4
https://github.com/hiqdev/hipanel-core/blob/090eb4b95dd731b338cd661b569f6b9b999f95e4/src/logic/Impersonator.php#L90-L100
train