pluralize() public static method

public static pluralize ( $string )
Esempio n. 1
0
 public function __construct($model = '', $fields = '', $zip = null, $version = '0.6', $norm = true)
 {
     if (empty($model)) {
         trigger_error('Please provide a model');
         exit;
     }
     if (empty($fields)) {
         trigger_error('Please provide fields');
         exit;
     }
     $this->model->lowercase = strtolower($this->computerize(Inflect::singularize($model)));
     $this->model->capital = ucwords($this->computerize(Inflect::singularize($model)));
     $this->models->lowercase = strtolower($this->computerize(Inflect::pluralize($model)));
     $this->models->capital = ucwords($this->computerize(Inflect::pluralize($model)));
     $this->models->table = $this->computerize($this->models->lowercase);
     $this->models->human = $this->humanize($this->models->lowercase);
     $this->models->human_capital = $this->humanize($this->models->capital);
     $this->models->class = ucwords($this->computerize(Inflect::singularize($model), 'camelcase'));
     $this->models->migration = ucwords($this->computerize(Inflect::pluralize($model), 'camelcase'));
     $this->fields = $this->field_cleaner($fields);
     $this->zip = $zip;
     $this->version = $version;
     if ($this->version < '0.6') {
         $this->norm = false;
     } else {
         $this->norm = $norm;
     }
     $this->include_path = $_SERVER['DOCUMENT_ROOT'] . '/tools/_shared/admin_templates/' . $this->version . ($this->norm ? '_norm' : '') . '/';
     if (!file_exists($this->include_path)) {
         trigger_error('AI files for ' . $this->version . ($this->norm ? '_norm' : '') . ' doesn\'t exist.');
         exit;
     }
 }
 public function __construct()
 {
     // Use a plural name for the database
     $this->_table = get_class($this);
     $inflect = new Inflect();
     $this->_table = strtolower($inflect->pluralize($this->_table));
     $this->loadTableColumns();
 }
Esempio n. 3
0
 public static function pluralize_if($count, $string)
 {
     if ($count == 1) {
         return "1 {$string}";
     } else {
         return $count . " " . Inflect::pluralize($string);
     }
 }
Esempio n. 4
0
 function __construct($options = null)
 {
     $this->config->associations = array();
     if (isset($options['table_name'])) {
         $this->config->table_name = $options['table_name'];
     } else {
         $this->config->table_name = Inflect::pluralize(strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', get_class($this))));
     }
     $this->config->ignore = array('config', 'id', 'created_at');
     $fields = mysql_query("SHOW COLUMNS FROM {$this->config->table_name}") or trigger_error("Table `{$this->config->table_name}` does not exist", E_USER_ERROR);
     while ($f = mysql_fetch_assoc($fields)) {
         $this->{$f}['Field'] = null;
         if (method_exists($this, $f['Field'])) {
             $this->{$f}['Field'] = $this->{$f}['Field']();
         }
     }
 }
Esempio n. 5
0
 function search()
 {
     $from = '`' . $this->_table . '` as `' . $this->_model . '` ';
     $conditions = '\'1\'=\'1\' AND ';
     $conditionsChild = '';
     $fromChild = '';
     if ($this->_hO == 1 && isset($this->hasOne)) {
         foreach ($this->hasOne as $alias => $model) {
             $table = strtolower(Inflect::pluralize($model));
             $singularAlias = strtolower($alias);
             $from .= 'LEFT JOIN `' . $table . '` as `' . $alias . '` ';
             $from .= 'ON `' . $this->_model . '`.`' . $singularAlias . '_id` = `' . $alias . '`.`id`  ';
         }
     }
     if ($this->id) {
         $conditions .= '`' . $this->_model . '`.`id` = \'' . mysql_real_escape_string($this->id) . '\' AND ';
     }
     if ($this->_extraConditions) {
         $conditions .= $this->_extraConditions;
     }
     $conditions = substr($conditions, 0, -4);
     if (isset($this->_orderBy)) {
         $conditions .= ' ORDER BY `' . $this->_model . '`.`' . $this->_orderBy . '` ' . $this->_order;
     }
     if (isset($this->_page)) {
         $offset = ($this->_page - 1) * $this->_limit;
         $conditions .= ' LIMIT ' . $this->_limit . ' OFFSET ' . $offset;
     }
     $this->_query = 'SELECT * FROM ' . $from . ' WHERE ' . $conditions;
     #echo '<!--'.$this->_query.'-->';
     $this->_result = mysql_query($this->_query, $this->_dbHandle);
     $result = array();
     $table = array();
     $field = array();
     $tempResults = array();
     $numOfFields = mysql_num_fields($this->_result);
     for ($i = 0; $i < $numOfFields; ++$i) {
         array_push($table, mysql_field_table($this->_result, $i));
         array_push($field, mysql_field_name($this->_result, $i));
     }
     if (mysql_num_rows($this->_result) > 0) {
         while ($row = mysql_fetch_row($this->_result)) {
             for ($i = 0; $i < $numOfFields; ++$i) {
                 $tempResults[$table[$i]][$field[$i]] = $row[$i];
             }
             if ($this->_hM == 1 && isset($this->hasMany)) {
                 foreach ($this->hasMany as $aliasChild => $modelChild) {
                     $queryChild = '';
                     $conditionsChild = '';
                     $fromChild = '';
                     $tableChild = strtolower(Inflect::pluralize($modelChild));
                     $pluralAliasChild = strtolower(Inflect::pluralize($aliasChild));
                     $singularAliasChild = strtolower($aliasChild);
                     $fromChild .= '`' . $tableChild . '` as `' . $aliasChild . '`';
                     $conditionsChild .= '`' . $aliasChild . '`.`' . strtolower($this->_model) . '_id` = \'' . $tempResults[$this->_model]['id'] . '\'';
                     $queryChild = 'SELECT * FROM ' . $fromChild . ' WHERE ' . $conditionsChild;
                     #echo '<!--'.$queryChild.'-->';
                     $resultChild = mysql_query($queryChild, $this->_dbHandle);
                     $tableChild = array();
                     $fieldChild = array();
                     $tempResultsChild = array();
                     $resultsChild = array();
                     if (mysql_num_rows($resultChild) > 0) {
                         $numOfFieldsChild = mysql_num_fields($resultChild);
                         for ($j = 0; $j < $numOfFieldsChild; ++$j) {
                             array_push($tableChild, mysql_field_table($resultChild, $j));
                             array_push($fieldChild, mysql_field_name($resultChild, $j));
                         }
                         while ($rowChild = mysql_fetch_row($resultChild)) {
                             for ($j = 0; $j < $numOfFieldsChild; ++$j) {
                                 $tempResultsChild[$tableChild[$j]][$fieldChild[$j]] = $rowChild[$j];
                             }
                             array_push($resultsChild, $tempResultsChild);
                         }
                     }
                     $tempResults[$aliasChild] = $resultsChild;
                     mysql_free_result($resultChild);
                 }
             }
             if ($this->_hMABTM == 1 && isset($this->hasManyAndBelongsToMany)) {
                 foreach ($this->hasManyAndBelongsToMany as $aliasChild => $tableChild) {
                     $queryChild = '';
                     $conditionsChild = '';
                     $fromChild = '';
                     $tableChild = strtolower(Inflect::pluralize($tableChild));
                     $pluralAliasChild = strtolower(Inflect::pluralize($aliasChild));
                     $singularAliasChild = strtolower($aliasChild);
                     $sortTables = array($this->_table, $pluralAliasChild);
                     sort($sortTables);
                     $joinTable = implode('_', $sortTables);
                     $fromChild .= '`' . $tableChild . '` as `' . $aliasChild . '`,';
                     $fromChild .= '`' . $joinTable . '`,';
                     $conditionsChild .= '`' . $joinTable . '`.`' . $singularAliasChild . '_id` = `' . $aliasChild . '`.`id` AND ';
                     $conditionsChild .= '`' . $joinTable . '`.`' . strtolower($this->_model) . '_id` = \'' . $tempResults[$this->_model]['id'] . '\'';
                     $fromChild = substr($fromChild, 0, -1);
                     $queryChild = 'SELECT * FROM ' . $fromChild . ' WHERE ' . $conditionsChild;
                     #echo '<!--'.$queryChild.'-->';
                     $resultChild = mysql_query($queryChild, $this->_dbHandle);
                     $tableChild = array();
                     $fieldChild = array();
                     $tempResultsChild = array();
                     $resultsChild = array();
                     if (mysql_num_rows($resultChild) > 0) {
                         $numOfFieldsChild = mysql_num_fields($resultChild);
                         for ($j = 0; $j < $numOfFieldsChild; ++$j) {
                             array_push($tableChild, mysql_field_table($resultChild, $j));
                             array_push($fieldChild, mysql_field_name($resultChild, $j));
                         }
                         while ($rowChild = mysql_fetch_row($resultChild)) {
                             for ($j = 0; $j < $numOfFieldsChild; ++$j) {
                                 $tempResultsChild[$tableChild[$j]][$fieldChild[$j]] = $rowChild[$j];
                             }
                             array_push($resultsChild, $tempResultsChild);
                         }
                     }
                     $tempResults[$aliasChild] = $resultsChild;
                     mysql_free_result($resultChild);
                 }
             }
             array_push($result, $tempResults);
         }
         if (mysql_num_rows($this->_result) == 1 && $this->id != null) {
             mysql_free_result($this->_result);
             $this->clear();
             return $result[0];
         } else {
             mysql_free_result($this->_result);
             $this->clear();
             return $result;
         }
     } else {
         mysql_free_result($this->_result);
         $this->clear();
         return $result;
     }
 }
Esempio n. 6
0
    public function __construct($rid, $existing, $opts = array())
    {
        $opts = array_merge(array('min_len' => 4, 'count' => 20), $opts);
        require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'Inflect.php';
        $dbh = App::get('db');
        $dbh->setQuery('SELECT t.raw_tag, fa.*
			FROM #__focus_areas fa
			INNER JOIN #__tags t ON t.id = fa.tag_id');
        $this->fa_properties = $dbh->loadAssocList('raw_tag');
        $dbh->setQuery('SELECT raw_tag, (label IS NOT NULL AND label != "") AS is_focus_area
			FROM #__tags_object to1
			INNER JOIN #__tags t ON t.id = to1.tagid
			WHERE to1.tbl = \'resources\' AND to1.objectid = ' . $rid);
        if (!$existing) {
            foreach ($dbh->loadAssocList() as $tag) {
                if ($tag['is_focus_area']) {
                    $this->focus_areas[] = $tag['raw_tag'];
                    $this->existing_fa_map[strtolower($tag['raw_tag'])] = true;
                } else {
                    $this->existing_tags[] = $tag['raw_tag'];
                    $this->existing_map[strtolower($tag['raw_tag'])] = true;
                }
            }
        } else {
            foreach ($existing as $tag) {
                if (!is_null($tag[2])) {
                    $this->existing_fa_map[strtolower($tag[0])] = true;
                } else {
                    $this->existing_tags[] = $tag[0];
                    $this->existing_map[strtolower($tag[0])] = true;
                }
            }
        }
        $dbh->setQuery('SELECT lower(raw_tag) AS raw_tag, CASE WHEN to1.id IS NULL THEN 0 ELSE 1 END AS is_endorsed
			FROM #__tags t
			LEFT JOIN #__tags_object to1 ON to1.tbl = \'tags\' AND to1.objectid = t.id AND to1.label = \'label\' AND to1.tagid = (SELECT id FROM #__tags WHERE tag = \'endorsed\')');
        $tags = array();
        foreach ($dbh->loadAssocList() as $row) {
            $tags[Inflect::singularize($row['raw_tag'])] = $row['is_endorsed'] ? self::ENDORSED_TAG : self::REGULAR_TAG;
            $tags[Inflect::pluralize($row['raw_tag'])] = $row['is_endorsed'] ? self::ENDORSED_TAG : self::REGULAR_TAG;
        }
        $dbh->setQuery('SELECT body FROM #__resource_assoc ra
			LEFT JOIN #__document_resource_rel drr ON drr.resource_id = ra.child_id
			INNER JOIN #__document_text_data dtd ON dtd.id = drr.document_id
			WHERE ra.parent_id = ' . $rid);
        $words = preg_split('/\\W+/', join(' ', $dbh->loadColumn()));
        $word_count = count($words);
        if (!$words[$word_count - 1]) {
            array_pop($words);
            --$word_count;
        }
        $freq = array();
        $last = array();
        foreach ($words as $idx => $word) {
            if (self::is_stop_word($word, $opts['min_len'])) {
                continue;
            }
            $stems = array(array(stem($word), strtolower($word)));
            if (isset($words[$idx + 1]) && !self::is_stop_word($words[$idx + 1], $opts['min_len'])) {
                $stems[] = array($stems[0][0] . ' ' . stem($words[$idx + 1]), strtolower($word) . ' ' . strtolower($words[$idx + 1]));
            }
            if (isset($words[$idx + 2]) && !self::is_stop_word($words[$idx + 2], $opts['min_len'])) {
                $stems[] = array($stems[0][0] . ' ' . stem($words[$idx + 1]) . ' ' . stem($words[$idx + 2]), Inflect::singularize(strtolower($word)) . ' ' . strtolower($words[$idx + 1]) . ' ' . strtolower($words[$idx + 2]));
            }
            foreach ($stems as $set_idx => $set) {
                list($stem, $word) = $set;
                if (isset($this->existing_map[strtolower($word)]) || isset($this->focus_area_map[strtolower($word)])) {
                    continue;
                }
                if (!isset($freq[$stem])) {
                    $freq[$stem] = array('text' => $word, 'count' => 0);
                } else {
                    $freq[$stem]['count'] += ($idx - $last[$stem]) / $word_count * ($set_idx + 1);
                }
                $last[$stem] = $idx;
            }
        }
        foreach ($freq as $stem => $def) {
            foreach (array($stem, $def['text']) as $text) {
                if (isset($tags[$text])) {
                    $freq[$stem]['count'] += $tags[$text] === self::ENDORSED_TAG ? 3 : 1.5;
                    break;
                }
            }
        }
        usort($freq, create_function('$a, $b', 'return $a[\'count\'] === $b[\'count\'] ? 0 : ($a[\'count\'] > $b[\'count\'] ? -1 : 1);'));
        $this->tags = array_slice($freq, 0, $opts['count']);
    }
Esempio n. 7
0
 /**
  * @return mixed
  */
 public function toPlural()
 {
     return Inflect::pluralize($this->name);
 }
 foreach (array('product_id', 'item_price', 'quantity', 'random_weight', 'total_weight', 'taxable', 'extra_charge', 'out_of_stock') as $field_name) {
     if (${$field_name} != $old_invoice[$product_id][$field_name]) {
         $error[$field_name] = $error_flag;
         $invoice[$field_name] = '<span id="invoice_' . $field_name . '" class="invoice_source">' . htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES) . '</span>';
         $move_link[$field_name] = '<span id="transfer_' . $field_name . '" class="transfer" onClick="transfer_to_field(\'invoice_' . $field_name . '\',\'update_' . $field_name . '\');update_db(\'' . $field_name . '\');document.getElementById(\'skip\').innerHTML=\' &nbsp; &nbsp; <br>Continue<br> &nbsp; &nbsp; \'">' . $transfer_this . '</span>';
         $update[$field_name] = '<input size="5" id="update_' . $field_name . '" class="update_destination" value="' . htmlentities(${$field_name}) . '" onChange="update_db(\'' . $field_name . '\')">';
         $errors++;
     } else {
         $invoice[$field_name] = htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES);
         $move_link[$field_name] = '';
         $update[$field_name] = htmlspecialchars(${$field_name}, ENT_QUOTES);
     }
 }
 // These fields must match with consideration for pluralization
 foreach (array('pricing_unit', 'ordering_unit') as $field_name) {
     if (${$field_name} != trim($old_invoice[$product_id][$field_name]) && Inflect::singularize(${$field_name}) != trim($old_invoice[$product_id][$field_name]) && Inflect::pluralize(${$field_name}) != trim($old_invoice[$product_id][$field_name]) && ${$field_name} . 's' != trim($old_invoice[$product_id][$field_name])) {
         $error[$field_name] = $error_flag;
         $invoice[$field_name] = '<span id="invoice_' . $field_name . '" class="invoice_source">' . htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES) . '</span>';
         $move_link[$field_name] = '<span id="transfer_' . $field_name . '" class="transfer" onClick="transfer_to_field(\'invoice_' . $field_name . '\',\'update_' . $field_name . '\');update_db(\'' . $field_name . '\');document.getElementById(\'skip\').innerHTML=\' &nbsp; &nbsp; <br>Continue<br> &nbsp; &nbsp; \'">' . $transfer_this . '</span>';
         $update[$field_name] = '<input size="15" id="update_' . $field_name . '" class="update_destination" value="' . htmlentities(${$field_name}) . '" onChange="update_db(\'' . $field_name . '\')">';
         $errors++;
     } else {
         $invoice[$field_name] = htmlspecialchars($old_invoice[$product_id][$field_name], ENT_QUOTES);
         $move_link[$field_name] = '';
         $update[$field_name] = htmlspecialchars(${$field_name}, ENT_QUOTES);
     }
 }
 if ($errors > 0) {
     // Only display this stuff if there were errors
     // How many products in this basket? This is used to create a basket-progress bar.
     $query_progress = '
Esempio n. 9
0
 /**
  * has_many()
  * 
  * Prepare a has_many association to another model type (Multiple records of another given model contain a foreign key for this model)
  * 
  * @param string $classes Class of the associated model (plural)
  * @param array $options Standard association options (see above)
  *
  * @return void
  **/
 public function has_many($classes, $options = array())
 {
     if ($this->config->associable) {
         $I = new Inflect();
         $class = $I->singularize($classes);
         $classes = $I->pluralize($class);
         if (is_null($this->id)) {
             $this->config->associations_waiting['id'][] = array('type' => 'has_many', 'class' => $classes, 'options' => $options);
         } else {
             $class_name = $this->classify($class);
             $c = new $class_name();
             if (isset($options['as'])) {
                 $classes = $options['as'];
             }
             if (isset($options['field'])) {
                 $id_field = $options['field'];
             } else {
                 $id_field = strtolower(get_class($this)) . '_id';
             }
             $find_options = array();
             if (isset($options['index'])) {
                 $find_options['index'] = $options['index'];
             }
             $members = $c->find(array("`{$id_field}` = '{$this->id}'"), array('associable' => false), $find_options);
             $this->{$classes} = $members;
             array_push($this->config->ignore, $class);
         }
     }
 }
Esempio n. 10
0
 /**
  * Transforma uma palavra para plural
  *
  * @param string $name
  * @return string
  */
 public function plural($name)
 {
     return Inflect::pluralize($name);
 }
function pluralize($str)
{
    require_once 'pluralize.inc';
    $infl = new Inflect();
    return $infl->pluralize($str);
}
Esempio n. 12
0
     */
     $functions = NULL;
     if ($has_menu) {
         $functions .= file_get_contents(BASE . '/build_parts/wp_nav_menu/_functions.php');
     }
     if ($has_widget) {
         $functions .= file_get_contents(BASE . '/build_parts/register_sidebar/_functions.php');
     }
     if ($has_custom_post_type) {
         // add the include to the functions file
         $functions .= file_get_contents(BASE . '/build_parts/custom_post_type/_functions.php');
         // Copy over the custom_post_type.php file and add edits
         copy_directory(BASE . '/build_parts/custom_post_type/files/', $new_theme . '/inc/php/');
         $custom_post_type_contents = file_get_contents($new_theme . '/inc/php/custom_post_type.php');
         $custom_post_type_name = $_POST['custom_post_type_name'];
         $custom_post_type_info = array('{SINGULAR}' => ucfirst($custom_post_type_name), '{PLURAL}' => Inflect::pluralize(ucfirst($custom_post_type_name)), '{PLURAL_LOWERCASE}' => strtolower(Inflect::pluralize($custom_post_type_name)));
         $custom_post_type_file = fopen($new_theme . '/inc/php/custom_post_type.php', "w+");
         foreach ($custom_post_type_info as $replace => $with) {
             $custom_post_type_contents = preg_replace("/{$replace}/", $with, $custom_post_type_contents);
         }
         fwrite($custom_post_type_file, $custom_post_type_contents);
         fclose($custom_post_type_file);
     }
     $contents = preg_replace("/{FUNCTIONS}/", $functions, $contents);
     break;
 case 'sidebar.php':
     $widget_area = '';
     if ($has_widget) {
         $widget_area = file_get_contents(BASE . '/build_parts/register_sidebar/_sidebar.php');
     }
     $contents = preg_replace("/{WIDGET_AREA}/", $widget_area, $contents);
Esempio n. 13
0
    public static function RelatedTypeInterface($customField, $inputName, $groupCounter, $fieldCounter)
    {
        global $mf_domain, $wpdb;
        $mf_post_id = apply_filters('mf_source_post_data', @$_REQUEST['post']);
        $customFieldId = '';
        if (isset($mf_post_id)) {
            $customFieldId = $customField->id;
            $value = esc_attr(RCCWP_CustomField::GetCustomFieldValues(true, $mf_post_id, $customField->name, $groupCounter, $fieldCounter));
        } else {
            $value = $customField->default_value[0];
        }
        //get id of related type / panel
        $panel_id = (int) $customField->properties['panel_id'];
        $requiredClass = "";
        if ($customField->required_field) {
            $requiredClass = "field_required";
        }
        ?>
		<div class="mf_custom_field">
		<select tabindex="3" <?php 
        if ($customField->required_field) {
            echo 'validate="required:true"';
        }
        ?>
 class="<?php 
        echo $requiredClass;
        ?>
 listbox_mf" name="<?php 
        echo $inputName;
        ?>
">
			<option value=""><?php 
        _e('--Select--', $mf_domain);
        ?>
</option>
		
		<?php 
        $pn_cache = array();
        // setup a panel name cache (so we only look up the panel name ONCe for each panel ID)
        if ($panel_id == -4) {
            $options = get_posts("post_type=post&numberposts=-1&order=ASC&orderby=title");
        } elseif ($panel_id == -3) {
            $options = get_posts("post_type=page&numberposts=-1&order=ASC&orderby=title");
        } elseif ($panel_id == -2) {
            $options = get_posts("post_type=post&meta_key=_mf_write_panel_id&numberposts=-1&order=ASC&orderby=title");
        } elseif ($panel_id == -1) {
            $options = get_posts("post_type=page&meta_key=_mf_write_panel_id&numberposts=-1&order=ASC&orderby=title");
        } elseif ($panel_id == -6) {
            $options = get_posts("post_type=any&numberposts=-1");
        } elseif ($panel_id == -7) {
            $options = get_categories("hide_empty=0");
            $options = RCCWP_WritePostPage::mf_category_order($options, 0, 0);
        } elseif ($panel_id == -5) {
            remove_filter('posts_where', array('RCCWP_Query', 'ExcludeWritepanelsPosts'));
            add_filter('posts_fields', 'RelatedTypeFieldsFilter');
            add_filter('posts_orderby', 'RelatedTypeOrderByFilter');
            $options = get_posts(array('suppress_filters' => false, 'post_type' => 'any', 'meta_key' => '_mf_write_panel_id', 'nopaging' => true, 'order' => 'ASC'));
            remove_filter('posts_fields', 'RelatedTypeFieldsFilter');
            remove_filter('posts_orderby', 'RelatedTypeOrderByFilter');
            add_filter('posts_where', array('RCCWP_Query', 'ExcludeWritepanelsPosts'));
        } else {
            $options = get_posts("post_type=any&meta_key=_mf_write_panel_id&numberposts=-1&meta_value={$panel_id}&order=ASC&orderby=title");
        }
        $last_panel_name = "";
        // traversal (for grouping)
        foreach ($options as $option) {
            /* TRAVERSAL ADDITION - Adds grouping of related type fields when all write panels are listed -- */
            $panel_name = "";
            $display_panel_name = "";
            if ($panel_id == -5 || $panel_id == -2 || $panel_id == -1) {
                $panel_name = $pn_cache[$option->meta_value];
                if (!$panel_name) {
                    // look it up
                    $sql = $wpdb->prepare("SELECT name FROM " . MF_TABLE_PANELS . " WHERE id = %d", array($option->meta_value));
                    $panel_name = $wpdb->get_var($sql);
                    if ($panel_name) {
                        $pn_cache[$option->meta_value] = $panel_name;
                    }
                }
                $panel = RCCWP_CustomWritePanel::Get($option->meta_value);
                if (!$panel_name) {
                    $panel_name = "";
                    $display_panel_name = "";
                } else {
                    if ($panel->single) {
                        $display_panel_name = "";
                    } else {
                        $display_panel_name = "&nbsp;&nbsp;&nbsp;" . Inflect::singularize($panel_name) . " - ";
                    }
                }
                if ($panel_name != "" && $panel_name != $last_panel_name) {
                    if ($last_panel_name != "") {
                        echo "</optgroup>";
                    }
                    if ($panel->single) {
                        $last_panel_name = "";
                    } else {
                        echo '<optgroup label="' . Inflect::pluralize($panel_name) . '">';
                        $last_panel_name = $panel_name;
                    }
                }
            }
            /* END TRAVERSAL ADDITION */
            if ($panel_id == -7) {
                $selected = $option->term_id == $value ? 'selected="selected"' : '';
                ?>
                    <option value="<?php 
                echo $option->term_id;
                ?>
" <?php 
                echo $selected;
                ?>
><?php 
                echo $display_panel_name . $option->name;
                ?>
</option><!-- TRAVERSAL UPDATE, adds display panel name as prefix -->
                       <?php 
            } else {
                $selected = $option->ID == $value ? 'selected="selected"' : '';
                ?>
                    <option value="<?php 
                echo $option->ID;
                ?>
" <?php 
                echo $selected;
                ?>
><?php 
                echo $display_panel_name . $option->post_title;
                ?>
</option><!-- TRAVERSAL UPDATE, adds display panel name as prefix -->
                       <?php 
            }
        }
        // TRAVERSAL ADDITION, closes optgroup
        if ($last_panel_name != "") {
            echo "</optgroup>";
        }
        // END TRAVERSAL ADDITION
        ?>

		</select></div>
		<?php 
        if ($customField->required_field) {
            ?>
			<div class="mf_message_error"><label for="<?php 
            echo $inputName;
            ?>
" class="error_magicfields error"><?php 
            _e("This field is required", $mf_domain);
            ?>
</label></div>
		<?php 
        }
        ?>
		
		<?php 
    }
Esempio n. 14
0
<?php

$cs = Yii::app()->getClientScript();
$cs->registerScriptFile($this->assetPath . '/js/crud.js');
$cs->registerCssFile($this->assetPath . '/css/modules/crud.css');
$controllerId = Yii::app()->controller->getControllerId(get_class($model));
?>
<div class="crud">
  <div class="header"><h2>Manage <?php 
echo $this->humanize(Inflect::pluralize($model->classTitle));
?>
</h2></div>

  <div class="actionBar">
    <?php 
echo $this->getActionLink(array("{$controllerId}/index"));
?>
    <?php 
echo $this->getActionLink(array("{$controllerId}/add"));
?>
    <div class="pager"><?php 
$this->widget('CLinkPager', array('pages' => $pages));
?>
</div>
  </div>

  <table class="manage">
    <thead>
    <tr>
      <?php 
foreach ($criteria->select as $attribute) {
function random_weight_display_calc(&$product, &$unique)
{
    $this_row = $product['this_row'];
    return $product[$this_row]['random_weight'] == 1 ? 'You will be billed for exact ' . $row['meat_weight_type'] . ' weight (' . ($product[$this_row]['minimum_weight'] == $product[$this_row]['maximum_weight'] ? $product[$this_row]['minimum_weight'] . ' ' . Inflect::pluralize_if($product[$this_row]['minimum_weight'], $product[$this_row]['pricing_unit']) : 'between ' . $product[$this_row]['minimum_weight'] . ' and ' . $product[$this_row]['maximum_weight'] . ' ' . Inflect::pluralize($product[$this_row]['pricing_unit'])) . ')' : '';
}
function ordering_unit_display_calc($data)
{
    return $data['inventory_quantity'] > 0 || !$data['inventory_id'] ? 'Order number of ' . Inflect::pluralize($data['ordering_unit']) . '. ' : '';
}
Esempio n. 17
0
 /**
  * Make a tree like relations to model
  *
  * @param string $parent_field The name of field that make relation possible
  * @return void
  */
 protected function act_as_tree($parent_field = 'parent_id')
 {
     $this->has_many(strtolower(Inflect::pluralize(get_class($this))) . ' as childs', array('foreign_field' => $parent_field));
     $this->belongs_to(strtolower(get_class($this)) . ' as parent', array('foreign_field' => $parent_field));
 }