Textpattern | PHP Cross Reference | Content Management Systems |
Description: Form
1 <?php 2 3 /* 4 * Textpattern Content Management System 5 * https://textpattern.com/ 6 * 7 * Copyright (C) 2020 The Textpattern Development Team 8 * 9 * This file is part of Textpattern. 10 * 11 * Textpattern is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation, version 2. 14 * 15 * Textpattern is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with Textpattern. If not, see <https://www.gnu.org/licenses/>. 22 */ 23 24 /** 25 * Form 26 * 27 * Manages Form. 28 * 29 * @since 4.7.0 30 * @package Skin 31 */ 32 33 namespace Textpattern\Skin; 34 35 class Form extends AssetBase implements FormInterface, \Textpattern\Container\FactorableInterface 36 { 37 /** 38 * {@inheritdoc} 39 */ 40 41 protected static $dir = 'forms'; 42 43 /** 44 * {@inheritdoc} 45 */ 46 47 protected static $subdirField = 'type'; 48 49 /** 50 * The expected subdirs for this asset type. 51 * 52 * Note the order of the values is the order the blocks appear in the 53 * Presentation->Forms panel. 54 * 55 * @var array 56 */ 57 58 protected static $subdirValues = array('article', 'misc', 'category', 'comment', 'file', 'link', 'section'); 59 60 /** 61 * {@inheritdoc} 62 */ 63 64 protected static $defaultSubdir = 'misc'; 65 66 /** 67 * {@inheritdoc} 68 */ 69 70 protected static $fileContentsField = 'Form'; 71 72 /** 73 * {@inheritdoc} 74 */ 75 76 protected static $essential = array( 77 array( 78 'name' => 'comments', 79 'type' => 'comment', 80 'Form' => '<!-- Default contents of the comments tag goes here. See https://docs.textpattern.com/tags/comments. -->', 81 ), 82 array( 83 'name' => 'comments_display', 84 'type' => 'comment', 85 'Form' => '<!-- Default contents of the popup_comments tag goes here. See https://docs.textpattern.com/tags/popup_comments. -->', 86 ), 87 array( 88 'name' => 'comment_form', 89 'type' => 'comment', 90 'Form' => '<!-- Default contents of the comments_form tag goes here. See https://docs.textpattern.com/tags/comments_form. -->', 91 ), 92 array( 93 'name' => 'default', 94 'type' => 'article', 95 'Form' => '<!-- Default contents of the article tag goes here. See https://docs.textpattern.com/tags/article. -->', 96 ), 97 array( 98 'name' => 'plainlinks', 99 'type' => 'link', 100 'Form' => '<!-- Default contents of the linklist tag goes here. See https://docs.textpattern.com/tags/linklist. -->', 101 ), 102 array( 103 'name' => 'files', 104 'type' => 'file', 105 'Form' => '<!-- Default contents of the file_download tag goes here. See https://docs.textpattern.com/tags/file_download. -->', 106 ), 107 ); 108 109 /** 110 * Constructor 111 */ 112 113 public function getInstance() 114 { 115 global $lang_ui; 116 117 $textarray = array(); 118 119 if ($custom_types = parse_ini_string(get_pref('custom_form_types'), true)) { 120 foreach ($custom_types as $type => $langpack) { 121 if (!empty($langpack['mediatype'])) { 122 static::$mimeTypes[$type] = $langpack['mediatype']; 123 } 124 125 $textarray[$type] = isset($langpack[$lang_ui]) ? 126 $langpack[$lang_ui] : 127 (isset($langpack['title']) ? 128 $langpack['title'] : 129 (isset(static::$mimeTypes[$type]) ? 130 strtoupper($type)." (".static::$mimeTypes[$type].")" 131 : $type 132 ) 133 ); 134 } 135 } else { 136 $custom_types = array(); 137 } 138 139 \Txp::get('\Textpattern\L10n\Lang')->setPack($textarray, true); 140 141 static::$subdirValues = array_unique(array_merge( 142 static::$subdirValues, 143 array_keys($custom_types), 144 array_keys(static::$mimeTypes) 145 )); 146 147 return $this; 148 } 149 150 /** 151 * {@inheritdoc} 152 */ 153 154 public function setInfos( 155 $name, 156 $type = null, 157 $Form = null 158 ) { 159 $name = $this->setName($name)->getName(); 160 161 $this->infos = compact('name', 'type', 'Form'); 162 163 return $this; 164 } 165 166 /** 167 * $defaultSubdir property getter. 168 */ 169 170 public static function getTypes() 171 { 172 return static::$subdirValues; 173 } 174 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
title