root/trunk/wifidog-auth/wifidog/classes/Content/BannerAdGroup/BannerAdGroup.php @ 1249

Revision 1249, 9.1 KB (checked in by benoitg, 6 years ago)

-This is a behemoth "the road to 1.0" commit. I've been working on this for 6 months,
and it's reached the point where others can help. Those are very far reaching changes, please
notify me if anything isn't working right (and im sure I can't have caught everything).

Mostly complete. Missing parts are Content stakeholders, system roles and "su" functionnality.
I need help replacing all the DEPRECATED* methods. Please read the wiki page above for instructions.

  • generic_object_admin.php: More work towards making it generic once again.
  • GenericDataObject?: New class. Eventually, most classes should extend this, instead of directly implementing GenericObject?
  • Menu.php: Finally a uniform Menuing system to replace the mismatch of links that made wifidog impossible to navigate. It's not very sophisticated yet, but it IS permission aware Loosely inspired from Drupal's menuing system. HTML is slightly modified "Son of suckerfish", so will be easy to style (althouh I haven't had time yet). Actual menus are added in the hook_menu methods of each class.
  • VirtualHost.php: Finally properly split off Virtual Hosts, and make Server a singleton.
  • install.php: Do the bare minimum changes so it's still possible to setup a wifidog auth server. However, install.php still needs 1- A good overhaull, 2- A way to install sample databases instead of the minimal one. -Other changes
  • Unbreak signup link for non-javascript enabled devices
  • AbstractDb?: Improve debuging features
  • *:getObject(): Hopefully improve performance of class caching by making sure that we do not manipulate different objects. Otherwise copies would be generated as soon as we change properties, wasting much memory.
    • Add dependency check for XSL module for hotspot_status.php.
    • Some work towards respecting the coding style: http://dev.wifidog.org/wiki/doc/developer/CodingStandard
    • wifidog/admin/index.php: Delete admin page. There is no longuer a concept of a separate admin section. Menu will depend on your access level.
  • Property svn:executable set to *
Line 
1<?php
2
3
4/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5
6// +-------------------------------------------------------------------+
7// | WiFiDog Authentication Server                                     |
8// | =============================                                     |
9// |                                                                   |
10// | The WiFiDog Authentication Server is part of the WiFiDog captive  |
11// | portal suite.                                                     |
12// +-------------------------------------------------------------------+
13// | PHP version 5 required.                                           |
14// +-------------------------------------------------------------------+
15// | Homepage:     http://www.wifidog.org/                             |
16// | Source Forge: http://sourceforge.net/projects/wifidog/            |
17// +-------------------------------------------------------------------+
18// | This program is free software; you can redistribute it and/or     |
19// | modify it under the terms of the GNU General Public License as    |
20// | published by the Free Software Foundation; either version 2 of    |
21// | the License, or (at your option) any later version.               |
22// |                                                                   |
23// | This program is distributed in the hope that it will be useful,   |
24// | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
25// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
26// | GNU General Public License for more details.                      |
27// |                                                                   |
28// | You should have received a copy of the GNU General Public License |
29// | along with this program; if not, contact:                         |
30// |                                                                   |
31// | Free Software Foundation           Voice:  +1-617-542-5942        |
32// | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
33// | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
34// |                                                                   |
35// +-------------------------------------------------------------------+
36
37/**
38 * @package    WiFiDogAuthServer
39 * @subpackage ContentClasses
40 * @author     Benoit Grégoire <bock@step.polymtl.ca>
41 * @copyright  2006 Benoit Grégoire, Technologies Coeus inc.
42 * @version    Subversion $Id: TrivialLangstring.php 1031 2006-05-10 18:56:02Z benoitg $
43 * @link       http://www.wifidog.org/
44 */
45
46/**
47 * Load required classes
48 */
49require_once ('classes/Content/ContentGroup/ContentGroup.php');
50/**
51 * Represents a list of banner ads
52 *
53 * @package    WiFiDogAuthServer
54 * @subpackage ContentClasses
55 * @author     Benoit Grégoire <bock@step.polymtl.ca>
56 * @copyright  2006 Benoit Grégoire, Technologies Coeus inc.
57 */
58class BannerAdGroup extends ContentGroup {
59    private $predefinedSizes;
60    /**
61     * Constructor
62     *
63     * @param string $content_id Content id
64     *
65     * @return void     */
66    protected function __construct($content_id) {
67        parent :: __construct($content_id);
68        $criteria_array = array (
69            array (
70                'isContentType',
71                array (
72                    array (
73                        'SimplePicture'
74                    )
75                )
76            )
77        );
78        $allowed_content_types = ContentTypeFilter :: getObject($criteria_array);
79        $this->setAllowedContentTypes($allowed_content_types);
80        $this->predefinedSizes = array (
81            /* Rectangles and Pop-Ups */
82                        '300px/250px' => _('300x250 - IAB Medium Rectangle'), 
83                        '250px/250px' => _('250x250 - IAB Square Pop-Up'), 
84                        '240px/400px' => _('240x400 - IAB Vertical Rectangle'), 
85                        '336px/280px' => _('336x280 - IAB Large Rectangle'), 
86                        '180px/150px' => _('180x150 - IAB Rectangle'),
87                                /* Banners and Buttons */
88                        '468px/60px' => _('468x60  - IAB Full Banner'), 
89                        '234px/60px' => _('234x60  - IAB Half Banner'), 
90                        '88px/31px' => _('88x31   - IAB Micro Bar'), 
91                        '120px/90px' => _('120x90  - IAB Button 1'), 
92                        '120px/60px' => _('120x60  - IAB Button 2'), 
93                        '120px/240px' => _('120x240 - IAB Vertical Banner'), 
94                        '125px/125px' => _('125x125 - IAB Square Button'), 
95                        '728px/90px' => _('728x90  - IAB Leaderboard'),
96                                /* Skyscrapers */
97                        '160px/600px' => _('160x600 - IAB Wide Skyscraper'), 
98                        '120px/600px' => _('120x600 - IAB Skyscraper'), 
99                        '300px/600px' => _('300x600 - IAB Half Page Ad'));
100            }
101
102    /** 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
103     * @return true or false */
104    public function isSimpleContent() {
105        return true;
106    }
107
108    /**Get all elements.  Set the max witdh and height
109     * @return an array of ContentGroupElement or an empty arrray */
110    function getElements($additional_where = null) {
111        $elements = parent :: getElements($additional_where);
112
113        foreach ($elements as $element) {
114            $picture = $element->getDisplayedContent();
115            $picture->configEnableEditWidthHeight(false);
116            $picture->setMaxDisplayWidth($this->getKVP(get_class($this) . '_max_width'));
117            $picture->setMaxDisplayHeight($this->getKVP(get_class($this) . '_max_height'));
118        }
119        return $elements;
120    }
121    public function getAdminUI($subclass_admin_interface = null, $title = null) {
122        $html = null;
123        /* width and height */
124        $max_width = $this->getKVP(get_class($this) . '_max_width');
125        $max_height = $this->getKVP(get_class($this) . '_max_height');
126
127        $html .= "<li class='admin_element_item_container'>\n";
128        $html .= "<div class='admin_element_label'>" . _("Maximum display size") . ": </div>\n";
129        $html .= "<div class='admin_element_data'>\n";
130        $name = "banner_add_group_{this->getId()}_widthxheight";
131        $html .= FormSelectGenerator :: generateFromKeyLabelArray($this->predefinedSizes, $max_width . '/' . $max_height, $name, null, true, _('Use the values below for width and height'));
132        $html .= "</div>\n";
133        $html .= "</li>\n";
134
135        /*max_width*/
136        $html .= "<li class='admin_element_item_container'>\n";
137        $html .= "<div class='admin_element_label'>" . ("Width") . ": </div>\n";
138        $html .= "<div class='admin_element_data'>\n";
139        $name = "banner_add_group_{this->getId()}_max_width";
140        $html .= "<input type='text' size='6' value='$max_width' name='$name'>\n";
141        $html .= "</div>\n";
142        $html .= "</li>\n";
143
144        /*max_height*/
145        $html .= "<li class='admin_element_item_container'>\n";
146        $html .= "<div class='admin_element_label'>" . ("Height") . ": </div>\n";
147        $html .= "<div class='admin_element_data'>\n";
148        $name = "banner_add_group_{this->getId()}_max_height";
149        $html .= "<input type='text' size='6' value='$max_height' name='$name'>\n";
150        $html .= "</div>\n";
151        $html .= "</li>\n";
152        return parent :: getAdminUI($html, $title);
153    }
154
155    /**
156    * Processes the input of the administration interface for Picture
157    *
158    * @return void
159    */
160    public function processAdminUI() {
161        if ($this->DEPRECATEDisOwner(User :: getCurrentUser()) || User :: getCurrentUser()->DEPRECATEDisSuperAdmin()) {
162            parent :: processAdminUI();
163            /* width and height */
164            $name = "banner_add_group_{this->getId()}_widthxheight";
165            $widthxheight = FormSelectGenerator :: getResult($name, null);
166            //pretty_print_r($widthxheight);
167
168            $name = "banner_add_group_{this->getId()}_max_width";
169            $max_width = $_REQUEST[$name];
170            /*max_height*/
171            $name = "banner_add_group_{this->getId()}_max_height";
172            $max_height = $_REQUEST[$name];
173            if (!empty ($widthxheight)) {
174                $widthxheightArray = explode('/', $widthxheight);
175                $max_width_select = $widthxheightArray[0];
176                $max_height_select = $widthxheightArray[1];
177                if (($max_width_select != $max_width || $max_height_select != $max_height) && ($max_width == $this->getKVP(get_class($this) . '_max_width') && $max_height == $this->getKVP(get_class($this) . '_max_height'))) {
178                    /* Width and height weren't manually changed, or were empty */
179                    $max_width = $max_width_select;
180                    $max_height = $max_height_select;
181                }
182            }
183            $this->setKVP(get_class($this) . '_max_width', $max_width);
184            $this->setKVP(get_class($this) . '_max_height', $max_height);
185        }
186    }
187    /**
188     * Reloads the object from the database.
189     *
190     * Should normally be called after a set operation.
191     *
192     * This function is private because calling it from a subclass will call the
193     * constructor from the wrong scope
194     *
195     * @return void
196   
197     */
198    private function refresh() {
199        $this->__construct($this->id);
200    }
201}
202
203/*
204 * Local variables:
205 * tab-width: 4
206 * c-basic-offset: 4
207 * c-hanging-comment-ender-p: nil
208 * End:
209 */
Note: See TracBrowser for help on using the browser.