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


PHP Set类代码示例

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


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

示例1: addSet

 public function addSet($name)
 {
     $s = new Set();
     $s->setName($name);
     $this->sets[] = $s;
     return $s;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:7,代码来源:StyleList.php

示例2: whenIteratingOverSet_ThenReturnAllUniqueItems

 /**
  * @test
  */
 public function whenIteratingOverSet_ThenReturnAllUniqueItems()
 {
     $item1 = 'A';
     $item2 = 'B';
     $set = new Set();
     $set->add($item1);
     $set->add($item2);
     $values = array();
     foreach ($set as $key => $value) {
         $values[$key] = $value;
     }
     $this->assertEquals(array(0 => 'A', 1 => 'B'), $values);
 }
开发者ID:roozbehmatloobi,项目名称:php-refactoring-browser,代码行数:16,代码来源:SetTest.php

示例3: collaborators

 public function collaborators()
 {
     $subscriptions = $this->Subscription->findAllByClassAndForeignId('Workspace', $this->Session->read('Workspace.id'));
     $subscribers = Set::extract('/Subscription/user_id', $subscriptions);
     $subscribers = $this->Subscription->User->find('all', array('conditions' => array('User.id' => $subscribers), 'fields' => array('id', 'name', 'email', 'facebook_id')));
     $this->set('subscribers', $subscribers);
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:7,代码来源:subscriptions_controller.php

示例4: _render

 protected function _render($options)
 {
     $metaFields = array_keys(Set::filter(Set::booleanize($this->getParam('metaFields'))));
     echo '<div class="line-meta-details">';
     echo $this->Html->postDetails($metaFields, array('prefixes' => array('author' => __('By', 'gummfw'), 'date' => __('/', 'gummfw'), 'comments' => __('/', 'gummfw'), 'category' => __('/', 'gummfw')), 'formats' => array('date' => 'd F Y')));
     echo '</div>';
 }
开发者ID:nikolaskarica,项目名称:bds-alliance,代码行数:7,代码来源:single_post_meta.php

示例5: admin_index

 public function admin_index()
 {
     $this->set('title_for_layout', __('Content', true));
     $this->Node->recursive = 0;
     $this->paginate['Node']['order'] = 'Node.id DESC';
     $this->paginate['Node']['conditions'] = array();
     $types = $this->Node->Term->Vocabulary->Type->find('all');
     $typeAliases = Set::extract('/Type/alias', $types);
     $this->paginate['Node']['conditions']['Node.type'] = $typeAliases;
     if (isset($this->params['named']['filter'])) {
         $filters = $this->Croogo->extractFilter();
         foreach ($filters as $filterKey => $filterValue) {
             if (strpos($filterKey, '.') === false) {
                 $filterKey = 'Node.' . $filterKey;
             }
             $this->paginate['Node']['conditions'][$filterKey] = $filterValue;
         }
         $this->set('filters', $filters);
     }
     $nodes = $this->paginate('Node');
     $this->set(compact('nodes', 'types', 'typeAliases'));
     if (isset($this->params['named']['links'])) {
         $this->layout = 'ajax';
         $this->render('admin_links');
     }
 }
开发者ID:alandesign,项目名称:croogo,代码行数:26,代码来源:nodes_controller.php

示例6: initialize

 /**
  *
  * @param AppController $controller
  * @param array         $settings
  */
 public function initialize($controller, $settings = array())
 {
     $this->settings = Set::merge($this->settings, $settings);
     $this->controller = $controller;
     $this->getTwitterSource();
     $this->Cookie->path = Router::url('/');
 }
开发者ID:hiromi2424,项目名称:twitter_kit,代码行数:12,代码来源:twitter.php

示例7: 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;
 }
开发者ID:rchavik,项目名称:20Couch,代码行数:34,代码来源:twitter_base.php

示例8: edit

 function edit($id)
 {
     //		if( (isset($this->data['Service']['submit'])) || (empty($this->data)) ) {
     if (empty($this->data)) {
         if (!$id) {
             $this->Session->setFlash('Invalid Service');
             $this->redirect($this->referer('/'));
         }
         $this->data = $this->Service->findById($id);
         //$this->set('service',$this->data);
         $this->pageTitle = "Edit Service: {$this->data['Service']['title']}";
         $this->set('user', Set::combine($this->Service->User->find('all', array('recursive' => 0)), '{n}.User.id', '{n}.User.name'));
         $this->set('customers', Set::combine($this->Service->Customer->find('all', array('recursive' => 0)), '{n}.Customer.id', '{n}.Customer.company_name'));
     } else {
         //$this->set('service',$this->Service->find(array('Service.id'=>$id)));
         if ($this->Service->save($this->data)) {
             $this->Session->setFlash("Website saved successfully.");
             $this->redirect($this->referer("/customers/view/{$this->data['Service']['customer_id']}"));
         } else {
             $this->Session->setFlash('Please correct errors below.');
             $this->set('user', Set::combine($this->Service->User->find('all', array('recursive' => 0)), '{n}.User.id', '{n}.User.name'));
             $this->set('customers', Set::combine($this->Service->Customer->find('all', array('recursive' => 0)), '{n}.Customer.id', '{n}.Customer.company_name'));
             $this->pageTitle = 'Edit Service: ' . $this->data['Service']['title'];
         }
     }
 }
开发者ID:searchfirst,项目名称:ODN,代码行数:26,代码来源:services_controller.php

示例9: index

 function index()
 {
     $this->Phrase->recursive = 0;
     $phrases = $this->paginate('Phrase');
     $this->set('phrases', $phrases);
     //get the list of locales
     $this->loadModel("Locale");
     //$locales = $this->Locale->find("list",array("fields"=>array("Locale.locale","Locale.name"),"order"=>array("name"=>"ASC")));
     $locales = Lang::localeList();
     $this->set("locales", $locales);
     //set the incoming locale to the session
     if (!empty($this->request->data)) {
         if (Set::check($this->request->data, "Phrase.selectLocale")) {
             $this->Session->write("ControlPanel.translate_locale", $this->request->data['Phrase']['selectLocale']);
         }
     }
     //get the locale from the session
     if ($this->Session->check("ControlPanel.translate_locale")) {
         $translate_locale = $this->Session->read("ControlPanel.translate_locale");
     } else {
         $translate_locale = 'en_us';
         $this->request->data['Phrase']['selectLocale'] = 'en_us';
     }
     $this->request->data['Phrase']['selectLocale'] = $translate_locale;
     $this->Phrase->setLanguage($translate_locale);
     //get the trnaslated phrases
     $ids = Set::extract("/Phrase/id", $phrases);
     //pr($this->Session->read());
     $locale_phrases = $this->Phrase->find('all', array("conditions" => array("Phrase.id" => $ids)));
     $this->set("locale_phrases", $locale_phrases);
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:31,代码来源:PhrasesController.php

示例10: _findCloud

 /**
  * Returns a tag cloud
  *
  * The result contains a "weight" field which has a normalized size of the tag
  * occurrence set. The min and max size can be set by passing 'minSize" and
  * 'maxSize' to the query. This value can be used in the view to controll the
  * size of the tag font.
  *
  * @todo Ideas to improve this are welcome
  * @param string
  * @param array
  * @param array
  * @return array
  * @access public
  */
 public function _findCloud($state, $query, $results = array())
 {
     if ($state == 'before') {
         $options = array('minSize' => 10, 'maxSize' => 20, 'page' => null, 'limit' => null, 'order' => null, 'joins' => null, 'offset' => null, 'contain' => 'Tag', 'conditions' => array(), 'fields' => 'Tag.*, Tagged.tag_id, COUNT(*) AS occurrence', 'group' => 'Tagged.tag_id');
         foreach ($query as $key => $value) {
             if (!empty($value)) {
                 $options[$key] = $value;
             }
         }
         $query = $options;
         if (isset($query['model'])) {
             $query['conditions'] = Set::merge($query['conditions'], array('Tagged.model' => $query['model']));
         }
         return $query;
     } elseif ($state == 'after') {
         if (!empty($results) && isset($results[0][0]['occurrence'])) {
             $weights = Set::extract($results, '{n}.0.occurrence');
             $maxWeight = max($weights);
             $minWeight = min($weights);
             $spread = $maxWeight - $minWeight;
             if (0 == $spread) {
                 $spread = 1;
             }
             foreach ($results as $key => $result) {
                 $size = $query['minSize'] + ($result[0]['occurrence'] - $minWeight) * (($query['maxSize'] - $query['minSize']) / $spread);
                 $results[$key]['Tag']['occurrence'] = $result[0]['occurrence'];
                 $results[$key]['Tag']['weight'] = ceil($size);
             }
         }
         return $results;
     }
 }
开发者ID:rchavik,项目名称:infinitas,代码行数:47,代码来源:tagged.php

示例11: validate

 function validate($prod, $order)
 {
     //debug($this->params);
     //debug($order);
     if (empty($order['ShopOrdersItem'])) {
         return false;
     }
     $ids = Set::extract('ShopOrdersItem.{n}.product_id', $order);
     $this->ShopProduct = ClassRegistry::init('Shop.ShopProduct');
     $this->ShopProduct->Aro = ClassRegistry::init('Aro');
     if (!empty($this->params['aroProduct'])) {
         $findOpt = array('fields' => array('Aro.foreign_key'), 'conditions' => array('Aro.model' => 'ShopProduct', 'Aro.foreign_key' => $ids), 'joins' => array(array('alias' => 'Parent', 'table' => $this->ShopProduct->Aro->useTable, 'type' => 'INNER', 'conditions' => array('Parent.id' => $this->params['aroProduct'], 'Aro.lft BETWEEN Parent.lft AND Parent.rght'))));
         $match = $this->ShopProduct->Aro->find('list', $findOpt);
         $match = array_values($match);
     } else {
         $match = $ids;
     }
     $qty = 0;
     foreach ($order['ShopOrdersItem'] as $item) {
         if (!empty($item['product_id']) && in_array($item['product_id'], $match)) {
             $qty += $item['nb'];
         }
     }
     return (!is_numeric($this->params['min']) || $qty >= $this->params['min']) && (!is_numeric($this->params['max']) || $qty <= $this->params['max']);
 }
开发者ID:kevthunder,项目名称:cake-shop,代码行数:25,代码来源:cart_contain_filter_promo.php

示例12: edit

 public function edit($id = null)
 {
     if (!$this->Session->check('Workspace.id')) {
         $this->Redirect->flash('not_in_workspace', array('controller' => 'workspaces', 'action' => 'index'));
     }
     if (!empty($this->data['TaskGroup'])) {
         if (!empty($this->data['TaskGroup']['id']) && !empty($this->data['TaskGroup']['assigned_to_id'])) {
             $this->TaskGroup->id = $this->data['TaskGroup']['id'];
             $oldAssignedToId = $this->TaskGroup->field('assigned_to_id');
         }
     }
     $Subscription = ClassRegistry::init('Subscription');
     $subscribers = $Subscription->findAllByClassAndForeignId('Workspace', $this->Session->read('Workspace.id'));
     $subscribers = Set::extract('/Subscription/user_id', $subscribers);
     $assignedTos = $this->TaskGroup->User->findList(array('conditions' => array('User.id' => $subscribers), 'fields' => array('id', 'name')));
     $this->set(compact('assignedTos'));
     $milestones = $this->TaskGroup->Milestone->find('list', array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id'))));
     $this->set(compact('milestones'));
     $stacksConditions = array();
     if ($this->Session->check('Milestone.id')) {
         $stacksConditions = array('conditions' => array('milestone_id' => $this->Session->read('Milestone.id')));
     } else {
         $stacksConditions = array('conditions' => array('workspace_id' => $this->Session->read('Workspace.id')));
     }
     $stacks = $this->TaskGroup->Stack->find('list', $stacksConditions);
     $this->set(compact('stacks'));
     parent::edit($id, array('controller' => 'tasks', 'action' => 'index'));
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:28,代码来源:task_groups_controller.php

示例13: __construct

 /**
  * Constructor
  *
  * @param ComponentCollection $collection The controller for this request.
  * @param string $settings An array of settings.  This class does not use any settings.
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $this->_Collection = $collection;
     $controller = $collection->getController();
     $this->controller($controller);
     $this->settings = Set::merge($this->settings, $settings);
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:13,代码来源:BaseAuthorize.php

示例14: formatCanteenOrder

 /**
  * Extract all required information from a CanteenOrder to send to the GatewayAccount Processor
  * @param CanteenOrder $CanteenOrder
  * @return Array:
  */
 public static function formatCanteenOrder($CanteenOrder)
 {
     $t = array();
     $customer = $CanteenOrder['BillingAddress'];
     #TRANSACTION
     $t['Transaction']['currency_id'] = Set::classicExtract($CanteenOrder, "CanteenOrder.currency_id");
     $t['Transaction']['amount'] = Set::classicExtract($CanteenOrder, "CanteenOrder.grand_total");
     $t['Transaction']['foreign_key'] = Set::classicExtract($CanteenOrder, "CanteenOrder.id");
     $t['Transaction']['model'] = "CanteenOrder";
     #CUSTOMER
     $t['Customer']['first_name'] = Set::classicExtract($customer, "first_name");
     $t['Customer']['last_name'] = Set::classicExtract($customer, "last_name");
     $t['Customer']['address'] = Set::classicExtract($customer, "street") . " " . Set::classicExtract($customer, "apt");
     $t['Customer']['postal'] = Set::classicExtract($customer, "postal_code");
     $t['Customer']['country'] = Set::classicExtract($customer, "country_code");
     $t['Customer']['email'] = Set::classicExtract($customer, "email");
     $t['Customer']['city'] = Set::classicExtract($customer, "city");
     $t['Customer']['state'] = Set::classicExtract($customer, "state");
     $t['Customer']['phone'] = Set::classicExtract($customer, "phone");
     $t['Customer']['user_id'] = Set::classicExtract($customer, "user_id");
     #CARD DATA
     $t['CardData']['number'] = Set::classicExtract($CanteenOrder, "CardData.number");
     $t['CardData']['exp_year'] = Set::classicExtract($CanteenOrder, "CardData.exp_year");
     $t['CardData']['exp_month'] = Set::classicExtract($CanteenOrder, "CardData.exp_month");
     $t['CardData']['code'] = Set::classicExtract($CanteenOrder, "CardData.code");
     return $t;
 }
开发者ID:josephbergdoll,项目名称:berrics,代码行数:32,代码来源:GatewayTransactionVO.php

示例15: file

 /**
  * リスト用のimgタグを出力する
  *
  * @param	array	$uploaderFile
  * @param	array	$options
  * @return	string	imgタグ
  */
 public function file($uploaderFile, $options = array())
 {
     if (isset($uploaderFile['UploaderFile'])) {
         $uploaderFile = $uploaderFile['UploaderFile'];
     }
     $imgUrl = $this->getFileUrl($uploaderFile['name']);
     $pathInfo = pathinfo($uploaderFile['name']);
     $ext = $pathInfo['extension'];
     $_options = array('alt' => $uploaderFile['alt']);
     $options = Set::merge($_options, $options);
     if (in_array(strtolower($ext), array('gif', 'jpg', 'png'))) {
         if (isset($options['size'])) {
             $resizeName = $pathInfo['filename'] . '__' . $options['size'] . '.' . $ext;
             if (!empty($uploaderFile['publish_begin']) || !empty($uploaderFile['publish_end'])) {
                 $savePath = $this->savePath . 'limited' . DS . $resizeName;
             } else {
                 $savePath = $this->savePath . $resizeName;
             }
             if (file_exists($savePath)) {
                 $imgUrl = $this->getFileUrl($resizeName);
                 unset($options['size']);
             }
         }
         return $this->Html->image($imgUrl, $options);
     } else {
         $imgUrl = 'Uploader.icon_upload_file.png';
         return $this->Html->image($imgUrl, $options);
     }
 }
开发者ID:baserproject,项目名称:basercms,代码行数:36,代码来源:UploaderHelper.php


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