Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F390571
module_page.inc.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
module_page.inc.php
View Options
<?php
/**
* module_page.inc.php
* Module for managing pages
*
* Copyright Gottfried Haider, Danja Vasiliev 2010.
* This source code is licensed under the GNU General Public License.
* See the file COPYING for more details.
*/
@
require_once
(
'config.inc.php'
);
require_once
(
'common.inc.php'
);
require_once
(
'html.inc.php'
);
require_once
(
'util.inc.php'
);
// module_image.inc.php has more information on what's going on inside modules
// (they can be easier than that one though)
/**
* get the current grid size
*
* @param array $args arguments
* @return array response
* 'x', 'y' the grid size
*/
function
page_get_grid
(
$args
)
{
if
((
$s
=
@
file_get_contents
(
CONTENT_DIR
.
'/grid'
))
!==
false
)
{
$a
=
expl
(
' '
,
$s
);
return
response
(
array
(
'x'
=>
intval
(
$a
[
0
]),
'y'
=>
intval
(
$a
[
1
])));
}
else
{
return
response
(
array
(
'x'
=>
PAGE_DEFAULT_GRID_X
,
'y'
=>
PAGE_DEFAULT_GRID_Y
));
}
}
register_service
(
'page.get_grid'
,
'page_get_grid'
);
function
page_render_object
(
$args
)
{
$obj
=
$args
[
'obj'
];
$a
=
expl
(
'.'
,
$obj
[
'name'
]);
if
(
$a
[
2
]
!=
'page'
)
{
return
false
;
}
if
(
isset
(
$obj
[
'page-background-color'
]))
{
html_css
(
'background-color'
,
$obj
[
'page-background-color'
]);
}
// set the html title
if
(
isset
(
$obj
[
'page-title'
]))
{
html_title
(
$obj
[
'page-title'
]);
}
}
function
page_render_page_early
(
$args
)
{
if
(
$args
[
'edit'
])
{
html_add_js
(
base_url
().
'modules/page/page-edit.js'
);
// set default grid
$grid
=
page_get_grid
(
array
());
$grid
=
$grid
[
'#data'
];
html_add_js_var
(
'$.glue.conf.page.default_grid_x'
,
$grid
[
'x'
]);
html_add_js_var
(
'$.glue.conf.page.default_grid_y'
,
$grid
[
'y'
]);
// set guides
$guide
=
expl
(
' '
,
PAGE_GUIDES_X
);
for
(
$i
=
0
;
$i
<
count
(
$guide
);
$i
++)
{
$guide
[
$i
]
=
intval
(
trim
(
$guide
[
$i
]));
}
html_add_js_var
(
'$.glue.conf.page.guides_x'
,
$guide
);
$guide
=
expl
(
' '
,
PAGE_GUIDES_Y
);
for
(
$i
=
0
;
$i
<
count
(
$guide
);
$i
++)
{
$guide
[
$i
]
=
intval
(
trim
(
$guide
[
$i
]));
}
html_add_js_var
(
'$.glue.conf.page.guides_y'
,
$guide
);
}
// set the html title to the page name by default
html_title
(
page_short
(
$args
[
'page'
]));
}
/**
* get the current grid size
*
* @param array $args arguments
* key 'x', 'y' is the grid size
* @return array response
* true if successful
*/
function
page_set_grid
(
$args
)
{
if
((
$x
=
@
intval
(
$args
[
'x'
]))
==
0
)
{
return
response
(
'Required argument "x" missing or invalid'
,
400
);
}
if
((
$y
=
@
intval
(
$args
[
'y'
]))
==
0
)
{
return
response
(
'Required argument "y" missing or invalid'
,
400
);
}
$m
=
umask
(
0111
);
if
(!@
file_put_contents
(
CONTENT_DIR
.
'/grid'
,
$x
.
' '
.
$y
))
{
umask
(
$m
);
return
response
(
'Error saving to global grid file'
,
500
);
}
else
{
umask
(
$m
);
return
response
(
true
);
}
}
register_service
(
'page.set_grid'
,
'page_set_grid'
,
array
(
'auth'
=>
true
));
?>
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Feb 22, 15:27 (15 h, 40 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
21970
Default Alt Text
module_page.inc.php (2 KB)
Attached To
rZED Zed
Event Timeline
Log In to Comment