CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 1.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 1.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Classes

  • AclBase
  • AclBehavior
  • AclComponent
  • AclNode
  • AclShell
  • Aco
  • AcoAction
  • AjaxHelper
  • ApcEngine
  • ApiShell
  • App
  • AppController
  • AppHelper
  • AppModel
  • Aro
  • AuthComponent
  • BakeShell
  • BehaviorCollection
  • Cache
  • CacheEngine
  • CacheHelper
  • CakeErrorController
  • CakeLog
  • CakeSchema
  • CakeSession
  • CakeSocket
  • ClassRegistry
  • Component
  • Configure
  • ConnectionManager
  • ConsoleShell
  • ContainableBehavior
  • Controller
  • ControllerTask
  • CookieComponent
  • DataSource
  • DbAcl
  • DbAclSchema
  • DbConfigTask
  • DboAdodb
  • DboDb2
  • DboFirebird
  • DboMssql
  • DboMysql
  • DboMysqlBase
  • DboMysqli
  • DboOdbc
  • DboOracle
  • DboPostgres
  • DboSource
  • DboSqlite
  • DboSybase
  • Debugger
  • EmailComponent
  • ErrorHandler
  • ExtractTask
  • File
  • FileEngine
  • Flay
  • Folder
  • FormHelper
  • Helper
  • HtmlHelper
  • HttpSocket
  • I18n
  • I18nModel
  • i18nSchema
  • I18nShell
  • Inflector
  • IniAcl
  • JavascriptHelper
  • JsHelper
  • JsHelperObject
  • L10n
  • MagicDb
  • MagicFileResource
  • MediaView
  • MemcacheEngine
  • Model
  • ModelBehavior
  • ModelTask
  • Multibyte
  • NumberHelper
  • Object
  • Overloadable
  • Overloadable2
  • PagesController
  • PaginatorHelper
  • Permission
  • PluginTask
  • ProjectTask
  • RequestHandlerComponent
  • Router
  • RssHelper
  • Sanitize
  • Scaffold
  • ScaffoldView
  • SchemaShell
  • Security
  • SecurityComponent
  • SessionComponent
  • SessionHelper
  • SessionsSchema
  • Set
  • Shell
  • String
  • TestSuiteShell
  • TestTask
  • TextHelper
  • ThemeView
  • TimeHelper
  • TranslateBehavior
  • TreeBehavior
  • Validation
  • View
  • ViewTask
  • XcacheEngine
  • Xml
  • XmlElement
  • XmlHelper
  • XmlManager
  • XmlNode
  • XmlTextNode

Functions

  • __enclose
  • make_clean_css
  • mb_encode_mimeheader
  • mb_stripos
  • mb_stristr
  • mb_strlen
  • mb_strpos
  • mb_strrchr
  • mb_strrichr
  • mb_strripos
  • mb_strrpos
  • mb_strstr
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • write_css_cache
  1: <?php
  2: /* SVN FILE: $Id$ */
  3: /**
  4:  * RSS Helper class file.
  5:  *
  6:  * Simplifies the output of RSS feeds.
  7:  *
  8:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  9:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 10:  *
 11:  * Licensed under The MIT License
 12:  * Redistributions of files must retain the above copyright notice.
 13:  *
 14:  * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 15:  * @link          http://cakephp.org CakePHP(tm) Project
 16:  * @package       cake
 17:  * @subpackage    cake.cake.libs.view.helpers
 18:  * @since         CakePHP(tm) v 1.2
 19:  * @version       $Revision$
 20:  * @modifiedby    $LastChangedBy$
 21:  * @lastmodified  $Date$
 22:  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 23:  */
 24: App::import('Helper', 'Xml');
 25: 
 26: /**
 27:  * XML Helper class for easy output of XML structures.
 28:  *
 29:  * XmlHelper encloses all methods needed while working with XML documents.
 30:  *
 31:  * @package       cake
 32:  * @subpackage    cake.cake.libs.view.helpers
 33:  */
 34: class RssHelper extends XmlHelper {
 35: /**
 36:  * Helpers used by RSS Helper
 37:  *
 38:  * @var array
 39:  * @access public
 40:  **/
 41:     var $helpers = array('Time');
 42: /**
 43:  * Base URL
 44:  *
 45:  * @access public
 46:  * @var string
 47:  */
 48:     var $base = null;
 49: /**
 50:  * URL to current action.
 51:  *
 52:  * @access public
 53:  * @var string
 54:  */
 55:     var $here = null;
 56: /**
 57:  * Parameter array.
 58:  *
 59:  * @access public
 60:  * @var array
 61:  */
 62:     var $params = array();
 63: /**
 64:  * Current action.
 65:  *
 66:  * @access public
 67:  * @var string
 68:  */
 69:     var $action = null;
 70: /**
 71:  * POSTed model data
 72:  *
 73:  * @access public
 74:  * @var array
 75:  */
 76:     var $data = null;
 77: /**
 78:  * Name of the current model
 79:  *
 80:  * @access public
 81:  * @var string
 82:  */
 83:     var $model = null;
 84: /**
 85:  * Name of the current field
 86:  *
 87:  * @access public
 88:  * @var string
 89:  */
 90:     var $field = null;
 91: /**
 92:  * Default spec version of generated RSS
 93:  *
 94:  * @access public
 95:  * @var string
 96:  */
 97:     var $version = '2.0';
 98: /**
 99:  * Returns an RSS document wrapped in <rss /> tags
100:  *
101:  * @param  array  $attrib <rss /> tag attributes
102:  * @return string An RSS document
103:  */
104:     function document($attrib = array(), $content = null) {
105:         if ($content === null) {
106:             $content = $attrib;
107:             $attrib = array();
108:         }
109:         if (!isset($attrib['version']) || empty($attrib['version'])) {
110:             $attrib['version'] = $this->version;
111:         }
112: 
113:         return $this->elem('rss', $attrib, $content);
114:     }
115: /**
116:  * Returns an RSS <channel /> element
117:  *
118:  * @param  array  $attrib   <channel /> tag attributes
119:  * @param  mixed  $elements Named array elements which are converted to tags
120:  * @param  mixed  $content  Content (<item />'s belonging to this channel
121:  * @return string An RSS <channel />
122:  */
123:     function channel($attrib = array(), $elements = array(), $content = null) {
124:         $view =& ClassRegistry::getObject('view');
125: 
126:         if (!isset($elements['title']) && !empty($view->pageTitle)) {
127:             $elements['title'] = $view->pageTitle;
128:         }
129:         if (!isset($elements['link'])) {
130:             $elements['link'] = '/';
131:         }
132:         if (!isset($elements['description'])) {
133:             $elements['description'] = '';
134:         }
135:         $elements['link'] = $this->url($elements['link'], true);
136: 
137:         $elems = '';
138:         foreach ($elements as $elem => $data) {
139:             $attributes = array();
140:             if (is_array($data)) {
141:                 if (strtolower($elem) == 'cloud') {
142:                     $attributes = $data;
143:                     $data = array();
144:                 } elseif (isset($data['attrib']) && is_array($data['attrib'])) {
145:                     $attributes = $data['attrib'];
146:                     unset($data['attrib']);
147:                 } else {
148:                     $innerElements = '';
149:                     foreach ($data as $subElement => $value) {
150:                         $innerElements .= $this->elem($subElement, array(), $value);
151:                     }
152:                     $data = $innerElements;
153:                 }
154:             }
155:             $elems .= $this->elem($elem, $attributes, $data);
156:         }
157:         return $this->elem('channel', $attrib, $elems . $content, !($content === null));
158:     }
159: /**
160:  * Transforms an array of data using an optional callback, and maps it to a set
161:  * of <item /> tags
162:  *
163:  * @param  array  $items    The list of items to be mapped
164:  * @param  mixed  $callback A string function name, or array containing an object
165:  *                          and a string method name
166:  * @return string A set of RSS <item /> elements
167:  */
168:     function items($items, $callback = null) {
169:         if ($callback != null) {
170:             $items = array_map($callback, $items);
171:         }
172: 
173:         $out = '';
174:         $c = count($items);
175: 
176:         for ($i = 0; $i < $c; $i++) {
177:             $out .= $this->item(array(), $items[$i]);
178:         }
179:         return $out;
180:     }
181: /**
182:  * Converts an array into an <item /> element and its contents
183:  *
184:  * @param  array  $attrib      The attributes of the <item /> element
185:  * @param  array  $elements    The list of elements contained in this <item />
186:  * @return string An RSS <item /> element
187:  */
188:     function item($att = array(), $elements = array()) {
189:         $content = null;
190: 
191:         if (isset($elements['link']) && !isset($elements['guid'])) {
192:             $elements['guid'] = $elements['link'];
193:         }
194: 
195:         foreach ($elements as $key => $val) {
196:             $attrib = array();
197:             
198:             $escape = true;
199:             if (is_array($val) && isset($val['convertEntities'])) {
200:                 $escape = $val['convertEntities'];
201:                 unset($val['convertEntities']);
202:             }
203:             
204:             switch ($key) {
205:                 case 'pubDate' :
206:                     $val = $this->time($val);
207:                 break;
208:                 case 'category' :
209:                     if (is_array($val) && !empty($val[0])) {
210:                         foreach ($val as $category) {
211:                             $attrib = array();
212:                             if (isset($category['domain'])) {
213:                                 $attrib['domain'] = $category['domain'];
214:                                 unset($category['domain']);
215:                             }
216:                             $categories[] = $this->elem($key, $attrib, $category);
217:                         }
218:                         $elements[$key] = implode('', $categories);
219:                         continue 2;
220:                     } else if (is_array($val) && isset($val['domain'])) {
221:                         $attrib['domain'] = $val['domain'];
222:                     }
223:                 break;
224:                 case 'link':
225:                 case 'guid':
226:                 case 'comments':
227:                     if (is_array($val) && isset($val['url'])) {
228:                         $attrib = $val;
229:                         unset($attrib['url']);
230:                         $val = $val['url'];
231:                     }
232:                     $val = $this->url($val, true);
233:                 break;
234:                 case 'source':
235:                     if (is_array($val) && isset($val['url'])) {
236:                         $attrib['url'] = $this->url($val['url'], true);
237:                         $val = $val['title'];
238:                     } elseif (is_array($val)) {
239:                         $attrib['url'] = $this->url($val[0], true);
240:                         $val = $val[1];
241:                     }
242:                 break;
243:                 case 'enclosure':
244:                     if (is_string($val['url']) && is_file(WWW_ROOT . $val['url']) && file_exists(WWW_ROOT . $val['url'])) {
245:                         if (!isset($val['length']) && strpos($val['url'], '://') === false) {
246:                             $val['length'] = sprintf("%u", filesize(WWW_ROOT . $val['url']));
247:                         }
248:                         if (!isset($val['type']) && function_exists('mime_content_type')) {
249:                             $val['type'] = mime_content_type(WWW_ROOT . $val['url']);
250:                         }
251:                     }
252:                     $val['url'] = $this->url($val['url'], true);
253:                     $attrib = $val;
254:                     $val = null;
255:                 break;
256:             }
257:             if (!is_null($val) && $escape) {
258:                 $val = h($val);
259:             }
260:             $elements[$key] = $this->elem($key, $attrib, $val);
261:         }
262:         if (!empty($elements)) {
263:             $content = implode('', $elements);
264:         }
265:         return $this->output($this->elem('item', $att, $content, !($content === null)));
266:     }
267: /**
268:  * Converts a time in any format to an RSS time
269:  *
270:  * @param  mixed  $time
271:  * @return string An RSS-formatted timestamp
272:  * @see TimeHelper::toRSS
273:  */
274:     function time($time) {
275:         return $this->Time->toRSS($time);
276:     }
277: }
278: ?>
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs