public function actionUpdate($dir, $fileName) { if (isset($_POST['fileContent'])) { FileSystem::write('./'.$dir.'/'.$fileName, $_POST['fileContent'], 'w'); Y::end(); } $content = ''; $info = FileSystem::getInfo('./'.$dir.'/'.$fileName, array('name', 'ext')); if (in_array($info['ext'], array('js', 'css'))) { if (substr($dir, 0, 2) == 'js' || substr($dir, 0, 3) == 'css') { $content = FileSystem::read('./'.$dir.'/'.$fileName); } } $output = $this->renderPartial('fileDetails', array( 'fileName' => $fileName, 'content' => $content, 'type' => $info['ext'] == 'css' ? 'css' : 'javascript', 'filePath' => './'.$dir.'/'.$fileName ), true); Y::tab('Содержимое файла', $output); $output = Y::getTabs('cssFileForm', true); Y::clientScript()->render($output); echo CHtml::tag('div', array(), $output); }
/** * Read from stream */ public function stream_read($count) { if (!in_array($this->mode, ['r', 'r+', 'w+', 'a+', 'x+', 'c+'])) { return FALSE; } $data = $this->fileSystem->read($this->getFileName(), $this->fpos, $count); if ($data === NULL) { return FALSE; } $this->fpos += strlen($data); return $data; }
public function getTemplate() { if ($this->_template === null) { $path = $this->filePath; $files = FileSystem::dirFileInfo($path); $fileName = $this->alias.$this->ext; if (isset($files[$fileName])) $this->_template = FileSystem::read($path.$fileName); } return $this->_template; }
</ul> </div> </header> <section> <h1>Rediger Nyheder</h1> <p>Her redigeres i Nyheder på Peter Gift hjemmesiden. <!-- Punkterne gemmes enkeltvis--></p> </section> <main id="menupunkter"> <form action="processes/process2.php" method="post"> <section class="formfelt"> <h2>Nyheder</h2> <h3>Nyheds titel</h3> <textarea class="nyhedtitel" name="titelnyhed"><?php // Læs menupunkt $filename = "includes/nyheder/nyhedstitel.html"; echo $file->read($filename); ?> </textarea> <h3>Nyheden</h3> <textarea class="nyhedtekst" name="tekstnyhed" ><?php // læs beskrivelse $filename = "includes/nyheder/nyhedstekst.html"; echo $file->read($filename); ?> </textarea> </section> <button type="submit" class="button">Gem</button> </form>
/** * Crea una nueva aplicacion con nombre $name. * En $params se pasarian parametros extra como clases del * modelo y sus campos para crear una estructura mas rica. * Este parametro todavia no se usa. * Tira una excepcion si no puede crear la estructura de directorios. */ public static function create($name, $params = array()) { $normalizedName = String::toUnderscore(String::filterCharacters($name)); $appStruct = array('./apps/' . $normalizedName, './apps/' . $normalizedName . '/controllers', './apps/' . $normalizedName . '/model', './apps/' . $normalizedName . '/views', './apps/' . $normalizedName . '/services', './apps/' . $normalizedName . '/i18n', './apps/' . $normalizedName . '/bootstrap', './apps/' . $normalizedName . '/config', './apps/' . $normalizedName . '/utils'); foreach ($appStruct as $package) { //echo "intenta crear $package<br/>"; if (!file_exists($package) && !mkdir($package)) { throw new Exception('No se puede crear el directorio ' . $package . ', verifique que tiene los permisos suficientes'); } } // FIXME: pueden venir tildes y cualquier tipo de caracter, deberia filtrar todo lo que venga mal, o pedirle que lo corrija. // TODO: crear descriptor con el nombre de la app $appDescriptor = FileSystem::read('./core/app/templates/app.xml'); $appDescriptor = str_replace('{appName}', $name, $appDescriptor); if (isset($params['description'])) { $appDescriptor = str_replace('{appDescription}', $params['description'], $appDescriptor); } if (isset($params['langs'])) { $appDescriptor = str_replace('{appLangs}', $params['langs'], $appDescriptor); } if (isset($params['controller'])) { $appDescriptor = str_replace('{epController}', $params['controller'], $appDescriptor); $appDescriptor = str_replace('{epAction}', 'index', $appDescriptor); $templateController = FileSystem::read('./core/app/templates/TemplateController.class.php'); $templateController = str_replace('Template', String::firstToUpper($params['controller']), $templateController); echo './apps/' . $normalizedName . '/controllers/apps.' . $normalizedName . '.controllers.' . String::firstToUpper($params['controller']) . 'Controller.class.php'; FileSystem::write('./apps/' . $normalizedName . '/controllers/apps.' . $normalizedName . '.controllers.' . String::firstToUpper($params['controller']) . 'Controller.class.php', $templateController); } FileSystem::write('./apps/' . $normalizedName . '/app.xml', $appDescriptor); }
public function adminForm() { $dir = 'mainContent.components.widgets.views.MainContent.'.$this->widgetModel->pk.'.'; Y::beginTab('Шаблон списка'); $this->widget('CodeMirror', array( 'type'=>'text/html', 'id'=>'main_content_list_template', 'content'=>FileSystem::read(Yii::getPathOfAlias($dir.'listTemplate').'.twig'), 'name'=>'list-template' )); Y::endTab(); Y::beginTab('Шаблон элемента'); $this->widget('CodeMirror', array( 'type'=>'text/html', 'id'=>'main_content_item', 'content'=>FileSystem::read(Yii::getPathOfAlias($dir.'item').'.twig'), 'name'=>'item' )); Y::endTab(); Y::beginTab('Шаблон полный'); $this->widget('CodeMirror', array( 'type'=>'text/html', 'id'=>'main_content_full', 'content'=>FileSystem::read(Yii::getPathOfAlias($dir.'full').'.twig'), 'name'=>'full' )); Y::endTab(); }