Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _processCmsTags
  • addArtspec
  • addslashes_deep
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • endsWith
  • extractNumber
  • generateDisplayFilePath
  • generateInfoButton
  • generateJs
  • getAktuellType
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • modTestModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setHelpContext
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • stripslashes_deep
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • xmlFileToArray
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the html validator class.
  4:  *
  5:  * @package    Core
  6:  * @subpackage Backend
  7:  * @version    SVN Revision $Rev:$
  8:  *
  9:  * @author     Unknown
 10:  * @copyright  four for business AG <www.4fb.de>
 11:  * @license    http://www.contenido.org/license/LIZENZ.txt
 12:  * @link       http://www.4fb.de
 13:  * @link       http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * This class validates HTML.
 20:  *
 21:  * @package    Core
 22:  * @subpackage Backend
 23:  */
 24: class cHTMLValidator {
 25: 
 26:     protected $_doubleTags = array(
 27:         "form",
 28:         "head",
 29:         "body",
 30:         "html",
 31:         "td",
 32:         "tr",
 33:         "table",
 34:         "a",
 35:         "tbody",
 36:         "title",
 37:         "container",
 38:         "span",
 39:         "div"
 40:     );
 41: 
 42:     protected $_html;
 43: 
 44:     protected $_nestingLevel = array();
 45: 
 46:     public $missingNodes = array();
 47: 
 48:     public $iNodeName;
 49: 
 50:     protected $_nestingNodes = array();
 51: 
 52:     protected $_existingTags = array();
 53: 
 54:     protected function _cleanHTML($html) {
 55:         // remove all php code from layout
 56:         $resultingHTML = preg_replace('/<\?(php)?((.)|(\s))*?\?>/i', '', $html);
 57: 
 58:         // We respect only \n, but we need to take care of windows (\n\r) and
 59:         // other systems (\r)
 60:         $resultingHTML = str_replace("\r\n", "\n", $resultingHTML);
 61:         $resultingHTML = str_replace("\r", "\n", $resultingHTML);
 62: 
 63:         return $resultingHTML;
 64:     }
 65: 
 66:     public function validate($html) {
 67:         $nestingLevel = 0;
 68: 
 69:         // Clean up HTML first from any PHP scripts, and clean up line breaks
 70:         $this->_html = $this->_cleanHTML($html);
 71: 
 72:         $htmlParser = new HtmlParser($this->_html);
 73: 
 74:         while ($htmlParser->parse()) {
 75:             $this->_existingTags[] = $htmlParser->iNodeName;
 76:             // Check if we found a double tag
 77:             if (in_array($htmlParser->iNodeName, $this->_doubleTags)) {
 78:                 if (!array_key_exists($htmlParser->iNodeName, $this->_nestingLevel)) {
 79:                     $this->_nestingLevel[$htmlParser->iNodeName] = 0;
 80:                 }
 81: 
 82:                 if (!array_key_exists($htmlParser->iNodeName, $this->_nestingNodes)) {
 83:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])] = array();
 84:                 }
 85: 
 86:                 // Check if it's a start tag
 87:                 if ($htmlParser->iNodeType == HtmlParser::NODE_TYPE_ELEMENT) {
 88:                     // Push the current element to the stack, remember ID and
 89:                     // Name, if possible
 90:                     $nestingLevel++;
 91: 
 92:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["name"] = $htmlParser->iNodeAttributes["name"];
 93:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["id"] = $htmlParser->iNodeAttributes["id"];
 94:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["level"] = $nestingLevel;
 95:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["char"] = $htmlParser->iHtmlTextIndex;
 96:                     $this->_nestingLevel[$htmlParser->iNodeName]++;
 97:                 }
 98: 
 99:                 if ($htmlParser->iNodeType == HtmlParser::NODE_TYPE_ENDELEMENT) {
100:                     // Check if we've an element of this type on the stack
101:                     if ($this->_nestingLevel[$htmlParser->iNodeName] > 0) {
102:                         unset($this->_nestingNodes[$htmlParser->iNodeName][$this->_nestingLevel[$htmlParser->iNodeName]]);
103:                         $this->_nestingLevel[$htmlParser->iNodeName]--;
104: 
105:                         if ($this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["level"] != $nestingLevel) {
106:                             // Todo: Check for the wrong nesting level
107:                         }
108: 
109:                         $nestingLevel--;
110:                     }
111:                 }
112:             }
113:         }
114: 
115:         // missingNodes should be an empty array by default
116:         $this->missingNodes = array();
117: 
118:         // Collect all missing nodes
119:         foreach ($this->_nestingLevel as $key => $value) {
120:             // One or more missing tags found
121:             if ($value > 0) {
122:                 // Step trough all missing tags
123:                 for ($i = 0; $i < $value; $i++) {
124:                     $node = $this->_nestingNodes[$key][$i];
125: 
126:                     list($line, $char) = $this->_getLineAndCharPos($node["char"]);
127:                     $this->missingNodes[] = array(
128:                         "tag" => $key,
129:                         "id" => $node["id"],
130:                         "name" => $node["name"],
131:                         "line" => $line,
132:                         "char" => $char
133:                     );
134: 
135:                     $this->missingTags[$line][$char] = true;
136:                 }
137:             }
138:         }
139:     }
140: 
141:     public function tagExists($tag) {
142:         if (in_array($tag, $this->_existingTags)) {
143:             return true;
144:         } else {
145:             return false;
146:         }
147:     }
148: 
149:     protected function _returnErrorMap() {
150:         $html = "<pre>";
151: 
152:         $chunks = explode("\n", $this->_html);
153: 
154:         foreach ($chunks as $key => $value) {
155:             $html .= ($key + 1) . " ";
156: 
157:             for ($i = 0; $i < strlen($value); $i++) {
158:                 $char = substr($value, $i, 1);
159: 
160:                 if (is_array($this->missingTags[$key + 1])) {
161:                     // echo ($key+1) . " ". $i."<br>";
162:                     if (array_key_exists($i + 2, $this->missingTags[$key + 1])) {
163:                         $html .= "<u><b>" . conHtmlSpecialChars($char) . "</b></u>";
164:                     } else {
165:                         $html .= conHtmlSpecialChars($char);
166:                     }
167:                 } else {
168:                     $html .= conHtmlSpecialChars($char);
169:                 }
170:             }
171: 
172:             $html .= "<br>";
173:         }
174: 
175:         return $html;
176:     }
177: 
178:     protected function _getLineAndCharPos($charpos) {
179:         $mangled = substr($this->_html, 0, $charpos);
180: 
181:         $line = substr_count($mangled, "\n") + 1;
182:         $char = $charpos - strrpos($mangled, "\n");
183: 
184:         return array(
185:             $line,
186:             $char
187:         );
188:     }
189: 
190: }
191: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0