Ejemplo n.º 1
0
/**
 * Function for embedding a date control in html.
 * 
 * @author Peter C. Verhage <*****@*****.**>
 */
function smarty_function_atkdatefield($params, &$smarty)
{
    $name = isset($params['name']) ? $params['name'] : 'date';
    $format = isset($params['format']) ? $params['format'] : atktext("date_format_edit", "atk", "", "", "", true);
    $mandatory = isset($params['mandatory']) && $params['mandatory'] || isset($params['obligatory']) && $params['obligatory'];
    $noweekday = isset($params['noweekday']) && $params['noweekday'];
    $calendar = isset($params['calendar']) && $params['calendar'];
    $time = isset($params['time']) ? $params['time'] : ($mandatory ? mktime() : NULL);
    $min = isset($params['min']) ? $params['min'] : 0;
    $max = isset($params['max']) ? $params['max'] : 0;
    if (is_array($time)) {
        $date = $time;
    } else {
        if ($time == NULL) {
            $date = NULL;
        } else {
            if (is_numeric($time)) {
                $date = getdate($time);
                $date = array('day' => $date['mday'], 'month' => $date['mon'], 'year' => $date['year']);
            } else {
                if (preg_match('/([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})/', $time, $matches)) {
                    $date = array('day' => (int) $matches[1], 'month' => (int) $matches[2], 'year' => $matches[3]);
                } else {
                    $date = getdate(strtotime($time));
                    $date = array('day' => $date['mday'], 'month' => $date['mon'], 'year' => $date['year']);
                }
            }
        }
    }
    useattrib('atkdateattribute');
    $attr = new atkDateAttribute($name, $format, '', $min, $max, ($noweekday ? AF_DATE_EDIT_NO_DAY : 0) | ($mandatory ? AF_OBLIGATORY : 0) | ($calendar ? 0 : AF_DATE_NO_CALENDAR));
    $html = $attr->edit(array($name => $date));
    return $html;
}
Ejemplo n.º 2
0
 function time_format($time, $displayzero = false)
 {
     useattrib("atkdurationattribute");
     if ($time == 0 && !$displayzero) {
         return "&nbsp;";
     }
     if (atkconfig("durationformat", 0) == DURATIONFORMAT_DECIMAL) {
         $decimalvalue = floor(abs($time) / 60) + abs($time) % 60 / 60;
         $result = ($time < 0 ? "-" : "") . sprintf("%02.02f", $decimalvalue);
     } elseif (atkconfig("durationformat", 0) == DURATIONFORMAT_TIME) {
         $result = ($time < 0 ? "-" : "") . floor(abs($time) / 60) . ":" . sprintf("%02d", abs($time) % 60);
     }
     return $result;
 }
Ejemplo n.º 3
0
 * Achievo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */
/* Setup the system */
$config_atkroot = "./";
include_once "atk.inc";
include_once "theme.inc";
include_once moduleDir("graph") . "jpgraph/jpgraph.php";
atksession("img", false);
atksecure();
// Create attribute.
$plottersource = $ATK_VARS["plotter"];
useattrib($plottersource);
list($module, $attribname) = explode(".", $plottersource);
$plotterclass = $attribname . "Plotter";
$res = false;
if (class_exists($plotterclass)) {
    // Since php does not support calling static methods
    // on a 'dynamic' class (where the name is inside a
    // variable), we use a companion plotter class to
    // plot stuff.
    $plotter = new $plotterclass();
    $res = $plotter->plot($ATK_VARS);
} else {
    atkerror("Graph: plotter " . $plotterclass . " not found.");
}
if (!$res) {
    $output =& atkOutput::getInstance();