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


PHP i18n::bind方法代码示例

本文整理汇总了PHP中i18n::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::bind方法的具体用法?PHP i18n::bind怎么用?PHP i18n::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在i18n的用法示例。


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

示例1: bind

 /**
  * create a new authenticator instance
  *
  * This function creates an instance of the Authenticator class based on the given type.
  * For the type '[code]foo[/code]', the script file '[code]users/authenticators/foo.php[/code]' is loaded.
  *
  * Example:
  * [php]
  * // create a new authenticator
  * $authenticator = Authenticator::bind('ldap');
  * [/php]
  *
  * The provided string may include parameters after the type.
  * These parameters, if any, are saved along authenticator attributes.
  *
  * @param string authenticator type, followed by parameters if any
  * @return a brand new instance
  *
  */
 public static function bind($type = '')
 {
     global $context;
     // stop hackers, if any
     $type = preg_replace(FORBIDDEN_IN_PATHS, '', strip_tags($type));
     // remove side spaces
     $type = trim($type);
     // sanity check
     if (!$type) {
         Logger::error(i18n::s('Invalid authenticator type.'));
         return NULL;
     }
     // localize authenticators strings
     i18n::bind('users');
     // extract parameters, if any
     $parameters = '';
     if (strlen($type) > 1 && ($separator = strpos($type, ' ', 1)) !== FALSE) {
         $parameters = substr($type, $separator + 1);
         $type = substr($type, 0, $separator);
     }
     // load the authenticator class file
     $file = $context['path_to_root'] . 'users/authenticators/' . $type . '.php';
     if (is_readable($file)) {
         include_once $file;
     }
     // create the instance
     $class_auth = $type . AUTH_CLASS_SUFFIX;
     if (class_exists(class_auth)) {
         $authenticator = new $class_auth();
         $authenticator->attributes = array();
         $authenticator->attributes['authenticator_type'] = $class_auth;
         $authenticator->attributes['authenticator_parameters'] = $parameters;
         return $authenticator;
     }
     // houston, we've got a problem
     Logger::error(sprintf(i18n::s('Unknown authenticator type %s'), $type));
     return NULL;
 }
开发者ID:rair,项目名称:yacs,代码行数:57,代码来源:authenticator.php

示例2: get_path_bar

 /**
  * get the path bar for this anchor
  *
  * For users, the path bar is made of one stem for all users, then one stem for the user himself.
  *
  * @return an array of $url => $label
  *
  * @see shared/anchor.php
  */
 function get_path_bar()
 {
     // load localized strings
     i18n::bind('users');
     // the index of users
     $output = array('users/' => i18n::s('People'));
     // then this user
     if (isset($this->item['id'])) {
         $url = $this->get_url();
         if (isset($this->item['full_name']) && $this->item['full_name']) {
             $label = $this->item['full_name'];
         } else {
             $label = $this->item['nick_name'];
         }
         $output = array_merge($output, array($url => $label));
     }
     // return an array of ($url => $label)
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:28,代码来源:user.php

示例3: array

                    // image link
                // image link
                case 'image':
                    include_once $context['path_to_root'] . 'images/images.php';
                    if ($item = Images::get($matches[2])) {
                        return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name'])));
                    }
                    return array('', $text, '');
                    // category link
                // category link
                case 'category':
                    if ($item = Categories::get($matches[2])) {
                        return array(Categories::get_permalink($item), $item['title'], $item['introduction']);
                    }
                    return array('', $text, '');
                    // user link
                // user link
                case 'user':
                    if ($item = Users::get($matches[2])) {
                        return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']);
                    }
                    return array('', $text, '');
            }
        }
        return array('', $text, '');
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('links');
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:links.php

示例4: elseif

// look for words
$search = '';
if (isset($_REQUEST['search'])) {
    $search = $_REQUEST['search'];
} elseif (isset($context['arguments'][0])) {
    $search = $context['arguments'][0];
}
$search = strip_tags($search);
// search type
$type = '';
if (isset($_REQUEST['type'])) {
    $type = $_REQUEST['type'];
}
$type = strip_tags($type);
// load localized strings
i18n::bind('services');
// load a skin engine
load_skin('services');
// loads feeding parameters
Safe::load('parameters/feeds.include.php');
// set default values
if (!$context['channel_title']) {
    $context['channel_title'] = $context['site_name'];
}
if (!$context['channel_description']) {
    $context['channel_description'] = $context['site_description'];
}
// channel attributes
$values = array();
$values['channel'] = array();
// set channel information
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:search.php

示例5: array

 * [title]What happens on first installation?[/title]
 *
 * The YACS archive that contains reference scripts is used jointly on first installation and on upgrades.
 * However, scripts to be ran once are useful only for upgrades.
 * Therefore, on first installation (i.e., when the switch file is absent), the extension '.done' is appended to
 * every script in the directory scripts/run_once without actual execution of them.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// include global declarations
include_once '../shared/global.php';
// load localized strings
i18n::bind('scripts');
// load the skin
load_skin('scripts');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = i18n::s('Run one-time scripts');
// the list of script to take into account
global $scripts;
$scripts = array();
// if the user table exists, check that the user is an admin
$query = "SELECT count(*) FROM " . SQL::table_name('users');
if (SQL::query($query) !== FALSE && !Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // open the directory
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:run_once.php

示例6: transcode

     */
    function transcode($transcoded)
    {
        global $context;
        // no item bound
        if (!isset($this->item['id'])) {
            return;
        }
        // prepare preg_replace()
        $from = array();
        $to = array();
        foreach ($transcoded as $pair) {
            $from[] = $pair[0];
            $to[] = $pair[1];
        }
        // transcode various fields
        $this->item['introduction'] = preg_replace($from, $to, $this->item['introduction']);
        $this->item['description'] = preg_replace($from, $to, $this->item['description']);
        // update the database
        $query = "UPDATE " . SQL::table_name('categories') . " SET " . " introduction = '" . SQL::escape($this->item['introduction']) . "'," . " description = '" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']);
        SQL::query($query);
        // always clear the cache, even on no update
        Categories::clear($this->item);
    }
}
// stop hackers
defined('YACS') or exit('Script must be included');
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('categories');
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:category.php

示例7: array

 * On subsequent access to the query page, using page handle, these data is restored to surfer environment.
 * With this setup, anonymous surfers may interact with a given web page without registering first.
 *
 * YACS attempts to stop robots by generating a random string and by asking user to type it.
 *
 * @author Bernard Paques
 * @tester fw_crocodile
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once 'shared/global.php';
// do not always show the edition form
$with_form = FALSE;
// load localized strings
i18n::bind('root');
// load the skin
load_skin('query');
// the title of the page
$context['page_title'] = i18n::s('Help');
// get a section for queries
if (!($anchor = Anchors::get('section:queries'))) {
    $fields = array();
    $fields['nick_name'] = 'queries';
    $fields['title'] =& i18n::c('Queries');
    $fields['introduction'] =& i18n::c('Submitted to the webmaster by any surfers');
    $fields['description'] =& i18n::c('<p>This section has been created automatically on query submission. It\'s aiming to capture feedback directly from surfers. It is highly recommended to delete pages below after their processing. Of course you can edit submitted queries to assign them to other sections if necessary.</p>');
    $fields['locked'] = 'Y';
    // no direct contributions
    $fields['active_set'] = 'N';
    // for associates only
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:query.php

示例8: array

 * the active configuration before the last change, if necessary.
 *
 * If the file [code]parameters/demo.flag[/code] exists, the script assumes that this instance
 * of YACS runs in demonstration mode.
 * In this mode the edit form is displayed, but parameters are not saved in the configuration file.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @tester Guillaume Perez
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
// load localized strings
i18n::bind('agents');
// load the skin
load_skin('agents');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Background processing'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('agents/configure.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例9: array

 * The file [code]parameters/feeds.flash.include.php.bak[/code] can be used to restore
 * the active configuration before the last change, if necessary.
 *
 * If the file [code]parameters/demo.flag[/code] exists, the script assumes that this instance
 * of YACS runs in demonstration mode.
 * In this mode the edit form is displayed, but parameters are not saved in the configuration file.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../../shared/global.php';
// load localized strings
i18n::bind('feeds');
// load the skin
load_skin('feeds');
// the path to this page
$context['path_bar'] = array('control/' => i18n::s('Control Panel'));
// the title of the page
$context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Configure'), i18n::s('Flash'));
// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('feeds/flash/configure.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the input form
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    // load current parameters, if any
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:configure.php

示例10: stat_threads

     *
     * @return the resulting ($count, $min_date, $max_date) array
     *
     * @see comments/index.php
     */
    public static function stat_threads()
    {
        global $context;
        // a dynamic where clause
        $where = '';
        // if not associate, restrict to comments at public published not expired pages
        if (!Surfer::is_associate()) {
            $where = "(articles.active='Y')" . " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND ((articles.expiry_date is NULL)" . "\tOR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'))";
        }
        // avoid blank records on join
        if ($where) {
            $where .= ' AND ';
        }
        $where .= '(articles.id > 0)';
        // the list of comments
        $query = "SELECT DISTINCT articles.id as id FROM " . SQL::table_name('comments') . " AS comments" . ", " . SQL::table_name('articles') . " AS articles" . " WHERE (comments.anchor_type LIKE 'article') AND (comments.anchor_id = articles.id)" . "\tAND " . $where;
        // select among available items
        $result = SQL::query($query);
        $output = SQL::count($result);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('comments');
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:comments.php

示例11:

                        }
                        // create the record in the database
                        if (!($fields['id'] = Files::post($fields))) {
                            return FALSE;
                        }
                        // record surfer activity
                        Activities::post('file:' . $fields['id'], 'upload');
                    }
                }
                // so far so good
                if (count($context['uploaded_files']) == 1) {
                    return $context['uploaded_files'][0];
                } else {
                    return $context['uploaded_files'];
                }
            }
        }
        // some error has occured
        return FALSE;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('files');
}
// the maximum size for uploads
global $context;
$context['file_maximum_size'] = str_replace('M', ' M', Safe::get_cfg_var('upload_max_filesize'));
if (!$context['file_maximum_size']) {
    $context['file_maximum_size'] = '2 M';
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:files.php

示例12: bind

 /**
  * create a new overlay from scratch
  *
  * This function creates an instance of the Overlay class based on the given type.
  * For the type '[code]foo[/code]', the script file '[code]overlays/foo.php[/code]' is loaded.
  *
  * Example:
  * [php]
  * // create a new overlay
  * $overlay = Overlay::bind('recipe');
  * [/php]
  *
  * The provided string may include parameters after the type.
  * These parameters, if any, are saved along overlay attributes.
  *
  * Example:
  * [php]
  * // this overlay will preserve past events
  * $overlay = Overlay::bind('day without_past_dates');
  * [/php]
  *
  * This function calls the member function initialize() to allow for additional
  * generic initialization steps, if required. Example: loading of an external configuration
  * file.
  *
  * @see articles/edit.php
  * @see overlays/day.php
  * @see sections/edit.php
  *
  * @param string overlay type
  * @return a brand new instance
  */
 public static final function bind($type)
 {
     global $context;
     // sanity check
     if (!$type || !trim($type)) {
         return NULL;
     }
     // stop hackers, if any
     $type = preg_replace(FORBIDDEN_IN_PATHS, '', strip_tags($type));
     // remove side spaces
     $type = trim($type);
     // localize overlays strings --not related to Overlay::bind() at all...
     i18n::bind('overlays');
     // extract parameters, if any
     $parameters = '';
     if (strlen($type) > 1 && ($separator = strpos($type, ' ', 1)) !== FALSE) {
         $parameters = substr($type, $separator + 1);
         $type = substr($type, 0, $separator);
     }
     // reject hooks
     if (preg_match('/hook$/i', $type)) {
         return NULL;
     }
     // load the overlay class file
     $file = $context['path_to_root'] . 'overlays/' . $type . '.php';
     if (is_readable($file)) {
         include_once $file;
     }
     // create the instance
     if (class_exists($type)) {
         $overlay = new $type();
         $overlay->attributes = array();
         $overlay->attributes['overlay_type'] = $type;
         $overlay->attributes['overlay_parameters'] = $parameters;
         // allow for internal initialization of the overlay
         $overlay->initialize();
         return $overlay;
     }
     // houston, we've got a problem -- Logger::error() is buggy here
     if ($context['with_debug'] == 'Y') {
         Logger::remember('overlays/overlay.php: overlay::bind() unknown overlay type', $type, 'debug');
     }
     return NULL;
 }
开发者ID:rair,项目名称:yacs,代码行数:76,代码来源:overlay.php

示例13: elseif

            } elseif (preg_match('/^\\s*left=(.*)$/is', $cell, $matches)) {
                $text .= $cell_opened . ' style="text-align: left;">' . $matches[1] . $cell_suffix;
            } else {
                $text .= $cell_prefix . $cell . $cell_suffix;
            }
        }
        // return a complete row
        $text = $row_prefix . $text . $row_suffix;
        return $text;
    }
    /**
     * close a table
     *
     * @return the HTML to display
     */
    public static function &table_suffix()
    {
        // close tbody
        global $current_table_has_body;
        if ($current_table_has_body) {
            $text = '</tbody></table>' . "\n";
        } else {
            $text = '</table>' . "\n";
        }
        return $text;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('skins');
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:skin_skeleton.php

示例14: stat_past_for_anchor

     *
     * @param the selected anchor (e.g., 'article:12')
     * @return the resulting ($count, $min_date, $max_date) array
     */
    public static function stat_past_for_anchor($anchor)
    {
        global $context;
        // restrict the query to addressable content
        $where = Articles::get_sql_where();
        // put only published pages in boxes
        if (isset($variant) && $variant == 'boxes') {
            $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
            // provide published pages to anonymous surfers
        } elseif (!Surfer::is_logged()) {
            $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
            // logged surfers that are non-associates are restricted to their own articles, plus published articles
        } elseif (!Surfer::is_empowered()) {
            $where .= " AND ((articles.create_id=" . Surfer::get_id() . ") OR (NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')))";
        }
        // now
        $match = gmstrftime('%Y-%m-%d %H:%M:%S');
        // select among available items
        $query = "SELECT COUNT(*) as count, MIN(articles.edit_date) as oldest_date, MAX(articles.edit_date) as newest_date " . " FROM " . SQL::table_name('dates') . " as dates " . ", " . SQL::table_name('articles') . " AS articles" . " WHERE ((dates.anchor_type LIKE 'article') AND (dates.anchor_id = articles.id))" . "\tAND (dates.date_stamp < '" . SQL::escape($match) . "') AND\t(articles.anchor = '" . SQL::escape($anchor) . "') AND " . $where;
        $output = SQL::query_first($query);
        return $output;
    }
}
// load localized strings
if (is_callable(array('i18n', 'bind'))) {
    i18n::bind('dates');
}
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:dates.php

示例15: array

 * To add a new smiley on this system, you will have:
 * - to prepare a new icon file
 * - to name it
 * - to update smileys.php to bind the name to the file
 * - to update the page below to show it working
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'smileys.php';
// load localized strings
i18n::bind('smileys');
// load the skin
load_skin('smileys');
// the path to this page
$context['path_bar'] = array('help/' => i18n::s('Help index'));
// the title of the page
$context['page_title'] = i18n::s('Smileys');
// the date of last modification
if (Surfer::is_associate()) {
    $context['page_details'] .= '<p class="details">' . sprintf(i18n::s('Edited %s'), Skin::build_date(getlastmod())) . '</p>';
}
// the splash message
$context['text'] .= '<p>' . i18n::s('Smileys are small graphical images that can be used to convey an emotion or feeling. If you have used email or Internet chat, you are likely familiar with the smilie concept.') . '</p>' . '<p>' . i18n::s('Let face it, sometimes words alone do not suffice. Adding a winking smilie, for instance, may help you clarify that you are joking.') . '</p>' . '<p>' . i18n::s('Use your smilies sparingly, though -- if overused, smilies can be downright annoying.') . '</p>' . '<p>' . i18n::s('Here is the list of codes that are automatically converted into images by this server.') . '</p>';
// use a table for the layout
$context['text'] .= Skin::table_prefix('grid');
$cells = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:index.php


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