本文整理汇总了PHP中gpFiles::ArrayInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP gpFiles::ArrayInsert方法的具体用法?PHP gpFiles::ArrayInsert怎么用?PHP gpFiles::ArrayInsert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gpFiles
的用法示例。
在下文中一共展示了gpFiles::ArrayInsert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CopyLayout
/**
* Copy a layout
*
*/
function CopyLayout()
{
global $gpLayouts, $langmessage, $config, $page, $dataDir;
$copy_id =& $_REQUEST['layout'];
if (empty($copy_id) || !isset($gpLayouts[$copy_id])) {
message($langmessage['OOPS'] . '(Invalid Request)');
return;
}
if (empty($_POST['label'])) {
message($langmessage['OOPS'] . '(Empty Label)');
return;
}
$newLayout = $gpLayouts[$copy_id];
$newLayout['color'] = self::GetRandColor();
$newLayout['label'] = htmlspecialchars($_POST['label']);
//get new unique layout id
do {
$layout_id = rand(1000, 9999);
} while (isset($gpLayouts[$layout_id]));
$gpLayoutsBefore = $gpLayouts;
$gpLayouts[$layout_id] = $newLayout;
if (!gpFiles::ArrayInsert($copy_id, $layout_id, $newLayout, $gpLayouts, 1)) {
message($langmessage['OOPS'] . '(Not Inserted)');
return;
}
//copy any css
$css = $this->layoutCSS($copy_id);
if (!empty($css)) {
$path = $dataDir . '/data/_layouts/' . $layout_id . '/custom.css';
if (!gpFiles::Save($path, $css)) {
message($langmessage['OOPS'] . ' (CSS not saved)');
return false;
}
}
if (admin_tools::SavePagesPHP()) {
message($langmessage['SAVED']);
} else {
$gpLayouts = $gpLayoutsBefore;
message($langmessage['OOPS'] . '(Not Saved)');
}
}
示例2: RenamedGallery
/**
* Handle the renaming of galleries for admin_menu_tools.php
*
* @static
*
*/
function RenamedGallery($old_title, $new_title)
{
$galleries = special_galleries::GetData();
if (!isset($galleries[$old_title])) {
return;
}
if (gpFiles::ArrayInsert($old_title, $new_title, $galleries[$old_title], $galleries, 0, 1)) {
special_galleries::SaveIndex($galleries);
}
}
示例3: ArrayReplace
/**
* Replace a key-value pair in an associative array
* ArrayReplace() is a shortcut for using gpFiles::ArrayInsert() with $offset = 0 and $length = 1
*/
public static function ArrayReplace($search_key, $new_key, $new_value, &$array)
{
return gpFiles::ArrayInsert($search_key, $new_key, $new_value, $array, 0, 1);
}
示例4: NewDrag
function NewDrag()
{
global $page, $langmessage;
$page->ajaxReplace = array();
//get the title of the gallery that was moved
$dragging = $_POST['title'];
if (!isset($this->galleries[$dragging])) {
message($langmessage['OOPS'] . ' (Title not in gallery list)');
return false;
}
$info = $this->galleries[$dragging];
unset($this->galleries[$dragging]);
//set visibility
if (isset($_POST['active'])) {
$info['visibility'] = 'show';
} else {
$info['visibility'] = 'hide';
}
//place before the element represented by $_POST['next'] if it's set
if (isset($_POST['next'])) {
$next = $_POST['next'];
if (!isset($this->galleries[$next])) {
message($langmessage['OOPS'] . ' (Next not found)');
return false;
}
if (!gpFiles::ArrayInsert($next, $dragging, $info, $this->galleries)) {
message($langmessage['OOPS'] . ' (Insert Failed)');
return false;
}
//place at the end
} else {
$this->galleries[$dragging] = $info;
}
//save it
if (!special_galleries::SaveIndex($this->galleries)) {
message($langmessage['OOPS'] . ' (Not Saved)');
return false;
}
}