Ejemplo n.º 1
0
 /**
  * @see FWS_Module::init($doc)
  * 
  * @param TDL_Document $doc
  */
 public function init($doc)
 {
     parent::init($doc);
     $input = FWS_Props::get()->input();
     $functions = FWS_Props::get()->functions();
     $renderer = $doc->use_default_renderer();
     $locale = FWS_Props::get()->locale();
     $cfg = FWS_Props::get()->cfg();
     $renderer->add_action(TDL_ACTION_EDIT_ENTRY, 'edit');
     $renderer->add_action(TDL_ACTION_NEW_ENTRY, 'add');
     $mode = $input->correct_var(TDL_URL_MODE, 'get', FWS_Input::STRING, array('add', 'edit'), 'add');
     if ($mode == 'edit') {
         $id = $input->get_predef(TDL_URL_IDS, 'get');
         $murl = TDL_URL::get_entry_url();
         $murl->set(TDL_URL_ACTION, 'edit_entry');
         $murl->set(TDL_URL_MODE, 'edit');
         $murl->set(TDL_URL_IDS, $id);
         if (FWS_String::substr_count($id, ',') > 1) {
             $title = $locale->_('Edit entries');
         } else {
             $title = $locale->_('Edit entry');
         }
     } else {
         $murl = TDL_URL::get_mod_url();
         $murl->set(TDL_URL_MODE, 'add');
         $title = $locale->_('New entry');
     }
     $renderer->set_has_access($mode == 'edit' || $cfg['project_id'] != 0);
     $renderer->add_breadcrumb($title, $murl->to_url());
 }
 /**
  * @see FWS_Module::init($doc)
  *
  * @param FWS_Document $doc
  */
 public function init($doc)
 {
     parent::init($doc);
     $renderer = $doc->use_default_renderer();
     $classname = get_class($this->sub);
     $lastus = strrpos($classname, '_');
     $prevlastus = strrpos(FWS_String::substr($classname, 0, $lastus), '_');
     $renderer->set_template(FWS_String::strtolower(FWS_String::substr($classname, $prevlastus + 1)) . '.htm');
 }
Ejemplo n.º 3
0
 /**
  * Checks whether the given file is excluded
  *
  * @param string $file the file
  * @param array $excl the excluded files
  * @return boolean true if so
  */
 private function is_excluded($file, $excl)
 {
     if (!FWS_String::ends_with($file, '.php')) {
         return true;
     }
     foreach ($excl as $ex) {
         if (strpos($file, $ex) !== false) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 4
0
/**
 * The autoloader for the test-cases
 * 
 * @param string $item the item to load
 * @return boolean whether the file has been loaded
 */
function PC_UnitTest_autoloader($item)
{
    if (FWS_String::starts_with($item, 'PC_Tests_')) {
        $item = FWS_String::substr($item, FWS_String::strlen('PC_Tests_'));
        $path = 'tests/' . FWS_String::strtolower($item) . '.php';
        if (is_file($path)) {
            include $path;
            return true;
        }
    }
    return false;
}
Ejemplo n.º 5
0
 /**
  * @see BS_Page::before_start()
  */
 protected function before_start()
 {
     parent::before_start();
     $doc = FWS_Props::get()->doc();
     // set the default template if not already done
     $template = '';
     if ($this->get_template() === null) {
         $classname = get_class($doc->get_module());
         $prefixlen = FWS_String::strlen('TDL_Module_');
         $template = FWS_String::strtolower(FWS_String::substr($classname, $prefixlen)) . '.htm';
         $this->set_template($template);
     }
 }
Ejemplo n.º 6
0
/**
 * The autoloader for the todolist src-files
 * 
 * @param string $item the item to load
 * @return boolean wether the file has been loaded
 */
function TDL_autoloader($item)
{
    if (FWS_String::starts_with($item, 'TDL_')) {
        $item = FWS_String::substr($item, 4);
        $item = str_replace('_', '/', $item);
        $item = FWS_String::strtolower($item);
        $item .= '.php';
        $path = FWS_Path::server_app() . 'src/' . $item;
        if (is_file($path)) {
            include $path;
            return true;
        }
    }
    return false;
}
Ejemplo n.º 7
0
 /**
  * Determines the type-instance by the given type-name
  *
  * @param string $name the type-name
  * @return PC_Obj_Type the type-instance
  */
 public static function get_type_by_name($name)
 {
     switch (FWS_String::strtolower($name)) {
         case 'number':
             // TODO keep that here?
         // TODO keep that here?
         case 'integer':
         case 'int':
         case 'long':
         case 'short':
         case 'byte':
             return new self(self::INT);
         case 'bool':
         case 'boolean':
             return new self(self::BOOL);
         case 'float':
         case 'double':
             return new self(self::FLOAT);
         case 'string':
         case 'str':
         case 'char':
             return new self(self::STRING);
         case 'array':
             return new self(self::TARRAY);
         case 'resource':
         case 'res':
             return new self(self::RESOURCE);
         case 'void':
             return new self(self::VOID);
         case 'mixed':
         case 'NULL':
             // return from gettype()
         // return from gettype()
         case 'unknown type':
             // return from gettype()
         // return from gettype()
         case 'unknown':
             return null;
         case 'callable':
         case 'function':
         case 'func':
             return new self(self::TCALLABLE);
         case 'object':
             return new self(self::OBJECT, null, '');
         default:
             return new self(self::OBJECT, null, $name);
     }
 }
Ejemplo n.º 8
0
/**
 * The autoloader for the phpcheck src-files
 * 
 * @param string $item the item to load
 * @return boolean whether the file has been loaded
 */
function PC_autoloader($item)
{
    if (FWS_String::starts_with($item, 'PC_')) {
        $nitem = substr($item, 3);
        $parts = explode('_', $nitem);
        if (!FWS_String::starts_with($item, 'PC_Module_')) {
            array_unshift($parts, 'src');
        }
        $nitem = implode('/', $parts);
        $nitem = str_replace('_', '/', $nitem);
        $nitem = strtolower($nitem);
        $nitem .= '.php';
        $path = FWS_Path::server_app() . $nitem;
        if (is_file($path)) {
            include $path;
            return true;
        }
    }
    return false;
}
Ejemplo n.º 9
0
 * This program 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
include_once 'config/userdef.php';
include_once 'config/mysql.php';
// define fwspath for init.php
define('FWS_PATH', TDL_FWS_PATH);
// init the framework
include_once TDL_FWS_PATH . 'init.php';
// the db is latin1
FWS_String::set_use_mb_functions(true, 'ISO-8859-1');
include_once FWS_Path::server_app() . 'src/props.php';
// init the autoloader
include_once FWS_Path::server_app() . 'src/autoloader.php';
FWS_AutoLoader::register_loader('TDL_autoloader');
// set the accessor and loader for the todolist
$accessor = new TDL_PropAccessor();
$accessor->set_loader(new TDL_PropLoader());
FWS_Props::set_accessor($accessor);
// init user
$user = FWS_Props::get()->user();
$user->init();
// ok, now show the page
$doc = FWS_Props::get()->doc();
echo $doc->render();
Ejemplo n.º 10
0
 /**
  * Collects all fields to update/insert
  * 
  * @return array the fields
  */
 private function _get_fields()
 {
     $fields = array();
     foreach (get_class_methods(get_class($this)) as $var) {
         // TODO that's no good solution. but what is one? :/
         if (FWS_String::substr($var, 0, 4) == 'get_' && $var != 'get_id' && $var != 'get_object_id' && $var != 'get_dump_vars' && $var != 'get_dump') {
             $value = $this->{$var}();
             if ($value !== null) {
                 $fields[FWS_String::substr($var, 4)] = $value;
             }
         }
     }
     return $fields;
 }
Ejemplo n.º 11
0
    /**
     * @see FWS_Module::run()
     */
    public function run()
    {
        $input = FWS_Props::get()->input();
        $functions = FWS_Props::get()->functions();
        $cfg = FWS_Props::get()->cfg();
        $cats = FWS_Props::get()->cats();
        $versions = FWS_Props::get()->versions();
        $db = FWS_Props::get()->db();
        $tpl = FWS_Props::get()->tpl();
        $user = FWS_Props::get()->user();
        $locale = FWS_Props::get()->locale();
        $s_keyword = $input->get_predef(TDL_URL_S_KEYWORD, 'get');
        $s_from_changed_date = $input->get_predef(TDL_URL_S_FROM_CHANGED_DATE, 'get');
        $s_to_changed_date = $input->get_predef(TDL_URL_S_TO_CHANGED_DATE, 'get');
        $s_from_start_date = $input->get_predef(TDL_URL_S_FROM_START_DATE, 'get');
        $s_to_start_date = $input->get_predef(TDL_URL_S_TO_START_DATE, 'get');
        $s_from_fixed_date = $input->get_predef(TDL_URL_S_FROM_FIXED_DATE, 'get');
        $s_to_fixed_date = $input->get_predef(TDL_URL_S_TO_FIXED_DATE, 'get');
        $s_type = $input->get_predef(TDL_URL_S_TYPE, 'get', '');
        $s_priority = $input->get_predef(TDL_URL_S_PRIORITY, 'get', '');
        $s_status = $input->get_predef(TDL_URL_S_STATUS, 'get', '');
        $s_category = $input->get_predef(TDL_URL_S_CATEGORY, 'get');
        $t_from_changed = $functions->get_date_from_string($s_from_changed_date);
        $t_to_changed = $functions->get_date_from_string($s_to_changed_date, 23, 59, 59);
        $t_from_start = $functions->get_date_from_string($s_from_start_date);
        $t_to_start = $functions->get_date_from_string($s_to_start_date, 23, 59, 59);
        $t_from_fixed = $functions->get_date_from_string($s_from_fixed_date);
        $t_to_fixed = $functions->get_date_from_string($s_to_fixed_date, 23, 59, 59);
        $form = new FWS_HTML_Formular(false);
        $s_type_combo = $form->get_combobox(TDL_URL_S_TYPE, $functions->get_types(true), $s_type);
        $s_priority_combo = $form->get_combobox(TDL_URL_S_PRIORITY, $functions->get_priorities(true), $s_priority);
        $s_status_combo = $form->get_combobox(TDL_URL_S_STATUS, $functions->get_states(true), $s_status);
        $category_options = array('' => $locale->_('- All -'));
        if ($cfg['project_id'] != 0) {
            $cat_rows = $cats->get_elements_with(array('project_id' => $cfg['project_id']));
        } else {
            $cat_rows = $cats->get_elements_with(array());
        }
        foreach ($cat_rows as $row) {
            $project = $versions->get_element_with(array('project_id' => $row['project_id']));
            $category_options[$row['id']] = $project['project_name_short'] . ' :: ' . $row['category_name'];
        }
        $s_category_combo = $form->get_combobox(TDL_URL_S_CATEGORY, $category_options, $s_category);
        $search_display_value = $input->get_var(TDL_COOKIE_PREFIX . 'display_search_form', 'cookie', FWS_Input::INT_BOOL);
        $where = ' WHERE ';
        if ($cfg['project_id'] != 0) {
            $where .= ' e.project_id = ' . $cfg['project_id'] . ' AND ';
        }
        if ($s_keyword != '') {
            $where .= " (LOWER(e.entry_title) LIKE LOWER('%" . $s_keyword . "%') OR";
            $where .= " LOWER(e.entry_description) LIKE LOWER('%" . $s_keyword . "%')) AND ";
        }
        if ($s_type != '') {
            $where .= " e.entry_type = '" . $s_type . "' AND ";
        }
        if ($s_priority != '') {
            $where .= " e.entry_priority = '" . $s_priority . "' AND ";
        }
        if ($s_status != '') {
            $where .= " e.entry_status = '" . $s_status . "' AND ";
        }
        if ($s_category != '') {
            $where .= " e.entry_category = " . $s_category . " AND ";
        }
        if ($t_from_changed) {
            $where .= ' e.entry_changed_date >= ' . $t_from_changed . ' AND ';
        }
        if ($t_to_changed) {
            $where .= ' e.entry_changed_date <= ' . $t_to_changed . ' AND ';
        }
        if ($t_from_start) {
            $where .= ' e.entry_start_date >= ' . $t_from_start . ' AND ';
        }
        if ($t_to_start) {
            $where .= ' e.entry_start_date <= ' . $t_to_start . ' AND ';
        }
        if ($t_from_fixed) {
            $where .= ' e.entry_fixed_date >= ' . $t_from_fixed . ' AND ';
        }
        if ($t_to_fixed) {
            $where .= ' e.entry_fixed_date <= ' . $t_to_fixed . ' AND ';
        }
        if (FWS_String::substr($where, -5) == ' AND ') {
            $where = FWS_String::substr($where, 0, -5);
        } else {
            $where = FWS_String::substr($where, 0, -7);
        }
        $order = $input->get_predef(TDL_URL_ORDER, 'get', 'changed');
        $base_url = new TDL_URL();
        $base_url->set(TDL_URL_S_KEYWORD, $s_keyword);
        $base_url->set(TDL_URL_S_CATEGORY, $s_category);
        $base_url->set(TDL_URL_S_PRIORITY, $s_priority);
        $base_url->set(TDL_URL_S_TYPE, $s_type);
        $base_url->set(TDL_URL_S_STATUS, $s_status);
        $base_url->set(TDL_URL_S_FROM_CHANGED_DATE, $s_from_changed_date);
        $base_url->set(TDL_URL_S_FROM_START_DATE, $s_from_start_date);
        $base_url->set(TDL_URL_S_FROM_FIXED_DATE, $s_from_fixed_date);
        $base_url->set(TDL_URL_S_TO_CHANGED_DATE, $s_to_changed_date);
        $base_url->set(TDL_URL_S_TO_START_DATE, $s_to_start_date);
        $base_url->set(TDL_URL_S_TO_FIXED_DATE, $s_to_fixed_date);
        $num = $db->get_row_count(TDL_TB_ENTRIES . ' e', 'e.id', ' LEFT JOIN ' . TDL_TB_CATEGORIES . ' c ON entry_category = c.id ' . $where);
        $site = $input->get_predef(TDL_URL_SITE, 'get');
        $order_url = clone $base_url;
        $order_url->set(TDL_URL_SITE, $site);
        $tpl->add_variables(array('num' => $num, 'date_comps' => $locale->get_date_order(), 'search_target' => $input->get_var('PHP_SELF', 'server', FWS_Input::STRING), 'cookie_name' => TDL_COOKIE_PREFIX . 'display_search_form', 'search_display_value' => $search_display_value == 1 ? 'block' : 'none', 's_keyword_param' => TDL_URL_S_KEYWORD, 's_from_start_date_param' => TDL_URL_S_FROM_START_DATE, 's_to_start_date_param' => TDL_URL_S_TO_START_DATE, 's_from_fixed_date_param' => TDL_URL_S_FROM_FIXED_DATE, 's_to_fixed_date_param' => TDL_URL_S_TO_FIXED_DATE, 's_from_changed_date_param' => TDL_URL_S_FROM_CHANGED_DATE, 's_to_changed_date_param' => TDL_URL_S_TO_CHANGED_DATE, 's_keyword' => stripslashes($s_keyword), 's_from_changed_date' => $s_from_changed_date, 's_to_changed_date' => $s_to_changed_date, 's_from_start_date' => $s_from_start_date, 's_to_start_date' => $s_to_start_date, 's_from_fixed_date' => $s_from_fixed_date, 's_to_fixed_date' => $s_to_fixed_date, 's_type_combo' => $s_type_combo, 's_priority_combo' => $s_priority_combo, 's_status_combo' => $s_status_combo, 's_category_combo' => $s_category_combo, 'type_col' => $functions->get_order_column($locale->_('Type'), 'type', 'ASC', $order, $order_url), 'title_col' => $functions->get_order_column($locale->_('Title'), 'title', 'ASC', $order, $order_url), 'project_col' => $functions->get_order_column($locale->_('Project'), 'project', 'ASC', $order, $order_url), 'start_col' => $functions->get_order_column($locale->_('Start'), 'start', 'DESC', $order, $order_url), 'fixed_col' => $functions->get_order_column($locale->_('Fixed'), 'fixed', 'DESC', $order, $order_url)));
        $ad = $input->get_predef(TDL_URL_AD, 'get', 'DESC');
        switch ($order) {
            case 'type':
                $sql_order = 'e.entry_type ' . $ad . ', e.entry_priority ' . $ad;
                break;
            case 'title':
                $sql_order = 'e.entry_title ' . $ad;
                break;
            case 'project':
                $sql_order = 'e.project_id ' . $ad . ', e.entry_category ' . $ad;
                break;
            case 'start':
                $sql_order = 'e.entry_start_date ' . $ad . ',e.id ' . $ad;
                break;
            case 'fixed':
                $sql_order = 'e.entry_fixed_date ' . $ad . ',e.id ' . $ad;
                break;
            default:
                $sql_order = 'e.entry_changed_date ' . $ad . ',e.id ' . $ad;
                break;
        }
        $limit = 20;
        $pagination = new TDL_Pagination($limit, $num);
        $hl = new FWS_KeywordHighlighter(array($s_keyword));
        $entries = array();
        $rows = $db->get_rows('SELECT e.*,c.category_name FROM ' . TDL_TB_ENTRIES . ' e
			 LEFT JOIN ' . TDL_TB_CATEGORIES . ' c ON entry_category = c.id
			 ' . $where . '
			 ORDER BY ' . $sql_order . '
			 LIMIT ' . $pagination->get_start() . ',' . $limit);
        $i = 0;
        foreach ($rows as $data) {
            $type_text = $functions->get_type_text($data['entry_type']);
            $priority_text = $functions->get_priority_text($data['entry_priority']);
            $start_version = $versions->get_element($data['entry_start_version']);
            if ($data['entry_fixed_date'] > 0) {
                if ($data['entry_fixed_version'] > 0) {
                    $fixed_version = $versions->get_element($data['entry_fixed_version']);
                } else {
                    $fixed_version = $versions->get_element($data['entry_start_version']);
                }
            }
            $title = $data['entry_title'];
            if ($s_keyword) {
                $title = $hl->highlight($title);
            }
            $entries[] = array('start_date' => FWS_Date::get_date($data['entry_start_date']), 'start_version' => $start_version['version_name'], 'project_name' => $start_version['project_name'], 'project_name_short' => $start_version['project_name_short'], 'category' => $data['entry_category'] ? $data['category_name'] : '', 'project' => $project, 'fixed_date' => $data['entry_fixed_date'] ? FWS_Date::get_date($data['entry_fixed_date']) : '', 'fixed_version' => $data['entry_fixed_date'] ? $fixed_version['version_name'] : '', 'title' => $title, 'info_link' => $data['entry_info_link'], 'priority' => $data['entry_priority'], 'type' => $data['entry_type'], 'type_text' => $type_text, 'priority_text' => $priority_text, 'image' => $data['entry_description'] != '' ? 'details_available' : 'details_not_available', 'id' => $data['id'], 'status' => $functions->get_status_text($data['entry_status']), 'class' => 'tl_status_' . $data['entry_status'], 'description' => nl2br($data['entry_description']));
            $i++;
        }
        $tpl->add_variable_ref('entries', $entries);
        $base_url->set(TDL_URL_ORDER, $order);
        $base_url->set(TDL_URL_AD, $ad);
        $pagination->populate_tpl($base_url);
        $edit_base = clone $base_url;
        $edit_base->set_separator('&');
        $edit_base->set(TDL_URL_IDS, '__IDS__');
        $edit_url = clone $edit_base;
        $edit_url->set(TDL_URL_ACTION, 'edit_entry');
        $edit_url->set(TDL_URL_MODE, 'edit');
        $chgstate_url = clone $edit_base;
        $chgstate_url->set(TDL_URL_ACTION, 'change_status');
        $del_url = clone $edit_base;
        $del_url->set(TDL_URL_ACTION, 'ajax_delmsg');
        $del_url->set(TDL_URL_LOC, 'view_entries');
        $tpl->add_variables(array('index' => $i, 'edit_url' => $edit_url->to_url(), 'chgstate_url' => $chgstate_url->to_url(), 'del_url' => $del_url->to_url()));
    }
Ejemplo n.º 12
0
 /**
  * Returns all tokens from the given source
  *
  * @param string $source the source
  * @return array the tokens: <code>array(array(<token>,<string>,<line>), ...)</code>
  */
 public static function get_tokens($source)
 {
     $line = 1;
     $res = array();
     $tokens = token_get_all($source);
     foreach ($tokens as $token) {
         if (is_array($token)) {
             list($t, $str, ) = $token;
         } else {
             $t = $token;
             $str = $token;
         }
         $res[] = array($t, $str, $line);
         $lines = FWS_String::substr_count($str, "\n");
         if ($lines >= 1) {
             $line += $lines;
         }
     }
     return $res;
 }
Ejemplo n.º 13
0
 /**
  * @see FWS_Module::run()
  */
 public function run()
 {
     $tpl = FWS_Props::get()->tpl();
     if (!$this->class) {
         $this->report_error();
         return;
     }
     $curl = PC_URL::get_mod_url();
     $classname = $this->class->get_name();
     // build class-declaration
     $declaration = '';
     if (!$this->class->is_interface()) {
         if ($this->class->is_abstract()) {
             $declaration .= 'abstract ';
         } else {
             if ($this->class->is_final()) {
                 $declaration .= 'final ';
             }
         }
         $declaration .= 'class ';
     } else {
         $declaration .= 'interface ';
     }
     $declaration .= $classname . ' ';
     if (!$this->class->is_interface() && ($cn = $this->class->get_super_class())) {
         $declaration .= 'extends <a href="' . $curl->set('name', $cn)->to_url() . '">' . $cn . '</a> ';
     }
     if (count($this->class->get_interfaces()) > 0) {
         $declaration .= !$this->class->is_interface() ? 'implements ' : 'extends ';
         foreach ($this->class->get_interfaces() as $if) {
             $declaration .= '<a href="' . $curl->set('name', $if)->to_url() . '">' . $if . '</a>, ';
         }
         $declaration = FWS_String::substr($declaration, 0, -1);
     }
     $declaration = FWS_String::substr($declaration, 0, -1) . ';';
     $tpl->add_variables(array('classname' => $classname, 'declaration' => $declaration));
     $classfile = $this->class->get_file();
     // constants
     $consts = array();
     foreach ($this->class->get_constants() as $const) {
         $consts[] = array('name' => $const->get_name(), 'type' => $const->get_type(), 'line' => $const->get_line(), 'url' => $this->get_url($classfile, $const));
     }
     $tpl->add_variable_ref('consts', $consts);
     // fields
     $fields = array();
     $cfields = $this->class->get_fields();
     ksort($cfields);
     foreach ($cfields as $field) {
         $fields[] = array('name' => $field->get_name(), 'type' => (string) $field, 'line' => $field->get_line(), 'url' => $this->get_url($classfile, $field));
     }
     $tpl->add_variable_ref('fields', $fields);
     // methods
     $methods = array();
     $cmethods = $this->class->get_methods();
     ksort($cmethods);
     foreach ($cmethods as $method) {
         $methods[] = array('name' => $method->get_name(), 'type' => $method->__ToString(), 'line' => $method->get_line(), 'url' => $this->get_url($classfile, $method), 'since' => implode(', ', $method->get_version()->get_min()), 'till' => implode(', ', $method->get_version()->get_max()));
     }
     $tpl->add_variable_ref('methods', $methods);
     if ($this->class->get_file() && $this->class->get_line()) {
         $source = PC_Utils::highlight_file($this->class->get_file());
     } else {
         $source = '';
     }
     $tpl->add_variables(array('source' => $source, 'file' => $this->class->get_file(), 'line' => $this->class->get_line(), 'since' => implode(', ', $this->class->get_version()->get_min()), 'till' => implode(', ', $this->class->get_version()->get_max())));
 }
Ejemplo n.º 14
0
 /**
  * Parses the given version information
  *
  * @param string $name the version name
  * @return array an array with the component name and the version number
  */
 private function get_version($name)
 {
     if (FWS_String::starts_with($name, 'PHP ')) {
         return explode(' ', $name);
     }
     list($name1, $name2, $version) = explode(' ', $name);
     return array($name1 . ' ' . $name2, $version);
 }