function index()
 {
     $module_id = Sanitize::getInt($this->params, 'module_id', Sanitize::getInt($this->data, 'module_id'));
     $this->viewSuffix = Sanitize::getString($this->params['module'], 'tmpl_suffix');
     $cache_file = 'modules_totals_' . $module_id . '_' . md5(serialize($this->params['module']));
     $page = $this->cached($cache_file);
     if ($page) {
         return $page;
     }
     // Initialize variables
     $extension = Sanitize::getString($this->params['module'], 'extension');
     // Automagically load and initialize Everywhere Model
     App::import('Model', 'everywhere_' . $extension, 'jreviews');
     $class_name = inflector::camelize('everywhere_' . $extension) . 'Model';
     $conditions_reviews = array('Review.published = 1');
     $extension == 'com_content' and $conditions_listings = array('Listing.state = 1');
     $extension != '' and $conditions_reviews[] = "Review.mode = " . $this->quote($extension);
     if (class_exists($class_name)) {
         $this->Listing = new $class_name();
         $this->Listing->_user = $this->_user;
         $listings = $this->Listing->findCount(array('conditions' => $conditions_listings), 'DISTINCT Listing.' . $this->Listing->realKey);
         $reviews = $this->Review->findCount(array('conditions' => $conditions_reviews), 'DISTINCT Review.id');
     }
     # Send variables to view template
     $this->set(array('listing_count' => isset($listings) ? $listings : 0, 'review_count' => isset($reviews) ? $reviews : 0));
     $page = $this->render('modules', 'totals');
     # Save cached version
     $this->cacheView('modules', 'totals', $cache_file, $page);
     return $page;
 }
示例#2
0
 public function __toString()
 {
     if ($this->name) {
         return $this->name;
     }
     return inflector::humanize(current(explode('@', $this->email)));
 }
示例#3
0
 /**
  * Sets up foreign and through properly.
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     // Default to the name of the column
     if (empty($this->foreign)) {
         $foreign_model = inflector::singular($column);
         $this->foreign = $foreign_model . '.' . $foreign_model . ':primary_key';
     } elseif (is_string($this->foreign) and FALSE === strpos($this->foreign, '.')) {
         $this->foreign = $this->foreign . '.' . $this->foreign . ':primary_key';
     }
     // Create an array from them for easier access
     if (!is_array($this->foreign)) {
         $this->foreign = array_combine(array('model', 'field'), explode('.', $this->foreign));
     }
     // Create the default through connection
     if (empty($this->through) or is_string($this->through)) {
         if (empty($this->through)) {
             // Find the join table based on the two model names pluralized,
             // sorted alphabetically and with an underscore separating them
             $through = array(inflector::plural($this->foreign['model']), inflector::plural($model));
             sort($through);
             $this->through = implode('_', $through);
         }
         $this->through = array('model' => $this->through, 'fields' => array(inflector::singular($model) . ':foreign_key', inflector::singular($this->foreign['model']) . ':foreign_key'));
     }
     parent::initialize($model, $column);
 }
示例#4
0
 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;
 }
 function beforeFilter()
 {
     parent::beforeFilter();
     if (Sanitize::getInt($this->data, 'OwnerReply')) {
         $this->review_id = Sanitize::getInt($this->data['OwnerReply'], 'id');
     } else {
         $this->review_id = Sanitize::getInt($this->params, 'review_id');
     }
     if (!$this->Config->owner_replies || $this->review_id == 0 || $this->_user->id == 0) {
         $this->denyAccess = true;
         return;
     }
     // Get the listing id and extension
     $this->_db->setQuery("\n            SELECT \n                Review.pid AS listing_id, Review.`mode` AS extension\n            FROM \n                #__jreviews_comments AS Review\n            WHERE \n                Review.id = " . $this->review_id);
     // Get listing owner id and check if it matches the current user
     if ($listing = current($this->_db->loadAssocList())) {
         // Automagically load and initialize Everywhere Model to check if user is listing owner
         App::import('Model', 'everywhere_' . $listing['extension'], 'jreviews');
         $class_name = inflector::camelize('everywhere_' . $listing['extension']) . 'Model';
         if (class_exists($class_name)) {
             $this->Listing = new $class_name();
             $owner = $this->Listing->getListingOwner($listing['listing_id']);
             if ($this->_user->id != $owner['user_id']) {
                 $this->denyAccess = true;
                 return;
             }
             $this->data['Listing']['created_by'] = $owner['user_id'];
             // Used in the Activities component
             $this->data['Listing']['listing_id'] = $listing['listing_id'];
             // Used in the Activities component
             $this->data['Listing']['extension'] = $listing['extension'];
             // Used in the Activities component
         }
     }
 }
 function index()
 {
     $reviews = array();
     $this->params = $this->data;
     $conditions = array("OwnerReply.owner_reply_approved = 0", "OwnerReply.owner_reply_text<>''");
     $replies = $this->OwnerReply->findAll(array('fields' => array('CASE WHEN CHAR_LENGTH(User.name) THEN User.name ELSE OwnerReply.name END AS `User.name`', 'OwnerReply.email AS `User.email`'), 'conditions' => $conditions, 'joins' => array('LEFT JOIN #__users AS User ON User.id = OwnerReply.userid'), 'offset' => $this->offset, 'limit' => $this->limit, 'order' => array('OwnerReply.owner_reply_created DESC')));
     $total = $this->OwnerReply->findCount(array('conditions' => $conditions));
     if (!empty($replies)) {
         $predefined_replies = $this->PredefinedReply->findAll(array('fields' => array('PredefinedReply.*'), 'conditions' => array('reply_type = "owner_reply"')));
         $this->Review->runProcessRatings = false;
         $this->EverywhereAfterFind = true;
         // Triggers the afterFind in the Observer Model
         // Complete the owner info for each reply
         // Get the review info for each reply
         $reviews = $this->Review->findAll(array('conditions' => 'Review.id IN (' . implode(',', array_keys($replies)) . ')'));
         # Pre-process all urls to sef
         $this->_getListingSefUrls($reviews);
         $this->_getReviewSefUrls($reviews);
         foreach ($replies as $key => $reply) {
             // Automagically load and initialize Everywhere Model to check if user is listing owner
             if (!isset($this->__loaded[$reply['Review']['extension']])) {
                 App::import('Model', 'everywhere_' . $reply['Review']['extension'], 'jreviews');
                 $class_name = inflector::camelize('everywhere_' . $reply['Review']['extension']) . 'Model';
                 if (class_exists($class_name)) {
                     ${$reply['Review']['extension']} = new $class_name();
                 }
             }
             $replies[$key]['Owner'] = ${$reply['Review']['extension']}->getListingOwner($reply['Review']['listing_id']);
             isset($reviews[$reply['Review']['review_id']]) and $replies[$key] = array_merge($replies[$key], $reviews[$reply['Review']['review_id']]);
         }
     }
     $this->set(array('total' => $total, 'owner_replies' => $replies, 'predefined_replies' => !empty($predefined_replies) ? $predefined_replies : array()));
     return $this->render('owner_replies', 'moderation');
 }
示例#7
0
文件: SipLib.php 项目: swk/bluebox
 public static function createExtension()
 {
     Event::$data += array('sip_username' => html::token(Event::$data['owner_name']), 'sip_password' => inflector::generatePassword());
     extract(Event::$data);
     $plugin = array('sip' => array('username' => $sip_username, 'password' => $sip_password));
     $device['plugins'] = arr::merge($device['plugins'], $plugin);
 }
示例#8
0
 public function habtm($model = NULL, $table = NULL, $id = NULL)
 {
     if (!$id and !$table) {
         $table = $model;
         $model = NULL;
     }
     if (!empty($this->form->model[$model])) {
         $model = $this->form->model[$model];
     } elseif ($id) {
         $model = ORM::factory($model, $id);
         $this->form->model[$model->object_name] = $model;
     } elseif (!is_object($model)) {
         // if no model is specified, use the last loaded model
         foreach ($this->form->model as $key => $_model) {
             $model = $this->form->model[$key];
             $table = $table;
             break;
         }
     }
     $model_name = $model->object_name;
     $keyname = "{$model_name}.{$table}";
     $this->habtm_name[$keyname] = ORM::factory($table)->primary_val;
     $this->habtm_plural[$keyname] = inflector::plural($table);
     $this->habtm_table[$keyname] = $table;
     $this->habtm_model[$keyname] = $model;
     $values = array();
     foreach (ORM::factory($this->habtm_table[$keyname])->find_all() as $option) {
         $values[$option->id] = $option->{$this->habtm_name[$keyname]};
         $this->elements[$keyname][] = $option->{$this->habtm_name[$keyname]};
     }
     $this->habtm_table[$keyname] = inflector::plural($this->habtm_table[$keyname]);
     $this->form->add_group($this->habtm_table[$keyname] . '[]', $values)->set($this->habtm_table[$keyname], 'required', FALSE);
     $this->fill_initial_values($keyname);
 }
示例#9
0
 public function index()
 {
     $dotfile = "digraph G {\n";
     foreach ($this->_get_models() as $model) {
         $dotfile .= $model->object_name . ' [shape="Mrecord", label=< <FONT POINT-SIZE="18.0">' . $model->object_name . '</FONT><BR ALIGN="CENTER"/>';
         foreach ($model->table_columns as $column => $meta) {
             if (substr($column, -3) == '_id' or $column == 'id') {
                 continue;
             }
             $dotfile .= '<FONT COLOR="darkgreen">' . $column . '</FONT> <FONT COLOR="grey">(' . $meta['type'] . ')' . '</FONT><BR ALIGN="LEFT"/>';
         }
         $dotfile .= '>];' . "\n";
         foreach ($model->has_one as $related) {
             $dotfile .= $model->object_name . ' -> ' . $related . ";\n";
             //" [arrowhead=\"tee\"];\n";
         }
         foreach ($model->has_many as $related) {
             $dotfile .= $model->object_name . ' -> ' . inflector::singular($related) . ";\n";
             //" [arrowhead=\"crow\"];\n";
         }
     }
     $dotfile .= '}';
     return $this->_render($dotfile);
     foreach ($this->_get_models() as $model) {
         echo $model->object_name . '<br />';
         foreach ($model->table_columns as $column => $meta) {
             echo ' : ' . $column . '<br />';
         }
         echo '<br />';
     }
 }
示例#10
0
 /**
  * Overload ORM::__get to support "parent" and "children" properties.
  *
  * @param   string  column name
  * @return  mixed
  */
 public function __get($column)
 {
     if ($column === 'parent') {
         if (empty($this->related[$column])) {
             // Load child model
             $model = ORM::factory(inflector::singular($this->children));
             if (array_key_exists($this->parent_key, $this->object)) {
                 // Find children of this parent
                 $model->where($model->primary_key, $this->object[$this->parent_key])->find();
             }
             $this->related[$column] = $model;
         }
         return $this->related[$column];
     } elseif ($column === 'children') {
         if (empty($this->related[$column])) {
             $model = ORM::factory(inflector::singular($this->children));
             if ($this->children === $this->table_name) {
                 // Load children within this table
                 $this->related[$column] = $model->where($this->parent_key, $this->object[$this->primary_key])->find_all();
             } else {
                 // Find first selection of children
                 $this->related[$column] = $model->where($this->foreign_key(), $this->object[$this->primary_key])->where($this->parent_key, NULL)->find_all();
             }
         }
         return $this->related[$column];
     }
     return parent::__get($column);
 }
示例#11
0
 /**
  * Overrides the initialize to automatically provide the column name
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     // Default to the name of the column
     if (empty($this->foreign)) {
         $foreign_model = inflector::singular($column);
         $this->foreign = $foreign_model . '.' . $foreign_model . ':primary_key';
     } elseif (FALSE === strpos($this->foreign, '.')) {
         $this->foreign = $this->foreign . '.' . $this->foreign . ':primary_key';
     }
     // Split them apart
     $foreign = explode('.', $this->foreign);
     // Create an array from them
     $this->foreign = array('model' => $foreign[0], 'column' => $foreign[1]);
     // We can work with nothing passed or just a model
     if (empty($this->through) or is_string($this->through)) {
         if (empty($this->through)) {
             // Find the join table based on the two model names pluralized,
             // sorted alphabetically and with an underscore separating them
             $through = array(inflector::plural($this->foreign['model']), inflector::plural($model));
             // Sort
             sort($through);
             // Bring them back together
             $this->through = implode('_', $through);
         }
         $this->through = array('model' => $this->through, 'columns' => array(inflector::singular($model) . ':foreign_key', inflector::singular($this->foreign['model']) . ':foreign_key'));
     }
     parent::initialize($model, $column);
 }
示例#12
0
 private function modelName()
 {
     $source = get_class($this);
     if (preg_match("/([a-z])([A-Z])/", $source, $reg)) {
         $source = str_replace($reg[0], $reg[1] . "_" . strtolower($reg[2]), $source);
     }
     return strtolower(inflector::pluralize($source));
 }
示例#13
0
文件: xml.php 项目: enormego/EightPHP
 /**
  * Add a row to the current data set
  *
  * @param  array $row
  */
 public function add_row($row)
 {
     $keyed_row = array();
     foreach ($row as $k => $v) {
         $keyed_row[inflector::camelize($this->columns[$k])] = $v;
     }
     $this->rows[] = $keyed_row;
 }
示例#14
0
 protected function _tables()
 {
     // Prepare an array to hold tables
     $tables = array();
     // Create a new database table with name and database
     $table = new Database_Table($this->_model->table(), $this->_db);
     // Get the model's primary keys as an array
     $model_pks = is_array($this->_model->pk()) ? $this->_model->pk() : array($this->_model->pk());
     // Loop through each field within the model
     foreach ($this->_model->fields() as $field) {
         // Check if the field implaments the migratable field interface
         if ($field instanceof Sprig_Field_Migratable) {
             // Loop through each column in the field
             foreach ($field->columns() as $column) {
                 // Add the column to the table
                 $table->add_column($column);
             }
         } elseif ($field->in_db) {
             // If the field is unique
             if ($field->unique) {
                 // Add a unique constraint to the table
                 $table->add_constraint(new Database_Constraint_Unique($field->column));
             }
             // Loop through every column in the model
             foreach ($this->_columns($field, $table) as $column) {
                 // Add the column to the table
                 $table->add_column($column);
             }
         } elseif ($field instanceof Sprig_Field_ManyToMany) {
             // ManyToMany fields also contain a pivot table
             $pivot = new Database_Table($field->through, $this->_db);
             // Get the columns associated with the first half
             $columns = $this->_columns(new Sprig_Field_BelongsTo(array('model' => $field->model)), $pivot);
             // Foreach column in the first half
             foreach ($columns as $column) {
                 // Add it to the pivot table
                 $pivot->add_column($column);
             }
             // Get the columns associated with the second half
             $columns = $this->_columns(new Sprig_Field_BelongsTo(array('model' => inflector::singular($this->_model->table()))), $pivot);
             // Foreach column in the second half
             foreach ($columns as $column) {
                 // Add it to the pivot table
                 $pivot->add_column($column);
             }
             // Add a primary key constraint on all fields within the pivot table
             $pivot->add_constraint(new Database_Constraint_Primary(array_keys($pivot->columns()), $pivot->name));
             // Add the pivot table to the list of tables
             $tables[] = $pivot;
         }
     }
     // Add the primary key constraints to the table
     $table->add_constraint(new Database_Constraint_Primary($model_pks, $table->name));
     // Add the table to the list
     $tables[] = $table;
     // And return all tables.
     return $tables;
 }
示例#15
0
 /**
  * Retrieve the list of synonyms using a meaning id.
  * @param string $meaning_field Name of the meaning field, either taxon_meaning_id or meaning_id.
  * @param int $meaning_id Id value of the meaning to search for
  * @param boolean $within_list Search within the current list only (true=default) or
  * across all lists (false).
  * @return ORM_Iterator List of synonyms
  */
 public function getSynonomy($meaning_field, $meaning_id, $within_list = true)
 {
     $filters = array('preferred' => 'f', 'deleted' => 'f', $meaning_field => $meaning_id);
     if ($within_list) {
         $list_id_field = $this->list_id_field;
         $filters[$list_id_field] = $this->{$list_id_field};
     }
     return ORM::factory(inflector::singular($this->table_name))->where($filters)->find_all();
 }
示例#16
0
 /**
  * Add routes for products
  * @Developer brandon
  * @Date Oct 19, 2010
  */
 public static function route_products_and_categories()
 {
     foreach (ORM::factory('product')->find_all() as $object) {
         Kohana::config_set('routes.' . $object->show_path(false), inflector::plural($object->object_name) . '/show/' . $object);
     }
     foreach (ORM::factory('category')->find_all() as $object) {
         Kohana::config_set('routes.' . $object->show_path(false), inflector::plural($object->object_name) . '/show/' . $object);
     }
 }
示例#17
0
 public function tool()
 {
     if (empty($_GET['tool_id'])) {
         die('invalid tool_id');
     }
     $tool_id = valid::id_key($_GET['tool_id']);
     $tool = ORM::factory('tool', $tool_id);
     if (!$tool->loaded) {
         die('invalid tool');
     }
     $toolname = strtolower($tool->system_tool->name);
     # load the tool parent
     $parent = ORM::factory($toolname, $tool->parent_id);
     if (!$parent->loaded) {
         die('invalid parent table');
     }
     # build the object.
     $export = new stdClass();
     $export->name = $toolname;
     # export the parent table.
     $parent_table = new stdClass();
     foreach ($parent->table_columns as $key => $value) {
         $parent_table->{$key} = $parent->{$key};
     }
     $export->parent_table = $parent_table;
     # export any child tables.
     $child_tables = new stdClass();
     # loop through data from available child tables.
     foreach ($parent->has_many as $table_name) {
         $table_name = inflector::singular($table_name);
         $child_tables->{$table_name} = array();
         # get the child table model so we can iterate through the fields.
         $table = ORM::factory($table_name);
         # get any rows beloning to the parent.
         $rows = ORM::factory($table_name)->where(array('fk_site' => $this->site_id, "{$toolname}_id" => $parent->id))->find_all();
         foreach ($rows as $row) {
             $object = new stdClass();
             foreach ($table->table_columns as $key => $value) {
                 $object->{$key} = $row->{$key};
             }
             array_push($child_tables->{$table_name}, $object);
         }
     }
     $export->child_tables = $child_tables;
     # get the css file.
     $export->css = file_get_contents($this->assets->themes_dir("{$this->theme}/tools/{$toolname}/_created/{$parent->id}/{$parent->type}_{$parent->view}.css"));
     $json = json_encode($export);
     echo '<h2>Copy this exactly and place into the importer=)</h2>';
     echo "<textarea style='width:99%;height:400px;'>{$json}</textarea>";
     die;
     echo kohana::debug($export);
     die;
     # just testing ...
     echo self::import($json);
     die;
 }
示例#18
0
 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;
     }
 }
示例#19
0
文件: xml.php 项目: enormego/EightPHP
 /**
  * Convert an ordered array to XML
  * Wraps each element in the singular form of the root element
  *
  * @param	array	ordered array
  * @param	string	root element, plural
  * @return	string	XML String
  */
 public static function ordered2xml($ordered, $root_element = "elements")
 {
     if (!is_array($ordered) || count($ordered) == 0) {
         return "<" . $root_element . " />\n";
     }
     foreach ($ordered as $element) {
         $xml .= xml::assoc2xml($element, inflector::singular($root_element));
     }
     return "<" . $root_element . ">\n" . xml::pad($xml) . "</" . $root_element . ">\n";
 }
示例#20
0
 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;
     }
 }
示例#21
0
 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;
     }
 }
示例#22
0
文件: token.php 项目: azuya/Wi3
 /**
  * Deletes all expired tokens.
  *
  * @return  void
  */
 public function delete_expired()
 {
     // Make sure the table is defined.....
     if (!$this->_table) {
         // Set the table name to the plural model name
         $this->_table = inflector::plural(strtolower(substr(get_class($this), 6)));
     }
     // Delete all expired tokens
     DB::delete($this->_table)->where('expires', '<', time())->execute($this->_db);
     return $this;
 }
示例#23
0
 public function __construct()
 {
     parent::__construct();
     // load the database
     $this->db = Database::instance();
     // From the ORM example, this works out the table name from the model name
     empty($this->class) and $this->class = strtolower(substr(get_class($this), 0, -6));
     empty($this->table) and $this->table = inflector::plural($this->class);
     // load the table stuff up
     $this->_load();
 }
示例#24
0
 function __initModels($models = null)
 {
     $models = !empty($models) ? $models : $this->uses;
     if (!empty($models)) {
         App::import('Model', $models, $this->app);
         foreach ($models as $model) {
             $method_name = inflector::camelize($model);
             $class_name = $method_name . 'Model';
             $this->{$method_name} = new $class_name();
         }
     }
 }
示例#25
0
 function __initModels($models = null, $app = 'jreviews')
 {
     if (!empty($models)) {
         if (!empty($models)) {
             App::import('Model', $models, $app);
             foreach ($models as $model) {
                 $method_name = inflector::camelize($model);
                 $class_name = $method_name . 'Model';
                 $this->{$method_name} = new $class_name();
             }
         }
     }
 }
示例#26
0
 /**
  * Determines the actual foreign model and field that the
  * relationship is tied to.
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     parent::initialize($model, $column);
     // Empty? The model defaults to the the singularized name
     // of this field, and the field defaults to this field's model's foreign key
     if (empty($this->foreign)) {
         $this->foreign = inflector::singular($this->name) . '.' . $model . ':foreign_key';
     } elseif (FALSE === strpos($this->foreign, '.')) {
         $this->foreign = $this->foreign . '.' . $model . ':foreign_key';
     }
     // Create an array fo easier access to the separate parts
     $this->foreign = array_combine(array('model', 'field'), explode('.', $this->foreign));
 }
示例#27
0
文件: config.php 项目: nephie/Moya
 /**
  * 
  * Get a configuration value for a given context
  * 
  * The context can either be a string with format [<plugin>/]specificPart (where Part is the basetype like 'model') or an object,in which 
  * case the namespace will provide the information
  * 
  * The field is what configuration field you desire. Nested configuration values can be requested by the base value, which will return an array
  * or specific with the following format: 'base/sub/subsub'
  *   
  * @param mixed $context
  * @param string $field
  */
 public static function get($context, $field)
 {
     $basetype = inflector::getBasetypefromcontext($context);
     $specific = inflector::getSpecificfromcontext($context);
     $plugin = inflector::getPluginfromcontext($context);
     if ($context == $basetype) {
         if ($plugin == '') {
             if (file_exists(FRAMEWORK . DS . 'config' . DS . $specific . '.php')) {
                 require FRAMEWORK . DS . 'config' . DS . $specific . '.php';
             }
         } elseif ($plugin == '%') {
             foreach (scandir(FRAMEWORK . DS . 'plugins') as $dynplugin) {
                 if (file_exists(FRAMEWORK . DS . 'plugins' . DS . $dynplugin . DS . 'config' . DS . $specific . '.php')) {
                     require FRAMEWORK . DS . 'plugins' . DS . $dynplugin . DS . 'config' . DS . $specific . '.php';
                     break;
                 }
             }
         } else {
             if (file_exists(FRAMEWORK . DS . 'plugins' . DS . $plugin . DS . 'config' . DS . $specific . '.php')) {
                 require FRAMEWORK . DS . 'plugins' . DS . $plugin . DS . 'config' . DS . $specific . '.php';
             }
         }
     } else {
         if ($plugin == '') {
             if (file_exists(FRAMEWORK . DS . 'config' . DS . $basetype . DS . $specific . '.php')) {
                 require FRAMEWORK . DS . 'config' . DS . $basetype . DS . $specific . '.php';
             }
         } elseif ($plugin == '%') {
             foreach (scandir(FRAMEWORK . DS . 'plugins') as $dynplugin) {
                 if (file_exists(FRAMEWORK . DS . 'plugins' . DS . $dynplugin . DS . 'config' . DS . $basetype . DS . $specific . '.php')) {
                     require FRAMEWORK . DS . 'plugins' . DS . $dynplugin . DS . 'config' . DS . $basetype . DS . $specific . '.php';
                     break;
                 }
             }
         } else {
             if (file_exists(FRAMEWORK . DS . 'plugins' . DS . $plugin . DS . 'config' . DS . $basetype . DS . $specific . '.php')) {
                 require FRAMEWORK . DS . 'plugins' . DS . $plugin . DS . 'config' . DS . $basetype . DS . $specific . '.php';
             }
         }
     }
     $fieldpieces = explode('/', $field);
     if (count($fieldpieces) == 1) {
         return $config[$field];
     } else {
         $tmp = $config;
         for ($i = 0; $i < count($fieldpieces); $i++) {
             $tmp = $tmp[$fieldpieces[$i]];
         }
         return $tmp;
     }
 }
示例#28
0
 /**
  * Overrides the initialize to automatically provide the column name
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     // Default to the name of the column
     if (empty($this->foreign)) {
         $this->foreign = inflector::singular($column) . '.' . $model . ':foreign_key';
     } elseif (FALSE === strpos($this->foreign, '.')) {
         $this->foreign = $this->foreign . '.' . $model . ':foreign_key';
     }
     // Split them apart
     $foreign = explode('.', $this->foreign);
     // Create an array from them
     $this->foreign = array('model' => $foreign[0], 'column' => $foreign[1]);
     parent::initialize($model, $column);
 }
示例#29
0
文件: core.php 项目: jerfowler/yada
 /**
  *
  * @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);
     }
 }
示例#30
0
文件: helper.php 项目: bizanto/Hooked
 function __construct($app = 'jreviews')
 {
     if (!empty($this->helpers)) {
         $this->app = $app;
         App::import('Helper', $this->helpers, $this->app);
         foreach ($this->helpers as $helper) {
             $method_name = inflector::camelize($helper);
             $class_name = $method_name . 'Helper';
             if (!isset($this->loaded[$method_name])) {
                 $this->{$method_name} = registerClass::getInstance($class_name);
                 $this->loaded[$method_name] =& ${$method_name};
             }
         }
     }
 }