本文整理汇总了PHP中valid::id_key方法的典型用法代码示例。如果您正苦于以下问题:PHP valid::id_key方法的具体用法?PHP valid::id_key怎么用?PHP valid::id_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valid
的用法示例。
在下文中一共展示了valid::id_key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page
public function page($page_id = NULL)
{
valid::id_key($page_id);
ob_start();
#TODO: if any tools are protected on this page, search for a possible
# theme template and load that within the page css.
# Is page_name protected?
#$page_config_value = yaml::does_key_exist($this->site_name, 'pages_config', $page_name);
# parse custom page sass file if it exists.
$page_sass = $this->assets->themes_dir("{$this->theme}/pages/{$page_id}.sass");
if (file_exists($page_sass)) {
echo Kosass::factory('compact')->compile(file($page_sass));
}
# load custom tool css files
$db = new Database();
# get all tools that are added to this page.
$tool_data = $db->query("\n SELECT *, LOWER(system_tools.name) AS name, tools.id AS guid\n FROM pages_tools \n JOIN tools ON pages_tools.tool_id = tools.id\n JOIN system_tools ON tools.system_tool_id = system_tools.id\n WHERE (page_id BETWEEN 1 AND 5 OR page_id = '{$page_id}')\n AND pages_tools.fk_site = '{$this->site_id}'\n ORDER BY pages_tools.container, pages_tools.position\n ");
$tool_dir = $this->assets->themes_dir("{$this->theme}/tools");
foreach ($tool_data as $tool) {
# get the type and the view from the system.
# TODO: try and optimize this later.
$table = ORM::factory($tool->name)->where('fk_site', $this->site_id)->find($tool->parent_id);
$custom_file = "{$tool_dir}/{$tool->name}/{$tool->parent_id}/{$table->type}_{$table->view}.css";
if (file_exists($custom_file)) {
readfile($custom_file);
}
}
# cache the full result as the live global css file.
file_put_contents("{$this->cache_dir}/{$page_id}.css", ob_get_clean());
return TRUE;
}
示例2: get_item
public function get_item($table, $id = FALSE)
{
$id = $id ? $id : valid::id_key($this->item_id);
$item = ORM::factory($table)->where('fk_site', $this->site_id)->find($id);
if (!$item->loaded) {
die("invalid item for {$table}");
}
return $item;
}
示例3: tool
public function tool()
{
if (empty($_GET['tool_id'])) {
die('invalid tool_id');
}
$tool_id = valid::id_key($_GET['tool_id']);
$tool = ORM::factory('tool', $tool_id);
if (!$tool->loaded) {
die('invalid tool');
}
$toolname = strtolower($tool->system_tool->name);
# load the tool parent
$parent = ORM::factory($toolname, $tool->parent_id);
if (!$parent->loaded) {
die('invalid parent table');
}
# build the object.
$export = new stdClass();
$export->name = $toolname;
# export the parent table.
$parent_table = new stdClass();
foreach ($parent->table_columns as $key => $value) {
$parent_table->{$key} = $parent->{$key};
}
$export->parent_table = $parent_table;
# export any child tables.
$child_tables = new stdClass();
# loop through data from available child tables.
foreach ($parent->has_many as $table_name) {
$table_name = inflector::singular($table_name);
$child_tables->{$table_name} = array();
# get the child table model so we can iterate through the fields.
$table = ORM::factory($table_name);
# get any rows beloning to the parent.
$rows = ORM::factory($table_name)->where(array('fk_site' => $this->site_id, "{$toolname}_id" => $parent->id))->find_all();
foreach ($rows as $row) {
$object = new stdClass();
foreach ($table->table_columns as $key => $value) {
$object->{$key} = $row->{$key};
}
array_push($child_tables->{$table_name}, $object);
}
}
$export->child_tables = $child_tables;
# get the css file.
$export->css = file_get_contents($this->assets->themes_dir("{$this->theme}/tools/{$toolname}/_created/{$parent->id}/{$parent->type}_{$parent->view}.css"));
$json = json_encode($export);
echo '<h2>Copy this exactly and place into the importer=)</h2>';
echo "<textarea style='width:99%;height:400px;'>{$json}</textarea>";
die;
echo kohana::debug($export);
die;
# just testing ...
echo self::import($json);
die;
}
示例4: get_tag
private function get_tag()
{
valid::id_key($this->tag_id);
$tag = ORM::factory('tag')->where('owner_id', $this->owner->id)->find($this->tag_id);
if (!$tag->loaded) {
$this->rsp->msg = 'Tag does not exist';
$this->rsp->send();
}
return $tag;
}
示例5: save_tree
function save_tree()
{
if ($_POST) {
valid::id_key($this->pid);
$json = json_decode($_POST['json']);
if (NULL === $json or !is_array($json)) {
die('invalid json');
}
echo Tree::save_tree('navigation', 'navigation_item', $this->pid, $this->site_id, $json);
}
die;
}
示例6: get_testimonial
private function get_testimonial()
{
if (0 == $this->testimonial_id) {
$new = ORM::factory('testimonial');
$new->owner_id = $this->owner->id;
return $new;
}
valid::id_key($this->testimonial_id);
$testimonial = ORM::factory('testimonial')->where('owner_id', $this->owner->id)->find($this->testimonial_id);
if (!$testimonial->loaded) {
$this->rsp->msg = 'Testimonial does not exist';
$this->rsp->send();
}
return $testimonial;
}
示例7: add_access
public function add_access()
{
if (!isset($_POST['password']) or 'supausah' !== $_POST['password']) {
die('invalid password');
}
$user_id = valid::id_key($_POST['user_id']);
$site_id = valid::id_key($_POST['site_id']);
# Create access row for the master account (jade)
$user = ORM::factory('account_user', $user_id);
if (!$user->loaded) {
die('invalid user');
}
$user->add(ORM::factory('site', $site_id));
$user->save();
echo 'Access Granted! Remember to delete when finished';
die;
}
示例8: css
public function css($system_tool_id = NULL, $parent_id = NULL)
{
valid::id_key($system_tool_id);
valid::id_key($parent_id);
$system_tool = ORM::factory('system_tool')->select('*, LOWER(name) AS name')->find($system_tool_id);
$tool = ORM::factory($system_tool->name)->where('fk_site', $this->site_id)->find($parent_id);
# Overwrite old file with new file contents;
if ($_POST) {
#$tool->attributes = $_POST['attributes'];
#$tool->save();
if (isset($_POST['save_template'])) {
#NOT WORKING.
$contents = preg_replace("/_(\\d+)/", '_++', $_POST['contents']);
$theme_template = $this->assets->themes_dir("{$this->theme}/tools/{$system_tool->name}/{$tool->type}/{$tool->view}_template.css");
if (file_put_contents($theme_template, $contents)) {
die('Template Saved');
}
die('The was a problem saving the file.');
}
# save the css
$custom_file = $this->assets->themes_dir("{$this->theme}/tools/{$system_tool->name}/{$tool->id}/{$tool->type}_{$tool->view}.css");
if (file_put_contents($custom_file, $_POST['output'])) {
die('CSS Changes Saved.');
}
die('The was a problem saving the file.');
}
# get stock css?
#$stock = self::get_sass($system_tool->name, $tool_id, $tool->type, $tool->view, 'stock');
#echo kohana::debug($stock); die();
$theme_sass = self::get_sass($system_tool->name, $tool->id, $tool->type, $tool->view, 'theme');
# testing !
$custom_sass = self::get_css($system_tool->name, $tool->id, $tool->type, $tool->view);
# $custom_sass = self::get_sass($system_tool->name, $tool_id, $tool->type, $tool->view, 'custom');
#echo kohana::debug($custom_sass); die();
$view = new View('tool/edit_css');
$view->custom_sass = $custom_sass;
$view->tool = $tool;
$view->theme_sass = $theme_sass;
$view->name_id = $system_tool_id;
$view->toolname = $system_tool->name;
$view->js_rel_command = "update-{$system_tool->name}-{$tool->id}";
die($view);
}
示例9: delete_user
public function delete_user()
{
valid::id_key($this->item_id);
ORM::factory('account_user')->where('fk_site', $this->site_id)->delete($this->item_id);
die('User deleted');
}
示例10: settings
public function settings($tool_id = NULL)
{
die('Showroom settings are currently disabled while we update our code. Thanks!');
valid::id_key($tool_id);
}
示例11: hide
public function hide($page_id = NULL)
{
valid::id_key($page_id);
$page = ORM::factory('page')->where('fk_site', $this->site_id)->find($page_id);
$page->menu = 'no';
$page->save();
die('Page is hidden');
# success
}
示例12: settings
public function settings($tool_id = NULL)
{
valid::id_key($tool_id);
$review = ORM::factory('review')->where('fk_site', $this->site_id)->find($tool_id);
if (FALSE === $review->loaded) {
die('invalid review');
}
if ($_POST) {
$review->name = $_POST['name'];
$review->view = $_POST['view'];
#$review->params = $_POST['params'];
$review->save();
die('review Settings Saved.');
}
switch ($review->type) {
case 'people':
$type_views = array('list', 'filmstrip');
break;
case 'contacts':
$type_views = array('list');
break;
case 'faqs':
$type_views = array('simple');
break;
case 'tabs':
$type_views = array('stock');
break;
default:
$type_views = array();
break;
}
$view = new View('edit_review/settings');
$view->review = $review;
$view->type_views = $type_views;
$view->js_rel_command = "update-review-{$tool_id}";
die($view);
}
示例13: event
public function event($id = NULL)
{
die('offline');
valid::id_key($id);
$db = new Database();
$event = $db->query("\n SELECT * FROM calendar_items \n WHERE id = '{$id}' \n AND fk_site = '{$this->site_id}'\n ")->current();
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == "XMLHttpRequest") {
$primary = new View('public_calendar/small/event');
$primary->event = $event;
echo $primary;
} else {
echo 'nice formatted page';
die;
$view = new View('shell');
$primary = new View('public_calendar/small/event');
$primary->event = $event;
echo $view;
}
}
示例14: delete
public function delete()
{
valid::id_key($this->item_id);
ORM::factory('calendar_item')->where('fk_site', $this->site_id)->delete($this->item_id);
die('Calendar item deleted.');
}
示例15: delete_comment
public function delete_comment($id = NULL)
{
valid::id_key($id);
ORM::factory('blog_post_comment')->where(array('fk_site' => $this->site_id))->delete($id);
die('Comment deleted!');
#status
}