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

PHP ArrayUtil类代码示例

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

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



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

示例1: parseKeywords

 /**
  * Parses search keywords.
  * 
  * @param	string		$keywordString
  */
 protected static function parseKeywords($keywordString)
 {
     // convert encoding if necessary
     if (CHARSET == 'UTF-8' && !StringUtil::isASCII($keywordString) && !StringUtil::isUTF8($keywordString)) {
         $keywordString = StringUtil::convertEncoding('ISO-8859-1', 'UTF-8', $keywordString);
     }
     // remove bad wildcards
     $keywordString = preg_replace('/(?<!\\w)\\*/', '', $keywordString);
     // remove search operators
     $keywordString = preg_replace('/[\\+\\-><()~]+/', '', $keywordString);
     if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
         // phrases search
         $keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
         if (!empty($keywordString)) {
             self::$keywords = array_merge(self::$keywords, array(StringUtil::encodeHTML($keywordString)));
         }
     } else {
         // replace word delimiters by space
         $keywordString = preg_replace('/[.,]/', ' ', $keywordString);
         $keywords = ArrayUtil::encodeHTML(ArrayUtil::trim(explode(' ', $keywordString)));
         if (count($keywords) > 0) {
             self::$keywords = array_merge(self::$keywords, $keywords);
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:30,代码来源:KeywordHighlighter.class.php


示例2: readFormParameters

 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['unignoredBoardIDArray']) && is_array($_POST['unignoredBoardIDArray'])) {
         $this->unignoredBoardIDArray = ArrayUtil::toIntegerArray($_POST['unignoredBoardIDArray']);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:10,代码来源:BoardIgnoreForm.class.php


示例3: resolveEmailMessageFromPostData

 /**
  * Given post data and an email message, populate the sender and account on the email message if possible.
  * Also add message recipients and any attachments.
  * @param array $postData
  * @param EmailMessage $emailMessage
  * @param User $userToSendMessagesFrom
  * @return boolean
  */
 public static function resolveEmailMessageFromPostData(array &$postData, CreateEmailMessageForm $emailMessageForm, User $userToSendMessagesFrom)
 {
     $postVariableName = get_class($emailMessageForm);
     Yii::app()->emailHelper->loadOutboundSettingsFromUserEmailAccount($userToSendMessagesFrom);
     $toRecipients = explode(",", $postData[$postVariableName]['recipientsData']['to']);
     // Not Coding Standard
     static::attachRecipientsToMessage($toRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_TO);
     if (ArrayUtil::getArrayValue($postData[$postVariableName]['recipientsData'], 'cc') != null) {
         $ccRecipients = explode(",", $postData[$postVariableName]['recipientsData']['cc']);
         // Not Coding Standard
         static::attachRecipientsToMessage($ccRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_CC);
     }
     if (ArrayUtil::getArrayValue($postData[$postVariableName]['recipientsData'], 'bcc') != null) {
         $bccRecipients = explode(",", $postData[$postVariableName]['recipientsData']['bcc']);
         // Not Coding Standard
         static::attachRecipientsToMessage($bccRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_BCC);
     }
     if (isset($postData['filesIds'])) {
         static::attachFilesToMessage($postData['filesIds'], $emailMessageForm->getModel());
     }
     $emailAccount = EmailAccount::getByUserAndName($userToSendMessagesFrom);
     $sender = new EmailMessageSender();
     $sender->fromName = Yii::app()->emailHelper->fromName;
     $sender->fromAddress = Yii::app()->emailHelper->fromAddress;
     $sender->personOrAccount = $userToSendMessagesFrom;
     $emailMessageForm->sender = $sender;
     $emailMessageForm->account = $emailAccount;
     $emailMessageForm->content->textContent = EmailMessageUtil::resolveTextContent(ArrayUtil::getArrayValue($postData[$postVariableName]['content'], 'htmlContent'), null);
     $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
     $emailMessageForm->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_OUTBOX);
     return $emailMessageForm;
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:40,代码来源:EmailMessageUtil.php


示例4: actionDetails

 public function actionDetails($id)
 {
     $contact = static::getModelAndCatchNotFoundAndDisplayError('Contact', intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($contact);
     if (!LeadsUtil::isStateALead($contact->state)) {
         $urlParams = array('/contacts/' . $this->getId() . '/details', 'id' => $contact->id);
         $this->redirect($urlParams);
     } else {
         AuditEvent::logAuditEvent('ZurmoModule', ZurmoModule::AUDIT_EVENT_ITEM_VIEWED, array(strval($contact), 'LeadsModule'), $contact);
         $getData = GetUtil::getData();
         $isKanbanBoardInRequest = ArrayUtil::getArrayValue($getData, 'kanbanBoard');
         if ($isKanbanBoardInRequest == 0 || $isKanbanBoardInRequest == null || Yii::app()->userInterface->isMobile() === true) {
             $breadCrumbView = StickySearchUtil::resolveBreadCrumbViewForDetailsControllerAction($this, 'LeadsSearchView', $contact);
             $detailsAndRelationsView = $this->makeDetailsAndRelationsView($contact, 'LeadsModule', 'LeadDetailsAndRelationsView', Yii::app()->request->getRequestUri(), $breadCrumbView);
             $view = new LeadsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $detailsAndRelationsView));
         } else {
             $kanbanItem = new KanbanItem();
             $kanbanBoard = new TaskKanbanBoard($kanbanItem, 'type', $contact, get_class($contact));
             $kanbanBoard->setIsActive();
             $params['relationModel'] = $contact;
             $params['relationModuleId'] = $this->getModule()->getId();
             $params['redirectUrl'] = null;
             $listView = new TasksForLeadKanbanView($this->getId(), 'tasks', 'Task', null, $params, null, array(), $kanbanBoard);
             $view = new LeadsPageView(ZurmoDefaultViewUtil::makeStandardViewForCurrentUser($this, $listView));
         }
         echo $view->render();
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:28,代码来源:DefaultController.php


示例5: readFormParameters

 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['subject'])) {
         $this->subject = $_POST['subject'];
     }
     if (isset($_POST['text'])) {
         $this->text = $_POST['text'];
     }
     if (isset($_POST['enableSmilies'])) {
         $this->enableSmilies = $_POST['enableSmilies'];
     }
     if (isset($_POST['enableHtml'])) {
         $this->enableHtml = $_POST['enableHtml'];
     }
     if (isset($_POST['enableBBCodes'])) {
         $this->enableBBCodes = $_POST['enableBBCodes'];
     }
     if (isset($_POST['showSignature'])) {
         $this->showSignature = $_POST['showSignature'];
     }
     if (isset($_POST['groupIDs']) && is_array($_POST['groupIDs'])) {
         $this->groupIDs = ArrayUtil::toIntegerArray($_POST['groupIDs']);
     }
     if (isset($_POST['preview'])) {
         $this->preview = (bool) $_POST['preview'];
     }
     if (isset($_POST['send'])) {
         $this->send = (bool) $_POST['send'];
     }
     if (isset($_POST['maxLifeTime'])) {
         $this->maxLifeTime = intval($_POST['maxLifeTime']);
     }
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:37,代码来源:PMToUserGroupsForm.class.php


示例6: resolveNonEditableWrapperHtmlOptions

 protected function resolveNonEditableWrapperHtmlOptions()
 {
     $htmlOptions = parent::resolveNonEditableWrapperHtmlOptions();
     $htmlOptions['class'] .= ' button-wrapper';
     $htmlOptions['align'] = ArrayUtil::getArrayValue($this->properties['backend'], 'align');
     return $htmlOptions;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:7,代码来源:BuilderButtonWrapperElement.php


示例7: __construct

 public function __construct($modelClassName, $attributeName)
 {
     parent::__construct($modelClassName, $attributeName);
     assert('$attributeName == null');
     $states = $this->resolveStates();
     $this->states = ArrayUtil::resolveArrayToLowerCase($states);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:7,代码来源:ContactStateBatchAttributeValueDataAnalyzer.php


示例8: readFormParameters

 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['username'])) {
         $this->username = StringUtil::trim($_POST['username']);
     }
     if (isset($_POST['email'])) {
         $this->email = StringUtil::trim($_POST['email']);
     }
     if (isset($_POST['confirmEmail'])) {
         $this->confirmEmail = StringUtil::trim($_POST['confirmEmail']);
     }
     if (isset($_POST['password'])) {
         $this->password = $_POST['password'];
     }
     if (isset($_POST['confirmPassword'])) {
         $this->confirmPassword = $_POST['confirmPassword'];
     }
     if (isset($_POST['groupIDs']) && is_array($_POST['groupIDs'])) {
         $this->groupIDs = ArrayUtil::toIntegerArray($_POST['groupIDs']);
     }
     if (isset($_POST['visibleLanguages']) && is_array($_POST['visibleLanguages'])) {
         $this->visibleLanguages = ArrayUtil::toIntegerArray($_POST['visibleLanguages']);
     }
     if (isset($_POST['languageID'])) {
         $this->languageID = intval($_POST['languageID']);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:31,代码来源:UserAddForm.class.php


示例9: readParameters

 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_POST['applicationIDs'])) {
         $this->applicationIDs = ArrayUtil::toIntegerArray($_POST['applicationIDs']);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:10,代码来源:UserGroupApplicationDeleteAction.class.php


示例10: go

 public static function go($obj, $arr)
 {
     if (!is_null($obj)) {
         try {
             if (!is_array($obj)) {
                 throw new Exception("obj or arr is not an array");
             }
         } catch (Exception $e) {
             krumo($obj, $arr);
             krumo($e);
             die;
         }
     }
     //-------------------------------------------
     $obj = ArrayUtil::array_replace_recursive($arr, $obj);
     //-------------------------------------------
     if (is_array($obj['file'])) {
         $files = array();
         foreach ($obj['file'] as $value) {
             $newObj = ArrayUtil::array_replace_recursive(array(), $obj);
             $newObj['file'] = $value;
             //-------------------------------------------
             $ref = new Import($newObj);
             //-------------------------------------------
             array_push($files, $ref->init());
         }
     } else {
         $ref = new Import($obj);
         return $ref->init();
     }
 }
开发者ID:awwthentic1234,项目名称:hey,代码行数:31,代码来源:Import.php


示例11: resolveEmailMessageFromPostData

 /**
  * Given post data and an email message, populate the sender and account on the email message if possible.
  * Also add message recipients and any attachments.
  * @param array $postData
  * @param CreateEmailMessageForm $emailMessageForm
  * @param User $userToSendMessagesFrom
  * @return CreateEmailMessageForm
  */
 public static function resolveEmailMessageFromPostData(array &$postData, CreateEmailMessageForm $emailMessageForm, User $userToSendMessagesFrom)
 {
     $postVariableName = get_class($emailMessageForm);
     $toRecipients = explode(",", $postData[$postVariableName]['recipientsData']['to']);
     // Not Coding Standard
     static::attachRecipientsToMessage($toRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_TO);
     if (ArrayUtil::getArrayValue($postData[$postVariableName]['recipientsData'], 'cc') != null) {
         $ccRecipients = explode(",", $postData[$postVariableName]['recipientsData']['cc']);
         // Not Coding Standard
         static::attachRecipientsToMessage($ccRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_CC);
     }
     if (ArrayUtil::getArrayValue($postData[$postVariableName]['recipientsData'], 'bcc') != null) {
         $bccRecipients = explode(",", $postData[$postVariableName]['recipientsData']['bcc']);
         // Not Coding Standard
         static::attachRecipientsToMessage($bccRecipients, $emailMessageForm->getModel(), EmailMessageRecipient::TYPE_BCC);
     }
     if (isset($postData['filesIds'])) {
         static::attachFilesToMessage($postData['filesIds'], $emailMessageForm->getModel());
     }
     $emailAccount = EmailAccount::getByUserAndName($userToSendMessagesFrom);
     $sender = new EmailMessageSender();
     $sender->fromName = $emailAccount->fromName;
     $sender->fromAddress = $emailAccount->fromAddress;
     $sender->personsOrAccounts->add($userToSendMessagesFrom);
     $emailMessageForm->sender = $sender;
     $emailMessageForm->account = $emailAccount;
     $box = EmailBoxUtil::getDefaultEmailBoxByUser($userToSendMessagesFrom);
     $emailMessageForm->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_OUTBOX);
     return $emailMessageForm;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:38,代码来源:EmailMessageUtil.php


示例12: readParameters

 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['userID'])) {
         $this->userID = ArrayUtil::toIntegerArray($_REQUEST['userID']);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:10,代码来源:UserActionPage.class.php


示例13: renderControlContentNonEditable

 protected function renderControlContentNonEditable()
 {
     if (!isset($this->properties['backend']['services'])) {
         return null;
     }
     $content = null;
     $sizeClass = null;
     if (isset($this->properties['backend']['sizeClass'])) {
         $sizeClass = $this->properties['backend']['sizeClass'];
     }
     foreach ($this->properties['backend']['services'] as $serviceName => $serviceDetails) {
         if (ArrayUtil::getArrayValue($serviceDetails, 'enabled') and ArrayUtil::getArrayValue($serviceDetails, 'url')) {
             $properties = array();
             $properties['frontend']['href'] = $serviceDetails['url'];
             $properties['frontend']['target'] = '_blank';
             $properties['backend']['text'] = $serviceName;
             $properties['backend']['sizeClass'] = 'button social-button ' . $serviceName . ' ' . $sizeClass;
             $id = $this->id . '_' . $serviceName;
             $element = BuilderElementRenderUtil::resolveElement('BuilderSocialButtonElement', $this->renderForCanvas, $id, $properties);
             $content .= $element->renderNonEditable();
             $content .= $this->resolveSpacerContentForVerticalLayout();
             $content .= $this->resolveTdCloseAndOpenContentForHorizontalLayout();
         }
     }
     return $content;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:26,代码来源:BuilderSocialElement.php


示例14: readFormParameters

 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     $this->ignoreUniques = $this->plugin = $this->standalone = 0;
     if (isset($_POST['packageUpdateServerIDs']) && is_array($_POST['packageUpdateServerIDs'])) {
         $this->packageUpdateServerIDs = ArrayUtil::toIntegerArray($_POST['packageUpdateServerIDs']);
     }
     if (isset($_POST['packageName'])) {
         $this->packageName = StringUtil::trim($_POST['packageName']);
     }
     if (isset($_POST['author'])) {
         $this->author = StringUtil::trim($_POST['author']);
     }
     if (isset($_POST['searchDescription'])) {
         $this->searchDescription = intval($_POST['searchDescription']);
     }
     if (isset($_POST['plugin'])) {
         $this->plugin = intval($_POST['plugin']);
     }
     if (isset($_POST['standalone'])) {
         $this->standalone = intval($_POST['standalone']);
     }
     if (isset($_POST['other'])) {
         $this->other = intval($_POST['other']);
     }
     if (isset($_POST['ignoreUniques'])) {
         $this->ignoreUniques = intval($_POST['ignoreUniques']);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:32,代码来源:PackageUpdateSearchForm.class.php


示例15: readParameters

 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_POST['sourceListPositions']) && is_array($_POST['sourceListPositions'])) {
         $this->positions = ArrayUtil::toIntegerArray($_POST['sourceListPositions']);
     }
 }
开发者ID:ZerGabriel,项目名称:PackageBuilder,代码行数:10,代码来源:SourceSortAction.class.php


示例16: news

 /**
  * 返回图文模板 - 多条图文,故采用方法,直接返回格式化后的字符串
  * @param String $fromUserName 发送方
  * @param String $toUserName 接收方
  * @param Array $arr 一维度数组 或 二维数组,代表一个图文消息里多个条目
  * @param Integer $brandId 品牌主键
  * 注意:
  * 数组$arr可以是关联数组,且存在键 title, description, pic_url, url
  * 也可以是索引数组,则0-3对应上述相应的值,不可错乱
  * 
  * picUrl限制图片链接的域名需要与开发者填写的基本资料中的Url一致
  */
 public static function news($fromUserName, $toUserName, $arr, $brandId)
 {
     if (ArrayUtil::depth($arr) == 1) {
         // 一维数组,图文一条条目
         if (isset($v['title'])) {
             return sprintf(PushTemplates::NEWS, $fromUserName, $toUserName, time(), $arr['title'], $arr['description'], Brand::fullPicUrl($arr['pic_url'], $brandId), URLOauth::redirect($brandId, $arr['url']));
         } else {
             return sprintf(PushTemplates::NEWS, $fromUserName, $toUserName, time(), $arr[0], $arr[1], Brand::fullPicUrl($arr[2], $brandId), URLOauth::redirect($brandId, $arr[3]));
         }
     } else {
         // 二维数组,图文多条条目
         $item = "<item>\n\t\t\t\t <Title><![CDATA[%s]]></Title> \n\t\t\t\t <Description><![CDATA[%s]]></Description>\n\t\t\t\t <PicUrl><![CDATA[%s]]></PicUrl>\n\t\t\t\t <Url><![CDATA[%s]]></Url>\n\t\t\t\t </item>";
         $itemStr = '';
         foreach ($arr as $v) {
             if (isset($v['title'])) {
                 $itemStr .= sprintf($item, $v['title'], $v['description'], Brand::fullPicUrl($v['pic_url'], $brandId), URLOauth::redirect($brandId, $v['url']));
             } else {
                 $itemStr .= sprintf($item, $v[0], $v[1], Brand::fullPicUrl($v[2], $brandId), URLOauth::redirect($brandId, $v[3]));
             }
         }
         // 注意,不能在此处 $tbl . $itemStr ."</Articles>...",然后再sprintf因此URLOauth中的网址包含了转义字符%s等,造成sprintf参数太少的错误
         $tbl = "<xml>\n\t\t\t\t\t <ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t <FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t <CreateTime>%s</CreateTime>\n\t\t\t\t\t <MsgType><![CDATA[news]]></MsgType>\n\t\t\t\t\t <ArticleCount>" . count($arr) . "</ArticleCount>\n\t\t\t\t\t <Articles>\n\t\t\t\t\t\t ";
         $frontPortion = sprintf($tbl, $fromUserName, $toUserName, time());
         return $frontPortion . $itemStr . "\n\t\t\t\t\t </Articles>\n\t\t\t\t\t <FuncFlag>1</FuncFlag>\n\t\t\t\t\t </xml>";
     }
 }
开发者ID:song-yuan,项目名称:wymenujp,代码行数:38,代码来源:ResponsePush.php


示例17: getAllModuleRightsDataByPermitable

 /**
  * @return array of all module rights data
  */
 public static function getAllModuleRightsDataByPermitable(Permitable $permitable)
 {
     $data = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         if ($module instanceof SecurableModule) {
             $moduleClassName = get_class($module);
             $rights = $moduleClassName::getRightsNames();
             $rightLabels = $moduleClassName::getTranslatedRightsLabels();
             $reflectionClass = new ReflectionClass($moduleClassName);
             if (!empty($rights)) {
                 $rightsData = array();
                 foreach ($rights as $right) {
                     if (!isset($rightLabels[$right])) {
                         throw new NotSupportedException($right);
                     }
                     $explicit = $permitable->getExplicitActualRight($moduleClassName, $right);
                     $inherited = $permitable->getInheritedActualRight($moduleClassName, $right);
                     $effective = $permitable->getEffectiveRight($moduleClassName, $right);
                     $constants = $reflectionClass->getConstants();
                     $constantId = array_search($right, $constants);
                     $rightsData[$constantId] = array('displayName' => $rightLabels[$right], 'explicit' => RightsUtil::getRightStringFromRight($explicit), 'inherited' => RightsUtil::getRightStringFromRight($inherited), 'effective' => RightsUtil::getRightStringFromRight($effective));
                 }
                 $data[$moduleClassName] = ArrayUtil::subValueSort($rightsData, 'displayName', 'asort');
             }
         }
     }
     return $data;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:RightsUtil.php


示例18: getSearchQuery

 /**
  * Gets the search query keywords.
  */
 protected static function getSearchQuery()
 {
     self::$searchQuery = false;
     if (isset($_GET['highlight'])) {
         $keywordString = $_GET['highlight'];
         // remove search operators
         $keywordString = preg_replace('/[\\+\\-><()~\\*]+/', '', $keywordString);
         if (StringUtil::substring($keywordString, 0, 1) == '"' && StringUtil::substring($keywordString, -1) == '"') {
             // phrases search
             $keywordString = StringUtil::trim(StringUtil::substring($keywordString, 1, -1));
             if (!empty($keywordString)) {
                 self::$searchQuery = $keywordString;
             }
         } else {
             self::$searchQuery = ArrayUtil::trim(explode(' ', $keywordString));
             if (count(self::$searchQuery) == 0) {
                 self::$searchQuery = false;
             } else {
                 if (count(self::$searchQuery) == 1) {
                     self::$searchQuery = reset(self::$searchQuery);
                 }
             }
         }
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:28,代码来源:SearchResultTextParser.class.php


示例19: testUpdateTopBarLinks

 public function testUpdateTopBarLinks()
 {
     //
     // ensure that we can reorder modules
     //
     $moduleIdsOrdered = Yii::app()->db->createCommand("\n            select id\n            from x2_modules\n            where visible\n            order by menuPosition asc\n        ")->queryColumn();
     Modules::updateTopBarLinks(array_reverse($moduleIdsOrdered), array());
     $moduleIdsOrderedNew = Yii::app()->db->createCommand("\n            select id\n            from x2_modules\n            where visible\n            order by menuPosition asc\n        ")->queryColumn();
     // ensure that module menu position order was reversed
     $this->assertEquals(array_reverse($moduleIdsOrdered), $moduleIdsOrderedNew);
     //
     // ensure that we can change visibility of modules
     //
     $moduleIdsOrdered = $moduleIdsOrderedNew;
     Modules::updateTopBarLinks(array(), $moduleIdsOrdered);
     $hiddenModuleIds = Yii::app()->db->createCommand("\n            select id\n            from x2_modules\n            where not visible and menuPosition=-1\n            order by id asc\n        ")->queryColumn();
     // ensure that all formerly visible modules are now hidden with menuPosition = -1
     $this->assertEquals(ArrayUtil::sort($moduleIdsOrdered), $hiddenModuleIds);
     //
     // Change visibility and reorder, for good measure
     //
     $moduleIds = Yii::app()->db->createCommand("\n            select id\n            from x2_modules\n            order by id asc\n        ")->queryColumn();
     $hideThese = array_reverse(array_slice($moduleIds, 0, floor(count($moduleIds) / 2)));
     $showThese = array_reverse(array_slice($moduleIds, floor(count($moduleIds) / 2)));
     Modules::updateTopBarLinks($showThese, $hideThese);
     $this->assertEquals($showThese, Yii::app()->db->createCommand("\n            select id\n            from x2_modules\n            where visible\n            order by menuPosition asc\n        ")->queryColumn());
     $this->assertEquals($hideThese, Yii::app()->db->createCommand("\n            select id\n            from x2_modules\n            where not visible and menuPosition = -1\n            order by id desc\n        ")->queryColumn());
 }
开发者ID:tymiles003,项目名称:X2CRM,代码行数:28,代码来源:ModulesTest.php


示例20: getFactors

/**
 *  2Moons
 *  Copyright (C) 2012 Jan Kröpke
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @package 2Moons
 * @author Jan Kröpke <[email protected]>
 * @copyright 2012 Jan Kröpke <[email protected]>
 * @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
 * @version 1.7.2 (2013-03-18)
 * @info $Id$
 * @link http://2moons.cc/
 */
function getFactors($USER, $Type = 'basic', $TIME = NULL)
{
    global $resource, $pricelist, $reslist;
    if (empty($TIME)) {
        $TIME = TIMESTAMP;
    }
    $bonusList = BuildFunctions::getBonusList();
    $factor = ArrayUtil::combineArrayWithSingleElement($bonusList, 0);
    foreach ($reslist['bonus'] as $elementID) {
        $bonus = $pricelist[$elementID]['bonus'];
        if (isset($PLANET[$resource[$elementID]])) {
            $elementLevel = $PLANET[$resource[$elementID]];
        } elseif (isset($USER[$resource[$elementID]])) {
            $elementLevel = $USER[$resource[$elementID]];
        } else {
            continue;
        }
        if (in_array($elementID, $reslist['dmfunc'])) {
            if (DMExtra($elementLevel, $TIME, false, true)) {
                continue;
            }
            foreach ($bonusList as $bonusKey) {
                $factor[$bonusKey] += $bonus[$bonusKey][0];
            }
        } else {
            foreach ($bonusList as $bonusKey) {
                $factor[$bonusKey] += $elementLevel * $bonus[$bonusKey][0];
            }
        }
    }
    return $factor;
}
开发者ID:Hetachi,项目名称:2Moons,代码行数:57,代码来源:GeneralFunctions.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP ArrayUtils类代码示例发布时间:2022-05-23
下一篇:
PHP ArrayObject类代码示例发布时间: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