本文整理汇总了PHP中select_box函数的典型用法代码示例。如果您正苦于以下问题:PHP select_box函数的具体用法?PHP select_box怎么用?PHP select_box使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select_box函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_select_incoming_mail_object_type
/**
* Render select Mailbox type control
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_incoming_mail_object_type($params, &$smarty)
{
$mailbox_object_types = array();
if (module_loaded('discussions')) {
$mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_DISCUSSION;
}
// if
if (module_loaded('tickets')) {
$mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_TICKET;
}
// if
if (!array_var($params, 'skip_comment', true)) {
$mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_COMMENT;
}
// if
$value = null;
if (isset($params['value'])) {
$value = $params['value'];
unset($params['value']);
}
// if
$options = array();
foreach ($mailbox_object_types as $mailbox_object_type) {
$option_attributes = $mailbox_object_type == $value ? array('selected' => true) : null;
$options[] = option_tag(Inflector::humanize($mailbox_object_type), $mailbox_object_type, $option_attributes);
}
// foreach
return select_box($options, $params);
}
示例2: render
/**
* Render form control
*
* @param string $control_name
* @return string
*/
function render($control_name) {
$options = array();
$option_attributes = $this->getValue() == 'd/m/Y' ? array('selected' => 'selected') : null;
$options[] = option_tag('dd/mm/yyyy', 'd/m/Y', $option_attributes);
$option_attributes = $this->getValue() == 'm/d/Y' ? array('selected' => 'selected') : null;
$options[] = option_tag('mm/dd/yyyy', 'm/d/Y', $option_attributes);
$option_attributes = $this->getValue() == 'Y/m/d' ? array('selected' => 'selected') : null;
$options[] = option_tag('yyyy/mm/dd', 'Y/m/d', $option_attributes);
$option_attributes = $this->getValue() == 'd-m-Y' ? array('selected' => 'selected') : null;
$options[] = option_tag('dd-mm-yyyy', 'd-m-Y', $option_attributes);
$option_attributes = $this->getValue() == 'm/d/Y' ? array('selected' => 'selected') : null;
$options[] = option_tag('mm-dd-yyyy', 'm-d-Y', $option_attributes);
$option_attributes = $this->getValue() == 'Y-m-d' ? array('selected' => 'selected') : null;
$options[] = option_tag('yyyy-mm-dd', 'Y-m-d', $option_attributes);
$option_attributes = $this->getValue() == 'd.m.Y' ? array('selected' => 'selected') : null;
$options[] = option_tag('dd.mm.yyyy', 'd.m.Y', $option_attributes);
$option_attributes = $this->getValue() == 'm/d/Y' ? array('selected' => 'selected') : null;
$options[] = option_tag('mm.dd.yyyy', 'm.d.Y', $option_attributes);
$option_attributes = $this->getValue() == 'Y.m.d' ? array('selected' => 'selected') : null;
$options[] = option_tag('yyyy.mm.dd', 'Y.m.d', $option_attributes);
return select_box($control_name, $options);
} // render
示例3: smarty_function_incoming_mail_select_user
/**
* Render select user control
*
* Supported paramteres:
*
* - all HTML attributes
* - value - ID of selected user
* - project - Instance of selected project, if NULL all users will be listed
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_incoming_mail_select_user($params, &$smarty)
{
$project = array_var($params, 'project');
if (!instance_of($project, 'Project')) {
return new InvalidParamError('object', $project, '$project is expected to be an instance of Project class', true);
}
// if
$users = Users::findForSelect(null, array_var($params, 'project'));
$value = array_var($params, 'value', null, true);
$options = array(option_tag(lang('Original Author'), 'original_author', $value == 'original_author' ? array('selected' => true) : null));
if (is_foreachable($users)) {
foreach ($users as $company_name => $company_users) {
$company_options = array();
foreach ($company_users as $user) {
$option_attributes = $user['id'] == $value ? array('selected' => true) : null;
$company_options[] = option_tag($user['display_name'], $user['id'], $option_attributes);
}
// foreach
$options[] = option_group_tag($company_name, $company_options);
}
// if
}
// if
return select_box($options, $params);
}
示例4: select_project_folder
/**
* Render select folder box
*
* @param string $name Control name
* @param Project $project
* @param integer $selected ID of selected folder
* @param array $attributes Select box attributes
* @return string
*/
function select_project_folder($name, $project = null, $selected = null, $attributes = null)
{
if (is_null($project)) {
$project = active_project();
}
// if
if (!$project instanceof Project) {
throw new InvalidInstanceError('$project', $project, 'Project');
}
// if
if (is_array($attributes)) {
if (!isset($attributes['class'])) {
$attributes['class'] = 'select_folder';
}
} else {
$attributes = array('class' => 'select_folder');
}
// if
$options = array(option_tag(lang('none'), 0));
$folders = $project->getFolders();
if (is_array($folders)) {
foreach ($folders as $folder) {
$option_attributes = $folder->getId() == $selected ? array('selected' => true) : null;
$options[] = option_tag($folder->getName(), $folder->getId(), $option_attributes);
}
// foreach
}
// if
return select_box($name, $options, $attributes);
}
示例5: smarty_function_select_team
/**
* Render select team control
*
* Params:
*
* - project - Project instance that need to be used
* - active_only - Return only active milestones, true by default
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_team($params, &$smarty)
{
$project = array_var($params, 'project');
if (!instance_of($project, 'Project')) {
return new InvalidParamError('project', $project, '$project value is expected to be an instance of Project class', true);
}
// if
unset($params['project']);
$value = null;
if (isset($params['value'])) {
$value = $params['value'];
unset($params['value']);
}
// if
$options = array();
$logged_user = $smarty->get_template_vars('logged_user');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$query = "select a.id, a.name from healingcrystals_projects a inner join healingcrystals_project_users b on (a.id=b.project_id and b.user_id='" . $logged_user->getId() . "') where a.status='active' and a.completed_on is null and b.role_id<>'9' order by a.name";
$result = mysql_query($query, $link);
while ($info = mysql_fetch_assoc($result)) {
if ($info['id'] == $project->getId()) {
$option_attributes = array('selected' => true);
$options[] = option_tag(lang($info['name']), $info['id'], $option_attributes);
} else {
$options[] = option_tag(lang($info['name']), $info['id']);
}
}
mysql_close($link);
return select_box($options, $params);
}
示例6: navbar
function navbar($sid, $title, $thold, $mode, $order)
{
global $MAIN_CFG, $prefix, $db, $mainindex, $cpgtpl, $textcolor1, $textcolor2, $bgcolor1, $bgcolor2;
list($count) = $db->sql_ufetchrow("SELECT COUNT(*) FROM " . $prefix . "_comments WHERE sid='{$sid}'", SQL_NUM);
$thold = intval($thold);
$cpgtpl->assign_vars(array('F_NEWSHIDE' => '', 'S_COUNT' => $count, 'S_COMMENTS' => $count == 1 ? _COMMENT : _COMMENTS, 'S_COMMWARN' => _COMMENTSWARNING, 'S_POSTCOMM' => $MAIN_CFG['global']['anonpost'] || is_user() ? _REPLYMAIN : '', 'S_SELTHOLD' => select_option('thold', $thold, array('-1', '0', '1', '2', '3', '4', '5')), 'S_SELMODE' => select_box('mode', $mode, array('nested' => _NESTED, 'flat' => _FLAT, 'thread' => _THREAD)), 'S_SELORDER' => select_box('order', $order, array('0' => _OLDEST, '1' => _NEWEST, '2' => _HIGHEST)), 'S_THRESHOLD' => _THRESHOLD, 'S_TITLE' => $title, 'S_USER' => is_user() ? _CONFIGURE : _LOGINCREATE, 'S_REFRESH' => _REFRESH, 'S_TEXTCOLOR1' => $textcolor1, 'S_TEXTCOLOR2' => $textcolor2, 'S_BGCOLOR1' => $bgcolor1, 'S_BGCOLOR2' => $bgcolor2, 'U_ARTICLE' => URL::index('&file=article&sid=' . $sid), 'U_TOPREPLY' => URL::index('&reply=0&sid=' . $sid), 'U_USER' => is_user() ? URL::index('Your_Account&op=editcomm') : URL::index('Your_Account')));
}
示例7: smarty_function_select_project_object
/**
* Render select parent object for provided project
*
* Supported paramteres:
*
* - types - type of of parent objects to be listed
* - project - Instance of selected project (required)
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_project_object($params, &$smarty)
{
$project = array_var($params, 'project');
if (!instance_of($project, 'Project')) {
return new InvalidParamError('project', $project, '$project is expected to be an instance of Project class', true);
}
// if
$value = array_var($params, 'value');
unset($params['project']);
$types = array_var($params, 'types', null);
if (!$types || !is_foreachable($types = explode(',', $types))) {
$types = array('ticket', 'file', 'discussion', 'page');
}
// if
$id_name_map = ProjectObjects::getIdNameMapForProject($project, $types);
if (!is_foreachable($id_name_map)) {
return false;
}
// if
$sorted = array();
foreach ($id_name_map as $object) {
$option_attributes = $value == $object['id'] ? array('selected' => true) : null;
$sorted[strtolower($object['type'])][] = option_tag($object['name'], $object['id'], $option_attributes);
}
// foreach
if (is_foreachable($sorted)) {
foreach ($sorted as $sorted_key => $sorted_values) {
$options[] = option_group_tag($sorted_key, $sorted_values);
}
// foreach
}
// if
return select_box($options, $params);
}
示例8: smarty_function_select_page
/**
* Render select page control
*
* Parameters:
*
* - project - Parent project
* - value - ID of selected page
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_page($params, &$smarty)
{
$project = array_var($params, 'project', null, true);
if (!instance_of($project, 'Project')) {
return new InvalidParamError('project', $project, '$project is expected to be an instance of Project class', true);
}
// if
$user = array_var($params, 'user');
if (!instance_of($user, 'User')) {
return new InvalidParamError('user', $user, '$user is exepcted to be an instance of User class', true);
}
// if
$options = array();
$value = array_var($params, 'value', null, true);
$skip = array_var($params, 'skip');
$categories = Categories::findByModuleSection($project, PAGES_MODULE, 'pages');
if (is_foreachable($categories)) {
foreach ($categories as $category) {
$option_attributes = $category->getId() == $value ? array('selected' => true) : null;
$options[] = option_tag($category->getName(), $category->getId(), $option_attributes);
$pages = Pages::findByCategory($category, STATE_VISIBLE, $user->getVisibility());
if (is_foreachable($pages)) {
foreach ($pages as $page) {
smarty_function_select_page_populate_options($page, $value, $user, $skip, $options, '- ');
}
// foreach
}
// if
}
// foreach
}
// if
return select_box($options, $params);
}
示例9: smarty_function_select_default_assignment_filter
/**
* Render select_default_assignment_filter control
*
* Parameters:
*
* - user - User - User using the page
* - value - integer - ID of selected filter
* - optional - boolean - Value is optional?
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_default_assignment_filter($params, &$smarty)
{
$user = array_var($params, 'user', null, true);
$value = array_var($params, 'value', null, true);
$optional = array_var($params, 'optional', true, true);
$default_filter_id = (int) ConfigOptions::getValue('default_assignments_filter');
$default_filter = $default_filter_id ? AssignmentFilters::findById($default_filter_id) : null;
$options = array();
if (instance_of($default_filter, 'AssignmentFilter') && $optional) {
$options[] = option_tag(lang('-- System Default (:filter) --', array('filter' => $default_filter->getName())), '');
}
// if
$grouped_filters = AssignmentFilters::findGrouped($user, true);
if (is_foreachable($grouped_filters)) {
foreach ($grouped_filters as $group_name => $filters) {
$group_options = array();
foreach ($filters as $filter) {
$group_options[] = option_tag($filter->getName(), $filter->getId(), array('selected' => $value == $filter->getId()));
}
// foreach
if (count($options) > 0) {
$options[] = option_tag('', '');
}
// if
$options[] = option_group_tag($group_name, $group_options);
}
// foreach
}
// if
return select_box($options, $params);
}
示例10: wiki_select_page
/**
* Renders select page box
*
* @param string $name Name to use in HTML for the select
* @param Project $project
* @param integer $selected Id of selected element
* @param array $attributes Array of additional attributes
* @return string
*/
function wiki_select_page($name, $project, $selected = null, $attributes = null)
{
if (is_array($attributes)) {
if (!isset($attributes['class'])) {
$attributes['class'] = 'wiki_select_page';
}
} else {
$attributes = array('class' => 'wiki_select_page');
}
// if
$options = array(option_tag(lang('none'), 0));
if (logged_user()->isAdministrator()) {
$pages = Wiki::getAllProjectPages($project);
} else {
$pages = Wiki::getAllProjectPages($project);
}
if (is_array($pages)) {
foreach ($pages as $page) {
$option_attributes = $page->getId() == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($page->getObjectName(), $page->getId(), $option_attributes);
}
// foreach
}
// if
return select_box($name, $options, $attributes);
}
示例11: smarty_function_select_milestone_category
/**
* Select milestone category control
*
* Params:
*
* - Commong SELECT attributes
* - Value - Selected milestone category id
*
* @param array $params
* @return string
*/
function smarty_function_select_milestone_category($params, &$smarty)
{
$project = array_var($params, 'project');
$project_id = 0;
if (instance_of($project, 'Project')) {
$project_id = $project->getId();
}
// if
$categories = array();
$categories[] = array('id' => '0', 'text' => '-- select --');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$sql = "select id as id, category_name as text from healingcrystals_project_milestone_categories where project_id='" . do_json_encode($project_id) . "' order by category_name";
$result = mysql_query($sql, $link);
while ($entry = mysql_fetch_array($result, MYSQL_ASSOC)) {
$categories[] = $entry;
}
mysql_close($link);
$value = 0;
if (isset($params['value'])) {
$value = $params['value'];
unset($params['value']);
}
// if
$options = array();
for ($i = 0; $i < count($categories); $i++) {
$option_attribites = $categories[$i]['id'] == $value ? array('selected' => true) : null;
$options[] = option_tag($categories[$i]['text'], $categories[$i]['id'], $option_attribites);
}
return select_box($options, $params);
}
示例12: select_locale
/**
* Renders locale select box
*
* @param string $name
* @param array $locales
* @param integer $selected id of selected element
* @param array $attributes additional attributes
* @return string
*/
function select_locale($name, $locales = null, $selected = null, $attributes = null)
{
if (is_array($attributes)) {
if (!isset($attributes['class'])) {
$attributes['class'] = 'select_locale';
}
} else {
$attributes = array('class' => 'select_locale');
}
// if
$options = array(option_tag(lang('none'), 0));
if (is_null($locales)) {
$locales = array();
}
if (is_array($locales)) {
foreach ($locales as $k => $locale) {
if (is_string($locale)) {
$option_attributes = $locale == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($locale, $k, $option_attributes);
} else {
$option_attributes = $locale->getId() == $selected ? array('selected' => 'selected') : null;
$options[] = option_tag($locale->getName(), $locale->getId(), $option_attributes);
}
}
// foreach
}
// if
return select_box($name, $options, $attributes);
}
示例13: smarty_function_select_category
/**
* Render select category control
*
* Supported paramteres:
*
* - all HTML attributes
* - project - Parent project, required
* - module - Module
* - controller - Controller name
* - value - ID of selected category
* - optional - If false there will be no -- none -- option
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_select_category($params, &$smarty)
{
static $ids = array();
$project = array_var($params, 'project', null, true);
if (!instance_of($project, 'Project')) {
return new InvalidParamError('project', $project, 'Project parameter is required for select category helper and it needs to be an instance of Project class', true);
}
// if
$user = array_var($params, 'user', null, true);
$module = trim(array_var($params, 'module', null, true));
if ($module == '') {
return new InvalidParamError('module', $module, 'Module parameter is required for select category helper', true);
}
// if
$controller = trim(array_var($params, 'controller', null, true));
if ($controller == '') {
return new InvalidParamError('controller', $controller, 'Controller parameter is required for select category helper', true);
}
// if
$id = array_var($params, 'id', null, true);
if (empty($id)) {
$counter = 1;
do {
$id = "select_category_{$counter}";
$counter++;
} while (in_array($id, $ids));
}
// if
$params['id'] = $id;
$value = array_var($params, 'value', null, true);
$optional = array_var($params, 'optional', true, true);
$options = array();
if ($optional) {
$options[] = option_tag(lang('-- None --'), '');
}
// if
$categories = Categories::findByModuleSection($project, $module, $controller);
if (is_foreachable($categories)) {
foreach ($categories as $category) {
$option_attributes = array('class' => 'object_option');
if ($category->getId() == $value) {
$option_attributes['selected'] = true;
}
// if
$options[] = option_tag($category->getName(), $category->getId(), $option_attributes);
}
// foreach
}
// if
if (instance_of($user, 'User') && Category::canAdd($user, $project)) {
$params['add_object_url'] = Category::getQuickAddUrl($project, $controller, $module);
$params['object_name'] = 'category';
$params['add_object_message'] = lang('Please insert new category name');
$options[] = option_tag('', '');
$options[] = option_tag(lang('New Category...'), '', array('class' => 'new_object_option'));
}
// if
return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
示例14: smarty_function_select_priority
/**
* Select priority control
*
* Params:
*
* - Commong SELECT attributes
* - Value - Selected priority
*
* @param array $params
* @return string
*/
function smarty_function_select_priority($params, &$smarty)
{
$priorities = array(PRIORITY_URGENT => lang('Urgent'), PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_HOLD => lang('Hold'), '-99' => lang('Unknown'));
if (isset($params['task_id'])) {
$priorities_images = array(PRIORITY_URGENT => 'assets/images/icons/priority/urgent.png', PRIORITY_HIGHEST => 'assets/images/icons/priority/highest.gif', PRIORITY_HIGH => 'assets/images/icons/priority/high.gif', PRIORITY_NORMAL => 'assets/images/icons/priority/normal.gif', PRIORITY_LOW => 'assets/images/icons/priority/low.gif', PRIORITY_LOWEST => 'assets/images/icons/priority/lowest.gif', PRIORITY_HOLD => 'assets/images/icons/priority/hold.png', '-99' => 'assets/images/icons/priority/unknown.png');
/*$priority_not_set = false;
if ($params['value']=='0'){
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME, $link);
$query = "select isnull(priority) as priority_not_set from healingcrystals_project_objects where id='" . (int)$params['task_id'] . "'";
$result = mysql_query($query, $link);
$info = mysql_fetch_assoc($result);
if ($info['priority_not_set']=='1') $priority_not_set = true;
mysql_close($link);
}
if (!$priority_not_set){
$params['sel-image'] = $priorities_images[$params['value']];
$value = 0;
if(isset($params['value'])) {
$value = (integer) $params['value'];
if($value > PRIORITY_URGENT || $value < PRIORITY_HOLD) {
$value = 0;
} // if
} // if
} else {
$value = '-99';
}
unset($params['value']);
return '<span id="' . $params['task_id'] . '" url="' . $params['url'] . '" class="cur_priority" style="cursor:pointer;"><img class="cur_priority" src="' . $priorities_images[$value] . '" /></span>';*/
return '<span id="' . $params['task_id'] . '" url="' . $params['url'] . '" class="cur_priority" style="cursor:pointer;"><img class="cur_priority" src="' . $priorities_images[$params['value']] . '" /></span>';
} else {
$value = 0;
if (isset($params['value'])) {
$value = (int) $params['value'];
//if($value > PRIORITY_HIGHEST || $value < PRIORITY_LOWEST) {
//BOF:mod 20121122
/*
//EOF:mod 20121122
if($value > PRIORITY_HIGHEST || $value < PRIORITY_HOLD) {
//BOF:mod 20121122
*/
if ($value > PRIORITY_URGENT || $value < PRIORITY_HOLD) {
//EOF:mod 20121122
$value = 0;
}
// if
unset($params['value']);
}
// if
$options = array();
foreach ($priorities as $priority => $priority_text) {
$option_attribites = $priority == $value ? array('selected' => true) : null;
$options[] = option_tag($priority_text, $priority, $option_attribites);
}
// if
return select_box($options, $params);
}
}
示例15: smarty_function_select_project
/**
* Render select project helper
*
* Parametars:
*
* - value - Id of selected project
* - user - Limit only to projects that can be viewed by User
* - optional
*
* @param void
* @return null
*/
function smarty_function_select_project($params, &$smarty)
{
$user = array_var($params, 'user', null, true);
if (!instance_of($user, 'User')) {
return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true);
}
// if
$show_all = array_var($params, 'show_all', false) && $user->isProjectManager();
$value = array_var($params, 'value', null, true);
$projects_table = TABLE_PREFIX . 'projects';
$project_users_table = TABLE_PREFIX . 'project_users';
if ($show_all) {
$projects = db_execute_all("SELECT {$projects_table}.id, {$projects_table}.name, {$projects_table}.status FROM {$projects_table} WHERE {$projects_table}.type = ? ORDER BY {$projects_table}.name", PROJECT_TYPE_NORMAL);
} else {
$projects = db_execute_all("SELECT {$projects_table}.id, {$projects_table}.name, {$projects_table}.status FROM {$projects_table}, {$project_users_table} WHERE {$project_users_table}.user_id = ? AND {$project_users_table}.project_id = {$projects_table}.id AND {$projects_table}.type = ? ORDER BY {$projects_table}.name", $user->getId(), PROJECT_TYPE_NORMAL);
}
// if
$exclude = (array) array_var($params, 'exclude', array(), true);
$active_options = array();
$archived_options = array();
if (is_foreachable($projects)) {
foreach ($projects as $k => $project) {
if (in_array($project['id'], $exclude)) {
continue;
}
// if
$option_attributes = $project['id'] == $value ? array('selected' => true) : null;
if ($project['status'] == PROJECT_STATUS_ACTIVE) {
$active_options[] = option_tag($project['name'], $project['id'], $option_attributes);
} else {
$archived_options[] = option_tag($project['name'], $project['id'], $option_attributes);
}
// if
}
// if
}
// if
$optional = array_var($params, 'optional', false, true);
$options = array();
if ($optional) {
$options[] = option_tag(lang(array_var($params, 'optional_caption', '-- Select Project --')), '');
$options[] = option_tag('', '');
}
// if
if (is_foreachable($active_options)) {
$options[] = option_group_tag(lang('Active'), $active_options);
}
// if
if (is_foreachable($active_options) && is_foreachable($archived_options)) {
$options[] = option_tag('', '');
}
// if
if (is_foreachable($archived_options)) {
$options[] = option_group_tag(lang('Archive'), $archived_options);
}
// if
return select_box($options, $params);
}