root/trunk/wifidog-auth/wifidog/classes/Content/SimpleString/SimpleString.php @ 1177

Revision 1177, 7.6 KB (checked in by fproulx, 6 years ago)

2007-01-28 François Proulx <francois.proulx@…>

  • First iteration of user profiles completed.
  • Need to improve Avatar admin UI


  • Property svn:executable set to *
Line 
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5// +-------------------------------------------------------------------+
6// | WiFiDog Authentication Server                                     |
7// | =============================                                     |
8// |                                                                   |
9// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
10// | portal suite.                                                     |
11// +-------------------------------------------------------------------+
12// | PHP version 5 required.                                           |
13// +-------------------------------------------------------------------+
14// | Homepage:     http://www.wifidog.org/                             |
15// | Source Forge: http://sourceforge.net/projects/wifidog/            |
16// +-------------------------------------------------------------------+
17// | This program is free software; you can redistribute it and/or     |
18// | modify it under the terms of the GNU General Public License as    |
19// | published by the Free Software Foundation; either version 2 of    |
20// | the License, or (at your option) any later version.               |
21// |                                                                   |
22// | This program is distributed in the hope that it will be useful,   |
23// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
24// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
25// | GNU General Public License for more details.                      |
26// |                                                                   |
27// | You should have received a copy of the GNU General Public License |
28// | along with this program; if not, contact:                         |
29// |                                                                   |
30// | Free Software Foundation           Voice:  +1-617-542-5942        |
31// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
32// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
33// |                                                                   |
34// +-------------------------------------------------------------------+
35
36/**
37 * @package    WiFiDogAuthServer
38 * @subpackage ContentClasses
39 * @author     Benoit Grégoire <bock@step.polymtl.ca>
40 * @copyright  2007 Benoit Grégoire, Technologies Coeus inc.
41 * @version    Subversion $Id: $
42 * @link       http://www.wifidog.org/
43 */
44
45/**
46 * Load required classes
47 */
48require_once('classes/LocaleList.php');
49require_once('classes/Locale.php');
50
51/**
52 * Represents a simple Langstring (no title, description, etc.)
53 *
54 * @package    WiFiDogAuthServer
55 * @subpackage ContentClasses
56 * @author     Benoit Grégoire <bock@step.polymtl.ca>
57 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc.
58 */
59class SimpleString extends Langstring
60{
61    /**
62     * Constructor
63     *
64     * @param string $content_id Content id
65     *
66     * @return void     */
67    protected function __construct($content_id)
68    {
69        parent::__construct($content_id);
70                $this->allowed_html_tags = "";
71        /*
72         * A SimpleString is NEVER persistent
73         */
74        parent::setIsPersistent(false);
75    }
76    /** When a content object is set as Simple, it means that is is used merely to contain it's own data.  No title, description or other metadata will be set or displayed, during display or administration
77     * @return true or false */
78    public function isSimpleContent() {
79        return true;
80    }
81   
82      /**
83     * Retreives the admin interface of this object. Anything that overrides
84     * this method should call the parent method with it's output at the END of
85     * processing.
86     * @param string $subclass_admin_interface HTML content of the interface
87     * element of a children.
88     * @param string $type_interface SIMPLE pour éditer un seul champ, COMPLETE
89     *                               pour voir toutes les chaînes, LARGE pour
90     *                               avoir un textarea.
91     * @return string The HTML fragment for this interface.
92     */
93    public function getAdminUI($subclass_admin_interface = null, $title = null, $type_interface = "LARGE") {
94        // Init values.
95        $html = '';
96        $html .= $subclass_admin_interface;
97        $result = "";
98        //$variantsCounter = 0;
99        //$_hideNewContent = false;
100        if (!empty ($this->allowed_html_tags)) {
101            $html .= "<div class='admin_section_hint'>" . _("Only these HTML tags are allowed : ") . htmlentities($this->allowed_html_tags) . "</div>";
102        }
103        $html .= "<ul class='admin_element_list'>\n";
104        $liste_languages = new LocaleList();
105        $sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '$this->id' ORDER BY locales_id";
106        $this->mBd->execSql($sql, $result, false); //echo "type_interface: $type_interface\n";
107
108        $exclude_array = array ();
109        if ($result != null) {
110            while (list ($key, $value) = each($result)) {
111                $exclude_array[$value['locales_id']] = $value['locales_id'];
112 
113                $html .= "<li class='admin_element_item_container'>\n";
114                $html .= "<div class='admin_element_data'>\n";
115                $name = "langstrings_" . $this->id . "_substring_$value[langstring_entries_id]_language";
116                $html .= "<input type='hidden' name='$name' value=''>\n";
117                if ($type_interface == 'LARGE') {
118                    $html .= "<textarea name='langstrings_" . $this->id . "_substring_$value[langstring_entries_id]_string' class='textarea' cols='60' rows='3'>" . htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8') . "</textarea>\n";
119                } else {
120                    $html .= "<input type='text' class='input_text' name='langstrings_" . $this->id . "_substring_$value[langstring_entries_id]_string' size='44' value='" . htmlspecialchars($value['value'], ENT_QUOTES, 'UTF-8') . "'>\n";
121                }
122
123                $html .= "</div>\n";
124                $html .= "</li>\n";
125            }
126        }
127
128        //Nouvelles chaîne
129        if($result == null) {
130            $html .= "<li class='admin_element_item_container'>\n";
131            $html .= "<div class='admin_element_data'>\n";
132            $name = "langstrings_" . $this->id . "_substring_new_language";
133            $html .= "<input type='hidden' name='$name' value=''>\n";
134            $new_substring_name = "langstrings_" . $this->id . "_substring_new_string";
135
136            if ($type_interface == 'LARGE') {
137                $html .= "<textarea name='$new_substring_name' class='textarea' cols='60' rows='3'></textarea>\n";
138            } else {
139                $html .= "<input type='text' name='$new_substring_name' class='input_text' size='44' value=''>\n";
140            }
141
142            $html .= "</div>\n";
143            $html .= "</li>\n";
144        }
145        $html .= "</ul>\n";
146
147        return Content :: getAdminUI($html, $title);
148    }
149   
150    /**
151     * A short string representation of the content
152     *
153     * @return string Returns the content
154     */
155    public function __toString($verbose = true)
156    {
157        return strip_tags($this->getString($verbose));
158    }
159
160    /**
161     * Reloads the object from the database.
162     *
163     * Should normally be called after a set operation.
164     *
165     * This function is private because calling it from a subclass will call the
166     * constructor from the wrong scope
167     *
168     * @return void
169
170     */
171    private function refresh()
172    {
173        $this->__construct($this->id);
174    }
175
176}
177
178/*
179 * Local variables:
180 * tab-width: 4
181 * c-basic-offset: 4
182 * c-hanging-comment-ender-p: nil
183 * End:
184 */
185
186
Note: See TracBrowser for help on using the browser.