本文整理汇总了PHP中model_cache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP model_cache::get方法的具体用法?PHP model_cache::get怎么用?PHP model_cache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model_cache
的用法示例。
在下文中一共展示了model_cache::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: activate
static function activate() {
// Update the root item. This is a quick hack because the search module is activated as part
// of the official install, so this way we don't start off with a "your index is out of date"
// banner.
search::update(model_cache::get("item", 1));
search::check_index();
}
示例2: lookup_by_name
/**
* Look up a group by name.
* @param integer $id the group name
* @return Group_Model the group object, or null if the name was invalid.
*/
static function lookup_by_name($name)
{
$group = model_cache::get("group", $name, "name");
if ($group->loaded) {
return $group;
}
return null;
}
示例3: unstar
/**
* Allows the given item to be displayed again.
*
* @param int $id the item id
*/
public function unstar($id)
{
$item = model_cache::get("item", $id);
$msg = t("Un-starred <b>%title</b> item", array("title" => html::purify($item->title)));
$this->_check_star_permissions($item);
star::unstar($item);
message::success($msg);
json::reply(array("result" => "success", "reload" => 1));
}
示例4: show
/**
* Allows the given item to be displayed again.
*
* @param int $id the item id
*/
public function show($id)
{
$item = model_cache::get("item", $id);
$msg = t("Displayed <b>%title</b> item", array("title" => html::purify($item->title)));
$this->_check_hide_permissions($item);
hide::show($item);
message::success($msg);
json::reply(array("result" => "success", "reload" => 1));
}
示例5: get_hidden_item_model
/**
* Returns the hidden_item model related to the given item.
*
* There is an attempt to fetch the model from the database through the model
* cache. If it fails, a new unsaved model is created.
*
* @param Item_Model $item the item
* @return Hidden_Item_Model the related hidden_item model
*/
static function get_hidden_item_model(Item_Model $item)
{
try {
$model = model_cache::get("item", $id);
} catch (Exception $e) {
$model = ORM::factory("hidden_item");
$model->item_id = $item->id;
$model->validate();
}
return $model;
}
示例6: _lookup_by_field
/**
* Search the groups by the field and value.
* @param string $field_name column to look up the user by
* @param string $value value to match
* @return Group_Definition the group object, or null if the name was invalid.
*/
private static function _lookup_by_field($field_name, $value)
{
try {
$user = model_cache::get("group", $value, $field_name);
if ($user->loaded()) {
return $user;
}
} catch (Exception $e) {
if (strpos($e->getMessage(), "MISSING_MODEL") === false) {
throw $e;
}
}
return null;
}
示例7: site
static function site($uri, $protocol = false)
{
if (($pos = strpos($uri, "?")) !== false) {
list($uri, $query) = explode("?", $uri, 2);
$query = "?{$query}";
} else {
$query = "";
}
$parts = explode("/", $uri, 3);
if ($parts[0] == "albums" || $parts[0] == "photos") {
$uri = model_cache::get("item", $parts[1])->relative_path();
}
return parent::site($uri . $query, $protocol);
}
示例8: restore
public function restore($id)
{
// Allow the user to restore the original photo.
// Make sure the current user has suficient access to view and edit the item.
$item = ORM::factory("item", $id);
access::required("view", $item);
access::required("edit", $item);
// Figure out where the original was stashed at.
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path());
// Make sure the current item is a photo and that an original exists.
if ($item->is_photo() && file_exists($original_image)) {
// Delete the modified version of the photo.
@unlink($item->file_path());
// Copy the original image back over, display an error message if the copy fails.
if (@rename($original_image, $item->file_path())) {
// Re-generate the items resize and thumbnail.
$item_data = model_cache::get("item", $id);
$item_data->resize_dirty = 1;
$item_data->thumb_dirty = 1;
$item_data->save();
graphics::generate($item_data);
// If the item is the thumbnail for the parent album,
// fix the parent's thumbnail as well.
$parent = $item_data->parent();
if ($parent->album_cover_item_id == $item_data->id) {
copy($item_data->thumb_path(), $parent->thumb_path());
$parent->thumb_width = $item_data->thumb_width;
$parent->thumb_height = $item_data->thumb_height;
$parent->save();
}
// Display a success message and redirect to the items page.
message::success(t("Your original image has been restored."));
url::redirect($item->url());
} else {
// Display an error message if the copy failed.
message::error(t("Image restore failed!"));
url::redirect($item->url());
}
} else {
// Display an error message if there is not an original photo.
message::error(t("Image restore failed!"));
url::redirect($item->url());
}
}
示例9: rotate
public function rotate($id, $dir)
{
access::verify_csrf();
$item = model_cache::get("item", $id);
access::required("view", $item);
access::required("edit", $item);
$item = $this->p_rotate($item, $dir);
json::reply(self::child_json_encode($item));
}
示例10: get
/**
* Load the corresponding Module_Model
* @param string $module_name
*/
static function get($module_name)
{
return model_cache::get("module", $module_name, "name");
}
示例11: form_edit
public function form_edit($id)
{
$item = model_cache::get("item", $id);
access::required("view", $item);
access::required("edit", $item);
if ($item->is_album()) {
$form = album::get_edit_form($item);
} else {
$form = photo::get_edit_form($item);
}
print $form;
}
示例12: _set
/**
* Internal method to set a permission
*
* @param Group_Model $group
* @param string $perm_name
* @param Item_Model $item
* @param boolean $value
*/
private static function _set(Group_Model $group, $perm_name, $album, $value)
{
if (get_class($group) != "Group_Model") {
throw new Exception("@todo PERMISSIONS_ONLY_WORK_ON_GROUPS");
}
if (!$album->loaded) {
throw new Exception("@todo INVALID_ALBUM {$album->id}");
}
if (!$album->is_album()) {
throw new Exception("@todo INVALID_ALBUM_TYPE not an album");
}
$access = model_cache::get("access_intent", $album->id, "item_id");
$access->__set("{$perm_name}_{$group->id}", $value);
$access->save();
if ($perm_name == "view") {
self::_update_access_view_cache($group, $album);
} else {
self::_update_access_non_view_cache($group, $perm_name, $album);
}
self::_update_htaccess_files($album, $group, $perm_name, $value);
model_cache::clear();
}
示例13: form_edit
public function form_edit($id)
{
$item = model_cache::get("item", $id);
access::required("view", $item);
access::required("edit", $item);
switch ($item->type) {
case "album":
return print album::get_edit_form($item);
case "photo":
return print photo::get_edit_form($item);
case "movie":
return print movie::get_edit_form($item);
}
}
示例14: parent
/**
* Return the parent of this node
*
* @return ORM
*/
function parent()
{
if (!$this->parent_id) {
return null;
}
return model_cache::get($this->model_name, $this->parent_id);
}
示例15: root
/**
* Return the root Item_Model
* @return Item_Model
*/
static function root()
{
return model_cache::get("item", 1);
}