static function repliesLabel($replies = 0, $activity = null) { static $format = null; if (is_null($format)) { $params = JComponentHelper::getParams('com_projectfork'); $format = $params->get('date_format'); if (!$format) { $format = JText::_('DATE_FORMAT_LC1'); } } $html = array(); $text = JText::plural('COM_PROJECTFORK_N_REPLIES', (int) $replies); if ($replies == 0) { $html[] = '<span class="label">' . $text . '</span>'; } else { $title = ''; $class = ''; $style = ''; if ($activity && $activity != JFactory::getDbo()->getNullDate()) { $title = ' title="' . PFDate::relative($activity) . '::' . JHtml::_('date', $activity, $format) . '"'; $style = ' style="cursor: help"'; $class = ' hasTip'; } $html[] = '<span class="label label-success' . $class . '"' . $title . $style . '>' . $text . '</span>'; } return implode('', $html); }
public static function complete($i, $complete = 0, $can_change = false, $parents = array(), $users = array(), $start = null) { $html = array(); $uid = JFactory::getUser()->get('id'); $nd = JFactory::getDbo()->getNullDate(); $p_tooltip = null; $u_tooltip = null; $s_tooltip = null; if ($can_change) { // Check if the user is assigned to the task if (count($users)) { $can_change = false; foreach ($users as $user) { if ((int) $user->user_id == $uid) { $can_change = true; } } if (!$can_change) { $u_tooltip = JText::_('COM_PROJECTFORK_TASKS_NOT_ASSIGNED'); } } // Check if all dependencies are completed if ($can_change && $complete == 0) { if (count($parents)) { $req = array(); foreach ($parents as $parent) { if ($parent->complete != '1') { $can_change = false; $req[] = htmlspecialchars($parent->title, ENT_COMPAT, 'UTF-8'); } } if (!$can_change) { $p_tooltip = JText::_('COM_PROJECTFORK_TASKS_DEPENDS_ON') . '::' . implode('<br/>', $req); } } } // Check if the task can be started if ($can_change && $complete == 0) { if ($start && $start != $nd) { $now = time(); $ts = strtotime($start); if ($ts > $now) { $can_change = false; $s_tooltip = JText::_('COM_PROJECTFORK_TASKS_NOT_STARTED') . '::' . PFDate::relative($start); } } } } if ($can_change) { $class = $complete ? ' btn-success active' : ''; $title = $complete ? '' : JText::_('COM_PROJECTFORK_FIELD_COMPLETE_LABEL'); $icon = $complete ? 'checkbox-unchecked' : 'checkbox-unchecked'; $html[] = '<div class="btn-group">'; $html[] = '<a id="complete-btn-' . $i . '" class="btn btn-mini' . $class . ' hasTooltip" rel="tooltip" title="' . $title . '" href="javascript:void(0);" onclick="PFtask.complete(' . $i . ');">'; $html[] = '<span aria-hidden="true" class="icon-ok"></span>'; $html[] = '</a>'; $html[] = '</div>'; $html[] = '<input type="hidden" id="complete' . $i . '" value="' . (int) $complete . '"/>'; } else { $class = $complete ? ' label-success' : ''; $icon = $complete ? 'icon-ok' : 'icon-ok'; $title = ''; if ($p_tooltip || $u_tooltip || $s_tooltip) { $class .= ' hasTip'; if ($p_tooltip) { $title = ' title="' . $p_tooltip . '"'; } if ($u_tooltip) { $title = ' title="' . $u_tooltip . '"'; } if ($s_tooltip) { $title = ' title="' . $s_tooltip . '"'; } } $html[] = '<div class="btn-group">'; $html[] = '<a id="complete-btn-' . $i . '" class="btn btn-mini disabled' . $class . '"' . $title . '>'; $html[] = '<span aria-hidden="true" class="' . $icon . '"></span>'; $html[] = '</a>'; $html[] = '</div>'; $html[] = '<input type="hidden" id="complete' . $i . '" value="' . (int) $complete . '"/>'; } return implode('', $html); }
/** * Returns the author of an item as label * * @param string $name The user name * @param string $date The date * @param string $format The new date format for the tooltip * * @return string The label html */ public static function author($name = null, $date = null, $format = null) { if (!$name || !$date) { return ''; } $string = PFDate::relative($date); if ($string == false) { return ''; } $tooltip = $string . '::' . JHtml::_('date', $date, $format ? $format : JText::_('DATE_FORMAT_LC1')); $html = array(); $html[] = '<span class="label hasTip" title="' . $tooltip . '" style="cursor: help">'; $html[] = '<i class="icon-user"></i> '; $html[] = htmlspecialchars($name, ENT_COMPAT, 'UTF-8'); $html[] = '</span>'; return implode('', $html); }