/** * 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); } } }
/** * @see Form::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); if (isset($_POST['unignoredBoardIDArray']) && is_array($_POST['unignoredBoardIDArray'])) { $this->unignoredBoardIDArray = ArrayUtil::toIntegerArray($_POST['unignoredBoardIDArray']); } }
/** * 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; }
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(); } }
/** * @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']); } }
protected function resolveNonEditableWrapperHtmlOptions() { $htmlOptions = parent::resolveNonEditableWrapperHtmlOptions(); $htmlOptions['class'] .= ' button-wrapper'; $htmlOptions['align'] = ArrayUtil::getArrayValue($this->properties['backend'], 'align'); return $htmlOptions; }
public function __construct($modelClassName, $attributeName) { parent::__construct($modelClassName, $attributeName); assert('$attributeName == null'); $states = $this->resolveStates(); $this->states = ArrayUtil::resolveArrayToLowerCase($states); }
/** * @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']); } }
/** * @see Action::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['applicationIDs'])) { $this->applicationIDs = ArrayUtil::toIntegerArray($_POST['applicationIDs']); } }
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(); } }
/** * 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; }
/** * @see Page::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['userID'])) { $this->userID = ArrayUtil::toIntegerArray($_REQUEST['userID']); } }
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; }
/** * @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']); } }
/** * @see Action::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_POST['sourceListPositions']) && is_array($_POST['sourceListPositions'])) { $this->positions = ArrayUtil::toIntegerArray($_POST['sourceListPositions']); } }
/** * 返回图文模板 - 多条图文,故采用方法,直接返回格式化后的字符串 * @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>"; } }
/** * @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; }
/** * 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); } } } } }
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()); }
/** * 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 <*****@*****.**> * @copyright 2012 Jan Kröpke <*****@*****.**> * @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; }
/** * @see Form::readFormParameters() */ public function readFormParameters() { parent::readFormParameters(); $this->allTemplates = $this->useRegex = $this->caseSensitive = $this->replace = $this->invertSearch = $this->invertTemplates = 0; if (isset($_POST['allTemplates'])) { $this->allTemplates = intval($_POST['allTemplates']); } if (isset($_POST['templateID']) && is_array($_POST['templateID'])) { $this->templateID = ArrayUtil::toIntegerArray($_POST['templateID']); } if (isset($_POST['useRegex'])) { $this->useRegex = intval($_POST['useRegex']); } if (isset($_POST['caseSensitive'])) { $this->caseSensitive = intval($_POST['caseSensitive']); } if (isset($_POST['replace'])) { $this->replace = intval($_POST['replace']); } if (isset($_POST['invertSearch'])) { $this->invertSearch = intval($_POST['invertSearch']); } if (isset($_POST['invertTemplates'])) { $this->invertTemplates = intval($_POST['invertTemplates']); } if (isset($_POST['replaceBy'])) { $this->replaceBy = $_POST['replaceBy']; } if (isset($_POST['query'])) { $this->query = $_POST['query']; } }
/** * Get files from directory, to be imported using Yii::import function * For WebApplication, we don't want to include files from test folders. * @param string $dir * @param string $basePath * @param string $beginAliasPath * @param boolean $includeTests * @return array */ public static function getFilesFromDir($dir, $basePath, $beginAliasPath, $includeTests = false) { $files = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { $includeFile = false; if ($file != 'tests') { $includeFile = true; } elseif ($file == 'tests') { if ($includeTests) { $includeFile = true; } else { $includeFile = false; } } if ($file != "." && $file != ".." && $includeFile) { if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { $dir2 = $dir . DIRECTORY_SEPARATOR . $file; $files[] = self::getFilesFromDir($dir2, $basePath, $beginAliasPath, $includeTests); } elseif (substr(strrchr($file, '.'), 1) == 'php') { $tmp = $dir . DIRECTORY_SEPARATOR . $file; $tmp = str_replace($basePath, $beginAliasPath, $tmp); $tmp = str_replace(DIRECTORY_SEPARATOR, '.', $tmp); $files[] = substr($tmp, 0, -4); } } } closedir($handle); } return ArrayUtil::flatten($files); }
public function testFindAllMainByExpressionAndObject() { $aMainPaths = ResourceFinder::findResourcesByExpressions(array('lib', 'main.php')); $this->assertSame(1, count($aMainPaths)); $oFileRes = new FileResource(ArrayUtil::assocPeek($aMainPaths)); $this->assertSame(array($oFileRes->getRelativePath() => MAIN_DIR . '/base/lib/main.php'), $aMainPaths); }
/** * Turn a record into a string * @param Record $object * @return string */ public function getXML(Transformable $object) { $xml = "\n<record table='{$object->getTableName()}' id='{$object->getId()}'>"; foreach ($object->getAttributes() as $key => $value) { // Need this to make sure the magic getter is called for lazy loading $value = $object->{$key}; $xml .= "\n\t<{$key}>"; if ($value instanceof XML) { $xml .= $value->getXML(); } else { if (is_bool($value)) { $xml .= $value ? "true" : "false"; } else { if (is_array($value)) { $xml .= ArrayUtil::getXML($value); } else { $xml .= htmlspecialchars($value, ENT_COMPAT, "UTF-8", false); } } } $xml .= "</{$key}>"; } $xml .= "\n</record>"; return $xml; }
/** * Unset a key in the settings data. * * @param string $key */ public function forget($key) { $this->unsaved = true; if ($this->has($key)) { ArrayUtil::forget($this->data, $key); } }
/** * @param string $modelClassName * @param string $memberName * @param array $attributeLabels * @param $defaultValue * @param int $maxLength * @param int $minValue * @param int $maxValue * @param int $precision * @param bool $isRequired * @param bool $isAudited * @param string $elementType * @param array $partialTypeRule * @param array $mixedRule */ public static function addOrUpdateMember($modelClassName, $memberName, $attributeLabels, $defaultValue, $maxLength, $minValue, $maxValue, $precision, $isRequired, $isAudited, $elementType, array $partialTypeRule, array $mixedRule = null) { assert('is_string($modelClassName) && $modelClassName != ""'); assert('is_string($memberName) && $memberName != ""'); assert('is_array($attributeLabels)'); assert('$defaultValue === null || $defaultValue !== ""'); assert('$maxLength === null || is_int($maxLength)'); assert('$precision === null || is_int($precision)'); assert('is_bool($isRequired)'); assert('is_bool($isAudited)'); assert('$mixedRule === null || is_array($mixedRule)'); $metadata = $modelClassName::getMetadata(); assert('isset($metadata[$modelClassName])'); if (!isset($metadata[$modelClassName]['members']) || !in_array($memberName, $metadata[$modelClassName]['members'])) { $memberName = self::resolveName($memberName); $metadata[$modelClassName]['members'][] = $memberName; } if (!ArrayUtil::isArrayNotUnique($metadata[$modelClassName]['members'])) { throw new NotSupportedException("Model metadata contains duplicate members"); } static::resolveAddOrRemoveNoAuditInformation($isAudited, $metadata[$modelClassName], $memberName); $metadata[$modelClassName]['elements'][$memberName] = $elementType; self::resolveAttributeLabelsMetadata($attributeLabels, $metadata, $modelClassName, $memberName); self::addOrUpdateRules($modelClassName, $memberName, $defaultValue, $maxLength, $minValue, $maxValue, $precision, $isRequired, $partialTypeRule, $metadata, $mixedRule); $modelClassName::setMetadata($metadata); }
/** * @return sorted array */ public function getAttributesForTimeTrigger() { $attributes = $this->resolveAttributesForActionsOrTimeTriggerData(true, true, true); $attributes = array_merge($attributes, $this->resolveDynamicallyDerivedAttributesForActionsOrTimeTriggerData(true, true, true)); $sortedAttributes = ArrayUtil::subValueSort($attributes, 'label', 'asort'); return $sortedAttributes; }
/** * @see Page::readParameters() */ public function readParameters() { parent::readParameters(); if (isset($_REQUEST['boardID'])) { $this->boardIDArray = ArrayUtil::toIntegerArray(explode(',', $_REQUEST['boardID'])); } }
/** * @see WCF::initTPL() */ protected function initTPL() { // init style to get template pack id $this->initStyle(); global $packageDirs; require_once WCF_DIR . 'lib/system/template/StructuredTemplate.class.php'; self::$tplObj = new StructuredTemplate(self::getStyle()->templatePackID, self::getLanguage()->getLanguageID(), ArrayUtil::appendSuffix($packageDirs, 'templates/')); $this->assignDefaultTemplateVariables(); // init cronjobs $this->initCronjobs(); // check offline mode if (OFFLINE && !self::getUser()->getPermission('user.board.canViewBoardOffline')) { $showOfflineError = true; foreach (self::$availablePagesDuringOfflineMode as $type => $names) { if (isset($_REQUEST[$type])) { foreach ($names as $name) { if ($_REQUEST[$type] == $name) { $showOfflineError = false; break 2; } } break; } } if ($showOfflineError) { self::getTPL()->display('offline'); exit; } } // user ban if (self::getUser()->banned && (!isset($_REQUEST['page']) || $_REQUEST['page'] != 'LegalNotice')) { throw new NamedUserException(WCF::getLanguage()->getDynamicVariable('wcf.user.banned')); } }
public static function arrayToReadableString(array $elements) { $buf = ''; $is_assoc = ArrayUtil::isAssoc($elements); $length = count($elements); $index = 0; foreach ($elements as $key => $element) { if (is_object($element)) { $element_as_string = self::objectToReadableString($element); } else { if (is_array($element)) { $element_as_string = self::arrayToReadableString($element); } else { $element_as_string = (string) $element; } } if ($index !== $length - 1) { $element_as_string .= ', '; } if ($is_assoc) { $buf .= "{$key} => {$element_as_string}"; } else { $buf .= $element_as_string; } $index++; } return 'Array(' . $buf . ')'; }