本文整理汇总了PHP中Set::numeric方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::numeric方法的具体用法?PHP Set::numeric怎么用?PHP Set::numeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set::numeric方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save($data)
{
if (empty($data['Origin']) && !Set::numeric(array_keys($data))) {
$data = array('Origin' => $data);
}
$key = null;
if (!empty($data['Origin']['link'])) {
$key = md5($data['Origin']['link']);
if (!empty($this->__cache[$key])) {
return $this->__cache[$key];
}
}
if (empty($data['Origin']['id']) && !empty($data['Origin']['provider_key'])) {
$found = parent::find('first', array('conditions' => array('Origin.provider_key' => $data['Origin']['provider_key'])));
if ($found) {
unset($found['Origin']['modified']);
$this->set($found);
}
}
$this->set($data);
$result = parent::save();
$result['Origin']['id'] = $this->id;
if ($key) {
$this->__cache[$key] = $result;
}
return $result;
}
示例2: addLoadedItems
function addLoadedItems($items)
{
$this->load();
foreach ($items as $modelName => $m_items) {
if (!Set::numeric(array_keys(SetMulti::excludeKeys($m_items, array('internal'))))) {
$m_items = array($m_items);
}
foreach ($m_items as $item) {
if (!empty($item['id'])) {
$model = ClassRegistry::init($modelName);
if ($model->Behaviors->attached('Node')) {
if (!empty($item['internal']['Node'][0]['id'])) {
$nodeId = $item['internal']['Node'][0]['id'];
} else {
$node = $model->node($model->myNodeRef($item['id']), false, true);
$nodeId = $node['Node']['id'];
}
if (!empty($nodeId)) {
if (isset($this->loadedItems[$nodeId])) {
unset($this->loadedItems[$nodeId]);
//Make sure everything id in DESC Order
}
$this->loadedItems[$nodeId] = $this->startTime;
if (!empty($item['items'])) {
$this->addLoadedItems($item['items']);
}
}
}
}
}
}
//debug($this->loadedItems);
}
示例3: afterFind
function afterFind($data)
{
if ($data && is_array($data) && !Set::numeric(array_keys($data))) {
$data = array($data);
}
if (is_array($data) && Set::numeric(array_keys($data))) {
foreach ($data as $i => $row) {
if (empty($row['user']) && !empty($row['sender'])) {
$row['user'] = $row['sender'];
$row['message'] = true;
} else {
$row['message'] = false;
}
$data[$i] = array('Item' => array('provider_key' => $row['id'], 'message' => $row['message'], 'text' => $row['text'], 'client' => $this->parse($row, 'source'), 'link' => 'http://twitter.com/' . $row['user']['screen_name'] . '/status/' . $row['id'], 'reply_user_provider_key' => $this->parse($row, 'in_reply_to_user_id'), 'reply_status_provider_key' => $this->parse($row, 'in_reply_to_status_id'), 'posted' => date('Y-m-d H:i:s', strtotime($row['created_at']))), 'Origin' => array('provider_key' => $row['user']['id'], 'name' => $row['user']['screen_name'], 'profile' => $row['user']['description'], 'origin_link' => $row['user']['url'], 'follower_count' => $row['user']['followers_count'], 'following_count' => $row['user']['friends_count'], 'update_count' => $row['user']['statuses_count'], 'avatar' => $row['user']['profile_image_url'], 'link' => 'http://twitter.com/' . $row['user']['screen_name']));
if ($this->name == 'TwitterAccount') {
$data[$i]['Origin']['following'] = true;
}
if (!empty($row['retweeted_status'])) {
$data[$i]['Item']['text'] = $row['retweeted_status']['text'];
$data[$i]['ForwardOrigin'] = array('provider_key' => $row['retweeted_status']['user']['id'], 'name' => $row['retweeted_status']['user']['screen_name'], 'profile' => $row['retweeted_status']['user']['description'], 'origin_link' => $row['retweeted_status']['user']['url'], 'follower_count' => $row['retweeted_status']['user']['followers_count'], 'following_count' => $row['retweeted_status']['user']['friends_count'], 'update_count' => $row['retweeted_status']['user']['statuses_count'], 'avatar' => $row['retweeted_status']['user']['profile_image_url'], 'link' => 'http://twitter.com/' . $row['retweeted_status']['user']['screen_name']);
}
}
} else {
if (is_string($data)) {
$dataArray = explode('&', $data);
$data = array();
foreach ($dataArray as $value) {
list($key, $value) = explode('=', $value);
$data[$key] = $value;
}
}
}
return $data;
}
示例4: afterFind
function afterFind($results, $primary)
{
$results = parent::afterFind($results, $primary);
if (!empty($results)) {
if (!Set::numeric(array_keys($results))) {
$tmp = array(&$results);
$myResults =& $tmp;
} else {
$myResults =& $results;
}
foreach ($myResults as &$resRoot) {
////// get updated Data //////
if (isset($resRoot[$this->alias])) {
$res =& $resRoot[$this->alias];
} else {
$res =& $resRoot;
}
$res['TemplateConfig'] = $this->getConfig($res);
if (!empty($res['TemplateConfig'])) {
$result = $res['TemplateConfig']->afterFind($this, $res);
if (!empty($result)) {
$res = $result;
}
}
if (!empty($resRoot['NewsletterAssoc'])) {
foreach ($resRoot['NewsletterAssoc'] as $assoc) {
$res['associated'][$assoc['type']] = $assoc['newsletter_id'];
}
}
}
}
return $results;
}
示例5: afterFind
function afterFind($data)
{
$data = $data['results'];
if ($data && Set::numeric(array_keys($data))) {
foreach ($data as $i => $row) {
$data[$i] = array('Item' => array('provider_key' => $row['id'], 'text' => $row['text'], 'client' => $row['source'], 'link' => 'http://twitter.com/' . $row['from_user'] . '/status/' . $row['id'], 'posted' => date('Y-m-d H:i:s', strtotime($row['created_at']))), 'Origin' => array('provider_key' => $row['from_user_id'], 'name' => $row['from_user'], 'avatar' => $row['profile_image_url'], 'link' => 'http://twitter.com/' . $row['from_user']));
}
}
return $data;
}
示例6: __prepareAction
function __prepareAction($data)
{
if (isset($data['Action']) && is_array($data['Action']) && count($data['Action']) > 0 && !Set::numeric(array_keys($data['Action']))) {
$action = $data['Action'];
$data['Action'] = array();
$i = 0;
foreach ($action as $metaUuid => $metaArray) {
$data['Action'][$i] = $metaArray;
$i++;
}
}
return $data;
}
示例7: __prepareMeta
/**
* Private method for MetaBehavior::prepareData()
*
* @param object $model
* @param array $data
* @return array
*/
private function __prepareMeta($data)
{
if (isset($data['Meta']) && is_array($data['Meta']) && count($data['Meta']) > 0 && !Set::numeric(array_keys($data['Meta']))) {
$meta = $data['Meta'];
$data['Meta'] = array();
$i = 0;
foreach ($meta as $metaUuid => $metaArray) {
$data['Meta'][$i] = $metaArray;
$i++;
}
}
return $data;
}
示例8: beforeSave
function beforeSave()
{
// Convert all the uuid keys to ordered numbers
if (isset($this->data['NodeSchemaField']) && is_array($this->data['NodeSchemaField']) && count($this->data['NodeSchemaField']) > 0 && !Set::numeric(array_keys($this->data['NodeSchemaField']))) {
$nodeSchemaField = $this->data['NodeSchemaField'];
$this->data['NodeSchemaField'] = array();
$i = 0;
foreach ($nodeSchemaField as $nodeSchemaFieldUuid => $nodeSchemaFieldArray) {
$this->data['NodeSchemaField'][$i] = $nodeSchemaFieldArray;
unset($this->data['NodeSchemaField'][$nodeSchemaFieldUuid]);
// don't need this uuid field anymore
$i++;
}
}
return true;
}
示例9: checkEvents
function checkEvents($events)
{
$toTrigger = array();
if (!Set::numeric(array_keys($events))) {
$events = array($events);
}
foreach ($events as $event) {
if (empty($event[$this->alias])) {
$event = array($this->alias => $event);
}
if (!empty($event[$this->alias]['time']) && strtotime($event[$this->alias]['time']) <= mktime()) {
$toTrigger[] = $event;
}
}
if (!empty($toTrigger)) {
$this->triggerEvents($toTrigger);
}
}
示例10: search
function search($artist)
{
$artist = strtolower($artist);
//check for "The ...." pattern, switch to ..., The"
if (stripos($artist, 'the ') === 0) {
$artist = substr($artist, 4) . ', The';
}
$url = sprintf('%s/search', $this->url);
$params = array('type' => 'artists', 'q' => $artist);
$results = $this->__request($url, $params);
if (!empty($results['Exactresults'])) {
if (Set::numeric(array_keys($results['Exactresults']['Result']))) {
return array_shift($results['Exactresults']['Result']);
}
return $results['Exactresults']['Result'];
}
return false;
}
示例11: getResultFormat
function getResultFormat($model, &$results, $alias = null)
{
if (is_null($alias)) {
$alias = $model->alias;
}
$oldFormat = array();
$oldFormat['multiple'] = is_array($results) && Set::numeric(array_keys($results));
if (!$oldFormat['multiple']) {
$val = $results;
} else {
$val = reset($results);
}
$oldFormat['named'] = !empty($val) && (is_array($val) && isset($val[$alias]) || !empty($model->{key($val)}) && $model->{key($val)} instanceof Model);
if (!$oldFormat['named']) {
$val = array($alias => $val);
}
$oldFormat['idOnly'] = !empty($val[$alias]) && !is_array($val[$alias]) && is_numeric($val[$alias]);
return $oldFormat;
}
示例12: afterFind
function afterFind($data)
{
$data = $data['results'];
$filteredData = array();
$maxReplyId = 0;
if ($data && Set::numeric(array_keys($data))) {
foreach ($data as $i => $row) {
$maxReplyId = max($maxReplyId, $row['id']);
$options = array('callbacks' => false, 'action' => 'single', 'urlSuffix' => $row['id']);
$item = parent::find('all', $options);
if (!empty($item['in_reply_to_status_id']) && $item['in_reply_to_status_id'] == $this->replyProviderKey) {
$filteredData[] = array('Item' => array('provider_key' => $row['id'], 'text' => $row['text'], 'client' => $row['source'], 'link' => 'http://twitter.com/' . $row['from_user'] . '/status/' . $row['id'], 'reply_user_provider_key' => $this->parse($item, 'in_reply_to_user_id'), 'reply_status_provider_key' => $this->parse($item, 'in_reply_to_status_id'), 'posted' => date('Y-m-d H:i:s', strtotime($row['created_at']))), 'Origin' => array('provider_key' => $row['from_user_id'], 'name' => $row['from_user'], 'avatar' => $row['profile_image_url'], 'link' => 'http://twitter.com/' . $row['from_user']));
}
}
}
if ($maxReplyId > 0) {
$filteredData[] = array('maxReplyId' => $maxReplyId);
}
return $filteredData;
}
示例13: normalizeConfig
/**
* Creates all parameters on configuration using defaults, if not set.
* The configuration is stored back in the Configure class.
*
* @access public
* @return boolean Return true if succefully nomalized, false, if not.
*/
static function normalizeConfig()
{
$config = Configure::read('ContentStream');
if (Configure::read() && (!is_array($config['streams']) || Set::numeric(array_keys($config['streams'])))) {
return !trigger_error('CsConfigurator::normalizeConfig - ContentStream.streams must be a array indexed by type of content stream.');
}
$config['streams'] = Set::normalize($config['streams']);
foreach ($config['streams'] as $type => &$stream) {
if (!isset($stream['model'])) {
$stream['model'] = Inflector::camelize($type) . '.' . Inflector::classify($type);
}
if (!isset($stream['controller'])) {
$stream['controller'] = Inflector::pluralize($type);
}
if (!isset($stream['title'])) {
$stream['title'] = Inflector::humanize($type);
}
}
Configure::write('ContentStream', $config);
return self::$nomalized = true;
}
示例14: index
function index()
{
$panels = array();
foreach (Configure::read('Status.panels') as $panel => $options) {
if (is_numeric($panel)) {
$panel = $options;
$options = array();
}
if (empty($options) || !Set::numeric(array_keys($options))) {
$options = array($options);
}
if (strpos($panel, '.') !== false) {
list($plugin, $panel) = explode('.', $panel);
} else {
$plugin = false;
}
foreach ($options as $option) {
$panels[] = array('plugin' => $plugin, 'element' => $panel, 'options' => $option);
}
}
$this->set('panels', $panels);
}
示例15: makeItemXml
function makeItemXml($items)
{
$out = '';
foreach ($items as $modelName => $model) {
if (!empty($model)) {
$tagName = Inflector::underscore($modelName);
if ($tagName != 'data') {
$tagName = Inflector::singularize($tagName);
}
unset($model['internal']);
if (!Set::numeric(array_keys($model))) {
$model = array($model);
} else {
}
foreach ($model as $item) {
$attrib = array();
if (is_array($item)) {
$subItems = null;
unset($item['internal']);
if (!empty($item['items'])) {
$subItems = $item['items'];
}
unset($item['items']);
extract($this->dataSplitAttrib($item));
//debug($attrib );
$content = $this->makeItemXml($collections);
if (!empty($subItems)) {
$content .= $this->Xml->elem('items', null, $this->makeItemXml($subItems));
}
} else {
$content = $item;
}
$out .= $this->Xml->elem($tagName, $attrib, $content);
}
}
}
return $out;
}