/** * Puts all variables to the template inc_pagination.htm so that it can be included. * * @param TDL_URL $url the URL-instance */ public function populate_tpl($url) { $tpl = FWS_Props::get()->tpl(); if (!$url instanceof TDL_URL) { FWS_Helper::def_error('instance', 'url', 'TDL_URL', $url); } if ($this->get_page_count() > 1) { $param = $this->get_page_param(); $page = $this->get_page(); $numbers = $this->get_page_numbers(); $tnumbers = array(); foreach ($numbers as $n) { $number = $n; $link = ''; if (FWS_Helper::is_integer($n)) { $url->set($param, $n); $link = $url->to_url(); } else { $link = ''; } $tnumbers[] = array('number' => $number, 'link' => $link); } $start_item = $this->get_start() + 1; $end_item = $start_item + $this->get_per_page() - 1; $end_item = $end_item > $this->get_num() ? $this->get_num() : $end_item; $tpl->set_template('inc_pagination.htm'); $tpl->add_variable_ref('numbers', $tnumbers); $tpl->add_variables(array('page' => $page, 'total_pages' => $this->get_page_count(), 'start_item' => $start_item, 'end_item' => $end_item, 'total_items' => $this->get_num(), 'prev_url' => $url->set($param, $page - 1)->to_url(), 'next_url' => $url->set($param, $page + 1)->to_url(), 'first_url' => $url->set($param, 1)->to_url(), 'last_url' => $url->set($param, $this->get_page_count())->to_url())); $tpl->restore_template(); } }
/** * Creates a new entry for given field * * @param PC_Obj_Field $field the field to create * @param int $class the class-id * @param int $pid the project-id (default = current) * @return int the used id */ public function create($field, $class, $pid = PC_Project::CURRENT_ID) { $db = FWS_Props::get()->db(); if (!$field instanceof PC_Obj_Field) { FWS_Helper::def_error('instance', 'field', 'PC_Obj_Field', $field); } if (!FWS_Helper::is_integer($class) || $class <= 0) { FWS_Helper::def_error('intgt0', 'class', $class); } $val = serialize($field->get_type()); if (strlen($val) > self::MAX_VALUE_LEN) { $val = serialize(null); } return $db->insert(PC_TB_CLASS_FIELDS, array('project_id' => PC_Utils::get_project_id($pid), 'class' => $class, 'file' => $field->get_file(), 'line' => $field->get_line(), 'name' => $field->get_name(), 'type' => $val, 'visibility' => $field->get_visibility(), 'static' => $field->is_static() ? 1 : 0)); }
public function perform_action() { $input = FWS_Props::get()->input(); $id = $input->get_var('id', 'get', FWS_Input::STRING); if (!FWS_Helper::is_integer($id) || $id <= 0) { return 'The id is invalid'; } PC_DAO::get_calls()->delete_by_project($id); PC_DAO::get_classes()->delete_by_project($id); PC_DAO::get_classfields()->delete_by_project($id); PC_DAO::get_constants()->delete_by_project($id); PC_DAO::get_errors()->delete_by_project($id); PC_DAO::get_functions()->delete_by_project($id); PC_DAO::get_vars()->delete_by_project($id); $this->set_redirect(false); $this->set_success_msg('The project has been cleaned successfully'); $this->set_show_status_page(true); $this->set_action_performed(true); return ''; }
/** * Returns all calls * * @param int $start the start-position (for the LIMIT-statement) * @param int $count the max. number of rows (for the LIMIT-statement) (0 = unlimited) * @param int $pid the project-id (default = current) * @param string $file the file * @param string $class the class-name * @param string $function the function-name * @return array all found calls */ public function get_list($start = 0, $count = 0, $file = '', $class = '', $function = '', $pid = PC_Project::CURRENT_ID) { $db = FWS_Props::get()->db(); if (!FWS_Helper::is_integer($start) || $start < 0) { FWS_Helper::def_error('intge0', 'start', $start); } if (!FWS_Helper::is_integer($count) || $count < 0) { FWS_Helper::def_error('intge0', 'count', $count); } $calls = array(); $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_CALLS . ' WHERE project_id = :pid' . ($file ? ' AND file LIKE :file' : '') . ($class ? ' AND class LIKE :class' : '') . ($function ? ' AND function LIKE :func' : '') . ' ORDER BY id ASC ' . ($count > 0 ? 'LIMIT :start,:count' : '')); $stmt->bind(':pid', PC_Utils::get_project_id($pid)); if ($file) { $stmt->bind(':file', '%' . $file . '%'); } if ($class) { $stmt->bind(':class', '%' . $class . '%'); } if ($function) { $stmt->bind(':func', '%' . $function . '%'); } if ($count > 0) { $stmt->bind(':start', $start); $stmt->bind(':count', $count); } foreach ($db->get_rows($stmt->get_statement()) as $row) { $calls[] = $this->build_call($row); } return $calls; }
/** * Constructor * * @param int $id the project-id * @param string $name the name * @param int $created the timestamp * @param string $type_folders the folders for the type-scanner * @param string $type_exclude the excluded items for the type-scanner * @param string $stmt_folders the folders for the statement-scanner * @param string $stmt_exclude the excluded items for the statement-scanner * @param boolean $report_argret_strictly report errors strictly? */ public function __construct($id, $name, $created, $type_folders, $type_exclude, $stmt_folders, $stmt_exclude, $report_argret_strictly) { parent::__construct(); if (!FWS_Helper::is_integer($id) || $id < 0) { FWS_Helper::def_error('intgt0', 'id', $id); } if (!FWS_Helper::is_integer($created) || $created < 0) { FWS_Helper::def_error('intge0', 'created', $created); } $this->id = $id; $this->name = $name; $this->created = $created; $this->type_folders = $type_folders; $this->type_exclude = $type_exclude; $this->stmt_folders = $stmt_folders; $this->stmt_exclude = $stmt_exclude; $this->report_argret_strictly = $report_argret_strictly; $this->req = array(); $this->set_project_deps(array()); }
/** * This method checks a field for a given type. By default the check will only be performed * if the value is not NULL. You can force the check by setting <var>$is_required</var> to true. * The possible values for $for are: * <ul> * <li>timestamp => uses {@link FWS_Date::is_valid_timestamp()}</li> * <li>empty => has to be empty</li> * <li>notempty => has to be not-empty</li> * <li>id => has to be a positive integer * <li>numeric => uses <var>is_numeric()</var></li> * <li>enum => requires <var>$values</var> and uses <var>in_array()</var></li> * </ul> * Will add a default-error message if invalid * * @param string $field the field-name * @param string $for the type to check for. See the list above! * @param boolean $is_required force the check? * @param array $values possible values for the field. empty if it should not be used * @return boolean true if the value is ok */ protected function check_field_for($field, $for = 'timestamp', $is_required = false, $values = array()) { $errors = 0; $method = 'get_' . $field; $val = $this->{$method}(); if ($val !== null || $is_required) { $error = false; switch ($for) { case 'empty': $error = !empty($val); break; case 'notempty': $error = empty($val); break; case 'timestamp': $error = !FWS_Date::is_valid_timestamp($val); break; case 'id': $error = !FWS_Helper::is_integer($val) || $val <= 0; break; case 'numeric': $error = !is_numeric($val); break; case 'enum': if (!is_array($values) || count($values) == 0) { FWS_Helper::def_error('array>0', 'values', $values); } $error = !in_array($val, $values); break; } if ($error) { if ($is_required && empty($val)) { $this->add_error($this->missing_field_msg($field), $field); } else { $this->add_error($this->invalid_field_msg($field), $field); } $errors++; } } return $errors == 0; }
/** * Creates a new entry for given function * * @param PC_Obj_Method $function the function to create * @param int $class the id of the class the function belongs to * @param int $pid the project-id (-1 = current) * @return int the used id */ public function create($function, $class = 0, $pid = PC_Project::CURRENT_ID) { $db = FWS_Props::get()->db(); if (!$function instanceof PC_Obj_Method) { FWS_Helper::def_error('instance', 'function', 'PC_Obj_Method', $function); } if (!FWS_Helper::is_integer($class) || $class < 0) { FWS_Helper::def_error('intge0', 'class', $class); } return $db->insert(PC_TB_FUNCTIONS, $this->get_fields($function, $class, $pid)); }
/** * Sets the type * * @param int $type the new value */ public function set_type($type) { if (!FWS_Helper::is_integer($type)) { FWS_Helper::def_error('int', 'type', $type); } $this->_type = $type; }
/** * Constructor * * @param PC_Obj_Location $loc the location of the error * @param string $msg the message to display * @param int $type the error-type. See self::E_* */ public function __construct($loc, $msg, $type) { parent::__construct(); if (!$loc instanceof PC_Obj_Location) { FWS_Helper::def_error('instance', 'loc', 'PC_Obj_Location', $loc); } if (!FWS_Helper::is_integer($type) || $type < 0) { FWS_Helper::def_error('intge0', 'type', $type); } $this->loc = $loc; $this->msg = $msg; $this->type = $type; }
/** * Returns all errors. Optionally you can filter the search by file and message * * @param int $pid the project-id (default = current) * @param int $start the start-position (for the LIMIT-statement) * @param int $count the max. number of rows (for the LIMIT-statement) (0 = unlimited) * @param string $file the file * @param string $msg the message * @param array $types an array of types (numeric!) * @return array all found errors */ public function get_list($pid = PC_Project::CURRENT_ID, $start = 0, $count = 0, $file = '', $msg = '', $types = array()) { $db = FWS_Props::get()->db(); if (!FWS_Helper::is_integer($start) || $start < 0) { FWS_Helper::def_error('intge0', 'start', $start); } if (!FWS_Helper::is_integer($count) || $count < 0) { FWS_Helper::def_error('intge0', 'count', $count); } if (!FWS_Array_Utils::is_numeric($types)) { FWS_Helper::def_error('numarray', 'types', $types); } $errs = array(); $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_ERRORS . ' WHERE project_id = :pid' . ($file ? ' AND file LIKE :file' : '') . ($msg ? ' AND message LIKE :msg' : '') . (count($types) ? ' AND type IN (:types)' : '') . ' ORDER BY file ASC, line ASC' . ($count > 0 ? ' LIMIT :start,:count' : '')); $stmt->bind(':pid', PC_Utils::get_project_id($pid)); if ($file) { $stmt->bind(':file', '%' . $file . '%'); } if ($msg) { $stmt->bind(':msg', '%' . $msg . '%'); } if (count($types)) { $stmt->bind(':types', $types); } if ($count > 0) { $stmt->bind(':start', $start); $stmt->bind(':count', $count); } foreach ($db->get_rows($stmt->get_statement()) as $row) { $errs[] = $this->build_error($row); } return $errs; }
/** * Creates a new entry for given function * * @param PC_Obj_Constant $constant the constant to create * @param int $class the class-id (0 = freestanding) * @param int $pid the project-id (-1 = current) * @return int the used id */ public function create($constant, $class = 0, $pid = PC_Project::CURRENT_ID) { $db = FWS_Props::get()->db(); if (!$constant instanceof PC_Obj_Constant) { FWS_Helper::def_error('instance', 'constant', 'PC_Obj_Constant', $constant); } if (!FWS_Helper::is_integer($class) || $class < 0) { FWS_Helper::def_error('intge0', 'class', $class); } $val = serialize($constant->get_type()); if (strlen($val) > self::MAX_VALUE_LEN) { $val = serialize(null); } return $db->insert(PC_TB_CONSTANTS, array('project_id' => PC_Utils::get_project_id($pid), 'class' => $class, 'file' => $constant->get_file(), 'line' => $constant->get_line(), 'name' => $constant->get_name(), 'type' => $val)); }
/** * Returns all classes * * @param int $start the start-position (for the LIMIT-statement) * @param int $count the max. number of rows (for the LIMIT-statement) (0 = unlimited) * @param string $class the class-name * @param string $file the file * @param int $pid the project-id (default = current) * @return array all found classes */ public function get_list($start = 0, $count = 0, $class = '', $file = '', $pid = PC_Project::CURRENT_ID) { $db = FWS_Props::get()->db(); if (!FWS_Helper::is_integer($start) || $start < 0) { FWS_Helper::def_error('intge0', 'start', $start); } if (!FWS_Helper::is_integer($count) || $count < 0) { FWS_Helper::def_error('intge0', 'count', $count); } $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_CLASSES . ' WHERE project_id = :pid' . ($file ? ' AND file LIKE :file' : '') . ($class ? ' AND (name LIKE :class OR superclass LIKE :class OR interfaces LIKE :class)' : '') . ' ORDER BY name ASC ' . ($count > 0 ? 'LIMIT :start,:count' : '')); $stmt->bind(':pid', PC_Utils::get_project_id($pid)); if ($file) { $stmt->bind(':file', '%' . $file . '%'); } if ($class) { $stmt->bind(':class', '%' . $class . '%'); } if ($count > 0) { $stmt->bind(':start', $start); $stmt->bind(':count', $count); } $rows = $db->get_rows($stmt->get_statement()); return $this->build_complete_classes($rows, $pid); }
/** * Returns all vars * * @param int $start the start-position (for the LIMIT-statement) * @param int $count the max. number of rows (for the LIMIT-statement) (0 = unlimited) * @param string $scope the scope * @param string $name the variable-name * @param int $pid the project-id (default = current) * @return array all found vars */ public function get_list($start = 0, $count = 0, $scope = '', $name = '', $pid = PC_Project::CURRENT_ID) { $db = FWS_Props::get()->db(); if (!FWS_Helper::is_integer($start) || $start < 0) { FWS_Helper::def_error('intge0', 'start', $start); } if (!FWS_Helper::is_integer($count) || $count < 0) { FWS_Helper::def_error('intge0', 'count', $count); } $vars = array(); $stmt = $db->get_prepared_statement('SELECT * FROM ' . PC_TB_VARS . ' WHERE project_id = :pid' . ($scope ? ' AND scope LIKE :scope' : '') . ($name ? ' AND name LIKE :name' : '') . ' ORDER BY id ASC ' . ($count > 0 ? 'LIMIT :start,:count' : '')); $stmt->bind(':pid', PC_Utils::get_project_id($pid)); if ($scope) { $stmt->bind(':scope', '%' . $scope . '%'); } if ($name) { $stmt->bind(':name', '%' . $name . '%'); } if ($count > 0) { $stmt->bind(':start', $start); $stmt->bind(':count', $count); } foreach ($db->get_rows($stmt->get_statement()) as $row) { $vars[] = $this->build_var($row); } return $vars; }