public function execute() { if ('' === ($name = trim($this->getRequest()->getParameter('n', '')))) { $this->getResponse()->setParameter('image', 'images/error.png'); $this->getResponse()->setParameter('status', 'Error'); $this->getResponse()->setParameter('message', 'The name of the repo is required'); } $escaped_name = RepoManager::escape($name); if (RepoManager::isAvailable($name)) { $this->getResponse()->setParameter('name', $escaped_name); $this->getResponse()->setParameter('image', 'images/tick.png'); $this->getResponse()->setParameter('status', 'Success'); $this->getResponse()->setParameter('message', 'The name of the repo is available'); } else { $this->getResponse()->setParameter('image', 'images/error.png'); $this->getResponse()->setParameter('status', 'Error'); $this->getResponse()->setParameter('message', 'The name of the repo is already in use'); } }
public function execute() { if ('' === ($name = trim($this->getRequest()->getParameter('name', '')))) { die('Bad request'); } $this->getResponse()->setParameter('title', 'Subvy'); $this->getResponse()->setParameter('subversion_root_url', Configuration::get('svn_root_url')); $escaped_name = RepoManager::escape($name); $repo = new Repo($escaped_name); if ($created_repo_name = $repo->create()) { $this->getResponse()->setParameter('name', $escaped_name); $this->getResponse()->setParameter('image', 'images/tick.png'); $this->getResponse()->setParameter('status', 'Exito'); $this->getResponse()->setParameter('message', 'El repositorio ' . $created_repo_name . ' fue creado.'); } else { $this->getResponse()->setParameter('name', $escaped_name); $this->getResponse()->setParameter('image', 'images/error.png'); $this->getResponse()->setParameter('status', 'No disponible'); $this->getResponse()->setParameter('message', 'El repositorio ' . $created_repo_name . ' ya existe.'); } }
public function create() { return RepoManager::create($this); }
<div class="modal-dialog" style="z-index:1100;"> <div class="modal-content"> <div class="modal-body"> <div class="well well-sm" style="margin-bottom:5px;font-size:12px;"><i class="fa fa-folder-open-o"></i> {{ path}}</div> <div style="border:1px solid #ddd;"> <div oc-lazy-load="{name: 'ngGrid', files: [ '<?php echo Yii::app()->controller->staticUrl('/js/lib/ng-grid.debug.js'); ?> ' , '<?php echo Yii::app()->controller->staticUrl('/css/ng-grid.css'); ?> ' ]}"> <div ng-if="gridReady" ng-grid="gridOptions" style="height:300px;"></div> </div> </div> <div class="clearfix"> </div> </div> </div> </div> <data name="repodata" class="hide"> <?php echo json_encode(RepoManager::model()->browse(RepoManager::getModuleDir())['item']); ?> </data> </div>
public function actionRemove() { $postdata = file_get_contents("php://input"); $post = CJSON::decode($postdata); $file = base64_decode($post['file']); $file = RepoManager::resolve($file); @unlink($file); // unlink($file . '.json'); }
public static function model() { if (is_null(self::$_model)) { self::$_model = new RepoManager(); } return self::$_model; }
public function save() { $path = $this->uploadPath; $path = trim(RepoManager::createDir($path)); $valid = $this->validate(); if ($valid) { ## remove delimeter character from attributes $attr = $this->attributes; foreach ($attr as $k => $i) { $attr[$k] = str_replace($this->repoDef['delimeter'], "-", $i); } ## modify attributes, so it can be safely stored as filename foreach ($attr as $k => $a) { $attr[$k] = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).]|[\\.]{2,})", '', $a); } extract($attr); ## get dir $pattern = $this->repoDef['pattern']; preg_match_all("/\\{(.*?)\\}/", $pattern, $blocks); foreach ($blocks[1] as $b) { $varname = '$' . explode(":", $b)[0]; $pattern = str_replace('{' . $b . '}', '{' . $varname . '}', $pattern); } eval('$dir = "' . $pattern . '";'); ## create dir $newdir = $path . "/" . $dir; $dirRenamed = false; if (!is_dir($newdir)) { if ($this->dirPath == "") { mkdir($newdir, 0777, true); } else { rename($path . "/" . $this->dirPath, $newdir); $dirRenamed = true; } } $oldDirPath = $path . "/" . $this->dirPath; $this->_dirpath = $dir; ## move uploaded file $fb = FormBuilder::load(get_class($this)); $fb->model = $this; $model = $this; foreach ($this->repoDef['fileFields'] as $fieldName) { if ($this->{$fieldName} != '') { ## find the FormField to get its file pattern $field = $fb->findField(['name' => $fieldName]); ## make sure file path is in the right path $this->{$fieldName} = RepoManager::resolve($this->{$fieldName}); ## get file extension $ext = pathinfo($this->{$fieldName}, PATHINFO_EXTENSION); ## file is uploaded if (is_file($this->{$fieldName})) { ## move the file to correct location eval('@rename($this->{$fieldName}, $newdir . "/' . $field['filePattern'] . '");'); ## assign new location to its var eval('$this->{$fieldName} = $newdir . "/' . $field['filePattern'] . '";'); if (isset($this->oldAttr[$fieldName])) { $old = RepoManager::resolve($this->oldAttr[$fieldName]); if ($old != $this->{$fieldName}) { @unlink($old); } } } else { if ($dirRenamed) { $this->{$fieldName} = $newdir . substr($this->{$fieldName}, strlen($oldDirPath)); } } ## change the path to relative path $this->{$fieldName} = RepoManager::getRelativePath($this->{$fieldName}); } } } return $valid; }
public function actionDownload($n, $f) { RepoManager::download($n, $f); }