本文整理汇总了PHP中ClassRegistry::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassRegistry::getObject方法的具体用法?PHP ClassRegistry::getObject怎么用?PHP ClassRegistry::getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassRegistry
的用法示例。
在下文中一共展示了ClassRegistry::getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sort
/**
* Generates a sorting link with an automatically translated name taken from field_names.po
* Also force it to be page 1 of the results
*
* @param mixed $title
* @param mixed $key null
* @param array $options array()
* @return void
* @access public
*/
public function sort($title, $key = null, $options = array())
{
if (!$key) {
$key = $title;
if (strpos($title, '.')) {
$title = str_replace('.', ' ', $title);
} else {
$view = ClassRegistry::getObject('view');
if (isset($view->viewVars['modelClass'])) {
$alias = $view->viewVars['modelClass'];
} else {
$alias = $view->association ? $view->association : $view->model;
}
$title = $alias . ' ' . $title;
}
if (substr($title, -3) == '_id') {
$title = substr($title, 0, strlen($title) - 3);
}
$title = Inflector::humanize(Inflector::underscore($title));
if (!empty($this->params['plugin'])) {
$pluginDomain = Inflector::underscore($this->params['plugin']) . '_';
} else {
$pluginDomain = '';
}
$_title = $title;
$title = __d($pluginDomain . 'field_names', $title, true);
if ($title === $_title && !empty($alias)) {
$alias = Inflector::humanize(Inflector::underscore($alias));
$title = str_replace($alias . ' ', '', $title);
}
}
$options['url']['page'] = 1;
return parent::sort($title, $key, $options);
}
示例2: __construct
function __construct($options, $paths = array())
{
$this->options = array_merge($this->options, $options);
$this->paths = array_merge($this->paths, $paths);
$this->View =& ClassRegistry::getObject('view');
$this->exceptions = Configure::read('Asset.exceptions');
}
示例3: afterLayout
/**
* afterLayout
*
*/
function afterLayout()
{
parent::afterLayout();
$view =& ClassRegistry::getObject('view');
if (!$view) {
return false;
}
$view->output = $view->output;
if (empty($view->ctp)) {
$view->ctp = array();
}
$tip = '';
$style = 'position: fixed;
border-bottom:1px solid #AAAAAA;
background:-moz-linear-gradient(center top , #EFEFEF, #CACACA) repeat scroll 0 0 transparent;
-moz-border-radius-bottomright:8px;
-moz-border-radius-topright:8px;
margin:0px; line-height:1.6em; padding:4px 4px;
top:0px; left:0px; cursor:pointer;';
$tip = "<div id='clickinit' style='" . $style . "'>" . $this->Html->image('../clickinit/img/clickinit.png') . "</div>";
$tip .= '<script type="text/javascript">var clickinitInitUrl="' . Router::url('/') . 'clickinit/clickinit/init' . '";</script>';
$tip .= $this->Html->script('../clickinit/js/clickinit.js');
if (preg_match('#</body>#', $view->output)) {
$view->output = preg_replace('#</body>#', $tip . "\n</body>", $view->output, 1);
}
}
示例4: generate
/**
*
* Generates nested unordered lists, with support for marking currently selected items
*
* $data = nested array of page results
*
* $settings = array with these keys:
*
* currentPath = array of IDs of the currently active item and all its parents.
* each item when rendered is checked to see if it is in this array, and if so,
* gets 'class="selected" added to its <li> tag
*
* initialDepth = how many levels should be expanded past the root. true means infinite,
* integer means number of levels to show. (currentPath items and their siblings
* are always shown - this is how to produce "open" branches.)
*
* depthLimit = not implemented yet - should stop us from opening the tree out too far -
* so that sub pages don't necessarily show up even if they are currently being viewed
*
* baseListId = ID of the root UL
*
* baseListClass = class to apply to the root UL
*
* TODO: allow custom HTML code for each item - so that edit/delete links could be output too. float:right with css?
*
* TODO: add a check for show_in_menu as treebehaviour->children() doesn't support find conditions
*
*
*/
function generate($data, $settings = array())
{
$this->myview = ClassRegistry::getObject('view');
$this->return = '';
$this->__generate($data, $settings);
return $this->return;
}
示例5: array
function &getInstance() {
static $instance = array();
if (!$instance) {
$instance[0] =& ClassRegistry::getObject('LoadsysAuthComponent');
}
return $instance[0];
}
示例6: render
function render($name, $params = array(), $loadHelpers = false)
{
$view =& ClassRegistry::getObject('view');
$file = $plugin = $key = null;
if (isset($params['cache'])) {
$expires = '+1 day';
if (is_array($params['cache'])) {
$expires = $params['cache']['time'];
$key = Inflector::slug($params['cache']['key']);
} elseif ($params['cache'] !== true) {
$expires = $params['cache'];
$key = implode('_', array_keys($params));
}
if ($expires) {
$cacheFile = 'partial_' . $key . '_' . Inflector::slug($name);
$cache = cache('views' . DS . $cacheFile, null, $expires);
if (is_string($cache)) {
return $cache;
}
}
}
$buf = explode(DS, $name);
$buf[count($buf) - 1] = '_' . $buf[count($buf) - 1];
$name = implode(DS, $buf);
if ($partial = $view->render($name, false)) {
if (isset($params['cache']) && isset($cacheFile) && isset($expires)) {
cache('views' . DS . $cacheFile, $partial, $expires);
}
return $partial;
}
if (Configure::read() > 0) {
return "Not Found: " . str_replace(DS . DS, DS, $view->viewPath . DS . $name);
}
}
示例7: afterLayout
function afterLayout()
{
$view =& ClassRegistry::getObject('view');
mb_internal_encoding('UTF-8');
$view->output = mb_convert_kana($view->output, 'k');
$view->output = mb_convert_encoding($view->output, 'SJIS', 'UTF-8');
}
示例8: __getView
/**
* Gets and caches an View object reference
*
* @access protected
* @return object The View object reference
*/
protected function __getView()
{
if (!$this->View) {
return $this->View =& ClassRegistry::getObject('view');
}
return $this->View;
}
示例9: _brwCheckPermissions
public function _brwCheckPermissions($model, $action = 'read', $id = null)
{
$Model = ClassRegistry::getObject($model);
if (!$Model) {
return false;
}
//really bad patch, fix with proper permissions
if ($action == 'read') {
return true;
}
if ($action == 'js_edit') {
return true;
}
if (in_array($action, array('reorder', 'edit_upload', 'delete_upload'))) {
$action = 'edit';
}
if ($action == 'filter') {
$action = 'index';
}
if ($action == 'delete_multiple') {
$action = 'delete';
}
if (!in_array($action, array('index', 'add', 'view', 'delete', 'edit', 'import', 'export'))) {
return false;
}
$Model->Behaviors->attach('Brownie.BrwPanel');
if (!empty($this->Content)) {
$actions = $Model->brwConfig['actions'];
if (!$actions[$action]) {
return false;
}
}
return true;
}
示例10: testInstances
function testInstances()
{
$this->assertTrue(is_a($this->Asset, 'AssetHelper'));
$this->assertTrue(is_a($this->Asset->Html, 'HtmlHelper'));
$this->assertTrue(is_a($this->View, 'View'));
$this->assertTrue(is_a(ClassRegistry::getObject('view'), 'View'));
}
示例11: __construct
/**
* Construction
* @param array $settings
* @return null
* @access public
*/
public function __construct($mappings = array())
{
// Grab our View object for use later...
$this->view = ClassRegistry::getObject('view');
// Merge our mappings together...
$this->mappings = am($this->mappings, $mappings);
}
示例12: js
function js($files, $inline = false, $duress = false)
{
// Register in header to prevent duplicates
$registry = ClassRegistry::getObject('javascript');
if (is_array($files)) {
$out = '';
foreach ($files as $i) {
if ($duress || !isset($registry[$i])) {
$out .= "\n\t" . $this->js($i, $inline, $duress);
}
}
if ($out != '' && $inline) {
echo $out . "\n";
}
return;
}
ClassRegistry::setObject($files, 1, 'javascript');
if (substr($files, -3) != '.js') {
$files = $files . '.js';
}
if (false !== strpos($files, MVC_ADMIN)) {
// Automatic routing to admin path
$files = str_replace(MVC_ADMIN . '/', '', $files);
$jsUrl = $this->locateScript($files, true);
} else {
$jsUrl = $this->locateScript($files);
}
if ($jsUrl) {
$out = sprintf($this->tags['javascriptlink'], $jsUrl);
cmsFramework::addScript($out, $inline, $duress);
}
}
示例13: getObject
function getObject($type, $name, $args = array())
{
$_this =& ClassCollection::getInstance();
$options = $_this->getOption($type, $name);
if ($options['singleton']) {
$exitant = ClassRegistry::getObject($type . '.' . $name);
if ($exitant) {
return $exitant;
}
}
$class = $_this->getClass($type, $options, $info);
if (!empty($class) && class_exists($class)) {
$created = $_this->_createObj($class, $args);
if ($options['setName'] && empty($created->name)) {
$created->name = $options['name'];
}
if ($options['setPlugin'] && !isset($created->plugin)) {
$created->plugin = $info['plugin'];
}
if ($created && $options['singleton'] && !$info['isParent']) {
$success = ClassRegistry::addObject($type . '.' . $name, $created);
}
return $created;
}
return null;
}
示例14: beforeRender
function beforeRender()
{
if (ClassRegistry::getObject('view')) {
$this->Javascript->link('jquery', false);
$this->Javascript->link('jquery.form', false);
}
}
示例15: afterLayout
/**
* afterLayout
*
* @return
*/
function afterLayout()
{
parent::afterLayout();
$view =& ClassRegistry::getObject('view');
if ($this->emoji->isMobile()) {
if ($this->emoji->isSjisCarrier()) {
header("Content-type: application/xhtml+xml; charset=Shift_JIS");
} else {
header("Content-type: application/xhtml+xml; charset=UTF-8");
}
} else {
header('Content-Type: text/html; charset=UTF-8');
}
if (isset($view->output)) {
if (empty($this->data) || $this->emoji->isMobile()) {
$view->output = $this->emoji->filter($view->output, array('DecToUtf8', 'HexToUtf8', 'output'));
} else {
// for PC form
$outputArray = preg_split('/(value ?= ?[\'"][^"]+[\'"])|(<textarea[^>]+>[^<]+<\\/textarea>)/', $view->output, null, PREG_SPLIT_DELIM_CAPTURE);
$output = '';
foreach ($outputArray as $key => $value) {
if (!preg_match('/value ?= ?[\'"]([^"]+)[\'"]|<textarea[^>]+>([^<]+)<\\/textarea>/', $value)) {
$output .= $this->emoji->filter($value, array('DecToUtf8', 'HexToUtf8', 'output'));
} else {
$output .= $value;
}
}
$view->output = $output;
}
}
}