Skip to content

Instantly share code, notes, and snippets.

@Dmi3yy
Last active August 29, 2015 13:56
Show Gist options
  • Save Dmi3yy/9306968 to your computer and use it in GitHub Desktop.
Save Dmi3yy/9306968 to your computer and use it in GitHub Desktop.

#Релиз 1.0.13 от 03.03.2014.

Данный релиз включает довольно много исправлений а так же нововведений которые упростят разработку сайтов на MODX EVO.

Исправлений: 44
Рефактор: 42
Улучшений: 23
Безопасность: 1

##Из основного на что хотел бы обратить внимаение:

  • KCFinder - генерация псевдонимов через TransAlias
  • Обновлен ManagerManager до версии 0.6.1
  • обновлен clearCach можно вызывать с параметром full ($modx->clearCache('full');)
  • обновленны функции getDocuments, getTemplateVars, getTemplateVarOutput, getDocumentChildren, getDocumentChildrenTVarOutput, getDocumentChildren можно вызывать с параметром all для вывода всех документов (а не только опубликованны и не опубликованных, так же и с удаленными)
  • Обновлен Wyfinder 2.0.2 (можно использовать [+pagetitle+], [+longtitle+] а так же исправленна работа @INHERIT для custom TVs)
  • Все менеджеры с ролью = 1 могут видеть все документы как в админке так и на сайте (раньше если документ был только для какой то группы на сайте мнеджер не видел их)
  • добавлен метод “$modx->parseText”
  • добавлен ID документа в заголовок при редактировании документа а так же в QM+
  • Breadcrumbs 1.0.4 (можно исключить документы с указанным шаблоном)
  • phpthumb 1.2 (не подключает phpthumb class если картинки на страничке уже пережаты)

Весь перечень изменений можно как всегда увидеть в файле install/changelog.txt

##Подробней о изменениях тут так же упомяну несколько вещей которые появились еще в версии 1.0.12 но не были достаточно хорошо высветленны

###Изменения API ####$modx->getDocument Добавленна возможность при выборе документа не учитывать параметры: опубликован, удален

/**
 * getDocument
 * @version 1.0.1 (2014-02-19)
 * 
 * @desc Returns required fields of a document.
 * 
 * @param $id {integer} - Id of a document which data has to be gained. @required
 * @param $fields {comma separated string; '*'} - Comma separated list of document fields to get. Default: '*'.
 * @param $published {0; 1; 'all'} - Document publication status. Once the parameter equals 'all', the result will be returned regardless of whether the ducuments are published or they are not. Default: false.
 * @param $deleted {0; 1; 'all'} - Document removal status. Once the parameter equals 'all', the result will be returned regardless of whether the ducuments are deleted or they are not. Default: 0.
 * 
 * @return {array; false} - Result array with fields or false.
 */
function getDocument($id = 0, $fields = '*', $published = 1, $deleted = 0){
	if ($id == 0){
		return false;
	}else{
		$docs = $this->getDocuments(array($id), $published, $deleted, $fields, '', '', '', 1);
		
		if ($docs != false){
			return $docs[0];
		}else{
			return false;
		}
	}
}

####$modx->getDocuments Добавленна возможность выбирать все документы (к примеру раньше можно было выбирать только опубликованные или только не опубликованные, сейчас можно выбирать все)

/**
 * getDocuments
 * @version 1.1.1 (2013-02-19)
 * 
 * @desc Returns required documents (their fields).
 * 
 * @param $ids {array; comma separated string} - Documents Ids to get. @required
 * @param $published {0; 1; 'all'} - Documents publication status. Once the parameter equals 'all', the result will be returned regardless of whether the documents are published or they are not. Default: 1.
 * @param $deleted {0; 1; 'all'} - Documents removal status. Once the parameter equals 'all', the result will be returned regardless of whether the documents are deleted or they are not. Default: 0.
 * @param $fields {comma separated string; '*'} - Documents fields to get. Default: '*'.
 * @param $where {string} - SQL WHERE clause. Default: ''.
 * @param $sort {comma separated string} - A comma-separated list of field names to sort by. Default: 'menuindex'.
 * @param $dir {'ASC'; 'DESC'} - Sorting direction. Default: 'ASC'.
 * @param $limit {string} - SQL LIMIT (without 'LIMIT '). An empty string means no limit. Default: ''.
 * 
 * @return {array; false} - Result array with documents, or false.
 */
function getDocuments($ids = array(), $published = 1, $deleted = 0, $fields = '*', $where = '', $sort = 'menuindex', $dir = 'ASC', $limit = ''){
	if(is_string($ids)){
		if(strpos($ids, ',') !== false){
			$ids = array_filter(array_map('intval', explode(',', $ids)));
		}else{
			$ids = array($ids);
		}
	}
	if (count($ids) == 0){
		return false;
	}else{
		// modify field names to use sc. table reference
		$fields = 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $fields))));
		$sort = ($sort == '') ? '' : 'sc.'.implode(',sc.', array_filter(array_map('trim', explode(',', $sort))));
		if ($where != ''){
			$where = 'AND '.$where;
		}
		
		$published = ($published !== 'all') ? "AND sc.published = '{$published}'" : '';
		$deleted = ($deleted !== 'all') ? "AND sc.deleted = '{$deleted}'" : '';
		
		// get document groups for current user
		if ($docgrp = $this->getUserDocGroups()){
			$docgrp = implode(',', $docgrp);
		}
		
		$access = ($this->isFrontend() ? 'sc.privateweb=0' : '1="'.$_SESSION['mgrRole'].'" OR sc.privatemgr=0').(!$docgrp ? '' : ' OR dg.document_group IN ('.$docgrp.')');
		
		$tblsc = $this->getFullTableName('site_content');
		$tbldg = $this->getFullTableName('document_groups');

		$result = $this->db->select(
			"DISTINCT {$fields}",
			"{$tblsc} sc
				LEFT JOIN {$tbldg} dg on dg.document = sc.id",
			"(sc.id IN (".implode(',', $ids).") {$published} {$deleted} {$where}) AND ({$access}) GROUP BY sc.id",
			($sort ? "{$sort} {$dir}" : ""),
			$limit
			);
		
		$resourceArray = $this->db->makeArray($result);
		
		return $resourceArray;
	}
}

####$modx->getDocumentChildren ####$modx->getDocumentChildrenTVarOutput ####$modx->getIdFromAlias() ####$modx->getTemplateVarOutput ####$modx->getTemplateVars ####$modx->db->optimize() ####$modx->sendmail()

###Ditto Новые параметры:
Новые плейсхолдеры:

###Eform ###Wayfinder ###Breadcrumbs ###ManagerManager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment