Example #1
0
 function Init($name = '', $settings = '')
 {
     $this->SetDefaultSettings();
     $this->contents = array();
     $params = unserialize_params($settings);
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
 }
Example #2
0
 function Init($name, $tags = array(), $settings = '')
 {
     $params = unserialize_params($settings);
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
     $this->tags = $tags;
     $this->name = $name;
 }
Example #3
0
 function Init($name = '', $settings = '')
 {
     $params = unserialize_params($settings);
     $this->settings['name'] = $name;
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
     if ($this->settings['urlprefix'] == '') {
         $this->settings['urlprefix'] = content_url_get_full();
     }
     $s = $this->settings['urlprefix'];
     if (preg_match('/\\?/', $s)) {
         if (!preg_match('/\\?$/', $s)) {
             $s .= '&';
         }
     } else {
         $s .= '?';
     }
     $this->settings['urlprefix'] = $s;
     if ($this->settings['pageid'] == '') {
         $this->settings['pageid'] = 'page';
     }
     $this->topStencil = $this->bottomStencil = $this->defaultStencil;
     if ($this->settings['perpage'] == '') {
         $this->settings['perpage'] = 1;
     }
 }
Example #4
0
 function Init($name = '', $settings = '')
 {
     $params = unserialize_params($settings);
     $this->settings['name'] = $name;
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
     if ($this->settings['caption'] == '') {
         $this->settings['caption'] = 'Сохранить';
     } else {
         $this->settings['caption'] = htmlspecialchars($this->settings['caption']);
     }
 }
Example #5
0
 function Init($v = '')
 {
     $this->vars = array();
     $this->SetDefaultSettings();
     $this->metas = array();
     $this->CSStyles = array();
     $this->content = new CVCContent();
     $params = unserialize_params($v);
     $this->topmenu = new CVCMenu();
     $this->topmenu->Init('PageTopMenu', 'type=hor;transparent=1;align=right;small=1;');
     $this->settings['favicon'] = '';
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
 }
}
echo lookInArray('Tina', $names) . PHP_EOL;
echo lookInArray('Bob', $names) . PHP_EOL;
function compareArray($newArray, $controlArray)
{
    $match = 0;
    $diff = 0;
    foreach ($newArray as $singleElement) {
        if (lookInArray($singleElement, $controlArray)) {
            $match = $match + 1;
        } else {
            $diff = $diff + 1;
        }
    }
    return "These arrays have {$match} values in common and {$diff} that didn't match between the two arrays" . PHP_EOL;
}
echo compareArray($compare, $names) . PHP_EOL;
function combine_arrays($newArray, $controlArray)
{
    $thirdArray = [];
    for ($i = 0; $i < count($newArray); $i++) {
        if ($newArray[$i] == $controlArray[$i]) {
            array_push($thirdArray, $newArray[$i]);
        } else {
            array_push($thirdArray, $newArray[$i], $controlArray[$i]);
        }
    }
    print_r($thirdArray);
}
echo combine_arrays($names, $compare) . PHP_EOL;
        foreach ($sameArray as $index) {
            if ($index == $key) {
                continue 2;
            }
        }
        array_push($newArray, $items);
    }
    return $newArray;
}
function search($array, $value)
{
    $result = array_search($value, $array);
    if (is_integer($result)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
function compare($array1, $array2)
{
    $newArray = array();
    foreach ($array1 as $item) {
        $result = array_search($item, $array2);
        if (is_integer($result)) {
            array_unshift($newArray, $result);
        }
    }
    return $newArray;
}
$test = combine_arrays($names, $compare);
var_dump($test);
Example #8
0
     }
     $addviews['view_' . $v] = true;
 }
 if (!empty($addviews)) {
     $collection->add_views($addviews);
     // New view permissions
     $collectiondifferent = false;
     $different = false;
     $differentarray = array();
     if (!empty($firstviewaccess) && empty($viewaccess)) {
         // adding the collection access rules to the added pages
         $different = true;
         $differentarray[] = $newviewid;
     } else {
         if (!empty($firstviewaccess)) {
             $merged = combine_arrays($firstviewaccess, $viewaccess);
             if ($merged != $firstviewaccess) {
                 // adding the new access rules to both collection and added pages
                 $different = true;
                 $collectiondifferent = true;
                 $differentarray[] = $newviewid;
             } else {
                 if ($merged != $viewaccess) {
                     // adding the collection access rules to the added pages
                     $different = true;
                     $differentarray[] = $newviewid;
                 }
             }
         } else {
             if (empty($firstviewaccess) && !empty($viewaccess)) {
                 // adding the page's access rules to the collection pages
Example #9
0
function addviews_submit(Pieform $form, $values)
{
    global $SESSION, $collection;
    // Check if the existing view permissions are different from the views being added
    $viewids = get_column('collection_view', 'view', 'collection', $collection->get('id'));
    $firstviewaccess = array();
    if (count($viewids)) {
        $firstview = new View($viewids[0]);
        $firstviewaccess = $firstview->get_access();
    }
    $chosen = array();
    foreach ($values as $key => $value) {
        if (substr($key, 0, 5) === 'view_' and $value == true) {
            $chosen[] = substr($key, 5);
        }
    }
    // New view permissions
    $collectiondifferent = false;
    $different = false;
    $differentarray = array();
    foreach ($chosen as $viewid) {
        $view = new View($viewid);
        $viewaccess = $view->get_access();
        if (!empty($firstviewaccess) && empty($viewaccess)) {
            // adding the collection access rules to the added pages
            $different = true;
            $differentarray[] = $viewid;
        } else {
            if (!empty($firstviewaccess)) {
                $merged = combine_arrays($firstviewaccess, $viewaccess);
                if ($merged != $firstviewaccess) {
                    // adding the new access rules to both collection and added pages
                    $different = true;
                    $collectiondifferent = true;
                    $differentarray[] = $viewid;
                } else {
                    if ($merged != $viewaccess) {
                        // adding collection access rules to the added pages
                        $different = true;
                        $differentarray[] = $viewid;
                    }
                }
            } else {
                if (empty($firstviewaccess) && !empty($viewaccess)) {
                    // adding the page's access rules to the collection pages
                    $different = true;
                    $collectiondifferent = true;
                }
            }
        }
    }
    $count = $collection->add_views($values);
    if ($collectiondifferent) {
        $differentarray = array_merge($differentarray, $viewids);
    }
    if ($different) {
        $SESSION->set('pageaccesschanged', $differentarray);
        $SESSION->set('pagesadded', $count);
    } else {
        $SESSION->add_ok_msg(get_string('viewsaddedtocollection1', 'collection', $count));
    }
    redirect('/collection/views.php?id=' . $collection->get('id'));
}
Example #10
0
 function Init($name = '', $settings = '')
 {
     $params = unserialize_params($settings);
     $this->settings['name'] = $name;
     $this->SetSettings(combine_arrays($this->GetSettings(), $params));
 }
Example #11
0
 function ReceiveContentSettings($title, $field)
 {
     $st = $_POST['cntset_' . $field . '_storage'];
     if (!manage_stroage_exists($st)) {
         add_info('Не указано хранилище данных для поля &laquo;' . $title . '&raquo;');
         return false;
     }
     $res = array();
     $res['storage'] = $st;
     if (!$this->UpdateLimitSetting(&$res, $title, $field, 'size', 'file_size')) {
         return false;
     }
     $this->settings['data'] = $res;
     $this->settings = combine_arrays($this->settings, $res);
     return true;
 }
Example #12
0
        }
    }
    if ($varverb == true) {
        return "SUCCESS: DELETED " . $rows . " RECORDS.";
    } else {
        return "SUCCESS: " . $rows;
    }
}
######################################################################
# ACTIONS
#
# This section parses the "action" parameter and decides what to do.
######################################################################
switch ($action) {
    case 'put':
        echo update_data($dbtable, $key, combine_arrays($fields, $values), $verbose);
        break;
    case 'get':
        if ($reverse == true) {
            echo retrieve_fields($dbtable, $key, $values, $verbose, $separator);
        } else {
            echo retrieve_values($dbtable, $key, $fields, $verbose, $separator);
        }
        break;
    case 'del':
        if ($reverse == true) {
            echo delete_fields($dbtable, $key, $values, $verbose);
        } else {
            echo delete_values($dbtable, $key, $fields, $verbose);
        }
        break;
Example #13
0
<?php

function combine_arrays($first, $second)
{
    $new = array();
    $newer = array($first[0], $first[1], $second[0], $second[1]);
    for ($a = 0; $a < 2; $a++) {
        $new[] = $first[$a];
    }
    for ($b = 0; $b < 2; $b++) {
        $new[] = $second[$b];
    }
    echo "(" . $new[0] . ", " . $new[1] . ", " . $new[2] . ", " . $new[3] . ")" . "<br>";
    return $newer;
}
print_r(combine_arrays(array(0, 1), array(2, 3)));
//COPY: cp source destination
// to put it in current directory, use a dot
//To refer to the directory it is in, use ~/Location/Location
//Git add: git add FOLLOWED BY a file name where the change happened
//Commit: git commit -m "A comment on it, like 'Added 2 new files'"
//To close an issue, in the commit comment add (closes #number of issue)
//New Comment!
?>


            $matches++;
            echo $value . " ";
        }
    }
    echo "  there are " . $matches . PHP_EOL;
}
//echo compareAnArray($haystacks,$compare);
function getUniqueValues($array1, $array2)
{
    return array_values(array_unique(array_merge($array1, $array2)));
}
print_r(getUniqueValues($haystacks, $compare));
function combine_arrays($array1, $array2)
{
    $combined = [];
    foreach ($array1 as $key => $value) {
        if ($array1[0] == $array2[0]) {
            $temp = array_shift($array1);
            array_shift($array2);
            array_push($combined, $temp);
        } else {
            $temp2 = array_shift($array2);
            $temp3 = array_shift($array1);
            array_push($combined, $temp3);
            array_push($combined, $temp2);
        }
    }
    return $combined;
}
$combined = combine_arrays($haystacks, $compare);
print_r($combined);
Example #15
0
<?php

// Write a function called combine_arrays() that will take in two array values and return a new array with values from both.
// If the arrays have the same value at the same index, then it should only be added once.
// If the values differ, then the value from the first array should be added and then the second.
// The function should use a combination of array_shift() & array_push() or array_pop() & array_unshift().
// Test your combine_arrays() function with $names and $compare. The resulting array should look like:
$names = ['Tina', 'Dana', 'Mike', 'Amy', 'Adam', 'Ben'];
$compare = ['Tina', 'Dean', 'Mel', 'Amy', 'Mike', 'Ben'];
$empty1 = [];
$empty2 = [];
$ev = ['Tina', 'Dana', 'Dean', 'Mike', 'Mel', 'Amy', 'Adam', 'Michael'];
function combine_arrays($arr1, $arr2)
{
    $array = [];
    foreach ($names as $value) {
        $value2 = array_shift($compare);
        $array[] = $value;
        if ($value != $value2) {
            $array[] = $value2;
        }
    }
    return $array;
}
var_dump(combine_arrays($names, $compare));
var_dump(combine_arrays($empty1, $empty2));
Example #16
0
 function iframe_reaccept_images($old, $new)
 {
     $old_images = iframe_get_images($old);
     $new_images = iframe_get_images($new);
     $old_files = iframe_get_files($old);
     $new_files = iframe_get_files($new);
     $old = combine_arrays($old_images, $old_files);
     $new = combine_arrays($new_images, $new_files);
     $arr = array();
     for ($i = 0, $n = count($old); $i < $n; $i++) {
         $found = false;
         for ($j = 0, $m = count($new); $j < $m; $j++) {
             if ($old[$i] == $new[$j]) {
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $arr[] = $old[$i];
         }
     }
     for ($i = 0, $n = count($arr); $i < $n; $i++) {
         $storage = manage_storage_by_dir(dirname($arr[$i]));
         if ($storage) {
             $storage->UnlinkFile(basename($arr[$i]));
         }
     }
 }
        if (stristr($filename, ".js")) {
            ?>
		<script src="<?php 
            echo $path . $filename;
            ?>
"></script>	
	<?php 
        }
    }
    // endif
}
// endforeach
?>

	<!-- Load stylesheets -->
	<?php 
foreach (combine_arrays(array($site_def_styles["global"], ($var = $site_def_styles[$page_controller]) != false ? $var : null)) as $filename) {
    $path = $site_def_styles["path"];
    $style_id = basename($filename);
    ?>
		<style id="<?php 
    echo $style_id;
    ?>
"><?php 
    include $path . $filename;
    ?>
</style>
	<?php 
}
?>
</head>
 public function testCombineArrays()
 {
     $a = array(1);
     $b = array(2);
     $this->assertEquals(combine_arrays(), array());
     $this->assertEquals(combine_arrays($a), $a);
     $this->assertEquals(combine_arrays($a, $b), array(1, 2));
 }
        return "TRUE" . PHP_EOL;
    } else {
        return "FALSE" . PHP_EOL;
    }
}
function compareArray($names, $compare)
{
    $match = 0;
    foreach ($names as $name) {
        if (array_search($name, $compare) !== false) {
            $match++;
        }
    }
    return $match;
}
function combine_arrays($names, $compare)
{
    $newArray = [];
    foreach ($names as $index => $name) {
        if (array_search($name, $compare) !== false) {
            array_push($newArray, $name);
        } else {
            array_push($newArray, $name, $compare[$index]);
        }
    }
    return $newArray;
}
print_r(combine_arrays($names, $compare));
echo searchArray('Dana', $names) . PHP_EOL;
echo searchArray($query, $names) . PHP_EOL;
echo compareArray($names, $compare) . PHP_EOL;
        if (in_array($data, $compare)) {
            $similarities++;
        }
    }
    echo "There are " . $similarities . " similarities between the arrays\n";
}
function combine_arrays($names, $compare)
{
    $newarray = [];
    for ($i = 0; $i < count($names) || $i < count($compare); $i++) {
        if (!empty($names[$i]) && !empty($compare[$i])) {
            array_push($newarray, $names[$i], $compare[$i]);
            if (in_array($names[$i], $compare)) {
                array_pop($newarray);
            }
        } else {
            if (!empty($names[$i]) && empty($compare[$i])) {
                array_push($newarray, $names[$i]);
            } else {
                if (empty($names[$i]) && !empty($compare[$i])) {
                    array_push($newarray, $compare[$i]);
                }
            }
        }
    }
    print_r($newarray);
}
echo isitthere($names);
echo comparison($names, $compare);
echo combine_arrays($names, $compare);