1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
17:
18: cInclude('includes', 'functions.con.php');
19: cInclude('includes', 'functions.upl.php');
20:
21: 22: 23: 24: 25: 26:
27: class cContentTypeLinkeditor extends cContentTypeAbstractTabbed {
28: 29: 30:
31: protected $_dirname = '';
32:
33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46:
47: function __construct($rawSettings, $id, array $contentTypes) {
48:
49:
50: $this->_type = 'CMS_LINKEDITOR';
51: $this->_prefix = 'linkeditor';
52: $this->_settingsType = self::SETTINGS_TYPE_XML;
53: $this->_formFields = array(
54: 'linkeditor_type',
55: 'linkeditor_externallink',
56: 'linkeditor_title',
57: 'linkeditor_newwindow',
58: 'linkeditor_idart',
59: 'linkeditor_filename'
60: );
61:
62:
63: $rawSettings = conHtmlEntityDecode($rawSettings);
64: $rawSettings = utf8_encode($rawSettings);
65:
66:
67: parent::__construct($rawSettings, $id, $contentTypes);
68:
69: $this->_settings['linkeditor_title'] = utf8_decode($this->_settings['linkeditor_title']);
70: $this->_settings['linkeditor_title'] = conHtmlentities($this->_settings['linkeditor_title']);
71:
72:
73:
74:
75: if (isset($_POST['linkeditor_action']) && $_POST['linkeditor_action'] === 'store' && isset($_POST['linkeditor_id']) && (int) $_POST['linkeditor_id'] == $this->_id) {
76:
77:
78: $_POST['linkeditor_title'] = conHtmlentities(conHtmlEntityDecode($_POST['linkeditor_title']));
79: $this->_storeSettings();
80: }
81: }
82:
83: 84: 85: 86: 87:
88: public function getLinkType() {
89: return $this->_settings['linkeditor_type'];
90: }
91:
92: 93: 94: 95: 96:
97: public function getTitle() {
98: return $this->_settings['linkeditor_title'];
99: }
100:
101: 102: 103: 104: 105:
106: public function getTarget() {
107: return ($this->_settings['linkeditor_newwindow'] === 'true') ? '_blank' : '';
108: }
109:
110: 111: 112: 113: 114: 115:
116: public function getLink() {
117: return $this->_generateHref();
118: }
119:
120: 121: 122:
123: public function getFilename()
124: {
125: return $this->_settings['linkeditor_filename'];
126: }
127:
128: 129: 130: 131: 132: 133: 134: 135:
136: public function getConfiguredData() {
137: $data = array(
138: 'type' => $this->_settings['linkeditor_type'],
139: 'externallink' => $this->_settings['linkeditor_externallink'],
140: 'title' => $this->_settings['linkeditor_title'],
141: 'newwindow' => $this->_settings['linkeditor_newwindow'],
142: 'idart' => $this->_settings['linkeditor_idart'],
143: 'filename' => $this->getFilename(),
144: 'href' => $this->_generateHref()
145: );
146:
147: return $data;
148: }
149:
150: 151: 152: 153: 154: 155: 156: 157:
158: public function generateViewCode() {
159:
160: $href = $this->_generateHref();
161: if (empty($href)) {
162: return '';
163: }
164: $linktext = $this->_settings['linkeditor_title'];
165:
166: if (empty($linktext)) {
167: $linktext = $href;
168: }
169: $target = ($this->_settings['linkeditor_newwindow'] === 'true') ? '_blank' : '';
170:
171: $link = new cHTMLLink($href);
172: $link->setClass('link_list');
173: $link->setTargetFrame($target);
174: $link->setContent($linktext);
175:
176: return $this->_encodeForOutput($link->render());
177: }
178:
179: 180: 181: 182: 183: 184: 185:
186: protected function _generateHref() {
187: switch ($this->_settings['linkeditor_type']) {
188: case 'external':
189:
190: $link = $this->_settings['linkeditor_externallink'];
191: if (cString::findFirstPos($link, 'http://') !== 0 && cString::findFirstPos($link, 'www.') === 0) {
192: $link = 'http://' . $link;
193: }
194: return $link;
195: break;
196: case 'internal':
197: if (cString::getPartOfString($this->_settings['linkeditor_idart'], 0, 8) == 'category') {
198:
199: $uriInstance = cUri::getInstance();
200: $uriBuilder = $uriInstance->getUriBuilder();
201: $uriParams = array(
202: 'idcat' => cSecurity::toInteger(cString::getPartOfString($this->_settings['linkeditor_idart'], 9))
203: );
204: $uriBuilder->buildUrl($uriParams, true);
205:
206: return $uriBuilder->getUrl();
207: } else if ($this->_settings['linkeditor_idart'] != "") {
208:
209: $oUri = cUri::getInstance();
210: $uriBuilder = $oUri->getUriBuilder();
211: $uriParams = array(
212: 'idart' => cSecurity::toInteger($this->_settings['linkeditor_idart'])
213: );
214: $uriBuilder->buildUrl($uriParams, true);
215:
216: return $uriBuilder->getUrl();
217:
218: }
219: break;
220: case 'file':
221: if (!empty($this->getFilename())) {
222: return $this->_cfgClient[$this->_client]['upl']['htmlpath'] . $this->getFilename();
223: } else {
224: return '';
225: }
226: break;
227: default:
228:
229: return '';
230: }
231: }
232:
233: 234: 235: 236: 237: 238: 239: 240: 241:
242: public function generateEditCode() {
243: $template = new cTemplate();
244: $template->set('s', 'ID', $this->_id);
245: $template->set('s', 'IDARTLANG', $this->_idArtLang);
246: $template->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
247:
248: $templateTabs = new cTemplate();
249: $templateTabs->set('s', 'PREFIX', $this->_prefix);
250:
251:
252: $templateTabs->set('d', 'TAB_ID', 'external');
253: $templateTabs->set('d', 'TAB_CLASS', 'external');
254: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabExternal());
255: $templateTabs->next();
256:
257:
258: $templateTabs->set('d', 'TAB_ID', 'internal');
259: $templateTabs->set('d', 'TAB_CLASS', 'internal');
260: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabInternal());
261: $templateTabs->next();
262:
263:
264: $templateTabs->set('d', 'TAB_ID', 'file');
265: $templateTabs->set('d', 'TAB_CLASS', 'file');
266: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateTabFile());
267: $templateTabs->next();
268:
269:
270:
271: $templateTabs->set('d', 'TAB_ID', 'basic-settings');
272: $templateTabs->set('d', 'TAB_CLASS', 'basic-settings');
273: $templateTabs->set('d', 'TAB_CONTENT', $this->_generateBasicSettings());
274: $templateTabs->next();
275:
276: $codeTabs = $templateTabs->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_tabs.html', true);
277:
278:
279: $templateTop = new cTemplate();
280: $templateTop->set('s', 'ICON', 'images/but_editlink.gif');
281: $templateTop->set('s', 'ID', $this->_id);
282: $templateTop->set('s', 'PREFIX', $this->_prefix);
283: $templateTop->set('s', 'HEADLINE', i18n('Link settings'));
284: $codeTop = $templateTop->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_top.html', true);
285:
286:
287: $tabMenu = array(
288: 'external' => i18n('External link'),
289: 'internal' => i18n('Internal link'),
290: 'file' => i18n('Link to a file')
291: );
292:
293:
294: $templateBottom = new cTemplate();
295: $templateBottom->set('s', 'PATH_FRONTEND', $this->_cfgClient[$this->_client]['path']['htmlpath']);
296: $templateBottom->set('s', 'ID', $this->_id);
297: $templateBottom->set('s', 'PREFIX', $this->_prefix);
298: $templateBottom->set('s', 'IDARTLANG', $this->_idArtLang);
299: $templateBottom->set('s', 'FIELDS', "'" . implode("','", $this->_formFields) . "'");
300: $templateBottom->set('s', 'SETTINGS', json_encode($this->_settings));
301: $templateBottom->set('s', 'JS_CLASS_SCRIPT', $this->_cfg['path']['contenido_fullhtml'] . 'scripts/content_types/cmsLinkeditor.js');
302: $templateBottom->set('s', 'JS_CLASS_NAME', 'Con.cContentTypeLinkeditor');
303: $codeBottom = $templateBottom->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_abstract_tabbed_edit_bottom.html', true);
304:
305:
306: $code = $this->generateViewCode();
307: $code .= $this->_encodeForOutput($codeTop);
308: $code .= $this->_generateTabMenuCode($tabMenu);
309: $code .= $this->_encodeForOutput($codeTabs);
310: $code .= $this->_generateActionCode();
311: $code .= $this->_encodeForOutput($codeBottom);
312:
313: return $code;
314: }
315:
316: 317: 318: 319: 320: 321: 322:
323: private function _generateTabExternal() {
324:
325: $wrapper = new cHTMLDiv();
326: $wrapperContent = array();
327:
328: $wrapperContent[] = new cHTMLLabel(i18n('Href'), 'linkeditor_externallink_' . $this->_id);
329: $wrapperContent[] = new cHTMLTextbox('linkeditor_externallink_' . $this->_id, $this->_settings['linkeditor_externallink'], '', '', 'linkeditor_externallink_' . $this->_id);
330:
331: $wrapper->setContent($wrapperContent);
332:
333: return $wrapper->render();
334: }
335:
336: 337: 338: 339: 340: 341: 342: 343: 344:
345: private function _generateBasicSettings() {
346:
347:
348: $wrapper = new cHTMLDiv();
349: $wrapperContent = array();
350:
351: $wrapperContent[] = new cHTMLLabel(i18n('Title'), 'linkeditor_title_' . $this->_id);
352: $title = conHtmlEntityDecode($this->_settings['linkeditor_title']);
353: $wrapperContent[] = new cHTMLTextbox('linkeditor_title_' . $this->_id, $title, '', '', 'linkeditor_title_' . $this->_id);
354: $wrapperContent[] = new cHTMLCheckbox('linkeditor_newwindow_' . $this->_id, '', 'linkeditor_newwindow_' . $this->_id, ($this->_settings['linkeditor_newwindow'] === 'true'));
355: $wrapperContent[] = new cHTMLLabel(i18n('Open in a new window'), 'linkeditor_newwindow_' . $this->_id);
356:
357: $wrapper->setContent($wrapperContent);
358:
359: return $wrapper->render();
360: }
361:
362: 363: 364: 365: 366: 367: 368: 369:
370: private function _generateTabInternal() {
371:
372: $wrapper = new cHTMLDiv();
373: $wrapperContent = array();
374:
375: $directoryList = new cHTMLDiv('', 'directoryList', 'directoryList' . '_' . $this->_id);
376: $liRoot = new cHTMLListItem('root', 'last');
377: $aUpload = new cHTMLLink('#');
378: $aUpload->setClass('on');
379: $aUpload->setAttribute('title', '0');
380: $aUpload->setContent('Root');
381:
382: $div = new cHTMLDiv(array(
383: '<em><a href="#"></a></em>',
384: $aUpload
385: ));
386: $liRoot->setContent(array(
387: $div,
388: ));
389: $conStrTree = new cHTMLList('ul', 'con_str_tree', 'con_str_tree', $liRoot);
390: $directoryList->setContent($conStrTree);
391: $wrapperContent[] = $directoryList;
392: $wrapperContent[] = new cHTMLDiv($this->generateArticleSelect(), 'directoryFile', 'directoryFile' . '_' . $this->_id);
393:
394: $wrapper->setContent($wrapperContent);
395:
396: return $wrapper->render();
397: }
398:
399: 400: 401: 402: 403: 404: 405: 406: 407: 408:
409: public function buildCategoryArray($level = 0, $parentid = 0) {
410: $db = cRegistry::getDb();
411: $directories = array();
412: $sql = 'SELECT distinct
413: *
414: FROM
415: ' . $this->_cfg['tab']['cat_tree'] . ' AS a,
416: ' . $this->_cfg['tab']['cat'] . ' AS c,
417: ' . $this->_cfg['tab']['cat_lang'] . ' AS d
418: WHERE
419: a.level = ' . $level . ' AND
420: c.parentid = ' . $parentid . ' AND
421: a.idcat = d.idcat AND
422: c.idcat = a.idcat AND
423: d.idlang = ' . cSecurity::toInteger($this->_lang) . ' AND
424: c.idclient = ' . cSecurity::toInteger($this->_client) . '
425: ORDER BY
426: a.idtree';
427:
428: $db->query($sql);
429: while ($db->nextRecord()) {
430: $directory = array();
431: $directory['idcat'] = $db->f('idcat');
432: $directory['name'] = $db->f('name');
433: $directory['sub'] = $this->buildCategoryArray($level + 1, $directory['idcat']);
434: $directories[] = $directory;
435: }
436:
437: return $directories;
438: }
439:
440: 441: 442: 443: 444: 445: 446: 447: 448: 449:
450: public function getCategoryList(array $categories) {
451: $template = new cTemplate();
452: $i = 1;
453:
454: foreach ($categories as $category) {
455: $activeIdcats = $this->getActiveIdcats();
456:
457: $divClass = (isset($activeIdcats[0]) && $category['idcat'] == $activeIdcats[0]) ? 'active' : '';
458: $template->set('d', 'DIVCLASS', $divClass);
459:
460: $template->set('d', 'TITLE', $category['idcat']);
461: $template->set('d', 'DIRNAME', $category['name']);
462:
463: $liClasses = array();
464:
465: if (in_array($category['idcat'], $activeIdcats) && $category['sub'] != '') {
466: $template->set('d', 'SUBDIRLIST', $this->getCategoryList($category['sub']));
467: } else if ($category['sub'] != '' && count($category['sub']) > 0) {
468: $liClasses[] = 'collapsed';
469: $template->set('d', 'SUBDIRLIST', '');
470: } else {
471: $template->set('d', 'SUBDIRLIST', '');
472: }
473:
474: if ($i === count($categories)) {
475: $liClasses[] = 'last';
476: }
477:
478: $template->set('d', 'LICLASS', implode(' ', $liClasses));
479:
480: $i++;
481: $template->next();
482: }
483:
484: return $template->generate($this->_cfg['path']['contenido'] . 'templates/standard/template.cms_filelist_dirlistitem.html', true);
485: }
486:
487: 488: 489: 490: 491: 492: 493:
494: public function getActiveIdcats() {
495: $activeIdcats = array();
496: if ($this->_settings['linkeditor_type'] === 'internal') {
497: if (cSecurity::isInteger($this->_settings['linkeditor_idart'])) {
498: $sql = 'SELECT distinct
499: *
500: FROM
501: ' . $this->_cfg['tab']['cat_tree'] . ' AS a,
502: ' . $this->_cfg['tab']['cat_art'] . ' AS b,
503: ' . $this->_cfg['tab']['cat'] . ' AS c,
504: ' . $this->_cfg['tab']['cat_lang'] . ' AS d
505: WHERE
506: b.idart = ' . cSecurity::toInteger($this->_settings['linkeditor_idart']) . ' AND
507: a.idcat = d.idcat AND
508: b.idcat = c.idcat AND
509: c.idcat = a.idcat AND
510: d.idlang = ' . cSecurity::toInteger($this->_lang) . ' AND
511: c.idclient = ' . cSecurity::toInteger($this->_client) . '
512: ORDER BY
513: a.idtree';
514: } else if (cString::getPartOfString($this->_settings['linkeditor_idart'], 0, 8) == 'category') {
515: $sql = 'SELECT distinct
516: *
517: FROM
518: ' . $this->_cfg['tab']['cat_tree'] . ' AS a,
519: ' . $this->_cfg['tab']['cat_art'] . ' AS b,
520: ' . $this->_cfg['tab']['cat'] . ' AS c,
521: ' . $this->_cfg['tab']['cat_lang'] . ' AS d
522: WHERE
523: b.idcat = ' . cSecurity::toInteger(cString::getPartOfString($this->_settings['linkeditor_idart'], 9)) . ' AND
524: a.idcat = d.idcat AND
525: b.idcat = c.idcat AND
526: c.idcat = a.idcat AND
527: d.idlang = ' . cSecurity::toInteger($this->_lang) . ' AND
528: c.idclient = ' . cSecurity::toInteger($this->_client) . '
529: ORDER BY
530: a.idtree';
531: }
532: $db = cRegistry::getDb();
533: $db->query($sql);
534: while ($db->nextRecord()) {
535: $activeIdcats = $this->_getParentIdcats($db->f('idcat'));
536: }
537: }
538:
539: return $activeIdcats;
540: }
541:
542: 543: 544: 545: 546: 547: 548: 549: 550: 551:
552: private function _getParentIdcats($idcat, array $idcats = array()) {
553:
554: $idcats[] = $idcat;
555:
556:
557: $category = new cApiCategory($idcat);
558: $parentId = $category->get('parentid');
559: if ($parentId != 0) {
560: $idcats = $this->_getParentIdcats($parentId, $idcats);
561: }
562:
563: return $idcats;
564: }
565:
566: 567: 568: 569: 570: 571: 572: 573: 574:
575: public function generateArticleSelect($idCat = 0) {
576: $htmlSelect = new cHTMLSelectElement('linkeditor_idart', '', 'linkeditor_idart_' . $this->_id);
577: $htmlSelect->setSize(16);
578:
579:
580:
581: $checkCategorySelection = ((cString::getPartOfString($this->_settings['linkeditor_idart'], 0, 8) == 'category' ? true : false));
582: $htmlSelectOptionCategory = new cHTMLOptionElement('- ' . i18n('Select category') . ' -', 'category-' . $idCat, $checkCategorySelection);
583: $htmlSelect->appendOptionElement($htmlSelectOptionCategory);
584:
585:
586: $htmlSelectOptionNothing = new cHTMLOptionElement('- '. i18n('Neither') . ' -', '', false);
587: $htmlSelect->appendOptionElement($htmlSelectOptionNothing);
588:
589:
590: if (empty($idCat)) {
591: return $htmlSelect->render();
592: }
593:
594:
595:
596: $sql = 'SELECT distinct
597: e.*
598: FROM
599: ' . $this->_cfg['tab']['cat_tree'] . ' AS a,
600: ' . $this->_cfg['tab']['cat_art'] . ' AS b,
601: ' . $this->_cfg['tab']['cat'] . ' AS c,
602: ' . $this->_cfg['tab']['cat_lang'] . ' AS d,
603: ' . $this->_cfg['tab']['art_lang'] . ' AS e
604: WHERE
605: c.idcat = ' . $idCat . ' AND
606: e.online = 1 AND
607: a.idcat = b.idcat AND
608: b.idcat = d.idcat AND
609: d.idlang = ' . cSecurity::toInteger($this->_lang) . ' AND
610: b.idart = e.idart AND
611: c.idcat = a.idcat AND
612: c.idclient = ' . cSecurity::toInteger($this->_client) . ' AND
613: e.idlang = ' . cSecurity::toInteger($this->_lang) . '
614: ORDER BY
615: e.title';
616: $db = cRegistry::getDb();
617: $db->query($sql);
618: while ($db->nextRecord()) {
619: $htmlSelectOption = new cHTMLOptionElement($db->f('title'), $db->f('idart'), ($db->f('idart') == $this->_settings['linkeditor_idart']));
620: $htmlSelect->appendOptionElement($htmlSelectOption);
621: }
622:
623: return $htmlSelect->render();
624: }
625:
626: 627: 628: 629: 630: 631: 632: 633:
634: private function _generateTabFile() {
635:
636: $wrapper = new cHTMLDiv();
637: $wrapperContent = array();
638:
639:
640: $newDirForm = new cHTMLForm();
641: $newDirForm->setAttribute('name', 'newdir');
642: $newDirForm->setAttribute('method', 'post');
643: $newDirForm->setAttribute('action', $this->_cfg['path']['contenido_fullhtml'] . 'main.php');
644: $caption1Span = new cHTMLSpan();
645: $caption1Span->setID('caption1');
646: $newDirHead = new cHTMLDiv(array(
647: '<b>' . i18n('Create a directory in') . '</b>',
648: $caption1Span
649: ));
650: $area = new cHTMLHiddenField('area', 'upl');
651: $action = new cHTMLHiddenField('action', 'upl_mkdir');
652: $frame = new cHTMLHiddenField('frame', '2');
653: $appendparameters = new cHTMLHiddenField('appendparameters');
654: $contenido = new cHTMLHiddenField('contenido', $_REQUEST['contenido']);
655: $path = new cHTMLHiddenField('path');
656: $foldername = new cHTMLTextbox('foldername');
657: $button = new cHTMLButton('', '', '', false, NULL, '', 'image');
658: $button->setAttribute('src', $this->_cfg['path']['contenido_fullhtml'] . 'images/submit.gif');
659: $newDirContent = new cHTMLDiv(array(
660: $area,
661: $action,
662: $frame,
663: $appendparameters,
664: $contenido,
665: $path,
666: $foldername,
667: $button
668: ));
669: $newDirForm->setContent(array(
670: $newDirHead,
671: $newDirContent
672: ));
673: $wrapperContent[] = $newDirForm;
674:
675:
676: $propertiesForm = new cHTMLForm();
677: $propertiesForm->setID('properties' . $this->_id);
678: $propertiesForm->setAttribute('name', 'properties');
679: $propertiesForm->setAttribute('method', 'post');
680: $propertiesForm->setAttribute('action', $this->_cfg['path']['contenido_fullhtml'] . 'main.php');
681: $propertiesForm->setAttribute('enctype', 'multipart/form-data');
682: $frame = new cHTMLHiddenField('frame', '4');
683: $area = new cHTMLHiddenField('area', 'upl');
684: $path = new cHTMLHiddenField('path');
685: $file = new cHTMLHiddenField('file');
686: $action = new cHTMLHiddenField('action', 'upl_upload');
687: $appendparameters = new cHTMLHiddenField('appendparameters');
688: $contenido = new cHTMLHiddenField('contenido', $_REQUEST['contenido']);
689: $caption2Span = new cHTMLSpan();
690: $caption2Span->setID('caption2');
691: $propertiesHead = new cHTMLDiv(array(
692: '<b>' . i18n('Path') . '</b>',
693: $caption2Span
694: ));
695: $imageUpload = new cHTMLUpload('file[]', '', '', 'cms_image_m' . $this->_id, false, '', '', 'file');
696: $imageUpload->setClass('jqueryAjaxUpload');
697: $propertiesForm->setContent(array(
698: $frame,
699: $area,
700: $path,
701: $file,
702: $action,
703: $appendparameters,
704: $contenido,
705: $propertiesHead,
706: $imageUpload
707: ));
708: $wrapperContent[] = $propertiesForm;
709:
710: $wrapperContent[] = new cHTMLImage($this->_cfg['path']['contenido_fullhtml'] . 'images/ajax-loader.gif', 'loading');
711:
712:
713: $directoryList = new cHTMLDiv('', 'directoryList', 'directoryList_' . $this->_id);
714: $liRoot = new cHTMLListItem('root', 'last');
715: $aUpload = new cHTMLLink('#');
716: $aUpload->setClass('on');
717: $aUpload->setAttribute('title', 'upload');
718: $aUpload->setContent('Uploads');
719: $directoryListCode = $this->generateDirectoryList($this->buildDirectoryList());
720: $div = new cHTMLDiv(array(
721: '<em><a href="#"></a></em>',
722: $aUpload
723: ));
724:
725: if (dirname($this->getFilename()) === '\\') {
726: $div->setClass('active');
727: }
728: $liRoot->setContent(array(
729: $div
730: ));
731: $conStrTree = new cHTMLList('ul', 'con_str_tree', 'con_str_tree', $liRoot);
732: $directoryList->setContent($conStrTree);
733: $wrapperContent[] = $directoryList;
734:
735: $wrapperContent[] = new cHTMLDiv($this->getUploadFileSelect('', true), 'directoryFile', 'directoryFile' . '_' . $this->_id);
736:
737: $wrapper->setContent($wrapperContent);
738:
739: return $wrapper->render();
740: }
741:
742: 743: 744: 745: 746: 747: 748: 749: 750: 751:
752: public function getUploadFileSelect($directoryPath = '', $isEmptySelect = false) {
753:
754: $directoryPath = str_replace('\\', '/', $directoryPath);
755:
756:
757: if ($directoryPath === '/') {
758: $directoryPath = '';
759: }
760:
761: if ($directoryPath !== '' && cString::getPartOfString($directoryPath, -1) != '/') {
762: $directoryPath .= '/';
763: }
764:
765: $htmlSelect = new cHTMLSelectElement('linkeditor_filename', '', 'linkeditor_filename_' . $this->_id);
766: $htmlSelect->setSize(16);
767: $htmlSelectOption = new cHTMLOptionElement('Kein', '', false);
768: $htmlSelect->addOptionElement(0, $htmlSelectOption);
769:
770: if (!$isEmptySelect) {
771: $files = array();
772: if (is_dir($this->_uploadPath . $directoryPath)) {
773:
774: if (false !== ($handle = cDirHandler::read($this->_uploadPath . $directoryPath, false, false, true))) {
775: foreach ($handle as $entry) {
776: if (cFileHandler::fileNameBeginsWithDot($entry) === false) {
777: $file = array();
778: $file["name"] = $entry;
779: $file["path"] = $directoryPath . $entry;
780: $files[] = $file;
781: }
782: }
783: }
784: }
785:
786: usort($files, function($a, $b) {
787: $a = cString::toLowerCase($a["name"]);
788: $b = cString::toLowerCase($b["name"]);
789: if($a < $b) {
790: return -1;
791: } else if($a > $b) {
792: return 1;
793: } else {
794: return 0;
795: }
796: });
797:
798: $i = 1;
799: foreach($files as $file) {
800: $htmlSelectOption = new cHTMLOptionElement($file["name"], $file["path"]);
801: $htmlSelect->addOptionElement($i, $htmlSelectOption);
802: $i++;
803: }
804:
805:
806: if ($this->_settings['linkeditor_type'] === 'file') {
807: $htmlSelect->setDefault($this->getFilename());
808: }
809: }
810:
811: return $htmlSelect->render();
812: }
813:
814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824:
825: protected function _isActiveDirectory(array $dirData) {
826: return $dirData['path'] . $dirData['name'] === dirname($this->getFilename());
827: }
828:
829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839:
840: protected function _shouldDirectoryBeExpanded(array $dirData) {
841: return $this->_isSubdirectory($dirData['path'] . $dirData['name'], $this->_dirname);
842: }
843:
844: }
845: