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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the CONTENIDO layout functions.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       Backend
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Jan Lengowski, Olaf Niemann
 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: cInclude('includes', 'functions.tpl.php');
 19: cInclude('includes', 'functions.con.php');
 20: cInclude('classes', 'class.layout.handler.php');
 21: 
 22: /**
 23:  * Edit or Create a new layout
 24:  *
 25:  * @param int $idlay Id of the Layout
 26:  * @param string $name Name of the Layout
 27:  * @param string $description Description of the Layout
 28:  * @param string $code Layout HTML Code
 29:  * @return int $idlay Id of the new or edited Layout
 30:  */
 31: function layEditLayout($idlay, $name, $description, $code) {
 32:     global $client, $auth, $cfg, $sess, $lang, $area_tree, $perm, $area, $frame, $cfgClient;
 33: 
 34:     $db2 = cRegistry::getDb();
 35:     $db = cRegistry::getDb();
 36: 
 37:     $date = date('Y-m-d H:i:s');
 38:     $author = (string) $auth->auth['uname'];
 39:     $description = (string) stripslashes($description);
 40:     set_magic_quotes_gpc($name);
 41:     set_magic_quotes_gpc($description);
 42: 
 43:     set_magic_quotes_gpc($code);
 44: 
 45:     if (strlen(trim($name)) == 0) {
 46:         $name = i18n('-- Unnamed layout --');
 47:     }
 48: 
 49:     // Replace all not allowed characters..
 50:     $layoutAlias = cModuleHandler::getCleanName(strtolower($name));
 51: 
 52:     // Constructor for the layout in filesystem
 53:     $layoutInFile = new cLayoutHandler($idlay, stripslashes($code), $cfg, $lang);
 54: 
 55:     // Track version
 56:     $oVersion = new cVersionLayout($idlay, $cfg, $cfgClient, $db, $client, $area, $frame);
 57:     // Save layout from file and not from db
 58:     $oVersion->setCode($layoutInFile->getLayoutCode());
 59:     // Create new Layout Version in cms/version/layout/
 60:     $oVersion->createNewVersion();
 61: 
 62:     if (!$idlay) {
 63:         $layoutCollection = new cApiLayoutCollection();
 64:         $layout = $layoutCollection->create($name, $client, $layoutAlias, $description, '1', $author);
 65:         $idlay = $layout->get('idlay');
 66: 
 67:         if ($layoutInFile->saveLayout(stripslashes($code)) == false) {
 68:             cRegistry::addErrorMessage(i18n("Can't save layout in file"));
 69:         } else {
 70:             cRegistry::addInfoMessage(i18n("Saved layout succsessfully!"));
 71:         }
 72: 
 73:         // Set correct rights for element
 74:         cInclude('includes', 'functions.rights.php');
 75:         createRightsForElement('lay', $idlay);
 76: 
 77:         return $idlay;
 78:     } else {
 79:         // Save the layout in file system
 80:         $layoutInFile = new cLayoutHandler($idlay, stripslashes($code), $cfg, $lang);
 81:         // Name changed
 82:         if ($layoutAlias != $layoutInFile->getLayoutName()) {
 83:             // Exist layout in directory
 84:             if (cLayoutHandler::existLayout($layoutAlias, $cfgClient, $client) == true) {
 85:                 // Save in old directory
 86:                 if ($layoutInFile->saveLayout(stripslashes($code)) == false) {
 87:                     cRegistry::addErrorMessage(i18n("Can't save layout in file!"));
 88:                 }
 89: 
 90:                 // Display error
 91:                 cRegistry::addErrorMessage(i18n("Can't rename the layout!"));
 92:                 die();
 93:             }
 94: 
 95:             // Rename the directory
 96:             if ($layoutInFile->rename($layoutInFile->getLayoutName(), $layoutAlias)) {
 97:                 if ($layoutInFile->saveLayout(stripslashes($code)) == false) {
 98:                     cRegistry::addWarningMessage(sprintf(i18n("The file %s has no write permissions. Saving only database changes!"), $layoutInFile->_getFileName()));
 99:                 } else {
100:                     cRegistry::addInfoMessage(i18n("Renamed layout succsessfully!"));
101:                 }
102:                 $layout = new cApiLayout(cSecurity::toInteger($idlay));
103:                 $layout->set('name', $name);
104:                 $layout->set('alias', $layoutAlias);
105:                 $layout->set('description', $description);
106:                 $layout->set('author', $author);
107:                 $layout->set('lastmodified', $date);
108:                 $layout->store();
109:             } else {
110:                 // Rename not successfully
111:                 // Save layout
112:                 if ($layoutInFile->saveLayout(stripslashes($code)) == false) {
113:                     cRegistry::addErrorMessage(i18n("Can't save layout file!"));
114:                 }
115:             }
116:         } else {
117:             // Name dont changed
118:             if ($layoutInFile->saveLayout(stripslashes($code)) == false) {
119:                 cRegistry::addWarningMessage(sprintf(i18n("The file %s has no write permissions. Saving only database changes!"), $layoutInFile->_getFileName()));
120:             } else {
121:                 cRegistry::addInfoMessage(i18n("Saved layout succsessfully!"));
122:             }
123:             $layout = new cApiLayout(cSecurity::toInteger($idlay));
124:             $layout->set('name', $name);
125:             $layout->set('alias', $layoutAlias);
126:             $layout->set('description', $description);
127:             $layout->set('author', $author);
128:             $layout->set('lastmodified', $date);
129:             $layout->store();
130:         }
131: 
132:         // Update CODE table
133:         conGenerateCodeForAllartsUsingLayout($idlay);
134: 
135:         return $idlay;
136:     }
137: }
138: 
139: /**
140:  * Deletes the layout with the given ID from the database and the file system.
141:  *
142:  * @param int $idlay the ID of the layout
143:  * @return string an error code if the layout is still in use
144:  */
145: function layDeleteLayout($idlay) {
146:     global $client, $cfg, $area_tree, $perm, $cfgClient;
147: 
148:     $tplColl = new cApiTemplateCollection();
149:     $tplColl->select('`idlay`=' . $idlay);
150:     if ($tplColl->next()) {
151:         // layout is still in use, you cannot delete it
152:         return '0301';
153:     } else {
154: 
155:         // delete the layout in file system
156:         $layoutInFile = new cLayoutHandler($idlay, '', $cfg, 1);
157:         if ($layoutInFile->eraseLayout()) {
158:             if (cFileHandler::exists($cfgClient[$client]['version']['path'] . "layout" . DIRECTORY_SEPARATOR . $idlay)) {
159:                 cDirHandler::recursiveRmdir($cfgClient[$client]['version']['path'] . "layout" . DIRECTORY_SEPARATOR . $idlay);
160:             }
161: 
162:             // delete layout in database
163:             $layoutCollection = new cApiLayoutCollection();
164:             $layoutCollection->delete($idlay);
165:         } else {
166:             cRegistry::addErrorMessage(i18n("Can't delete layout!"));
167:         }
168:     }
169: 
170:     // Delete rights for element
171:     cInclude('includes', 'functions.rights.php');
172:     deleteRightsForElement('lay', $idlay);
173: }
174: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen