Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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
  • cTinymce4Configuration
  • cTinyMCE4Editor
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TODOBackendList
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • addArtspec
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageCheckImageEditingPossibility
  • 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
  • conGetUniqueArticleUrlname
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsArticleUrlnameUnique
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSetStartArticle
  • consoleLog
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParentAreaId
  • getRightsList
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckAlias
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • 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
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the module search class.
  5:  *
  6:  * @todo refactor documentation
  7:  *
  8:  * @package    Core
  9:  * @subpackage Backend
 10:  * @author     Rusmir Jusufovic
 11:  * @copyright  four for business AG <www.4fb.de>
 12:  * @license    http://www.contenido.org/license/LIZENZ.txt
 13:  * @link       http://www.4fb.de
 14:  * @link       http://www.contenido.org
 15:  */
 16: 
 17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 18: 
 19: /**
 20:  * This class performs the module search.
 21:  *
 22:  * @package    Core
 23:  * @subpackage Backend
 24:  */
 25: class cModuleSearch extends cModuleHandler {
 26: 
 27:     /**
 28:      * Items/Element per page.
 29:      *
 30:      * @var int
 31:      */
 32:     protected $_elementPerPage = '';
 33: 
 34:     /**
 35:      * Order by.
 36:      *
 37:      * @var string
 38:      */
 39:     protected $_orderBy = '';
 40: 
 41:     /**
 42:      * Sort order.
 43:      *
 44:      * @var string
 45:      */
 46:     protected $_sortOrder = '';
 47: 
 48:     /**
 49:      * Module type.
 50:      *
 51:      * @var string
 52:      */
 53:     protected $_moduleType = '';
 54: 
 55:     /**
 56:      * Filter string.
 57:      *
 58:      * @var string
 59:      */
 60:     protected $_filter = '';
 61: 
 62:     /**
 63:      * Where should be searched (all, description, type, input, output).
 64:      *
 65:      * @var string
 66:      */
 67:     protected $_searchIn = '';
 68: 
 69:     /**
 70:      * Selected page.
 71:      *
 72:      * @var int
 73:      */
 74:     protected $_selectedPage = 1;
 75: 
 76:     /**
 77:      * Result saved in a array.
 78:      *
 79:      * @var array
 80:      */
 81:     protected $_result = array();
 82: 
 83:     /**
 84:      * Constructor to create an instance of this class.
 85:      *
 86:      * @param array $searchOptions
 87:      *
 88:      * @throws cException
 89:      */
 90:     public function __construct($searchOptions) {
 91:         parent::__construct();
 92: 
 93:         $this->_elementPerPage = $searchOptions['elementPerPage'];
 94:         $this->_orderBy = $searchOptions['orderBy'];
 95:         $this->_sortOrder = $searchOptions['sortOrder'];
 96:         $this->_moduleType = $searchOptions['moduleType'];
 97:         $this->_filter = $searchOptions['filter'];
 98:         $this->_searchIn = $searchOptions['searchIn'];
 99:         $this->_selectedPage = $searchOptions['selectedPage'];
100:     }
101: 
102:     /**
103:      * Print a array.
104:      *
105:      * @param array $arg
106:      */
107:     private function _echo($arg) {
108:         echo '<pre>' . print_r($arg) . '</pre>';
109:     }
110: 
111:     /**
112:      * Count result.
113:      *
114:      * @return int
115:      *         count in result
116:      */
117:     public function getModulCount() {
118:         return count($this->_result);
119:     }
120: 
121:     /**
122:      * Search for modules in db columns and in filesystem (input and
123:      * output files).
124:      *
125:      * @return array
126:      * @throws cDbException
127:      * @throws cInvalidArgumentException
128:      */
129:     public function searchForAllModules() {
130:         global $cfg, $client;
131: 
132:         $idClient = $client;
133:         // first fetch all modules for client
134:         // then apply _filter on input and output from files
135:         // then use the whitelisted id's and search for additional filter matches on database
136:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s", $cfg['tab']['mod'], $idClient);
137: 
138: 
139:         $db = cRegistry::getDb();
140:         $db->query($sql);
141:         $moduleIds = array();
142: 
143:         // filter modules based on input and output
144:         while (($modul = $db->nextRecord()) !== false) {
145:             $this->initWithDatabaseRow($db);
146:             if (cString::getStringLength(stripslashes($this->_filter)) === 0
147:                     || cString::findFirstPos($this->readInput(), stripslashes($this->_filter)) !== false
148:                     || cString::findFirstPos($this->readOutput(), stripslashes($this->_filter)) !== false) {
149:                     $moduleIds[] = $db->f('idmod');
150:             }
151:         }
152: 
153:         // build query using whitelisted id's
154:         $idFilter = "";
155:         foreach ($moduleIds as $moduleId) {
156:             $idFilter .= " OR idmod=" . (int) $moduleId;
157:         }
158:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s AND (
159:                             type LIKE '%s'
160:                             AND type LIKE '%s'
161:                             OR description LIKE '%s'
162:                             OR name LIKE  '%s'" . $idFilter . ")
163:                             ORDER BY %s %s", $cfg['tab']['mod'], $idClient, $this->_moduleType, '%' . $this->_filter . '%', '%' . $this->_filter . '%', '%' . $this->_filter . '%', $this->_orderBy, $this->_sortOrder);
164: 
165:         $db = cRegistry::getDb();
166:         $db->query($sql);
167:         $result = array();
168: 
169:         while (($modul = $db->nextRecord()) !== false) {
170:             $this->initWithDatabaseRow($db);
171:             $result[$db->f('idmod')] = array(
172:                     'name' => $db->f('name'),
173:                     'description' => $db->f('description'),
174:                     'error' => $db->f('error'),
175:                     'input' => $this->readInput(),
176:                     'output' => $this->readOutput()
177:             );
178:         }
179: 
180:         return $result;
181:     }
182: 
183:     /**
184:      * Main method for the class. Search for modules in db and in input and
185:      * outputs files.
186:      *
187:      * @return array
188:      * @throws cDbException
189:      * @throws cInvalidArgumentException
190:      */
191:     public function getModules() {
192:         $modules = array();
193: 
194:         switch ($this->_searchIn) {
195:             case 'all':
196:                 $modules = $this->searchForAllModules();
197:                 break;
198:             case 'name':
199:                 $modules = $this->findeModulWithName();
200:                 break;
201:             case 'description':
202:                 $modules = $this->findModuleWithDescription();
203:                 break;
204:             case 'type':
205:                 $modules = $this->findModuleWithType();
206:                 break;
207:             case 'input': // Search for modulname_input.php
208:                 $modules = $this->findModulWithInput();
209:                 break;
210:             case 'output': // Search fro modulname_output.php
211:                 $modules = $this->findModulWithOutput();
212:                 break;
213:         }
214: 
215:         $this->_result = $modules;
216:         if ($this->_elementPerPage > 0) {
217:             if (count($this->_result) < (($this->_page - 1) * $this->_elementPerPage)) {
218:                 $this->_page = 1;
219:             }
220: 
221:             if ($this->_elementPerPage * ($this->_page) >= count($this->_result) + $this->_elementPerPage && $this->_page != 1) {
222:                 $this->_page--;
223:             }
224:             return array_slice($modules, $this->_elementPerPage * ($this->_selectedPage - 1), $this->_elementPerPage, true);
225:         } else {
226:             return $modules;
227:         }
228:     }
229: 
230:     /**
231:      * Search for modules in "name" column of modul.
232:      *
233:      * @return array
234:      * @throws cDbException
235:      * @throws cInvalidArgumentException
236:      */
237:     public function findeModulWithName() {
238:         global $cfg, $client;
239:         $idClient = $client;
240: 
241:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s AND (type LIKE '%s' AND name LIKE '%s')
242:                         ORDER BY %s %s ", $cfg['tab']['mod'], $idClient, $this->_moduleType, '%' . $this->_filter . '%', $this->_orderBy, $this->_sortOrder);
243: 
244:         $db = cRegistry::getDb();
245:         $db->query($sql);
246:         $result = array();
247: 
248:         while (($module = $db->nextRecord()) !== false) {
249:             $this->initWithDatabaseRow($db);
250:             $result[$db->f('idmod')] = array(
251:                     'name' => $db->f('name'),
252:                     'description' => $db->f('description'),
253:                     'error' => $db->f('error'),
254:                     'input' => $this->readInput(),
255:                     'output' => $this->readOutput()
256:             );
257:         }
258:         return $result;
259:     }
260: 
261:     /**
262:      * Search for modules in input file of the module.
263:      *
264:      * @return array
265:      * @throws cDbException
266:      * @throws cInvalidArgumentException
267:      */
268:     public function findModulWithInput() {
269:         global $cfg, $client;
270: 
271:         $idClient = $client;
272:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s AND type LIKE '%s'
273:                         ORDER BY %s %s ", $cfg['tab']['mod'], $idClient, $this->_moduleType, $this->_orderBy, $this->_sortOrder);
274: 
275:         $db = cRegistry::getDb();
276:         $db->query($sql);
277:         $result = array();
278:         while (($module = $db->nextRecord()) !== false) {
279:             $this->initWithDatabaseRow($db);
280:             if (cString::getStringLength(stripslashes($this->_filter)) === 0
281:                 || cString::findFirstPos($this->readInput(), stripslashes($this->_filter)) !== false) {
282:                 $result[$db->f('idmod')] = array(
283:                         'name' => $db->f('name'),
284:                         'description' => $db->f('description'),
285:                         'error' => $db->f('error'),
286:                         'input' => $this->readInput(),
287:                         'output' => $this->readOutput()
288:                 );
289:             }
290:         }
291: 
292:         return $result;
293:     }
294: 
295:     /**
296:      * Search for modules in output of modules of current client.
297:      *
298:      * @return array
299:      * @throws cDbException
300:      * @throws cInvalidArgumentException
301:      */
302:     public function findModulWithOutput() {
303:          global $cfg, $client;
304: 
305:         $result = array();
306: 
307:         $idClient = $client;
308:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s AND type LIKE '%s'
309:                         ORDER BY %s %s ", $cfg['tab']['mod'], $idClient, $this->_moduleType, $this->_orderBy, $this->_sortOrder);
310: 
311:         $db = cRegistry::getDb();
312:         $db->query($sql);
313:         $result = array();
314:         while (($module = $db->nextRecord()) !== false) {
315:             $this->initWithDatabaseRow($db);
316:             if (cString::getStringLength(stripslashes($this->_filter)) === 0
317:                 || cString::findFirstPos($this->readOutput(), stripslashes($this->_filter)) !== false) {
318:                 $result[$db->f('idmod')] = array(
319:                         'name' => $db->f('name'),
320:                         'description' => $db->f('description'),
321:                         'error' => $db->f('error'),
322:                         'input' => $this->readInput(),
323:                         'output' => $this->readOutput()
324:                 );
325:             }
326:         }
327: 
328:         return $result;
329:     }
330: 
331:     /**
332:      * Search for modules in type column.
333:      *
334:      * @return array
335:      * @throws cDbException
336:      * @throws cInvalidArgumentException
337:      */
338:     public function findModuleWithType() {
339:         global $cfg, $client;
340:         $idClient = $client;
341: 
342:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s AND (
343:                             type LIKE '%s'
344:                             AND type LIKE '%s')
345:                             ORDER BY %s %s ", $cfg['tab']['mod'], $idClient, $this->_moduleType, '%' . $this->_filter . '%', $this->_orderBy, $this->_sortOrder);
346: 
347:         $db = cRegistry::getDb();
348:         $db->query($sql);
349:         $result = array();
350: 
351:         while (($module = $db->nextRecord()) !== false) {
352:             $this->initWithDatabaseRow($db);
353:             $result[$db->f('idmod')] = array(
354:                     'name' => $db->f('name'),
355:                     'description' => $db->f('description'),
356:                     'error' => $db->f('error'),
357:                     'input' => $this->readInput(),
358:                     'output' => $this->readOutput()
359:             );
360:         }
361:         return $result;
362:     }
363: 
364:     /**
365:      * Search for modules in description column of modules.
366:      *
367:      * @return array
368:      * @throws cDbException
369:      * @throws cInvalidArgumentException
370:      */
371:     public function findModuleWithDescription() {
372:         global $cfg, $client;
373:         $idClient = $client;
374: 
375:         $sql = sprintf("SELECT * FROM %s WHERE idclient = %s AND (
376:                             type LIKE '%s'
377:                             AND description LIKE '%s')
378:                             ORDER BY %s %s ", $cfg['tab']['mod'], $idClient, $this->_moduleType, '%' . $this->_filter . '%', $this->_orderBy, $this->_sortOrder);
379: 
380:         $db = cRegistry::getDb();
381:         $db->query($sql);
382:         $result = array();
383: 
384:         while (($module = $db->nextRecord()) !== false) {
385:             $this->initWithDatabaseRow($db);
386:             $result[$db->f('idmod')] = array(
387:                     'name' => $db->f('name'),
388:                     'description' => $db->f('description'),
389:                     'error' => $db->f('error'),
390:                     'input' => $this->readInput(),
391:                     'output' => $this->readOutput()
392:             );
393:         }
394: 
395:         return $result;
396:     }
397: 
398: }
399: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0