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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
laravel-doctrine/fluent | src/Extensions/ExtensibleClassMetadata.php | ExtensibleClassMetadata.appendExtension | public function appendExtension($name, array $config = [])
{
$merged = array_merge_recursive(
$this->getExtension($name),
$config
);
$this->addExtension($name, $merged);
} | php | public function appendExtension($name, array $config = [])
{
$merged = array_merge_recursive(
$this->getExtension($name),
$config
);
$this->addExtension($name, $merged);
} | [
"public",
"function",
"appendExtension",
"(",
"$",
"name",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"merged",
"=",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"getExtension",
"(",
"$",
"name",
")",
",",
"$",
"config",
")",
";",
... | Merge with current extension configuration, appending new values to old ones.
@param string $name
@param array $config | [
"Merge",
"with",
"current",
"extension",
"configuration",
"appending",
"new",
"values",
"to",
"old",
"ones",
"."
] | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Extensions/ExtensibleClassMetadata.php#L49-L57 | train |
laravel-doctrine/fluent | src/Extensions/ExtensibleClassMetadata.php | ExtensibleClassMetadata.mergeExtension | public function mergeExtension($name, array $config)
{
$this->addExtension($name, array_merge(
$this->getExtension($name),
$config
));
} | php | public function mergeExtension($name, array $config)
{
$this->addExtension($name, array_merge(
$this->getExtension($name),
$config
));
} | [
"public",
"function",
"mergeExtension",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"addExtension",
"(",
"$",
"name",
",",
"array_merge",
"(",
"$",
"this",
"->",
"getExtension",
"(",
"$",
"name",
")",
",",
"$",
"config",... | Merge with current extension configuration, overwriting with new values.
@param string $name
@param array $config
@return void | [
"Merge",
"with",
"current",
"extension",
"configuration",
"overwriting",
"with",
"new",
"values",
"."
] | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Extensions/ExtensibleClassMetadata.php#L67-L73 | train |
laravel-doctrine/fluent | src/Builders/GeneratedValue.php | GeneratedValue.auto | public function auto($name = null, $initial = null, $size = null)
{
$this->strategy = 'AUTO';
$this->customize($name, $initial, $size);
return $this;
} | php | public function auto($name = null, $initial = null, $size = null)
{
$this->strategy = 'AUTO';
$this->customize($name, $initial, $size);
return $this;
} | [
"public",
"function",
"auto",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"initial",
"=",
"null",
",",
"$",
"size",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"strategy",
"=",
"'AUTO'",
";",
"$",
"this",
"->",
"customize",
"(",
"$",
"name",
",",
"$",... | Tells Doctrine to pick the strategy that is preferred by the used database platform. The preferred strategies
are IDENTITY for MySQL, SQLite, MsSQL and SQL Anywhere and SEQUENCE for Oracle and PostgreSQL. This strategy
provides full portability.
@param string|null $name
@param string|null $initial
@param string|null $size
@return $this | [
"Tells",
"Doctrine",
"to",
"pick",
"the",
"strategy",
"that",
"is",
"preferred",
"by",
"the",
"used",
"database",
"platform",
".",
"The",
"preferred",
"strategies",
"are",
"IDENTITY",
"for",
"MySQL",
"SQLite",
"MsSQL",
"and",
"SQL",
"Anywhere",
"and",
"SEQUENC... | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Builders/GeneratedValue.php#L67-L73 | train |
laravel-doctrine/fluent | src/Builders/GeneratedValue.php | GeneratedValue.sequence | public function sequence($name = null, $initial = null, $size = null)
{
$this->strategy = 'SEQUENCE';
$this->customize($name, $initial, $size);
return $this;
} | php | public function sequence($name = null, $initial = null, $size = null)
{
$this->strategy = 'SEQUENCE';
$this->customize($name, $initial, $size);
return $this;
} | [
"public",
"function",
"sequence",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"initial",
"=",
"null",
",",
"$",
"size",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"strategy",
"=",
"'SEQUENCE'",
";",
"$",
"this",
"->",
"customize",
"(",
"$",
"name",
","... | Tells Doctrine to use a database sequence for ID generation. This strategy does currently not provide full
portability. Sequences are supported by Oracle, PostgreSql and SQL Anywhere.
@param string|null $name
@param string|null $initial
@param string|null $size
@return $this | [
"Tells",
"Doctrine",
"to",
"use",
"a",
"database",
"sequence",
"for",
"ID",
"generation",
".",
"This",
"strategy",
"does",
"currently",
"not",
"provide",
"full",
"portability",
".",
"Sequences",
"are",
"supported",
"by",
"Oracle",
"PostgreSql",
"and",
"SQL",
"... | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Builders/GeneratedValue.php#L85-L91 | train |
laravel-doctrine/fluent | src/Builders/Traits/Queueable.php | Queueable.build | public function build()
{
/** @var Buildable[] $delayed */
$delayed = [];
foreach ($this->getQueued() as $buildable) {
if ($buildable instanceof Delay) {
$delayed[] = $buildable;
} else {
$buildable->build();
}
}
foreach ($delayed as $buildable) {
$buildable->build();
}
} | php | public function build()
{
/** @var Buildable[] $delayed */
$delayed = [];
foreach ($this->getQueued() as $buildable) {
if ($buildable instanceof Delay) {
$delayed[] = $buildable;
} else {
$buildable->build();
}
}
foreach ($delayed as $buildable) {
$buildable->build();
}
} | [
"public",
"function",
"build",
"(",
")",
"{",
"/** @var Buildable[] $delayed */",
"$",
"delayed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueued",
"(",
")",
"as",
"$",
"buildable",
")",
"{",
"if",
"(",
"$",
"buildable",
"instanceof",
"... | Execute the build process for all queued buildables. | [
"Execute",
"the",
"build",
"process",
"for",
"all",
"queued",
"buildables",
"."
] | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Builders/Traits/Queueable.php#L37-L53 | train |
laravel-doctrine/fluent | src/Builders/Entity.php | Entity.cacheable | public function cacheable($usage = ClassMetadataInfo::CACHE_USAGE_READ_ONLY, $region = null)
{
$meta = $this->builder->getClassMetadata();
$meta->enableCache(compact('usage', $region === null ?: 'region'));
return $this;
} | php | public function cacheable($usage = ClassMetadataInfo::CACHE_USAGE_READ_ONLY, $region = null)
{
$meta = $this->builder->getClassMetadata();
$meta->enableCache(compact('usage', $region === null ?: 'region'));
return $this;
} | [
"public",
"function",
"cacheable",
"(",
"$",
"usage",
"=",
"ClassMetadataInfo",
"::",
"CACHE_USAGE_READ_ONLY",
",",
"$",
"region",
"=",
"null",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"builder",
"->",
"getClassMetadata",
"(",
")",
";",
"$",
"meta",
... | Enables second-level cache on this entity.
If you want to enable second-level cache,
you must enable it on the EntityManager configuration.
Depending on the cache mode selected, you may also need to configure
lock modes.
@param int $usage Cache mode. use ClassMetadataInfo::CACHE_USAGE_* constants.
Defaults to READ_ONLY mode.
@param string|null $region The cache region to be used. Doctrine will use a default region
for each entity, if none is provided.
@return Entity
@see http://doctrine-orm.readthedocs.org/en/latest/reference/second-level-cache.html | [
"Enables",
"second",
"-",
"level",
"cache",
"on",
"this",
"entity",
".",
"If",
"you",
"want",
"to",
"enable",
"second",
"-",
"level",
"cache",
"you",
"must",
"enable",
"it",
"on",
"the",
"EntityManager",
"configuration",
".",
"Depending",
"on",
"the",
"cac... | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Builders/Entity.php#L52-L58 | train |
laravel-doctrine/fluent | src/Extensions/Gedmo/Tree.php | Tree.enable | public static function enable()
{
Builder::macro(self::MACRO_METHOD, function (Fluent $builder, callable $callback = null) {
$tree = new static($builder);
if (is_callable($callback)) {
call_user_func($callback, $tree);
}
return $tree;
});
NestedSet::enable();
MaterializedPath::enable();
ClosureTable::enable();
} | php | public static function enable()
{
Builder::macro(self::MACRO_METHOD, function (Fluent $builder, callable $callback = null) {
$tree = new static($builder);
if (is_callable($callback)) {
call_user_func($callback, $tree);
}
return $tree;
});
NestedSet::enable();
MaterializedPath::enable();
ClosureTable::enable();
} | [
"public",
"static",
"function",
"enable",
"(",
")",
"{",
"Builder",
"::",
"macro",
"(",
"self",
"::",
"MACRO_METHOD",
",",
"function",
"(",
"Fluent",
"$",
"builder",
",",
"callable",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"tree",
"=",
"new",
"sta... | Enable extension. | [
"Enable",
"extension",
"."
] | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/src/Extensions/Gedmo/Tree.php#L35-L50 | train |
laravel-doctrine/fluent | lib/FluentExtension.php | FluentExtension.readExtendedMetadata | public function readExtendedMetadata($meta, array &$config)
{
if (!$meta instanceof ExtensibleClassMetadata) {
return;
}
$config = array_merge_recursive($config, $meta->getExtension(
$this->getExtensionName()
));
} | php | public function readExtendedMetadata($meta, array &$config)
{
if (!$meta instanceof ExtensibleClassMetadata) {
return;
}
$config = array_merge_recursive($config, $meta->getExtension(
$this->getExtensionName()
));
} | [
"public",
"function",
"readExtendedMetadata",
"(",
"$",
"meta",
",",
"array",
"&",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"$",
"meta",
"instanceof",
"ExtensibleClassMetadata",
")",
"{",
"return",
";",
"}",
"$",
"config",
"=",
"array_merge_recursive",
"(",
... | Read extended metadata configuration for
a single mapped class.
@param ExtensibleClassMetadata $meta
@param array $config
@return void | [
"Read",
"extended",
"metadata",
"configuration",
"for",
"a",
"single",
"mapped",
"class",
"."
] | 337b82d49d83370bf51afa12004d3c082bd9c462 | https://github.com/laravel-doctrine/fluent/blob/337b82d49d83370bf51afa12004d3c082bd9c462/lib/FluentExtension.php#L32-L41 | train |
tzsk/payu | src/Model/PayuPayment.php | PayuPayment.get | public function get($item)
{
$data = $this->getData();
return empty($data->$item) ? null : $data->$item;
} | php | public function get($item)
{
$data = $this->getData();
return empty($data->$item) ? null : $data->$item;
} | [
"public",
"function",
"get",
"(",
"$",
"item",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"return",
"empty",
"(",
"$",
"data",
"->",
"$",
"item",
")",
"?",
"null",
":",
"$",
"data",
"->",
"$",
"item",
";",
"}"
] | Get from Data Attribute.
@param $item
@return null|mixed | [
"Get",
"from",
"Data",
"Attribute",
"."
] | f829611dfa6b136cfce061bfe2dab7a0b049be55 | https://github.com/tzsk/payu/blob/f829611dfa6b136cfce061bfe2dab7a0b049be55/src/Model/PayuPayment.php#L65-L70 | train |
tzsk/payu | src/PayuGateway.php | PayuGateway.capture | public function capture()
{
$storage = new Storage();
$config = new Config($storage->getAccount());
if ($config->getDriver() == 'database') {
return PayuPayment::find($storage->getPayment());
}
return new PayuPayment($storage->getPayment());
} | php | public function capture()
{
$storage = new Storage();
$config = new Config($storage->getAccount());
if ($config->getDriver() == 'database') {
return PayuPayment::find($storage->getPayment());
}
return new PayuPayment($storage->getPayment());
} | [
"public",
"function",
"capture",
"(",
")",
"{",
"$",
"storage",
"=",
"new",
"Storage",
"(",
")",
";",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"storage",
"->",
"getAccount",
"(",
")",
")",
";",
"if",
"(",
"$",
"config",
"->",
"getDriver",
"("... | Receive Payment and Return Payment Model.
@return PayuPayment | [
"Receive",
"Payment",
"and",
"Return",
"Payment",
"Model",
"."
] | f829611dfa6b136cfce061bfe2dab7a0b049be55 | https://github.com/tzsk/payu/blob/f829611dfa6b136cfce061bfe2dab7a0b049be55/src/PayuGateway.php#L92-L102 | train |
tzsk/payu | src/PayuGateway.php | PayuGateway.verify | public function verify($transactionId)
{
session()->put('tzsk_payu_data', ['account' => $this->account]);
$transactionId = is_array($transactionId) ?
$transactionId : explode('|', $transactionId);
return $this->getVerifier($transactionId)->verify();
} | php | public function verify($transactionId)
{
session()->put('tzsk_payu_data', ['account' => $this->account]);
$transactionId = is_array($transactionId) ?
$transactionId : explode('|', $transactionId);
return $this->getVerifier($transactionId)->verify();
} | [
"public",
"function",
"verify",
"(",
"$",
"transactionId",
")",
"{",
"session",
"(",
")",
"->",
"put",
"(",
"'tzsk_payu_data'",
",",
"[",
"'account'",
"=>",
"$",
"this",
"->",
"account",
"]",
")",
";",
"$",
"transactionId",
"=",
"is_array",
"(",
"$",
"... | Get Status of a given Transaction.
@param $transactionId string
@return object | [
"Get",
"Status",
"of",
"a",
"given",
"Transaction",
"."
] | f829611dfa6b136cfce061bfe2dab7a0b049be55 | https://github.com/tzsk/payu/blob/f829611dfa6b136cfce061bfe2dab7a0b049be55/src/PayuGateway.php#L110-L118 | train |
tzsk/payu | src/Helpers/Processor.php | Processor.getStatus | public function getStatus()
{
switch (strtolower($this->request->status)) {
case 'success':
return self::STATUS_COMPLETED;
case 'pending':
return self::STATUS_PENDING;
case 'failure':
return self::STATUS_FAILED;
default:
return self::STATUS_FAILED;
}
} | php | public function getStatus()
{
switch (strtolower($this->request->status)) {
case 'success':
return self::STATUS_COMPLETED;
case 'pending':
return self::STATUS_PENDING;
case 'failure':
return self::STATUS_FAILED;
default:
return self::STATUS_FAILED;
}
} | [
"public",
"function",
"getStatus",
"(",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"request",
"->",
"status",
")",
")",
"{",
"case",
"'success'",
":",
"return",
"self",
"::",
"STATUS_COMPLETED",
";",
"case",
"'pending'",
":",
"return",
... | Get the status of the Payment.
@return string | [
"Get",
"the",
"status",
"of",
"the",
"Payment",
"."
] | f829611dfa6b136cfce061bfe2dab7a0b049be55 | https://github.com/tzsk/payu/blob/f829611dfa6b136cfce061bfe2dab7a0b049be55/src/Helpers/Processor.php#L49-L64 | train |
tzsk/payu | src/Helpers/Redirector.php | Redirector.redirectTo | public function redirectTo($url, $parameters = [], $secure = null)
{
$this->url = url($url, $parameters, $secure);
return $this;
} | php | public function redirectTo($url, $parameters = [], $secure = null)
{
$this->url = url($url, $parameters, $secure);
return $this;
} | [
"public",
"function",
"redirectTo",
"(",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"url",
"=",
"url",
"(",
"$",
"url",
",",
"$",
"parameters",
",",
"$",
"secure",
")",
";",
... | Set Redirect URL.
@param $url
@param array $parameters
@param null $secure
@return $this | [
"Set",
"Redirect",
"URL",
"."
] | f829611dfa6b136cfce061bfe2dab7a0b049be55 | https://github.com/tzsk/payu/blob/f829611dfa6b136cfce061bfe2dab7a0b049be55/src/Helpers/Redirector.php#L20-L25 | train |
tzsk/payu | src/Controllers/PaymentController.php | PaymentController.payment | public function payment(Request $request)
{
$payment = (new Processor($request))->process();
Session::put('tzsk_payu_data.payment', $payment);
return redirect()->to(base64_decode($request->callback));
} | php | public function payment(Request $request)
{
$payment = (new Processor($request))->process();
Session::put('tzsk_payu_data.payment', $payment);
return redirect()->to(base64_decode($request->callback));
} | [
"public",
"function",
"payment",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"payment",
"=",
"(",
"new",
"Processor",
"(",
"$",
"request",
")",
")",
"->",
"process",
"(",
")",
";",
"Session",
"::",
"put",
"(",
"'tzsk_payu_data.payment'",
",",
"$",
"... | After payment it will return here.
@param Request $request
@return \Illuminate\Http\RedirectResponse | [
"After",
"payment",
"it",
"will",
"return",
"here",
"."
] | f829611dfa6b136cfce061bfe2dab7a0b049be55 | https://github.com/tzsk/payu/blob/f829611dfa6b136cfce061bfe2dab7a0b049be55/src/Controllers/PaymentController.php#L32-L39 | train |
Codeinwp/wp-menu-icons | includes/picker.php | Menu_Icons_Picker._get_menu_item_fields | protected static function _get_menu_item_fields( $meta ) {
$fields = array_merge(
array(
array(
'id' => 'type',
'label' => __( 'Type', 'menu-icons' ),
'value' => $meta['type'],
),
array(
'id' => 'icon',
'label' => __( 'Icon', 'menu-icons' ),
'value' => $meta['icon'],
),
),
Menu_Icons_Settings::get_settings_fields( $meta )
);
return $fields;
} | php | protected static function _get_menu_item_fields( $meta ) {
$fields = array_merge(
array(
array(
'id' => 'type',
'label' => __( 'Type', 'menu-icons' ),
'value' => $meta['type'],
),
array(
'id' => 'icon',
'label' => __( 'Icon', 'menu-icons' ),
'value' => $meta['icon'],
),
),
Menu_Icons_Settings::get_settings_fields( $meta )
);
return $fields;
} | [
"protected",
"static",
"function",
"_get_menu_item_fields",
"(",
"$",
"meta",
")",
"{",
"$",
"fields",
"=",
"array_merge",
"(",
"array",
"(",
"array",
"(",
"'id'",
"=>",
"'type'",
",",
"'label'",
"=>",
"__",
"(",
"'Type'",
",",
"'menu-icons'",
")",
",",
... | Get menu item setting fields
@since 0.9.0
@access protected
@param array $meta Menu item meta value.
@return array | [
"Get",
"menu",
"item",
"setting",
"fields"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/picker.php#L70-L88 | train |
Codeinwp/wp-menu-icons | includes/picker.php | Menu_Icons_Picker._save | public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
$screen = get_current_screen();
if ( ! $screen instanceof WP_Screen || 'nav-menus' !== $screen->id ) {
return;
}
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
// Sanitize
if ( ! empty( $_POST['menu-icons'][ $menu_item_db_id ] ) ) {
$value = array_map(
'sanitize_text_field',
wp_unslash( (array) $_POST['menu-icons'][ $menu_item_db_id ] )
);
} else {
$value = array();
}
Menu_Icons_Meta::update( $menu_item_db_id, $value );
} | php | public static function _save( $menu_id, $menu_item_db_id, $menu_item_args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return;
}
$screen = get_current_screen();
if ( ! $screen instanceof WP_Screen || 'nav-menus' !== $screen->id ) {
return;
}
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
// Sanitize
if ( ! empty( $_POST['menu-icons'][ $menu_item_db_id ] ) ) {
$value = array_map(
'sanitize_text_field',
wp_unslash( (array) $_POST['menu-icons'][ $menu_item_db_id ] )
);
} else {
$value = array();
}
Menu_Icons_Meta::update( $menu_item_db_id, $value );
} | [
"public",
"static",
"function",
"_save",
"(",
"$",
"menu_id",
",",
"$",
"menu_item_db_id",
",",
"$",
"menu_item_args",
")",
"{",
"if",
"(",
"defined",
"(",
"'DOING_AJAX'",
")",
"&&",
"DOING_AJAX",
")",
"{",
"return",
";",
"}",
"$",
"screen",
"=",
"get_cu... | Save menu item's icons metadata
@since 0.1.0
@access protected
@wp_hook action wp_update_nav_menu_item
@link http://codex.wordpress.org/Plugin_API/Action_Reference/wp_update_nav_menu_item
@param int $menu_id Nav menu ID.
@param int $menu_item_db_id Menu item ID.
@param array $menu_item_args Menu item data. | [
"Save",
"menu",
"item",
"s",
"icons",
"metadata"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/picker.php#L196-L219 | train |
Codeinwp/wp-menu-icons | includes/picker.php | Menu_Icons_Picker._media_templates | public static function _media_templates() {
$id_prefix = 'tmpl-menu-icons';
// Deprecated.
$templates = apply_filters( 'menu_icons_media_templates', array() );
if ( ! empty( $templates ) ) {
if ( WP_DEBUG ) {
_deprecated_function( 'menu_icons_media_templates', '0.9.0', 'menu_icons_js_templates' );
}
foreach ( $templates as $key => $template ) {
$id = sprintf( '%s-%s', $id_prefix, $key );
self::_print_tempate( $id, $template );
}
}
require_once dirname( __FILE__ ) . '/media-template.php';
} | php | public static function _media_templates() {
$id_prefix = 'tmpl-menu-icons';
// Deprecated.
$templates = apply_filters( 'menu_icons_media_templates', array() );
if ( ! empty( $templates ) ) {
if ( WP_DEBUG ) {
_deprecated_function( 'menu_icons_media_templates', '0.9.0', 'menu_icons_js_templates' );
}
foreach ( $templates as $key => $template ) {
$id = sprintf( '%s-%s', $id_prefix, $key );
self::_print_tempate( $id, $template );
}
}
require_once dirname( __FILE__ ) . '/media-template.php';
} | [
"public",
"static",
"function",
"_media_templates",
"(",
")",
"{",
"$",
"id_prefix",
"=",
"'tmpl-menu-icons'",
";",
"// Deprecated.",
"$",
"templates",
"=",
"apply_filters",
"(",
"'menu_icons_media_templates'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"!",
... | Get and print media templates from all types
@since 0.2.0
@since 0.9.0 Deprecate menu_icons_media_templates filter.
@wp_hook action print_media_templates | [
"Get",
"and",
"print",
"media",
"templates",
"from",
"all",
"types"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/picker.php#L229-L247 | train |
Codeinwp/wp-menu-icons | includes/picker.php | Menu_Icons_Picker._add_extra_type_props_data | public static function _add_extra_type_props_data( $props, $id, $type ) {
$settings_fields = array(
'hide_label',
'position',
'vertical_align',
);
if ( 'Font' === $props['controller'] ) {
$settings_fields[] = 'font_size';
}
switch ( $id ) {
case 'image':
$settings_fields[] = 'image_size';
break;
case 'svg':
$settings_fields[] = 'svg_width';
break;
}
$props['data']['settingsFields'] = $settings_fields;
return $props;
} | php | public static function _add_extra_type_props_data( $props, $id, $type ) {
$settings_fields = array(
'hide_label',
'position',
'vertical_align',
);
if ( 'Font' === $props['controller'] ) {
$settings_fields[] = 'font_size';
}
switch ( $id ) {
case 'image':
$settings_fields[] = 'image_size';
break;
case 'svg':
$settings_fields[] = 'svg_width';
break;
}
$props['data']['settingsFields'] = $settings_fields;
return $props;
} | [
"public",
"static",
"function",
"_add_extra_type_props_data",
"(",
"$",
"props",
",",
"$",
"id",
",",
"$",
"type",
")",
"{",
"$",
"settings_fields",
"=",
"array",
"(",
"'hide_label'",
",",
"'position'",
",",
"'vertical_align'",
",",
")",
";",
"if",
"(",
"'... | Add extra icon type properties data
@since 0.9.0
@wp_hook action icon_picker_type_props
@param array $props Icon type properties.
@param string $id Icon type ID.
@param Icon_Picker_Type $type Icon_Picker_Type object.
@return array | [
"Add",
"extra",
"icon",
"type",
"properties",
"data"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/picker.php#L278-L301 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings.is_menu_icons_disabled_for_menu | public static function is_menu_icons_disabled_for_menu( $menu_id = 0 ) {
if ( empty( $menu_id ) ) {
$menu_id = self::get_current_menu_id();
}
// When we're creating a new menu or the recently edited menu
// could not be found.
if ( empty( $menu_id ) ) {
return true;
}
$menu_settings = self::get_menu_settings( $menu_id );
$is_disabled = ! empty( $menu_settings['disabled'] );
return $is_disabled;
} | php | public static function is_menu_icons_disabled_for_menu( $menu_id = 0 ) {
if ( empty( $menu_id ) ) {
$menu_id = self::get_current_menu_id();
}
// When we're creating a new menu or the recently edited menu
// could not be found.
if ( empty( $menu_id ) ) {
return true;
}
$menu_settings = self::get_menu_settings( $menu_id );
$is_disabled = ! empty( $menu_settings['disabled'] );
return $is_disabled;
} | [
"public",
"static",
"function",
"is_menu_icons_disabled_for_menu",
"(",
"$",
"menu_id",
"=",
"0",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"menu_id",
")",
")",
"{",
"$",
"menu_id",
"=",
"self",
"::",
"get_current_menu_id",
"(",
")",
";",
"}",
"// When we're... | Check if menu icons is disabled for a menu
@since 0.8.0
@param int $menu_id Menu ID. Defaults to current menu being edited.
@return bool | [
"Check",
"if",
"menu",
"icons",
"is",
"disabled",
"for",
"a",
"menu"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L122-L137 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings.get_current_menu_id | public static function get_current_menu_id() {
global $nav_menu_selected_id;
if ( ! empty( $nav_menu_selected_id ) ) {
return $nav_menu_selected_id;
}
if ( is_admin() && isset( $_REQUEST['menu'] ) ) {
$menu_id = absint( $_REQUEST['menu'] );
} else {
$menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
}
return $menu_id;
} | php | public static function get_current_menu_id() {
global $nav_menu_selected_id;
if ( ! empty( $nav_menu_selected_id ) ) {
return $nav_menu_selected_id;
}
if ( is_admin() && isset( $_REQUEST['menu'] ) ) {
$menu_id = absint( $_REQUEST['menu'] );
} else {
$menu_id = absint( get_user_option( 'nav_menu_recently_edited' ) );
}
return $menu_id;
} | [
"public",
"static",
"function",
"get_current_menu_id",
"(",
")",
"{",
"global",
"$",
"nav_menu_selected_id",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"nav_menu_selected_id",
")",
")",
"{",
"return",
"$",
"nav_menu_selected_id",
";",
"}",
"if",
"(",
"is_admin",
... | Get ID of menu being edited
@since 0.7.0
@since 0.8.0 Get the recently edited menu from user option.
@return int | [
"Get",
"ID",
"of",
"menu",
"being",
"edited"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L147-L161 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings.get_menu_settings | public static function get_menu_settings( $menu_id ) {
$menu_settings = self::get( sprintf( 'menu_%d', $menu_id ) );
$menu_settings = apply_filters( 'menu_icons_menu_settings', $menu_settings, $menu_id );
if ( ! is_array( $menu_settings ) ) {
$menu_settings = array();
}
return $menu_settings;
} | php | public static function get_menu_settings( $menu_id ) {
$menu_settings = self::get( sprintf( 'menu_%d', $menu_id ) );
$menu_settings = apply_filters( 'menu_icons_menu_settings', $menu_settings, $menu_id );
if ( ! is_array( $menu_settings ) ) {
$menu_settings = array();
}
return $menu_settings;
} | [
"public",
"static",
"function",
"get_menu_settings",
"(",
"$",
"menu_id",
")",
"{",
"$",
"menu_settings",
"=",
"self",
"::",
"get",
"(",
"sprintf",
"(",
"'menu_%d'",
",",
"$",
"menu_id",
")",
")",
";",
"$",
"menu_settings",
"=",
"apply_filters",
"(",
"'men... | Get menu settings
@since 0.3.0
@param int $menu_id
@return array | [
"Get",
"menu",
"settings"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L172-L181 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings._ajax_menu_icons_update_settings | public static function _ajax_menu_icons_update_settings() {
check_ajax_referer( self::UPDATE_KEY, self::UPDATE_KEY );
if ( empty( $_POST['menu-icons']['settings'] ) ) {
wp_send_json_error();
}
$redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
wp_send_json_success( array( 'redirectUrl' => $redirect_url ) );
} | php | public static function _ajax_menu_icons_update_settings() {
check_ajax_referer( self::UPDATE_KEY, self::UPDATE_KEY );
if ( empty( $_POST['menu-icons']['settings'] ) ) {
wp_send_json_error();
}
$redirect_url = self::_update_settings( $_POST['menu-icons']['settings'] ); // Input var okay.
wp_send_json_success( array( 'redirectUrl' => $redirect_url ) );
} | [
"public",
"static",
"function",
"_ajax_menu_icons_update_settings",
"(",
")",
"{",
"check_ajax_referer",
"(",
"self",
"::",
"UPDATE_KEY",
",",
"self",
"::",
"UPDATE_KEY",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"_POST",
"[",
"'menu-icons'",
"]",
"[",
"'setting... | Update settings via ajax
@since 0.7.0
@wp_hook action wp_ajax_menu_icons_update_settings | [
"Update",
"settings",
"via",
"ajax"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L310-L319 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings._admin_notices | public static function _admin_notices() {
$messages = array(
'updated' => __( '<strong>Menu Icons Settings</strong> have been successfully updated.', 'menu-icons' ),
'reset' => __( '<strong>Menu Icons Settings</strong> have been successfully reset.', 'menu-icons' ),
);
$message_type = get_transient( self::TRANSIENT_KEY );
if ( ! empty( $message_type ) && ! empty( $messages[ $message_type ] ) ) {
printf(
'<div class="updated notice is-dismissible"><p>%s</p></div>',
wp_kses( $messages[ $message_type ], array( 'strong' => true ) )
);
}
delete_transient( self::TRANSIENT_KEY );
} | php | public static function _admin_notices() {
$messages = array(
'updated' => __( '<strong>Menu Icons Settings</strong> have been successfully updated.', 'menu-icons' ),
'reset' => __( '<strong>Menu Icons Settings</strong> have been successfully reset.', 'menu-icons' ),
);
$message_type = get_transient( self::TRANSIENT_KEY );
if ( ! empty( $message_type ) && ! empty( $messages[ $message_type ] ) ) {
printf(
'<div class="updated notice is-dismissible"><p>%s</p></div>',
wp_kses( $messages[ $message_type ], array( 'strong' => true ) )
);
}
delete_transient( self::TRANSIENT_KEY );
} | [
"public",
"static",
"function",
"_admin_notices",
"(",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
"'updated'",
"=>",
"__",
"(",
"'<strong>Menu Icons Settings</strong> have been successfully updated.'",
",",
"'menu-icons'",
")",
",",
"'reset'",
"=>",
"__",
"(",
"'... | Print admin notices
@since 0.3.0
@wp_hook action admin_notices | [
"Print",
"admin",
"notices"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L327-L343 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings._meta_box | public static function _meta_box() {
?>
<div class="taxonomydiv">
<ul id="menu-icons-settings-tabs" class="taxonomy-tabs add-menu-item-tabs hide-if-no-js">
<?php foreach ( self::get_fields() as $section ) : ?>
<?php
printf(
'<li><a href="#" title="%s" class="mi-settings-nav-tab" data-type="menu-icons-settings-%s">%s</a></li>',
esc_attr( $section['description'] ),
esc_attr( $section['id'] ),
esc_html( $section['title'] )
);
?>
<?php endforeach; ?>
<?php
printf(
'<li><a href="#" class="mi-settings-nav-tab" data-type="menu-icons-settings-extensions">%s</a></li>',
esc_html__( 'Extensions', 'menu-icons' )
);
?>
</ul>
<?php foreach ( self::_get_fields() as $section_index => $section ) : ?>
<div id="menu-icons-settings-<?php echo esc_attr( $section['id'] ) ?>"
class="tabs-panel _<?php echo esc_attr( $section_index ) ?>">
<h4 class="hide-if-js"><?php echo esc_html( $section['title'] ) ?></h4>
<?php foreach ( $section['fields'] as $field ) : ?>
<div class="_field">
<?php
printf(
'<label for="%s" class="_main">%s</label>',
esc_attr( $field->id ),
esc_html( $field->label )
);
?>
<?php $field->render() ?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
<div id="menu-icons-settings-extensions" class="tabs-panel _extensions">
<h4 class="hide-if-js"><?php echo esc_html__( 'Extensions', 'menu-icons' ) ?></h4>
<ul>
<li><a target="_blank" href="http://wordpress.org/plugins/menu-icons-icomoon/">IcoMoon</a></li>
</ul>
</div>
</div>
<p class="submitbox button-controls">
<?php wp_nonce_field( self::UPDATE_KEY, self::UPDATE_KEY ) ?>
<span class="list-controls">
<?php
printf(
'<a href="%s" title="%s" class="select-all submitdelete">%s</a>',
esc_url(
wp_nonce_url(
admin_url( '/nav-menus.php' ),
self::RESET_KEY,
self::RESET_KEY
)
),
esc_attr__( 'Discard all changes and reset to default state', 'menu-icons' ),
esc_html__( 'Reset', 'menu-icons' )
);
?>
</span>
<span class="add-to-menu">
<span class="spinner"></span>
<?php
submit_button(
__( 'Save Settings', 'menu-icons' ),
'secondary',
'menu-icons-settings-save',
false
);
?>
</span>
</p>
<?php
} | php | public static function _meta_box() {
?>
<div class="taxonomydiv">
<ul id="menu-icons-settings-tabs" class="taxonomy-tabs add-menu-item-tabs hide-if-no-js">
<?php foreach ( self::get_fields() as $section ) : ?>
<?php
printf(
'<li><a href="#" title="%s" class="mi-settings-nav-tab" data-type="menu-icons-settings-%s">%s</a></li>',
esc_attr( $section['description'] ),
esc_attr( $section['id'] ),
esc_html( $section['title'] )
);
?>
<?php endforeach; ?>
<?php
printf(
'<li><a href="#" class="mi-settings-nav-tab" data-type="menu-icons-settings-extensions">%s</a></li>',
esc_html__( 'Extensions', 'menu-icons' )
);
?>
</ul>
<?php foreach ( self::_get_fields() as $section_index => $section ) : ?>
<div id="menu-icons-settings-<?php echo esc_attr( $section['id'] ) ?>"
class="tabs-panel _<?php echo esc_attr( $section_index ) ?>">
<h4 class="hide-if-js"><?php echo esc_html( $section['title'] ) ?></h4>
<?php foreach ( $section['fields'] as $field ) : ?>
<div class="_field">
<?php
printf(
'<label for="%s" class="_main">%s</label>',
esc_attr( $field->id ),
esc_html( $field->label )
);
?>
<?php $field->render() ?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
<div id="menu-icons-settings-extensions" class="tabs-panel _extensions">
<h4 class="hide-if-js"><?php echo esc_html__( 'Extensions', 'menu-icons' ) ?></h4>
<ul>
<li><a target="_blank" href="http://wordpress.org/plugins/menu-icons-icomoon/">IcoMoon</a></li>
</ul>
</div>
</div>
<p class="submitbox button-controls">
<?php wp_nonce_field( self::UPDATE_KEY, self::UPDATE_KEY ) ?>
<span class="list-controls">
<?php
printf(
'<a href="%s" title="%s" class="select-all submitdelete">%s</a>',
esc_url(
wp_nonce_url(
admin_url( '/nav-menus.php' ),
self::RESET_KEY,
self::RESET_KEY
)
),
esc_attr__( 'Discard all changes and reset to default state', 'menu-icons' ),
esc_html__( 'Reset', 'menu-icons' )
);
?>
</span>
<span class="add-to-menu">
<span class="spinner"></span>
<?php
submit_button(
__( 'Save Settings', 'menu-icons' ),
'secondary',
'menu-icons-settings-save',
false
);
?>
</span>
</p>
<?php
} | [
"public",
"static",
"function",
"_meta_box",
"(",
")",
"{",
"?>\n\t\t<div class=\"taxonomydiv\">\n\t\t\t<ul id=\"menu-icons-settings-tabs\" class=\"taxonomy-tabs add-menu-item-tabs hide-if-no-js\">\n\t\t\t\t<?php",
"foreach",
"(",
"self",
"::",
"get_fields",
"(",
")",
"as",
"$",
"s... | Settings meta box
@since 0.3.0 | [
"Settings",
"meta",
"box"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L350-L428 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings.get_fields | public static function get_fields() {
$menu_id = self::get_current_menu_id();
$icon_types = wp_list_pluck( Menu_Icons::get( 'types' ), 'name' );
asort( $icon_types );
$sections = array(
'global' => array(
'id' => 'global',
'title' => __( 'Global', 'menu-icons' ),
'description' => __( 'Global settings', 'menu-icons' ),
'fields' => array(
array(
'id' => 'icon_types',
'type' => 'checkbox',
'label' => __( 'Icon Types', 'menu-icons' ),
'choices' => $icon_types,
'value' => self::get( 'global', 'icon_types' ),
),
),
'args' => array(),
),
);
if ( ! empty( $menu_id ) ) {
$menu_term = get_term( $menu_id, 'nav_menu' );
$menu_key = sprintf( 'menu_%d', $menu_id );
$menu_settings = self::get_menu_settings( $menu_id );
$sections['menu'] = array(
'id' => $menu_key,
'title' => __( 'Current Menu', 'menu-icons' ),
'description' => sprintf(
__( '"%s" menu settings', 'menu-icons' ),
apply_filters( 'single_term_title', $menu_term->name )
),
'fields' => self::get_settings_fields( $menu_settings ),
'args' => array( 'inline_description' => true ),
);
}
return apply_filters( 'menu_icons_settings_sections', $sections, $menu_id );
} | php | public static function get_fields() {
$menu_id = self::get_current_menu_id();
$icon_types = wp_list_pluck( Menu_Icons::get( 'types' ), 'name' );
asort( $icon_types );
$sections = array(
'global' => array(
'id' => 'global',
'title' => __( 'Global', 'menu-icons' ),
'description' => __( 'Global settings', 'menu-icons' ),
'fields' => array(
array(
'id' => 'icon_types',
'type' => 'checkbox',
'label' => __( 'Icon Types', 'menu-icons' ),
'choices' => $icon_types,
'value' => self::get( 'global', 'icon_types' ),
),
),
'args' => array(),
),
);
if ( ! empty( $menu_id ) ) {
$menu_term = get_term( $menu_id, 'nav_menu' );
$menu_key = sprintf( 'menu_%d', $menu_id );
$menu_settings = self::get_menu_settings( $menu_id );
$sections['menu'] = array(
'id' => $menu_key,
'title' => __( 'Current Menu', 'menu-icons' ),
'description' => sprintf(
__( '"%s" menu settings', 'menu-icons' ),
apply_filters( 'single_term_title', $menu_term->name )
),
'fields' => self::get_settings_fields( $menu_settings ),
'args' => array( 'inline_description' => true ),
);
}
return apply_filters( 'menu_icons_settings_sections', $sections, $menu_id );
} | [
"public",
"static",
"function",
"get_fields",
"(",
")",
"{",
"$",
"menu_id",
"=",
"self",
"::",
"get_current_menu_id",
"(",
")",
";",
"$",
"icon_types",
"=",
"wp_list_pluck",
"(",
"Menu_Icons",
"::",
"get",
"(",
"'types'",
")",
",",
"'name'",
")",
";",
"... | Get settings sections
@since 0.3.0
@uses apply_filters() Calls 'menu_icons_settings_sections'.
@return array | [
"Get",
"settings",
"sections"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L437-L479 | train |
Codeinwp/wp-menu-icons | includes/settings.php | Menu_Icons_Settings._get_fields | private static function _get_fields() {
if ( ! class_exists( 'Kucrut_Form_Field' ) ) {
require_once Menu_Icons::get( 'dir' ) . 'includes/library/form-fields.php';
}
$keys = array( 'menu-icons', 'settings' );
$sections = self::get_fields();
foreach ( $sections as &$section ) {
$_keys = array_merge( $keys, array( $section['id'] ) );
$_args = array_merge( array( 'keys' => $_keys ), $section['args'] );
foreach ( $section['fields'] as &$field ) {
$field = Kucrut_Form_Field::create( $field, $_args );
}
unset( $field );
}
unset( $section );
return $sections;
} | php | private static function _get_fields() {
if ( ! class_exists( 'Kucrut_Form_Field' ) ) {
require_once Menu_Icons::get( 'dir' ) . 'includes/library/form-fields.php';
}
$keys = array( 'menu-icons', 'settings' );
$sections = self::get_fields();
foreach ( $sections as &$section ) {
$_keys = array_merge( $keys, array( $section['id'] ) );
$_args = array_merge( array( 'keys' => $_keys ), $section['args'] );
foreach ( $section['fields'] as &$field ) {
$field = Kucrut_Form_Field::create( $field, $_args );
}
unset( $field );
}
unset( $section );
return $sections;
} | [
"private",
"static",
"function",
"_get_fields",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'Kucrut_Form_Field'",
")",
")",
"{",
"require_once",
"Menu_Icons",
"::",
"get",
"(",
"'dir'",
")",
".",
"'includes/library/form-fields.php'",
";",
"}",
"$",
"k... | Get processed settings fields
@since 0.3.0
@access private
@return array | [
"Get",
"processed",
"settings",
"fields"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/settings.php#L620-L642 | train |
Codeinwp/wp-menu-icons | includes/meta.php | Menu_Icons_Meta.get | public static function get( $id, $defaults = array() ) {
$defaults = wp_parse_args( $defaults, self::$defaults );
$value = get_post_meta( $id, self::KEY, true );
$value = wp_parse_args( (array) $value, $defaults );
// Backward-compatibility.
if ( empty( $value['icon'] ) &&
! empty( $value['type'] ) &&
! empty( $value[ "{$value['type']}-icon" ] )
) {
$value['icon'] = $value[ "{$value['type']}-icon" ];
}
if ( ! empty( $value['width'] ) ) {
$value['svg_width'] = $value['width'];
}
unset( $value['width'] );
if ( isset( $value['position'] ) &&
! in_array( $value['position'], array( 'before', 'after' ), true )
) {
$value['position'] = $defaults['position'];
}
if ( isset( $value['size'] ) && ! isset( $value['font_size'] ) ) {
$value['font_size'] = $value['size'];
unset( $value['size'] );
}
// The values below will NOT be saved
if ( ! empty( $value['icon'] ) &&
in_array( $value['type'], array( 'image', 'svg' ), true )
) {
$value['url'] = wp_get_attachment_image_url( $value['icon'], 'thumbnail', false );
}
return $value;
} | php | public static function get( $id, $defaults = array() ) {
$defaults = wp_parse_args( $defaults, self::$defaults );
$value = get_post_meta( $id, self::KEY, true );
$value = wp_parse_args( (array) $value, $defaults );
// Backward-compatibility.
if ( empty( $value['icon'] ) &&
! empty( $value['type'] ) &&
! empty( $value[ "{$value['type']}-icon" ] )
) {
$value['icon'] = $value[ "{$value['type']}-icon" ];
}
if ( ! empty( $value['width'] ) ) {
$value['svg_width'] = $value['width'];
}
unset( $value['width'] );
if ( isset( $value['position'] ) &&
! in_array( $value['position'], array( 'before', 'after' ), true )
) {
$value['position'] = $defaults['position'];
}
if ( isset( $value['size'] ) && ! isset( $value['font_size'] ) ) {
$value['font_size'] = $value['size'];
unset( $value['size'] );
}
// The values below will NOT be saved
if ( ! empty( $value['icon'] ) &&
in_array( $value['type'], array( 'image', 'svg' ), true )
) {
$value['url'] = wp_get_attachment_image_url( $value['icon'], 'thumbnail', false );
}
return $value;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"defaults",
"=",
"array",
"(",
")",
")",
"{",
"$",
"defaults",
"=",
"wp_parse_args",
"(",
"$",
"defaults",
",",
"self",
"::",
"$",
"defaults",
")",
";",
"$",
"value",
"=",
"get_post_met... | Get menu item meta value
@since 0.3.0
@since 0.9.0 Add $defaults parameter.
@param int $id Menu item ID.
@param array $defaults Optional. Default value.
@return array | [
"Get",
"menu",
"item",
"meta",
"value"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/meta.php#L67-L104 | train |
Codeinwp/wp-menu-icons | includes/meta.php | Menu_Icons_Meta.update | public static function update( $id, $value ) {
/**
* Allow plugins/themes to filter the values
*
* Deprecated.
*
* @since 0.1.0
* @param array $value Metadata value.
* @param int $id Menu item ID.
*/
$_value = apply_filters( 'menu_icons_values', $value, $id );
if ( $_value !== $value && WP_DEBUG ) {
_deprecated_function( 'menu_icons_values', '0.8.0', 'menu_icons_item_meta_values' );
}
/**
* Allow plugins/themes to filter the values
*
* @since 0.8.0
* @param array $value Metadata value.
* @param int $id Menu item ID.
*/
$value = apply_filters( 'menu_icons_item_meta_values', $_value, $id );
// Don't bother saving if `type` or `icon` is not set.
if ( empty( $value['type'] ) || empty( $value['icon'] ) ) {
$value = false;
}
// Update
if ( ! empty( $value ) ) {
update_post_meta( $id, self::KEY, $value );
} else {
delete_post_meta( $id, self::KEY );
}
} | php | public static function update( $id, $value ) {
/**
* Allow plugins/themes to filter the values
*
* Deprecated.
*
* @since 0.1.0
* @param array $value Metadata value.
* @param int $id Menu item ID.
*/
$_value = apply_filters( 'menu_icons_values', $value, $id );
if ( $_value !== $value && WP_DEBUG ) {
_deprecated_function( 'menu_icons_values', '0.8.0', 'menu_icons_item_meta_values' );
}
/**
* Allow plugins/themes to filter the values
*
* @since 0.8.0
* @param array $value Metadata value.
* @param int $id Menu item ID.
*/
$value = apply_filters( 'menu_icons_item_meta_values', $_value, $id );
// Don't bother saving if `type` or `icon` is not set.
if ( empty( $value['type'] ) || empty( $value['icon'] ) ) {
$value = false;
}
// Update
if ( ! empty( $value ) ) {
update_post_meta( $id, self::KEY, $value );
} else {
delete_post_meta( $id, self::KEY );
}
} | [
"public",
"static",
"function",
"update",
"(",
"$",
"id",
",",
"$",
"value",
")",
"{",
"/**\n\t\t * Allow plugins/themes to filter the values\n\t\t *\n\t\t * Deprecated.\n\t\t *\n\t\t * @since 0.1.0\n\t\t * @param array $value Metadata value.\n\t\t * @param int $id Menu item ID.\n\t\t *... | Update menu item metadata
@since 0.9.0
@param int $id Menu item ID.
@param mixed $value Metadata value.
@return void | [
"Update",
"menu",
"item",
"metadata"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/meta.php#L117-L153 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End.init | public static function init() {
$active_types = Menu_Icons_Settings::get( 'global', 'icon_types' );
if ( empty( $active_types ) ) {
return;
}
foreach ( Menu_Icons::get( 'types' ) as $type ) {
if ( in_array( $type->id, $active_types, true ) ) {
self::$icon_types[ $type->id ] = $type;
}
}
/**
* Allow themes/plugins to override the hidden label class
*
* @since 0.8.0
* @param string $hidden_label_class Hidden label class.
* @return string
*/
self::$hidden_label_class = apply_filters( 'menu_icons_hidden_label_class', self::$hidden_label_class );
/**
* Allow themes/plugins to override default inline style
*
* @since 0.9.0
* @param array $default_style Default inline style.
* @return array
*/
self::$default_style = apply_filters( 'menu_icons_default_style', self::$default_style );
add_action( 'wp_enqueue_scripts', array( __CLASS__, '_enqueue_styles' ), 7 );
add_filter( 'wp_nav_menu_args', array( __CLASS__, '_add_menu_item_title_filter' ) );
add_filter( 'wp_nav_menu', array( __CLASS__, '_remove_menu_item_title_filter' ) );
} | php | public static function init() {
$active_types = Menu_Icons_Settings::get( 'global', 'icon_types' );
if ( empty( $active_types ) ) {
return;
}
foreach ( Menu_Icons::get( 'types' ) as $type ) {
if ( in_array( $type->id, $active_types, true ) ) {
self::$icon_types[ $type->id ] = $type;
}
}
/**
* Allow themes/plugins to override the hidden label class
*
* @since 0.8.0
* @param string $hidden_label_class Hidden label class.
* @return string
*/
self::$hidden_label_class = apply_filters( 'menu_icons_hidden_label_class', self::$hidden_label_class );
/**
* Allow themes/plugins to override default inline style
*
* @since 0.9.0
* @param array $default_style Default inline style.
* @return array
*/
self::$default_style = apply_filters( 'menu_icons_default_style', self::$default_style );
add_action( 'wp_enqueue_scripts', array( __CLASS__, '_enqueue_styles' ), 7 );
add_filter( 'wp_nav_menu_args', array( __CLASS__, '_add_menu_item_title_filter' ) );
add_filter( 'wp_nav_menu', array( __CLASS__, '_remove_menu_item_title_filter' ) );
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"$",
"active_types",
"=",
"Menu_Icons_Settings",
"::",
"get",
"(",
"'global'",
",",
"'icon_types'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"active_types",
")",
")",
"{",
"return",
";",
"}",
"foreach... | Add hooks for front-end functionalities
@since 0.9.0 | [
"Add",
"hooks",
"for",
"front",
"-",
"end",
"functionalities"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L60-L94 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End._add_icon | public static function _add_icon( $title, $id ) {
$meta = Menu_Icons_Meta::get( $id );
$icon = self::get_icon( $meta );
if ( empty( $icon ) ) {
return $title;
}
$title_class = ! empty( $meta['hide_label'] ) ? self::$hidden_label_class : '';
$title_wrapped = sprintf(
'<span%s>%s</span>',
( ! empty( $title_class ) ) ? sprintf( ' class="%s"', esc_attr( $title_class ) ) : '',
$title
);
if ( 'after' === $meta['position'] ) {
$title_with_icon = "{$title_wrapped}{$icon}";
} else {
$title_with_icon = "{$icon}{$title_wrapped}";
}
/**
* Allow plugins/themes to override menu item markup
*
* @since 0.8.0
*
* @param string $title_with_icon Menu item markup after the icon is added.
* @param integer $id Menu item ID.
* @param array $meta Menu item metadata values.
* @param string $title Original menu item title.
*
* @return string
*/
$title_with_icon = apply_filters( 'menu_icons_item_title', $title_with_icon, $id, $meta, $title );
return $title_with_icon;
} | php | public static function _add_icon( $title, $id ) {
$meta = Menu_Icons_Meta::get( $id );
$icon = self::get_icon( $meta );
if ( empty( $icon ) ) {
return $title;
}
$title_class = ! empty( $meta['hide_label'] ) ? self::$hidden_label_class : '';
$title_wrapped = sprintf(
'<span%s>%s</span>',
( ! empty( $title_class ) ) ? sprintf( ' class="%s"', esc_attr( $title_class ) ) : '',
$title
);
if ( 'after' === $meta['position'] ) {
$title_with_icon = "{$title_wrapped}{$icon}";
} else {
$title_with_icon = "{$icon}{$title_wrapped}";
}
/**
* Allow plugins/themes to override menu item markup
*
* @since 0.8.0
*
* @param string $title_with_icon Menu item markup after the icon is added.
* @param integer $id Menu item ID.
* @param array $meta Menu item metadata values.
* @param string $title Original menu item title.
*
* @return string
*/
$title_with_icon = apply_filters( 'menu_icons_item_title', $title_with_icon, $id, $meta, $title );
return $title_with_icon;
} | [
"public",
"static",
"function",
"_add_icon",
"(",
"$",
"title",
",",
"$",
"id",
")",
"{",
"$",
"meta",
"=",
"Menu_Icons_Meta",
"::",
"get",
"(",
"$",
"id",
")",
";",
"$",
"icon",
"=",
"self",
"::",
"get_icon",
"(",
"$",
"meta",
")",
";",
"if",
"(... | Add icon to menu item title
@since 0.1.0
@since 0.9.0 Renamed the method to `add_icon()`.
@wp_hook filter the_title
@param string $title Menu item title.
@param int $id Menu item ID.
@return string | [
"Add",
"icon",
"to",
"menu",
"item",
"title"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L218-L254 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End.get_icon_style | public static function get_icon_style( $meta, $keys, $as_attribute = true ) {
$style_a = array();
$style_s = '';
foreach ( $keys as $key ) {
if ( ! isset( self::$default_style[ $key ] ) ) {
continue;
}
$rule = self::$default_style[ $key ];
if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) {
continue;
}
$value = $meta[ $key ];
if ( ! empty( $rule['unit'] ) ) {
$value .= $rule['unit'];
}
$style_a[ $rule['property'] ] = $value;
}
if ( empty( $style_a ) ) {
return $style_s;
}
foreach ( $style_a as $key => $value ) {
$style_s .= "{$key}:{$value};";
}
$style_s = esc_attr( $style_s );
if ( $as_attribute ) {
$style_s = sprintf( ' style="%s"', $style_s );
}
return $style_s;
} | php | public static function get_icon_style( $meta, $keys, $as_attribute = true ) {
$style_a = array();
$style_s = '';
foreach ( $keys as $key ) {
if ( ! isset( self::$default_style[ $key ] ) ) {
continue;
}
$rule = self::$default_style[ $key ];
if ( ! isset( $meta[ $key ] ) || $meta[ $key ] === $rule['value'] ) {
continue;
}
$value = $meta[ $key ];
if ( ! empty( $rule['unit'] ) ) {
$value .= $rule['unit'];
}
$style_a[ $rule['property'] ] = $value;
}
if ( empty( $style_a ) ) {
return $style_s;
}
foreach ( $style_a as $key => $value ) {
$style_s .= "{$key}:{$value};";
}
$style_s = esc_attr( $style_s );
if ( $as_attribute ) {
$style_s = sprintf( ' style="%s"', $style_s );
}
return $style_s;
} | [
"public",
"static",
"function",
"get_icon_style",
"(",
"$",
"meta",
",",
"$",
"keys",
",",
"$",
"as_attribute",
"=",
"true",
")",
"{",
"$",
"style_a",
"=",
"array",
"(",
")",
";",
"$",
"style_s",
"=",
"''",
";",
"foreach",
"(",
"$",
"keys",
"as",
"... | Get icon style
@since 0.9.0
@param array $meta Menu item meta value.
@param array $keys Style properties.
@param bool $as_attribute Optional. Whether to output the style as HTML attribute or value only.
Defaults to TRUE.
@return string | [
"Get",
"icon",
"style"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L311-L349 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End.get_icon_classes | public static function get_icon_classes( $meta, $output = 'string' ) {
$classes = array( '_mi' );
if ( empty( $meta['hide_label'] ) ) {
$classes[] = "_{$meta['position']}";
}
if ( 'string' === $output ) {
$classes = implode( ' ', $classes );
}
return $classes;
} | php | public static function get_icon_classes( $meta, $output = 'string' ) {
$classes = array( '_mi' );
if ( empty( $meta['hide_label'] ) ) {
$classes[] = "_{$meta['position']}";
}
if ( 'string' === $output ) {
$classes = implode( ' ', $classes );
}
return $classes;
} | [
"public",
"static",
"function",
"get_icon_classes",
"(",
"$",
"meta",
",",
"$",
"output",
"=",
"'string'",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
"'_mi'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"meta",
"[",
"'hide_label'",
"]",
")",
")",
"{",
... | Get icon classes
@since 0.9.0
@param array $meta Menu item meta value.
@param string $output Whether to output the classes as string or array. Defaults to string.
@return string|array | [
"Get",
"icon",
"classes"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L360-L372 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End.get_font_icon | public static function get_font_icon( $meta ) {
$classes = sprintf( '%s %s %s', self::get_icon_classes( $meta ), $meta['type'], $meta['icon'] );
$style = self::get_icon_style( $meta, array( 'font_size', 'vertical_align' ) );
return sprintf( '<i class="%s" aria-hidden="true"%s></i>', esc_attr( $classes ), $style );
} | php | public static function get_font_icon( $meta ) {
$classes = sprintf( '%s %s %s', self::get_icon_classes( $meta ), $meta['type'], $meta['icon'] );
$style = self::get_icon_style( $meta, array( 'font_size', 'vertical_align' ) );
return sprintf( '<i class="%s" aria-hidden="true"%s></i>', esc_attr( $classes ), $style );
} | [
"public",
"static",
"function",
"get_font_icon",
"(",
"$",
"meta",
")",
"{",
"$",
"classes",
"=",
"sprintf",
"(",
"'%s %s %s'",
",",
"self",
"::",
"get_icon_classes",
"(",
"$",
"meta",
")",
",",
"$",
"meta",
"[",
"'type'",
"]",
",",
"$",
"meta",
"[",
... | Get font icon
@since 0.9.0
@param array $meta Menu item meta value.
@return string | [
"Get",
"font",
"icon"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L382-L387 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End.get_image_icon | public static function get_image_icon( $meta ) {
$args = array(
'class' => sprintf( '%s _image', self::get_icon_classes( $meta ) ),
'aria-hidden' => 'true',
);
$style = self::get_icon_style( $meta, array( 'vertical_align' ), false );
if ( ! empty( $style ) ) {
$args['style'] = $style;
}
return wp_get_attachment_image( $meta['icon'], $meta['image_size'], false, $args );
} | php | public static function get_image_icon( $meta ) {
$args = array(
'class' => sprintf( '%s _image', self::get_icon_classes( $meta ) ),
'aria-hidden' => 'true',
);
$style = self::get_icon_style( $meta, array( 'vertical_align' ), false );
if ( ! empty( $style ) ) {
$args['style'] = $style;
}
return wp_get_attachment_image( $meta['icon'], $meta['image_size'], false, $args );
} | [
"public",
"static",
"function",
"get_image_icon",
"(",
"$",
"meta",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"'class'",
"=>",
"sprintf",
"(",
"'%s _image'",
",",
"self",
"::",
"get_icon_classes",
"(",
"$",
"meta",
")",
")",
",",
"'aria-hidden'",
"=>",
"... | Get image icon
@since 0.9.0
@param array $meta Menu item meta value.
@return string | [
"Get",
"image",
"icon"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L397-L409 | train |
Codeinwp/wp-menu-icons | includes/front.php | Menu_Icons_Front_End.get_svg_icon | public static function get_svg_icon( $meta ) {
$classes = sprintf( '%s _svg', self::get_icon_classes( $meta ) );
$style = self::get_icon_style( $meta, array( 'svg_width', 'vertical_align' ) );
return sprintf(
'<img src="%s" class="%s" aria-hidden="true"%s />',
esc_url( wp_get_attachment_url( $meta['icon'] ) ),
esc_attr( $classes ),
$style
);
} | php | public static function get_svg_icon( $meta ) {
$classes = sprintf( '%s _svg', self::get_icon_classes( $meta ) );
$style = self::get_icon_style( $meta, array( 'svg_width', 'vertical_align' ) );
return sprintf(
'<img src="%s" class="%s" aria-hidden="true"%s />',
esc_url( wp_get_attachment_url( $meta['icon'] ) ),
esc_attr( $classes ),
$style
);
} | [
"public",
"static",
"function",
"get_svg_icon",
"(",
"$",
"meta",
")",
"{",
"$",
"classes",
"=",
"sprintf",
"(",
"'%s _svg'",
",",
"self",
"::",
"get_icon_classes",
"(",
"$",
"meta",
")",
")",
";",
"$",
"style",
"=",
"self",
"::",
"get_icon_style",
"(",
... | Get SVG icon
@since 0.9.0
@param array $meta Menu item meta value.
@return string | [
"Get",
"SVG",
"icon"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/front.php#L419-L429 | train |
Codeinwp/wp-menu-icons | includes/library/form-fields.php | Kucrut_Form_Field.create_name | protected function create_name() {
$format = '%s';
$format .= str_repeat( '[%s]', ( count( $this->args->keys ) - 1 ) );
return $this->create_id_name( $format );
} | php | protected function create_name() {
$format = '%s';
$format .= str_repeat( '[%s]', ( count( $this->args->keys ) - 1 ) );
return $this->create_id_name( $format );
} | [
"protected",
"function",
"create_name",
"(",
")",
"{",
"$",
"format",
"=",
"'%s'",
";",
"$",
"format",
".=",
"str_repeat",
"(",
"'[%s]'",
",",
"(",
"count",
"(",
"$",
"this",
"->",
"args",
"->",
"keys",
")",
"-",
"1",
")",
")",
";",
"return",
"$",
... | Create name attribute
@since 0.1.0
@access protected
@return string | [
"Create",
"name",
"attribute"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/library/form-fields.php#L260-L265 | train |
Codeinwp/wp-menu-icons | includes/library/form-fields.php | Kucrut_Form_Field.build_attributes | protected function build_attributes( $excludes = array() ) {
$excludes = array_filter( (array) $excludes );
$attributes = '';
foreach ( $this->attributes as $key => $value ) {
if ( in_array( $key, $excludes, true ) ) {
continue;
}
if ( 'class' === $key ) {
$value = implode( ' ', (array) $value );
}
$attributes .= sprintf(
' %s="%s"',
esc_attr( $key ),
esc_attr( $value )
);
}
return $attributes;
} | php | protected function build_attributes( $excludes = array() ) {
$excludes = array_filter( (array) $excludes );
$attributes = '';
foreach ( $this->attributes as $key => $value ) {
if ( in_array( $key, $excludes, true ) ) {
continue;
}
if ( 'class' === $key ) {
$value = implode( ' ', (array) $value );
}
$attributes .= sprintf(
' %s="%s"',
esc_attr( $key ),
esc_attr( $value )
);
}
return $attributes;
} | [
"protected",
"function",
"build_attributes",
"(",
"$",
"excludes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"excludes",
"=",
"array_filter",
"(",
"(",
"array",
")",
"$",
"excludes",
")",
";",
"$",
"attributes",
"=",
"''",
";",
"foreach",
"(",
"$",
"this"... | Build field attributes
@since 0.1.0
@param array $excludes Attributes to be excluded
@return string | [
"Build",
"field",
"attributes"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/library/form-fields.php#L283-L304 | train |
Codeinwp/wp-menu-icons | includes/library/form-fields.php | Kucrut_Form_Field.description | public function description() {
if ( ! empty( $this->field['description'] ) ) {
$tag = ( ! empty( $this->args->inline_description ) ) ? 'span' : 'p';
printf( // WPCS: XSS ok.
'<%1$s class="description">%2$s</%1$s>',
$tag,
wp_kses( $this->field['description'], $this->allowed_html )
);
}
} | php | public function description() {
if ( ! empty( $this->field['description'] ) ) {
$tag = ( ! empty( $this->args->inline_description ) ) ? 'span' : 'p';
printf( // WPCS: XSS ok.
'<%1$s class="description">%2$s</%1$s>',
$tag,
wp_kses( $this->field['description'], $this->allowed_html )
);
}
} | [
"public",
"function",
"description",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"field",
"[",
"'description'",
"]",
")",
")",
"{",
"$",
"tag",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"args",
"->",
"inline_description",
... | Print field description
@since 0.1.0 | [
"Print",
"field",
"description"
] | aaa298cd11d43b305358df62f99181efbd1061af | https://github.com/Codeinwp/wp-menu-icons/blob/aaa298cd11d43b305358df62f99181efbd1061af/includes/library/form-fields.php#L320-L330 | train |
lakshmaji/Thumbnail | src/Thumbnail.php | Thumbnail.getThumbnail | public function getThumbnail($video_path,$storage_path,$thumnail_name,$tts=10)
{
try {
if(config('thumbnail.binaries.enabled')) {
$ffmpeg = FFMpeg::create(
array(
'ffmpeg.binaries' => config('thumbnail.binaries.path.ffmpeg'),
'ffprobe.binaries' => config('thumbnail.binaries.path.ffprobe'),
'timeout' => config('thumbnail.binaries.path.timeout'),
'ffmpeg.threads' => config('thumbnail.binaries.path.threads'),
)
);
}
else {
$ffmpeg = FFMpeg::create();
}
$video = $ffmpeg->open($video_path);
$result_image = $storage_path.'/'.$thumnail_name;
$video
->filters()
->resize(new Coordinate\Dimension(config('thumbnail.dimensions.height'), config('thumbnail.dimensions.width')))
->synchronize();//320, 240
$video
->frame(Coordinate\TimeCode::fromSeconds($tts))
->save($result_image);
if($video) {
if(config('thumbnail.watermark.image.enabled')) {
$src = imagecreatefrompng(config('thumbnail.watermark.image.path'));
$got_image = imagecreatefromjpeg($result_image);
// Get dimensions of image screen shot
$width = imagesx($got_image);
$height = imagesy($got_image);
// final output image dimensions
$newwidth = config('thumbnail.dimensions.width');
$newheight = config('thumbnail.dimensions.height');
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$got_image,0,0,0,0,$newwidth,$newheight,$width,$height);
// Set the brush
imagesetbrush($tmp, $src);
// Draw a couple of brushes, each overlaying each
imageline($tmp, imagesx($tmp) / 2, imagesy($tmp) / 2, imagesx($tmp) / 2, imagesy($tmp) / 2, IMG_COLOR_BRUSHED);
imagejpeg($tmp,$result_image,100);
}
return true;
}
else {
return false;
}
} catch(Exception $thumbnailException) {
// error processing request
throw new Exception($thumbnailException->getMessage());
}
} | php | public function getThumbnail($video_path,$storage_path,$thumnail_name,$tts=10)
{
try {
if(config('thumbnail.binaries.enabled')) {
$ffmpeg = FFMpeg::create(
array(
'ffmpeg.binaries' => config('thumbnail.binaries.path.ffmpeg'),
'ffprobe.binaries' => config('thumbnail.binaries.path.ffprobe'),
'timeout' => config('thumbnail.binaries.path.timeout'),
'ffmpeg.threads' => config('thumbnail.binaries.path.threads'),
)
);
}
else {
$ffmpeg = FFMpeg::create();
}
$video = $ffmpeg->open($video_path);
$result_image = $storage_path.'/'.$thumnail_name;
$video
->filters()
->resize(new Coordinate\Dimension(config('thumbnail.dimensions.height'), config('thumbnail.dimensions.width')))
->synchronize();//320, 240
$video
->frame(Coordinate\TimeCode::fromSeconds($tts))
->save($result_image);
if($video) {
if(config('thumbnail.watermark.image.enabled')) {
$src = imagecreatefrompng(config('thumbnail.watermark.image.path'));
$got_image = imagecreatefromjpeg($result_image);
// Get dimensions of image screen shot
$width = imagesx($got_image);
$height = imagesy($got_image);
// final output image dimensions
$newwidth = config('thumbnail.dimensions.width');
$newheight = config('thumbnail.dimensions.height');
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$got_image,0,0,0,0,$newwidth,$newheight,$width,$height);
// Set the brush
imagesetbrush($tmp, $src);
// Draw a couple of brushes, each overlaying each
imageline($tmp, imagesx($tmp) / 2, imagesy($tmp) / 2, imagesx($tmp) / 2, imagesy($tmp) / 2, IMG_COLOR_BRUSHED);
imagejpeg($tmp,$result_image,100);
}
return true;
}
else {
return false;
}
} catch(Exception $thumbnailException) {
// error processing request
throw new Exception($thumbnailException->getMessage());
}
} | [
"public",
"function",
"getThumbnail",
"(",
"$",
"video_path",
",",
"$",
"storage_path",
",",
"$",
"thumnail_name",
",",
"$",
"tts",
"=",
"10",
")",
"{",
"try",
"{",
"if",
"(",
"config",
"(",
"'thumbnail.binaries.enabled'",
")",
")",
"{",
"$",
"ffmpeg",
"... | Create Thumbnail Image
Create a new image from video source based on the specified parameters.
This method will allows video to convert to image.
This method will add watermark to image
@access public
@param video_path Video resource source path
@param storage_path Image resource destination path
@param thumbnail_name Image name for output
@param tts Time to take screenshot [optional]
@return boolean
@since Method available since Release 1.0.0
@version 1.4.4
@author lakshmajim <lakshmajee88@gmail.com> | [
"Create",
"Thumbnail",
"Image"
] | a0f4cfe4efe543253695a573551df51be8e91959 | https://github.com/lakshmaji/Thumbnail/blob/a0f4cfe4efe543253695a573551df51be8e91959/src/Thumbnail.php#L50-L111 | train |
lakshmaji/Thumbnail | src/Thumbnail.php | Thumbnail.clipWebM | public function clipWebM($src, $dest, $from, $to)
{
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open($src);
if($from >= $to)
throw new Exception("The start clipping time must be less than end clipping time");
$video
->filters()
->clip(Coordinate\TimeCode::fromSeconds($from), Coordinate\TimeCode::fromSeconds($to));
$video
->save(new Video\WebM(), $dest);
if($video) return true;
else return false;
} | php | public function clipWebM($src, $dest, $from, $to)
{
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open($src);
if($from >= $to)
throw new Exception("The start clipping time must be less than end clipping time");
$video
->filters()
->clip(Coordinate\TimeCode::fromSeconds($from), Coordinate\TimeCode::fromSeconds($to));
$video
->save(new Video\WebM(), $dest);
if($video) return true;
else return false;
} | [
"public",
"function",
"clipWebM",
"(",
"$",
"src",
",",
"$",
"dest",
",",
"$",
"from",
",",
"$",
"to",
")",
"{",
"$",
"ffmpeg",
"=",
"FFMpeg",
"::",
"create",
"(",
")",
";",
"$",
"video",
"=",
"$",
"ffmpeg",
"->",
"open",
"(",
"$",
"src",
")",
... | Clips the given video
Create a new clipped video of type WebM
from the given video
@access public
@param src Video resource source path
@param dest Video resource destination path
@param from Clipping start time
@param to Clipping end time
@return boolean
@since Method available since Release 1.4.4
@version 1.4.4
@author lakshmajim <lakshmajee88@gmail.com> | [
"Clips",
"the",
"given",
"video"
] | a0f4cfe4efe543253695a573551df51be8e91959 | https://github.com/lakshmaji/Thumbnail/blob/a0f4cfe4efe543253695a573551df51be8e91959/src/Thumbnail.php#L134-L151 | train |
lakshmaji/Thumbnail | src/Thumbnail.php | Thumbnail.watermarkVideo | public function watermarkVideo($src, $dest)
{
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open($src);
if(!config('thumbnail.watermark.video.enabled'))
throw new Exception("Configure watermark path in env file");
// $video->filters()->resize($dimension, $mode, $useStandards);
$video
->filters()
->watermark(config('thumbnail.watermark.video.path'), array(
'position' => 'relative',
'bottom' => 50,
'right' => 50,
));
$video
->save(new Video\WebM(), $dest);
if($video) return true;
else return false;
} | php | public function watermarkVideo($src, $dest)
{
$ffmpeg = FFMpeg::create();
$video = $ffmpeg->open($src);
if(!config('thumbnail.watermark.video.enabled'))
throw new Exception("Configure watermark path in env file");
// $video->filters()->resize($dimension, $mode, $useStandards);
$video
->filters()
->watermark(config('thumbnail.watermark.video.path'), array(
'position' => 'relative',
'bottom' => 50,
'right' => 50,
));
$video
->save(new Video\WebM(), $dest);
if($video) return true;
else return false;
} | [
"public",
"function",
"watermarkVideo",
"(",
"$",
"src",
",",
"$",
"dest",
")",
"{",
"$",
"ffmpeg",
"=",
"FFMpeg",
"::",
"create",
"(",
")",
";",
"$",
"video",
"=",
"$",
"ffmpeg",
"->",
"open",
"(",
"$",
"src",
")",
";",
"if",
"(",
"!",
"config",... | Insert watermark on the given video
@access public
@param src Video resource source path
@param dest Video resource destination path
@return boolean
@since Method available since Release 1.4.4
@version 1.4.4
@author lakshmajim <lakshmajee88@gmail.com> | [
"Insert",
"watermark",
"on",
"the",
"given",
"video"
] | a0f4cfe4efe543253695a573551df51be8e91959 | https://github.com/lakshmaji/Thumbnail/blob/a0f4cfe4efe543253695a573551df51be8e91959/src/Thumbnail.php#L170-L193 | train |
generationtux/jwt-artisan | src/GetsJwtToken.php | GetsJwtToken.getToken | public function getToken($request = null)
{
$request = $request ?: $this->makeRequest();
list($token) = sscanf($request->header($this->getAuthHeaderKey()), 'Bearer %s');
if( ! $token) {
$name = $this->getInputName();
$token = $request->input($name);
}
return $token;
} | php | public function getToken($request = null)
{
$request = $request ?: $this->makeRequest();
list($token) = sscanf($request->header($this->getAuthHeaderKey()), 'Bearer %s');
if( ! $token) {
$name = $this->getInputName();
$token = $request->input($name);
}
return $token;
} | [
"public",
"function",
"getToken",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"request",
"=",
"$",
"request",
"?",
":",
"$",
"this",
"->",
"makeRequest",
"(",
")",
";",
"list",
"(",
"$",
"token",
")",
"=",
"sscanf",
"(",
"$",
"request",
"->",
... | Get the JWT token from the request
We'll check the Authorization header first, and if that's not set
then check the input to see if its provided there instead.
@param Request|null $request
@return string|null | [
"Get",
"the",
"JWT",
"token",
"from",
"the",
"request"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/GetsJwtToken.php#L26-L37 | train |
generationtux/jwt-artisan | src/GetsJwtToken.php | GetsJwtToken.jwtToken | public function jwtToken($request = null)
{
$token = $this->getToken($request);
if( ! $token) throw new NoTokenException('JWT token is required.');
$driver = $this->makeDriver();
$jwt = new JwtToken($driver);
$jwt->setToken($token);
return $jwt;
} | php | public function jwtToken($request = null)
{
$token = $this->getToken($request);
if( ! $token) throw new NoTokenException('JWT token is required.');
$driver = $this->makeDriver();
$jwt = new JwtToken($driver);
$jwt->setToken($token);
return $jwt;
} | [
"public",
"function",
"jwtToken",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"throw",
"new",
"NoTokenException",
"(",
"'JWT token is re... | Create a new JWT token object from the token in the request
@param Request|null $request
@return JwtToken
@throws NoTokenException | [
"Create",
"a",
"new",
"JWT",
"token",
"object",
"from",
"the",
"token",
"in",
"the",
"request"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/GetsJwtToken.php#L48-L58 | train |
generationtux/jwt-artisan | src/GetsJwtToken.php | GetsJwtToken.jwtPayload | public function jwtPayload($path = null, $request = null)
{
$jwt = $this->jwtToken($request);
return $jwt->payload($path);
} | php | public function jwtPayload($path = null, $request = null)
{
$jwt = $this->jwtToken($request);
return $jwt->payload($path);
} | [
"public",
"function",
"jwtPayload",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"jwt",
"=",
"$",
"this",
"->",
"jwtToken",
"(",
"$",
"request",
")",
";",
"return",
"$",
"jwt",
"->",
"payload",
"(",
"$",
"path",
... | Get payload from JWT token
@param string|null $path to query payload
@param Request|null $request
@return array | [
"Get",
"payload",
"from",
"JWT",
"token"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/GetsJwtToken.php#L68-L73 | train |
generationtux/jwt-artisan | src/Drivers/FirebaseDriver.php | FirebaseDriver.validateToken | public function validateToken($token, $secret, $algorithm = 'HS256')
{
try {
JWT::decode($token, $secret, [$algorithm]);
} catch(\Exception $e) {
return false;
}
return true;
} | php | public function validateToken($token, $secret, $algorithm = 'HS256')
{
try {
JWT::decode($token, $secret, [$algorithm]);
} catch(\Exception $e) {
return false;
}
return true;
} | [
"public",
"function",
"validateToken",
"(",
"$",
"token",
",",
"$",
"secret",
",",
"$",
"algorithm",
"=",
"'HS256'",
")",
"{",
"try",
"{",
"JWT",
"::",
"decode",
"(",
"$",
"token",
",",
"$",
"secret",
",",
"[",
"$",
"algorithm",
"]",
")",
";",
"}",... | Validate that the provided token
@param string $token
@param string $secret
@param string $algorithm
@return bool | [
"Validate",
"that",
"the",
"provided",
"token"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/Drivers/FirebaseDriver.php#L28-L37 | train |
generationtux/jwt-artisan | src/Drivers/FirebaseDriver.php | FirebaseDriver.decodeToken | public function decodeToken($token, $secret, $algorithm = 'HS256')
{
$decoded = JWT::decode($token, $secret, [$algorithm]);
return $this->convertObjectToArray($decoded);
} | php | public function decodeToken($token, $secret, $algorithm = 'HS256')
{
$decoded = JWT::decode($token, $secret, [$algorithm]);
return $this->convertObjectToArray($decoded);
} | [
"public",
"function",
"decodeToken",
"(",
"$",
"token",
",",
"$",
"secret",
",",
"$",
"algorithm",
"=",
"'HS256'",
")",
"{",
"$",
"decoded",
"=",
"JWT",
"::",
"decode",
"(",
"$",
"token",
",",
"$",
"secret",
",",
"[",
"$",
"algorithm",
"]",
")",
";... | Decode the provided token into an array
@param string $token
@param string $secret
@param string $algorithm
@return array | [
"Decode",
"the",
"provided",
"token",
"into",
"an",
"array"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/Drivers/FirebaseDriver.php#L62-L67 | train |
generationtux/jwt-artisan | src/Drivers/FirebaseDriver.php | FirebaseDriver.convertObjectToArray | private function convertObjectToArray($data)
{
$converted = [];
foreach($data as $key => $value) {
if(is_object($value)) {
$converted[$key] = $this->convertObjectToArray($value);
} else {
$converted[$key] = $value;
}
}
return $converted;
} | php | private function convertObjectToArray($data)
{
$converted = [];
foreach($data as $key => $value) {
if(is_object($value)) {
$converted[$key] = $this->convertObjectToArray($value);
} else {
$converted[$key] = $value;
}
}
return $converted;
} | [
"private",
"function",
"convertObjectToArray",
"(",
"$",
"data",
")",
"{",
"$",
"converted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
... | Recursively convert the provided object to an array
@param mixed $data
@return array | [
"Recursively",
"convert",
"the",
"provided",
"object",
"to",
"an",
"array"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/Drivers/FirebaseDriver.php#L76-L88 | train |
generationtux/jwt-artisan | src/Http/JwtMiddleware.php | JwtMiddleware.handle | public function handle($request, Closure $next)
{
$token = $this->getTokenFromRequest($request);
$this->jwt->setToken($token)->validateOrFail();
return $next($request);
} | php | public function handle($request, Closure $next)
{
$token = $this->getTokenFromRequest($request);
$this->jwt->setToken($token)->validateOrFail();
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getTokenFromRequest",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"jwt",
"->",
"setToken",
"(",
"$",
"token",
")"... | Validate JWT token before passing on to the next middleware
@param \Illuminate\Http\Request $request
@param Closure $next | [
"Validate",
"JWT",
"token",
"before",
"passing",
"on",
"to",
"the",
"next",
"middleware"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/Http/JwtMiddleware.php#L32-L38 | train |
generationtux/jwt-artisan | src/Exceptions/JwtExceptionHandler.php | JwtExceptionHandler.handleJwtException | public function handleJwtException(JwtException $e)
{
if($e instanceof InvalidTokenException) {
return $this->handleJwtInvalidToken($e);
} elseif ($e instanceof NoTokenException) {
return $this->handleJwtNoToken($e);
} elseif ($e instanceof NoSecretException) {
return $this->handleJwtNoSecret($e);
} else {
$message = getenv('JWT_MESSAGE_ERROR') ?: 'There was an error while validating the authorization token.';
return response()->json([
'error' => $message
], 500);
}
} | php | public function handleJwtException(JwtException $e)
{
if($e instanceof InvalidTokenException) {
return $this->handleJwtInvalidToken($e);
} elseif ($e instanceof NoTokenException) {
return $this->handleJwtNoToken($e);
} elseif ($e instanceof NoSecretException) {
return $this->handleJwtNoSecret($e);
} else {
$message = getenv('JWT_MESSAGE_ERROR') ?: 'There was an error while validating the authorization token.';
return response()->json([
'error' => $message
], 500);
}
} | [
"public",
"function",
"handleJwtException",
"(",
"JwtException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"InvalidTokenException",
")",
"{",
"return",
"$",
"this",
"->",
"handleJwtInvalidToken",
"(",
"$",
"e",
")",
";",
"}",
"elseif",
"(",
"$... | Render JWT exception
@param JwtException $e
@return \Illuminate\Http\Response | [
"Render",
"JWT",
"exception"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/Exceptions/JwtExceptionHandler.php#L15-L29 | train |
generationtux/jwt-artisan | src/JwtToken.php | JwtToken.validateOrFail | public function validateOrFail($secret = null, $algo = null)
{
if( ! $this->validate($secret, $algo)) {
throw new InvalidTokenException('Token is not valid.');
}
return true;
} | php | public function validateOrFail($secret = null, $algo = null)
{
if( ! $this->validate($secret, $algo)) {
throw new InvalidTokenException('Token is not valid.');
}
return true;
} | [
"public",
"function",
"validateOrFail",
"(",
"$",
"secret",
"=",
"null",
",",
"$",
"algo",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
"$",
"secret",
",",
"$",
"algo",
")",
")",
"{",
"throw",
"new",
"InvalidTokenExcepti... | Validate the token or throw an exception
@param string|null $secret
@param string|null $algo
@return bool
@throws InvalidTokenException | [
"Validate",
"the",
"token",
"or",
"throw",
"an",
"exception"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/JwtToken.php#L156-L163 | train |
generationtux/jwt-artisan | src/JwtToken.php | JwtToken.payload | public function payload($path = null, $secret = null, $algo = null)
{
$token = $this->token();
$secret = $secret ?: $this->secret();
$algo = $algo ?: $this->algorithm();
$payload = $this->jwt->decodeToken($token, $secret, $algo);
return $this->queryPayload($payload, $path);
} | php | public function payload($path = null, $secret = null, $algo = null)
{
$token = $this->token();
$secret = $secret ?: $this->secret();
$algo = $algo ?: $this->algorithm();
$payload = $this->jwt->decodeToken($token, $secret, $algo);
return $this->queryPayload($payload, $path);
} | [
"public",
"function",
"payload",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"secret",
"=",
"null",
",",
"$",
"algo",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"token",
"(",
")",
";",
"$",
"secret",
"=",
"$",
"secret",
"?",
":",... | Get the payload from the current token
@param string|null $path dot syntax to query for specific data
@param string|null $secret
@param string|null $algo
@return array | [
"Get",
"the",
"payload",
"from",
"the",
"current",
"token"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/JwtToken.php#L174-L183 | train |
generationtux/jwt-artisan | src/JwtToken.php | JwtToken.queryPayload | private function queryPayload($payload, $path = null)
{
if(is_null($path)) return $payload;
if(array_key_exists($path, $payload)) {
return $payload[$path];
}
$dotData = Arr::dot($payload);
if(array_key_exists($path, $dotData)) {
return $dotData[$path];
}
return null;
} | php | private function queryPayload($payload, $path = null)
{
if(is_null($path)) return $payload;
if(array_key_exists($path, $payload)) {
return $payload[$path];
}
$dotData = Arr::dot($payload);
if(array_key_exists($path, $dotData)) {
return $dotData[$path];
}
return null;
} | [
"private",
"function",
"queryPayload",
"(",
"$",
"payload",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"return",
"$",
"payload",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"path",
",",
"$",
"payload"... | Query the payload using dot syntax to find specific data
@param array $payload
@param string|null $path
@return mixed | [
"Query",
"the",
"payload",
"using",
"dot",
"syntax",
"to",
"find",
"specific",
"data"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/JwtToken.php#L193-L207 | train |
generationtux/jwt-artisan | src/JwtToken.php | JwtToken.createToken | public function createToken($payload, $secret = null, $algo = null)
{
$algo = $algo ?: $this->algorithm();
$secret = $secret ?: $this->secret();
if($payload instanceof JwtPayloadInterface) {
$payload = $payload->getPayload();
}
$newToken = $this->jwt->createToken($payload, $secret, $algo);
$token = clone $this;
$token->setToken($newToken);
return $token;
} | php | public function createToken($payload, $secret = null, $algo = null)
{
$algo = $algo ?: $this->algorithm();
$secret = $secret ?: $this->secret();
if($payload instanceof JwtPayloadInterface) {
$payload = $payload->getPayload();
}
$newToken = $this->jwt->createToken($payload, $secret, $algo);
$token = clone $this;
$token->setToken($newToken);
return $token;
} | [
"public",
"function",
"createToken",
"(",
"$",
"payload",
",",
"$",
"secret",
"=",
"null",
",",
"$",
"algo",
"=",
"null",
")",
"{",
"$",
"algo",
"=",
"$",
"algo",
"?",
":",
"$",
"this",
"->",
"algorithm",
"(",
")",
";",
"$",
"secret",
"=",
"$",
... | Create a new token with the provided payload
The default algorithm used is HS256. To set a custom one, set
the env variable JWT_ALGO.
@todo Support for enforcing required claims in payload as well as defaults
@param JwtPayloadInterface|array $payload
@param string|null $secret
@param string|null $algo
@return JwtToken | [
"Create",
"a",
"new",
"token",
"with",
"the",
"provided",
"payload"
] | 3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e | https://github.com/generationtux/jwt-artisan/blob/3be10ad14e5d6b6db8dd1d35fa3b888e4dadd54e/src/JwtToken.php#L223-L238 | train |
LaravelCollective/bus | src/Dispatcher.php | Dispatcher.dispatchFrom | public function dispatchFrom($command, ArrayAccess $source, array $extras = [])
{
return $this->dispatch($this->marshal($command, $source, $extras));
} | php | public function dispatchFrom($command, ArrayAccess $source, array $extras = [])
{
return $this->dispatch($this->marshal($command, $source, $extras));
} | [
"public",
"function",
"dispatchFrom",
"(",
"$",
"command",
",",
"ArrayAccess",
"$",
"source",
",",
"array",
"$",
"extras",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"marshal",
"(",
"$",
"command",
",",
... | Marshal a command and dispatch it to its appropriate handler.
@param mixed $command
@param \ArrayAccess $source
@param array $extras
@return mixed | [
"Marshal",
"a",
"command",
"and",
"dispatch",
"it",
"to",
"its",
"appropriate",
"handler",
"."
] | 720298af5ddaa09e1ddb846d02c2a911e92c3574 | https://github.com/LaravelCollective/bus/blob/720298af5ddaa09e1ddb846d02c2a911e92c3574/src/Dispatcher.php#L101-L104 | train |
LaravelCollective/bus | src/Dispatcher.php | Dispatcher.marshal | protected function marshal($command, ArrayAccess $source, array $extras = [])
{
$injected = [];
$reflection = new ReflectionClass($command);
if ($constructor = $reflection->getConstructor()) {
$injected = array_map(function ($parameter) use ($command, $source, $extras) {
return $this->getParameterValueForCommand($command, $source, $parameter, $extras);
}, $constructor->getParameters());
}
return $reflection->newInstanceArgs($injected);
} | php | protected function marshal($command, ArrayAccess $source, array $extras = [])
{
$injected = [];
$reflection = new ReflectionClass($command);
if ($constructor = $reflection->getConstructor()) {
$injected = array_map(function ($parameter) use ($command, $source, $extras) {
return $this->getParameterValueForCommand($command, $source, $parameter, $extras);
}, $constructor->getParameters());
}
return $reflection->newInstanceArgs($injected);
} | [
"protected",
"function",
"marshal",
"(",
"$",
"command",
",",
"ArrayAccess",
"$",
"source",
",",
"array",
"$",
"extras",
"=",
"[",
"]",
")",
"{",
"$",
"injected",
"=",
"[",
"]",
";",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"command"... | Marshal a command from the given array accessible object.
@param string $command
@param \ArrayAccess $source
@param array $extras
@return mixed | [
"Marshal",
"a",
"command",
"from",
"the",
"given",
"array",
"accessible",
"object",
"."
] | 720298af5ddaa09e1ddb846d02c2a911e92c3574 | https://github.com/LaravelCollective/bus/blob/720298af5ddaa09e1ddb846d02c2a911e92c3574/src/Dispatcher.php#L128-L141 | train |
LaravelCollective/bus | src/Dispatcher.php | Dispatcher.resolveHandler | public function resolveHandler($command)
{
if ($command instanceof SelfHandling) {
return $command;
}
return $this->container->make($this->getHandlerClass($command));
} | php | public function resolveHandler($command)
{
if ($command instanceof SelfHandling) {
return $command;
}
return $this->container->make($this->getHandlerClass($command));
} | [
"public",
"function",
"resolveHandler",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"command",
"instanceof",
"SelfHandling",
")",
"{",
"return",
"$",
"command",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"this",
"->",
... | Get the handler instance for the given command.
@param mixed $command
@return mixed | [
"Get",
"the",
"handler",
"instance",
"for",
"the",
"given",
"command",
"."
] | 720298af5ddaa09e1ddb846d02c2a911e92c3574 | https://github.com/LaravelCollective/bus/blob/720298af5ddaa09e1ddb846d02c2a911e92c3574/src/Dispatcher.php#L289-L296 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/helloAnalyticsApi.php | HelloAnalyticsApi.getFormattedResults | private function getFormattedResults($results) {
$profileName = $results->getProfileInfo()->getProfileName();
$output = '<h3>Results for profile: '
. htmlspecialchars($profileName, ENT_NOQUOTES)
. '</h3>';
if (count($results->getRows()) > 0) {
$table = '<table>';
// Print headers.
$table .= '<tr>';
foreach ($results->getColumnHeaders() as $header) {
$table .= '<th>' . $header->getName() . '</th>';
}
$table .= '</tr>';
// Print table rows.
foreach ($results->getRows() as $row) {
$table .= '<tr>';
foreach ($row as $cell) {
$table .= '<td>'
. htmlspecialchars($cell, ENT_NOQUOTES)
. '</td>';
}
$table .= '</tr>';
}
$table .= '</table>';
} else {
$table = '<p>No results found.</p>';
}
return $output . $table;
} | php | private function getFormattedResults($results) {
$profileName = $results->getProfileInfo()->getProfileName();
$output = '<h3>Results for profile: '
. htmlspecialchars($profileName, ENT_NOQUOTES)
. '</h3>';
if (count($results->getRows()) > 0) {
$table = '<table>';
// Print headers.
$table .= '<tr>';
foreach ($results->getColumnHeaders() as $header) {
$table .= '<th>' . $header->getName() . '</th>';
}
$table .= '</tr>';
// Print table rows.
foreach ($results->getRows() as $row) {
$table .= '<tr>';
foreach ($row as $cell) {
$table .= '<td>'
. htmlspecialchars($cell, ENT_NOQUOTES)
. '</td>';
}
$table .= '</tr>';
}
$table .= '</table>';
} else {
$table = '<p>No results found.</p>';
}
return $output . $table;
} | [
"private",
"function",
"getFormattedResults",
"(",
"$",
"results",
")",
"{",
"$",
"profileName",
"=",
"$",
"results",
"->",
"getProfileInfo",
"(",
")",
"->",
"getProfileName",
"(",
")",
";",
"$",
"output",
"=",
"'<h3>Results for profile: '",
".",
"htmlspecialcha... | Formats the results from the Core Reporting API into some nice
HTML. The profile name is printed as a header. The results of
the query is printed as a table. Note, all the results from the
API are html escaped to prevent malicious code from running on the
page.
@param GaData $results The Results from the Core Reporting API.
@return string The nicely formatted results. | [
"Formats",
"the",
"results",
"from",
"the",
"Core",
"Reporting",
"API",
"into",
"some",
"nice",
"HTML",
".",
"The",
"profile",
"name",
"is",
"printed",
"as",
"a",
"header",
".",
"The",
"results",
"of",
"the",
"query",
"is",
"printed",
"as",
"a",
"table",... | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/helloAnalyticsApi.php#L143-L176 | train |
alchemy-fr/google-plus-api-client | src/io/Google_HttpRequest.php | Google_HttpRequest.getQueryParams | public function getQueryParams() {
if ($pos = strpos($this->url, '?')) {
$queryStr = substr($this->url, $pos + 1);
$params = array();
parse_str($queryStr, $params);
return $params;
}
return array();
} | php | public function getQueryParams() {
if ($pos = strpos($this->url, '?')) {
$queryStr = substr($this->url, $pos + 1);
$params = array();
parse_str($queryStr, $params);
return $params;
}
return array();
} | [
"public",
"function",
"getQueryParams",
"(",
")",
"{",
"if",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"this",
"->",
"url",
",",
"'?'",
")",
")",
"{",
"$",
"queryStr",
"=",
"substr",
"(",
"$",
"this",
"->",
"url",
",",
"$",
"pos",
"+",
"1",
")"... | Misc function that returns an array of the query parameters of the current
url used by the OAuth signing class to calculate the signature
@return array Query parameters in the query string. | [
"Misc",
"function",
"that",
"returns",
"an",
"array",
"of",
"the",
"query",
"parameters",
"of",
"the",
"current",
"url",
"used",
"by",
"the",
"OAuth",
"signing",
"class",
"to",
"calculate",
"the",
"signature"
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/src/io/Google_HttpRequest.php#L79-L87 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/authHelper.php | AuthHelper.setTokenFromStorage | public function setTokenFromStorage() {
$accessToken = $this->storage->get();
if (isset($accessToken)) {
$this->client->setAccessToken($accessToken);
}
} | php | public function setTokenFromStorage() {
$accessToken = $this->storage->get();
if (isset($accessToken)) {
$this->client->setAccessToken($accessToken);
}
} | [
"public",
"function",
"setTokenFromStorage",
"(",
")",
"{",
"$",
"accessToken",
"=",
"$",
"this",
"->",
"storage",
"->",
"get",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"accessToken",
")",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"setAccessToke... | Retrieves an access token from the storage object and sets it into the
client object. | [
"Retrieves",
"an",
"access",
"token",
"from",
"the",
"storage",
"object",
"and",
"sets",
"it",
"into",
"the",
"client",
"object",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/authHelper.php#L56-L61 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/authHelper.php | AuthHelper.revokeToken | public function revokeToken() {
$accessToken = $this->storage->get();
if ($accessToken) {
$tokenObj = json_decode($accessToken);
try {
$this->client->revokeToken($tokenObj->refresh_token);
$this->storage->delete();
} catch (Google_AuthException $e) {
$this->errorMsg = $e->getMessage();
}
}
// Keep things pretty. Removes the auth code from the URL.
header("Location: $this->controllerUrl");
} | php | public function revokeToken() {
$accessToken = $this->storage->get();
if ($accessToken) {
$tokenObj = json_decode($accessToken);
try {
$this->client->revokeToken($tokenObj->refresh_token);
$this->storage->delete();
} catch (Google_AuthException $e) {
$this->errorMsg = $e->getMessage();
}
}
// Keep things pretty. Removes the auth code from the URL.
header("Location: $this->controllerUrl");
} | [
"public",
"function",
"revokeToken",
"(",
")",
"{",
"$",
"accessToken",
"=",
"$",
"this",
"->",
"storage",
"->",
"get",
"(",
")",
";",
"if",
"(",
"$",
"accessToken",
")",
"{",
"$",
"tokenObj",
"=",
"json_decode",
"(",
"$",
"accessToken",
")",
";",
"t... | Revokes an authorization token. This both revokes the token by making a
Google Accounts API request to revoke the token as well as deleting the
token from the storage mechanism. If any errors occur, the authorization
exception is caught and the message is stored in error. | [
"Revokes",
"an",
"authorization",
"token",
".",
"This",
"both",
"revokes",
"the",
"token",
"by",
"making",
"a",
"Google",
"Accounts",
"API",
"request",
"to",
"revoke",
"the",
"token",
"as",
"well",
"as",
"deleting",
"the",
"token",
"from",
"the",
"storage",
... | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/authHelper.php#L95-L108 | train |
alchemy-fr/google-plus-api-client | examples/adexchangebuyer/BaseExample.php | BaseExample.execute | public function execute() {
if (count($this->getInputParameters())) {
if ($this->isSubmitComplete()) {
$this->formValues = $this->getFormValues();
$this->run();
} else {
$this->renderInputForm();
}
} else {
$this->run();
}
} | php | public function execute() {
if (count($this->getInputParameters())) {
if ($this->isSubmitComplete()) {
$this->formValues = $this->getFormValues();
$this->run();
} else {
$this->renderInputForm();
}
} else {
$this->run();
}
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"getInputParameters",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSubmitComplete",
"(",
")",
")",
"{",
"$",
"this",
"->",
"formValues",
"=",
"... | Executes the example, checks if the examples requires parameters and
request them before invoking run. | [
"Executes",
"the",
"example",
"checks",
"if",
"the",
"examples",
"requires",
"parameters",
"and",
"request",
"them",
"before",
"invoking",
"run",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adexchangebuyer/BaseExample.php#L57-L68 | train |
alchemy-fr/google-plus-api-client | examples/adexchangebuyer/BaseExample.php | BaseExample.renderInputForm | protected function renderInputForm() {
$parameters = $this->getInputParameters();
if (count($parameters)) {
printf('<h2>Enter %s parameters</h2>', $this->getName());
print '<form method="POST"><fieldset>';
foreach ($parameters as $parameter) {
$name = $parameter['name'];
$display = $parameter['display'];
$currentValue = isset($_POST[$name]) ? $_POST[$name] : '';
printf('%s: <input name="%s" value="%s">', $display, $name,
$currentValue);
if ($parameter['required']) {
print '*';
}
print '</br>';
}
print '</fieldset>*required<br/>';
print '<input type="submit" name="submit" value="Submit"/>';
print '</form>';
}
} | php | protected function renderInputForm() {
$parameters = $this->getInputParameters();
if (count($parameters)) {
printf('<h2>Enter %s parameters</h2>', $this->getName());
print '<form method="POST"><fieldset>';
foreach ($parameters as $parameter) {
$name = $parameter['name'];
$display = $parameter['display'];
$currentValue = isset($_POST[$name]) ? $_POST[$name] : '';
printf('%s: <input name="%s" value="%s">', $display, $name,
$currentValue);
if ($parameter['required']) {
print '*';
}
print '</br>';
}
print '</fieldset>*required<br/>';
print '<input type="submit" name="submit" value="Submit"/>';
print '</form>';
}
} | [
"protected",
"function",
"renderInputForm",
"(",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getInputParameters",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
")",
"{",
"printf",
"(",
"'<h2>Enter %s parameters</h2>'",
",",
"$",
... | Renders an input form to capture the example parameters. | [
"Renders",
"an",
"input",
"form",
"to",
"capture",
"the",
"example",
"parameters",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adexchangebuyer/BaseExample.php#L88-L108 | train |
alchemy-fr/google-plus-api-client | examples/adexchangebuyer/BaseExample.php | BaseExample.isSubmitComplete | protected function isSubmitComplete() {
if (!isset($_POST['submit'])) {
return false;
}
foreach ($this->getInputParameters() as $parameter) {
if ($parameter['required'] &&
empty($_POST[$parameter['name']])) {
return false;
}
}
return true;
} | php | protected function isSubmitComplete() {
if (!isset($_POST['submit'])) {
return false;
}
foreach ($this->getInputParameters() as $parameter) {
if ($parameter['required'] &&
empty($_POST[$parameter['name']])) {
return false;
}
}
return true;
} | [
"protected",
"function",
"isSubmitComplete",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_POST",
"[",
"'submit'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getInputParameters",
"(",
")",
"as",
"$",
"p... | Checks if the form has been submitted and all required parameters are
set.
@return bool | [
"Checks",
"if",
"the",
"form",
"has",
"been",
"submitted",
"and",
"all",
"required",
"parameters",
"are",
"set",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adexchangebuyer/BaseExample.php#L115-L126 | train |
alchemy-fr/google-plus-api-client | examples/adexchangebuyer/BaseExample.php | BaseExample.getFormValues | protected function getFormValues() {
$input = array();
foreach ($this->getInputParameters() as $parameter) {
if (isset($_POST[$parameter['name']])) {
$input[$parameter['name']] = $_POST[$parameter['name']];
}
}
return $input;
} | php | protected function getFormValues() {
$input = array();
foreach ($this->getInputParameters() as $parameter) {
if (isset($_POST[$parameter['name']])) {
$input[$parameter['name']] = $_POST[$parameter['name']];
}
}
return $input;
} | [
"protected",
"function",
"getFormValues",
"(",
")",
"{",
"$",
"input",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getInputParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"$",
... | Retrieves the submitted form values.
@return array | [
"Retrieves",
"the",
"submitted",
"form",
"values",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adexchangebuyer/BaseExample.php#L132-L140 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/coreReportingApiReference.php | CoreReportingApiReference.queryCoreReportingApi | private function queryCoreReportingApi($tableId) {
$optParams = array(
'dimensions' => 'ga:source,ga:keyword',
'sort' => '-ga:visits,ga:keyword',
'filters' => 'ga:medium==organic',
'max-results' => '25');
return $this->analytics->data_ga->get(
urldecode($tableId),
'2010-01-01',
'2010-01-15',
'ga:visits',
$optParams);
} | php | private function queryCoreReportingApi($tableId) {
$optParams = array(
'dimensions' => 'ga:source,ga:keyword',
'sort' => '-ga:visits,ga:keyword',
'filters' => 'ga:medium==organic',
'max-results' => '25');
return $this->analytics->data_ga->get(
urldecode($tableId),
'2010-01-01',
'2010-01-15',
'ga:visits',
$optParams);
} | [
"private",
"function",
"queryCoreReportingApi",
"(",
"$",
"tableId",
")",
"{",
"$",
"optParams",
"=",
"array",
"(",
"'dimensions'",
"=>",
"'ga:source,ga:keyword'",
",",
"'sort'",
"=>",
"'-ga:visits,ga:keyword'",
",",
"'filters'",
"=>",
"'ga:medium==organic'",
",",
"... | Queries the Core Reporting API for the top 25 organic search terms
ordered by visits. Because the table id comes from the query parameter
it needs to be URI decoded.
@param string $tableId The value of the ids parameter in the
Core Reporting API. This is the ga namespaced profile ID. It has the
format of ga:xxxx where xxxx is the profile ID. You can get this
value from the Management API. See the helloAnalytics.php example
for details.
@return GaData The results from the Core Reporting API. | [
"Queries",
"the",
"Core",
"Reporting",
"API",
"for",
"the",
"top",
"25",
"organic",
"search",
"terms",
"ordered",
"by",
"visits",
".",
"Because",
"the",
"table",
"id",
"comes",
"from",
"the",
"query",
"parameter",
"it",
"needs",
"to",
"be",
"URI",
"decoded... | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/coreReportingApiReference.php#L97-L111 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/coreReportingApiReference.php | CoreReportingApiReference.getFormattedResults | private function getFormattedResults(&$results) {
return implode('', array(
$this->getReportInfo($results),
$this->getPaginationInfo($results),
$this->getProfileInformation($results),
$this->getQueryParameters($results),
$this->getColumnHeaders($results),
$this->getTotalsForAllResults($results),
$this->getRows($results)
));
} | php | private function getFormattedResults(&$results) {
return implode('', array(
$this->getReportInfo($results),
$this->getPaginationInfo($results),
$this->getProfileInformation($results),
$this->getQueryParameters($results),
$this->getColumnHeaders($results),
$this->getTotalsForAllResults($results),
$this->getRows($results)
));
} | [
"private",
"function",
"getFormattedResults",
"(",
"&",
"$",
"results",
")",
"{",
"return",
"implode",
"(",
"''",
",",
"array",
"(",
"$",
"this",
"->",
"getReportInfo",
"(",
"$",
"results",
")",
",",
"$",
"this",
"->",
"getPaginationInfo",
"(",
"$",
"res... | Returns the results from the API as a HTML formatted string.
@param GaData $results The results from the Core Reporting API.
@return string The formatted results. | [
"Returns",
"the",
"results",
"from",
"the",
"API",
"as",
"a",
"HTML",
"formatted",
"string",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/coreReportingApiReference.php#L118-L129 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/coreReportingApiReference.php | CoreReportingApiReference.getQueryParameters | private function getQueryParameters(&$results) {
$query = $results->getQuery();
$html = '<h3>Query Parameters</h3><pre>';
foreach ($query as $paramName => $value) {
$html .= "$paramName = $value\n";
}
$html .= '</pre>';
return $html;
} | php | private function getQueryParameters(&$results) {
$query = $results->getQuery();
$html = '<h3>Query Parameters</h3><pre>';
foreach ($query as $paramName => $value) {
$html .= "$paramName = $value\n";
}
$html .= '</pre>';
return $html;
} | [
"private",
"function",
"getQueryParameters",
"(",
"&",
"$",
"results",
")",
"{",
"$",
"query",
"=",
"$",
"results",
"->",
"getQuery",
"(",
")",
";",
"$",
"html",
"=",
"'<h3>Query Parameters</h3><pre>'",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"paramN... | Returns all the query parameters in the initial API query.
@param GaData $results The results from the Core Reporting API.
@return string The formatted results. | [
"Returns",
"all",
"the",
"query",
"parameters",
"in",
"the",
"initial",
"API",
"query",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/coreReportingApiReference.php#L192-L201 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/coreReportingApiReference.php | CoreReportingApiReference.getColumnHeaders | private function getColumnHeaders(&$results) {
$html = '<h3>Column Headers</h3><pre>';
$headers = $results->getColumnHeaders();
foreach ($headers as $header) {
$html .= <<<HTML
Column Name = {$header->getName()}
Column Type = {$header->getColumnType()}
Data Type = {$header->getDataType()}
HTML;
}
$html .= '</pre>';
return $html;
} | php | private function getColumnHeaders(&$results) {
$html = '<h3>Column Headers</h3><pre>';
$headers = $results->getColumnHeaders();
foreach ($headers as $header) {
$html .= <<<HTML
Column Name = {$header->getName()}
Column Type = {$header->getColumnType()}
Data Type = {$header->getDataType()}
HTML;
}
$html .= '</pre>';
return $html;
} | [
"private",
"function",
"getColumnHeaders",
"(",
"&",
"$",
"results",
")",
"{",
"$",
"html",
"=",
"'<h3>Column Headers</h3><pre>'",
";",
"$",
"headers",
"=",
"$",
"results",
"->",
"getColumnHeaders",
"(",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
... | Returns all the column headers for the table view.
@param GaData $results The results from the Core Reporting API.
@return string The formatted results. | [
"Returns",
"all",
"the",
"column",
"headers",
"for",
"the",
"table",
"view",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/coreReportingApiReference.php#L208-L224 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/coreReportingApiReference.php | CoreReportingApiReference.getTotalsForAllResults | private function getTotalsForAllResults(&$results) {
$rowCount = count($results->getRows());
$totalResults = $results->getTotalResults();
$html = '<h3>Total Metrics For All Results</h3>';
$html .= "<p>This query returned $rowCount rows. <br>";
$html .= "But the query matched $totalResults total results. <br>";
$html .= 'Here are the metric totals for the matched results.</p>';
$html .= '<pre>';
$totals = $results->getTotalsForAllResults();
foreach ($totals as $metricName => $metricTotal) {
$html .= "Metric Name = $metricName\n";
$html .= "Metric Total = $metricTotal";
}
$html .= '</pre>';
return $html;
} | php | private function getTotalsForAllResults(&$results) {
$rowCount = count($results->getRows());
$totalResults = $results->getTotalResults();
$html = '<h3>Total Metrics For All Results</h3>';
$html .= "<p>This query returned $rowCount rows. <br>";
$html .= "But the query matched $totalResults total results. <br>";
$html .= 'Here are the metric totals for the matched results.</p>';
$html .= '<pre>';
$totals = $results->getTotalsForAllResults();
foreach ($totals as $metricName => $metricTotal) {
$html .= "Metric Name = $metricName\n";
$html .= "Metric Total = $metricTotal";
}
$html .= '</pre>';
return $html;
} | [
"private",
"function",
"getTotalsForAllResults",
"(",
"&",
"$",
"results",
")",
"{",
"$",
"rowCount",
"=",
"count",
"(",
"$",
"results",
"->",
"getRows",
"(",
")",
")",
";",
"$",
"totalResults",
"=",
"$",
"results",
"->",
"getTotalResults",
"(",
")",
";"... | Returns the totals for all the results.
@param GaData $results The results from the Core Reporting API.
@return string The formatted results. | [
"Returns",
"the",
"totals",
"for",
"all",
"the",
"results",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/coreReportingApiReference.php#L231-L249 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/coreReportingApiReference.php | CoreReportingApiReference.getRows | private function getRows($results) {
$table = '<h3>Rows Of Data</h3>';
if (count($results->getRows()) > 0) {
$table .= '<table>';
// Print headers.
$table .= '<tr>';
foreach ($results->getColumnHeaders() as $header) {
$table .= '<th>' . $header->name . '</th>';
}
$table .= '</tr>';
// Print table rows.
foreach ($results->getRows() as $row) {
$table .= '<tr>';
foreach ($row as $cell) {
$table .= '<td>'
. htmlspecialchars($cell, ENT_NOQUOTES)
. '</td>';
}
$table .= '</tr>';
}
$table .= '</table>';
} else {
$table .= '<p>No results found.</p>';
}
return $table;
} | php | private function getRows($results) {
$table = '<h3>Rows Of Data</h3>';
if (count($results->getRows()) > 0) {
$table .= '<table>';
// Print headers.
$table .= '<tr>';
foreach ($results->getColumnHeaders() as $header) {
$table .= '<th>' . $header->name . '</th>';
}
$table .= '</tr>';
// Print table rows.
foreach ($results->getRows() as $row) {
$table .= '<tr>';
foreach ($row as $cell) {
$table .= '<td>'
. htmlspecialchars($cell, ENT_NOQUOTES)
. '</td>';
}
$table .= '</tr>';
}
$table .= '</table>';
} else {
$table .= '<p>No results found.</p>';
}
return $table;
} | [
"private",
"function",
"getRows",
"(",
"$",
"results",
")",
"{",
"$",
"table",
"=",
"'<h3>Rows Of Data</h3>'",
";",
"if",
"(",
"count",
"(",
"$",
"results",
"->",
"getRows",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"table",
".=",
"'<table>'",
";",
"//... | Returns the rows of data as an HTML Table.
@param GaData $results The results from the Core Reporting API.
@return string The formatted results. | [
"Returns",
"the",
"rows",
"of",
"data",
"as",
"an",
"HTML",
"Table",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/coreReportingApiReference.php#L256-L287 | train |
alchemy-fr/google-plus-api-client | examples/adsense/examples/GetAccountTree.php | GetAccountTree.buildTree | private function buildTree($account, &$data, $parent) {
$data[] = array($account['name'], null, 1);
if ($account['subAccounts']) {
foreach($account['subAccounts'] as $subAccount) {
$this->buildTree($subAccount, $data, $account['name']);
}
}
} | php | private function buildTree($account, &$data, $parent) {
$data[] = array($account['name'], null, 1);
if ($account['subAccounts']) {
foreach($account['subAccounts'] as $subAccount) {
$this->buildTree($subAccount, $data, $account['name']);
}
}
} | [
"private",
"function",
"buildTree",
"(",
"$",
"account",
",",
"&",
"$",
"data",
",",
"$",
"parent",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"array",
"(",
"$",
"account",
"[",
"'name'",
"]",
",",
"null",
",",
"1",
")",
";",
"if",
"(",
"$",
"accoun... | Builds the data structure to represent the tree from the API response.
@param array $account The response of the API
@param array $data The data structure that represent the tree
@param string $parent The parent for the current node | [
"Builds",
"the",
"data",
"structure",
"to",
"represent",
"the",
"tree",
"from",
"the",
"API",
"response",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adsense/examples/GetAccountTree.php#L56-L63 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getTraverseManagementApiHtml | private function getTraverseManagementApiHtml() {
$accounts = $this->analytics->management_accounts
->listManagementAccounts();
$html = $this->getAccountsHtml($accounts);
if (count($accounts->getItems()) > 0) {
$firstAccountId = $this->getFirstId($accounts);
$webproperties = $this->analytics->management_webproperties
->listManagementWebproperties($firstAccountId);
$html .= $this->getWebpropertiesHtml($webproperties);
if (count($webproperties->getItems()) > 0) {
$firstWebpropertyId = $this->getFirstId($webproperties);
$profiles = $this->analytics->management_profiles
->listManagementProfiles($firstAccountId,
$firstWebpropertyId);
$html .= $this->getProfilesHtml($profiles);
if (count($profiles->getItems()) > 0) {
$firstProfileId = $this->getFirstId($profiles);
$goals = $this->analytics->management_goals
->listManagementGoals($firstAccountId,
$firstWebpropertyId,
$firstProfileId);
$html .= $this->getGoalsHtml($goals);
}
}
}
$segments = $this->analytics->management_segments
->listManagementSegments();
$html .= $this->getSegmentsHtml($segments);
return $html;
} | php | private function getTraverseManagementApiHtml() {
$accounts = $this->analytics->management_accounts
->listManagementAccounts();
$html = $this->getAccountsHtml($accounts);
if (count($accounts->getItems()) > 0) {
$firstAccountId = $this->getFirstId($accounts);
$webproperties = $this->analytics->management_webproperties
->listManagementWebproperties($firstAccountId);
$html .= $this->getWebpropertiesHtml($webproperties);
if (count($webproperties->getItems()) > 0) {
$firstWebpropertyId = $this->getFirstId($webproperties);
$profiles = $this->analytics->management_profiles
->listManagementProfiles($firstAccountId,
$firstWebpropertyId);
$html .= $this->getProfilesHtml($profiles);
if (count($profiles->getItems()) > 0) {
$firstProfileId = $this->getFirstId($profiles);
$goals = $this->analytics->management_goals
->listManagementGoals($firstAccountId,
$firstWebpropertyId,
$firstProfileId);
$html .= $this->getGoalsHtml($goals);
}
}
}
$segments = $this->analytics->management_segments
->listManagementSegments();
$html .= $this->getSegmentsHtml($segments);
return $html;
} | [
"private",
"function",
"getTraverseManagementApiHtml",
"(",
")",
"{",
"$",
"accounts",
"=",
"$",
"this",
"->",
"analytics",
"->",
"management_accounts",
"->",
"listManagementAccounts",
"(",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getAccountsHtml",
"(",
... | Traverses the Management API. A query is made to the Accounts collection.
The first account ID is used to then query the webproperties collection.
The first webproperty ID is used to query the profiles collection. The
first profile is used to query the goals collection. Finally the segments
collection is queries. At each level, an HTML representation is rendered
of the entire collection. If one of the levels has no entities to query
for a child level, then traversal stops.
@return string The HTML representation of the Management API traversal. | [
"Traverses",
"the",
"Management",
"API",
".",
"A",
"query",
"is",
"made",
"to",
"the",
"Accounts",
"collection",
".",
"The",
"first",
"account",
"ID",
"is",
"used",
"to",
"then",
"query",
"the",
"webproperties",
"collection",
".",
"The",
"first",
"webpropert... | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L81-L119 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getAccountsHtml | private function getAccountsHtml(&$accounts) {
$html = '<h3>Accounts Collection</h3>' .
$this->getCollectionInfoHtml($accounts);
$items = $accounts->getItems();
if (count($items) == 0) {
$html .= '<p>No Accounts Found</p>';
} else {
foreach($items as &$account) {
$html .= <<<HTML
<hr>
<pre>
Account ID = {$account->getId()}
Kind = {$account->getKind()}
Self Link = {$account->getSelfLink()}
Account Name = {$account->getName()}
Created = {$account->getCreated()}
Updated = {$account->getUpdated()}
</pre>
HTML;
}
}
return $html;
} | php | private function getAccountsHtml(&$accounts) {
$html = '<h3>Accounts Collection</h3>' .
$this->getCollectionInfoHtml($accounts);
$items = $accounts->getItems();
if (count($items) == 0) {
$html .= '<p>No Accounts Found</p>';
} else {
foreach($items as &$account) {
$html .= <<<HTML
<hr>
<pre>
Account ID = {$account->getId()}
Kind = {$account->getKind()}
Self Link = {$account->getSelfLink()}
Account Name = {$account->getName()}
Created = {$account->getCreated()}
Updated = {$account->getUpdated()}
</pre>
HTML;
}
}
return $html;
} | [
"private",
"function",
"getAccountsHtml",
"(",
"&",
"$",
"accounts",
")",
"{",
"$",
"html",
"=",
"'<h3>Accounts Collection</h3>'",
".",
"$",
"this",
"->",
"getCollectionInfoHtml",
"(",
"$",
"accounts",
")",
";",
"$",
"items",
"=",
"$",
"accounts",
"->",
"get... | Returns important information from the accounts collection.
@param Accounts $accounts The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"from",
"the",
"accounts",
"collection",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L138-L163 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getWebpropertiesHtml | private function getWebpropertiesHtml(&$webproperties) {
$html = '<h3>Webproperties Collection</h3>' .
$this->getCollectionInfoHtml($webproperties);
$items = $webproperties->getItems();
if (count($items) == 0) {
$html .= '<p>No Web Properties Found</p>';
} else {
foreach ($items as &$webproperty) {
$html .= <<<HTML
<hr>
<pre>
Kind = {$webproperty->getKind()}
Account ID = {$webproperty->getAccountId()}
Webproperty ID = {$webproperty->getId()}
Internal Webproperty ID = {$webproperty->getInternalWebPropertyId()}
Website URL = {$webproperty->getWebsiteUrl()}
Created = {$webproperty->getCreated()}
Updated = {$webproperty->getUpdated()}
Self Link = {$webproperty->getSelfLink()}
Parent Link
Parent link href = {$webproperty->getParentLink()->getHref()}
Parent link type = {$webproperty->getParentLink()->getType()}
Child Link
Child link href = {$webproperty->getChildLink()->getHref()}
Child link type = {$webproperty->getChildLink()->getType()}
</pre>
HTML;
}
}
return $html;
} | php | private function getWebpropertiesHtml(&$webproperties) {
$html = '<h3>Webproperties Collection</h3>' .
$this->getCollectionInfoHtml($webproperties);
$items = $webproperties->getItems();
if (count($items) == 0) {
$html .= '<p>No Web Properties Found</p>';
} else {
foreach ($items as &$webproperty) {
$html .= <<<HTML
<hr>
<pre>
Kind = {$webproperty->getKind()}
Account ID = {$webproperty->getAccountId()}
Webproperty ID = {$webproperty->getId()}
Internal Webproperty ID = {$webproperty->getInternalWebPropertyId()}
Website URL = {$webproperty->getWebsiteUrl()}
Created = {$webproperty->getCreated()}
Updated = {$webproperty->getUpdated()}
Self Link = {$webproperty->getSelfLink()}
Parent Link
Parent link href = {$webproperty->getParentLink()->getHref()}
Parent link type = {$webproperty->getParentLink()->getType()}
Child Link
Child link href = {$webproperty->getChildLink()->getHref()}
Child link type = {$webproperty->getChildLink()->getType()}
</pre>
HTML;
}
}
return $html;
} | [
"private",
"function",
"getWebpropertiesHtml",
"(",
"&",
"$",
"webproperties",
")",
"{",
"$",
"html",
"=",
"'<h3>Webproperties Collection</h3>'",
".",
"$",
"this",
"->",
"getCollectionInfoHtml",
"(",
"$",
"webproperties",
")",
";",
"$",
"items",
"=",
"$",
"webpr... | Returns important information from the webproperties collection.
@param Google_Webproperties $webproperties The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"from",
"the",
"webproperties",
"collection",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L170-L203 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getProfilesHtml | private function getProfilesHtml(&$profiles) {
$html = '<h3>Profiles Collections</h3>' .
$this->getCollectionInfoHtml($profiles);
$items = $profiles->getItems();
if (count($items) == 0) {
$html .= '<p>No Profiles Found</p>';
} else {
foreach ($items as &$profile) {
$html .= <<<HTML
<hr>
<pre>
Kind = {$profile->getKind()}
Account ID = {$profile->getAccountId()}
Web Property ID = {$profile->getWebPropertyId()}
Internal Web Property ID = {$profile->getInternalWebPropertyId()}
Profile ID = {$profile->getId()}
Profile Name = {$profile->getName()}
Currency = {$profile->getCurrency()}
Timezone = {$profile->getTimezone()}
Default Page = {$profile->getDefaultPage()}
Exclude Query Parameters = {$profile->getExcludeQueryParameters()}
Site Search Category Parameters = {$profile->getSiteSearchCategoryParameters()}
Site Search Query Parameters = {$profile->getSiteSearchQueryParameters()}
Created = {$profile->getCreated()}
Updated = {$profile->getUpdated()}
Self Link = {$profile->getSelfLink()}
Parent Link
Parent Link href = {$profile->getParentLink()->getHref()}
Parent link type = {$profile->getParentLink()->getType()}
Child Link
Child link href = {$profile->getChildLink()->getHref()}
Child link type = {$profile->getChildLink()->getType()}
</pre>
HTML;
}
}
return $html;
} | php | private function getProfilesHtml(&$profiles) {
$html = '<h3>Profiles Collections</h3>' .
$this->getCollectionInfoHtml($profiles);
$items = $profiles->getItems();
if (count($items) == 0) {
$html .= '<p>No Profiles Found</p>';
} else {
foreach ($items as &$profile) {
$html .= <<<HTML
<hr>
<pre>
Kind = {$profile->getKind()}
Account ID = {$profile->getAccountId()}
Web Property ID = {$profile->getWebPropertyId()}
Internal Web Property ID = {$profile->getInternalWebPropertyId()}
Profile ID = {$profile->getId()}
Profile Name = {$profile->getName()}
Currency = {$profile->getCurrency()}
Timezone = {$profile->getTimezone()}
Default Page = {$profile->getDefaultPage()}
Exclude Query Parameters = {$profile->getExcludeQueryParameters()}
Site Search Category Parameters = {$profile->getSiteSearchCategoryParameters()}
Site Search Query Parameters = {$profile->getSiteSearchQueryParameters()}
Created = {$profile->getCreated()}
Updated = {$profile->getUpdated()}
Self Link = {$profile->getSelfLink()}
Parent Link
Parent Link href = {$profile->getParentLink()->getHref()}
Parent link type = {$profile->getParentLink()->getType()}
Child Link
Child link href = {$profile->getChildLink()->getHref()}
Child link type = {$profile->getChildLink()->getType()}
</pre>
HTML;
}
}
return $html;
} | [
"private",
"function",
"getProfilesHtml",
"(",
"&",
"$",
"profiles",
")",
"{",
"$",
"html",
"=",
"'<h3>Profiles Collections</h3>'",
".",
"$",
"this",
"->",
"getCollectionInfoHtml",
"(",
"$",
"profiles",
")",
";",
"$",
"items",
"=",
"$",
"profiles",
"->",
"ge... | Returns important information from the profiles collection.
@param Profiles $profiles The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"from",
"the",
"profiles",
"collection",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L210-L254 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getGoalsHtml | private function getGoalsHtml(&$goals) {
$html = '<h3>Goals Collections</h3>' .
$this->getCollectionInfoHtml($goals);
$items = $goals->getItems();
if (count($items) == 0) {
$html .= '<p>No Goals Found</p>';
} else {
foreach ($items as &$goal) {
$html .= <<<HTML
<hr>
<pre>
Goal ID = {$goal->getId()}
Kind = {$goal->getKind()}
Self Link = {$goal->getSelfLink()}
Account ID = {$goal->getAccountId()}
Web Property ID = {$goal->getWebPropertyId()}
Internal Web Property ID = {$goal->getInternalWebPropertyId()}
Profile ID
Goal Name = {$goal->getName()}
Goal Value = {$goal->getValue()}
Goal Active = {$goal->getActive()}
Goal Type = {$goal->getType()}
Created = {$goal->getCreated()}
Updated = {$goal->getUpdated()}
Parent Link
Parent link href = {$goal->getParentLink()->getHref()}
Parent link type = {$goal->getParentLink()->getHref()}
</pre>
HTML;
// Now get the HTML for the type of goal.
switch($goal->getType()) {
case 'URL_DESTINATION':
$html .= $this->getUrlDestinationDetailsHtml(
$goal->getUrlDestinationDetails());
break;
case 'VISIT_TIME_ON_SITE':
$html .= $this->getVisitTimeOnSiteDetailsHtml(
$goal->getVisitTimeOnSiteDetails());
break;
case 'VISIT_NUM_PAGES':
$html .= $this->getVisitNumPagesDetailsHtml(
$goal->getVisitNumPagesDetails());
break;
case 'EVENT':
$html .= $this->getEventDetailsHtml(
$goal->getEventDetails());
break;
}
}
}
return $html;
} | php | private function getGoalsHtml(&$goals) {
$html = '<h3>Goals Collections</h3>' .
$this->getCollectionInfoHtml($goals);
$items = $goals->getItems();
if (count($items) == 0) {
$html .= '<p>No Goals Found</p>';
} else {
foreach ($items as &$goal) {
$html .= <<<HTML
<hr>
<pre>
Goal ID = {$goal->getId()}
Kind = {$goal->getKind()}
Self Link = {$goal->getSelfLink()}
Account ID = {$goal->getAccountId()}
Web Property ID = {$goal->getWebPropertyId()}
Internal Web Property ID = {$goal->getInternalWebPropertyId()}
Profile ID
Goal Name = {$goal->getName()}
Goal Value = {$goal->getValue()}
Goal Active = {$goal->getActive()}
Goal Type = {$goal->getType()}
Created = {$goal->getCreated()}
Updated = {$goal->getUpdated()}
Parent Link
Parent link href = {$goal->getParentLink()->getHref()}
Parent link type = {$goal->getParentLink()->getHref()}
</pre>
HTML;
// Now get the HTML for the type of goal.
switch($goal->getType()) {
case 'URL_DESTINATION':
$html .= $this->getUrlDestinationDetailsHtml(
$goal->getUrlDestinationDetails());
break;
case 'VISIT_TIME_ON_SITE':
$html .= $this->getVisitTimeOnSiteDetailsHtml(
$goal->getVisitTimeOnSiteDetails());
break;
case 'VISIT_NUM_PAGES':
$html .= $this->getVisitNumPagesDetailsHtml(
$goal->getVisitNumPagesDetails());
break;
case 'EVENT':
$html .= $this->getEventDetailsHtml(
$goal->getEventDetails());
break;
}
}
}
return $html;
} | [
"private",
"function",
"getGoalsHtml",
"(",
"&",
"$",
"goals",
")",
"{",
"$",
"html",
"=",
"'<h3>Goals Collections</h3>'",
".",
"$",
"this",
"->",
"getCollectionInfoHtml",
"(",
"$",
"goals",
")",
";",
"$",
"items",
"=",
"$",
"goals",
"->",
"getItems",
"(",... | Returns important information from the goals collection.
@param Goals $goals The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"from",
"the",
"goals",
"collection",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L261-L320 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getUrlDestinationDetailsHtml | private function getUrlDestinationDetailsHtml(&$details) {
$html = '<h4>Url Destination Goal</h4>';
$html .= <<<HTML
<pre>
Goal URL = {$details->getUrl()}
Case Sensitive = {$details->getCaseSensitive()}
Match Type = {$details->getMatchType()}
First Step Required = {$details->getFirstStepRequired()}
</pre>
HTML;
$html .= '<h4>Destination Goal Steps</h4>';
$steps = $details->getSteps();
if (count($steps) == 0) {
$html .= '<p>No Steps Configured</p>';
} else {
foreach ($steps as &$step) {
$html .= <<<HTML
<pre>
Step Number = {$step->getNumber()}
Step Name = {$step->getName()}
Step URL = {$step->getUrl()}
</pre>
HTML;
}
}
return $html;
} | php | private function getUrlDestinationDetailsHtml(&$details) {
$html = '<h4>Url Destination Goal</h4>';
$html .= <<<HTML
<pre>
Goal URL = {$details->getUrl()}
Case Sensitive = {$details->getCaseSensitive()}
Match Type = {$details->getMatchType()}
First Step Required = {$details->getFirstStepRequired()}
</pre>
HTML;
$html .= '<h4>Destination Goal Steps</h4>';
$steps = $details->getSteps();
if (count($steps) == 0) {
$html .= '<p>No Steps Configured</p>';
} else {
foreach ($steps as &$step) {
$html .= <<<HTML
<pre>
Step Number = {$step->getNumber()}
Step Name = {$step->getName()}
Step URL = {$step->getUrl()}
</pre>
HTML;
}
}
return $html;
} | [
"private",
"function",
"getUrlDestinationDetailsHtml",
"(",
"&",
"$",
"details",
")",
"{",
"$",
"html",
"=",
"'<h4>Url Destination Goal</h4>'",
";",
"$",
"html",
".=",
" <<<HTML\n<pre>\nGoal URL = {$details->getUrl()}\nCase Sensitive = {$details->getCaseSensitive()}... | Returns important information for url destination type goals.
@param GoalUrlDestinationDetails $details The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"for",
"url",
"destination",
"type",
"goals",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L327-L356 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getEventDetailsHtml | private function getEventDetailsHtml(&$details) {
$html = '<h4>Event Goal</h4><pre>' .
'Use Event Value = ' . $details->getUseEventValue();
// Get all the event goal conditions.
$conditions = $details->getEventConditions();
// String condition types.
$stringTypes = array('CATEGORY', 'ACTION', 'LABEL');
foreach ($conditions as &$condition) {
$html .= "Event Type = $condition->getEventType()";
$eventType = $condition->getType();
if (in_array($eventType, $stringTypes)) {
// Process CATEGORY, ACTION, LABEL.
$html .= "Match Type = $condition->getMatchType()" .
"Expression = $condition->getExpression()";
} else {
// Process VALUE.
$html .= "Comparison Type = $condition->getComparisonType()" .
"Comparison Value = $condition->getComparisonValue()";
}
}
return $html . '</pre>';
} | php | private function getEventDetailsHtml(&$details) {
$html = '<h4>Event Goal</h4><pre>' .
'Use Event Value = ' . $details->getUseEventValue();
// Get all the event goal conditions.
$conditions = $details->getEventConditions();
// String condition types.
$stringTypes = array('CATEGORY', 'ACTION', 'LABEL');
foreach ($conditions as &$condition) {
$html .= "Event Type = $condition->getEventType()";
$eventType = $condition->getType();
if (in_array($eventType, $stringTypes)) {
// Process CATEGORY, ACTION, LABEL.
$html .= "Match Type = $condition->getMatchType()" .
"Expression = $condition->getExpression()";
} else {
// Process VALUE.
$html .= "Comparison Type = $condition->getComparisonType()" .
"Comparison Value = $condition->getComparisonValue()";
}
}
return $html . '</pre>';
} | [
"private",
"function",
"getEventDetailsHtml",
"(",
"&",
"$",
"details",
")",
"{",
"$",
"html",
"=",
"'<h4>Event Goal</h4><pre>'",
".",
"'Use Event Value = '",
".",
"$",
"details",
"->",
"getUseEventValue",
"(",
")",
";",
"// Get all the event goal conditions.",
"$",
... | Returns important information for event goals.
@param Google_GoalEventDetails $details The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"for",
"event",
"goals",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L395-L421 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getSegmentsHtml | private function getSegmentsHtml(&$segments) {
$html = '<h3>Segments Collection</h3>' .
$this->getCollectionInfoHtml($segments);
$items = $segments->getItems();
if (count($items) == 0) {
$html .= '<p>No Segments Found</p>';
} else {
foreach ($items as &$segment) {
$html .= <<<HTML
<hr>
<pre>
Segment ID = {$segment->getId()}
Kind = {$segment->getKind()}
Self Link = {$segment->getSelfLink()}
Name = {$segment->getName()}
Definition = {$segment->getDefinition()}
Created = {$segment->getCreated()}
Updated = {$segment->getUpdated()}
</pre>
HTML;
}
}
return $html;
} | php | private function getSegmentsHtml(&$segments) {
$html = '<h3>Segments Collection</h3>' .
$this->getCollectionInfoHtml($segments);
$items = $segments->getItems();
if (count($items) == 0) {
$html .= '<p>No Segments Found</p>';
} else {
foreach ($items as &$segment) {
$html .= <<<HTML
<hr>
<pre>
Segment ID = {$segment->getId()}
Kind = {$segment->getKind()}
Self Link = {$segment->getSelfLink()}
Name = {$segment->getName()}
Definition = {$segment->getDefinition()}
Created = {$segment->getCreated()}
Updated = {$segment->getUpdated()}
</pre>
HTML;
}
}
return $html;
} | [
"private",
"function",
"getSegmentsHtml",
"(",
"&",
"$",
"segments",
")",
"{",
"$",
"html",
"=",
"'<h3>Segments Collection</h3>'",
".",
"$",
"this",
"->",
"getCollectionInfoHtml",
"(",
"$",
"segments",
")",
";",
"$",
"items",
"=",
"$",
"segments",
"->",
"get... | Returns important information from the segments collection.
@param Google_Segments $segments The result from the API.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"from",
"the",
"segments",
"collection",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L428-L453 | train |
alchemy-fr/google-plus-api-client | examples/analytics/demo/managementApiReference.php | ManagementApiReference.getCollectionInfoHtml | private function getCollectionInfoHtml(&$collection) {
$previousLink = $collection->getPreviousLink()
? $collection->getPreviousLink() : 'none';
$nextLink = $collection->getNextLink()
? $collection->getNextLink() : 'none';
return <<<HTML
<pre>
Username = {$collection->getUsername()}
Items Per Page = {$collection->getItemsPerPage()}
Total Results = {$collection->getTotalResults()}
Start Index = {$collection->getStartIndex()}
Previous Link = {$previousLink}
Next Link = {$nextLink}
</pre>
HTML;
} | php | private function getCollectionInfoHtml(&$collection) {
$previousLink = $collection->getPreviousLink()
? $collection->getPreviousLink() : 'none';
$nextLink = $collection->getNextLink()
? $collection->getNextLink() : 'none';
return <<<HTML
<pre>
Username = {$collection->getUsername()}
Items Per Page = {$collection->getItemsPerPage()}
Total Results = {$collection->getTotalResults()}
Start Index = {$collection->getStartIndex()}
Previous Link = {$previousLink}
Next Link = {$nextLink}
</pre>
HTML;
} | [
"private",
"function",
"getCollectionInfoHtml",
"(",
"&",
"$",
"collection",
")",
"{",
"$",
"previousLink",
"=",
"$",
"collection",
"->",
"getPreviousLink",
"(",
")",
"?",
"$",
"collection",
"->",
"getPreviousLink",
"(",
")",
":",
"'none'",
";",
"$",
"nextLi... | Returns important information common to each collection in the API.
Most of this data can be used to paginate through the results.
@param collection $collection The result from a Management API request.
@return string An HTML representation. | [
"Returns",
"important",
"information",
"common",
"to",
"each",
"collection",
"in",
"the",
"API",
".",
"Most",
"of",
"this",
"data",
"can",
"be",
"used",
"to",
"paginate",
"through",
"the",
"results",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/analytics/demo/managementApiReference.php#L461-L478 | train |
alchemy-fr/google-plus-api-client | src/service/Google_MediaFileUpload.php | Google_MediaFileUpload.processFileUpload | public static function processFileUpload($file, $mime) {
if (!$file) return array();
if (substr($file, 0, 1) != '@') {
$file = '@' . $file;
}
// This is a standard file upload with curl.
$params = array('postBody' => array('file' => $file));
if ($mime) {
$params['content-type'] = $mime;
}
return $params;
} | php | public static function processFileUpload($file, $mime) {
if (!$file) return array();
if (substr($file, 0, 1) != '@') {
$file = '@' . $file;
}
// This is a standard file upload with curl.
$params = array('postBody' => array('file' => $file));
if ($mime) {
$params['content-type'] = $mime;
}
return $params;
} | [
"public",
"static",
"function",
"processFileUpload",
"(",
"$",
"file",
",",
"$",
"mime",
")",
"{",
"if",
"(",
"!",
"$",
"file",
")",
"return",
"array",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"1",
")",
"!=",
"'@'",
... | Prepares a standard file upload via cURL.
@param $file
@param $mime
@return array Includes the processed file name.
@visible For testing. | [
"Prepares",
"a",
"standard",
"file",
"upload",
"via",
"cURL",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/src/service/Google_MediaFileUpload.php#L150-L163 | train |
alchemy-fr/google-plus-api-client | examples/adsense/AdSenseAuth.php | AdSenseAuth.refreshToken | public function refreshToken() {
if ($this->apiClient->getAccessToken() != null) {
$dbh = new PDO('sqlite:examples.sqlite');
$this->saveToken($dbh, true, $this->apiClient->getAccessToken());
}
} | php | public function refreshToken() {
if ($this->apiClient->getAccessToken() != null) {
$dbh = new PDO('sqlite:examples.sqlite');
$this->saveToken($dbh, true, $this->apiClient->getAccessToken());
}
} | [
"public",
"function",
"refreshToken",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"apiClient",
"->",
"getAccessToken",
"(",
")",
"!=",
"null",
")",
"{",
"$",
"dbh",
"=",
"new",
"PDO",
"(",
"'sqlite:examples.sqlite'",
")",
";",
"$",
"this",
"->",
"save... | During the request, the access code might have been changed for another.
This function updates the token in the db. | [
"During",
"the",
"request",
"the",
"access",
"code",
"might",
"have",
"been",
"changed",
"for",
"another",
".",
"This",
"function",
"updates",
"the",
"token",
"in",
"the",
"db",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adsense/AdSenseAuth.php#L101-L106 | train |
alchemy-fr/google-plus-api-client | examples/adsense/AdSenseAuth.php | AdSenseAuth.getToken | private function getToken($dbh) {
$stmt = $dbh->prepare('SELECT token FROM auth WHERE user= ?');
$stmt->execute(array($this->user));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
return $row['token'];
} | php | private function getToken($dbh) {
$stmt = $dbh->prepare('SELECT token FROM auth WHERE user= ?');
$stmt->execute(array($this->user));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
return $row['token'];
} | [
"private",
"function",
"getToken",
"(",
"$",
"dbh",
")",
"{",
"$",
"stmt",
"=",
"$",
"dbh",
"->",
"prepare",
"(",
"'SELECT token FROM auth WHERE user= ?'",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"array",
"(",
"$",
"this",
"->",
"user",
")",
")",
... | Retrieves token for use.
@param PDO $dbh a PDO object for the local authentication db
@return string a JSON object representing the token | [
"Retrieves",
"token",
"for",
"use",
"."
] | d375b00e963984744b8a91bde2c8b87b3ee7d6f1 | https://github.com/alchemy-fr/google-plus-api-client/blob/d375b00e963984744b8a91bde2c8b87b3ee7d6f1/examples/adsense/AdSenseAuth.php#L131-L136 | train |
hellosign/hellosign-php-sdk | library/HelloSign/SignatureRequest.php | SignatureRequest.setCustomFieldValue | public function setCustomFieldValue($field_name, $value, $editor = null, $required = null)
{
$custom_fields = isset($this->custom_fields) ? json_decode($this->custom_fields) : array();
$custom_fields[] = array(
'name' => $field_name,
'value' => $value,
'editor' => $editor,
'required' => $required
);
$this->custom_fields = json_encode($custom_fields);
return $this;
} | php | public function setCustomFieldValue($field_name, $value, $editor = null, $required = null)
{
$custom_fields = isset($this->custom_fields) ? json_decode($this->custom_fields) : array();
$custom_fields[] = array(
'name' => $field_name,
'value' => $value,
'editor' => $editor,
'required' => $required
);
$this->custom_fields = json_encode($custom_fields);
return $this;
} | [
"public",
"function",
"setCustomFieldValue",
"(",
"$",
"field_name",
",",
"$",
"value",
",",
"$",
"editor",
"=",
"null",
",",
"$",
"required",
"=",
"null",
")",
"{",
"$",
"custom_fields",
"=",
"isset",
"(",
"$",
"this",
"->",
"custom_fields",
")",
"?",
... | Set the value for a custom field with the given field name
and optionally define a Role allowed to edit it and if the field is required to be filled
@param string $field_name field name to be filled in
@param string $value
@param string $editor
@param string $required
@return SignatureRequest | [
"Set",
"the",
"value",
"for",
"a",
"custom",
"field",
"with",
"the",
"given",
"field",
"name",
"and",
"optionally",
"define",
"a",
"Role",
"allowed",
"to",
"edit",
"it",
"and",
"if",
"the",
"field",
"is",
"required",
"to",
"be",
"filled"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/SignatureRequest.php#L215-L226 | train |
hellosign/hellosign-php-sdk | library/HelloSign/SignatureRequest.php | SignatureRequest.addAttachment | public function addAttachment($name, $signer_index, $instructions = null, $required = null)
{
$attachment = new Attachment(array(
'name' => $name,
'instructions' => $instructions,
'signer_index' => $signer_index,
'required' => $required
));
$this->attachments[] = $attachment;
return $this;
} | php | public function addAttachment($name, $signer_index, $instructions = null, $required = null)
{
$attachment = new Attachment(array(
'name' => $name,
'instructions' => $instructions,
'signer_index' => $signer_index,
'required' => $required
));
$this->attachments[] = $attachment;
return $this;
} | [
"public",
"function",
"addAttachment",
"(",
"$",
"name",
",",
"$",
"signer_index",
",",
"$",
"instructions",
"=",
"null",
",",
"$",
"required",
"=",
"null",
")",
"{",
"$",
"attachment",
"=",
"new",
"Attachment",
"(",
"array",
"(",
"'name'",
"=>",
"$",
... | Adds an Attachment to the SignatureRequest
@param string $name Name of the Attachment.
@param integer $signer_index Index of the signer to upload this Attachment.
@param string $instructions Instructions for uploading the Attachment. (optional)
@param boolean $required Whether or not the signer is required to upload this Attachment. (optional)
@return SignatureRequest | [
"Adds",
"an",
"Attachment",
"to",
"the",
"SignatureRequest"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/SignatureRequest.php#L248-L260 | train |
hellosign/hellosign-php-sdk | library/HelloSign/AbstractResource.php | AbstractResource.getMetadata | public function getMetadata($key)
{
if (!is_array($this->metadata)) {
$this->metadata = json_decode(json_encode($this->metadata), true);
}
return (isset($this->metadata[$key])) ? $this->metadata[$key] : null;
} | php | public function getMetadata($key)
{
if (!is_array($this->metadata)) {
$this->metadata = json_decode(json_encode($this->metadata), true);
}
return (isset($this->metadata[$key])) ? $this->metadata[$key] : null;
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"metadata",
")",
")",
"{",
"$",
"this",
"->",
"metadata",
"=",
"json_decode",
"(",
"json_encode",
"(",
"$",
"this",
"->",
"metadata",
... | Get the current metadata value for the provided key.
@param string $key
@return string|NULL | [
"Get",
"the",
"current",
"metadata",
"value",
"for",
"the",
"provided",
"key",
"."
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/AbstractResource.php#L272-L278 | train |
hellosign/hellosign-php-sdk | library/HelloSign/AbstractList.php | AbstractList.setCollection | public function setCollection($array)
{
foreach ($array as $key => $object) {
$class_name = "HelloSign\\{$this->resource_class}";
$resource = new $class_name;
$resource->fromObject($object);
$this->collection[$key] = $resource;
}
return $this;
} | php | public function setCollection($array)
{
foreach ($array as $key => $object) {
$class_name = "HelloSign\\{$this->resource_class}";
$resource = new $class_name;
$resource->fromObject($object);
$this->collection[$key] = $resource;
}
return $this;
} | [
"public",
"function",
"setCollection",
"(",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"object",
")",
"{",
"$",
"class_name",
"=",
"\"HelloSign\\\\{$this->resource_class}\"",
";",
"$",
"resource",
"=",
"new",
"$",
"c... | Populate collection from array
@param array $array
@return static | [
"Populate",
"collection",
"from",
"array"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/AbstractList.php#L159-L170 | train |
hellosign/hellosign-php-sdk | library/HelloSign/AbstractSignatureRequest.php | AbstractSignatureRequest.addSigner | public function addSigner($email_or_signer, $name = null, $index = null)
{
$signer = ($email_or_signer instanceof Signer)
? $email_or_signer
: new Signer(array(
'name' => $name,
'email_address' => $email_or_signer
));
if (isset($index)) {
$this->signers[$index] = $signer;
} else {
$this->signers[] = $signer;
}
return $this;
} | php | public function addSigner($email_or_signer, $name = null, $index = null)
{
$signer = ($email_or_signer instanceof Signer)
? $email_or_signer
: new Signer(array(
'name' => $name,
'email_address' => $email_or_signer
));
if (isset($index)) {
$this->signers[$index] = $signer;
} else {
$this->signers[] = $signer;
}
return $this;
} | [
"public",
"function",
"addSigner",
"(",
"$",
"email_or_signer",
",",
"$",
"name",
"=",
"null",
",",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"signer",
"=",
"(",
"$",
"email_or_signer",
"instanceof",
"Signer",
")",
"?",
"$",
"email_or_signer",
":",
"new"... | Adds a signer to the signature request
@param mixed $email_or_signer
@param string $name
@param string $index
@return AbstractSignatureRequest | [
"Adds",
"a",
"signer",
"to",
"the",
"signature",
"request"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/AbstractSignatureRequest.php#L147-L163 | train |
hellosign/hellosign-php-sdk | library/HelloSign/AbstractSignatureRequest.php | AbstractSignatureRequest.addGroup | public function addGroup($name, $group_index_or_role = 0)
{
$group = new SignerGroup(array(
'name' => $name
));
$this->signers[$group_index_or_role] = $group;
return $this;
} | php | public function addGroup($name, $group_index_or_role = 0)
{
$group = new SignerGroup(array(
'name' => $name
));
$this->signers[$group_index_or_role] = $group;
return $this;
} | [
"public",
"function",
"addGroup",
"(",
"$",
"name",
",",
"$",
"group_index_or_role",
"=",
"0",
")",
"{",
"$",
"group",
"=",
"new",
"SignerGroup",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"signers",
"[",
"$",
... | Adds a Signer Group to the Signature Request
@param string $name Signer Group name
@param mixed $group_index_or_role Group Index or Signer Role. Defaults to 0.
@return AbstractSignatureRequest | [
"Adds",
"a",
"Signer",
"Group",
"to",
"the",
"Signature",
"Request"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/AbstractSignatureRequest.php#L172-L181 | train |
hellosign/hellosign-php-sdk | library/HelloSign/AbstractSignatureRequest.php | AbstractSignatureRequest.addGroupSigner | public function addGroupSigner($name, $email, $signer_index, $group_index_or_role = 0)
{
$signer = new Signer(array(
'name' => $name,
'email_address' => $email
)
);
$this->signers[$group_index_or_role]->$signer_index = $signer;
return $this;
} | php | public function addGroupSigner($name, $email, $signer_index, $group_index_or_role = 0)
{
$signer = new Signer(array(
'name' => $name,
'email_address' => $email
)
);
$this->signers[$group_index_or_role]->$signer_index = $signer;
return $this;
} | [
"public",
"function",
"addGroupSigner",
"(",
"$",
"name",
",",
"$",
"email",
",",
"$",
"signer_index",
",",
"$",
"group_index_or_role",
"=",
"0",
")",
"{",
"$",
"signer",
"=",
"new",
"Signer",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"name",
",",
"'emai... | Adds Signers to a Signer Group in the Signature Request
@param string $name Name of the Signer
@param string $email Email address of the Signer
@param integer $signer_index Signer Index of the Signer
@param mixed $group_index_or_role Group Index or Signer Role. Defaults to 0.
@return AbstractSignatureRequest | [
"Adds",
"Signers",
"to",
"a",
"Signer",
"Group",
"in",
"the",
"Signature",
"Request"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/AbstractSignatureRequest.php#L192-L203 | train |
hellosign/hellosign-php-sdk | library/HelloSign/Event.php | Event.isValid | public function isValid($api_key)
{
if (!$api_key) {
return false;
}
return ($this->event_hash == $this->calculateHash($api_key))
? true : false;
} | php | public function isValid($api_key)
{
if (!$api_key) {
return false;
}
return ($this->event_hash == $this->calculateHash($api_key))
? true : false;
} | [
"public",
"function",
"isValid",
"(",
"$",
"api_key",
")",
"{",
"if",
"(",
"!",
"$",
"api_key",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"$",
"this",
"->",
"event_hash",
"==",
"$",
"this",
"->",
"calculateHash",
"(",
"$",
"api_key",
")",... | Check the event is valid or not
@param string $api_key
@return boolean
@see Event::calculateHash() | [
"Check",
"the",
"event",
"is",
"valid",
"or",
"not"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/Event.php#L214-L222 | train |
hellosign/hellosign-php-sdk | library/HelloSign/TemplateSignatureRequest.php | TemplateSignatureRequest.setTemplateId | public function setTemplateId($id, $order = null) {
if ($order === null) {
// If no order is provided, append the template ID to the end of the list
$this->template_ids[] = $id;
} else {
$this->template_ids[$order] = $id;
}
return $this;
} | php | public function setTemplateId($id, $order = null) {
if ($order === null) {
// If no order is provided, append the template ID to the end of the list
$this->template_ids[] = $id;
} else {
$this->template_ids[$order] = $id;
}
return $this;
} | [
"public",
"function",
"setTemplateId",
"(",
"$",
"id",
",",
"$",
"order",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"order",
"===",
"null",
")",
"{",
"// If no order is provided, append the template ID to the end of the list",
"$",
"this",
"->",
"template_ids",
"[",
... | Set the template ID, along with an optional order
@param string $id
@param int null $index
@return \HelloSign\TemplateSignatureRequest | [
"Set",
"the",
"template",
"ID",
"along",
"with",
"an",
"optional",
"order"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/TemplateSignatureRequest.php#L65-L73 | train |
hellosign/hellosign-php-sdk | library/HelloSign/TemplateSignatureRequest.php | TemplateSignatureRequest.setSigner | public function setSigner($role, $email_or_signer, $name = null)
{
return parent::addSigner($email_or_signer, $name, $role);
} | php | public function setSigner($role, $email_or_signer, $name = null)
{
return parent::addSigner($email_or_signer, $name, $role);
} | [
"public",
"function",
"setSigner",
"(",
"$",
"role",
",",
"$",
"email_or_signer",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"parent",
"::",
"addSigner",
"(",
"$",
"email_or_signer",
",",
"$",
"name",
",",
"$",
"role",
")",
";",
"}"
] | Set the signer to the list of signers for this request
@param string $role
@param mixed $email_or_signer
@param string $name
@return TemplateSignatureRequest
@see AbstractSignatureRequest::addSigner() | [
"Set",
"the",
"signer",
"to",
"the",
"list",
"of",
"signers",
"for",
"this",
"request"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/TemplateSignatureRequest.php#L84-L87 | train |
hellosign/hellosign-php-sdk | library/HelloSign/TemplateSignatureRequest.php | TemplateSignatureRequest.setCC | public function setCC($role, $email)
{
$obj = new stdClass;
$obj->email_address = $email;
$this->ccs[$role] = $obj;
return $this;
} | php | public function setCC($role, $email)
{
$obj = new stdClass;
$obj->email_address = $email;
$this->ccs[$role] = $obj;
return $this;
} | [
"public",
"function",
"setCC",
"(",
"$",
"role",
",",
"$",
"email",
")",
"{",
"$",
"obj",
"=",
"new",
"stdClass",
";",
"$",
"obj",
"->",
"email_address",
"=",
"$",
"email",
";",
"$",
"this",
"->",
"ccs",
"[",
"$",
"role",
"]",
"=",
"$",
"obj",
... | Sets the CC email address for the provided role
@param string $role
@param string $email
@return TemplateSignatureRequest | [
"Sets",
"the",
"CC",
"email",
"address",
"for",
"the",
"provided",
"role"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/TemplateSignatureRequest.php#L96-L104 | train |
hellosign/hellosign-php-sdk | library/HelloSign/AbstractResourceList.php | AbstractResourceList.fromResponse | public function fromResponse($response)
{
$this->page = $response->list_info->page;
$this->num_pages = $response->list_info->num_pages;
$this->num_results = $response->list_info->num_results;
$this->page_size = $response->list_info->page_size;
property_exists($response, $this->list_type) && $this->setCollection($response->{$this->list_type});
return $this;
} | php | public function fromResponse($response)
{
$this->page = $response->list_info->page;
$this->num_pages = $response->list_info->num_pages;
$this->num_results = $response->list_info->num_results;
$this->page_size = $response->list_info->page_size;
property_exists($response, $this->list_type) && $this->setCollection($response->{$this->list_type});
return $this;
} | [
"public",
"function",
"fromResponse",
"(",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"page",
"=",
"$",
"response",
"->",
"list_info",
"->",
"page",
";",
"$",
"this",
"->",
"num_pages",
"=",
"$",
"response",
"->",
"list_info",
"->",
"num_pages",
";",
... | Populate from response
@param stdClass $response
@return static
@see static::setCollection() | [
"Populate",
"from",
"response"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/AbstractResourceList.php#L145-L155 | train |
hellosign/hellosign-php-sdk | library/HelloSign/BulkSendJob.php | BulkSendJob.addSignerfile | public function addSignerfile($file)
{
if (!file_exists($file)) {
throw new Error('file not found', 'File does not exist. Please use an absolute file path.');
}
$this->signer_file = fopen($file, 'rb');
return $this;
} | php | public function addSignerfile($file)
{
if (!file_exists($file)) {
throw new Error('file not found', 'File does not exist. Please use an absolute file path.');
}
$this->signer_file = fopen($file, 'rb');
return $this;
} | [
"public",
"function",
"addSignerfile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'file not found'",
",",
"'File does not exist. Please use an absolute file path.'",
")",
";",
"}",
... | Adds a list of signers in a CSV file. Required unless signer_list is used.
@param string $file path for signer_file
@return BulkSendJob
@ignore | [
"Adds",
"a",
"list",
"of",
"signers",
"in",
"a",
"CSV",
"file",
".",
"Required",
"unless",
"signer_list",
"is",
"used",
"."
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/BulkSendJob.php#L120-L128 | train |
hellosign/hellosign-php-sdk | library/HelloSign/Client.php | Client.sendSignatureRequest | public function sendSignatureRequest(SignatureRequest $request)
{
$params = $request->toParams();
$response = $this->rest->post(
static::SIGNATURE_REQUEST_SEND_PATH,
$params
);
$this->checkResponse($response);
return $request->fromResponse($response);
} | php | public function sendSignatureRequest(SignatureRequest $request)
{
$params = $request->toParams();
$response = $this->rest->post(
static::SIGNATURE_REQUEST_SEND_PATH,
$params
);
$this->checkResponse($response);
return $request->fromResponse($response);
} | [
"public",
"function",
"sendSignatureRequest",
"(",
"SignatureRequest",
"$",
"request",
")",
"{",
"$",
"params",
"=",
"$",
"request",
"->",
"toParams",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"static",
"::",
"SIG... | Send a new SignatureRequest with the submitted documents
@param SignatureRequest $request
@return SignatureRequest
@throws BaseException | [
"Send",
"a",
"new",
"SignatureRequest",
"with",
"the",
"submitted",
"documents"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/Client.php#L147-L159 | train |
hellosign/hellosign-php-sdk | library/HelloSign/Client.php | Client.cancelSignatureRequest | public function cancelSignatureRequest($id)
{
$response = $this->rest->post(
static::SIGNATURE_REQUEST_CANCEL_PATH . '/' . $id
);
$this->checkResponse($response, false);
return true;
} | php | public function cancelSignatureRequest($id)
{
$response = $this->rest->post(
static::SIGNATURE_REQUEST_CANCEL_PATH . '/' . $id
);
$this->checkResponse($response, false);
return true;
} | [
"public",
"function",
"cancelSignatureRequest",
"(",
"$",
"id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"static",
"::",
"SIGNATURE_REQUEST_CANCEL_PATH",
".",
"'/'",
".",
"$",
"id",
")",
";",
"$",
"this",
"->",
"check... | Cancels an existing signature request
If it has been completed, it will delete the signature request from
your account.
@param string $id
@return boolean
@throws BaseException | [
"Cancels",
"an",
"existing",
"signature",
"request"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/Client.php#L171-L180 | train |
hellosign/hellosign-php-sdk | library/HelloSign/Client.php | Client.requestEmailReminder | public function requestEmailReminder($request_id, $email, $name = null)
{
$response = $this->rest->post(
static::SIGNATURE_REQUEST_REMIND_PATH . '/' . $request_id,
array('email_address' => $email, 'name' => $name)
);
$this->checkResponse($response);
return new SignatureRequest($response);
} | php | public function requestEmailReminder($request_id, $email, $name = null)
{
$response = $this->rest->post(
static::SIGNATURE_REQUEST_REMIND_PATH . '/' . $request_id,
array('email_address' => $email, 'name' => $name)
);
$this->checkResponse($response);
return new SignatureRequest($response);
} | [
"public",
"function",
"requestEmailReminder",
"(",
"$",
"request_id",
",",
"$",
"email",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"static",
"::",
"SIGNATURE_REQUEST_REMIND_PATH",
".",
"'/'... | Instructs HelloSign to email the given address with a reminder to sign
the SignatureRequest referenced by the given request ID.
Note: You cannot send a reminder within 1 hour of the last reminder that
was sent, manually or automatically.
@param string $request_id Signature Request ID
@param string $email Email address of the signer
@param string $name Name of signer to send reminder to (optional)
@return SignatureRequest
@throws BaseException | [
"Instructs",
"HelloSign",
"to",
"email",
"the",
"given",
"address",
"with",
"a",
"reminder",
"to",
"sign",
"the",
"SignatureRequest",
"referenced",
"by",
"the",
"given",
"request",
"ID",
"."
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/Client.php#L195-L205 | train |
hellosign/hellosign-php-sdk | library/HelloSign/Client.php | Client.updateSignatureRequest | public function updateSignatureRequest($request_id, $signature_id, $email)
{
$response = $this->rest->post(
static::SIGNATURE_REQUEST_UPDATE_PATH . '/' . $request_id,
array('signature_id' => $signature_id, 'email_address' => $email)
);
$this->checkResponse($response);
return new SignatureRequest($response);
} | php | public function updateSignatureRequest($request_id, $signature_id, $email)
{
$response = $this->rest->post(
static::SIGNATURE_REQUEST_UPDATE_PATH . '/' . $request_id,
array('signature_id' => $signature_id, 'email_address' => $email)
);
$this->checkResponse($response);
return new SignatureRequest($response);
} | [
"public",
"function",
"updateSignatureRequest",
"(",
"$",
"request_id",
",",
"$",
"signature_id",
",",
"$",
"email",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"static",
"::",
"SIGNATURE_REQUEST_UPDATE_PATH",
".",
"'/'",
".... | Updates the email address for a given signer on a SignatureRequest
@param string $request_id Signature Request ID to update
@param string $signature_id The Signature ID for the recipient
@param string $email The new email address for the recipient
@return SignatureRequest
@throws BaseException | [
"Updates",
"the",
"email",
"address",
"for",
"a",
"given",
"signer",
"on",
"a",
"SignatureRequest"
] | 4382ee60973a5fc5f957fa86777e93dedfc64d50 | https://github.com/hellosign/hellosign-php-sdk/blob/4382ee60973a5fc5f957fa86777e93dedfc64d50/library/HelloSign/Client.php#L216-L226 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.