function getNovedades() {
        if($this->novedades != null) return $this->novedades;
        parent::process();

        $this->novedades = array();
        foreach(pq('div.blog') as $item) {
            $novedad = new stdClass();
            $tmp_autor = pq('em', $item);
            $tmp_autor_i = strpos($tmp_autor, '<a class');
            $tmp_autor_f = strpos($tmp_autor, '</a>') + 4;

            $novedad->texto = pq($item)->children('p');
            foreach(pq('a', $novedad->texto) as $href) {
                $href_url = pq($href)->attr('href');
                if(substr($href_url, 0, 2) == 'r/')
                    pq($href)->attr('href', $this->url . $href_url);
            }
            foreach(pq('img', $novedad->texto) as $href) {
                $img_src = pq($href)->attr('src');
                if(substr($img_src, 0, 2) == 'r/')
                    pq($href)->attr('src', $this->url . $img_src);
            }

            $novedad->texto = mb_convert_encoding(pq($novedad->texto)->html(), 'UTF-8');
            $novedad->titulo = trim(pq(pq($item)->children('h1'))->text());
            $novedad->fecha = trim(substr($tmp_autor, $tmp_autor_f));
            $novedad->autor = new stdClass();
            $novedad->autor->nombre = pq(substr($tmp_autor, $tmp_autor_i, $tmp_autor_f - $tmp_autor_i + 1))->html();
            $novedad->autor->avatar = pq('img')->attr('src');
            $this->novedades[] = $novedad;
        }
        return $this->novedades;
    }
    function getNotas() {
        if($this->cursos != null) return $this->cursos;
        parent::process();

        $this->cursos = array();
        $identifier = null;
        foreach(pq('table > *:not(thead)') as $bloques) {
            if ($bloques->tagName == 'tr') {
                if(!$identifier) {
                    $identifier = pq('td', $bloques)->text();
                }
            }
            else {
                $identifier = $identifier ? $identifier : '';
                if (!isset($this->notas[$identifier])) $this->notas[$identifier] = array();
                foreach(pq('tr', $bloques) as $tr) {
                    $curso = new stdClass();
                    $curso->id = pq('td:nth-child(3)', $tr)->html();
                    $curso->nombre = mb_convert_encoding(pq('td:nth-child(4) > a', $tr)->html(), 'UTF-8');
                    $curso->url = pq('td:nth-child(4) > a', $tr)->attr('href');
                    $curso->cargo = UcursosScrapper::toUserType(pq('td:nth-child(1) > img', $tr)->attr('title'));
                    $curso->institucion = new stdClass();
                    $curso->institucion->nombre = pq('td:nth-child(2) > img', $tr)->attr('title');
                    $curso->institucion->icono = pq('td:nth-child(2) > img', $tr)->attr('src');
                    $this->cursos[$identifier][] = $curso;
                }
                $identifier = null;
            }
        }
        return $this->cursos;
    }
    function getHorario() {
        if($this->horario != null) return $this->horario;
        parent::process();

        $dotw = array('Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado');

        $this->horario = array('Lunes' => array()
                       , 'Martes' => array()
                       , 'Miércoles' => array()
                       , 'Jueves' => array()
                       , 'Viernes' => array()
                       , 'Sábado' => array());

        foreach(pq('td.dia') as $day => $bloques) {
            foreach(pq('div', $bloques) as $tmp_bloque) {
                $bloque = new stdClass();
                $bloque->codigo = pq('a', $tmp_bloque)->html();
                list(,$tmp_tipo,, $tmp_horario) = pq($tmp_bloque)->contents()->elements;
                $bloque->tipo = trim(pq($tmp_tipo)->text());
                list($bloque->sala, $bloque->hora) = explode(chr(194).chr(160), pq($tmp_horario)->text());
                $this->horario[$dotw[$day]][] = $bloque;
            }
        }

        return $this->horario;
    }
 public static function toUserType($str, $default = 'administrador_de_comunidad', $nan = 'miembro_de_comunidad') {
     // $default: cuando no tiene tipo
     // $nan: cuando no es un tipo conocido
     $types = array('profesor_de_catedra', 'auxiliar', 'ayudante', 'alumno', 'miembro_de_comunidad', 'administrador_de_comunidad');
     $str = UcursosScrapper::toAscii($str);
     return $str ? (in_array($str, $types) ? $str : $nan ) : $default;
 }
    function getThreads($default = 'alumno', $nan = 'miembro_de_comunidad') {
        if($this->threads != null) return $this->threads;
        parent::process();

        $this->default = $default;
        $this->nan = $nan;

        $this->threads = array();
        foreach (pq('div.msg.raiz') as $tmp_thread) {
            $thread = $this->getThreadInfo($tmp_thread);

            $tmp_content = pq($tmp_thread)->children('div.container:first');

            $tmp_autor = pq($tmp_content)->children('span.autor', $tmp_thread);
            $thread->autor = $this->getAuthorInfo($tmp_autor);
            $thread->fecha = trim(pq('em', $tmp_autor)->text());

            $tmp_post = new stdClass();
            $tmp_post->autor = $thread->autor;
            $tmp_post->fecha = trim(pq('em', $tmp_autor)->html());
            $tmp_post->texto = $this->getPostContent($tmp_content);
            list($tmp_post->id, $tmp_post->responder) = $this->getPostInfo($tmp_content);

            $tmp_post->primero = true;

            $thread->posts = array();
            $thread->posts[] = $tmp_post;

            foreach (pq('div.hijo', $tmp_thread) as $reply) {
                $tmp_post = new stdClass();
                $tmp_post->nuevo = pq($reply)->hasClass('nuevo');

                $reply = pq($reply)->children('div.container');
                $tmp_post->texto = $this->getPostContent($reply);
                list($tmp_post->id, $tmp_post->responder) = $this->getPostInfo($reply);

                $tmp_autor = pq(pq($reply)->children('span.autor'));
                $tmp_post->autor = $this->getAuthorInfo($tmp_autor);

                $tmp_post->fecha = trim(pq('em', $tmp_autor)->html());
                $tmp_post->primero = false;

                $thread->posts[] = $tmp_post;
            }
            $this->threads[] = $thread;
        }

        return $this->threads;
    }
    function getUserInstituciones() {
        $id = 'instituciones';
        if(!property_exists($this, $id)) return null;
        if($this->$id != null) return $this->$id;
        parent::process();

        $this->$id = array();
        foreach(pq('div#'.$id.' > ul > li') as $item) {
            $element = new stdClass();
            $element->tipo = UcursosScrapper::toAscii((pq('img', $item)->attr('alt')));
            $element->nombre = pq('a > span:first', $item)->text();
            $element->url = substr(pq('a', $item)->attr('href'), strlen('https://www.u-cursos.cl'));
            $element->nuevos = array();
            foreach(pq('div.nuevo > a', $item) as $new_item) {
                $new_count = pq($new_item)->html();
                $element->nuevos[substr(pq($new_item)->attr('href'), strlen('https://www.u-cursos.cl'. $element->url), -1)] = substr($new_count, strpos($new_count, '(')+1, -1);
            }
            $this->{$id}[] = $element;
        }
        return $this->$id;
    }
 function getCantidadPreguntas() {
     if($this->cantidad != null) return $this->cantidad;
     parent::process();
     return pq('thead th')->size()-2;
 }