
SilverStripe The Complete Guide to CMS Development Ingo Schommer and Steven Broschart Translated by Dr Julian Seidenberg and Ingo Schommer A John Wiley and Sons, Ltd., Publication SilverStripe SilverStripe The Complete Guide to CMS Development Ingo Schommer and Steven Broschart Translated by Dr Julian Seidenberg and Ingo Schommer A John Wiley and Sons, Ltd., Publication 2009 by Galileo Press Galileo Computing is an imprint of Galileo Press, Bonn (Germany), Boston (USA). German Edition first published 2008 by Galileo Press. All rights reserved. Neither this publication nor any part of it may be copied or reproduced in any form or by any means or translated into another language without the prior consent of Galileo Press, Rheinwerkallee 4. 53227 Bonn, Germany. Galileo Press makes no warranties or representations with respect to the content hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. Galileo Press assumes no responsibility for any errors that may appear in this publication. This edition first published 2009 2009 John Wiley and Sons, Ltd Registered office John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex, PO19 8SQ, United Kingdom For details of our global editorial offices, for customer services and for information about how to apply for permission to reuse the copyright material in this book please see our website at www.wiley.com. The right of the author to be identified as the author of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of the publisher. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought. ISBN 978-0-470-68183-1 A catalogue record for this book is available from the British Library. Typeset in 10/12 Optima by Laserwords Private Limited, Chennai, India Printed in USA ‘‘I feel SilverStripe is a great example of a well-constructed open source project.’’ Chris DiBona, Open Source Programs Manager, Google Inc. Publisher’s Acknowledgements Some of the people who helped bring this book to market include the following: Editorial and Production VP Consumer and Technology Publishing Director: Michelle Leete Associate Director - Book Content Management: Martin Tribe Associate Publisher: Chris Webb Executive Commissioning Editor: Birgit Gruber Assistant Editor: Colleen Goldring Content Editor: Claire Spinks Publishing Assistant: Ellie Scott Copy Editor: Andrew Finch Composition: Laserwords Private Ltd Marketing Senior Marketing Manager: Louise Breinholt Marketing Executive: Kate Batchelor Contents About the Authors xi About the Translator xiii Foreword by Sigurd Magnusson xv Preface by Steven Broschart xvii 1 Introduction 1 1.1 Why SilverStripe? 1 1.2 History 15 1.3 Future 17 1.4 Conclusion 18 2 Installation 19 2.1 System Requirements 19 2.2 Preparation 20 2.3 Installation 23 2.4 Useful Software 33 2.5 Database Management 36 2.6 Support 37 2.7 Conclusion 38 3 Architecture 39 3.1 Introduction 39 3.2 MVC – Model View Controller 40 viii CONTENTS 3.3 ORM – Object Relational Mapping 49 3.4 Directory Structure 54 3.5 Modules and Widgets 58 3.6 Themes 59 3.7 Configuration 61 3.8 Conclusion 62 4 First Steps 65 4.1 Our Project: Job Portal and User Group 65 4.2 Creating the Page Structure 67 4.3 Inserting Page Content 78 4.4 Managing Files and Images 84 4.5 Versioning 92 4.6 Comments 93 4.7 Simple Contact Form 96 4.8 Creating New Users 102 4.9 Themes 105 4.10 Conclusion 108 5 Development: Job Postings 109 5.1 Job Categories as a Page Type 110 5.2 Job as a DataObject 115 5.3 Relations Between DataObjects 119 5.4 Creating the Interface 123 5.5 Creating Templates 129 5.6 Custom Forms 146 5.7 Email Notification 154 5.8 Integrating the Blog Module 160 5.9 Search Engine Optimization 162 5.10 Conclusion 168 6 CRM 169 6.1 Where are we Headed? 170 6.2 Datamodel 171 6.3 Using ModelAdmin for Data Management 177 6.4 Multi-page Registration Form 182 6.5 Skills as Tags 194 6.6 File Uploads for References 196 6.7 Searching DataObjects 202 6.8 Generic Views Using CollectionController 207 6.9 Defining Access Permissions 217 6.10 Web Services Using RESTfulServer 221 6.11 RSS Feeds for Jobs 229 6.12 Conclusion 231 CONTENTS ix 7 Security 233 7.1 Cross-site Scripting (XSS) 233 7.2 Cross-site Request Forgery (CSRF) 237 7.3 SQL Injection 238 7.4 Directory Traversal 241 7.5 Sessions 243 7.6 Conclusion 246 8 Maintenance 247 8.1 Environment Types 247 8.2 Configuration of Multiple Environments 249 8.3 Version Control using Subversion 251 8.4 Backup 256 8.5 Upgrade 260 8.6 Error Handling 261 8.7 Performance 266 8.8 Conclusion 272 9 Testing 273 9.1 Test-driven Development 274 9.2 Installing PHPUnit 276 9.3 Running Tests 277 9.4 Unit Tests for the Model 280 9.5 Functional Tests for the Controllers 286 9.6 Conclusion 290 10 Localization 291 10.1 Character Sets and Unicode 292 10.2 Translating Templates and Code 295 10.3 Translatable: Translating Database Content 301 10.4 Conclusion 307 11 Recipes 309 11.1 Prerequisites 309 11.2 Customizable Page Banner 310 11.3 Branding the CMS Interfaces 314 11.4 Full-text Search for Websites 318 11.5 Redirecting from Legacy URLs 324 11.6 Simple Statistics using TableListField 329 11.7 Showing Related Pages 337 11.8 CSV Import using CSVBulkLoader 345 11.9 A Fully Flash-based Website Driven by SilverStripe 352 11.10 Conclusion 372 xCONTENTS 12 Extending 373 12.1 Different Ways to Extend SilverStripe 374 12.2 Extending Core Functions 374 12.3 Creating Custom Modules 382 12.4 Creating Custom Widgets 385 12.5 Conclusion 392 13 Useful Modules 395 13.1 E-commerce 396 13.2 Forum 398 13.3 Gallery 401 13.4 Flickr Service 402 13.5 Youtube Gallery 404 13.6 Spam Protection: Mollom and Recaptcha 405 13.7 Auth_External 408 13.8 Auth_OpenID 409 13.9 Subsites 410 13.10 CMS Workflow 411 13.11 Site-tree Importer 415 13.12 Geospatial Modules 415 13.13 Conclusion 417 Index 419 About the Authors Steven Broschart has been active for 6 years as an advisor and developer at one of Germany’s leading online marketing agencies, cyberpromote GmbH. Aside from developing PHP and Ruby on Rails business applica- tions and coordinating key accounts for SEO, he advises his clients on selecting appropriate open source software. Steven is a regular author in relevant industry publications. Ingo Schommer freelanced as a PHP and Flash developer for several years prior to joining SilverStripe in 2006 as a senior developer. At SilverStripe, Ingo analyses and builds modern web applications, making sure that they work well in a browser and not just on paper. He has a key role architecting and implementing core functionality in the SilverStripe platform, and facilitates involvement of the open-source community. About the Translator Julian Seidenberg has a background in developing web applications using PHP and Java and has worked in a variety of software engineering roles. He is also a developer at SilverStripe and holds a PhD in Semantic Web technology from the University of Manchester. Foreword Sigurd Magnusson Co-founder and Chief Marketing Officer, SilverStripe Ltd Thanks for buying the book! After countless long days and nights, it’s a real joy to see it come to fruition. In 2000, the dream of the SilverStripe project began: to make a fan- tastic software platform to build and manage websites. Our company SilverStripe Ltd, which had its fair share of geeks, was in the business of building websites for customers. We found the tools out there didn’t suit us, and certainly didn’t suit our customers. Tools were either too technical, which suited us fine but confused our clients, or were simple enough for our non-technical customers, but insulted us with poorly constructed HTML and limited us from building sophisticated website features. So, we committed to make a system that let professional, expe- rienced web developers build innovative websites which can then be passed, in confidence, to non-technical people to manage. Several years passed, and by 2006 we had a few hundred customers. We had always sought to make the product global, but because we were the only one developing SilverStripe, adoption was limited to our home country, New Zealand. We were working hard on an entirely rewritten version of SilverStripe, v2.0, and agreed that if we were to make it successful, it had to be released as free software, with a loyal community of developers around it.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages30 Page
-
File Size-