public function loadAction() { $request = $this->getRequest(); if (!$request->isPost()) { return; } $this->view->editor = 'ckeditor'; $module = $request->getPost('mod'); $widgetName = $request->getPost('name'); $this->view->module = $module; $this->view->widgetName = $widgetName; $pageIndex = $request->getPost('page'); $pageIndex = $pageIndex ? $pageIndex : 1; $perPage = 30; $offset = ($pageIndex - 1) * $perPage; $this->view->start = $offset; $this->view->end = $offset + $perPage; $sizes = null; $this->view->sizes = null; $params = $request->getPost('params'); $json = new Services_JSON(); $params = $json->decode($params); $path = isset($params->path) ? $params->path : null; $path = $path ? base64_decode(rawurldecode($path)) : null; $path = trim($path, DS); $style = isset($params->style) ? $params->style : null; $style = $style ? $style : 'list'; $fullPath = ROOT_DIR . DS . $path; $this->view->fullPath = $fullPath; if (!file_exists($fullPath)) { $fullPath = ROOT_DIR; $path = null; } $dirIterator = new DirectoryIterator($fullPath); $dirs = $files = array(); foreach ($dirIterator as $obj) { if ($obj->isDot()) { continue; } $name = $obj->getFilename(); if ('CVS' == $name || '.svn' == strtolower($name)) { continue; } if ($obj->isDir()) { $dir = array(); $dir['name'] = $name; $dir['size'] = Gio_Core_File::formatFileSize(Gio_Core_File::getDirSize($fullPath . DS . $name)); $dir['modified'] = null; $dir['is_dir'] = true; $dirs[] = $dir; } else { $file = array(); $file['name'] = $name; $file['size'] = Gio_Core_File::formatFileSize(@filesize($fullPath . DS . $name)); $file['modified'] = @filemtime($fullPath . DS . $name); $file['is_dir'] = false; $files[] = $file; } } $data = array_merge($dirs, $files); $breakcrumb = $path ? explode(DS, $path) : array(''); $this->view->breakcrumb = $breakcrumb; $upDir = null; if ($path) { array_pop($breakcrumb); $upDir = implode(DS, $breakcrumb); } // $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($data)); // $paginator->setCurrentPageNumber($pageIndex)->setItemCountPerPage($perPage); // // $this->_view->paginator = $paginator; // $this->_view->paginatorOptions = array( // 'path' => '', // 'itemLink' => "javascript: Tomato.Upload.Widgets.FileToolbox.loadWidgets('" // . $this->_view->directoryBuilder()->getPathLink($path) . "', %d, '" . $style . "')", // ); $this->view->path = $path; $this->view->style = $style; $this->view->data = $data; $viewFilePath = ROOT_DIR . DS . 'modules' . DS . $module . DS . 'widgets' . DS . $widgetName; $response = null; switch ($style) { case 'grid': $response = $this->view->render($viewFilePath . DS . '_grid.phtml'); break; case 'list': default: $response = $this->view->render($viewFilePath . DS . '_list.phtml'); break; } $this->view->response = $response; }