function __construct($connectionNumber = 0) { $this->connection = org_glizy_dataAccessDoctrine_DataAccess::getConnection($connectionNumber); $this->data = new StdClass(); $this->virtualData = new StdClass(); $this->driverName = __Config::get('DB_TYPE' . ($connectionNumber == 0 ? '' : '#' . $connectionNumber)); }
function init() { if (__Config::get('QUERY_CACHING_INIT')) { org_glizy_dataAccessDoctrine_DataAccess::initCache(); } glz_loadLocale('org.glizycms.*'); glz_loadLocale('org.glizycms.contents.*'); glz_loadLocale('org.glizycms.languages.*'); $application = org_glizy_ObjectValues::get('org.glizy', 'application'); if ($application) { if (!$application->isAdmin()) { org_glizy_ObjectFactory::remapClass('org.glizy.components.Page', 'org.glizycms.views.components.Page'); org_glizy_ObjectFactory::remapClass('org.glizy.mvc.components.Page', 'org.glizycms.views.components.MvcPage'); org_glizycms_userManager_fe_Module::registerModule(); } // la creazione dell'istanza serve per il listener $speakingUrlManager = $application->registerProxy('org.glizycms.speakingUrl.Manager'); // registra il resolver di default org_glizycms_speakingUrl_Manager::registerResolver(org_glizy_ObjectFactory::createObject('org.glizycms.speakingUrl.PageResolver')); } if (is_null(__Config::get('glizycms.sitemap.cacheLife'))) { __Config::set('glizycms.sitemap.cacheLife', 36000); } if (is_null(__Config::get('glizycms.content.history', ''))) { __Config::set('glizycms.content.history', true); } if (is_null(__Config::get('glizycms.content.history.comment', ''))) { __Config::set('glizycms.content.history.comment', false); } __Config::set('glizy.dataAccess.document.enableComment', __Config::get('glizycms.content.history.comment')); if (is_null(__Config::get('glizycms.pageEdit.editUrlEnabled', ''))) { __Config::set('glizycms.pageEdit.editUrlEnabled', true); } if (is_null(__Config::get('glizycms.mediaArchive.exifEnabled', ''))) { __Config::set('glizycms.mediaArchive.exifEnabled', false); } if (is_null(__Config::get('glizycms.speakingUrl', ''))) { __Config::set('glizycms.speakingUrl', false); } if (is_null(__Config::get('glizycms.content.showAllPageTypes', ''))) { __Config::set('glizycms.content.showAllPageTypes', true); } if (is_null(__Config::get('glizycms.form.actionLink.cssClass', ''))) { __Config::set('glizycms.form.actionLink.cssClass', 'btn action-link'); } if (is_null(__Config::get('glizycms.print.enabled', ''))) { __Config::set('glizycms.print.enabled', false); } if (is_null(__Config::get('glizycms.print.pdf.enabled', ''))) { __Config::set('glizycms.print.pdf.enabled', false); } if (is_null(__Config::get('glizycms.mediaArchive.bridge', ''))) { __Config::set('glizycms.mediaArchive.bridge', 'org.glizycms.mediaArchive.Bridge'); } self::$mediaArchiveBridge = org_glizy_ObjectFactory::createObject(__Config::get('glizycms.mediaArchive.bridge')); if ($application && __Config::get('glizycms.mediaArchive.mediaMappingEnabled')) { $application->registerProxy('org.glizycms.mediaArchive.services.MediaMappingService'); } }
function __construct($connectionNumber = 0) { parent::__construct($connectionNumber); $this->setTableName('documents_tbl', org_glizy_dataAccessDoctrine_DataAccess::getTablePrefix($connectionNumber)); $sm = new org_glizy_dataAccessDoctrine_SchemaManager($this->connection); $sequenceName = $sm->getSequenceName($this->getTableName()); $this->setSequenceName($sequenceName); $fields = $sm->getFields($this->getTableName()); foreach ($fields as $field) { $this->addField($field); } $this->addRelation(array('type' => 'joinTable', 'name' => 'rel_aclEdit', 'className' => 'org.glizy.models.JoinDoctrine', 'field' => 'join_FK_source_id', 'destinationField' => 'join_FK_dest_id', 'bindTo' => '__aclEdit', 'objectName' => '')); $this->addRelation(array('type' => 'joinTable', 'name' => 'rel_aclView', 'className' => 'org.glizy.models.JoinDoctrine', 'field' => 'join_FK_source_id', 'destinationField' => 'join_FK_dest_id', 'bindTo' => '__aclView', 'objectName' => '')); $this->setProcessRelations(true); }
function execute($mediaPath, $languageId, $languageCode, $menuIdArray, $title, $subtitle, $creditPageId, $isExhibitionActive) { if ($this->user->isLogged()) { $mobileContentsTable = __Config::get('movio.modules.publishApp.mobileContentsTable'); org_glizy_dataAccessDoctrine_DataAccess::truncateTable($mobileContentsTable); $mobileFulltextTable = __Config::get('movio.modules.publishApp.mobileFulltextTable'); org_glizy_dataAccessDoctrine_DataAccess::truncateTable($mobileFulltextTable); $exportService = org_glizy_ObjectFactory::createObject('movio.modules.publishApp.service.ExportService'); $exportService->export($languageId, $languageCode, $menuIdArray, $title, $subtitle, $creditPageId, $isExhibitionActive); $medias = $exportService->getMedias(); foreach ($medias as $id => $fileName) { $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id); @copy($media->getFileName(), $mediaPath . $fileName); } return $exportService->getGraphs(); } }
function execute($exportPath, $languages, $mediaPath, $graphPath, $zipFolder, $zipFile) { if ($this->user->isLogged()) { org_glizy_helpers_Files::deleteDirectory($exportPath); @unlink($zipFile); @mkdir($exportPath); @mkdir($mediaPath); @mkdir($graphPath); @mkdir($graphPath . 'document'); foreach ($languages as $language) { $ar = __ObjectFactory::createModel('org.glizycms.core.models.Language'); $ar->load($language); @mkdir($graphPath . $ar->language_code); @mkdir($graphPath . 'document/' . $ar->language_code); } @mkdir($zipFolder); @chmod($zipFolder, 0777); $mobileCodesTable = __Config::get('movio.modules.publishApp.mobileCodesTable'); org_glizy_dataAccessDoctrine_DataAccess::truncateTable($mobileCodesTable); } }
function process_ajax() { $aColumns = array(); foreach ($this->columns as $column) { if (!in_array($column['columnName'], $aColumns)) { $aColumns[] = $column['columnName']; } } $sSearch = __Request::get('sSearch'); $filters = array(); $it = org_glizy_ObjectFactory::createModelIterator($this->getAttribute('recordClassName')); if ($it->getArType() === 'document') { $it->setOptions(array('type' => 'PUBLISHED_DRAFT')); } if ($this->getAttribute('setFiltersToQuery')) { for ($i = 0; $i < count($aColumns); $i++) { if (__Request::get('sSearch_' . $i)) { $filters[$aColumns[$i]] = __Request::get('sSearch_' . $i); } else { if ($sSearch != '' && __Request::get('bSearchable_' . $i) == "true") { $filters[$aColumns[$i]] = $sSearch; } } } $it->load($this->getAttribute('query'), array('filters' => $filters)); } else { $it->load($this->getAttribute('query')); if (method_exists($it, 'showAll')) { $it->showAll(); } if ($this->getAttribute('fullTextSearch') && $sSearch) { $it->where('fulltext', '%' . $sSearch . '%', 'ILIKE'); } else { for ($i = 0; $i < count($aColumns); $i++) { if (__Request::get('sSearch_' . $i)) { $filters[$aColumns[$i]] = array('value' => __Request::get('sSearch_' . $i), 'condition' => 'LIKE'); } else { if ($sSearch != '' && __Request::get('bSearchable_' . $i) == "true") { $filters[$aColumns[$i]] = array('value' => '%' . $sSearch . '%', 'condition' => 'LIKE'); } } } if (!empty($filters)) { if ($this->getAttribute('queryOperator') === 'OR') { $it->setOrFilters($filters); } else { $it->setFilters($filters); } } } } // Ordering if (__Request::exists('iSortCol_0')) { $iSortingCols = intval(__Request::get('iSortingCols')); for ($i = 0; $i < $iSortingCols; $i++) { if (__Request::get('bSortable_' . intval(__Request::get('iSortCol_' . $i))) == "true") { $order = $aColumns[intval(__Request::get('iSortCol_' . $i))]; $order_dir = __Request::get('sSortDir_' . $i); $it->orderBy($order, $order_dir); break; } } } // Paging if (__Request::get('iDisplayStart', -1) != -1) { $it->limit(array(__Request::get('iDisplayStart'), __Request::get('iDisplayLength', -1))); } $aaData = array(); if ($this->getAttribute('dbDebug')) { org_glizy_dataAccessDoctrine_DataAccess::enableLogging(); } try { foreach ($it as $row) { $rowToInsert = array(); foreach ($this->columns as $column) { if ($column['acl']) { if (!$this->_user->acl($column['acl']['service'], $column['acl']['action'])) { continue; } } $value = $row->{$column}['columnName']; if ($column['renderCell']) { if (!is_object($column['renderCell'])) { $column['renderCell'] = org_glizy_ObjectFactory::createObject($column['renderCell'], $this->_application); } if (is_object($column['renderCell'])) { $value = $column['renderCell']->renderCell($row->getId(), $value, $row, $column['columnName']); } } if (is_object($value)) { $value = json_encode($value); } $rowToInsert[] = $value; } $aaData[] = $rowToInsert; } } catch (Exception $e) { var_dump($e); } if ($this->getAttribute('dbDebug')) { org_glizy_dataAccessDoctrine_DataAccess::disableLogging(); die; } $output = array("sEcho" => intval(__Request::get('sEcho')), "iTotalRecords" => $it->count(), "iTotalDisplayRecords" => $it->count(), "aaData" => $aaData); return $output; }
private static function loadLibrary() { self::$isLibLoaded = true; require_once GLZ_LIBS_DIR . '/Doctrine/Common/ClassLoader.php'; $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\Common', GLZ_LIBS_DIR); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine\\DBAL', GLZ_LIBS_DIR); $classLoader->register(); }
function render() { $tableName = __Request::get('mbTableDB'); $moduleType = __Request::get('mbModuleType'); $fieldOrder = __Request::get('fieldOrder', array()); $fieldRequired = __Request::get('fieldRequired', array()); $fieldType = __Request::get('fieldType', array()); $fieldSearch = __Request::get('fieldSearch', array()); $fieldListSearch = __Request::get('fieldListSearch', array()); $fieldAdmin = __Request::get('fieldAdmin', array()); $fieldLabel = __Request::get('fieldLabel', array()); $fieldPrimaryKey = ''; if ($moduleType == 'document') { $fieldOrder = explode(',', $fieldOrder); } else { if ($moduleType == 'csv') { $fieldOrder = array(); $fieldType = array(); $csvIterator = org_glizy_ObjectFactory::createObject('movio.modules.modulesBuilder.services.CVSImporter', __Request::get('mbCsvOptions')); $fieldLabel = $csvIterator->getHeading(); $i = 0; foreach ($fieldLabel as $f) { if (!$f) { continue; } $fieldOrder[] = 'row_' . $i++; $fieldType[] = 'TEXT'; } } else { $connection = org_glizy_dataAccessDoctrine_DataAccess::getConnection(); $sm = new org_glizy_dataAccessDoctrine_SchemaManager($connection); $fields = $sm->getFields($tableName); $fieldOrder = array(); $fieldType = array(); $fieldLabel = array(); foreach ($fields as $f) { $fieldLabel[] = $f->name; $fieldOrder[] = $f->name; if ($f->key) { $fieldPrimaryKey = $f->name; } switch ($f->type) { case 'text': $type = 'longtext'; break; case 'date': case 'datetime': $type = 'date'; break; default: $type = 'text'; break; } $fieldType[] = $type; } } } $output = '<table id="editTable" class="modulesBuilderTable table table-striped">'; $output .= '<tbody>'; $theadFields = ''; for ($i = 0; $i < count($fieldOrder); $i++) { $type = $fieldType[$i]; $label = $fieldLabel[$i]; $id = $fieldOrder[$i]; $output .= '<tr id="' . $id . '">'; $output .= '<td width="10"><img src="application/templates/images/dragHandler.gif" /></td>'; $output .= '<td>'; $output .= '<input type="text" name="fieldLabel[]" value="' . $label . '" size="30" />'; $output .= '</td>'; $output .= '<td>'; $output .= '<select name="fieldType[]">'; $output .= '<option value="TEXT"' . ($type == 'TEXT' ? ' selected="selected"' : '') . '>' . __T('Testo') . '</option>'; $output .= '<option value="LONG_TEXT_HTML"' . ($type == 'LONG_TEXT_HTML' ? ' selected="selected"' : '') . '>' . __T('Testo descrittivo (html)') . '</option>'; $output .= '<option value="LONG_TEXT"' . ($type == 'LONG_TEXT' ? ' selected="selected"' : '') . '>' . __T('Testo lungo') . '</option>'; $output .= '<option value="DATA"' . ($type == 'DATA' ? ' selected="selected"' : '') . '>' . __T('Data') . '</option>'; $output .= '<option value="DATETIME"' . ($type == 'DATETIME' ? ' selected="selected"' : '') . '>' . __T('Data ora') . '</option>'; $output .= '<option value="CHECKBOX"' . ($type == 'CHECKBOX' ? ' selected="selected"' : '') . '>' . __T('Checkbox') . '</option>'; $output .= '<option value="LIST"' . ($type == 'LIST' ? ' selected="selected"' : '') . '>' . __T('Lista aperta') . '</option>'; $output .= '<option value="URL"' . ($type == 'URL' ? ' selected="selected"' : '') . '>' . __T('Link esterno') . '</option>'; $output .= '<option value="IMAGE"' . ($type == 'IMAGE' ? ' selected="selected"' : '') . '>' . __T('Immagine') . '</option>'; $output .= '<option value="IMAGEURL"' . ($type == 'IMAGEURL' ? ' selected="selected"' : '') . '>' . __T('Immagine esterna') . '</option>'; if ($moduleType == 'document') { $output .= '<option value="IMAGEREPEATER"' . ($type == 'IMAGEREPEATER' ? ' selected="selected"' : '') . '>' . __T('Immagine ripetibile') . '</option>'; } $output .= '<option value="MEDIA"' . ($type == 'MEDIA' ? ' selected="selected"' : '') . '>' . __T('Media') . '</option>'; if ($moduleType == 'document') { $output .= '<option value="MEDIAREPEATER"' . ($type == 'MEDIAREPEATER' ? ' selected="selected"' : '') . '>' . __T('Media ripetibile') . '</option>'; } $output .= '<option value="HIDDEN"' . ($type == 'HIDDEN' ? ' selected="selected"' : '') . '>' . __T('Nascosto') . '</option>'; // $output .= '<option value="PICO"'.( $type == 'PICO' ? ' selected="selected"' : '' ).'>'.__T( 'Pico thesaurus' ).'</option>'; $output .= '</select>'; $output .= '</td>'; $output .= '<td style="text-align: center">'; $output .= '<input type="checkbox" name="fieldRequired[]" value="' . $id . '" ' . (in_array($id, $fieldRequired) ? 'checked="checked"' : '') . '/>'; $output .= '</td>'; $output .= '<td style="text-align: center">'; $output .= '<input type="checkbox" name="fieldSearch[]" value="' . $id . '" ' . (in_array($id, $fieldSearch) ? 'checked="checked"' : '') . '/>'; $output .= '</td>'; $output .= '<td style="text-align: center">'; $output .= '<input type="checkbox" name="fieldListSearch[]" value="' . $id . '" ' . (in_array($id, $fieldListSearch) ? 'checked="checked"' : '') . '/>'; $output .= '</td>'; $output .= '<td style="text-align: center">'; $output .= '<input type="checkbox" name="fieldAdmin[]" value="' . $id . '" ' . (in_array($id, $fieldAdmin) ? 'checked="checked"' : '') . '/>'; $output .= '</td>'; $output .= '</tr>'; } $output .= '</tbody>'; $output .= '<thead>'; $output .= '<tr>'; $output .= '<th></th>'; $output .= '<th><input type="hidden" id="fieldOrder" name="fieldOrder" value="" />'; $output .= '<input type="hidden" id="moduleType" name="moduleType" value="' . ($moduleType != 'db' ? 'document' : 'db') . '" />'; $output .= '<input type="hidden" id="fieldKey" name="fieldKey" value="' . $fieldPrimaryKey . '" />'; $output .= $theadFields . __T('Etichetta') . '</th>'; $output .= '<th>' . __T('Tipologia') . '</th>'; $output .= '<th>' . __T('Obbligatorio') . '</th>'; $output .= '<th>' . __T('Ricerca') . '</th>'; $output .= '<th>' . __T('Lista ricerca') . '</th>'; $output .= '<th>' . __T('Lista amm.') . '</th>'; $output .= '</tr>'; $output .= '</thead>'; $output .= '</table>'; $output .= '<input type="hidden" name="mbModuleType" value="' . $moduleType . '" />'; $output .= '<input type="hidden" name="mbTableDB" value="' . $tableName . '" />'; $this->addOutputCode($output); }
/** * Execute this query using the bound parameters and their types. * * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate} * for insert, update and delete statements. * * @return mixed */ public function execute() { $connection = $this->getConnection(); if ($this->type == self::SELECT) { // TODO migliorare creando un QuerybuiBuilderCache if (__Config::get('QUERY_CACHING') && ($cacheDriver = org_glizy_dataAccessDoctrine_DataAccess::getCache())) { $lifeTime = __Config::get('QUERY_CACHING_LIFETIME'); $sql = $this->getSQL(); $key = md5($sql); return $connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes, new QueryCacheProfile($lifeTime, $key, $cacheDriver)); } else { return $connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes); } } else { return $connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes); } }
public function exec() { if (!$this->querySqlToExec) { $this->finalizeQuery(); } if (empty($this->unionArray)) { if (__Config::get('ACL_ROLES')) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $user = $application->getCurrentUser(); if ($user->id && !$user->acl($application->getPageId(), 'all')) { $this->addAcl(); } } try { parent::exec(); } catch (Exception $e) { require_once org_glizy_Paths::get('CORE_LIBS') . 'sql-formatter/lib/SqlFormatter.php'; $trace = $e->getTrace(); var_dump($trace[0]['args'][0]->errorInfo); echo SqlFormatter::format($sql) . '</br></br>'; var_dump($this->unionArrayParams); } } else { $this->unionArray[] = $this->qb; $this->unionArrayParams = array_merge($this->unionArrayParams, $this->qb->getParameters()); if (!empty($this->unionOrderBy)) { list($fieldName, $order) = $this->unionOrderBy; if (!$this->ar->getField($fieldName)->isSystemField) { $indexType = $this->ar->getIndexFieldType($fieldName); $documentDetailIdName = $this->ar->getDocumentDetailTableIdName(); $documentTableIndexPrefix = $this->ar->getDocumentIndexTablePrefix(); $indexAlias = 'orderIndex'; $indexTablePrefix = $documentTableIndexPrefix . $indexType; $documentFieldIndexPrefix = $this->ar->getDocumentIndexFieldPrefix(); $indexFieldPrefix = $documentFieldIndexPrefix . $indexType; $indexFieldPrefixAlias = $indexAlias . '.' . $indexFieldPrefix; $detailAlias = $this->options['type'] == 'PUBLISHED_DRAFT' ? self::DOCUMENT_DETAIL_TABLE_PUBLISHED_ALIAS : self::DOCUMENT_DETAIL_TABLE_ALIAS; foreach ($this->unionArray as $qb) { $qb->addSelect('orderIndex.*'); $qb->join(self::DOCUMENT_TABLE_ALIAS, $indexTablePrefix . '_tbl', 'orderIndex', $this->expr->eq($detailAlias . '.' . $documentDetailIdName, $indexFieldPrefixAlias . '_FK_document_detail_id')); $qb->andWhere($this->expr->eq("{$indexFieldPrefixAlias}_name", ':orderIndex')); } $this->unionArrayParams[":orderIndex"] = $fieldName; $orderSql = "ORDER BY {$indexFieldPrefix}_value"; } else { $orderSql = "ORDER BY {$fieldName} {$order}"; } } $sqlArray = array(); foreach ($this->unionArray as $qb) { if (!$this->siteSet && $this->ar->getSiteField()) { $qb->andWhere($this->expr->eq($this->ar->getSiteField(), ':site')); $this->unionArrayParams[":site"] = $this->ar->getSiteid(); } $sqlArray[] = $qb->getSql(); } $sql = '(' . implode(') UNION (', $sqlArray) . ')'; if (!empty($this->unionOrderBy)) { $sql .= $orderSql; } try { if (__Config::get('QUERY_CACHING') && ($cacheDriver = org_glizy_dataAccessDoctrine_DataAccess::getCache())) { $lifeTime = __Config::get('QUERY_CACHING_LIFETIME'); $key = md5($sql); $this->statement = $this->ar->getConnection()->executeQuery($sql, $this->unionArrayParams, array(), new QueryCacheProfile($lifeTime, $key, $cacheDriver)); } else { $this->statement = $this->ar->getConnection()->executeQuery($sql, $this->unionArrayParams); } } catch (Exception $e) { require_once org_glizy_Paths::get('CORE_LIBS') . 'sql-formatter/lib/SqlFormatter.php'; $trace = $e->getTrace(); var_dump($trace[0]['args'][0]->errorInfo); echo SqlFormatter::format($sql) . '</br></br>'; var_dump($this->unionArrayParams); } $this->resetQuery(); } }
/** * @param int $connectionNumber */ function __construct($connectionNumber = 0) { $this->connection = org_glizy_dataAccessDoctrine_DataAccess::getConnection($connectionNumber); }
private function initDebugBar() { $this->glizyCollector = org_glizy_ObjectFactory::createObject('org.glizy.debug.dataCollector.GlizyCollector'); $this->debugBar = new DebugBar(); $this->debugBar->addCollector(new PhpInfoCollector()); $this->debugBar->addCollector(new MessagesCollector()); $this->debugBar->addCollector(new MessagesCollector('logs')); $this->debugBar->addCollector(new TimeDataCollector()); $this->debugBar->addCollector(new MemoryCollector()); $this->debugBar->addCollector($this->glizyCollector); $conn = org_glizy_dataAccessDoctrine_DataAccess::getConnection(); $config = $conn->getConfiguration(); $debugStack = new Doctrine\DBAL\Logging\DebugStack(); $config->setSQLLogger($debugStack); $this->debugBar->addCollector(new DoctrineCollector($debugStack)); }