• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP KInflector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中KInflector的典型用法代码示例。如果您正苦于以下问题:PHP KInflector类的具体用法?PHP KInflector怎么用?PHP KInflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了KInflector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: findPath

 /**
  * Get the path based on a class name
  *
  * @param  string		  	The class name 
  * @return string|false		Returns the path on success FALSE on failure
  */
 public function findPath($classname, $basepath = null)
 {
     $path = false;
     if (strpos($classname, $this->_prefix) === 0) {
         $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $classname));
         $parts = explode('_', $word);
         if (array_shift($parts) == 'tmpl') {
             $name = array_shift($parts);
             $file = array_pop($parts);
             if (count($parts)) {
                 if ($parts[0] != 'view') {
                     foreach ($parts as $key => $value) {
                         $parts[$key] = KInflector::pluralize($value);
                     }
                 } else {
                     $parts[0] = KInflector::pluralize($parts[0]);
                 }
                 $path = implode('/', $parts) . '/' . $file;
             } else {
                 $path = $file;
             }
             $path = $this->_basepath . '/templates/' . $name . '/' . $path . '.php';
         }
     }
     return $path;
 }
开发者ID:walteraries,项目名称:anahita,代码行数:32,代码来源:template.php


示例2: _initialize

 /**
  * Initializes the options for the object.
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  */
 protected function _initialize(KConfig $config)
 {
     $child = clone $this->_parent;
     $child->name = KInflector::singularize($config->name);
     $config->append(array('entityset' => 'anahita:domain.entityset.onetomany', 'cardinality' => 'many', 'child_key' => $this->_parent->name, 'parent_delete' => AnDomain::DELETE_CASCADE, 'child' => $child));
     parent::_initialize($config);
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:14,代码来源:onetomany.php


示例3: _initialize

 /**
  * Initializes the options for the object
  *
  * Called from {@link __construct()} as a first step of object instantiation.
  *
  * @param 	object 	An optional KConfig object with configuration options.
  * @return  void
  */
 protected function _initialize(KConfig $config)
 {
     $package = $this->_identifier->package;
     $name = KInflector::singularize($this->_identifier->name);
     $config->append(array('xml_path' => JPATH_ADMINISTRATOR . '/components/com_' . $package . '/views/' . $name . '/tmpl/' . $name . '.xml'));
     parent::_initialize($config);
 }
开发者ID:ravenlife,项目名称:Ninja-Framework,代码行数:15,代码来源:settings.php


示例4: onContentSearch

 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     if ($text) {
         $rows = array();
         $rowset = KService::get('com://admin/kutafuta.model.terms')->type($phrase)->search($text)->getList();
         foreach ($rowset as $row) {
             // We have table and row.
             // Row is always multiple but we check non the less.
             $parts = explode('_', $row->table);
             $data = KService::get('com://site/' . $parts[0] . '.model.' . KInflector::pluralize($parts[1]))->id($row->row)->getItem();
             if (empty($data->id)) {
                 continue;
             }
             $result = new stdClass();
             $result->title = $data->title;
             $result->metadesc = $data->meta_description;
             $result->metakey = $data->meta_keywords;
             $result->created = $data->created_on;
             $result->text = $data->introtext . $data->fulltext;
             $result->href = 'index.php?option=com_' . $parts[0] . '&view=' . KInflector::singularize($parts[1]) . '&id=' . $row->row;
             $rows[] = $result;
         }
         return $rows;
     }
 }
开发者ID:kedweber,项目名称:com_kutafuta,代码行数:25,代码来源:kutafuta.php


示例5: _commandDelete

 /**
  * Delete Command for an entity.
  *
  * @param LibBaseTemplateObject $command The action object
  */
 protected function _commandDelete($command)
 {
     $entity = $this->getController()->getItem();
     $name = KInflector::pluralize($this->getController()->getIdentifier()->name);
     $redirect = 'option=com_' . $this->getIdentifier()->package . '&view=' . $name;
     $command->append(array('label' => JText::_('LIB-AN-ACTION-DELETE')))->href(JRoute::_($entity->getURL()))->setAttribute('data-action', 'delete')->setAttribute('data-redirect', JRoute::_($redirect))->class('action-delete');
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:12,代码来源:default.php


示例6: _pathFromIdentifier

	/**
	 * Get the path based on an identifier
	 *
	 * @param  object  			An Identifier object - com:[//application/]component.view.[.path].name
	 * @return string|false		Returns the path on success FALSE on failure
	 */
	protected function _pathFromIdentifier($identifier)
	{
		$path = false;
		
		if($identifier->type == 'yaml')
		{
			$parts = $identifier->path;
	
			$component = 'com_'.strtolower($identifier->package);
			
			//Store the basepath for re-use
		    if($identifier->basepath) {
	            $this->_basepath = $identifier->basepath;
		    }

			if(!empty($identifier->name))
			{
				if(count($parts)) 
				{
					$path    = KInflector::pluralize(array_shift($parts));
					$path   .= count($parts) ? '/'.implode('/', $parts) : '';
					$path   .= '/'.strtolower($identifier->name);	
				} 
				else $path  = strtolower($identifier->name);	
			}
				
			$path = $this->_basepath.'/components/'.$component.'/'.$path.'.yaml';
		}	
		
		return $path;
	}
开发者ID:raeldc,项目名称:com_learn,代码行数:37,代码来源:yaml.php


示例7: setPermissions

 /**
  * Generic function for setting the permissions
  *
  * @return void
  */
 public function setPermissions($context)
 {
     //Temp fix
     if (KInflector::isPlural(KRequest::get('get.view', 'cmd')) || KRequest::type() == 'AJAX') {
         return;
     }
     $model = KFactory::get($this->getModel());
     $table = KFactory::tmp(KFactory::get(KFactory::get('admin::com.ninja.helper.access')->models->assets)->getTable());
     $query = $table->getDatabase()->getQuery();
     $item = $model->getItem();
     $identifier = $this->getIdentifier();
     $id = $identifier->type . '_' . $identifier->package . '.' . $identifier->name . '.' . $item->id . '.';
     $permissions = (array) KRequest::get('post.permissions', 'int');
     $editable = KRequest::get('post.editpermissions', 'boolean', false);
     if (!$permissions && $editable) {
         $query->where('tbl.name', 'LIKE', $id . '%');
         $table->select($query)->delete();
     }
     $safe = array();
     $query = $table->getDatabase()->getQuery()->where('name', 'like', $id . '%');
     foreach ((array) KRequest::get('post.params.permissions', 'raw') as $group => $other) {
         $safe[] = $id . $group;
     }
     if ($safe) {
         $query->where('name', 'not in', $safe);
     }
     $table->select($query, KDatabase::FETCH_ROWSET)->delete();
     foreach ($permissions as $usergroup => $rules) {
         foreach ($rules as $name => $permission) {
             KFactory::tmp(KFactory::get('admin::com.ninja.helper.access')->models->assets)->name($id . $usergroup . '.' . $name)->getItem()->setData(array('name' => $id . $usergroup . '.' . $name, 'level' => $permission))->save();
         }
     }
 }
开发者ID:ravenlife,项目名称:Ninjaboard,代码行数:38,代码来源:forum.php


示例8: _buildQueryJoins

 /**
  * @param KDatabaseQuery $query
  */
 protected function _buildQueryJoins(KDatabaseQuery $query)
 {
     $state = $this->_state;
     parent::_buildQueryJoins($query);
     $iso_code = substr(JFactory::getLanguage()->getTag(), 0, 2);
     if ($iso_code != 'en') {
         $prefix = $iso_code . '_';
     }
     if (is_array($state->type)) {
         $subquery = '(';
         $i = 1;
         foreach ($state->type as $type) {
             $subquery .= 'SELECT ' . KInflector::pluralize($type) . '_' . KInflector::singularize($type) . '_id AS id, LOWER("' . strtoupper(KInflector::pluralize($type)) . '_' . strtoupper(KInflector::pluralize($type)) . '") AS test FROM #__' . $prefix . KInflector::pluralize($type) . '_' . KInflector::pluralize($type) . ' AS ' . KInflector::pluralize($type) . '
             WHERE enabled = 1 AND frontpage = 1';
             if (KInflector::singularize($type) == 'event') {
                 $subquery .= ' AND start_date >= CURDATE()';
             }
             if ($i < count($state->type)) {
                 $subquery .= ' UNION ALL ';
             }
             $i++;
         }
         $subquery .= ')';
         $query->join[] = array('type' => 'INNER', 'table' => $subquery . 'AS b', 'condition' => array('tbl.row = b.id AND tbl.table = b.test'));
     }
 }
开发者ID:kedweber,项目名称:com_taxonomy,代码行数:29,代码来源:taxonomies.php


示例9: _updateLanguages

 public function _updateLanguages($id, $items)
 {
     foreach ($items as $language => $item) {
         $model_identifier = clone $item->getIdentifier();
         $model_identifier->path = array('model');
         $model_identifier->name = KInflector::pluralize($model_identifier->name);
         // Original Data
         $data = $item->getData();
         unset($data['id']);
         if (isset($data['featured'])) {
             unset($data['featured']);
         }
         $this->_checkName($item, false);
         $title = $item->title . ' (' . $this->count . ')';
         $slug = $item->slug . '-' . $this->count;
         JFactory::getLanguage()->setLanguage($language);
         $row = $this->getService($model_identifier)->id($id)->getItem();
         $row->setData($data);
         $row->title = $title;
         $row->enabled = 0;
         $row->slug = $slug;
         $row->translated = 0;
         if ($row->isRelationable()) {
             $row->setData(json_decode($row->ancestors));
             $row->setData(json_decode($row->descendants));
         }
         $row->save();
     }
 }
开发者ID:kedweber,项目名称:com_moyo,代码行数:29,代码来源:copyable.php


示例10: translations

 public function translations($config = array())
 {
     $config = new KConfig($config);
     $config->append(array('row' => null, 'table' => ''));
     // First for our knowledge we get the original language (if exists.)
     $original = $this->_getOriginalLanguage($config->row, $config->table);
     $html = '<style src="media://com_translations/css/translations.css" />';
     $view = KInflector::singularize(KRequest::get('get.view', 'string'));
     foreach ($this->_getLanguages() as $language) {
         $relation = $this->_getLanguage($config, $language->lang_code);
         if ($language->lang_code == $original->iso_code) {
             $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-info">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
         } else {
             if ($relation->translated) {
                 $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-success">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
             } else {
                 if (strtotime('+ 2 weeks', strtotime($original->created_on)) > strtotime(date('d-m-Y H:i:s'))) {
                     $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-warning">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
                 } else {
                     if (strtotime('+ 2 weeks', strtotime($original->created_on)) < strtotime(date('d-m-Y H:i:s'))) {
                         $html .= ' <a href="' . $this->getTemplate()->getView()->createRoute('view=' . $view . '&id=' . $config->row . '&backendlanguage=' . $language->lang_code) . '"><div class="badge badge-important">' . strtoupper(substr($language->lang_code, 0, 2)) . '</a></div>';
                     }
                 }
             }
         }
     }
     return $html;
 }
开发者ID:kedweber,项目名称:com_translations,代码行数:28,代码来源:language.php


示例11: getCommands

    /**
	 * Get the list of commands
	 *
	 * Will attempt to use information from the xml manifest if possible
	 *
	 * @return  array
	 */
	public function getCommands()
	{
	    $name     = $this->getController()->getIdentifier()->name;
	    $package  = $this->_identifier->package;
	    $manifest = JPATH_ADMINISTRATOR.'/components/com_'.$package.'/manifest.xml';

	    if(file_exists($manifest))
	    {
	        $xml = simplexml_load_file($manifest);
	        
	        if(isset($xml->administration->submenu)) 
	        {
	            foreach($xml->administration->submenu->children() as $menu)
	            {
	                $view = (string)$menu['view'];
	                
	                $this->addCommand(JText::_((string)$menu), array(
	            		'href'   => JRoute::_('index.php?option=com_'.$package.'&view='.$view),
	            		'active' => ($name == KInflector::singularize($view))
	                ));
	            }
	        }
	    }
	
	    return parent::getCommands();   
	}
开发者ID:raeldc,项目名称:com_learn,代码行数:33,代码来源:menubar.php


示例12: id

 /**
  * Helper for creating DOM element ids used by javascript behaviors
  *
  * If no type and package identifiers were supplied,
  * uses the current option $_GET variable, and changing com_foo_bar to com-foo_bar.
  * '-' are used as separators, and in our javascript used to parse identifier strings.
  * If a form got the id com-foo_bar-people, 
  * then we can assume that the toolbar will have the id toolbar-people,
  *
  * @author Stian Didriksen <[email protected]>
  * @param  array | int $parts
  * @return string
  */
 public function id($parts = array())
 {
     if (!is_array($parts) && is_int($parts)) {
         $parts['id'] = (int) $parts;
     }
     // If we pass a string, set $parts back as an array in order to proceed.
     if (!is_array($parts)) {
         settype($parts, 'array');
     }
     // Set the defaults, if needed
     $defaults = array();
     if (!isset($parts['type.package'])) {
         // We only want to replace the first underscore, not the rest.
         $defaults['type_package'] = str_replace('com_', 'com-', KRequest::get('get.option', 'cmd'));
     }
     if (!isset($parts['view'])) {
         $view = KRequest::get('get.view', 'cmd');
         // The view part always needs to be plural to allow ajax BREAD.
         if (KInflector::isSingular($view)) {
             $view = KInflector::pluralize($view);
         }
         $defaults['view'] = $view;
     }
     if (!isset($parts['id']) && KRequest::has('get.id', 'int')) {
         $defaults['id'] = KRequest::get('get.id', 'int');
     }
     // Filter away parts that are unset on purpose using a null value, or a negative boolean.
     return implode('-', array_filter(array_merge($defaults, $parts)));
 }
开发者ID:raeldc,项目名称:com_blog,代码行数:42,代码来源:behavior.php


示例13: setModel

 public function setModel($model)
 {
     $model = parent::setModel($model);
     $model->package = KInflector::pluralize($this->_identifier->name);
     
     return $model; 
 }
开发者ID:raeldc,项目名称:com_learn,代码行数:7,代码来源:group.php


示例14: loadClass

 /**
  * Load the file for a class
  *
  * @param   string  $class  The class that will be loaded
  * @return  boolean True on success
  */
 public static function loadClass($class)
 {
     // pre-empt further searching for the named class or interface.
     // do not use autoload, because this method is registered with
     // spl_autoload already.
     if (class_exists($class, false) || interface_exists($class, false)) {
         return;
     }
     // if class start with a 'Nooku' it is a Nooku class.
     // create the path and register it with the loader.
     switch (substr($class, 0, 6)) {
         case 'Picman':
             $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', substr_replace($class, '', 0, 6)));
             $parts = explode('_', $word);
             if (count($parts) > 1) {
                 $path = KInflector::pluralize(array_shift($parts)) . DS . implode(DS, $parts);
             } else {
                 $path = $word;
             }
             if (is_file(dirname(__FILE__) . DS . $path . '.php')) {
                 KLoader::register($class, dirname(__FILE__) . DS . $path . '.php');
             }
             break;
     }
     $classes = KLoader::register();
     if (array_key_exists(strtolower($class), $classes)) {
         include $classes[strtolower($class)];
         return true;
     }
     return false;
 }
开发者ID:janssit,项目名称:www.gincoprojects.be,代码行数:37,代码来源:loader.php


示例15: order

     public function order($config = array())
     {
         $config = new KConfig($config);
         $config->append(array(
             'name'          => 'order',
             'state'         => null,
             'attribs'       => array(),
             'model'         => null,
             'package'       => $this->getIdentifier()->package,
             'selected'      => 0
        ));
        
        //@TODO can be removed when name collisions fixed
        $config->name = 'order'; 

        $app        = $this->getIdentifier()->application;
        $identifier = 'com://'.$app.'/'.$config->package.'.model.'.($config->model ? $config->model : KInflector::pluralize($config->package));

        $list = KFactory::get($identifier)->limit(0)->set($config->filter)->getList();

        $options = array();
        foreach($list as $item) {
			$options[] =  $this->option(array('text' => $item->ordering, 'value' => $item->ordering - $config->ordering));
		}
		
        $list = $this->optionlist(array(
            'options'  => $options,
            'name'     => $config->name,
            'attribs'  => $config->attribs,
            'selected' => $config->selected
        )); 
        return $list;
     }
开发者ID:raeldc,项目名称:com_learn,代码行数:33,代码来源:listbox.php


示例16: _actionGet

 /**
  * Get action.
  *
  * @param KCommandContext $context Context parameter
  *
  * @return string
  */
 protected function _actionGet(KCommandContext $context)
 {
     $action = null;
     if ($this->_request->get) {
         $action = strtolower('get' . $this->_request->get);
     } else {
         $action = KInflector::isPlural($this->view) ? 'browse' : 'read';
     }
     $result = null;
     if (in_array($action, $this->getActions())) {
         $result = $this->execute($action, $context);
         if (is_string($result) || $result === false) {
             $context->response->setContent($result . ' ');
         }
     }
     $view = $this->getView();
     if (!$context->response->getContent()) {
         if ($context->params) {
             foreach ($context->params as $key => $value) {
                 $view->set($key, $value);
             }
         }
         $content = $view->display();
         //Set the data in the response
         $context->response->setContent($content);
     }
     $context->response->setContentType($view->mimetype);
     return $context->response->getContent();
 }
开发者ID:stonyyi,项目名称:anahita,代码行数:36,代码来源:resource.php


示例17: humanize

	public function humanize($config = array())
	{
		$config = new KConfig($config);
		$config->append(array(
			'sizes' => array('Bytes', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb')
		));
		$bytes = $config->size;
		$result = '';
		$format = (($bytes > 1024*1024 && $bytes % 1024 !== 0) ? '%.2f' : '%d').' %s';

		foreach ($config->sizes as $s) {
			$size = $s;
			if ($bytes < 1024) {
				$result = $bytes;
				break;
			}
			$bytes /= 1024;
		}

		if ($result == 1) {
			$size = KInflector::singularize($size);
		}

		return sprintf($format, $result, JText::_($size));
	}
开发者ID:raeldc,项目名称:com_learn,代码行数:25,代码来源:filesize.php


示例18: getRow

 /**
  * @param array $options
  * @return object
  */
 public function getRow(array $options = array())
 {
     $identifier = clone $this->getIdentifier();
     $identifier->path = array('database', 'row');
     $identifier->name = 'api_' . KInflector::singularize($this->getIdentifier()->name);
     return $this->getService($identifier, $options);
 }
开发者ID:kedweber,项目名称:com_wufoo,代码行数:11,代码来源:fields.php


示例19: getCommands

    /**
     * Get the list of commands
     *
     * Prepending a special command not found in the manifest.xml
     *
     * @return  array
     */
    public function getCommands()
    {
        $option  = $this->getController()->getRequest()->option;
        //@TODO figure out why option=com_installer&view=components sets $request->option to NULL
        $active  = !$option || $option == 'com_installer';
        $view    = $active ? 'components' : KInflector::pluralize($this->getController()->getIdentifier()->name);

        $this->addCommand('Install/Uninstall', array(
            'href'   => JRoute::_('index.php?option=com_installer&view='.$view),
            'active' => $active
        ));

        $commands = parent::getCommands();

        //If the com_installer command is active, then following commands cannot be active
        if($commands['Install/Uninstall']->active)
        {
            foreach($commands as $key => $command)
            {
                if($key != 'Install/Uninstall') $command->active = false;
            }
        }

        return $commands;
    }
开发者ID:raeldc,项目名称:com_learn,代码行数:32,代码来源:menubar.php


示例20: display

 public function display()
 {
     $targets = KFactory::tmp('site::com.stream.model.targets')->getList()->getData();
     $thing = reset($targets);
     $string = substr($thing['title'], 3);
     $option = strtolower(substr($string, 0, stripos($string, 'controller')));
     $view = strtolower(substr($string, stripos($string, 'controller') + 10));
     $model = KInflector::pluralize($view);
     $list = KFactory::tmp('site::com.' . $option . '.model.' . $model)->getList()->getData();
     $array = array();
     foreach ($list as $item) {
         $array[] = $item['id'];
     }
     //Get the list of posts
     $activities = KFactory::get($this->getModel())->set('parent_target_id', KRequest::get('get.parent_target_id', 'int'))->getList();
     $myactivities = array();
     foreach (@$activities as $activity) {
         if (!in_array($activity->parent_target_id, $array)) {
             continue;
         } else {
             $myactivities[] = $activity;
         }
     }
     $this->assign('myactivities', $myactivities);
     $this->assign('pagination', KFactory::get($this->getModel())->getState()->pagination);
     return parent::display();
 }
开发者ID:raeldc,项目名称:com_stream,代码行数:27,代码来源:html.php



注:本文中的KInflector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP KLoader类代码示例发布时间:2022-05-23
下一篇:
PHP KHelperArray类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap