本文整理汇总了PHP中data_entry_helper::explode_lines方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::explode_lines方法的具体用法?PHP data_entry_helper::explode_lines怎么用?PHP data_entry_helper::explode_lines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::explode_lines方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_perms
/**
* Declare the list of permissions we've got set up to pass to the CMS' permissions code.
* @param int $nid Node ID, not used
* @param array $args Form parameters array, used to extract the defined permissions.
* @return array List of distinct permissions.
*/
public static function get_perms($nid, $args)
{
$perms = array();
if (!empty($args['structure'])) {
// scan for @permission=... in the form structure
$structure = data_entry_helper::explode_lines($args['structure']);
$permissions = preg_grep('/^@((smp|occ|loc)Attr:\\d+|)?permission=/', $structure);
foreach ($permissions as $permission) {
$parts = explode('=', $permission, 2);
$perms[] = array_pop($parts);
}
}
return $perms;
}
示例2: get_perms
/**
* Declare the list of permissions we've got set up to pass to the CMS' permissions code.
* @param int $nid Node ID, not used
* @param array $args Form parameters array, used to extract the defined permissions.
* @return array List of distinct permissions.
*/
public static function get_perms($nid, $args)
{
$perms = array('biotope codes');
if (!empty($args['edit_permission'])) {
$perms[] = $args['edit_permission'];
}
if (!empty($args['ro_permission'])) {
$perms[] = $args['ro_permission'];
}
// scan for @permission=... in the form structure
// @todo Refactor this into dynamic.php so that all types of dynamic form benefit
$structure = data_entry_helper::explode_lines($args['structure']);
$permissions = preg_grep('/^@((smp|occ|loc)Attr:\\d+|)?permission=/', $structure);
foreach ($permissions as $permission) {
$parts = explode('=', $permission, 2);
$perms[] = array_pop($parts);
}
return $perms;
}
示例3: simple_user_square_upload
public static function simple_user_square_upload($auth, $args, $tabalias, $options, $path)
{
if (empty($options['minimumLocationDate'])) {
drupal_set_message('Please enter a @minimumLocationDate option to specify minimum square created_on date to look for');
return false;
}
$minSquareDate = new DateTime($options['minimumLocationDate']);
$r = '';
//Need to call this so we can use indiciaData.read
data_entry_helper::$js_read_tokens = $auth['read'];
if (!function_exists('iform_ajaxproxy_url')) {
return 'An AJAX Proxy module must be enabled for user sites administration to work.';
}
$r .= '<div><form method="post"><textarea id="upload-data" name="upload-data" cols="20" rows="50"></textarea>';
$r .= '<input type="submit" id="upload-squares" value="Upload"></form></div><br>';
$postUrl = iform_ajaxproxy_url(null, 'person_attribute_value');
//If there is data to upload then get the lines of data
if (!empty($_POST['upload-data'])) {
$uploadLines = data_entry_helper::explode_lines($_POST['upload-data']);
}
$convertedUploadData = array();
$convertedUploadIdx = 0;
if (!empty($uploadLines)) {
//Get existing data to detect duplicates
$existingPersonAttrVals = data_entry_helper::get_population_data(array('table' => 'person_attribute_value', 'extraParams' => $auth['read'] + array(), 'nocache' => true));
//Cycle through all the lines in the upload data
foreach ($uploadLines as $lineIdx => $uploadLine) {
//Split each line up into cells, cell 2 (index 1) onwards contain all the squares we are going to attach to people.
$lineParts = explode(",", $uploadLine);
$email = $lineParts[0];
//Get the id of the person to attach squares to
$personData = data_entry_helper::get_population_data(array('table' => 'person', 'extraParams' => $auth['read'] + array('email_address' => $email, 'view' => 'detail'), 'nocache' => true));
if (empty($personData[0]['id'])) {
$personData = data_entry_helper::get_report_data(array('dataSource' => 'reports_for_prebuilt_forms/Splash/get_person_for_email_address', 'readAuth' => $auth['read'], 'extraParams' => array('email_address' => $email)));
}
//Cycle through all the squares we want to attach to a person.
for ($idx2 = 1; $idx2 < count($lineParts); $idx2++) {
if (!empty($lineParts[$idx2])) {
//Get the name of the square to attach and then its id.
$location = $lineParts[$idx2];
$locationData = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $auth['read'] + array('name' => $location, 'view' => 'detail'), 'nocache' => true));
//Save the data ready to import.
if (!empty($personData[0]['id']) && !empty($locationData[0]['id'])) {
$locationCreatedOnDate = new DateTime($locationData[0]['created_on']);
//Only attach squares if they are newer than the specified minimum created_on option
if ($locationCreatedOnDate >= $minSquareDate) {
$convertedUploadData[$convertedUploadIdx][0] = $personData[0]['id'];
$convertedUploadData[$convertedUploadIdx][1] = $locationData[0]['id'];
$convertedUploadIdx++;
}
} else {
drupal_set_message('An upload issue has been detected.');
if (empty($personData[0]['id'])) {
drupal_set_message('Could not upload to person. The following email address was not found ' . $email);
}
if (empty($locationData[0]['id'])) {
drupal_set_message('Could not upload square. The following location was not found ' . $location);
}
}
}
}
}
data_entry_helper::$javascript .= "\n var i;\n var i2;\n var uploadLines = " . json_encode($convertedUploadData) . ";\n var existingPersonAttrVals = " . json_encode($existingPersonAttrVals) . ";\n var duplicateDetected = false;\n for (i=0; i<uploadLines.length; i++) {\n for (i2=0; i2<existingPersonAttrVals .length; i2++) {\n if (uploadLines[i][1]==existingPersonAttrVals[i2]['value']&&uploadLines[i][0]==existingPersonAttrVals[i2]['person_id']) {\n duplicateDetected=true;\n }\n }\n if (duplicateDetected==false) {\n \$.post('{$postUrl}', \n {\"website_id\":" . $args['website_id'] . ",\"person_attribute_id\":" . $options['mySitesPsnAttrId'] . ",\"person_id\":uploadLines[i][0],\"int_value\":uploadLines[i][1]},\n function (data) {\n if (typeof data.error !== 'undefined') {\n alert(data.error);\n } \n },\n 'json'\n );\n var emptyObj={};\n emptyObj.value=uploadLines[i][1];\n emptyObj.person_id=uploadLines[i][0];\n\n existingPersonAttrVals.push(emptyObj);\n } else {\n alert('A duplicate entry upload has been attempted for person id ' + uploadLines[i][0] + ' location id ' + uploadLines[i][1]); \n }\n duplicateDetected=false;\n }\n alert('Import Complete');";
}
return $r;
}
示例4: get_form
/**
* Return the generated form output.
* @param array $args List of parameter values passed through to the form depending on how the form has been configured.
* This array always contains a value for language.
* @param object $node The Drupal node object.
* @param array $response When this form is reloading after saving a submission, contains the response from the service call.
* Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
* @return Form HTML.
* @todo: Implement this method
*/
public static function get_form($args, $node, $response = null)
{
if (empty($args['group_id'])) {
drupal_set_message('Please specify a group_id in the page configuration.');
}
if (empty($args['instructions_configuration'])) {
drupal_set_message('Please provide a page configuration in the User Interface options.');
}
//Only perform if the user has specified an instruction to appear under each page like.
if (!empty($args['instructions_configuration'])) {
$configuration = data_entry_helper::explode_lines($args['instructions_configuration']);
$key = '';
$description = '';
//Keep track of the ordering of the titles
$titleNumber = 0;
//For each configured line we need to find all the descriptions and store them against the page titles in an array
foreach ($configuration as $configLineNum => $configurationLine) {
//If line is a link title (specified inside square brackets)
if (preg_match('/^\\[.+\\]$/', $configurationLine)) {
//If this isn't the first title, then we need to store the description for the previous title into an
//array. The key is a number representing the order of the titles in the configuration, the sub array key is the name of the page link.
if (!empty($key)) {
$titleDescriptions[$titleNumber] = array($key => $description);
$description = '';
}
//Get the next array key we will use from the specified page link title. Chop the square brackets off the ends.
$key = substr($configurationLine, 1, -1);
$titleNumber++;
} else {
//If the line does not use square brackets then we know it is part of the description/instruction. We do an
//append as the instruction might span several lines.
$description .= $configurationLine;
}
}
//For the last description we still need to save it to the array.
$titleDescriptions[$titleNumber] = array($key => $description);
$description = '';
}
$r = '';
global $user;
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
//Get all the links to display
$reportOptions = array('dataSource' => 'library/groups/groups_list', 'readAuth' => $auth['read'], 'mode' => 'report', 'extraParams' => array('currentUser' => hostsite_get_user_field('indicia_user_id'), 'id' => $args['group_id'], 'pending_path' => '{rootFolder}?q=groups/pending&group_id=', 'userFilterMode' => 'member'));
// automatic handling for Drupal clean urls.
$pathParam = function_exists('variable_get') && variable_get('clean_url', 0) == '0' ? 'q' : '';
$rootFolder = helper_base::getRootFolder() . (empty($pathParam) ? '' : "?{$pathParam}=");
$groupsData = data_entry_helper::get_report_data($reportOptions);
if (empty($groupsData)) {
if (!empty($args['no_group_found_message'])) {
$r = '<div>' . $args['no_group_found_message'] . '</div>';
} else {
$r = '<div>' . 'Sorry, you do not appear to be a member of this group so there are no links to display.' . '</div>';
}
return $r;
}
foreach ($groupsData as $groupDataItem) {
$pageLinks = $groupDataItem['pages'];
$groupTitle = $groupDataItem['title'];
}
//All the page links come out of the database in one cluster. Explode these so we have each link separately
$explodedPageLinks = explode('</a>', $pageLinks);
// reinsert the closing </a> used in the explode above
foreach ($explodedPageLinks as &$pageLink) {
$pageLink .= '</a>';
}
$pageLinkHtml = '';
//Go through all the page links to display
foreach ($titleDescriptions as $titleDescArr) {
foreach ($explodedPageLinks as &$pageLink) {
//Each page link is a html link, we just want the plain name
$plainPageLink = trim(strip_tags($pageLink));
//If the user has specified an instruction/description for the page link, then display the instruction in the lines following the link
//using italics.
if (array_key_exists($plainPageLink, $titleDescArr)) {
if (!empty($titleDescArr[$plainPageLink])) {
$pageLinkHtml .= "<h3>{$pageLink}</a></h3><p>{$titleDescArr[$plainPageLink]}</p>\n";
} else {
$pageLinkHtml .= "<h3>{$pageLink}</a></h3>";
}
}
}
}
$r = "<div><h2>{$groupTitle} Links</h2>";
$r .= str_replace(array('{rootFolder}', '{sep}'), array($rootFolder, strpos($rootFolder, '?') === FALSE ? '?' : '&'), $pageLinkHtml);
$r .= '</div><br>';
$r .= parent::get_form($args, $node, $response = null);
return $r;
}