当前位置: 首页>>代码示例>>PHP>>正文


PHP CUtils::strLeftBack方法代码示例

本文整理汇总了PHP中CUtils::strLeftBack方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtils::strLeftBack方法的具体用法?PHP CUtils::strLeftBack怎么用?PHP CUtils::strLeftBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUtils的用法示例。


在下文中一共展示了CUtils::strLeftBack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHandlerNames

 /**
  * Генератор названий обработчиков
  *
  * @param string $event
  * @param string $element
  * @return array
  */
 private function getHandlerNames($event = '', $element = '')
 {
     // получим основные названия обработчиков
     $handlers = array();
     $handlers[] = $event . '_' . $element;
     $e = $element;
     while (mb_strpos($e, '_') !== false) {
         $e = CUtils::strLeftBack($e, '_');
         $handlers[] = $event . '_' . $e;
     }
     $handlers[] = $event;
     // для цифровых обработчиков сгенерируем нецифровые аналоги
     $pattern = '/(_[0-9]+)/';
     foreach ($handlers as $handler) {
         if (preg_match($pattern, $handler) > 0) {
             $h = preg_replace($pattern, '', $handler);
             if (!in_array($h, $handlers)) {
                 $handlers[] = $h;
             }
         }
     }
     // сгенерируем дополнительно полный список
     $result = array();
     foreach ($handlers as $handler) {
         $result[] = 'handle_before_' . $handler;
         $result[] = 'handle_' . $handler;
         $result[] = 'handle_after_' . $handler;
     }
     // для отладки пропишем все обработчики в бин
     $this->getStatefullFormBean()->getElement($element)->setHandlers($result);
     return $result;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:39,代码来源:CStatefullFormController.class.php

示例2: getCurrentTask

 /**
  * @return CUserRole
  */
 public static function getCurrentTask()
 {
     $self = $_SERVER["PHP_SELF"];
     $root_folder = CSettingsManager::getSettingValue("root_folder");
     $self = str_replace($root_folder, "", $self);
     if (substr($self, 0, 1) == "/") {
         $self = substr($self, 1);
     }
     /**
      * Начинаем поиск задач, походящих под описание. Если не находим,
      * то отрезаем справа /
      */
     $queryCount = 0;
     $tasks = CActiveRecordProvider::getWithCondition(TABLE_USER_ROLES, "url='" . $self . "'");
     while ($tasks->getCount() == 0 && strlen($self) > 1 && $queryCount <= 5) {
         $self = CUtils::strLeftBack($self, "/");
         if (substr($self, strlen($self) - 1) != "/") {
             $self .= "/";
         }
         $tasks = CActiveRecordProvider::getWithCondition(TABLE_USER_ROLES, "url='" . $self . "'");
         $queryCount++;
     }
     $task = null;
     if ($tasks->getCount() > 0) {
         foreach ($tasks->getItems() as $ar) {
             $task = new CUserRole($ar);
         }
     }
     return $task;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:33,代码来源:CSession.class.php

示例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;
//.........这里部分代码省略.........
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:101,代码来源:CGeneratorControllersController.class.php


注:本文中的CUtils::strLeftBack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。