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
    • 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

  • PimPlugin
  • PimPluginArchiveExtractor
  • PimPluginCollection
  • PimPluginRelations
  • PimPluginRelationsCollection
  • PimPluginSetup
  • PimPluginSetupInstall
  • PimPluginSetupStatus
  • PimPluginSetupUninstall
  • PimPluginSetupUpdate
  • 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:  * Install class for new plugins, extends PimPluginSetup
 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:     // Class variable for DOMDocument
 47:     protected $_DOMDocument;
 48: 
 49:     // Class variable for cApiNavMainCollection
 50:     protected $_ApiNavMainCollection;
 51: 
 52:     // Class variable for cApiNavSubCollection
 53:     protected $_ApiNavSubCollection;
 54: 
 55:     /**
 56:      * Initializing and set variable for DOMDocument
 57:      *
 58:      * @return DOMDocument
 59:      */
 60:     private function _setDOMDocument() {
 61:         return $this->_DOMDocument = new DOMDocument();
 62:     }
 63: 
 64:     /**
 65:      * Initializing and set variable for cApiNavMainCollection
 66:      *
 67:      * @return cApiNavMainCollection
 68:      */
 69:     private function _setApiNavMainCollection() {
 70:         return $this->_ApiNavMainCollection = new cApiNavMainCollection();
 71:     }
 72: 
 73:     /**
 74:      * Initializing and set variable for cApiNavSubCollection
 75:      *
 76:      * @return cApiNavSubCollection
 77:      */
 78:     private function _setApiNavSubCollection() {
 79:         return $this->_ApiNavSubCollection = new cApiNavSubCollection();
 80:     }
 81: 
 82:     /**
 83:      * Construct function
 84:      */
 85:     public function __construct() {
 86: 
 87:         // Initializing and set classes
 88:         $this->_setDOMDocument();
 89: 
 90:         // cApiClasses
 91:         $this->_setApiNavMainCollection();
 92:         $this->_setApiNavSubCollection();
 93:     }
 94: 
 95:     // GET and SET methods for installation routine
 96:     /**
 97:      * Set variable for plugin foldername
 98:      *
 99:      * @param string $foldername
100:      * @return string
101:      */
102:     public function setPluginFoldername($foldername) {
103:         return $this->PluginFoldername = cSecurity::escapeString($foldername);
104:     }
105: 
106:     // View methods
107:     /**
108:      * Get nav_sub entries
109:      *
110:      * @return Ambigous <string, string>|Ambigous <string, boolean>
111:      */
112:     public function getNavSubentries() {
113:         global $belang;
114: 
115:         $cfg = cRegistry::getConfig();
116: 
117:         // get contents of plugin.xml file
118:         $dataPluginXml = file_get_contents($cfg['path']['contenido'] . $cfg['path']['plugins'] . $this->PluginFoldername . DIRECTORY_SEPARATOR . self::PLUGIN_CONFIG_FILENAME);
119: 
120:         // load xml strings
121:         $xmlPluginXml = simplexml_load_string($dataPluginXml);
122: 
123:         // count nav_sub entries for this plugin
124:         $this->_NavCount = count($xmlPluginXml->contenido->nav_sub->nav);
125: 
126:         // no navigation configured, so we can stop this process
127:         if ($this->_NavCount == 0) {
128:             return i18n('No navigation configuration founded', 'pim');
129:         }
130: 
131:         // added nav_sub entries to variable XmlNavSub
132:         self::$XmlNavSub = $xmlPluginXml->contenido->nav_sub;
133: 
134:         // check for CONTENIDO navigation entries
135:         $contenidoNav = $this->_getCONTENIDONavigation();
136: 
137:         if ($contenidoNav != "") { // CONTENIDO navigation entry founded
138:             return $this->_getPluginNavigation($contenidoNav);
139:         } else { // No CONTENIDO navigation entry founded
140: 
141:             // Check for plugin navigation entry
142:             $pluginNav = $this->_checkAndGetPluginNavigation();
143: 
144:             if ($pluginNav != "") { // Plugin navigation entry founded
145:                 return $this->_getPluginNavigation($pluginNav);
146:             } else { // No navigation entries founded
147:                 return i18n('No navigation configuration founded', 'pim');
148:             }
149:         }
150:     }
151: 
152:     /**
153:      * Get founded CONTENIDO navigation entries
154:      *
155:      * @return bool
156:      */
157:     private function _getCONTENIDONavigation() {
158:         $cfg = cRegistry::getConfig();
159: 
160:         // path to CONTENIDO navigation xml file
161:         $contenidoLanguageFileLang = $cfg['path']['contenido'] . 'xml/' . self::CONTENIDO_NAVIGATION_FILENAME;
162: 
163:         if (cFileHandler::exists($contenidoLanguageFileLang)) {
164: 
165:             for ($i = 0; $i < $this->_NavCount; $i++) {
166: 
167:                 // get only navigation value (pattern)
168:                 preg_match(self::PATTERN, self::$XmlNavSub->nav[$i], $matches);
169: 
170:                 // get single navigation values
171:                 $navSubEntries = explode("/", $matches[1]);
172: 
173:                 if ($navSubEntries[0] == "navigation") { // CONTENIDO navigation
174:                                                          // case
175:                     $query = '//language/navigation/' . $navSubEntries[1] . '/main';
176:                 } else { // No CONTENIDO navigation case
177:                     return false;
178:                 }
179: 
180:                 // load CONTENIDO navigation xml file
181:                 $this->_DOMDocument->load($contenidoLanguageFileLang);
182: 
183:                 // create new DOMXPath
184:                 $xpath = new DOMXPath($this->_DOMDocument);
185: 
186:                 // run defined query
187:                 $entriesLang = $xpath->query($query);
188: 
189:                 foreach ($entriesLang as $entry) {
190:                     return $entry->firstChild->nodeValue;
191:                 }
192:             }
193:         } else {
194:             return false;
195:         }
196:     }
197: 
198:     /**
199:      * Checks for plugin navigation entry and get navigation entries from
200:      * CONTENIDO navigation xml file
201:      *
202:      * @return bool
203:      */
204:     private function _checkAndGetPluginNavigation() {
205:         $cfg = cRegistry::getConfig();
206: 
207:         // path to CONTENIDO navigation xml file
208:         $contenidoLanguageFileLang = $cfg['path']['contenido'] . 'xml/' . self::CONTENIDO_NAVIGATION_FILENAME;
209: 
210:         if (cFileHandler::exists($contenidoLanguageFileLang)) {
211: 
212:             for ($i = 0; $i < $this->_NavCount; $i++) {
213: 
214:                 $this->_ApiNavMainCollection->setWhere('idnavm', cSecurity::toInteger(self::$XmlNavSub->nav[$i]->attributes()->navm));
215:                 $this->_ApiNavMainCollection->query();
216: 
217:                 // if no entry at nav_sub database table founded,
218:                 // return false
219:                 if ($this->_ApiNavMainCollection->count() == 0) {
220:                     return false;
221:                 }
222: 
223:                 $row = $this->_ApiNavMainCollection->next();
224: 
225:                 // define query
226:                 $query = '//' . $row->get('location');
227: 
228:                 // load plugin navigation xml file
229:                 $this->_DOMDocument->load($contenidoLanguageFileLang);
230: 
231:                 // create new DOMXPath
232:                 $xpath = new DOMXPath($this->_DOMDocument);
233: 
234:                 // run defined query
235:                 $entriesLang = $xpath->query($query);
236: 
237:                 foreach ($entriesLang as $entry) {
238:                     return $entry->firstChild->nodeValue;
239:                 }
240:             }
241:         } else {
242:             return false;
243:         }
244:     }
245: 
246:     /**
247:      * Get founded plugin navigation entries
248:      *
249:      * @param string $contenidoNav
250:      * @return string boolean
251:      */
252:     private function _getPluginNavigation($contenidoNav = "") {
253:         global $belang;
254:         $cfg = cRegistry::getConfig();
255: 
256:         // path to plugin specific navigation xml file with selected backend
257:         // language
258:         $pluginLanguageFileLang = $cfg['path']['contenido'] . $cfg['path']['plugins'] . $this->PluginFoldername . DIRECTORY_SEPARATOR . 'xml' . DIRECTORY_SEPARATOR . $cfg['lang'][$belang];
259: 
260:         if (cFileHandler::exists($pluginLanguageFileLang) && $contenidoNav != "") {
261: 
262:             // initializing founded variable
263:             $founded = "";
264: 
265:             for ($i = 0; $i < $this->_NavCount; $i++) {
266: 
267:                 // get only navigation value (pattern)
268:                 preg_match(self::PATTERN, self::$XmlNavSub->nav[$i], $matches);
269: 
270:                 // define query
271:                 $query = '//' . $matches[1];
272: 
273:                 // load plugin navigation xml file
274:                 $this->_DOMDocument->load($pluginLanguageFileLang);
275: 
276:                 // create new DOMXPath
277:                 $xpath = new DOMXPath($this->_DOMDocument);
278: 
279:                 // run defined query
280:                 $entriesLang = $xpath->query($query);
281: 
282:                 // prevent misarrangement
283:                 if ($entriesLang->length == 0) {
284:                     return false;
285:                 }
286: 
287:                 foreach ($entriesLang as $entry) {
288: 
289:                     // if we have more then one navigation entry, define
290:                     // menuname for other entries
291:                     if (self::$XmlNavSub->nav[$i]->attributes()->level == 0 && $this->_NavCount > 1) {
292:                         $menuName = $entry->nodeValue;
293:                         continue;
294:                     }
295: 
296:                     $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 />";
297:                 }
298:             }
299: 
300:             // prevent double entries
301:             $founded = array_unique($founded);
302: 
303:             // initializing output variable
304:             $output = "";
305: 
306:             // convert founded array to an string
307:             foreach ($founded as $entry) {
308:                 $output .= $entry;
309:             }
310: 
311:             return $output;
312:         } else {
313:             return false;
314:         }
315:     }
316: 
317: }
318: ?>
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0