当前位置: 首页>>代码示例>>PHP>>正文


PHP gp_array_get函数代码示例

本文整理汇总了PHP中gp_array_get函数的典型用法代码示例。如果您正苦于以下问题:PHP gp_array_get函数的具体用法?PHP gp_array_get怎么用?PHP gp_array_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gp_array_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 /**
  * Import originals for a project from a file
  *
  * ## OPTIONS
  *
  * <project>
  * : Project name
  *
  * <file>
  * : File to import from
  *
  * [--format=<format>]
  * : Accepted values: po, mo, android, resx, strings. Default: po
  */
 public function __invoke($args, $assoc_args)
 {
     // Double-check for compatibility
     if ($args[0] === '-p' || $args[1] === '-f') {
         WP_CLI::error(__('-p and -f are no longer required and should be removed.', 'glotpress'));
     }
     $project = GP::$project->by_path($args[0]);
     if (!$project) {
         WP_CLI::error(__('Project not found!', 'glotpress'));
     }
     $format = isset($assoc_args['format']) ? $assoc_args['format'] : 'po';
     $format = gp_array_get(GP::$formats, $format, null);
     if (!$format) {
         WP_CLI::error(__('No such format.', 'glotpress'));
     }
     $translations = $format->read_originals_from_file($args[1], $project);
     if (!$translations) {
         WP_CLI::error(__("Couldn't load translations from file!", 'glotpress'));
     }
     list($originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted, $originals_error) = GP::$original->import_for_project($project, $translations);
     $notice = sprintf(__('%1$s new strings added, %2$s updated, %3$s fuzzied, and %4$s obsoleted.', 'glotpress'), $originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted);
     if ($originals_error) {
         $notice = ' ' . sprintf(_n('%s new string was not imported due to an error.', '%s new strings were not imported due to an error.', $originals_error, 'glotpress'), $originals_error);
     }
     WP_CLI::line($notice);
 }
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:40,代码来源:import-originals.php

示例2: export

 /**
  * Export the translation set
  *
  * ## OPTIONS
  *
  * <project>
  * : Project path
  *
  * <locale>
  * : Locale to export
  *
  * [--set=<set>]
  * : Translation set slug; default is "default"
  *
  * [--format=<format>]
  * : Format for output (one of "po", "mo", "android", "resx", "strings"; default is "po")
  *
  * [--search=<search>]
  * : Search term
  *
  * [--status=<status>]
  * : Translation string status; default is "current"
  *
  * [--priority=<priorities>]
  * : Original priorities, comma separated. Possible values are "hidden,low,normal,high"
  */
 public function export($args, $assoc_args)
 {
     $set_slug = isset($assoc_args['set']) ? $assoc_args['set'] : 'default';
     $translation_set = $this->get_translation_set($args[0], $args[1], $set_slug);
     if (is_wp_error($translation_set)) {
         WP_CLI::error($translation_set->get_error_message());
     }
     $format = isset($assoc_args['format']) ? $assoc_args['format'] : 'po';
     $format = gp_array_get(GP::$formats, $format, null);
     if (!$format) {
         WP_CLI::error(__('No such format.', 'glotpress'));
     }
     $filters = array();
     if (isset($assoc_args['search'])) {
         $filters['term'] = $assoc_args['search'];
     }
     $filters['status'] = isset($assoc_args['status']) ? $assoc_args['status'] : 'current';
     if (isset($assoc_args['priority'])) {
         $filters['priority'] = array();
         $priorities = explode(',', $assoc_args['priority']);
         $valid_priorities = GP::$original->get_static('priorities');
         foreach ($priorities as $priority) {
             $key = array_search($priority, $valid_priorities);
             if (false === $key) {
                 WP_CLI::warning(sprintf('Invalid priority %s', $priority));
             } else {
                 $filters['priority'][] = $key;
             }
         }
     }
     $entries = GP::$translation->for_export($this->project, $translation_set, $filters);
     WP_CLI::line($format->print_exported_file($this->project, $this->locale, $translation_set, $entries));
 }
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:59,代码来源:translation-set.php

示例3: _options_from_projects

 function _options_from_projects($projects)
 {
     // TODO: mark which nodes are editable by the current user
     $tree = array();
     $top = array();
     foreach ($projects as $p) {
         $tree[$p->id]['self'] = $p;
         if ($p->parent_project_id) {
             $tree[$p->parent_project_id]['children'][] = $p->id;
         } else {
             $top[] = $p->id;
         }
     }
     $options = array('' => __('No parent'));
     $stack = array();
     foreach ($top as $top_id) {
         $stack = array($top_id);
         while (!empty($stack)) {
             $id = array_pop($stack);
             $tree[$id]['level'] = gp_array_get($tree[$id], 'level', 0);
             $options[$id] = str_repeat('-', $tree[$id]['level']) . $tree[$id]['self']->name;
             foreach (gp_array_get($tree[$id], 'children', array()) as $child_id) {
                 $stack[] = $child_id;
                 $tree[$child_id]['level'] = $tree[$id]['level'] + 1;
             }
         }
     }
     return $options;
 }
开发者ID:rmccue,项目名称:GlotPress,代码行数:29,代码来源:_main.php

示例4: run

 function run()
 {
     if (!isset($this->options['p'])) {
         $this->usage();
     }
     $project = GP::$project->by_path($this->options['p']);
     if (!$project) {
         $this->error(__('Project not found!'));
     }
     $format = gp_array_get(GP::$formats, isset($this->options['o']) ? $this->options['o'] : 'po', null);
     if (!$format) {
         $this->error(__('No such format.'));
     }
     $translations = $format->read_originals_from_file($this->options['f'], $project);
     if (!$translations) {
         $this->error(__("Couldn't load translations from file!"));
     }
     $disable_propagating = isset($this->options['disable-propagating']);
     $disable_matching = isset($this->options['disable-matching']);
     if ($disable_propagating) {
         add_filter('enable_propagate_translations_across_projects', '__return_false');
     }
     if ($disable_matching) {
         add_filter('enable_add_translations_from_other_projects', '__return_false');
     }
     list($originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted) = GP::$original->import_for_project($project, $translations);
     if ($disable_matching) {
         remove_filter('enable_add_translations_from_other_projects', '__return_false');
     }
     if ($disable_propagating) {
         remove_filter('enable_propagate_translations_across_projects', '__return_false');
     }
     printf(__('%1$s new strings added, %2$s updated, %3$s fuzzied, and %4$s obsoleted.'), $originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted);
     echo "\n";
 }
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:35,代码来源:import-originals.php

示例5: gp_url_current

function gp_url_current()
{
    // TODO: https
    // TODO: port
    $host = gp_array_get($_SERVER, 'HTTP_HOST');
    $path_and_args = gp_array_get($_SERVER, 'REQUEST_URI');
    return "http://{$host}{$path_and_args}";
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:8,代码来源:url.php

示例6: action_on_translation_set

 function action_on_translation_set($translation_set)
 {
     $format = gp_array_get(GP::$formats, isset($this->options['o']) ? $this->options['o'] : 'po', null);
     if (!$format) {
         $this->error(__('No such format.'));
     }
     $entries = GP::$translation->for_export($this->project, $translation_set, $this->get_filters_for_translation());
     echo $format->print_exported_file($this->project, $this->locale, $translation_set, $entries) . "\n";
 }
开发者ID:pedro-mendonca,项目名称:GlotPress-WP,代码行数:9,代码来源:export.php

示例7: guess_uri

/**
 * Guesses the final installed URI based on the location of the install script
 *
 * @return string The guessed URI
 */
function guess_uri()
{
    $schema = 'http://';
    if (strtolower(gp_array_get($_SERVER, 'HTTPS')) == 'on') {
        $schema = 'https://';
    }
    $uri = preg_replace('|/[^/]*$|i', '/', $schema . gp_array_get($_SERVER, 'HTTP_HOST') . gp_array_get($_SERVER, 'REQUEST_URI'));
    return rtrim($uri, " \t\n\r\v/") . '/';
}
开发者ID:rmccue,项目名称:GlotPress,代码行数:14,代码来源:install-upgrade.php

示例8: prepare_fields_for_save

 function prepare_fields_for_save($args)
 {
     $args = (array) $args;
     $args['object_type'] = $this->object_type;
     if (gp_array_get($args, 'project_id') && gp_array_get($args, 'locale_slug') && gp_array_get($args, 'set_slug') && !gp_array_get($args, 'object_id')) {
         $args['object_id'] = $this->object_id($args['project_id'], $args['locale_slug'], $args['set_slug']);
     }
     $args = parent::prepare_fields_for_save($args);
     return $args;
 }
开发者ID:akirk,项目名称:GlotPress,代码行数:10,代码来源:validator-permission.php

示例9: can_user

 function can_user($verdict, $args)
 {
     if (!($verdict === false && $args['action'] == 'approve' && $args['object_type'] == GP::$validator_permission->object_type && $args['object_id'] && $args['user'])) {
         return $verdict;
     }
     list($project_id, $locale_slug, $set_slug) = GP::$validator_permission->project_id_locale_slug_set_slug($args['object_id']);
     if (!gp_array_get($this->permissions_map, $project_id)) {
         return $verdict;
     }
     return $args['user']->can('approve', $args['object_type'], GP::$validator_permission->object_id(gp_array_get($this->permissions_map, $project_id), $locale_slug, $set_slug));
 }
开发者ID:serhi,项目名称:wordpress-sites,代码行数:11,代码来源:common-permissions.php

示例10: export

 /**
  * Export the translation set
  *
  * ## OPTIONS
  *
  * <project>
  * : Project path
  *
  * <locale>
  * : Locale to export
  *
  * [--set=<set>]
  * : Translation set slug; default is "default"
  *
  * [--format=<format>]
  * : Format for output (one of "po", "mo", "android", "resx", "strings"; default is "po")
  *
  * [--search=<search>]
  * : Search term
  *
  * [--status=<status>]
  * : Translation string status; default is "current"
  */
 public function export($args, $assoc_args)
 {
     $set_slug = isset($assoc_args['set']) ? $assoc_args['set'] : 'default';
     $translation_set = $this->get_translation_set($args[0], $args[1], $set_slug);
     if (is_wp_error($translation_set)) {
         WP_CLI::error($translation_set->get_error_message());
     }
     $format = isset($assoc_args['format']) ? $assoc_args['format'] : 'po';
     $format = gp_array_get(GP::$formats, $format, null);
     if (!$format) {
         WP_CLI::error(__('No such format.', 'glotpress'));
     }
     $filters = array();
     if (isset($assoc_args['search'])) {
         $filters['term'] = $assoc_args['search'];
     }
     $assoc_args['status'] = isset($assoc_args['status']) ? $assoc_args['status'] : 'current';
     $entries = GP::$translation->for_export($this->project, $translation_set, $filters);
     WP_CLI::line($format->print_exported_file($this->project, $this->locale, $translation_set, $entries));
 }
开发者ID:akirk,项目名称:GlotPress,代码行数:43,代码来源:translation-set.php

示例11: run

 public function run()
 {
     if (!isset($this->options['l']) || !isset($this->options['p'])) {
         $this->usage();
     }
     $this->project = GP::$project->by_path($this->options['p']);
     if (!$this->project) {
         $this->error(__('Project not found!', 'glotpress'));
     }
     $this->locale = GP_Locales::by_slug($this->options['l']);
     if (!$this->locale) {
         $this->error(__('Locale not found!', 'glotpress'));
     }
     $this->options['t'] = gp_array_get($this->options, 't', 'default');
     $this->translation_set = GP::$translation_set->by_project_id_slug_and_locale($this->project->id, $this->options['t'], $this->locale->slug);
     if (!$this->translation_set) {
         $this->error(__('Translation set not found!', 'glotpress'));
     }
     $this->action_on_translation_set($this->translation_set);
 }
开发者ID:ramiy,项目名称:GlotPress-WP,代码行数:20,代码来源:cli.php

示例12: __invoke

 /**
  * Import originals for a project from a file
  *
  * ## OPTIONS
  *
  * <project>
  * : Project name
  *
  * <file>
  * : File to import from
  *
  * [--format=<format>]
  * : Accepted values: po, mo, android, resx, strings. Default: po
  *
  * [--disable-propagating]
  * : If set, propagation will be disabled.
  *
  * [--disable-matching]
  * : If set, matching will be disabled.
  */
 public function __invoke($args, $assoc_args)
 {
     // Double-check for compatibility
     if ($args[0] === '-p' || $args[1] === '-f') {
         WP_CLI::error(__('-p and -f are no longer required and should be removed.', 'glotpress'));
     }
     $project = GP::$project->by_path($args[0]);
     if (!$project) {
         WP_CLI::error(__('Project not found!', 'glotpress'));
     }
     $format = isset($assoc_args['format']) ? $assoc_args['format'] : 'po';
     $format = gp_array_get(GP::$formats, $format, null);
     if (!$format) {
         WP_CLI::error(__('No such format.', 'glotpress'));
     }
     $translations = $format->read_originals_from_file($args[1], $project);
     if (!$translations) {
         WP_CLI::error(__("Couldn't load translations from file!", 'glotpress'));
     }
     $disable_propagating = isset($assoc_args['disable-propagating']);
     $disable_matching = isset($assoc_args['disable-matching']);
     if ($disable_propagating) {
         add_filter('gp_enable_propagate_translations_across_projects', '__return_false');
     }
     if ($disable_matching) {
         add_filter('gp_enable_add_translations_from_other_projects', '__return_false');
     }
     list($originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted) = GP::$original->import_for_project($project, $translations);
     if ($disable_matching) {
         remove_filter('gp_enable_add_translations_from_other_projects', '__return_false');
     }
     if ($disable_propagating) {
         remove_filter('gp_enable_propagate_translations_across_projects', '__return_false');
     }
     WP_CLI::line(sprintf(__('%1$s new strings added, %2$s updated, %3$s fuzzied, and %4$s obsoleted.', 'glotpress'), $originals_added, $originals_existing, $originals_fuzzied, $originals_obsoleted));
 }
开发者ID:akirk,项目名称:GlotPress,代码行数:56,代码来源:import-originals.php

示例13: translations_get

 function translations_get($project_path, $locale_slug, $translation_set_slug)
 {
     $project = GP::$project->by_path($project_path);
     $locale = GP_Locales::by_slug($locale_slug);
     $translation_set = GP::$translation_set->by_project_id_slug_and_locale($project->id, $translation_set_slug, $locale_slug);
     if (!$project || !$locale || !$translation_set) {
         gp_tmpl_404();
     }
     $page = gp_get('page', 1);
     $filters = gp_get('filters', array());
     $sort = gp_get('sort', array());
     if ('random' == gp_array_get($sort, 'by')) {
         add_filter('gp_pagination', create_function('$html', 'return "";'));
     }
     $translations = GP::$translation->for_translation($project, $translation_set, $page, $filters, $sort);
     $total_translations_count = GP::$translation->found_rows;
     $per_page = GP::$translation->per_page;
     $can_edit = GP::$user->logged_in();
     $can_approve = $this->can('approve', 'translation-set', $translation_set->id);
     $url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug));
     $discard_warning_url = gp_url_project($project, gp_url_join($locale->slug, $translation_set->slug, '_discard-warning'));
     $approve_action = gp_url_join($url, '_approve');
     gp_tmpl_load('translations', get_defined_vars());
 }
开发者ID:rmccue,项目名称:GlotPress,代码行数:24,代码来源:translation.php

示例14: _bulk_set_priority

 function _bulk_set_priority($project, $locale, $translation_set, $bulk)
 {
     if ($this->cannot_and_redirect('write', 'project', $project->id)) {
         return;
     }
     $ok = $error = 0;
     foreach ($bulk['row-ids'] as $row_id) {
         $original_id = gp_array_get(explode('-', $row_id), 0);
         $original = GP::$original->get($original_id);
         if (!$original) {
             continue;
         }
         $original->priority = $bulk['priority'];
         if (!$original->validate()) {
             return $this->die_with_error('Invalid priority value!');
         }
         if (!$original->save()) {
             $error++;
         } else {
             $ok++;
         }
     }
     if (0 === $error) {
         $this->notices[] = sprintf(_n('Priority of %d original was modified.', 'Priority of %d originals were modified.', $ok, 'glotpress'), $ok);
     } else {
         if ($ok > 0) {
             $message = sprintf(_n('Error modifying priority of %d original.', 'Error modifying priority of %d originals.', $error, 'glotpress'), $error);
             $message .= sprintf(_n('The remaining %d original was modified successfully.', 'The remaining %d originals were modified successfully.', $ok, 'glotpress'), $ok);
             $this->errors[] = $message;
         } else {
             $this->errors[] = sprintf(_n('Error modifying priority of %d original.', 'Error modifying priority of all %d originals.', $error, 'glotpress'), $error);
         }
     }
 }
开发者ID:akirk,项目名称:GlotPress,代码行数:34,代码来源:translation.php

示例15: gp_url_current

/**
 * The URL of the current page
 */
function gp_url_current()
{
    $protocol = is_ssl() ? 'https://' : 'http://';
    $host = gp_array_get($_SERVER, 'HTTP_HOST');
    $path_and_args = gp_array_get($_SERVER, 'REQUEST_URI');
    return $protocol . $host . $path_and_args;
}
开发者ID:johnjamesjacoby,项目名称:GlotPress-WP,代码行数:10,代码来源:url.php


注:本文中的gp_array_get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。