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:  * Project:
  4:  * CONTENIDO Content Management System
  5:  *
  6:  * Description:
  7:  * TINYMCE 4 PHP WYSIWYG interface
  8:  * Generates file/link list for editor
  9:  *
 10:  * Requirements:
 11:  * @con_php_req 5.3
 12:  * @con_notice
 13:  * TINYMCE 4 Fileversion
 14:  *
 15:  * @package    CONTENIDO Backend Editor
 16:  * @version    0.0.1
 17:  * @author     Thomas Stauer
 18:  * @copyright  four for business AG <www.4fb.de>
 19:  * @license    http://www.contenido.org/license/LIZENZ.txt
 20:  * @link       http://www.4fb.de
 21:  * @link       http://www.contenido.org
 22:  */
 23: 
 24: if (!defined('CON_FRAMEWORK')) {
 25:     define('CON_FRAMEWORK', true);
 26: }
 27: 
 28: // CONTENIDO startup process
 29: $contenido_path = str_replace('\\', '/', realpath(dirname(__FILE__) . '/../../../../../')) . '/';
 30: 
 31: if (!is_file($contenido_path . 'includes/startup.php')) {
 32:     die("<h1>Fatal Error</h1><br>Couldn't include CONTENIDO startup.");
 33: }
 34: include_once($contenido_path . 'includes/startup.php');
 35: 
 36: cRegistry::bootstrap(array(
 37:     'sess' => 'cSession',
 38:     'auth' => 'cAuthHandlerBackend',
 39:     'perm' => 'cPermission'
 40: ));
 41: 
 42: // include editor config/combat file
 43: include(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'config.php');
 44: 
 45: $db = cRegistry::getDb();
 46: 
 47: cInclude('includes', 'functions.lang.php');
 48: 
 49: $mediaList = new cTinyMCE4List($_GET['mode']);
 50: 
 51: /**
 52:  */
 53: class cTinyMCE4List {
 54: 
 55:     /**
 56:      */
 57:     public function __construct($mode = null) {
 58:         // output an empty list for no specified mode
 59:         if (false === isset($mode)) {
 60:             echo '[]';
 61:             return;
 62:         }
 63: 
 64:         $list = array();
 65:         // process defined list modes
 66:         switch ($mode) {
 67:             case 'image':
 68:                 $list = $this->_buildImageList();
 69:                 break;
 70:             case 'link':
 71:                 $list = $this->_buildLinkList();
 72:                 break;
 73:             default:
 74:                 // just output an empty list for unknown mode
 75:         }
 76:         
 77:         $this->_printList($list);
 78:     }
 79:     
 80:     /**
 81:      * get a list of images that is accessible for tinymce
 82:      * @return array The array of images filled with upload objects
 83:      */
 84:     private function _buildImageList() {
 85:         $client = cRegistry::getClientId();
 86:         $clientConfig = cRegistry::getClientConfig($client);
 87: 
 88:         // get needed data using cApiUploadCollection class
 89:         $oApiUploadCol = new cApiUploadCollection();
 90:         // get uploads for current client
 91:         // filetype can be either gif, jpg, jpeg or png
 92: 
 93:         $selectClause = "idclient='" . cSecurity::toInteger($client) . "' AND filetype IN ('gif', 'jpg', 'jpeg', 'png')";
 94:         $oApiUploadCol->select($selectClause, '', 'dirname, filename ASC');
 95:         // $oApiUploadCol->setWhere('idclient', cSecurity::toInteger($client));
 96:         // $oApiUploadCol->setWhere('filetype', array('gif', 'jpg', 'jpeg', 'png'), 'IN');
 97:         // $oApiUploadCol->setOrder('dirname, filename ASC');
 98:         // $oApiUploadCol->query();
 99:         $aUplList = $oApiUploadCol->fetchArray($oApiUploadCol->primaryKey, array('idclient', 'dirname', 'filetype', 'filename'));
100: 
101:         $imageList = array();
102:         foreach ($aUplList as $uplItem) {
103:             $imageItem = new stdClass();
104:             $imageItem->title = $uplItem['dirname'] . $uplItem['filename'];
105:             $imageItem->value = $clientConfig['upload'] . $uplItem['dirname'] . $uplItem['filename'];
106:             
107:             $imageList[] = $imageItem;
108:         }
109: 
110:         return $imageList;
111:     }
112: 
113:     /**
114:      * This function helps adding the category entries to the wood according to their deepness level
115:      * @param array $woodTree
116:      * @param int $lvl The level where entry should be inserted into wood. Level 0 means we enter a tree to the wood.
117:      * @param stdClass $entry The entry to add into the wood.
118:      * @return array The altered woodTree with newly inserted entry at the correct level.
119:      */
120:     private function _addToWoodTree($woodTree, $lvl, $entry) {
121:         // add to wood if its a tree root
122:         if ($lvl === 0) {
123:             $woodTree[] = $entry;
124:             return $woodTree;
125:         }
126: 
127:         // get copy of catTree
128:         $res = unserialize(serialize($woodTree));
129: 
130:         // use pseudo-reference to manipulate result in-place
131:         $scope = &$res;
132:         for ($i = $lvl; $i > 0; $i--) {
133:             // set pointer to last element of array
134:             end($scope);
135:             // get reference to last element of array
136:             $scope = &$scope[key($scope)];
137:             // add menu property to object if it does not exist
138:             if (false === isset($scope->menu)) {
139:                 $scope->menu = array();
140:             }
141:             // get reference to menu
142:             $scope = &$scope->menu;
143:         }
144: 
145:         // add entry to scope
146:         // because scope is a reference the res variable is altered at the correct place, too
147:         $scope[] = $entry;
148: 
149:         // we're done
150:         return $res;
151: 
152:     }
153: 
154:     /**
155:      * get a list of links to articles for current client and language
156:      * @return array The array of articles filled with link objects
157:      */
158:     private function _buildLinkList() {
159:         global $client, $lang;
160: 
161:         $linkList = array();
162: 
163:         $catTree = new cApiCategoryTreeCollection();
164:         $catList = $catTree->getCategoryTreeStructureByClientIdAndLanguageId($client, $lang);
165: 
166:         foreach ($catList as $catEntry) {
167:             $tmp_catname = $catEntry['name'];
168:             if ($catEntry['visible'] == 0) {
169:                 $tmp_catname = "[" . $tmp_catname . "]";
170:             }
171:             $listEntry = (object) array('title' => $tmp_catname,
172:                                         'value' => 'front_content.php?idcat=' . $catEntry['idcat']);
173: 
174:             $linkList = $this->_addToWoodTree($linkList, (int) $catEntry['level'], $listEntry);
175: 
176:             $options = array();
177:             $options['idcat'] = $catEntry['idcat'];
178:             // order by title
179:             $options['order'] = 'title';
180:             // order ascending
181:             $options['direction'] = 'asc';
182:             // include start articles
183:             $options['start'] = true;
184:             // show offline articles
185:             $options['offline'] = true;
186: 
187: 
188:             // create cArticleCollector instance with specified options
189:             $articleCollector = new cArticleCollector($options);
190: 
191:             // add subcategories to communicate category structure
192:             if (0 === count($articleCollector)) {
193:                 continue;
194:             }
195: 
196:             $listEntry->menu = array();
197:             $listEntry->menu[] = (object) array('title' => $tmp_catname . ' ' . i18n('Category'),
198:                                                 'value' => 'front_content.php?idcat=' . $catEntry['idcat']
199:             );
200: 
201:             foreach ($articleCollector as $articleLanguage) {
202:                 $tmp_title = $articleLanguage->get("title");
203: 
204:                 if (strlen($tmp_title) > 32) {
205:                     $tmp_title = substr($tmp_title, 0, 32);
206:                 }
207: 
208:                 $is_start = isStartArticle($articleLanguage->get('idartlang'), $catEntry['idcat'], $lang);
209:             
210:                 if ($is_start) {
211:                     $tmp_title .= "*";
212:                 }
213: 
214:                 if ('0' === $articleLanguage->get("online")) {
215:                     $tmp_title = "[" . $tmp_title . "]";
216:                 }
217:                 $articleEntry = new stdClass();
218:                 $articleEntry->title = $tmp_title;
219:                 $articleEntry->value = 'front_content.php?idart=' . $articleLanguage->get('idart');
220:                 $listEntry->menu[] = $articleEntry;
221:             }
222:         }
223:         return $linkList;
224:     }
225: 
226:     /**
227:      * Output the created list as JSON.
228:      */
229:     private function _printList($list) {
230:         echo json_encode($list);
231:     }
232: }
233: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen