本文整理汇总了PHP中is_foreachable函数的典型用法代码示例。如果您正苦于以下问题:PHP is_foreachable函数的具体用法?PHP is_foreachable怎么用?PHP is_foreachable使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_foreachable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders the chart
* @param IUser $logged_user
* @return string
*/
function render(IUser $logged_user)
{
$db_result = DB::execute("SELECT milestone_id, COUNT(*) as count FROM " . TABLE_PREFIX . "project_objects WHERE project_id = ? AND type='Task' AND state >= ? AND visibility >= ? GROUP BY milestone_id", $this->project->getId(), STATE_VISIBLE, $logged_user->getMinVisibility());
$array_result = $db_result instanceof DBResult ? $db_result->toArrayIndexedBy('milestone_id') : false;
if (is_foreachable($array_result)) {
$pie_chart = new PieChart('400px', '400px', 'milestone_eta_report_pie_chart_placeholder');
$this->serie_array = array();
$this->milestones = array();
// Set data for the rest
foreach ($array_result as $serie_data) {
$point = new ChartPoint('1', $serie_data['count']);
$serie = new ChartSerie($point);
if (intval($serie_data['milestone_id'])) {
$milestone = new RemediaMilestone(intval($serie_data['milestone_id']));
$label = PieChart::makeShortForPieChart($milestone->getName());
$this->milestones[] = $milestone;
} else {
$label = lang('No Milestone');
}
//if
$serie->setOption('label', $label);
$this->serie_array[] = $serie;
}
//foreach
$pie_chart->addSeries($this->serie_array);
return $pie_chart->render();
} else {
return '<p class="empty_slate">' . lang('There are no milestones in this project.') . '</p>';
}
//if
}
示例2: source_handle_on_frequently
/**
* Daily update of repositories
*
* @param null
* @return void
*/
function source_handle_on_frequently()
{
require_once ANGIE_PATH . '/classes/xml/xml2array.php';
$results = 'Repositories updated: ';
$repositories = Repositories::findByUpdateType(REPOSITORY_UPDATE_FREQUENTLY);
foreach ($repositories as $repository) {
// don't update projects other than active ones
$project = Projects::findById($repository->getProjectId());
if ($project->getStatus() !== PROJECT_STATUS_ACTIVE) {
continue;
}
// if
$repository->loadEngine();
$repository_engine = new RepositoryEngine($repository, true);
$last_commit = $repository->getLastCommit();
$revision_to = is_null($last_commit) ? 1 : $last_commit->getRevision() + 1;
$logs = $repository_engine->getLogs($revision_to);
if (!$repository_engine->has_errors) {
$repository->update($logs['data']);
$total_commits = $logs['total'];
$results .= $repository->getName() . ' (' . $total_commits . ' new commits); ';
if ($total_commits > 0) {
$repository->sendToSubscribers($total_commits, $repository_engine);
$repository->createActivityLog($total_commits);
}
// if
}
// if
}
// foreach
return is_foreachable($repositories) && count($repositories) > 0 ? $results : 'No repositories for frequently update';
}
示例3: smarty_function_object_comments_all
/**
* List object comments
*
* Parameters:
*
* - object - Parent object. It needs to be an instance of ProjectObject class
* - comments - List of comments. It is optional. If it is missing comments
* will be loaded by calling getCommetns() method of parent object
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_object_comments_all($params, &$smarty)
{
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
}
// if
$logged_user = $smarty->get_template_vars('logged_user');
if (!instance_of($logged_user, 'User')) {
return '';
}
// if
$visiblity = $logged_user->getVisibility();
// if ($object->canView($logged_user) && $object->getVisibility() == VISIBILITY_PRIVATE) {
if ($object->canView($logged_user)) {
$visiblity = VISIBILITY_PRIVATE;
}
$comments = $object->getComments($visiblity);
if (is_foreachable($comments)) {
foreach ($comments as $comment) {
ProjectObjectViews::log($comment, $logged_user);
//BOF:task_1260
$comment->set_action_request_n_fyi_flag($logged_user);
//EOF:task_1260
}
// foreach
}
// if
$count_from = 0;
$smarty->assign(array('_object_comments_object' => $object, '_object_comments_count_from' => $count_from, '_object_comments_comments' => $comments, '_total_comments' => sizeof($comments)));
return $smarty->fetch(get_template_path('_object_comments_all', 'comments', RESOURCES_MODULE));
}
示例4: 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);
}
示例5: index
/**
* Settings form
*
* @param void
* @return null
*/
function index()
{
js_assign('test_svn_url', assemble_url('admin_source_test_svn'));
$source_data = $this->request->post('source');
if (!is_foreachable($source_data)) {
$source_data = array('svn_path' => ConfigOptions::getValue('source_svn_path'), 'svn_config_dir' => ConfigOptions::getValue('source_svn_config_dir'), 'source_svn_use_output_redirect' => ConfigOptions::getValue('source_svn_use_output_redirect'), 'source_svn_trust_server_cert' => ConfigOptions::getValue('source_svn_trust_server_cert'));
}
// if
if ($this->request->isSubmitted()) {
$svn_path = array_var($source_data, 'svn_path', null);
$svn_path = $svn_path ? with_slash($svn_path) : null;
ConfigOptions::setValue('source_svn_path', $svn_path);
$svn_config_dir = array_var($source_data, 'svn_config_dir') == '' ? null : array_var($source_data, 'svn_config_dir');
ConfigOptions::setValue('source_svn_config_dir', $svn_config_dir);
$svn_use_output_redirection = array_var($source_data, 'source_svn_use_output_redirect') == "1";
ConfigOptions::setValue('source_svn_use_output_redirect', $svn_use_output_redirection);
$svn_trust_server_certificate = array_var($source_data, 'source_svn_trust_server_cert') == "1";
ConfigOptions::setValue('source_svn_trust_server_cert', $svn_trust_server_certificate);
flash_success("Source settings successfully saved");
$this->redirectTo('admin_source');
}
// if
if (!RepositoryEngine::executableExists()) {
$this->wireframe->addPageMessage(lang("SVN executable not found. You won't be able to use this module"), 'error');
}
// if
$this->smarty->assign(array('source_data' => $source_data));
}
示例6: findByTicket
/**
* Return array of ticket changes
*
* @param Ticket $ticket
* @param integer $count
* @return array
*/
function findByTicket($ticket, $count = null)
{
$count = (int) $count;
if ($count < 1) {
$rows = db_execute_all('SELECT * FROM ' . TABLE_PREFIX . 'ticket_changes WHERE ticket_id = ? ORDER BY version DESC', $ticket->getId());
} else {
$rows = db_execute_all('SELECT * FROM ' . TABLE_PREFIX . "ticket_changes WHERE ticket_id = ? ORDER BY version DESC LIMIT 0, {$count}", $ticket->getId());
}
// if
if (is_foreachable($rows)) {
$changes = array();
foreach ($rows as $row) {
$change = new TicketChange();
$change->setTicketId($ticket->getId());
$change->setVersion($row['version']);
$change->changes = unserialize($row['changes']);
$change->created_on = $row['created_on'] ? new DateTimeValue($row['created_on']) : null;
$change->created_by_id = (int) $row['created_by_id'];
$change->created_by_name = $row['created_by_name'];
$change->created_by_email = $row['created_by_email'];
$changes[$row['version']] = $change;
}
// foreach
return $changes;
} else {
return null;
}
// if
}
示例7: smarty_function_join
/**
* Join items
*
* array('Peter', 'Joe', 'Adam') will be join like:
*
* 'Peter, Joe and Adam
*
* where separators can be defined as paremeters.
*
* Parements:
*
* - items - array of items that need to be join
* - separator - used to separate all elements except the last one. ', ' by
* default
* - final_separator - used to separate last element from the rest of the
* string. ' and ' by default
*
* @param array $params
* @return string
*/
function smarty_function_join($params, &$smarty)
{
$items = array_var($params, 'items');
$separator = array_var($params, 'separator', ', ');
$final_separator = array_var($params, 'final_separator', lang(' and '));
if (is_foreachable($items)) {
$result = '';
$items_count = count($items);
$counter = 0;
foreach ($items as $item) {
$counter++;
if ($counter < $items_count - 1) {
$result .= $item . $separator;
} elseif ($counter == $items_count - 1) {
$result .= $item . $final_separator;
} else {
$result .= $item;
}
// if
}
// if
return $result;
} else {
return $items;
}
// if
}
示例8: getValues
/**
* Return associative array with config option values by name and given
* company
*
* @param Company $company
* @return array
*/
function getValues($names, $company)
{
$result = array();
// lets get option definition instances
$options = ConfigOptions::findByNames($names, COMPANY_CONFIG_OPTION);
if (is_foreachable($options)) {
// Now we need all company specific values we can get
$values = db_execute_all('SELECT name, value FROM ' . TABLE_PREFIX . 'company_config_options WHERE name IN (?) AND company_id = ?', $names, $company->getId());
$foreachable = is_foreachable($values);
// Populate result
foreach ($options as $name => $option) {
if ($foreachable) {
foreach ($values as $record) {
if ($record['name'] == $name) {
$result[$name] = trim($record['value']) != '' ? unserialize($record['value']) : null;
break;
}
// if
}
// foreach
}
// if
if (!isset($result[$name])) {
$result[$name] = $option->getValue();
}
// if
}
// foreach
}
// if
return $result;
}
示例9: 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);
}
示例10: 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);
}
示例11: system_handle_on_project_overview_sidebars
/**
* Add sidebars to project overview page
*
* @param array $sidebars
* @param Project $project
* @param User $user
* @return null
*/
function system_handle_on_project_overview_sidebars(&$sidebars, &$project, &$user)
{
// only project leader, system administrators and project manages can see last activity
$can_see_last_activity = $user->isProjectLeader($project) || $user->isAdministrator() || $user->isProjectManager();
$project_users = $project->getUsers();
if (is_foreachable($project_users)) {
$smarty =& Smarty::instance();
require_once SYSTEM_MODULE_PATH . '/helpers/function.user_link.php';
require_once SMARTY_PATH . '/plugins/modifier.ago.php';
$output = '';
$sorted_users = Users::groupByCompany($project_users);
foreach ($sorted_users as $sorted_user) {
$company = $sorted_user['company'];
$users = $sorted_user['users'];
if (is_foreachable($users)) {
$output .= '<h3><a href="' . $company->getViewUrl() . '">' . clean($company->getName()) . '</a></h3>';
$output .= '<ul class="company_users">';
foreach ($users as $current_user) {
$last_seen = '';
if ($can_see_last_activity && $user->getId() != $current_user->getId()) {
$last_seen = smarty_modifier_ago($current_user->getLastActivityOn());
}
// if
$output .= '<li><span class="icon_holder"><img src="' . $current_user->getAvatarUrl() . '" /></span> ' . smarty_function_user_link(array('user' => $current_user), $smarty) . ' ' . $last_seen . '</li>';
}
// foreach
$output .= '</ul>';
}
// if
}
// foreach
$sidebars[] = array('label' => lang('People on This Project'), 'is_important' => false, 'id' => 'project_people', 'body' => $output);
}
// if
}
示例12: resources_handle_on_project_user_removed
/**
* Handle on_project_user_removed event
*
* @param Project $project
* @param User $user
* @return null
*/
function resources_handle_on_project_user_removed($project, $user)
{
$rows = db_execute('SELECT id FROM ' . TABLE_PREFIX . 'project_objects WHERE project_id = ?', $project->getId());
if (is_foreachable($rows)) {
$object_ids = array();
foreach ($rows as $row) {
$object_ids[] = (int) $row['id'];
}
// foreach
$user_id = $user->getId();
// Assignments cleanup
db_execute('DELETE FROM ' . TABLE_PREFIX . 'assignments WHERE user_id = ? AND object_id IN (?)', $user_id, $object_ids);
cache_remove('object_starred_by_' . $user_id);
cache_remove('object_assignments_*');
cache_remove('object_assignments_*_rendered');
// Starred objects cleanup
db_execute('DELETE FROM ' . TABLE_PREFIX . 'starred_objects WHERE user_id = ? AND object_id IN (?)', $user_id, $object_ids);
cache_remove('object_starred_by_' . $user_id);
// Subscriptions cleanup
db_execute('DELETE FROM ' . TABLE_PREFIX . 'subscriptions WHERE user_id = ? AND parent_id IN (?)', $user_id, $object_ids);
cache_remove('user_subscriptions_' . $user_id);
// remove pinned project
PinnedProjects::unpinProject($project, $user);
}
// if
}
示例13: smarty_function_object_subscriptions
/**
* Render object subscribers
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_object_subscriptions($params, &$smarty)
{
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
}
// if
js_assign('max_subscribers_count', MAX_SUBSCRIBERS_COUNT);
require_once SYSTEM_MODULE_PATH . '/helpers/function.user_link.php';
$subscribers = $object->getSubscribers();
if (count($subscribers) > MAX_SUBSCRIBERS_COUNT) {
$smarty->assign(array('_object_subscriptions_list_subscribers' => false, '_object_subscriptions_object' => $object, '_object_subscriptions_subscribers_count' => count($subscribers), '_object_subscription_brief' => array_var($params, 'brief', false), '_object_subscriptions_popup_url' => assemble_url('object_subscribers_widget', array('object_id' => $object->getId()))));
} else {
$links = null;
if (is_foreachable($subscribers)) {
$links = array();
foreach ($subscribers as $subscriber) {
$links[] = smarty_function_user_link(array('user' => $subscriber), $smarty);
}
// foreach
}
// if
$smarty->assign(array('_object_subscriptions_list_subscribers' => true, '_object_subscriptions' => $subscribers, '_object_subscriptions_object' => $object, '_object_subscription_links' => $links, '_object_subscription_brief' => array_var($params, 'brief', false), '_object_subscriptions_popup_url' => assemble_url('object_subscribers_widget', array('object_id' => $object->getId()))));
}
// if
return $smarty->fetch(get_template_path('_object_subscriptions', 'subscriptions', RESOURCES_MODULE));
}
示例14: smarty_function_mobile_access_paginator
/**
* Render pagination block
*
* Parameters:
*
* - page - current_page
* - total_pages - total pages
* - route - route for URL assembly
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_mobile_access_paginator($params, &$smarty)
{
$url_params = '';
if (is_foreachable($params)) {
foreach ($params as $k => $v) {
if (strpos($k, 'url_param_') !== false && $v) {
$url_params .= '&' . substr($k, 10) . '=' . $v;
}
// if
}
// foreach
}
// if
$paginator = array_var($params, 'paginator', new Pager());
$paginator_url = array_var($params, 'url', ROOT_URL);
$paginator_anchor = array_var($params, 'anchor', '');
$smarty->assign(array("_mobile_access_paginator_url" => $paginator_url, "_mobile_access_paginator" => $paginator, '_mobile_access_paginator_anchor' => $paginator_anchor, "_mobile_access_paginator_url_params" => $url_params));
$paginator_url = strpos($paginator_url, '?') === false ? $paginator_url . '?' : $paginator_url . '&';
if (!$paginator->isFirst()) {
$smarty->assign('_mobile_access_paginator_prev_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() - 1) . $url_params . $paginator_anchor);
}
// if
if (!$paginator->isLast()) {
$smarty->assign('_mobile_access_paginator_next_url', $paginator_url . 'page=' . ($paginator->getCurrentPage() + 1) . $url_params . $paginator_anchor);
}
// if
return $smarty->fetch(get_template_path('_paginator', null, MOBILE_ACCESS_MODULE));
}
示例15: smarty_function_object_tasks
/**
* Render object tasks section
*
* Parameters:
*
* - object - Selected project object
*
* @param array $params
* @param Smarty $smarty
* @return string
*/
function smarty_function_object_tasks($params, &$smarty)
{
$object = array_var($params, 'object');
if (!instance_of($object, 'ProjectObject')) {
return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true);
}
// if
$open_tasks = $object->getOpenTasks();
if (is_foreachable($open_tasks)) {
foreach ($open_tasks as $open_task) {
ProjectObjectViews::log($open_task, $smarty->get_template_vars('logged_user'));
}
// foreach
}
// if
$completed_tasks = $object->getCompletedTasks(COMPLETED_TASKS_PER_OBJECT);
if (is_foreachable($completed_tasks)) {
foreach ($completed_tasks as $completed_task) {
ProjectObjectViews::log($completed_task, $smarty->get_template_vars('logged_user'));
}
// foreach
}
// if
$smarty->assign(array('_object_tasks_object' => $object, '_object_tasks_open' => $open_tasks, '_object_tasks_can_reorder' => (int) $object->canEdit($smarty->get_template_vars('logged_user')), '_object_tasks_completed' => $completed_tasks, '_object_tasks_completed_remaining' => $object->countCompletedTasks() - COMPLETED_TASKS_PER_OBJECT, '_object_tasks_skip_wrapper' => array_var($params, 'skip_wrapper', false), '_object_tasks_skip_head' => array_var($params, 'skip_head', false), '_object_tasks_force_show' => array_var($params, 'force_show', true)));
return $smarty->fetch(get_template_path('_object_tasks', 'tasks', RESOURCES_MODULE));
}