<commit_before><?php

class FilesController extends Zend_Controller_Action
{
    public function listAction()
    {
        $registry = Zend_Registry::getInstance();
        $config = $registry->get("config");
        
        $request = $this->getRequest();
        
        $this->_helper->loadApiresource->user();
        
        $userInfo = $registry->get("userInfo");
        
        $params = $request->getParams();
        
        $share = Ml_Share::getInstance();
        
        $perPage = $request->getParam("per_page", 20);
        if ($perPage > 100) {
            $perPage = 100;
        } else if ($perPage < 1 || $perPage > 100) {
            $perPage = 20;
        }
        
        $page = $request->getParam("page", 1);
        
        if (! is_natural($page)) {
            $page = 1;
        }
        
        $paginator = $share->getPages($userInfo['id'], $perPage, $page);
        
        if ($paginator->count() < $page) {
            $page = $paginator->count();
        }
        
        $doc = new Ml_Dom();
        $doc->formatOutput = true;
        
        $rootElement = $doc->createElement("files");
        
        $doc->appendChild($rootElement);
        
        $shareData = array(
            "page" => $page,
            "pages" => $paginator->count(),
            "per_page" => $perPage,
            "total" => $paginator->getTotalItemCount(),
        );
        
        foreach ($shareData as $field => $data) {
            $rootElement->appendChild($doc->newTextAttribute($field, $data));
        }
    
        foreach ($paginator->getCurrentItems()->toArray() as $share) {
            $shareElement = $doc->createElement("file");
            
            $shareElement
            ->appendChild($doc->newTextAttribute("id", $share['id']));
            
            $shareElement
            ->appendChild($doc
             ->newTextAttribute("posted", $share['uploadedTime']));
            
            $shareData = array("title" => $share['title'], 
            "filename" => $share['filename'], "filetype" => $share['type'], 
            "short" => $share['short']);
            
            foreach ($shareData as $field => $data) {
                $shareElement->appendChild($doc->newTextElement($field, $data));
            }
            
            $filesizeElement = $doc->createElement("filesize");
            $filesizeElement
            ->appendChild($doc->newTextAttribute("bits", $share['fileSize']));
            
            $filesizeElement
            ->appendChild($doc
            ->newTextAttribute("kbytes", ceil($share['fileSize']/(1024*8))));
            
            $shareElement->appendChild($filesizeElement);
            
            $rootElement->appendChild($shareElement);
        }
    
        $this->_helper->printResponse($doc);
    }
    
    public function infoAction()
    {
        //@todo route: do it the right way!
        $router = new Zend_Controller_Router_Rewrite();
        
        $routeConfig =
        new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
        
        $router->$routeConfig($config, 'routes');
        
        $registry = Zend_Registry::getInstance();
        $config = $registry->get("config");
        
        $request = $this->getRequest();
        
        $params = $request->getParams();
        
        $people = Ml_People::getInstance();
        $favorites = Ml_Favorites::getInstance();
        $comments = Ml_Comments::getInstance();
        $tags = Ml_Tags::getInstance();
        <commit_msg>fix issue of wrong variable name ($routeConfig was given as $config)<commit_after><?php

class FilesController extends Zend_Controller_Action
{
    public function listAction()
    {
        $registry = Zend_Registry::getInstance();
        $config = $registry->get("config");
        
        $request = $this->getRequest();
        
        $this->_helper->loadApiresource->user();
        
        $userInfo = $registry->get("userInfo");
        
        $params = $request->getParams();
        
        $share = Ml_Share::getInstance();
        
        $perPage = $request->getParam("per_page", 20);
        if ($perPage > 100) {
            $perPage = 100;
        } else if ($perPage < 1 || $perPage > 100) {
            $perPage = 20;
        }
        
        $page = $request->getParam("page", 1);
        
        if (! is_natural($page)) {
            $page = 1;
        }
        
        $paginator = $share->getPages($userInfo['id'], $perPage, $page);
        
        if ($paginator->count() < $page) {
            $page = $paginator->count();
        }
        
        $doc = new Ml_Dom();
        $doc->formatOutput = true;
        
        $rootElement = $doc->createElement("files");
        
        $doc->appendChild($rootElement);
        
        $shareData = array(
            "page" => $page,
            "pages" => $paginator->count(),
            "per_page" => $perPage,
            "total" => $paginator->getTotalItemCount(),
        );
        
        foreach ($shareData as $field => $data) {
            $rootElement->appendChild($doc->newTextAttribute($field, $data));
        }
    
        foreach ($paginator->getCurrentItems()->toArray() as $share) {
            $shareElement = $doc->createElement("file");
            
            $shareElement
            ->appendChild($doc->newTextAttribute("id", $share['id']));
            
            $shareElement
            ->appendChild($doc
             ->newTextAttribute("posted", $share['uploadedTime']));
            
            $shareData = array("title" => $share['title'], 
            "filename" => $share['filename'], "filetype" => $share['type'], 
            "short" => $share['short']);
            
            foreach ($shareData as $field => $data) {
                $shareElement->appendChild($doc->newTextElement($field, $data));
            }
            
            $filesizeElement = $doc->createElement("filesize");
            $filesizeElement
            ->appendChild($doc->newTextAttribute("bits", $share['fileSize']));
            
            $filesizeElement
            ->appendChild($doc
            ->newTextAttribute("kbytes", ceil($share['fileSize']/(1024*8))));
            
            $shareElement->appendChild($filesizeElement);
            
            $rootElement->appendChild($shareElement);
        }
    
        $this->_helper->printResponse($doc);
    }
    
    public function infoAction()
    {
        //@todo route: do it the right way!
        $router = new Zend_Controller_Router_Rewrite();
        
        $routeConfig =
        new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
        
        $router->addConfig($routeConfig, 'routes');
        
        $registry = Zend_Registry::getInstance();
        $config = $registry->get("config");
        
        $request = $this->getRequest();
        
        $params = $request->getParams();
        
        $people = Ml_People::getInstance();
        $favorites = Ml_Favorites::getInstance();
        $comments = Ml_Comments::getInstance();
        $tags = Ml_Tags::getInstance();
        
{'fraction_non_alphanumeric': 0.1541148525918681, 'fraction_numerical': 0.0058683806063993295, 'mean_word_length': 1.7669114804793198, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 109, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1083146', 'n_tokens_mistral': 1957, 'n_tokens_neox': 1895, 'n_words': 318}