本文整理汇总了PHP中app::public_url方法的典型用法代码示例。如果您正苦于以下问题:PHP app::public_url方法的具体用法?PHP app::public_url怎么用?PHP app::public_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app
的用法示例。
在下文中一共展示了app::public_url方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFieldValueByType
public static function renderFieldValueByType($f, $values, $extra_values = array(), $is_export = false)
{
$value = isset($values[$f['id']]) ? $values[$f['id']] : '';
switch ($f['type']) {
case 'file':
$html = '';
if ($a = Doctrine_Core::getTable('Attachments')->find($value)) {
if ($is_export) {
return app::public_url('attachments/download?id=' . $a->getId());
} else {
$html = Attachments::getLink($a);
}
}
return $html;
break;
case 'date_dropdown':
return strlen($value) > 2 ? app::dateFormat($value, 0, $is_export ? false : true) : '';
break;
case 'date':
return app::dateFormat($value, 0, $is_export ? false : true);
break;
case 'date_time':
return app::dateTimeFormat($value, 0, $is_export ? false : true);
break;
case 'date_range':
if (strlen($value) > 1) {
$value = explode('|', $value);
return app::dateFormat($value[0], 0, $is_export ? false : true) . ' - ' . app::dateFormat($value[1], 0, $is_export ? false : true);
} else {
return '';
}
break;
case 'formula':
$formula = $f['default_values'];
foreach ($values as $k => $v) {
$formula = str_replace('[' . $k . ']', (double) $v, $formula);
}
foreach ($extra_values as $k => $v) {
$formula = str_replace('[' . $k . ']', (double) $v, $formula);
}
if (!strstr($formula, '[')) {
if (strstr($formula, '{')) {
$eval_str = 'function getFormulaValue()' . $formula . '; $fv=getFormulaValue();';
} else {
$eval_str = '$fv=' . $formula . ';';
}
@($r = eval($eval_str));
if ($r !== null) {
$fv = $formula;
}
return $fv;
} else {
return '';
}
break;
case 'checkbox':
return str_replace("\n", '<br>', $value);
break;
case 'url':
if (strlen($value) > 0) {
if (!strstr($value, '://')) {
$value = 'http://' . $value;
}
if ($is_export) {
return $value;
} else {
return '<a href="' . $value . '" target="blank">' . t::__('view') . '</a>';
}
} else {
return '';
}
break;
case 'textarea':
return nl2br($value);
break;
default:
return $value;
break;
}
}
示例2: notifyUser
protected function notifyUser($user, $password)
{
if (strlen(sfConfig::get('app_new_user_email_subject')) > 0) {
$subject = sfConfig::get('app_new_user_email_subject');
} else {
$subject = t::__('Your account has been created in') . ' ' . sfConfig::get('app_app_name');
}
$login_details = '<p><b>' . t::__('Login Details') . ':</b></p><p>' . t::__('Email') . ': ' . $user->getEmail() . '<br>' . t::__('Password') . ': ' . $password . '</p><p><a href="' . app::public_url('login/index') . '">' . app::public_url('login/index') . '</a></p>';
if (strlen(sfConfig::get('app_new_user_email_body')) > 0) {
$body = sfConfig::get('app_new_user_email_body');
$body = str_replace('[user_name]', $user->getName(), $body);
if (strstr($body, '[login_details]')) {
$body = str_replace('[login_details]', $login_details, $body);
} else {
$body .= $login_details;
}
} else {
$body = $login_details;
}
$from = array(sfConfig::get('app_administrator_email') => sfConfig::get('app_app_name'));
$to = array($user->getEmail() => $user->getName());
Users::sendEmail($from, $to, $subject, $body, $this->getUser());
}
示例3: executeExport
public function executeExport(sfWebRequest $request)
{
/*check access*/
Users::checkAccess($this, 'view', $this->getModuleName(), $this->getUser());
$this->columns = array('id' => t::__('Id'), 'ProjectsStatus' => t::__('Status'), 'name' => t::__('Name'), 'description' => t::__('Description'), 'team' => t::__('Team'), 'ProjectsTypes' => t::__('Type'), 'Users' => t::__('Created By'), 'created_at' => t::__('Created At'));
$extra_fields = ExtraFieldsList::getFieldsByType('projects', $this->getUser(), false, array('all' => true));
foreach ($extra_fields as $v) {
$this->columns['extra_field_' . $v['id']] = $v['name'];
}
$this->columns['url'] = t::__('Url');
if ($fields = $request->getParameter('fields')) {
$separator = "\t";
$format = $request->getParameter('format', '.csv');
$filename = $request->getParameter('filename', 'projects');
header("Content-type: Application/octet-stream");
header("Content-disposition: attachment; filename=" . $filename . "." . $format);
header("Pragma: no-cache");
header("Expires: 0");
$content = '';
foreach ($fields as $f) {
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $this->columns[$f]) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
if (strlen($request->getParameter('selected_items') == 0)) {
exit;
}
$q = Doctrine_Core::getTable('Projects')->createQuery('p')->leftJoin('p.ProjectsStatus ps')->leftJoin('p.ProjectsTypes pt')->leftJoin('p.Users')->whereIn('p.id', explode(',', $request->getParameter('selected_items')));
if (Users::hasAccess('view_own', 'projects', $this->getUser())) {
$q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',p.team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'");
}
$q = app::addListingOrder($q, 'projects', $this->getUser());
$projects = $q->fetchArray();
$totals = array();
foreach ($projects as $p) {
$ex_values = ExtraFieldsList::getValuesList($extra_fields, $p['id']);
$content = '';
foreach ($fields as $f) {
$v = '';
if (in_array($f, array('id', 'name', 'description'))) {
$v = $p[$f];
} elseif (strstr($f, 'extra_field_')) {
if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) {
$v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true);
if (in_array($ex->getType(), array('number', 'formula'))) {
if (!isset($totals[$ex->getId()])) {
$totals[$ex->getId()] = 0;
}
$totals[$ex->getId()] += $v;
}
$v = str_replace('<br>', ', ', $v);
}
} elseif ($f == 'team') {
$v = Users::getNameById($p[$f], ', ');
} elseif ($f == 'created_at') {
if (strlen($p[$f]) > 0) {
$v = date(app::getDateTimeFormat(), app::getDateTimestamp($p[$f]));
}
} elseif ($f == 'url') {
$v = app::public_url('projectsComments/index?projects_id=' . $p['id']);
} else {
$v = app::getArrayName($p, $f);
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
}
$content = '';
foreach ($fields as $f) {
$v = '';
if (strstr($f, 'extra_field_')) {
if (isset($totals[str_replace('extra_field_', '', $f)])) {
$v = $totals[str_replace('extra_field_', '', $f)];
}
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
exit;
}
}
示例4: executeExport
//.........这里部分代码省略.........
$q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id'));
} else {
$q->orderBy('LTRIM(p.name), ts.sort_order, LTRIM(ts.name), LTRIM(t.name)');
}
$tickets = $q->fetchArray();
$totals = array();
$projects_totals = array();
$current_project_id = 0;
foreach ($tickets as $t) {
$ex_values = ExtraFieldsList::getValuesList($extra_fields, $t['id']);
$content = '';
//
if ($current_project_id == 0) {
$current_project_id = $t['projects_id'];
}
if ($current_project_id != $t['projects_id']) {
//adding totals
if (isset($projects_totals[$current_project_id])) {
foreach ($fields as $f) {
$v = '';
if (strstr($f, 'extra_field_')) {
if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
$v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
}
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n\n";
}
$current_project_id = $t['projects_id'];
}
foreach ($fields as $f) {
$v = '';
if (in_array($f, array('id', 'name', 'description'))) {
$v = $t[$f];
} elseif (strstr($f, 'extra_field_')) {
if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) {
$v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true);
if (in_array($ex->getType(), array('number', 'formula'))) {
if (!isset($totals[$ex->getId()])) {
$totals[$ex->getId()] = 0;
}
if (!isset($projects_totals[$t['projects_id']][$ex->getId()])) {
$projects_totals[$t['projects_id']][$ex->getId()] = 0;
}
$totals[$ex->getId()] += $v;
$projects_totals[$t['projects_id']][$ex->getId()] += $v;
}
$v = str_replace('<br>', ', ', $v);
}
} elseif ($f == 'created_at') {
if (strlen($t[$f]) > 0) {
$v = app::dateTimeFormat($t[$f]);
}
} elseif ($f == 'url') {
$v = app::public_url('ticketsComments/index?projects_id=' . $t['projects_id'] . '&tickets_id=' . $t['id']);
} else {
$v = app::getArrayName($t, $f);
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
}
$content = '';
//adding totals
if (isset($projects_totals[$current_project_id]) and !$request->hasParameter('projects_id')) {
foreach ($fields as $f) {
$v = '';
if (strstr($f, 'extra_field_')) {
if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
$v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
}
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n\n";
}
foreach ($fields as $f) {
$v = '';
if (strstr($f, 'extra_field_')) {
if (isset($totals[str_replace('extra_field_', '', $f)])) {
$v = $totals[str_replace('extra_field_', '', $f)];
}
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
exit;
}
}
示例5: executeExport
//.........这里部分代码省略.........
if ($f == 'name') {
$v = $name_adding . $t[$f];
} elseif (in_array($f, array('id', 'description', 'estimated_time', 'work_hours'))) {
if ($f == 'work_hours') {
$v = TasksComments::getTotalWorkHours($t['id']);
} else {
$v = $t[$f];
}
if (in_array($f, array('estimated_time', 'work_hours'))) {
if (!isset($totals[$f])) {
$totals[$f] = 0;
}
if (!isset($projects_totals[$t['projects_id']][$f])) {
$projects_totals[$t['projects_id']][$f] = 0;
}
$totals[$f] += $v;
$projects_totals[$t['projects_id']][$f] += $v;
}
} elseif (in_array($f, array('start_date', 'due_date', 'created_at'))) {
$v = app::dateTimeFormat($t[$f]);
} elseif ($f == 'progress') {
$v = (int) $t['progress'] . '%';
} elseif (strstr($f, 'extra_field_')) {
if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) {
$v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true);
if (in_array($ex->getType(), array('number', 'formula'))) {
if (!isset($totals[$ex->getId()])) {
$totals[$ex->getId()] = 0;
}
if (!isset($projects_totals[$t['projects_id']][$ex->getId()])) {
$projects_totals[$t['projects_id']][$ex->getId()] = 0;
}
$totals[$ex->getId()] += $v;
$projects_totals[$t['projects_id']][$ex->getId()] += $v;
}
$v = str_replace('<br>', ', ', $v);
}
} elseif ($f == 'assigned_to') {
$v = Users::getNameById($t[$f], ', ');
} elseif ($f == 'url') {
$v = app::public_url('tasksComments/index?projects_id=' . $t['projects_id'] . '&tasks_id=' . $t['id']);
} elseif ($f == 'actual_time') {
if ($t['work_hours'] > 0 and $t['togo_hours'] == 0) {
$v = $t['work_hours'];
} else {
$v = (double) $t['estimated_time'] - (double) $t['work_hours'] + (double) $t['togo_hours'];
}
if (!isset($totals[$f])) {
$totals[$f] = 0;
}
$totals[$f] += $v;
$projects_totals[$t['projects_id']][$f] += $v;
} else {
$v = app::getArrayName($t, $f);
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
}
$content = '';
//adding totals
if (isset($projects_totals[$current_project_id]) and !$request->hasParameter('projects_id')) {
foreach ($fields as $f) {
$v = '';
if (in_array($f, array('estimated_time', 'work_hours'))) {
$v = $projects_totals[$current_project_id][$f];
} elseif (strstr($f, 'extra_field_')) {
if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) {
$v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)];
}
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n\n";
}
foreach ($fields as $f) {
$v = '';
if (in_array($f, array('estimated_time', 'work_hours'))) {
$v = $totals[$f];
} elseif (strstr($f, 'extra_field_')) {
if (isset($totals[str_replace('extra_field_', '', $f)])) {
$v = $totals[str_replace('extra_field_', '', $f)];
}
}
$content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator;
}
$content .= "\n";
if ($format == 'csv') {
echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
} else {
echo $content;
}
exit;
}
}