• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Set类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: index

 function index()
 {
     $this->name = 'feedbacks';
     $feedbacks = $this->Feedback->getAllFeedbacks();
     $user_ids = Set::extract('/Feedback/user_id', $feedbacks);
     $this->set(array('feedbacks' => $feedbacks, 'feedback_posters' => $this->Profile->getProfilesInfoFromUserIds($user_ids), 'feedback_count' => $this->FeedbackComment->countFeedbackComments()));
 }
开发者ID:adityar003,项目名称:Cake-Resume-Builder,代码行数:7,代码来源:feedbacks_controller.php


示例17: display

 /**
  * Method to output a tag-cloud formatted based on the weight of the tags
  *
  * @param array $tags Tag data array
  * @param array $options Display options. Valid keys are:
  * 	- shuffle: true to shuffle the tag list, false to display them in the same order than passed [default: true]
  *  - extract: Set::extract() compatible format string. Path to extract weight values from the $tags array [default: {n}.Tag.weight]
  *  - before: string to be displayed before each generated link. "%size%" will be replaced with tag size calculated from the weight [default: empty]
  *  - after: string to be displayed after each generated link. "%size%" will be replaced with tag size calculated from the weight [default: empty]
  *  - maxSize: size of the heaviest tag [default: 160]
  *  - minSize: size of the lightest tag [default: 80]
  *  - url: an array containing the default URL
  *  - named: the named parameter used to send the tag [default: by]
  *  - paramType: the type of URL parameters used (named or querystring) [default: named]
  * @return string
  */
 public function display($tags = null, $options = array())
 {
     if (empty($tags) || !is_array($tags)) {
         return '';
     }
     $defaults = array('tagModel' => 'Tag', 'shuffle' => true, 'extract' => '{n}.Tag.weight', 'before' => '', 'after' => '', 'maxSize' => 160, 'minSize' => 80, 'url' => array('controller' => 'search'), 'named' => 'by', 'paramType' => 'named');
     $options = array_merge($defaults, $options);
     $weights = Set::extract($tags, $options['extract']);
     $maxWeight = max($weights);
     $minWeight = min($weights);
     // find the range of values
     $spread = $maxWeight - $minWeight;
     if (0 == $spread) {
         $spread = 1;
     }
     if ($options['shuffle'] == true) {
         shuffle($tags);
     }
     $cloud = null;
     foreach ($tags as $tag) {
         $data = Set::extract(array($tag), $options['extract']);
         $tagWeight = array_pop($data);
         $size = $options['minSize'] + ($tagWeight - $minWeight) * (($options['maxSize'] - $options['minSize']) / $spread);
         $size = $tag[$options['tagModel']]['size'] = ceil($size);
         $cloud .= $this->_replace($options['before'], $size);
         $cloud .= $this->Html->link($tag[$options['tagModel']]['name'], $this->_tagUrl($tag, $options), array('id' => 'tag-' . $tag[$options['tagModel']]['id'])) . ' ';
         $cloud .= $this->_replace($options['after'], $size);
     }
     return $cloud;
 }
开发者ID:tnoi,项目名称:tags,代码行数:46,代码来源:TagCloudHelper.php


示例18: testIndex

 public function testIndex()
 {
     $vars = $this->testAction('involvement_leaders/index/Involvement:1', array('return' => 'vars'));
     $results = Set::extract('/Leader', $vars['leaders']);
     $expected = array(array('Leader' => array('id' => 2, 'user_id' => 1, 'model' => 'Involvement', 'model_id' => 1, 'created' => '2010-04-09 07:28:57', 'modified' => '2010-04-09 07:28:57')));
     $this->assertEqual($results, $expected);
 }
开发者ID:styfle,项目名称:core,代码行数:7,代码来源:leaders_controller.test.php


示例19: getBilanServiceWithSqlQuery

 function getBilanServiceWithSqlQuery($id = 'all')
 {
     //  Méthode 3 : à l'aide d'une requête SQL directe
     $prefix = $this->tablePrefix;
     if ($id == 'all' or $id == null) {
         $sql = "SELECT perso_id AS id, perso_id, SUM( h_cours ) AS h_cours, SUM( h_td ) AS h_td, SUM( h_tp ) AS h_tp FROM {$prefix}matieres_persos AS MatieresPerso GROUP BY perso_id";
         $result = $this->query($sql);
         $result = Set::combine($result, '{n}.MatieresPerso.id', '{n}.0');
         // Mise en forme l'array pour avoir perso_id comme clé
         return $result;
     } else {
         App::import('Sanitize');
         $id = Sanitize::paranoid($id);
         // use Sanitize for $id to avoid SQL injection
         $sql = "SELECT perso_id AS id, perso_id, SUM( h_cours ) AS h_cours, SUM( h_td ) AS h_td, SUM( h_tp ) AS h_tp FROM {$prefix}matieres_persos AS MatieresPerso WHERE perso_id={$id} GROUP BY perso_id LIMIT 1";
         $result = $this->query($sql);
         if (!empty($result[0])) {
             //$result = Set::merge($result[0]["MatieresPerso"], $result[0][0]);
             //return $result;
             return $result[0][0];
         } else {
             return array('h_cours' => 0, 'h_td' => 0, 'h_tp' => 0);
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:25,代码来源:perso.php


示例20: initCore

 /**
  * initCore
  * Setup your Config/core.php
  *
  * @param array $config 
  * @return boolean
  * @throws CakeException
  */
 public function initCore($config = array())
 {
     $path = $this->appPath . 'Config' . DS . 'core.php';
     if (!file_exists($path)) {
         throw new CakeException(__d('oven', 'Core config file could not be found.'));
     }
     if (!is_writable($path)) {
         throw new CakeException(__d('oven', 'Core config is not writable.'));
     }
     $config = Set::merge(array('salt' => substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'), 0, 40), 'cipherSeed' => str_shuffle(str_repeat('0123456789', 3))), $config);
     // READ FILE
     $file = new File($path);
     $contents = $file->read();
     // CHANGE SALT
     $replace = "Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');";
     $with = "Configure::write('Security.salt', '" . $config['salt'] . "');";
     $contents = str_replace($replace, $with, $contents);
     // CHANGE CIPHERSEED
     $replace = "Configure::write('Security.cipherSeed', '76859309657453542496749683645');";
     $with = "Configure::write('Security.cipherSeed', '" . $config['cipherSeed'] . "');";
     $contents = str_replace($replace, $with, $contents);
     // TURN ON ADMIN ROUTING
     $replace = "//Configure::write('Routing.prefixes', array('admin'));";
     $with = "Configure::write('Routing.prefixes', array('admin'));";
     $contents = str_replace($replace, $with, $contents);
     // WRITE FILE
     $file->write($contents);
     $file->close();
     return true;
 }
开发者ID:shama,项目名称:oven,代码行数:38,代码来源:Init.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Setting类代码示例发布时间:2022-05-23
下一篇:
PHP Sessions类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap