/** * autoloader for modules (main model) * * @version: 0.1 * @since: chispa 0.1 */ function __autoload($class) { $class_orig = from_camel_case($class); $parts = explode('_', $class); if (is_dir("modules/" . $class_orig)) { require_once "modules/" . $class_orig . "/" . $class_orig . ".class.php"; } elseif (count($parts) > 1 && is_dir("modules/" . $parts[0] . "/" . $class_orig)) { require_once "modules/" . $parts[0] . "/" . $class_orig . "/" . $class_orig . ".class.php"; } else { Error::addError('Das Modul ' . $class . ' ist im passenden Verzeichnis nicht vorhanden!', true); } }
function __autoload($class) { global $class_map; $file = $class_map[$class]; if (is_null($file)) { $file = from_camel_case($class) . '.php'; } if (file_included_in_path($file)) { require_once $file; } else { throw new LoadError("Class ({$class}) not found"); } }
public function __call($name, $arguments) { if (preg_match('/^(get|set|unset|isset)(.*)$/', $name, $M)) { $func = $M[1]; $varname = from_camel_case($M[2]); switch ($func) { case 'set': return $this->setData($varname, array_shift($arguments)); case 'get': return $this->getData($varname, array_shift($arguments)); case 'unset': return $this->unsetData($varname); case 'isset': return $this->issetData($varname); } } // TODO: throw Exception? }
/** * [format_relationship description] * @param [type] $from_class [description] * @param [type] $to_class [description] * @param [type] $relationship_type [description] * @param [type] $reverse [description] * @return [type] [description] */ function format_relationship($from_class, $relationship_type, $origin = false, $to_class = 'collection') { // default $to_class to collection in case ro not there!! // return $origin; if (str_replace('party', '', $to_class) != $to_class) { $to_class = 'party'; } if (str_replace('party', '', $from_class) != $from_class) { $from_class = 'party'; } $typeArray['collection'] = array("describes" => array("Describes", "Described by"), "hasAssociationWith" => array("Associated with", "Associated with"), "hasCollector" => array("Aggregated by", "Collector of"), "hasPart" => array("Contains", "Part of"), "isDescribedBy" => array("Described by", "Describes"), "isLocatedIn" => array("Located in", "Location for"), "isLocationFor" => array("Location for", "Located in"), "isManagedBy" => array("Managed by", "Manages"), "isOutputOf" => array("Output of", "Outputs"), "isOwnedBy" => array("Owned by", "Owns"), "isPartOf" => array("Part of", "Contains"), "supports" => array("Supports", "Supported by"), "enriches" => array("Enriches", "Enriched by"), "isEnrichedBy" => array("Enriched by", "Enriches"), "makesAvailable" => array("Makes available", "Available through"), "isPresentedBy" => array("Presented by", "Presents"), "presents" => array("Presents", "Presented by"), "isDerivedFrom" => array("Derived from", "Derives"), "hasDerivedCollection" => array("Derives", "Derived From"), "supports" => array("Supports", "Supported by"), "isAvailableThrough" => array("Available through", "Makes available"), "isProducedBy" => array("Produced by", "Produces"), "produces" => array("Produces", "Produced by"), "isOperatedOnBy" => array("Is operated on by", "Operates on"), "hasPrincipalInvestigator" => array("Principal investigator", "Principal investigator of"), "isPrincipalInvestigator" => array("Principal investigator of", "Principal investigator"), "hasValueAddedBy" => array("Value added by", "Adds value"), "pointOfContact" => array("Point of Contact", "Is point of contact for")); $typeArray['party'] = array("hasAssociationWith" => array("Associated with", "Associated with"), "hasMember" => array("Has member", "Member of"), "hasPart" => array("Has part", "Part of"), "isCollectorOf" => array("Collector of", "Collected by"), "isFundedBy" => array("Funded by", "Funds"), "isFunderOf" => array("Funds", "Funded by"), "isManagedBy" => array("Managed by", "Manages"), "isManagerOf" => array("Manages", "Managed by"), "isMemberOf" => array("Member of", "Has member"), "isOwnedBy" => array("Owned by", "Owns"), "isOwnerOf" => array("Owner of", "Owned by"), "isParticipantIn" => array("Participant in", "Participant"), "isPartOf" => array("Part of", "Participant in"), "enriches" => array("Enriches", "Enriched by"), "makesAvailable" => array("Makes available", "Available through"), "isEnrichedBy" => array("Enriched by", "Enriches"), "hasPrincipalInvestigator" => array("Principal investigator", "Principal investigator of"), "isPrincipalInvestigatorOf" => array("Principal investigator of", "Principal investigator"), "isPrincipalInvestigator" => array("Principal investigator of", "Principal investigator")); $typeArray['service'] = array("hasAssociationWith" => array("Associated with", "Associated with"), "hasPart" => array("Includes", "Part of"), "isManagedBy" => array("Managed by", "Manages"), "isOwnedBy" => array("Owned by", "Owns"), "isPartOf" => array("Part of", "Has part"), "isSupportedBy" => array("Supported by", "Supports"), "enriches" => array("Enriches", "Enriched by"), "makesAvailable" => array("Makes available", "Available through"), "isPresentedBy" => array("Presented by", "Presents"), "presents" => array("Presents", "Presented by"), "produces" => array("Produces", "Produced by"), "isProducedBy" => array("Produced by", "Produces"), "operatesOn" => array("Operates on", "Operated by"), "isOperatedOnBy" => array("Operated on", "Operates on"), "addsValueTo" => array("Adds value to", "Value added by"), "hasPrincipalInvestigator" => array("Principal investigator", "Principal investigator of"), "isPrincipalInvestigator" => array("Principal investigator of", "Principal investigator")); $typeArray['activity'] = array("hasAssociationWith" => array("Associated with", "Associated with"), "hasOutput" => array("Produces", "Output of"), "hasPart" => array("Includes", "Part of"), "hasParticipant" => array("Participant", "Participant in"), "isParticipantIn" => array("Participant in", "Undertaken by"), "isFundedBy" => array("Funded by", "Funds"), "isManagedBy" => array("Managed by", "Manages"), "isOwnedBy" => array("Owned by", "Owns"), "isPartOf" => array("Part of", "Includes"), "enriches" => array("Enriches", "Enriched by"), "makesAvailable" => array("Makes available", "Available through"), "hasPrincipalInvestigator" => array("Principal investigator", "Principal investigator of"), "isPrincipalInvestigator" => array("Principal investigator of", "Principal investigator")); //$allTypesArray = array_merge($typeArray['collection'],$typeArray['party'],$typeArray['service'],$typeArray['activity']); if ($origin != 'EXPLICIT' && $origin != 'CONTRIBUTOR' && $origin != 'IDENTIFIER') { //reverse return isset($typeArray[$to_class][$relationship_type]) ? $typeArray[$to_class][$relationship_type][1] : from_camel_case($relationship_type); } else { return isset($typeArray[$from_class][$relationship_type]) ? $typeArray[$from_class][$relationship_type][0] : from_camel_case($relationship_type); } }
/** * load config */ protected function __construct($class = '') { parent::__construct(); $this->s->auth(); // load module config file if ($class != '') { $class .= '/'; } $class .= substr(get_class($this), 0, -1); $parts = explode('/', $class); foreach ($parts as $key => $value) { $parts[$key] = from_camel_case($value); } $class = implode('/', $parts); $this->config = (require "modules/" . $class . "/config.inc.php"); // load config for sub modules (actions / menu items) if (is_array($this->config['sub'])) { foreach ($this->config['sub'] as $sub) { $sub_config = (require "modules/" . $class . "/" . $sub . "/config.inc.php"); foreach ($sub_config['actions'] as $area => $actions) { foreach ($actions as $name => $title) { $this->config['actions'][$area][$sub . '-' . $name] = $title; } } foreach ($sub_config['menu'] as $section => $items) { foreach ($items as $key => $item) { $item['action'] = $sub . '-' . $item['action']; if ($section == 'root') { $this->config['menu'][$section][$key] = $item; } else { $this->config['menu'][$section][] = $item; } } } } } }
/** * generate the current right string * * @return string the right * @author Elias Müller **/ protected final function right() { $class = from_camel_case(substr(get_class($this), 0, -1)); $right = $this->s->controller != $class ? $class . '-' : ''; $right .= $this->s->action; return $right; }
function set_post_terms($expose, $id) { if (!isset($expose['realEstate']['@xsi.type'])) { return false; } // get term name key $xsi_type = $expose['realEstate']['@xsi.type']; $term_key = from_camel_case(str_replace('expose:', '', $xsi_type)); // get term cat nice name $term_parent = array_key_exists($term_key, $this->terms['rent']) ? 'rent' : 'buy'; $term_parent_nicename = $term_parent == 'rent' ? __('Mieten', 'immopress') : __('Kaufen', 'immopress'); // get term parent $term_nicename = $this->terms[$term_parent][$term_key]; $term_parent = term_exists($term_parent_nicename, $this->taxonomy); // set term parent # Y U NO WORK?!? // wp_set_object_terms( $id, intval( $term_parent['term_id'] ), $this->taxonomy ); // get child term $term_child_exists = term_exists($term_nicename, $this->taxonomy, $term_parent['term_id']); // set child term wp_set_object_terms($id, intval($term_child_exists['term_id']), $this->taxonomy); return true; }