public static function addEditor() { $container = Container::getInstance(); $config = $container->get('app')->getConfig(); $config = isset($config['editor']) ? $config['editor'] : NULL; if ($config) { $name = !empty($config['name']) ? $config['name'] : null; $version = !empty($config['version']) ? $config['version'] : null; $options = !empty($config['options']) ? json_encode($config['options']) : null; if ($name == 'ckeditor') { self::addJquery(); self::addCkeditor($version, $options); } elseif ($name == 'tinymce') { self::addJquery(); self::addTinyMCE($version, $options); } } }
public function getEntityManager($smart = FALSE, $path_to_entity = null, $proxyPath = null, $proxyNamespace = null) { // if (!self::em) { // if ($path_to_entity === NULL) { // $path_to_entity = self::app->getEntitiesPathes(); // } // //$applicationMode = !empty(Sokol::$app->config['app']['mode']) ? Sokol::$app->config['app']['mode'] : 'development'; // //$isDev = Sokol::getApp()->isDev; // $config = self::app->getConfig(); // $connectionParams = isset($config['db']) ? $config['db'] : NULL; // //var_dump($connectionParams);die; // //---Table Prefix--- // $tablePrefix = !empty($connectionParams['tablePrefix']) ? $connectionParams['tablePrefix'] : null; // if ($tablePrefix) { // $evm = new \Doctrine\Common\EventManager; // $tablePrefix = new TablePrefix($tablePrefix); // $evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix); // } // //---/Table Prefix--- // if ($smart) { // self::em = self::getEmSmart($path_to_entity, $isDev, $connectionParams, $evm); // } else { // if ($proxyPath === NULL) // $proxyPath = self::app->getProxyDir(); // if ($proxyNamespace === NULL) // $proxyNamespace = self::app->getProxyNameSpace(); // self::em = self::getEm($path_to_entity, self::isDev, $connectionParams, $evm, $proxyPath, $proxyNamespace); // } // //подключаем тип данных "html" // Type::addType('html', 'Core\DoctrineExtensions\HtmlType'); // self::em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('db_html', 'html'); // } // return self::em; $container = Container::getInstance(); $app = $container->get('app'); return $app->getEntityManager(); }
/** * * @return \Phpnik\Core\Container */ public function getContainer() { return Container::getInstance(); }
public function get() { $container = Container::getInstance(); $app = $container->get('app'); $contr = $app->getController(); $html = '<table style="width:100%;">'; $metadata = $this->getMetadata(); //echo '<pre>';var_dump($metadata); $columns = $this->getColumns(); $values = $this->getValues(); $this->getRequired(); foreach ($columns as $column => $label) { if (isset($metadata->associationMappings[$column])) { $row = $metadata->associationMappings[$column]; if (Doctrine::isManyToOne($metadata, $column)) { $class = $row['targetEntity']; $name = $row['fieldName']; $method = 'get_' . $name; $method = Camel::to_camel_case($method); $obj = $this->entity->{$method}(); $value = !empty($obj) ? $obj->getId() : 0; $class_meta = $this->em->getClassMetadata($class); if (isset($class_meta->fieldMappings['path_alias'])) { $items = $this->em->getRepository($class)->findBy(array(), array('path_alias' => 'ASC')); } else { $items = $this->em->getRepository($class)->findAll(); } $attributes = array('required' => $this->has($name, $this->required), 'style' => 'width: 100%;'); $html .= '<tr><td>' . $label . '</td><td>' . self::getSelect($name, $value, $items, $attributes) . '</td></tr>'; } elseif (Doctrine::isManyToMany($metadata, $column)) { $class = $row['targetEntity']; $name = $row['fieldName']; $method = 'get_' . $name; $method = Camel::to_camel_case($method); $arr = $this->entity->{$method}(); $class_meta = $this->em->getClassMetadata($class); if (isset($class_meta->fieldMappings['path_alias'])) { $items = $this->em->getRepository($class)->findBy(array(), array('path_alias' => 'ASC')); } else { $items = $this->em->getRepository($class)->findAll(); } $attributes = array('required' => $this->has($name, $this->required), 'style' => 'width: 100%;'); $html .= '<tr><td>' . $label . '</td><td>' . self::getMulti($name . '[]', $arr, $items, $attributes) . '</td></tr>'; } } else { $row = $metadata->fieldMappings[$column]; $name = $row['fieldName']; $primary = isset($row['id']) && $row['id'] == TRUE; $type = $row['type']; $length = isset($row['length']) ? $row['length'] : null; $value = $values->{$name}; $attributes = array('required' => $this->has($name, $this->required)); $html .= '<tr><td>' . $label . '</td><td>' . self::getInput($type, $name, $value, $length, $primary, $attributes) . '</td></tr>'; } } $html .= '</table>'; $html .= HTML::submit('submit', 'Сохранить'); $form_atr = array('action' => $app->generateURL('default', array('_component' => $contr->getComponentName(), '_controller' => $contr->getControllerName(), '_action' => 'save')), 'method' => 'POST', 'style' => 'width: 100%;'); return HTML::form($html, $form_atr); }