예제 #1
0
 /**
  * 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();
     }
 }
예제 #2
0
 /**
  * Sets the property-accessor for the properties
  *
  * @param FWS_PropAccessor $accessor the accessor
  */
 public static function set_accessor($accessor)
 {
     if (!$accessor instanceof FWS_PropAccessor) {
         FWS_Helper::def_error('instance', 'accessor', 'FWS_PropAccessor', $accessor);
     }
     self::$accessor = $accessor;
 }
예제 #3
0
 /**
  * Constructor
  *
  * @param PC_Engine_Options $options the options
  */
 public function __construct($options)
 {
     parent::__construct();
     if (!$options instanceof PC_Engine_Options) {
         FWS_Helper::def_error('instance', 'options', 'PC_Engine_Options', $options);
     }
     $this->options = $options;
 }
예제 #4
0
 /**
  * Reports the given error
  * 
  * @param PC_Obj_Location $locsrc an object from which the location will be copied (null = current)
  * @param string $msg the error-message
  * @param int $type the error-type
  */
 public function report($locsrc, $msg, $type)
 {
     if (!$locsrc instanceof PC_Obj_Location) {
         FWS_Helper::def_error('instance', 'locsrc', 'PC_Obj_Location', $locsrc);
     }
     $locsrc = new PC_Obj_Location($locsrc->get_file(), $locsrc->get_line());
     $this->errors[] = new PC_Obj_Error($locsrc, $msg, $type);
 }
 /**
  * Constructor
  * 
  * @param PC_Engine_Env $env the environment
  */
 public function __construct($env)
 {
     parent::__construct();
     if (!$env instanceof PC_Engine_Env) {
         FWS_Helper::def_error('instance', 'env', 'PC_Engine_Env', $env);
     }
     $this->env = $env;
 }
예제 #6
0
 /**
  * Sets the type
  * 
  * @param PC_Obj_MultiType $type the new type
  */
 public function set_type($type)
 {
     if ($type !== null && !$type instanceof PC_Obj_MultiType) {
         FWS_Helper::def_error('instance', 'type', 'PC_Obj_MultiType', $type);
     }
     $this->type = $type;
 }
예제 #7
0
 /**
  * Checks whether it contains the given type
  *
  * @param PC_Obj_Type $type the type
  * @return boolean true if so
  */
 public function contains($type)
 {
     if (!$type instanceof PC_Obj_Type) {
         FWS_Helper::def_error('instance', 'type', 'PC_Obj_Type', $type);
     }
     foreach ($this->types as $t) {
         if ($t->equals($type)) {
             return true;
         }
     }
     return false;
 }
예제 #8
0
 /**
  * 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());
 }
예제 #9
0
 /**
  * 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;
 }
예제 #10
0
 /**
  * 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;
 }
예제 #11
0
 /**
  * Deletes all class-fields from the project with given id
  *
  * @param int $id the project-id
  * @return int the number of affected rows
  */
 public function delete_by_project($id)
 {
     $db = FWS_Props::get()->db();
     if (!PC_Utils::is_valid_project_id($id)) {
         FWS_Helper::def_error('intge0', 'id', $id);
     }
     $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_CLASS_FIELDS . ' WHERE project_id = :id');
     $stmt->bind(':id', $id);
     $db->execute($stmt->get_statement());
     return $db->get_affected_rows();
 }
예제 #12
0
 /**
  * Adds the given method to the class
  *
  * @param PC_Obj_Method $method the method
  */
 public function add_method($method)
 {
     if (!$method instanceof PC_Obj_Method) {
         FWS_Helper::def_error('instance', 'method', 'PC_Obj_Method', $method);
     }
     $this->load_methods();
     $this->methods[strtolower($method->get_name())] = $method;
 }
예제 #13
0
 /**
  * Adds all given errors
  * 
  * @param array $errors
  */
 public function add_errors($errors)
 {
     if (!is_array($errors)) {
         FWS_Helper::def_error('array', 'errors', $errors);
     }
     $this->errors = array_merge($this->errors, $errors);
 }
예제 #14
0
    /**
     * Deletes the projects with given ids
     *
     * @param array $ids the ids
     * @return int the number of affected rows
     */
    public function delete($ids)
    {
        if (!FWS_Array_Utils::is_numeric($ids) || count($ids) == 0) {
            FWS_Helper::def_error('numarray>0', 'ids', $ids);
        }
        $db = FWS_Props::get()->db();
        $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_PROJECT_DEPS . '
			 WHERE project_id IN (:ids) OR dep_id IN (:ids)');
        $stmt->bind(':ids', $ids);
        $db->execute($stmt->get_statement());
        $stmt = $db->get_prepared_statement('DELETE FROM ' . PC_TB_PROJECTS . ' WHERE id IN (:ids)');
        $stmt->bind(':ids', $ids);
        $db->execute($stmt->get_statement());
        return $db->get_affected_rows();
    }
예제 #15
0
 /**
  * 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;
 }
예제 #16
0
 /**
  * Sets the type
  * 
  * @param PC_Obj_MultiType $type the new value
  */
 public function set_type($type)
 {
     if (!$type instanceof PC_Obj_MultiType) {
         FWS_Helper::def_error('instance', 'type', 'PC_Obj_MultiType', $type);
     }
     if ($this->arrayref !== null) {
         assert(!$this->arrayref->type->is_multiple() && !$this->arrayref->type->is_unknown());
         $this->arrayref->type->get_first()->set_array_type($this->arrayoff, $type);
     }
     $this->type = $type;
 }
예제 #17
0
 /**
  * Adds the given type as argument
  *
  * @param PC_Obj_MultiType $type the type
  */
 public function add_argument($type)
 {
     if (!$type instanceof PC_Obj_MultiType) {
         FWS_Helper::def_error('instance', 'type', 'PC_Obj_MultiType', $type);
     }
     $this->arguments[] = clone $type;
 }
예제 #18
0
 /**
  * Puts the parameter to the method
  *
  * @param PC_Obj_Parameter $param the param
  */
 public function put_param($param)
 {
     if (!$param instanceof PC_Obj_Parameter) {
         FWS_Helper::def_error('instance', 'param', 'PC_Obj_Parameter', $param);
     }
     $this->params[$param->get_name()] = $param;
 }
예제 #19
0
 /**
  * Constructor
  * 
  * @param string $str the file or string
  * @param bool $is_file whether $str is a file
  * @param PC_Engine_Env $env the environment
  */
 public function __construct($str, $is_file, $env)
 {
     parent::__construct($str, $is_file);
     if (!$env instanceof PC_Engine_Env) {
         FWS_Helper::def_error('instance', 'env', 'PC_Engine_Env', $env);
     }
     $this->env = $env;
     $this->scope = new PC_Engine_Scope();
     $this->vars = new PC_Engine_VarContainer();
     $this->methods_analyzer = new PC_Analyzer_Methods($env);
     $this->calls_analyzer = new PC_Analyzer_Calls($env);
     $this->classes_analyzer = new PC_Analyzer_Classes($env);
     $this->req_analyzer = new PC_Analyzer_Requirements($env);
     $this->ret_analyzer = new PC_Analyzer_Returns($env);
     $this->throws_analyzer = new PC_Analyzer_Throws($env);
     $this->modifiers_analyzer = new PC_Analyzer_Modifiers($env);
     $this->vars_analyzer = new PC_Analyzer_Vars($env);
 }
예제 #20
0
 /**
  * Builds the delete-items to a text
  * 
  * @param array $ids a numeric array with the ids
  * @param string $sql the sql-statement
  * @param string $field the field which should be used to show the entries to delete to the user
  * @return string the item-string
  */
 public function get_delete_items($ids, $sql, $field)
 {
     $db = FWS_Props::get()->db();
     $locale = FWS_Props::get()->locale();
     if (!is_array($ids) || count($ids) == 0) {
         FWS_Helper::def_error('array>0', 'ids', $ids);
     }
     if (empty($sql)) {
         FWS_Helper::def_error('notempty', 'sql', $sql);
     }
     if (empty($field)) {
         FWS_Helper::def_error('notempty', 'field', $field);
     }
     $text = '';
     $num = count($ids);
     $i = 0;
     foreach ($db->get_rows($sql) as $data) {
         $text .= '"' . $data[$field] . '"';
         if ($i < $num - 2) {
             $text .= ', ';
         } else {
             if ($i == $num - 2) {
                 $text .= ' ' . $locale->lang('and') . ' ';
             }
         }
         $i++;
     }
     return $text;
 }
예제 #21
0
 /**
  * @see PC_Obj_Visible::set_visibility()
  *
  * @param string $visibility
  */
 public function set_visibility($visibility)
 {
     $valid = array(self::V_PUBLIC, self::V_PROTECTED, self::V_PRIVATE);
     if (!in_array($visibility, $valid)) {
         FWS_Helper::def_error('inarray', 'visibility', $valid, $visibility);
     }
     $this->visibility = $visibility;
 }
예제 #22
0
 /**
  * Sets the multi-type-instance for this parameter. Will reset is_mtype_default() to false.
  *
  * @param PC_Obj_MultiType $mtype the new value
  */
 public function set_mtype($mtype)
 {
     if (!$mtype instanceof PC_Obj_MultiType) {
         FWS_Helper::def_error('instance', 'mtype', 'PC_Obj_MultiType', $mtype);
     }
     $this->mtype = $mtype;
     $this->mtype_is_default = false;
 }