コード例 #1
0
ファイル: index.php プロジェクト: hostellerie/nexpro
function scan_css_file($scan_id, $css_file, $scan_num)
{
    global $_CONF, $_TABLES, $CONF_NS, $LANG_NS02, $_USER;
    $retval = '';
    //first parse the css file and build array of definitions
    $css_classes = array();
    $css_ids = array();
    $res = DB_query("SELECT * FROM {$_TABLES['nxscan_options']} WHERE scan_id={$scan_id}");
    $options = DB_fetchArray($res);
    $scan_dirs = unserialize($options['directories_to_scan']);
    $file_types = unserialize($options['file_filter']);
    $orphans_only = $options['only_show_unused'];
    $fuzzy_filter = $options['fuzzy_filter'] == 1 ? 1 : 0;
    $fp = fopen($css_file, 'r');
    if ($fp !== NULL) {
        $length = filesize($css_file);
        if ($length > 0) {
            $buffer = fread($fp, $length);
        }
        fclose($fp);
    } else {
        $retval .= COM_startBlock($LANG_NS02['error']);
        $retval .= $LANG_NS02['could_not_open_css_file'];
        $retval .= COM_endBlock();
        return $retval;
    }
    $buffer = prepare_css($buffer);
    $definitions = explode('{}', $buffer);
    foreach ($definitions as $definition) {
        $definition = trim($definition);
        $subdefs = explode(',', $definition);
        foreach ($subdefs as $subdef) {
            $subdef = trim($subdef);
            if (($pos = strpos($subdef, ':')) !== false) {
                $subdef = substr($subdef, 0, $pos);
            }
            if (($pos = strpos($subdef, '[')) !== false) {
                $subdef = substr($subdef, 0, $pos);
            }
            //now find the class or id in the subdef
            if (($pos = strpos($subdef, '.')) !== false) {
                //this is a class definition
                $def = substr($subdef, $pos + 1);
                //+ 1 to lop off the .
                $defarr = explode(' ', $def);
                $def = $defarr[0];
                if ($fuzzy_filter == 0) {
                    $css_classes[$def] = array($def, $definition);
                    //short def, full def
                } else {
                    if (!in_array(array($def, $definition), $css_classes)) {
                        $css_classes[] = array($def, $definition);
                        //short def, full def
                    }
                }
            } else {
                if (($pos = strpos($subdef, '#')) !== false) {
                    //this is a id definition
                    $def = substr($subdef, $pos + 1);
                    //+ 1 to lop off the #
                    $defarr = explode(' ', $def);
                    $def = $defarr[0];
                    if ($fuzzy_filter == 0) {
                        $css_ids[$def] = array($def, $definition);
                        //short def, full def
                    } else {
                        if (!in_array(array($def, $definition), $css_ids)) {
                            $css_ids[] = array($def, $definition);
                            //short def, full def
                        }
                    }
                }
            }
            //else it is a semantic definition, and will always be used.
        }
    }
    if (count($css_classes) + count($css_ids) != 0) {
        foreach ($scan_dirs as $scan_dir) {
            $scan_dir = trim($scan_dir);
            if ($scan_dir != '') {
                $retval .= recursive_css_scandir($scan_dir, $css_classes, $css_ids, $file_types, $scan_id, $css_file);
            }
        }
    }
    //now generate the report
    $p = new Template($_CONF['path'] . 'plugins/nexscan/templates');
    $p->set_file('css_scanner_report_shell', 'css_scanner_report_shell.thtml');
    $p->set_file('css_scanner_report_class', 'css_scanner_report_class.thtml');
    $p->set_file('css_scanner_report_row', 'css_scanner_report_row.thtml');
    NXCOM_set_common_vars($p);
    NXCOM_set_language_vars($p, $LANG_NS02);
    $p->set_var('stylesheet_name', $css_file);
    $p->set_var('scan_num', $scan_num);
    $p->set_var('stylesheet_row', $scan_num % 2 + 1);
    //filter out the duplicate classnames depentant on search type
    $css_classes_filtered = array();
    $css_ids_filtered = array();
    foreach ($css_classes as $entry) {
        $css_classes_filtered[$entry[$fuzzy_filter]] = $entry[$fuzzy_filter];
    }
    foreach ($css_ids as $entry) {
        $css_ids_filtered[$entry[$fuzzy_filter]] = $entry[$fuzzy_filter];
    }
    foreach ($css_classes_filtered as $class) {
        $p->set_var('classname', $class);
        $p->set_var('css_scanner_report_row_output', '');
        $field = $fuzzy_filter == 1 ? 'fullname' : 'classname';
        $res = DB_query("SELECT found_in_file, line_number FROM {$_TABLES['nxscan_cssscan']} WHERE {$field} LIKE '{$class}' AND scan_id={$scan_id} ORDER BY found_in_file ASC, line_number ASC");
        $i = 0;
        while (list($found_in_file, $line_number) = DB_fetchArray($res)) {
            $p->set_var('row', $i % 2 + 1);
            $p->set_var('found_in_file', $found_in_file);
            $p->set_var('line_number', $line_number);
            $p->set_var('filename', urlencode($found_in_file));
            $p->parse('css_scanner_report_row_output', 'css_scanner_report_row', true);
            $i++;
        }
        if ($orphans_only == 1 && $i == 0 || $orphans_only != 1) {
            $p->set_var('total_found', $i);
            $p->set_var('results', $p->get_var('css_scanner_report_row_output'));
            $p->set_var('bgcolor', $i == 0 ? ' background-color: #F3B498;' : ' background-color: #FEF1B4;');
            $p->parse('css_scanner_report_class_output', 'css_scanner_report_class', true);
        }
    }
    $p->set_var('class_reports', $p->get_var('css_scanner_report_class_output'));
    $p->set_var('css_scanner_report_class_output', '');
    foreach ($css_ids_filtered as $class) {
        $p->set_var('classname', $class);
        $p->set_var('css_scanner_report_row_output', '');
        $field = $fuzzy_filter == 1 ? 'fullname' : 'classname';
        $res = DB_query("SELECT found_in_file, line_number FROM {$_TABLES['nxscan_cssscan']} WHERE {$field} LIKE '{$class}' AND scan_id={$scan_id} ORDER BY found_in_file ASC, line_number ASC");
        $i = 0;
        while (list($found_in_file, $line_number) = DB_fetchArray($res)) {
            $p->set_var('row', $i % 2 + 1);
            $p->set_var('found_in_file', $found_in_file);
            $p->set_var('line_number', $line_number);
            $p->set_var('filename', urlencode($found_in_file));
            $p->parse('css_scanner_report_row_output', 'css_scanner_report_row', true);
            $i++;
        }
        if ($orphans_only == 1 && $i == 0 || $orphans_only != 1) {
            $p->set_var('total_found', $i);
            $p->set_var('results', $p->get_var('css_scanner_report_row_output'));
            $p->set_var('bgcolor', $i == 0 ? ' background-color: #F3B498;' : ' background-color: #FEF1B4;');
            $p->parse('css_scanner_report_class_output', 'css_scanner_report_class', true);
        }
    }
    $p->set_var('id_reports', $p->get_var('css_scanner_report_class_output'));
    $p->parse('output', 'css_scanner_report_shell');
    $retval = $p->finish($p->get_var('output'));
    return $retval;
}
コード例 #2
0
 case 'get_panel_form':
     $taskid = intval($_POST['taskid']);
     $sql = "SELECT a.*, b.stepType, b.is_interactiveStepType FROM {$_TABLES['nf_templatedata']} a ";
     $sql .= "LEFT JOIN {$_TABLES['nf_steptype']} b ON a.nf_stepType=b.id ";
     $sql .= "WHERE a.id={$taskid}";
     $res = DB_query($sql);
     $A = DB_fetchArray($res);
     $template = strtolower(str_replace(' ', '_', $A['stepType']));
     $p = new Template($_CONF['path_layout'] . 'nexflow/admin/task_edit_templates');
     $p->set_file('edit_template', $template . '.thtml');
     if ($A['is_interactiveStepType'] == 1) {
         $p->set_file('assignment', 'assignment.thtml');
         $p->set_file('notification', 'notification.thtml');
     }
     //set language vars
     NXCOM_set_language_vars($p, $LANG_NF03);
     NXCOM_set_common_vars($p);
     $p->set_var('message_help', $LANG_NF_MESSAGE['msg1']);
     $p->set_var('LANG_help1', $LANG_NF_MESSAGE['hlp1']);
     $p->set_var('LANG_help2', $LANG_NF_MESSAGE['hlp2']);
     $p->set_var('LANG_help3', $LANG_NF_MESSAGE['hlp3']);
     //generic set_vars
     $p->set_var('taskid', $taskid);
     $p->set_var('edit_task_name', $A['taskname']);
     if ($A['isDynamicTaskName'] == 1) {
         $p->set_var('chk_isDynamicName', ' checked="checked"');
         $p->set_var('show_dynamicnamevars', '');
     } else {
         $p->set_var('chk_isDynamicName', '');
         $p->set_var('show_dynamicnamevars', 'none');
     }
コード例 #3
0
ファイル: edit.php プロジェクト: hostellerie/nexpro
function display_main($workflow_id)
{
    global $_TABLES, $_CONF, $NF_CONF, $LANG_NF02;
    $p = new Template($_CONF['path_layout'] . 'nexflow/admin');
    $p->set_file('workflow_view', 'workflow_view.thtml');
    $p->set_file('tasktemplate', 'task_template.thtml');
    //set language vars
    NXCOM_set_language_vars($p, $LANG_NF02);
    NXCOM_set_common_vars($p);
    $p->set_var('workflow_id', $workflow_id);
    $p->set_var('task_title', '%s');
    $p->set_var('task_id', '%d');
    $p->set_var('css_class', '%c');
    $p->set_var('task_info', '%i');
    $p->set_var('task_type', '%t');
    $p->set_var('task_type_underscored', '%u');
    $p->parse('task_template_output', 'tasktemplate');
    $p->set_var('task_template', $p->get_var('task_template_output'));
    $sql = "SELECT a.id, a.taskname, a.offsetLeft, a.offsetTop, b.stepType, b.is_interactiveStepType, a.assignedByVariable ";
    $sql .= "FROM {$_TABLES['nf_templatedata']} a ";
    $sql .= "LEFT JOIN {$_TABLES['nf_steptype']} b ON a.nf_stepType=b.id ";
    $sql .= "WHERE a.nf_templateID={$workflow_id} ORDER BY logicalID ASC";
    $res = DB_query($sql);
    $i = 0;
    $j = 0;
    $k = 0;
    $x = 50;
    $y = 0;
    $additional_js1 = '';
    $additional_js2 = '';
    while (list($task_id, $task_title, $offsetLeft, $offsetTop, $step_type, $is_interactive, $assignedByVar) = DB_fetchArray($res)) {
        if (strlen($task_title) > 25) {
            $task_title = substr($task_title, 0, 25) . '...';
        }
        $p->set_var('task_title', $task_title);
        $p->set_var('task_id', $task_id);
        $fmtd_steptype = ucwords($step_type);
        $task_info = "{$LANG_NF02['task_type']}: {$fmtd_steptype}";
        $p->set_var('task_type', $fmtd_steptype);
        $p->set_var('task_type_underscored', str_replace(' ', '_', $fmtd_steptype));
        if ($is_interactive == 1) {
            //find out who is assigned:
            $sql2 = "SELECT b.uid FROM {$_TABLES['nf_templateassignment']} a, {$_TABLES['users']} b ";
            $sql2 .= "WHERE a.uid=b.uid AND a.nf_templateDataId={$task_id}";
            $assignedUsers = DB_query($sql2);
            $numusers = DB_numRows($assignedUsers);
            if ($assignedByVar == 0 and $numusers > 0) {
                $names = array();
                for ($userCntr = 0; $userCntr < $numusers; $userCntr++) {
                    $rec = DB_fetchArray($assignedUsers);
                    $names[] = COM_getDisplayName($rec['uid']);
                }
                $task_assigned = $LANG_NF02['assigned_to'] . ': ' . implode(', ', $names);
            } else {
                $variables = array();
                if ($assignedByVar == 1) {
                    $asql = "SELECT variableName FROM {$_TABLES['nf_templateassignment']} a ";
                    $asql .= "INNER JOIN {$_TABLES['nf_templatevariables']} b ON a.nf_processVariable=b.id ";
                    $asql .= "WHERE a.nf_templateDataID={$task_id} ";
                    $aquery = DB_query($asql);
                    while (list($assignmentVariableName) = DB_fetchArray($aquery)) {
                        $variables[] = $assignmentVariableName;
                    }
                }
                if (count($variables) > 0) {
                    $task_assigned = $LANG_NF02['assigned_to'] . ': ' . implode(', ', $variables);
                } else {
                    $task_assigned = $LANG_NF02['nobody_assigned'];
                }
            }
            $p->set_var('task_assignment', $task_assigned);
            $p->set_var('css_class', 'nf_interactive');
        } else {
            if ($step_type == 'If') {
                $p->set_var('css_class', 'nf_if');
            } else {
                if ($step_type == 'Start') {
                    $p->set_var('css_class', 'nf_start');
                } else {
                    if ($step_type == 'End') {
                        $p->set_var('css_class', 'nf_end');
                    } else {
                        $p->set_var('css_class', 'nf_noninteractive');
                    }
                }
            }
            $p->set_var('task_assignment', '');
        }
        $p->set_var('offsetLeft', $offsetLeft);
        $p->set_var('offsetTop', $offsetTop);
        $additional_js1 .= "existing_tasks[{$i}] = ['task{$task_id}', {$offsetLeft}, {$offsetTop}];\n";
        $res2 = DB_query("SELECT nf_TemplateDataTo, nf_templateDataToFalse FROM {$_TABLES['nf_templatedatanextstep']} WHERE nf_templateDataFrom={$task_id}");
        while (list($to, $toFalse) = DB_fetchArray($res2)) {
            $to = intval($to);
            $toFalse = intval($toFalse);
            if ($to != 0) {
                $additional_js2 .= "line_ids[{$j}] = ['task{$task_id}', 'task{$to}', true];\n";
                $j++;
            }
            if ($toFalse != 0) {
                $additional_js2 .= "line_ids[{$j}] = ['task{$task_id}', 'task{$toFalse}', false];\n";
                $j++;
            }
        }
        $p->parse('existing_tasks_output', 'tasktemplate', true);
        $i++;
    }
    $p->set_var('existing_tasks', $p->get_var('existing_tasks_output'));
    $additional_js3 = '';
    $i = 0;
    $res = DB_query("SELECT id, stepType, is_interactiveStepType FROM {$_TABLES['nf_steptype']} WHERE stepType!='Start' AND stepType!='End'");
    while (list($step_id, $step_type, $interactive) = DB_fetchArray($res)) {
        $step_type = ucwords($step_type);
        $p->set_var('task_type', $step_type);
        $p->set_var('task_type_underscored', str_replace(' ', '_', $step_type));
        $additional_js3 .= "steptypes[{$i}] = [{$step_id}, '{$step_type}', {$interactive}];\n";
        $i++;
    }
    $p->set_var('additional_js', $additional_js1 . "\n" . $additional_js2 . "\n" . $additional_js3);
    $p->parse('output', 'workflow_view');
    return $p->finish($p->get_var('output'));
}