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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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

  • PimPlugin
  • PimPluginArchiveExtractor
  • PimPluginCollection
  • PimPluginRelations
  • PimPluginRelationsCollection
  • PimPluginSetup
  • PimPluginSetupInstall
  • PimPluginSetupStatus
  • PimPluginSetupUninstall
  • PimPluginSetupUpdate
  • PimPluginViewDependencies
  • PimPluginViewNavSub
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains abstract class for view navsub entries
  4:  *
  5:  * @package Plugin
  6:  * @subpackage PluginManager
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Frederic Schneider
 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:  * View navigation entries
 20:  * TODO: Later implement into new PIM view design
 21:  *
 22:  * @package Plugin
 23:  * @subpackage PluginManager
 24:  * @author frederic.schneider
 25:  */
 26: class PimPluginViewNavSub {
 27: 
 28:     // Pattern for navigation (nav_sub) xml entries
 29:     const PATTERN = '/;(.+)$/';
 30: 
 31:     // Filename of Xml configuration file for plugins
 32:     const PLUGIN_CONFIG_FILENAME = "plugin.xml";
 33: 
 34:     // Filename of Xml configuration file for CONTENIDO navigation
 35:     const CONTENIDO_NAVIGATION_FILENAME = "navigation.xml";
 36: 
 37:     // Initializing variables
 38:     private $PluginFoldername;
 39: 
 40:     // CONTENIDO sub navigations: *_nav_sub
 41:     public static $XmlNavSub;
 42: 
 43:     // Varianle for counted nav entries
 44:     protected $_NavCount = 0;
 45: 
 46:     // Variable for filepath to CONTENIDO base navigation.xml
 47:     protected $_contenidoLanguageFileLang;
 48: 
 49:     // Variable for subnavigation name
 50:     protected $_SubNav;
 51: 
 52:     // Class variable for DOMDocument
 53:     protected $_DOMDocument;
 54: 
 55:     // Class variable for cApiNavMainCollection
 56:     protected $_ApiNavMainCollection;
 57: 
 58:     // Class variable for cApiNavSubCollection
 59:     protected $_ApiNavSubCollection;
 60: 
 61:     /**
 62:      * Initializing and set variable for DOMDocument
 63:      *
 64:      * @return DOMDocument
 65:      */
 66:     private function _setDOMDocument() {
 67:         return $this->_DOMDocument = new DOMDocument();
 68:     }
 69: 
 70:     /**
 71:      * Initializing and set variable for cApiNavMainCollection
 72:      *
 73:      * @return cApiNavMainCollection
 74:      */
 75:     private function _setApiNavMainCollection() {
 76:         return $this->_ApiNavMainCollection = new cApiNavMainCollection();
 77:     }
 78: 
 79:     /**
 80:      * Initializing and set variable for cApiNavSubCollection
 81:      *
 82:      * @return cApiNavSubCollection
 83:      */
 84:     private function _setApiNavSubCollection() {
 85:         return $this->_ApiNavSubCollection = new cApiNavSubCollection();
 86:     }
 87: 
 88:     /**
 89:      * Set contenidoLanguageFileLang variable
 90:      * (Filepath to CONTENIDO base navigation.xml)
 91:      *
 92:      * @param string $path
 93:      * @return boolean
 94:      */
 95:     private function _setNavigationXmlPath($path) {
 96:         $this->_contenidoLanguageFileLang = $path;
 97:         return true;
 98:     }
 99: 
100:     /**
101:      * Get contenidoLanguageFileLang variable
102:      * (Filepath to CONTENIDO base navigation.xml)
103:      *
104:      * @return string contenigoLanguageFileLang
105:      */
106:     private function _getNavigationXmlPath() {
107:         return $this->_contenidoLanguageFileLang;
108:     }
109: 
110: 
111:     /**
112:      * Construct function
113:      */
114:     public function __construct() {
115: 
116:         // Initializing and set classes
117:         $this->_setDOMDocument();
118: 
119:         // cApiClasses
120:         $this->_setApiNavMainCollection();
121:         $this->_setApiNavSubCollection();
122:     }
123: 
124:     // GET and SET methods for installation routine
125:     /**
126:      * Set variable for plugin foldername
127:      *
128:      * @param string $foldername
129:      * @return string
130:      */
131:     public function setPluginFoldername($foldername) {
132:         return $this->PluginFoldername = cSecurity::escapeString($foldername);
133:     }
134: 
135:     // View methods
136:     /**
137:      * Get nav_sub entries
138:      *
139:      * @return Ambigous <string, string>|Ambigous <string, boolean>
140:      */
141:     public function getNavSubentries() {
142:         global $belang;
143: 
144:         $cfg = cRegistry::getConfig();
145: 
146:         // Get contents of plugin.xml file
147:         $dataPluginXml = file_get_contents($cfg['path']['contenido'] . $cfg['path']['plugins'] . $this->PluginFoldername . DIRECTORY_SEPARATOR . self::PLUGIN_CONFIG_FILENAME);
148: 
149:         // Load xml strings
150:         $xmlPluginXml = simplexml_load_string($dataPluginXml);
151: 
152:         // Count nav_sub entries for this plugin
153:         $this->_NavCount = count($xmlPluginXml->contenido->nav_sub->nav);
154: 
155:         // No navigation configured, so we can stop this process
156:         if ($this->_NavCount == 0) {
157:             return i18n('No navigation configuration founded', 'pim');
158:         }
159: 
160:         // Added nav_sub entries to variable XmlNavSub
161:         self::$XmlNavSub = $xmlPluginXml->contenido->nav_sub;
162: 
163:         // Check for CONTENIDO navigation entries
164:         $contenidoNav = $this->_getCONTENIDONavigation();
165: 
166:         if ($contenidoNav != "") { // CONTENIDO navigation entry founded
167:             return $this->_getPluginNavigation($contenidoNav);
168:         } else { // No CONTENIDO navigation entry founded
169: 
170:             // Check for plugin navigation entry
171:             $pluginNav = $this->_checkAndGetPluginNavigation();
172: 
173:             if ($pluginNav != "") { // Plugin navigation entry founded
174:                 return $this->_getPluginNavigation($pluginNav);
175:             } else { // No navigation entries founded
176:                 return i18n('No navigation configuration founded', 'pim');
177:             }
178:         }
179:     }
180: 
181:     /**
182:      * Get founded CONTENIDO navigation entries
183:      *
184:      * @return bool
185:      */
186:     private function _getCONTENIDONavigation() {
187:         $cfg = cRegistry::getConfig();
188: 
189:         // Path to CONTENIDO navigation xml file
190:         $this->_setNavigationXmlPath($cfg['path']['contenido'] . 'xml/' . self::CONTENIDO_NAVIGATION_FILENAME);
191: 
192:         if (cFileHandler::exists($this->_getNavigationXmlPath())) {
193: 
194:             for ($i = 0; $i < $this->_NavCount; $i++) {
195: 
196:                 // Get only navigation value (pattern)
197:                 preg_match(self::PATTERN, self::$XmlNavSub->nav[$i], $matches);
198: 
199:                 // Get single navigation values
200:                 $navSubEntries = explode("/", $matches[1]);
201: 
202:                 if ($navSubEntries[0] == "navigation") { // CONTENIDO navigation
203:                                                          // case
204: 
205:                     // Define subnavigation name (example: navigation/content/linkchecker)
206:                     $this->_SubNav = $this->_getTranslatedNavigationName('//language/navigation/' . $navSubEntries[1] . '/' . $navSubEntries[2] . '/main');
207: 
208:                     // Define navigation name (example: navigation/content)
209:                     return $this->_getTranslatedNavigationName('//language/navigation/' . $navSubEntries[1] . '/main');
210:                 } else { // No CONTENIDO navigation case
211:                     return false;
212:                 }
213:             }
214:         } else {
215:             return false;
216:         }
217:     }
218: 
219:     /**
220:      * Get translated navigation name
221:      *
222:      * @param string $query
223:      * @return xml String of translated navigation nane
224:      */
225:     private function _getTranslatedNavigationName($query = '') {
226: 
227:         if ($query == '') {
228:             return false;
229:         }
230: 
231:         // Load CONTENIDO navigation xml file
232:         $this->_DOMDocument->load($this->_getNavigationXmlPath());
233: 
234:         // Create new DOMXPath
235:         $xpath = new DOMXPath($this->_DOMDocument);
236: 
237:         // Run defined query
238:         $entriesLang = $xpath->query($query);
239: 
240:         foreach ($entriesLang as $entry) {
241:             return $entry->firstChild->nodeValue;
242:         }
243:     }
244: 
245:     /**
246:      * Checks for plugin navigation entry and get navigation entries from
247:      * CONTENIDO navigation xml file
248:      *
249:      * @return bool
250:      */
251:     private function _checkAndGetPluginNavigation() {
252:         $cfg = cRegistry::getConfig();
253: 
254:         // Path to CONTENIDO navigation xml file
255:         $contenidoLanguageFileLang = $cfg['path']['contenido'] . 'xml/' . self::CONTENIDO_NAVIGATION_FILENAME;
256: 
257:         if (cFileHandler::exists($contenidoLanguageFileLang)) {
258: 
259:             for ($i = 0; $i < $this->_NavCount; $i++) {
260: 
261:                 $this->_ApiNavMainCollection->setWhere('idnavm', cSecurity::toInteger(self::$XmlNavSub->nav[$i]->attributes()->navm));
262:                 $this->_ApiNavMainCollection->query();
263: 
264:                 // If no entry at nav_sub database table founded,
265:                 // return false
266:                 if ($this->_ApiNavMainCollection->count() == 0) {
267:                     return false;
268:                 }
269: 
270:                 $row = $this->_ApiNavMainCollection->next();
271: 
272:                 // Define query
273:                 $query = '//' . $row->get('location');
274: 
275:                 // Load plugin navigation xml file
276:                 $this->_DOMDocument->load($contenidoLanguageFileLang);
277: 
278:                 // Create new DOMXPath
279:                 $xpath = new DOMXPath($this->_DOMDocument);
280: 
281:                 // Run defined query
282:                 $entriesLang = $xpath->query($query);
283: 
284:                 foreach ($entriesLang as $entry) {
285:                     return $entry->firstChild->nodeValue;
286:                 }
287:             }
288:         } else {
289:             return false;
290:         }
291:     }
292: 
293:     /**
294:      * Get founded plugin navigation entries
295:      *
296:      * @param string $contenidoNav
297:      * @return string boolean
298:      */
299:     private function _getPluginNavigation($contenidoNav = "") {
300:         global $belang;
301:         $cfg = cRegistry::getConfig();
302: 
303:         // Path to plugin specific navigation xml file with selected backend
304:         // language
305:         $pluginLanguageFileLang = $cfg['path']['contenido'] . $cfg['path']['plugins'] . $this->PluginFoldername . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . $cfg['lang'][$belang];
306: 
307:         if (cFileHandler::exists($pluginLanguageFileLang) && $contenidoNav != "") {
308: 
309:             // Initializing founded variable
310:             $founded = "";
311: 
312:             for ($i = 0; $i < $this->_NavCount; $i++) {
313: 
314:                 // Get only navigation value (pattern)
315:                 preg_match(self::PATTERN, self::$XmlNavSub->nav[$i], $matches);
316: 
317:                 // Define query
318:                 $query = '//' . $matches[1];
319: 
320:                 // Load plugin navigation xml file
321:                 $this->_DOMDocument->load($pluginLanguageFileLang);
322: 
323:                 // Create new DOMXPath
324:                 $xpath = new DOMXPath($this->_DOMDocument);
325: 
326:                 // Run defined query
327:                 $entriesLang = $xpath->query($query);
328: 
329:                 // Prevent misarrangement
330:                 if ($entriesLang->length == 0) {
331:                     return false;
332:                 }
333: 
334:                 foreach ($entriesLang as $entry) {
335: 
336:                     // If we have more then one navigation entry, define
337:                     // menuname for other entries
338:                     if (self::$XmlNavSub->nav[$i]->attributes()->level == 0 && $this->_NavCount > 1) {
339:                         $menuName = $entry->nodeValue;
340:                         continue;
341:                     } elseif (self::$XmlNavSub->nav[$i]->attributes()->level == 1 && $menuName == '') {
342:                         // If we have an plugin with level one and no defined menuName, use subnavigation name
343:                         // as menuName
344:                         $menuName = $this->_SubNav;
345:                     }
346: 
347:                     $founded[] = i18n('You find this plugin at navigation section', 'pim') . " &quot;{$contenidoNav}&quot; " . i18n('as', 'pim') . (($menuName != "") ? ' &quot;' . $menuName . '&quot; ->' : '') . " &quot;{$entry->nodeValue}&quot;<br />";
348:                 }
349:             }
350: 
351:             // Prevent double entries
352:             $founded = array_unique($founded);
353: 
354:             // Initializing output variable
355:             $output = "";
356: 
357:             // Convert founded array to an string
358:             foreach ($founded as $entry) {
359:                 $output .= $entry;
360:             }
361: 
362:             return $output;
363:         } else {
364:             return false;
365:         }
366:     }
367: 
368: }
369: ?>
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0