public function __toString() { if ($this->name) { return $this->name; } return inflector::humanize(current(explode('@', $this->email))); }
public static function packageData(&$metadata, $filepath) { $metadata['directory'] = dirname($filepath); if (empty($metadata['packageName'])) { $metadata['packageName'] = dirname(str_replace(DOCROOT, '', $filepath)); } if (empty($metadata['identifier'])) { //kohana::log('debug', 'Creating identifier from md5(\'' .$metadata['packageName'] .$metadata['version'] .'\');'); $metadata['identifier'] = md5($metadata['packageName'] . $metadata['version']); } if (empty($metadata['displayName'])) { $metadata['displayName'] = ucfirst(inflector::humanize($metadata['packageName'])); } if (!is_bool($metadata['default'])) { $metadata['default'] = FALSE; } if (!is_array($metadata['required'])) { $metadata['required'] = array(); Package_Message::log('error', 'Package ' . $metadata['packageName'] . ' required parameter is poorly formated, ignoring'); } if (is_numeric($metadata['version'])) { $versionParts = explode('.', $metadata['version']); $versionParts = array_pad($versionParts, 3, 0); $metadata['version'] = implode('.', $versionParts); } $metadata['version'] = (string) $metadata['version']; $metadata['upgrades'] = array(); $metadata['downgrades'] = array(); $metadata['basedir'] = dirname(str_replace(DOCROOT, '', $filepath)); $metadata['status'] = Package_Manager::STATUS_UNINSTALLED; $metadata['datastore_id'] = NULL; }
public function label($val = NULL) { if ($val === NULL) { // Do not display labels for checkboxes, labels wrap checkboxes return ''; } else { $this->data['label'] = $val === TRUE ? utf8::ucwords(inflector::humanize($this->name)) : $val; return $this; } }
public function label($val = nil) { if ($val === nil) { if ($label = $this->data['label']) { return $this->data['label']; } } else { $this->data['label'] = $val === YES ? ucwords(inflector::humanize($this->data['name'])) : $val; return $this; } }
public function label($val = NULL) { if ($val === NULL) { if ($label = $this->data['label']) { return html::purify($this->data['label']); } } else { $this->data['label'] = $val === TRUE ? ucwords(inflector::humanize($this->data['name'])) : $val; return $this; } }
/** * * @param Yada_Meta $meta * @param Yada_Model $model * @param <type> $name * @param <type> $alias */ public function initialize(Yada_Meta $meta, Yada_Model $model, $name, $alias) { $this->meta = $meta; // This will come in handy for setting complex relationships $this->model = $model; // This is for naming form fields $this->name = $name; // This is the alias of the table $this->alias = $alias; // Check for a name, because we can easily provide a default if (!$this->label) { $this->label = inflector::humanize($name); } }
public function action_index() { // Get all methods $methods = get_class_methods($this); // Start a new test list $tests = array(); foreach ($methods as $method) { if (strpos($method, 'action_') === 0 and $method !== 'action_index') { // Remove "action" prefix $method = substr($method, 7); // Add the method to the test list $tests[$this->request->url(array('action' => $method))] = $method; } } // Get the controller name $controller = inflector::humanize(substr(get_class($this), 16)); // Show the test list $this->request->response = View::factory('test/index')->set('controller', $controller)->set('tests', $tests); }
/** * This function scans the bluebox module path for configure files and returns a list * of packages. * * @return array * @param string $category[optional] * @param bool $ignoreDB[optional] If this is set to true then we will not consider the installed modules */ public static function listPackages($filter = array(), $ignoreDB = false) { // Reset the error and warning vars, also create a instance if it doesnt exist self::init(); // Initialize a empty packages array $packages = array(); // Check if there are any filters if (!empty($filter)) { // If we are only supplied with a string then assume it is a inlcude filter if (is_string($filter)) { $filter = array('include' => array($filter)); // If we are given a one dimentional array then assume it is also an include filter } else { if (is_array($filter) && empty($filter['include']) && empty($filter['exclude'])) { $filter = array('include' => $filter); } } // Ensure are sub-keys are arrays themselfs if (!empty($filter['include']) && is_string($filter['include'])) { $filter['include'] = array($filter['include']); } if (!empty($filter['exclude']) && is_string($filter['exclude'])) { $filter['exclude'] = array($filter['exclude']); } } if (!is_array($filter)) { $filter = array(); } // Merge the corrected filters array with the defaults to fill in any blanks $filter = array_merge(array('include' => array(), 'exclude' => array()), $filter); // Get a list of what's already installed. Defaults to modules, but can be languages, telephony drivers, etc. $configurations = glob(MODPATH . '*/configure.php', GLOB_MARK); // Run through all the config files and include them foreach ($configurations as $configuration) { // Add what we think might be a configure.php file $declaredBefore = get_declared_classes(); require_once $configuration; // Get the last added class $declaredAfter = get_declared_classes(); if (count($declaredBefore) == count($declaredAfter)) { continue; } $foundClass = end($declaredAfter); // Check if we found a Bluebox_Configure class if ($foundClass && is_subclass_of($foundClass, 'Bluebox_Configure')) { // If we have found a configure class add it to the list self::$configurations[$foundClass] = $configuration; } } // Run down the array of configuration classes that where found during this session foreach (self::$configurations as $class => $configuration) { // Get a list of all the static vars of this class $packageVars = get_class_vars($class); // If the moduleName is empty use the class name if (empty($packageVars['packageName'])) { $packageVars['packageName'] = str_replace('_Configure', '', $class); } // moduleName is used in a lot of places, and I am lazy ;) $packageName = $packageVars['packageName']; // If this module is already been loaded into the modules array skip the rest of this if (array_key_exists($packageName, $packages)) { continue; } // If there is no displayName specified then attempt to make a pretty version of moduleName if (empty($packageVars['displayName'])) { $packageVars['displayName'] = ucfirst(inflector::humanize($packageName)); } // make sure the defualt value is a bool if (!is_bool($packageVars['default'])) { $packageVars['default'] = false; } // make sure to save the directory to the module arrays $packageVars['directory'] = dirname(str_replace(DOCROOT, '', $configuration)); // Standardize the type list // if (!defined('Bluebox_Installer::' . $packageVars['type'])) // { // $packageVars['type'] = Bluebox_Installer::TYPE_DEFAULT; // } if ($packageVars['type'] == Bluebox_Installer::TYPE_DEFAULT) { kohana::log('alert', 'Module ' . $packageName . ' is using the default package type!'); } // Standardize the required list as an array, assuming they ment core if only a string $packageVars['required'] = is_string($packageVars['required']) ? array('core' => $packageVars['required']) : $packageVars['required']; // Save the name of the configuration class $packageVars['configureClass'] = $class; // Default installedAs and action $packageVars['installedAs'] = FALSE; $packageVars['action'] = FALSE; // if the navStructures array is missing or not an array build it from the individual values if (!isset($packageVars['navStructures']) || !is_array($packageVars['navStructures'])) { if (!is_null($packageVars['navURL'])) { $packageVars['navStructures'] = array(array_intersect_key($packageVars, array_flip(array('navBranch', 'navURL', 'navLabel', 'navSummary', 'navSubmenu')))); } else { kohana::log('alert', 'Package ' . $packageName . ' does not have any valid navigation defined.'); } } // if the navStructures is an array make sure it is in the correct format if (isset($packageVars['navStructures'])) { if (!array_key_exists(0, $packageVars['navStructures'])) { $packageVars['navStructures'] = array($packageVars['navStructures']); } foreach ($packageVars['navStructures'] as $key => $navStructure) { if (empty($navStructure['navURL'])) { kohana::log('error', 'Package ' . $packageName . ' defined an invalid navigation!'); unset($packageVars['navStructures'][$key]); continue; } if (empty($navStructure['navLabel'])) { $packageVars['navStructures'][$key]['navLabel'] = $packageVars['displayName']; } if (empty($navStructure['navSummary'])) { $packageVars['navStructures'][$key]['navSummary'] = $packageVars['summary']; } if (empty($navStructure['navBranch'])) { $packageVars['navStructures'][$key]['navBranch'] = '/'; } if (!isset($navStructure['navSubmenu'])) { $packageVars['navStructures'][$key]['navSubmenu'] = array(); } else { if (!is_array($navStructure['navSubmenu'])) { kohana::log('error', 'Package ' . $packageName . ' defined an invalid submenu!'); $packageVars['navStructures'][$key]['navSubmenu'] = array(); } else { $submenuItems = array(); foreach ($navStructure['navSubmenu'] as $name => $submenu) { if (is_string($submenu)) { $submenu = array('url' => $submenu); } if (empty($submenu['url'])) { kohana::log('error', 'Package ' . $packageName . ' defined an invalid submenu item!'); continue; } else { $submenuItem =& $submenuItems[$name]; $submenuItem['url'] = $submenu['url']; } if (empty($submenu['disabled'])) { $submenuItem['disabled'] = FALSE; } else { $submenuItem['disabled'] = TRUE; } if (trim($submenuItem['url'], '/') == trim($navStructure['navURL'], '/')) { $submenuItem['entry'] = TRUE; } else { $submenuItem['entry'] = FALSE; } } $packageVars['navStructures'][$key]['navSubmenu'] = $submenuItems; } } } } else { $packageVars['navStructures'] = array(); } // we dont need these anymore unset($packageVars['navIcon']); unset($packageVars['navBranch']); unset($packageVars['navURL']); unset($packageVars['navLabel']); unset($packageVars['navSummary']); unset($packageVars['navSubmenu']); // Check if there are any exlcude filters and apply them if (!empty($filter['exclude']) && in_array($packageVars['type'], $filter['exclude'])) { continue; } // Check if there are any include filters and apply them if (!empty($filter['include']) && !in_array($packageVars['type'], $filter['include'])) { continue; } // Get a directory listing of the php files in models for this package $possibleModels = glob(DOCROOT . $packageVars['directory'] . '/models/*.php', GLOB_MARK); // Attempt to load any models that belong to this module if (!empty($possibleModels)) { $packageVars['models'] = Doctrine::loadModels(DOCROOT . $packageVars['directory'] . '/models', Doctrine::MODEL_LOADING_CONSERVATIVE); } else { $packageVars['models'] = array(); } // If we got to this point save the vars $packages[$packageName] = $packageVars; // Skip checking the DB if we dont need to if ($ignoreDB) { continue; } // Check if this module is already installed $q = Doctrine_Query::create(); $q->from('Package m'); $q->where('m.name = ?', $packageName); // Save the query results in the array try { $results = $q->execute(array(), Doctrine::HYDRATE_ARRAY); $packages[$packageName]['installedAs'] = reset($results); // If the module is already disabled/enabled copy that into default $status = $packages[$packageName]['installedAs']['status']; if ($status == 'installed') { $packages[$packageName]['default'] = TRUE; } } catch (Doctrine_Connection_Exception $e) { $results = array(); } } return $packages; }
/** * Creates an HTML form label tag. * * @param string|array label "for" name or an array of HTML attributes * @param string label text or HTML * @param string a string to be attached to the end of the attributes * @return string */ public static function label($data = '', $text = NULL, $extra = '') { if (!is_array($data)) { if (is_string($data)) { // Specify the input this label is for $data = array('for' => $data); } else { // No input specified $data = array(); } } if ($text === NULL and isset($data['for'])) { // Make the text the human-readable input name $text = ucwords(inflector::humanize($data['for'])); } return '<label' . form::attributes($data) . ' ' . $extra . '>' . $text . '</label>'; }
function targetList() { App::import('Lib', 'Migration.MigrationConfig'); $targets = MigrationConfig::load('target_instances'); $list = array(); foreach ($targets as $key => $opt) { $list[$key] = !empty($opt['label']) ? $opt['label'] : __(inflector::humanize($key), true); } return $list; }
/** * This is called after construction so that fields can finish * constructing themselves with a copy of the column it represents. * * @param string $model * @param string $column * @return void **/ public function initialize($model, $column) { // This will come in handy for setting complex relationships $this->model = $model; // This is for naming form fields $this->name = $column; if (!$this->column) { $this->column = $column; } // Check for a name, because we can easily provide a default if (!$this->label) { $this->label = inflector::humanize($column); } }
/** * Render this element, this should be overloaded by each extention type * * @param string $content * @param string $print * @return string rendered content * @author Sam Clark */ public function render(&$render_variables, $errors = array()) { // Override the template name for this element if locally modified if (isset($this->template)) { $template_name = $this->template; } else { $template_name = Kohana::config('morf.elements.' . $this->type . '.template'); } $result = array('template' => new View('morf/' . $template_name)); if (!in_array($this->type, array('submit', 'hidden'))) { // Process post if ($this->post) { $this->_process_post(); } // Discover if there is an error if (isset($this->attributes['name']) and $errors and array_key_exists($this->name, $errors)) { $this->add_class(Kohana::config('morf.errors.class')); $result['template']->error = $errors[$this->name]; } if ($this->label === TRUE) { if (isset($this->attributes['name'])) { $name = $this->name; } elseif (isset($this->attributes['id'])) { $name = $this->id; } else { $name = FALSE; } if ($name) { $result['template']->label = form::label($this->name, ucwords(inflector::humanize($name))); } } elseif (is_string($this->label)) { $result['template']->label = form::label($this->name, $this->label); } } if ($this->type === 'file') { $upload = TRUE; } // Attributes $result['attributes'] = $this->_format_attributes(); return $result; }
</tfoot> <tbody> <?php foreach ($activity as $row) { ?> <tr> <td><?php echo $row->user->first_name; ?> <?php echo $row->user->last_name; ?> </td> <td><?php echo ucwords(inflector::humanize($row->action->name)); ?> </td> <td><?php echo $row->details; ?> </td> <td><?php echo date('M j, Y \\@ g:i a', $row->created); ?> </td> </tr> <?php } ?> </tbody>
<dl> <?if (isset($error) OR isset($label)):?> <dt> <?if (isset($error)) : ?><?php echo $error; ?> <?endif;?><?if (isset($label)) :?><?php echo $label; ?> <?endif;?> </dt> <?endif;?> <dd> <?if (isset($element)) : ?> <?foreach ($element as $text => $radio) :?> <p><?php echo $radio; ?> <?php echo inflector::humanize($text); ?> </p> <?endforeach;?> <?endif;?> </dd> </dl>
/** * Generate a "breadcrumb" list of anchors representing the URI. * * @param array segments to use as breadcrumbs, defaults to using Router::$segments * @return string */ public static function breadcrumb($segments = NULL) { empty($segments) and $segments = Router::$segments; $array = array(); while ($segment = array_pop($segments)) { $array[] = html::anchor(implode('/', $segments) . '/' . $segment, ucwords(inflector::humanize($segment))); } // Retrun the array of all the segments return array_reverse($array); }
/** * Sets or returns the input label. * * @chainable * @param string label to set * @return string|object */ public function label($val = NULL) { if ($val === NULL) { if (isset($this->data['name']) and isset($this->data['label'])) { return form::label($this->data['name'], $this->data['label']); } return FALSE; } else { $this->data['label'] = $val === TRUE ? utf8::ucwords(inflector::humanize($this->name)) : $val; return $this; } }
/** * Sets or returns the input label. * * @chainable * @param string label to set * @return string|object */ public function label($val = nil) { if ($val === nil) { if (isset($this->data['name']) and isset($this->data['label'])) { if ($this->has_rule('required')) { $extra_text .= '<span class="required">*</span>'; } return form::label($this->data['name'], $this->data['label'] . $extra_text); } return NO; } else { $this->data['label'] = $val === YES ? utf8::ucwords(inflector::humanize($this->name)) : $val; return $this; } }