本文整理汇总了PHP中CUtils::createFoldersToPath方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::createFoldersToPath方法的具体用法?PHP CUtils::createFoldersToPath怎么用?PHP CUtils::createFoldersToPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtils
的用法示例。
在下文中一共展示了CUtils::createFoldersToPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUploadFile
/**
* Загрузка файлов на сервер
*/
public function actionUploadFile()
{
$field = $_POST["_watch"];
$uploadTo = $_POST["_storage"];
if (array_key_exists($field, $_FILES)) {
$filename = md5(time()) . "." . CUtils::strRightBack($_FILES[$field]["name"], ".");
CUtils::createFoldersToPath($uploadTo);
move_uploaded_file($_FILES[$field]["tmp_name"], $uploadTo . $filename);
echo $filename;
}
}
示例2: hasCache
public function hasCache($key)
{
$filename = md5($key);
CUtils::createFoldersToPath($this->cacheDir);
if (file_exists($this->cacheDir . $filename . ".cache")) {
$now = time();
$created = filemtime($this->cacheDir . $filename . ".cache");
if ($now - $created > $this->timeout) {
unlink($this->cacheDir . $filename . ".cache");
return false;
}
return true;
}
return false;
}
示例3: actionGenerate
public function actionGenerate()
{
$params = new CGeneratableController();
$params->setAttributes(CRequest::getArray($params::getClassName()));
if ($params->validate()) {
$files = array();
/**
* Создаем сам контроллер
*/
$templateController = file_get_contents(CORE_CWD . "/_core/_models/generator/templates/controller.tpl");
$controllerFields = array("controllerName" => $params->controllerName, "controllerFile" => CUtils::strRightBack($params->controllerFile, CORE_DS), "controllerPath" => $params->controllerPath, "pageTitle" => $params->pageTitle, "modelName" => $params->modelName, "modelTable" => $params->modelTable, "modelManager" => $params->modelManager, "modelManagerGetter" => $params->modelManagerGetter, "viewPath" => $params->viewPath);
foreach ($controllerFields as $key => $value) {
$templateController = str_replace("#" . $key . "#", $value, $templateController);
}
$filePath = CORE_CWD . CORE_DS . $params->controllerPath . $params->controllerName . ".class.php";
CUtils::createFoldersToPath(CUtils::strLeftBack($filePath, CORE_DS));
file_put_contents($filePath, $templateController);
$files[] = $filePath;
/**
* Создаем модуль, которым этот контроллер рулит
*/
$templateModule = file_get_contents(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "module.tpl");
$moduleFields = array("controllerName" => $params->controllerName);
foreach ($moduleFields as $key => $value) {
$templateModule = str_replace("#" . $key . "#", $value, $templateModule);
}
$filePath = CORE_CWD . CORE_DS . $params->controllerFile;
CUtils::createFoldersToPath(CUtils::strLeftBack($filePath, CORE_DS));
file_put_contents($filePath, $templateModule);
$files[] = $filePath;
/**
* Модель данных, тоже пусть будет для полноты картины
*/
if ($params->modelGenerate == 1) {
$templateModel = file_get_contents(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "model.tpl");
$modelFields = array("modelName" => $params->modelName, "modelTable" => $params->modelTable);
foreach ($modelFields as $key => $value) {
$templateModel = str_replace("#" . $key . "#", $value, $templateModel);
}
$filePath = CORE_CWD . CORE_DS . $params->modelPath . $params->modelName . ".class.php";
CUtils::createFoldersToPath(CUtils::strLeftBack($filePath, CORE_DS));
file_put_contents($filePath, $templateModel);
$files[] = $filePath;
}
/**
* Получим список полей модели, которые хранятся в БД
* и из них сразу наклепаем столбцов в таблице и полей в форме
*/
$fields = array();
$modelName = $params->modelName;
$model = new $modelName();
if (is_a($model, "CActiveModel")) {
foreach ($model->getDbTableFields()->getItems() as $field) {
$fields[] = $field->name;
}
}
$viewFormFields = array();
$viewTableHeadFields = array();
$viewTableBodyFields = array();
foreach ($fields as $field) {
$templateField = file_get_contents(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "field.text.tpl");
$fieldFields = array("fieldTitle" => $field);
foreach ($fieldFields as $key => $value) {
$templateField = str_replace("#" . $key . "#", $value, $templateField);
}
$viewFormFields[] = $templateField;
$templateField = file_get_contents(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "field.tablebody.tpl");
$fieldFields = array("fieldTitle" => $field);
foreach ($fieldFields as $key => $value) {
$templateField = str_replace("#" . $key . "#", $value, $templateField);
}
$viewTableBodyFields[] = $templateField;
$templateField = file_get_contents(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "field.tablehead.tpl");
$fieldFields = array("fieldTitle" => $field);
foreach ($fieldFields as $key => $value) {
$templateField = str_replace("#" . $key . "#", $value, $templateField);
}
$viewTableHeadFields[] = $templateField;
}
$viewFormFields = implode("\n\n", $viewFormFields);
$viewTableHeadFields = implode("\n", $viewTableHeadFields);
$viewTableBodyFields = implode("\n", $viewTableBodyFields);
/**
* Набор представлений на все случаи жизни
*/
CUtils::createFoldersToPath(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_views" . CORE_DS . $params->viewPath);
$viewFiles = array(CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "index.tpl", CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "common.right.tpl", CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "add.tpl", CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "edit.tpl", CORE_CWD . CORE_DS . "_core" . CORE_DS . "_models" . CORE_DS . "generator" . CORE_DS . "templates" . CORE_DS . "form.tpl");
$viewFields = array("viewIndexTitle" => $params->viewIndexTitle, "viewIndexNoObjects" => $params->viewIndexNoObjects, "viewObjectSingleName" => $params->viewObjectSingleName, "viewObjectSingleNameRP" => $params->viewObjectSingleNameRP, "controllerFile" => CUtils::strRightBack($params->controllerFile, CORE_DS), "viewPath" => $params->viewPath, "viewFormFields" => $viewFormFields, "viewTableHeadFields" => $viewTableHeadFields, "viewTableBodyFields" => $viewTableBodyFields);
foreach ($viewFiles as $viewFile) {
$templateView = file_get_contents($viewFile);
foreach ($viewFields as $key => $value) {
$templateView = str_replace("#" . $key . "#", $value, $templateView);
}
$filePath = CORE_CWD . CORE_DS . "_core" . CORE_DS . "_views" . CORE_DS . $params->viewPath . CORE_DS . CUtils::strRightBack($viewFile, CORE_DS);
file_put_contents($filePath, $templateView);
$files[] = $filePath;
}
$this->setData("files", $files);
$this->renderView("__generator/controller/success.tpl");
return true;
//.........这里部分代码省略.........