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


PHP ZendT_Lib::createDirectory方法代码示例

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


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

示例1: create

 /**
  * Cria a classe de controle 
  * 
  * @param string $pathBase
  * @param array $config 
  */
 public static function create($pathBase, $config, $overwrite = 0)
 {
     if (!isset($config['table']['modelName'])) {
         $config['table']['modelName'] = $config['table']['name'];
     }
     $modelName = ZendT_Lib::convertTableNameToClassName($config['table']['modelName']);
     $ucModuleName = ucfirst($config['table']['moduleName']);
     if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
         $config['table']['moduleName'] = 'Application';
         $path = 'application/controllers';
         $moduleControllerName = $modelName . 'Controller';
     } else {
         $path = 'application/modules/' . $config['table']['moduleName'] . '/controllers';
         $moduleControllerName = $ucModuleName . '_' . $modelName . 'Controller';
     }
     ZendT_Lib::createDirectory($pathBase, $path);
     $filename = $path . '/' . $modelName . 'Controller.php';
     $contentText = "<?php\n    class {$moduleControllerName} extends ZendT_Controller_ActionCrud {\n        public function init() {\n            \$this->_init();\n            //\$this->_startupAcl();            \n            \$this->_formName = '{$ucModuleName}_Form_{$modelName}_Edit';\n            \$this->_mapper = new {$ucModuleName}_DataView_{$modelName}_MapperView();\n            \$this->view->tabs = \$this->_mapper->getTabs();\n            /**\n             * Configuração do Grid\n             */\n            \$name = \$this->getRequest()->getParam('name');\n            if (!\$name)\n                \$name = '" . strtolower($modelName) . "';\n            \$this->setGrid( new ZendT_Grid('grid_'.\$name));\n        }\n    }\n?>\n";
     $replace = null;
     if (file_exists($filename)) {
         if ($overwrite) {
             $replace = true;
         } else {
             $replace = false;
         }
     }
     if ($replace === null || $replace === true) {
         file_put_contents($filename, $contentText);
     }
     //file_put_contents($filename, $contentText);
 }
开发者ID:rtsantos,项目名称:mais,代码行数:37,代码来源:Controller.php

示例2: factory

 public function factory($table, $module)
 {
     $this->_loadProfile(self::NO_PROFILE_THROW_EXCEPTION);
     $path = $this->_loadedProfile->getAttribute('projectDirectory');
     $dirModules = $path . '/application/configs/modules';
     if (!is_dir($dirModules)) {
         mkdir($dirModules);
     }
     $dirModule = $dirModules . '/' . $module;
     if (!is_dir($dirModule)) {
         mkdir($dirModule);
     }
     $fileName = $dirModule . '/' . $table . '.php';
     if (!file_exists($fileName)) {
         throw new Zend_Tool_Project_Provider_Exception('Para executar essa ação é necessário criar o arquivo ' . $fileName);
     }
     $config = (require $fileName);
     $path .= '/application/modules/' . strtolower($module);
     /**
      * Gerando o DataView 
      */
     if (!isset($config['table']['modelName'])) {
         $config['table']['modelName'] = $config['table']['name'];
     }
     $modelName = ZendT_Lib::convertTableNameToClassName($config['table']['modelName']);
     /**
      * 
      */
     if (file_exists($path . '/models/' . $modelName . '/MapperView.php')) {
         ZendT_Lib::createDirectory($path, '/data-views/' . $modelName . '/Crud');
         copy($path . '/models/' . $modelName . '/Crud/MapperView.php', $path . '/data-views/' . $modelName . '/Crud/MapperView.php');
         unlink($path . '/models/' . $modelName . '/Crud/MapperView.php');
         $content = file_get_contents($path . '/data-views/' . $modelName . '/Crud/MapperView.php');
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_Crud_MapperView', ucfirst($module) . '_DataView_' . $modelName . '_Crud_MapperView', $content);
         file_put_contents($path . '/data-views/' . $modelName . '/Crud/MapperView.php', $content);
         copy($path . '/models/' . $modelName . '/MapperView.php', $path . '/data-views/' . $modelName . '/MapperView.php');
         unlink($path . '/models/' . $modelName . '/MapperView.php');
         $content = file_get_contents($path . '/data-views/' . $modelName . '/MapperView.php');
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_MapperView', ucfirst($module) . '_DataView_' . $modelName . '_MapperView', $content);
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_Crud_MapperView', ucfirst($module) . '_DataView_' . $modelName . '_Crud_MapperView', $content);
         file_put_contents($path . '/data-views/' . $modelName . '/MapperView.php', $content);
         $content = file_get_contents($path . '/controllers/' . $modelName . 'Controller.php');
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_MapperView', ucfirst($module) . '_DataView_' . $modelName . '_MapperView', $content);
         file_put_contents($path . '/controllers/' . $modelName . 'Controller.php', $content);
         $this->_print('Objeto MapperView fatorado com sucesso!');
     } else {
         $this->_print('Objeto MapperView já fatorado');
     }
     /**
      * 
      */
     if (file_exists($path . '/models/' . $modelName . '/Element.php')) {
         copy($path . '/models/' . $modelName . '/Crud/Element.php', $path . '/forms/' . $modelName . '/Crud/Elements.php');
         unlink($path . '/models/' . $modelName . '/Crud/Element.php');
         $content = file_get_contents($path . '/forms/' . $modelName . '/Crud/Elements.php');
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_Crud_Element', ucfirst($module) . '_Form_' . $modelName . '_Crud_Elements', $content);
         file_put_contents($path . '/forms/' . $modelName . '/Crud/Elements.php', $content);
         copy($path . '/models/' . $modelName . '/Element.php', $path . '/forms/' . $modelName . '/Elements.php');
         unlink($path . '/models/' . $modelName . '/Element.php');
         $content = file_get_contents($path . '/forms/' . $modelName . '/Elements.php');
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_Element', ucfirst($module) . '_Form_' . $modelName . '_Elements', $content);
         $content = str_replace(ucfirst($module) . '_Model_' . $modelName . '_Crud_Element', ucfirst($module) . '_Form_' . $modelName . '_Crud_Elements', $content);
         file_put_contents($path . '/forms/' . $modelName . '/Elements.php', $content);
         $this->_print('Objeto Element fatorado com sucesso!');
     } else {
         $this->_print('Objeto Element já fatorado');
     }
     ZendT_Lib::replaceFiles($path, ucfirst($module) . '_Model_' . $modelName . '_MapperView', ucfirst($module) . '_DataView_' . $modelName . '_MapperView');
     ZendT_Lib::replaceFiles($path, ucfirst($module) . '_Model_' . $modelName . '_Element', ucfirst($module) . '_Form_' . $modelName . '_Elements');
     $path = $this->_loadedProfile->getAttribute('projectDirectory');
     $this->_print(' Criando Tables ');
     ZendT_Tool_Crud_Table::create($path, $config);
     $this->_print(' Criando Mappers ');
     ZendT_Tool_Crud_Mapper::create($path, $config);
     $this->_print(' Criando MapperView ');
     ZendT_Tool_Crud_MapperView::create($path, $config);
     $this->_print(' Criando Elements ');
     ZendT_Tool_Crud_Element::create($path, $config);
     $this->_print(' Criando Form ');
     ZendT_Tool_Crud_Form::create($path, $config);
     $this->_print(' Criando Bootstrap ');
     ZendT_Tool_Crud_Bootstrap::create($path, $config, 1);
     $this->_print('Finalizado Factory ' . $table);
 }
开发者ID:rtsantos,项目名称:mais,代码行数:84,代码来源:CrudTProvider.php

示例3: create

    /**
     * Cria as classes de Elemento 
     * 
     * @param string $pathBase
     * @param array $config 
     */
    public static function create($pathBase, $config)
    {
        if (!isset($config['table']['modelName'])) {
            $config['table']['modelName'] = $config['table']['name'];
        }
        $modelName = ZendT_Lib::convertTableNameToClassName($config['table']['modelName']);
        if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
            $config['table']['moduleName'] = 'Application';
            $path = 'application/forms/Crud';
        } else {
            $path = 'application/modules/' . $config['table']['moduleName'] . '/forms/' . $modelName . '/Crud';
        }
        ZendT_Lib::createDirectory($pathBase, $path);
        $filename = $pathBase . '/' . $path . '/Elements.php';
        $strBody = '';
        foreach ($config['table']['columns'] as $column => $prop) {
            //echo $column . ' :: ' . $prop['object']['type'] . "\n";
            if (strpos($column, '_type') !== false || strpos($column, '_name') !== false) {
                $name = str_replace(array('_type', '_name'), '', $column);
                $_propLob = $config['table']['columns'][$name];
                if ($_propLob['object']['type'] == 'File') {
                    continue;
                }
            }
            $tableColumn = $column;
            $strValidators = '';
            if (is_array($prop['object']['validators'])) {
                foreach ($prop['object']['validators'] as $validator) {
                    $strValidators .= ",'{$validator['name']}'";
                }
            }
            $strValidators = 'array(' . substr($strValidators, 1) . ')';
            if ($prop['object']['type'] == 'Seeker') {
                $strAttrId = '';
                if (isset($prop['object']['seeker']['id'])) {
                    foreach ($prop['object']['seeker']['id'] as $key => $value) {
                        if ($value) {
                            $strAttrId .= ",'{$key}'=>'{$value}'";
                        }
                    }
                }
                $strAttrId = 'array(' . substr($strAttrId, 1) . ')';
                $strAttrSearch = '';
                if ($prop['object']['seeker']['search']) {
                    foreach ($prop['object']['seeker']['search'] as $key => $value) {
                        if ($value) {
                            $strAttrSearch .= ",'{$key}'=>'{$value}'";
                        }
                    }
                    //$strAttrSearch.= ",'id'=>'$tableColumn'";
                    $strAttrSearch = 'array(' . substr($strAttrSearch, 1) . ')';
                }
                $strAttrDisplay = '';
                if ($prop['object']['seeker']['display']) {
                    foreach ($prop['object']['seeker']['display'] as $key => $value) {
                        if ($value) {
                            $strAttrDisplay .= ",'{$key}'=>'{$value}'";
                        }
                    }
                }
                $strAttrDisplay = 'array(' . substr($strAttrDisplay, 1) . ')';
                $namePrepare = '';
                if (substr(strtolower($tableColumn), 0, 3) == 'id_') {
                    $nameSeeker = substr(strtolower($tableColumn), 3);
                    $namePrepare = "\$element->setSuffix('{$nameSeeker}');";
                } elseif (substr(strtolower($tableColumn), 0, 2) == 'id') {
                    $nameSeeker = substr(strtolower($tableColumn), 2);
                    $namePrepare = "\$element->setSuffix('{$nameSeeker}');";
                } elseif (substr(strtolower($tableColumn), strlen($tableColumn) - 3, 3) == '_id') {
                    $nameSeeker = substr(strtolower($tableColumn), 0, strlen($tableColumn) - 3);
                    $namePrepare = "\$element->setPrefix('{$nameSeeker}');";
                } elseif (substr(strtolower($tableColumn), strlen($tableColumn) - 2, 2) == 'id') {
                    $nameSeeker = substr(strtolower($tableColumn), 0, strlen($tableColumn) - 2);
                    $namePrepare = "\$element->setPrefix('{$nameSeeker}');";
                } else {
                    $nameSeeker = $tableColumn;
                    $namePrepare = "\$element->setSuffix('{$nameSeeker}');";
                }
                //
                if (!isset($prop['object']['seeker']['url']['mapperView'])) {
                    $mapperViewAux = explode('/', $prop['object']['seeker']['url']['grid']);
                    $mapperView['module'] = ucfirst($mapperViewAux[1]);
                    $mapperViewAux = explode('-', $mapperViewAux[2]);
                    $mapperView['name'] = '';
                    foreach ($mapperViewAux as $mapperViewName) {
                        $mapperView['name'] .= ucfirst($mapperViewName);
                    }
                    $prop['object']['seeker']['url']['mapperView'] = $mapperView['module'] . '_DataView_' . $mapperView['name'] . '_MapperView';
                }
                $commentElement = 'ZendT_Form_Element_Seeker';
                if ($prop['object']['seeker']['url']['retrieve'] == '') {
                    $prop['object']['seeker']['url']['retrieve'] = $prop['object']['seeker']['url']['retrive'];
                }
                $suffix = '';
//.........这里部分代码省略.........
开发者ID:rtsantos,项目名称:mais,代码行数:101,代码来源:Element.php

示例4: create

 /**
  * Cria o script de linguagem :: dicionário de dados
  * 
  * @param string $pathBase
  * @param array $config 
  */
 public static function create($pathBase, $config)
 {
     if (!isset($config['table']['modelName'])) {
         $config['table']['modelName'] = $config['table']['name'];
     }
     if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
         $config['table']['moduleName'] = 'Application';
         $path = 'application/languages';
     } else {
         $path = 'application/modules/' . $config['table']['moduleName'] . '/languages';
     }
     ZendT_Lib::createDirectory($pathBase, $path);
     $filename = $path . '/pt_BR.php';
     $dataTranslate = array();
     if (file_exists($filename)) {
         $dataTranslate = (require $filename);
     }
     if (!isset($dataTranslate['operacao'])) {
         $dataTranslate['operacao'] = 'Operação';
     }
     if (!isset($dataTranslate['valor'])) {
         $dataTranslate['valor'] = 'Valor';
     }
     if (!isset($dataTranslate['portalName'])) {
         $dataTranslate['portalName'] = 'Portal TA';
     }
     if (!isset($dataTranslate['moduleName'])) {
         $dataTranslate['moduleName'] = ZendT_Tool_Crud::getModuleName($pathBase, $config['table']['moduleName']);
     }
     $controllerName = str_replace('_', '-', $config['table']['modelName']);
     $form = $config['table']['moduleName'] . '.' . $controllerName . '.form';
     if (!isset($dataTranslate[$form])) {
         $dataTranslate[$form] = 'Cadastro de ' . $config['table']['description'];
     }
     $grid = $config['table']['moduleName'] . '.' . $controllerName . '.grid';
     if (!isset($dataTranslate[$grid])) {
         $dataTranslate[$grid] = 'Listagem de ' . $config['table']['description'];
     }
     //{$reference['tableNameReference']}.{$prop['object']['seeker']['field']['search']}
     /* depreciado
         * $search = $config['table']['moduleName'].'.'.$controllerName.'.search';
        if (!isset($dataTranslate[$search])) {
            $dataTranslate[$search] = 'Pesquisa de '.$config['table']['description'];
        }*/
     $index = $config['table']['name'];
     if (!isset($dataTranslate[$index])) {
         $dataTranslate[$index] = $config['table']['description'];
     }
     if (!$config['table']['alias']) {
         $config['table']['alias'] = $config['table']['name'];
     }
     foreach ($config['table']['columns'] as $column => $prop) {
         if ($dataTranslate["{$config['table']['alias']}.{$column}"] == $column) {
             unset($dataTranslate["{$config['table']['alias']}.{$column}"]);
         }
         if (!isset($dataTranslate["{$config['table']['alias']}.{$column}"])) {
             $dataTranslate["{$config['table']['alias']}.{$column}"] = $prop['label'];
         }
         if ($prop['object']['type'] == 'Seeker') {
             $reference = ZendT_Tool_Crud::getReference($config, $column);
             $configRelation = ZendT_Tool_Crud::getConfig($pathBase, $reference['tableNameReference'], $reference['schemaNameReference']);
             /**
              * Busca o label da tabela de relacionamento, indo no dicionário de dados da tabela de referência
              */
             if ($configRelation['table']['moduleName'] == '' || $configRelation['table']['moduleName'] == 'Application') {
                 $configRelation['table']['moduleName'] = 'Application';
                 $pathRelation = 'application/languages';
             } else {
                 $pathRelation = 'application/modules/' . $configRelation['table']['moduleName'] . '/languages';
             }
             $filenameRelation = $pathRelation . '/pt_BR.php';
             if (file_exists($filenameRelation)) {
                 $dataTranslateRelation = (require $filenameRelation);
             }
             $label['search'] = $dataTranslateRelation["{$reference['tableNameReference']}.{$prop['object']['seeker']['field']['search']}"];
             if ($prop['object']['seeker']['field']['display']) {
                 $label['display'] = $dataTranslateRelation["{$reference['tableNameReference']}.{$prop['object']['seeker']['field']['display']}"];
             }
             /**
              * Pega os campos de relação 2 nível do display
              */
             if (isset($prop['object']['seeker']['relation']) && $label['display'] == '') {
                 foreach ($prop['object']['seeker']['relation'] as $relation) {
                     if ($relation['moduleNameReference'] == '' || $relation['moduleNameReference'] == 'Application') {
                         $relation['moduleNameReference'] = 'Application';
                         $pathRelation = 'application/languages';
                     } else {
                         $pathRelation = 'application/modules/' . $relation['moduleNameReference'] . '/languages';
                     }
                     $filenameRelation = $pathRelation . '/pt_BR.php';
                     if (file_exists($filenameRelation)) {
                         $dataTranslateRelation = (require $filenameRelation);
                     }
                     foreach ($relation['columnDisplay'] as $columnDisplay) {
//.........这里部分代码省略.........
开发者ID:rtsantos,项目名称:mais,代码行数:101,代码来源:Language.php

示例5: formSearchView

    /**
     * Cria o script de pesquisa dos dados
     * 
     * @param string $pathBase
     * @param array $config 
     */
    public static function formSearchView($pathBase, $config)
    {
        if (!isset($config['table']['modelName'])) {
            $config['table']['modelName'] = $config['table']['name'];
        }
        $nameViewController = str_replace('_', '-', $config['table']['modelName']);
        if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
            $config['table']['moduleName'] = 'Application';
            $path = 'application/views/scripts/' . $nameViewController;
        } else {
            $path = 'application/modules/' . $config['table']['moduleName'] . '/views/scripts/' . $nameViewController;
        }
        ZendT_Lib::createDirectory($pathBase, $path);
        $filename = $path . '/search.phtml';
        $contentText = <<<EOS
<?php
    echo \$this->form;
?>
EOS;
        if (!file_exists($filename)) {
            file_put_contents($filename, $contentText);
        }
    }
开发者ID:rtsantos,项目名称:mais,代码行数:29,代码来源:View.php

示例6: createView

    public static function createView($pathBase, $name, $configTable)
    {
        $modelName = ZendT_Lib::convertTableNameToClassName($configTable['table']['name']);
        $className = ZendT_Lib::convertTableNameToClassName($name);
        if ($configTable['table']['moduleName'] == '' || $configTable['table']['moduleName'] == 'Application') {
            $configTable['table']['moduleName'] = 'Application';
            $path = 'application/models/View';
        } else {
            $path = 'application/modules/' . $configTable['table']['moduleName'] . '/models/' . $modelName . '/View';
        }
        $ucModuleName = ucfirst($configTable['table']['moduleName']);
        ZendT_Lib::createDirectory($pathBase, $path);
        $contentText = <<<EOS
<?php
    /**
    * Classe de visão da tabela {$configTable['table']['name']}
    */
    class {$ucModuleName}_Model_{$modelName}_View_{$className} extends {$ucModuleName}_Model_{$modelName}_Mapper implements ZendT_Db_View
    {
        /**
         * Retorna as configurações padrão da visualização
         *
         * @return array
         */
        protected function _getSettingsDefault(){
           \$profile = array();
           \$profile['order'] = array();
           \$profile['width'] = array();
           \$profile['align'] = array();
           \$profile['hidden'] = array();
           \$profile['remove'] = array();
           \$profile['listOptions'] = array();
           return \$profile;
        }
        /**
         * Carrega as colunas com suas configurações 
         */
        protected function _loadColumns(){
            \$this->_columns = new ZendT_Db_Column_View('{$ucModuleName}_Model_{$modelName}_View_{$className}',\$this->_getSettingsDefault());
        }
        /**
         * Retorna o SQL Base
         */
        protected function _getSqlBase() {
            \$sql = \$this->getModel()->getTableName() . ' {$configTable['table']['name']} ';
            return \$sql;
        }
    }
?>
EOS;
        $filename = $path . '/' . $className . '.php';
        echo $filename;
        file_put_contents($filename, $contentText);
    }
开发者ID:rtsantos,项目名称:mais,代码行数:54,代码来源:MapperView.php

示例7: create

    /**
     * Cria as classes de Mappero 
     * 
     * @param string $pathBase
     * @param array $config 
     */
    public static function create($pathBase, $config)
    {
        if (!isset($config['table']['modelName'])) {
            $config['table']['modelName'] = $config['table']['name'];
        }
        $modelName = ZendT_Lib::convertTableNameToClassName($config['table']['modelName']);
        if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
            $config['table']['moduleName'] = 'Application';
            $path = 'application/models/Crud';
        } else {
            $path = 'application/modules/' . $config['table']['moduleName'] . '/models/' . $modelName . '/Crud';
        }
        $ucModuleName = ucfirst($config['table']['moduleName']);
        ZendT_Lib::createDirectory($pathBase, $path);
        $tabs = $config['table']['tabs'];
        if (!$tabs) {
            $tabs = array();
        }
        $tabs = var_export($tabs, true);
        $strReferenceMap = '';
        foreach ($config['table']['referenceMaps'] as $prop) {
            $referenceName = ZendT_Lib::convertTableNameToClassName($prop['columnName']);
            $strReferenceMap .= ",\n                '" . $prop['columnName'] . "' => array(\n                    'mapper' => '" . str_replace('_Model_', '_DataView_', $prop['objectNameReference']) . "_MapperView',\n                    'column' => '" . $prop['columnReference'] . "'\n                )";
        }
        $strReferenceMap = substr($strReferenceMap, 1);
        $strBody = '';
        $strRequired = '';
        foreach ($config['table']['columns'] as $column => $prop) {
            //print_r($prop['object']['filter']);
            $strFilter = 'array(';
            if (isset($prop['object']['filter'])) {
                foreach ($prop['object']['filter'] as $key => $value) {
                    if (is_array($value)) {
                        $strFilter .= "'{$key}' => array('" . implode("','", $value) . "'), ";
                    } else {
                        $strFilter .= "'{$value}', ";
                    }
                }
            }
            $strFilter .= ')';
            $set = "\$this->_data['{$column}'] = \$value;";
            if (in_array($prop['object']['type'], array('Date', 'DateTime', 'Time'))) {
                $set = "\$this->_data['{$column}'] = new ZendT_Type_Date(\$value,'{$prop['object']['type']}');";
                $set .= "\n         if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                    ";
            } elseif (in_array($prop['object']['type'], array('Numeric', 'Integer')) || in_array($prop['type'], array('Numeric', 'Integer'))) {
                #echo $column . "\n";
                $numDecimal = $prop['object']['numeric']['numDecimal'];
                if (strtolower($prop['object']['type']) == strtolower('Seeker') || in_array(strtolower($column), $config['table']['primary'])) {
                    $numDecimal = 'null';
                } else {
                    if (!$numDecimal) {
                        $numDecimal = 0;
                    }
                }
                $set = "\$this->_data['{$column}'] = new ZendT_Type_Number(\$value,array('numDecimal'=>{$numDecimal}));";
                $set .= "\n         if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                    ";
            } else {
                if (in_array($prop['type'], array('StringLong'))) {
                    $set = "\n         \$this->_data['{$column}'] = new ZendT_Type_Clob(\$value);";
                    $set .= "\n         if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                ";
                } else {
                    if (in_array($prop['object']['type'], array('File'))) {
                        $set = "\$this->_data['{$column}'] = new ZendT_Type_Blob(\$value);\n         if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                ";
                    } else {
                        if ($prop['object']['mask'] != NULL) {
                            $set = "\$this->_data['{$column}'] = new ZendT_Type_String(\$value,array('mask'=>" . var_export($prop['object']['mask'], true) . "\n                                                                   ,'charMask'=>" . var_export($prop['object']['charMask'], true) . "\n                                                                   ,'filterDb'=>" . var_export($prop['object']['filterDb'], true) . "\n                                                                   ,'filter'=>" . $strFilter . "));\n        if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                ";
                        } else {
                            if (in_array($prop['object']['type'], array('Text'))) {
                                $set = "\$this->_data['{$column}'] = new ZendT_Type_String(\$value,array('mask'=>''\n                                                                   ,'charMask'=>''\n                                                                   ,'filterDb'=>" . var_export($prop['object']['filterDb'], true) . "\n                                                                   ,'filter'=>" . $strFilter . "));\n        if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                ";
                            } else {
                                if (in_array($prop['object']['type'], array('Select'))) {
                                    $varListOptions = array();
                                    foreach ($prop['object']['listOptions'] as $key => $value) {
                                        if ((string) $key != '') {
                                            $varListOptions[] = "'" . $key . "'=>'" . $value . "'";
                                        }
                                    }
                                    $set = "\n        \$options['listOptions']=array(" . implode(',', $varListOptions) . ");\n        \$this->_data['{$column}'] = new ZendT_Type_String(\$value,\$options);\n        if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                ";
                                } else {
                                    $set = "\$this->_data['{$column}'] = new ZendT_Type_String(\$value);\n        if (\$options['db'])\n            \$this->_data['{$column}']->setValueFromDb(\$value);\n                ";
                                }
                            }
                        }
                    }
                }
            }
            $strValidators = '';
            if ($prop['object']['required']) {
                $strRequired .= ",'{$column}'";
                $strValidators .= "\n         if (\$options['required'])\n            \$this->isRequired(\$value,'{$column}');\n                    ";
            }
            if (is_array($prop['object']['validators'])) {
                foreach ($prop['object']['validators'] as $validator) {
                    $strValidators .= "\n            \$valid = new " . $validator['name'] . "(" . str_replace("\n", " ", var_export($validator['param'], true)) . " );\n            \$valueValid = \$this->_data['{$column}']->getValueToDb();\n            if (\$valueValid && !\$valid->isValid(\$valueValid)){\n                throw new ZendT_Exception_Business(implode(\"\\n\",\$valid->getMessages()));\n            }\n                    ";
//.........这里部分代码省略.........
开发者ID:rtsantos,项目名称:mais,代码行数:101,代码来源:Mapper.php

示例8: developerTable

    /**
     * Cria o modelo do desenvolvedor que pode manipular os dados
     * 
     * @param string $pathBase
     * @param array $config 
     */
    public static function developerTable($pathBase, $config)
    {
        if (!isset($config['table']['modelName'])) {
            $config['table']['modelName'] = $config['table']['name'];
        }
        $modelName = ZendT_Lib::convertTableNameToClassName($config['table']['modelName']);
        if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
            $config['table']['moduleName'] = 'Application';
            $path = 'application/models';
        } else {
            $path = 'application/modules/' . $config['table']['moduleName'] . '/models/' . $modelName;
        }
        ZendT_Lib::createDirectory($pathBase, $path);
        $filename = $pathBase . '/' . $path . '/Table.php';
        $ucModuleName = ucfirst($config['table']['moduleName']);
        $contentText = <<<EOS
<?php
    /**
     * Classe de mapeamento da tabela {$config['table']['name']}
     */
    class {$ucModuleName}_Model_{$modelName}_Table extends {$ucModuleName}_Model_{$modelName}_Crud_Table{

    }
?>
EOS;
        if (!file_exists($filename)) {
            file_put_contents($filename, $contentText);
        }
    }
开发者ID:rtsantos,项目名称:mais,代码行数:35,代码来源:Table.php

示例9: create

    /**
     * Cria as classes de Serviço 
     * 
     * @param string $pathBase
     * @param array $config 
     */
    public static function create($pathBase, $name, $module)
    {
        $modelName = ZendT_Lib::convertTableNameToClassName($name);
        $moduleName = $module;
        if ($moduleName == '' || $moduleName == 'Application') {
            $moduleName = 'Application';
            $path = 'application/reports';
        } else {
            $path = 'application/modules/' . $moduleName . '/reports';
        }
        $ucModuleName = ucfirst($moduleName);
        ZendT_Lib::createDirectory($pathBase, $path);
        $filename = $path . '/' . $modelName . '.php';
        $contentText = <<<EOS
<?php
    /**
     * Classe de relatório {$modelName}
     *
     * @package ZendT
     * @subpackage Report
     */
    class {$ucModuleName}_Report_{$modelName}{
        /**
         * @var ZendT_Report_Abstract
         */
        protected \$_report;
        /**
         * @var ZendT_Db_Mapper
         */
        protected \$_mapper;
        /**
         * Construtor
         */
        public function __construct(\$driver,ZendT_Db_Mapper \$_mapper){
            \$this->_report = ZendT_Report::factory(\$driver);
            \$this->_mapper = \$_mapper;
            
            \$this->_report->setTitle('Título do Relatório');
            \$this->_report->addPage();
            
            \$row = array();
            \$row['column'] = 'column';
            \$this->_addRow(\$row,true);
            \$this->_report->drawLine();
        }
        /**
         *
         * @param array \$row
         * @param bool \$title
         */
        private function _addRow(\$row,\$title=false){
            \$_cell = new ZendT_Report_Cell();
            \$_cell->setValue(\$row['column']);
            \$_cell->setWidth(200);
            \$_cell->setType('String');
            \$_cell->setFontWeight(\$title);
            \$this->_report->addCell(\$_cell);
            
            \$this->_report->printCells();
        }
        /**
         *
         * @return ZendT_Db_Recordset
         */
        private function _getRecodset(){
            \$sql = "SELECT * FROM ".\$this->_mapper->getModel()->getTableName();
            \$stmt = \$this->_mapper->getModel()->getAdapter()->query(\$sql);
            \$columnMappers = new ZendT_Db_Column_Mapper();
            \$columnMappers->add('column', \$this->_mapper->getColumn(true));
            \$rs = new ZendT_Db_Recordset(\$stmt,\$columnMappers,true);
            return \$rs;
        }
        /**
         *
         */
        private function _make(){
            \$recordset = \$this->_getRecodset();
            while(\$row = \$recordset->getRow()){
                \$this->_addRow(\$row,false);
            }
            \$this->_report->drawLine();
        }
        /**
         *
         */
        public function show(\$dest='S'){
            \$this->_make();
            return \$this->_report->output('relatorio',\$dest);
        }
    }
?>
EOS;
        file_put_contents($filename, $contentText);
    }
开发者ID:rtsantos,项目名称:mais,代码行数:100,代码来源:Report.php

示例10: editForm

    /**
     * Cria o formulário de edição
     * 
     * @param string $pathBase
     * @param array $config 
     */
    public static function editForm($pathBase, $config)
    {
        if (!isset($config['table']['modelName'])) {
            $config['table']['modelName'] = $config['table']['name'];
        }
        $modelName = ZendT_Lib::convertTableNameToClassName($config['table']['modelName']);
        if ($config['table']['moduleName'] == '' || $config['table']['moduleName'] == 'Application') {
            $config['table']['moduleName'] = 'Application';
            $path = 'application/forms';
        } else {
            $path = 'application/modules/' . $config['table']['moduleName'] . '/forms/' . $modelName . '/Crud';
        }
        $ucModuleName = ucfirst($config['table']['moduleName']);
        ZendT_Lib::createDirectory($pathBase, $path);
        $filename = $path . '/Edit.php';
        $strBody = '';
        foreach ($config['table']['columns'] as $column => $prop) {
            if (strpos($column, '_type') !== false || strpos($column, '_name') !== false) {
                $name = str_replace(array('_type', '_name'), '', $column);
                $_propLob = $config['table']['columns'][$name];
                if ($_propLob['object']['type'] == 'File') {
                    continue;
                }
            }
            if ($prop['multiple']) {
                $strBody .= "\n        for(\$i=0; \$i<\$this->_multiple['{$column}']; \$i++){\n            \$element = \$model->getElement('{$column}[\$i]');";
                if ($prop['object']['required']) {
                    $strBody .= "\n            \$element->setRequired(true);";
                }
                $strBody .= "\n            \$element->setBelongsTo('{$column}');\n        }\n                ";
            } else {
                $strBody .= "\n            \$element = \$model->getElement('{$column}');";
                if ($prop['object']['required']) {
                    $strBody .= "\n            \$element->setRequired(true);";
                }
            }
            if (count($config['table']['primary']) == 1) {
                if (strtolower($config['table']['primary'][0]) == strtolower($column)) {
                    $strBody .= "\n            \$element->addDecorator(new ZendT_Form_Decorator_Hidden());\n            \$element->setRequired(false);\n                    ";
                }
            }
            $strBody .= "\n            \$this->addElement(\$element);\n\n            ";
        }
        $elementId = '';
        if (count($config['table']['primary']) > 1) {
            $elementId .= "\n            \$element = new ZendT_Form_Element_Hidden('id');\n            \$element->addDecorator(new ZendT_Form_Decorator_Hidden());\n            \$element->setRequired(false);\n            \$this->addElement(\$element);\n            ";
        }
        $url = 'array()';
        if (count($config['table']['form']['url']) > 1) {
            $url = var_export($config['table']['form']['url'], true);
        }
        $formName = strtolower($config['table']['name']);
        $contentText = <<<EOS
<?php
    class {$ucModuleName}_Form_{$modelName}_Crud_Edit extends ZendT_Form {
        /**
         * Configura se uma coluna é multipla
         * @var array
         */
        protected \$_multiple;
        /**
         * @var array
         */
        protected \$_url = {$url};
        /**
         * Carrega os elementos no formulário para serem renderizado
         * @return void
         */
        public function loadElements(\$action='insert') {
            \$this->setName('frm_{$formName}');
            {$elementId}
    
            \$model = new {$ucModuleName}_Form_{$modelName}_Elements();
            {$strBody}
        }
        /**
         * Configura uma coluna para ser multipla, ou seja,
         * transformar um dado em array
         *
         * @return void
         */        
        public function setMultiple(\$column,\$numRepeat){
            \$this->_multiple[\$column] = \$numRepeat;
        }
    }
?>
EOS;
        file_put_contents($filename, $contentText);
        $contentText = <<<EOS
<?php
    class {$ucModuleName}_Form_{$modelName}_Edit extends {$ucModuleName}_Form_{$modelName}_Crud_Edit {
        /**
         * Carrega os elementos no formulário para serem renderizado
         * @return void
//.........这里部分代码省略.........
开发者ID:rtsantos,项目名称:mais,代码行数:101,代码来源:Form.php


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