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


PHP underscore函数代码示例

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


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

示例1: tabs

function tabs($tabs, $position = 'left', $active = FALSE, $id_prefix = '')
{
    if (!$tabs) {
        return '';
    }
    if (!is_array($tabs)) {
        return $tabs;
    }
    $menu = '<ul class="nav nav-tabs">';
    $content = '<div class="tab-content">';
    foreach ($tabs as $name => $tab) {
        if ($tab) {
            $name = strtolower(underscore($name));
            $menu .= '<li';
            $content .= '<div id="' . $id_prefix . $name . '" class="tab-pane';
            if ($active === FALSE || $active === $name) {
                $menu .= ' class="active"';
                $content .= ' active';
                $active = TRUE;
            }
            $menu .= '><a href="#' . $id_prefix . $name . '" data-toggle="tab" class="no-ajax">' . humanize(preg_replace('/tab(\\d)+_/i', '', $name)) . '</a></li>';
            $content .= '">' . $tab . '</div>';
        }
    }
    $menu .= '</ul>';
    $content .= '</div>';
    return '<div class="tabbable tabs-' . $position . '">' . ($position != 'below' ? $menu . $content : $content . $menu) . '</div>';
}
开发者ID:jayalfredprufrock,项目名称:winx,代码行数:28,代码来源:bootstrap_helper.php

示例2: chain

 public function chain($item = null)
 {
     list($item) = self::_wrapArgs(func_get_args(), 1);
     $__ = isset($this) && isset($this->_chained) && $this->_chained ? $this : underscore($item);
     $__->_chained = true;
     return $__;
 }
开发者ID:websublime,项目名称:pressly,代码行数:7,代码来源:underscore.php

示例3: test_underscore

 public function test_underscore()
 {
     $strs = array('this is the string' => 'this_is_the_string', 'this is another one' => 'this_is_another_one', 'i-am-playing-a-trick' => 'i-am-playing-a-trick', 'what_do_you_think-yo?' => 'what_do_you_think-yo?');
     foreach ($strs as $str => $expect) {
         $this->assertEquals($expect, underscore($str));
     }
 }
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:7,代码来源:inflector_helper_test.php

示例4: generate

 /**
  * Generates set of code based on data.
  *
  * @return array
  */
 public function generate()
 {
     $this->prepareData($this->data);
     $columnFields = ['name', 'description', 'label'];
     $table = $this->describe->getTable($this->data['name']);
     foreach ($table as $column) {
         if ($column->isAutoIncrement()) {
             continue;
         }
         $field = strtolower($column->getField());
         $method = 'set_' . $field;
         $this->data['camel'][$field] = lcfirst(camelize($method));
         $this->data['underscore'][$field] = underscore($method);
         array_push($this->data['columns'], $field);
         if ($column->isForeignKey()) {
             $referencedTable = Tools::stripTableSchema($column->getReferencedTable());
             $this->data['foreignKeys'][$field] = $referencedTable;
             array_push($this->data['models'], $referencedTable);
             $dropdown = ['list' => plural($referencedTable), 'table' => $referencedTable, 'field' => $field];
             if (!in_array($field, $columnFields)) {
                 $field = $this->describe->getPrimaryKey($referencedTable);
                 $dropdown['field'] = $field;
             }
             array_push($this->data['dropdowns'], $dropdown);
         }
     }
     return $this->data;
 }
开发者ID:rougin,项目名称:combustor,代码行数:33,代码来源:ControllerGenerator.php

示例5: define

 /**
  * Model definition.
  */
 function define()
 {
     // Fields.
     $this->fields = array('id', 'slug', 'name', 'fields', 'inputs', 'subscribers', 'date_created', 'date_updated', 'fields' => function ($channel) {
         return orderby($channel['fields'], 'sort');
     }, 'fields_by_id' => function ($channel) {
         return Channels::get_fields_by_id($channel);
     }, 'entries' => function ($channel) {
         return get("/entries", array('channel_id' => $channel['id']));
     }, 'entry_count' => function ($channel) {
         return get("/entries/:count", array('channel_id' => $channel['id']));
     });
     $this->search_fields = array('name');
     // Indexes.
     $this->indexes = array('id' => 'unique', 'slug' => 'unique');
     // Query defaults.
     $this->query = array('order' => 'name ASC');
     // Validate.
     $this->validate = array('required' => array('name', 'slug'), 'unique' => array('slug'), ':fields' => array('required' => array('id', 'name', 'type'), 'unique' => array('id')));
     // Event binds.
     $this->binds = array('POST' => function ($event) {
         $data =& $event['data'];
         // Auto slug?
         if ($data['name'] && !$data['slug']) {
             $data['slug'] = hyphenate($data['name']);
         }
     }, 'POST.fields' => function ($event) {
         $data =& $event['data'];
         // Default field ID to underscored field name.
         if (isset($data['name']) && !$data['id']) {
             $data['id'] = underscore($data['name']);
         }
     });
 }
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:37,代码来源:Channels.php

示例6: transformField

 /**
  * Transforms the field into the template.
  *
  * @param  string $field
  * @param  string $type
  * @return array
  */
 protected function transformField($field, $type)
 {
     if ($type == 'camelize') {
         return ['field' => lcfirst(camelize($field)), 'accessor' => lcfirst(camelize('get_' . $field)), 'mutator' => lcfirst(camelize('set_' . $field))];
     }
     return ['field' => lcfirst(underscore($field)), 'accessor' => lcfirst(underscore('get_' . $field)), 'mutator' => lcfirst(underscore('set_' . $field))];
 }
开发者ID:rougin,项目名称:combustor,代码行数:14,代码来源:BaseGenerator.php

示例7: collectionName

 public function collectionName()
 {
     if ($this->_ns) {
         return substr($this->_ns, strpos($this->_ns, '.') + 1);
     }
     $name = str_replace('\\', '_', underscore(get_called_class()));
     return preg_replace('/_model/', '', $name, 1);
 }
开发者ID:tany,项目名称:php-note,代码行数:8,代码来源:Model.php

示例8: testCanWrapWithShortcutFunction

 public function testCanWrapWithShortcutFunction()
 {
     // Skip if base function not present
     if (!function_exists('underscore')) {
         return $this->assertTrue(true);
     }
     $under = underscore($this->array);
     $this->assertInstanceOf('Underscore\\Underscore', $under);
 }
开发者ID:arizawan,项目名称:livetvwithyoutube,代码行数:9,代码来源:UnderscoreTest.php

示例9: update

 public function update($fields)
 {
     $fields['group_key'] = strtolower(preg_replace("/[^a-z\\-_\\d]/i", "", underscore($fields['group_title'])));
     $update_item = parent::update($fields);
     // Everytime you update a group, let's publish it.
     CI()->load->model('publish_queue_model');
     CI()->publish_queue_model->publish($this->table, $update_item[$this->id_field], $update_item);
     return $update_item;
 }
开发者ID:vsa-partners,项目名称:typologycms,代码行数:9,代码来源:page_attributegroup_model.php

示例10: render_template

 /**
  * Fetches the default template for an action of this controller.  It calculates
  * the file location, loads it into smarty and returns the results.
  *
  * @param string The name of the action to display the view of
  * @param array An array of parameters to send to the template.  This generally come
  *        from the route processor.
  * @return The rendered result
  * @author Ted Kulp
  **/
 function render_template($action_name, $params = array())
 {
     $default_template_dir = str_replace('_controller', '', underscore(get_class($this)));
     $path_to_default_template = join_path($this->get_component_directory(), 'views', $default_template_dir, underscore($action_name) . '.tpl');
     if (is_file($path_to_default_template)) {
         return smarty()->fetch("file:{$path_to_default_template}");
     } else {
         throw new SilkViewNotFoundException();
     }
 }
开发者ID:JackSpratt,项目名称:silk,代码行数:20,代码来源:class.silk_controller_base.php

示例11: setLabel

 /**
  *
  */
 public function setLabel($label)
 {
     if (!is_string($label)) {
         throw new \InvalidArgumentException();
     }
     $this->label = $label;
     if (empty($this->name)) {
         $this->name = underscore($label, '-');
     }
 }
开发者ID:jellybeansoup,项目名称:php-ui,代码行数:13,代码来源:Field.php

示例12: downloadStudentResult

 function downloadStudentResult($class_id, $topic_manage_id)
 {
     $this->CI->load->model('student_info_model');
     $this->CI->load->model('class_model');
     $this->CI->load->model('topic_model');
     $this->CI->load->model('student_mark_model');
     $this->CI->load->helper('inflector');
     $this->CI->load->library(['utils']);
     $class = $this->CI->class_model->find_by_pkey($class_id);
     $topic = $this->CI->topic_model->getTopicIdByTopicManageId($topic_manage_id);
     $topics = array_filter(array_map('trim', explode(',', $topic->topic_id)));
     $studentsMark = $this->CI->student_mark_model->getMarkStudents($topics, $class_id);
     $studentsMark = $this->CI->utils->makeList('student_id', $studentsMark);
     $students = $this->CI->student_info_model->getAllStudents($class_id);
     $this->CI->load->library('PhpOffice/PHPExcel');
     $sheet = $this->CI->phpexcel->getActiveSheet();
     $title_class = underscore($class->class_name) . '.xls';
     $row = 1;
     // header
     $sheet->setCellValue('A' . $row, 'STT');
     $sheet->setCellValue('B' . $row, 'Họ tên');
     $sheet->setCellValue('C' . $row, 'Điểm');
     $sheet->setCellValue('D' . $row, 'Ghi chú');
     $sheet->setCellValue('E' . $row, 'IP');
     $listIndentities = array();
     $ipList = array();
     foreach ($students as $key => $student) {
         ++$row;
         $sheet->setCellValue("A{$row}", $student->indentity_number);
         $sheet->setCellValue("B{$row}", $student->fullname);
         if (isset($studentsMark[$student->student_id])) {
             $resultOfStudent = $studentsMark[$student->student_id];
             if (!empty($resultOfStudent->ip_address) && in_array($resultOfStudent->ip_address, $ipList)) {
                 $sheet->setCellValue("D{$row}", "Trùng địa chỉ IP");
             } else {
                 $sheet->setCellValue("D{$row}", "");
                 $ipList[] = $resultOfStudent->ip_address;
             }
             $sheet->setCellValue("E{$row}", $resultOfStudent->ip_address);
             $sheet->setCellValue("C{$row}", (double) $resultOfStudent->score);
         } else {
             $sheet->setCellValue("D{$row}", "Chưa làm bài");
             $sheet->setCellValue("C{$row}", "");
         }
         if (in_array($student->indentity_number, $listIndentities)) {
             $sheet->setCellValue("D{$row}", "Trùng mã số học sinh");
         }
         $listIndentities[] = $student->indentity_number;
     }
     unset($sheet);
     header('Content-type: application/vnd.ms-excel');
     header("Content-Disposition: attachment; filename=\"{$title_class}\"");
     $writer = new PHPExcel_Writer_Excel5($this->CI->phpexcel);
     $writer->save('php://output');
 }
开发者ID:nhatlang19,项目名称:elearningONL,代码行数:55,代码来源:Excel.php

示例13: silk_autoload

/**
 * The one and only autoload function for the system.  This basically allows us
 * to remove a lot of the require_once BS and keep the file loading to as much
 * of a minimum as possible.
 */
function silk_autoload($class_name)
{
    $files = scan_classes();
    if (array_key_exists('class.' . underscore($class_name) . '.php', $files)) {
        require $files['class.' . underscore($class_name) . '.php'];
    } else {
        if (array_key_exists('class.' . strtolower($class_name) . '.php', $files)) {
            require $files['class.' . strtolower($class_name) . '.php'];
        }
    }
}
开发者ID:JackSpratt,项目名称:silk,代码行数:16,代码来源:silk.api.php

示例14: getModelName

 function getModelName()
 {
     if ($this->modelName === null) {
         $className = get_class($this);
         $tmp = explode('_', underscore($className));
         $prefix = pascal(implode('_', array_slice($tmp, 0, count($tmp) - 1)));
         //echo $prefix;
         $this->modelName = $prefix . 'Model';
     }
     return $this->modelName;
 }
开发者ID:WeishengChang,项目名称:wogap,代码行数:11,代码来源:ImplicitController.php

示例15: __construct

 /**
  * Construct mongo.
  */
 function __construct($params)
 {
     parent::__construct($params);
     // Adapter represents one collection at a time.
     if ($params['name']) {
         $this->collection = underscore($params['name']);
     } else {
         throw new Exception("MongoDB adapter requires param 'name'");
     }
     // Connect!
     $this->connect();
 }
开发者ID:kfuchs,项目名称:fwdcommerce,代码行数:15,代码来源:MongoDatabase.php


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