当前位置: 首页>>代码示例>>PHP>>正文


PHP Type::getApplication方法代码示例

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


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

示例1: toCSV

 /**
  * Exports items of a type to a csv file
  *
  * @param Type $type The type object
  *
  * @return string File path, false if no items were found
  *
  * @since 2.0
  */
 public function toCSV($type)
 {
     $item_table = $this->app->table->item;
     $type->getApplication()->getCategoryTree();
     $data = array();
     $i = 1;
     $maxima = array();
     foreach ($item_table->getByType($type->id, $type->getApplication()->id) as $item) {
         // item properties
         $data[$i]['Id'] = $item->id;
         $data[$i]['Name'] = $item->name;
         $data[$i]['Alias'] = $item->alias;
         $data[$i]['Author Alias'] = $item->getAuthor();
         $data[$i]['Created Date'] = $item->created;
         // categories
         $data[$i]['Category'] = array();
         foreach ($item->getRelatedCategories() as $category) {
             $name = $category->name . '|||' . $category->alias;
             while (($category = $category->getParent()) && $category->id) {
                 $name = $category->name . '|||' . $category->alias . "///{$name}";
             }
             $data[$i]['Category'][] = $name;
         }
         // tags
         $data[$i]['Tag'] = $item->getTags();
         // elements
         foreach ($type->getElements() as $identifier => $element) {
             if (!isset($item->elements[$identifier])) {
                 continue;
             }
             $name = $element->config->get('name') ? $element->config->get('name') : $element->getElementType();
             switch ($element->getElementType()) {
                 case 'text':
                 case 'textarea':
                 case 'link':
                 case 'email':
                 case 'date':
                     $data[$i][$name] = array();
                     foreach ($item->elements[$identifier] as $self) {
                         $data[$i][$name][] = @$self['value'];
                     }
                     break;
                 case 'select':
                 case 'radio':
                 case 'checkbox':
                     $data[$i][$name] = isset($item->elements[$identifier]['option']) ? $item->elements[$identifier]['option'] : array();
                     break;
                 case 'country':
                     $data[$i][$name] = isset($item->elements[$identifier]['country']) ? $item->elements[$identifier]['country'] : array();
                     break;
                 case 'gallery':
                     $data[$i][$name] = @$item->elements[$identifier]['value'];
                     break;
                 case 'image':
                 case 'download':
                     $data[$i][$name] = @$item->elements[$identifier]['file'];
                     break;
                 case 'googlemaps':
                     $data[$i][$name] = @$item->elements[$identifier]['location'];
                     break;
             }
         }
         foreach ($data[$i] as $key => $value) {
             if (is_array($value)) {
                 $maxima[$key] = max(1, @$maxima[$key], count($value));
             }
         }
         $item_table->unsetObject($item->id);
         $i++;
     }
     if (empty($data)) {
         return false;
     }
     // use maxima to pad arrays
     foreach ($maxima as $key => $num) {
         foreach (array_keys($data) as $i) {
             $data[$i][$key] = array_pad($data[$i][$key], $num, '');
         }
     }
     // set header
     array_unshift($data, array());
     foreach ($data[1] as $key => $value) {
         $num = is_array($value) ? count($value) : 1;
         $data[0] = array_merge($data[0], array_fill(0, max(1, $num), $key));
     }
     $file = rtrim($this->app->system->config->get('tmp_path'), '\\/') . "/{$type->id}.csv";
     if (($handle = fopen($file, "w")) !== false) {
         foreach ($data as $row) {
             fputcsv($handle, $this->app->data->create($row)->flattenRecursive());
         }
         fclose($handle);
//.........这里部分代码省略.........
开发者ID:JBZoo,项目名称:Zoo-Changelog,代码行数:101,代码来源:export.php

示例2: layouts

 /**
  * Returns layouts for a type of an app.
  *
  * @param Type $type
  * @param string $layout_type
  *
  * @return array The layouts
  * @since 2.0
  */
 public function layouts($type, $layout_type = '')
 {
     $result = array();
     // get template
     if ($template = $type->getApplication()->getTemplate()) {
         // get renderer
         $renderer = $this->app->renderer->create('item')->addPath($template->getPath());
         $path = 'item';
         $prefix = 'item.';
         if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type->id)) {
             $path .= DIRECTORY_SEPARATOR . $type->id;
             $prefix .= $type->id . '.';
         }
         foreach ($renderer->getLayouts($path) as $layout) {
             $metadata = $renderer->getLayoutMetaData($prefix . $layout);
             if (empty($layout_type) || $metadata->get('type') == $layout_type) {
                 $result[$layout] = $metadata;
             }
         }
     }
     return $result;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:31,代码来源:type.php

示例3: _getElementFromXMLNode

 protected static function _getElementFromXMLNode(YXMLElement $xml, Type $type)
 {
     // load element
     $element_type = (string) $xml->attributes()->type;
     $element = self::loadElement($element_type, $type->getApplication()->getPath() . '/elements');
     // bind element data or set undefined
     if ($element !== false) {
         $element->loadConfig($xml);
         return $element;
     }
     return null;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:12,代码来源:element.php


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