当前位置: 首页>>代码示例>>PHP>>正文


PHP ife函数代码示例

本文整理汇总了PHP中ife函数的典型用法代码示例。如果您正苦于以下问题:PHP ife函数的具体用法?PHP ife怎么用?PHP ife使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ife函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renderAlbums

 /**
  * Render albums with link to album photos
  *
  * @param array $data
  */
 public function renderAlbums($data = array())
 {
     $output = '';
     if (!empty($data)) {
         $output .= '<h1>Albums for ' . $data['author']['name'] . '</h1>';
         if (!empty($data['entry'])) {
             if (!isset($data['entry'][0])) {
                 $data['entry'][0] = $data['entry'];
             }
             foreach ($data['entry'] as $album) {
                 $output .= '<div class="album">';
                 $output .= '<h2 class="album-title">' . $this->Html->link($album['title'], array('action' => 'album', $this->_pullIdFromHref($album['link'][0]['href']))) . '</h2>';
                 $output .= '<img src="' . $album['group']['thumbnail']['url'] . '" height="50" alt="" style="float:left; margin:0 1em 1em 0;" />';
                 $output .= '<p class="summary">' . nl2br($album['summary']) . '</p>';
                 $output .= '<p class="meta">' . $album['numphotos'] . ife($album['numphotos'] <= 1, ' Photo', ' Photos') . ' | Published: ' . date('m-d-Y', strtotime($album['published'])) . ' | Location(s): ' . $album['location'] . '</p>';
                 if ($album['numphotos'] > 0) {
                     // render photos?
                 }
                 $output .= '</div>';
             }
         } else {
             $output .= 'There are no albums available.';
         }
     }
     return $this->output($output);
 }
开发者ID:neilcrookes,项目名称:gdata,代码行数:31,代码来源:picaso.php

示例2: flagSwitcher

/**
 * Displays a list of flags
 * 
 * @param array $options Options with the following possible keys
 * 	- basePath: Base path for the flag images, with a trailing slash
 * 	- class: Class of the <ul> wrapper
 * 	- id Id of the wrapper
 * @return void
 */
	public function flagSwitcher($options = array()) {
		$_defaults = array(
			'basePath' => $this->basePath,
			'class' => 'languages');
		$options = array_merge($_defaults, $options);
		$langs = Configure::read('Config.languages');
		if (defined('DEFAULT_LANGUAGE')) {
			array_unshift($langs, DEFAULT_LANGUAGE);
		}
		
		$out = '';
		if (!empty($langs)) {
			$out .= '<ul class="' . $options['class'] . '"' . ife(empty($options['id']), '', ' id="' . $options['id'] . '"') . '>';
			foreach($langs as $lang) {
				$class = $lang;
				if ($lang == Configure::read('Config.language')) {
					$class .= ' selected';
				}
				$url = array_merge($this->params['named'], $this->params['pass'], compact('lang'));
				$out .= 
				'<li class="' . $class . '">' .
					$this->Html->link($this->flagImage($lang, $options), $url, array('escape' => false)) .
				'</li>';
			}
			$out .= '</ul>';
		}
		
		return $out;
	}
开发者ID:ntung,项目名称:i18n,代码行数:38,代码来源:i18n.php

示例3: updateCounterCache

 /**
  * Updates the sum and counter cache of belongsTo associations after a save or delete operation
  *
  * @param array $keys Optional foreign key data, defaults to the information $this->data
  * @param boolean $created True if a new record was created, otherwise only associations with
  *                                  'counterScope' defined get updated
  * @return void
  * @access public
  */
 function updateCounterCache($keys = array(), $created = false)
 {
     parent::updateCounterCache($keys);
     if (empty($keys)) {
         $keys = $this->data[$this->alias];
     }
     foreach ($this->belongsTo as $parent => $assoc) {
         if (!empty($assoc['sumCache'])) {
             if ($assoc['sumCache'] === true) {
                 $assoc['sumCache'] = Inflector::underscore($this->alias) . '_sum';
             }
             if ($this->{$parent}->hasField($assoc['sumCache'])) {
                 $conditions = array($this->escapeField($assoc['foreignKey']) => $keys[$assoc['foreignKey']]);
                 if (isset($assoc['sumScope'])) {
                     $conditions = array_merge($conditions, (array) $assoc['sumScope']);
                 }
                 if (!isset($assoc['sumField'])) {
                     $assoc['sumField'] = 'amount';
                 }
                 $fields = 'SUM(' . $assoc['sumField'] . ') AS ' . $assoc['sumField'] . '';
                 $recursive = -1;
                 list($edge) = array_values($this->find('first', compact('conditions', 'fields', 'recursive')));
                 $sum = ife(empty($edge[$assoc['sumField']]), 0, $edge[$assoc['sumField']]);
                 $this->{$parent}->updateAll(array($assoc['sumCache'] => $sum), array($this->{$parent}->escapeField() => $keys[$assoc['foreignKey']]));
             }
         }
     }
 }
开发者ID:02468,项目名称:ebocash,代码行数:37,代码来源:app_model.php

示例4: setup

 /**
  * Setup
  *
  * @param AppModel $Model
  * @param array $settings
  */
 public function setup(&$Model, $settings = array())
 {
     if (!isset($this->settings[$Model->alias])) {
         $this->settings[$Model->alias] = $this->defaults;
     }
     $this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:real34,项目名称:i18n,代码行数:13,代码来源:i18nable.php

示例5: setup

 /**
  * Initiate behavior for the model using specified settings. Available settings:
  *
  * - recursive: (boolean, optional) set to true to allow containable to automatically
  * 				determine the recursiveness level needed to fetch specified models,
  * 				and set the model recursiveness to this level. setting it to false
  * 				disables this feature. DEFAULTS TO: true
  *
  * - notices:	(boolean, optional) issues E_NOTICES for bindings referenced in a
  * 				containable call that are not valid. DEFAULTS TO: true
  *
  * - autoFields: (boolean, optional) auto-add needed fields to fetch requested
  * 				bindings. DEFAULTS TO: true
  *
  * @param object $Model Model using the behavior
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     if (!isset($this->settings[$Model->alias])) {
         $this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true);
     }
     $this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:BLisa90,项目名称:cakecart,代码行数:25,代码来源:containable.php

示例6: setup

 /**
  * Initiate behavior for the model using settings.
  *
  * @param object $Model Model using the behaviour
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $defaults = array('createdField' => 'created_by', 'modifiedField' => 'modified_by', 'model' => 'User');
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $defaults;
     }
     $this->__settings[$Model->alias] = am($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:stripthis,项目名称:donate,代码行数:15,代码来源:saved_by.php

示例7: setup

 /**
  * Initiate behavior for the model using settings.
  *
  * @param object $Model Model using the behavior
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $defaults = array('field' => 'continuous_id', 'offset' => '1');
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $defaults;
     }
     $this->__settings[$Model->alias] = am($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:stripthis,项目名称:donate,代码行数:15,代码来源:continuous_id.php

示例8: setup

 /**
  * Initiate behaviour for the model using settings.
  *
  * @param object $Model Model using the behaviour
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $default = array('field' => 'deleted', 'field_date' => 'deleted_date', 'delete' => true, 'find' => true);
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $default;
     }
     $this->__settings[$Model->alias] = array_merge($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:jimiyash,项目名称:cake-pluggables,代码行数:15,代码来源:soft_deletable.php

示例9: setup

 /**
  * Initiate behaviour for the model using specified settings.
  *
  * @param object $model    Model using the behaviour
  * @param array $settings    Settings to override for model.
  *
  * @access public
  */
 function setup(&$model, $settings = array())
 {
     $default = array('fieldName' => 'url');
     if (!isset($this->settings[$model->name])) {
         $this->settings[$model->name] = $default;
     }
     $this->settings[$model->name] = Set::merge($this->settings[$model->name], ife(is_array($settings), $settings, array()));
 }
开发者ID:ritiksingh,项目名称:simpleflan,代码行数:16,代码来源:url.php

示例10: setup

 function setup(&$Model, $settings = array())
 {
     $default = array('saveto' => 'ChangeLog');
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $default;
     }
     $this->__settings[$Model->alias] = am($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:vinicius-ianni,项目名称:PHPMyScrum,代码行数:8,代码来源:auto_logger.php

示例11: setup

 /**
  * Initiate behavior for the model using specified settings. Available settings:
  *
  * - incrementFieldName: (string) The name of the field which needs to be incremented
  * 
  *
  * @param object $Model Model using the behaviour
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $default = array('incrementFieldName' => array('views'));
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $default;
     }
     $this->__settings[$Model->alias] = am($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:afzet,项目名称:cake-cart,代码行数:18,代码来源:increment.php

示例12: browseforfolder

/**
 * @param string $curdir
 */
function browseforfolder($curdir)
{
    global $maxlevel, $root, $brlist;
    $maxlevel = 0;
    $brlist = array(array("dir" => "/", "level" => 0, "put" => ife($curdir == "/", "", "/")));
    _subbrowse($curdir, 0, 1);
    return $brlist;
}
开发者ID:GuillaumeFromage,项目名称:AlternC,代码行数:11,代码来源:browseforfolder2.php

示例13: setup

 /**
  * Initiate behavior for the model using settings.
  *
  * @param object $Model Model using the behaviour
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $defaults = array('field' => 'serial', 'length' => 5);
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $defaults;
     }
     $this->__settings[$Model->alias] = am($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:stripthis,项目名称:donate,代码行数:15,代码来源:serialable.php

示例14: setup

 /**
  * Initiate behavior for the model using specified settings.
  * Available settings:
  *
  * - view_counter: string :: the field in the table that has the count
  *
  * @param object $Model Model using the behaviour
  * @param array $settings Settings to override for model.
  * @access public
  */
 function setup(&$Model, $settings = array())
 {
     $default = array('view_counter' => 'views');
     if (!isset($this->__settings[$Model->alias])) {
         $this->__settings[$Model->alias] = $default;
     }
     $this->__settings[$Model->alias] = am($this->__settings[$Model->alias], ife(is_array($settings), $settings, array()));
 }
开发者ID:sdoney,项目名称:infinitas,代码行数:18,代码来源:viewable.php

示例15: setup

 function setup(&$model, $settings = array())
 {
     $default = array('field' => 'content', 'doctype' => 'XHTML 1.0 Strict');
     if (!isset($this->settings[$model->name])) {
         $this->settings[$model->name] = $default;
     }
     $this->settings[$model->name] = array_merge($this->settings[$model->name], ife(is_array($settings), $settings, array()));
 }
开发者ID:Jaciss,项目名称:wildflower,代码行数:8,代码来源:pure_html.php


注:本文中的ife函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。