/** * Get property from object. * * Tries to read a property from an object, in the following order: * * Array access $object[$name] * * Object property $object->$name * * Object magic property $object->$name through __get * * Method $object->$name() * * Get method $object->get$name() * * Propel virtual columns $object->getVirtualColumn($name) * * Magic method $object->get$name() __call * * Otherwise, return null. * * @param mixed $object * @param mixed $name * @return mixed */ public static function getProperty($object, $name) { // Array if ((is_array($object) || is_object($object) && $object instanceof ArrayAccess) && isset($object[$name])) { return $object[$name]; } if (is_object($object)) { // Object property if (property_exists($object, $name)) { return $object->{$name}; } if (method_exists($object, '__get') && isset($object->{$name})) { return $object->{$name}; } // Method if (method_exists($object, $name)) { return $object->{$name}(); } if (method_exists($object, 'get' . $name)) { return $object->{'get' . $name}(); } // Propel virtual columns if ($object instanceof BaseObject && $object->hasVirtualColumn($name)) { return $object->getVirtualColumn($name); } // Attempt to call function (__call) if (method_exists($object, '__call')) { try { return $object->{$name}(); } catch (Exception $e) { trace_error($e->getMessage()); } } } return null; }
/** * gContacts_error_exception_handler * * gContacts Error Exception Handler function **/ function gContacts_error_exception_handler($number = null, $message = null, $file = null, $line = null, $context = null) { global $version; $version = check_version($version); $error = trace_error(debug_backtrace()); if (!$file) { $debug = debug_backtrace(); if ($debug) { $debug = debug_backtrace(); new Error($version, $number, $message, $debug[0]['file'], $debug[0]['line'], $debug[0]['trace'], 'gContacts_error_exception_handler'); } else { die('Something Fishy happened'); } } else { new Error($version, $number, $message, $file, $line, $context, 'gContacts_error_exception_handler'); } }
/** * Get file details. * * @param array $selected * @return array */ public function getFileInfo($selected) { if (count($selected) == 1) { try { $path = $selected[0]; $physical = self::virtualToPhysical($path); $public = self::physicalToPublic($physical); if (!is_file($physical)) { return null; } $owner = fileowner($physical); if (function_exists('posix_getpwuid')) { $owner = posix_getpwuid($owner); $owner = '<span title="' . $owner['uid'] . '">' . htmlspecialchars($owner['name']) . '</span>'; } $group = filegroup($physical); if (function_exists('posix_getgrgid')) { $group = posix_getgrgid($group); $group = '<span title="' . $group['gid'] . '">' . htmlspecialchars($group['name']) . '</span>'; } $fi = array('Name' => '<h2>' . basename($physical) . '</h2>', 'Preview' => '', 'Size' => '<strong>Size: </strong>' . Curry_Util::humanReadableBytes(filesize($physical)), 'Writable' => '<strong>Writable: </strong>' . (self::isWritable($physical) ? 'Yes' : 'No'), 'Permissions' => '<strong>Permissions: </strong>' . Curry_Util::getFilePermissions($physical), 'Owner' => '<strong>Owner: </strong>' . $owner . ' / ' . $group); switch (strtolower(pathinfo($physical, PATHINFO_EXTENSION))) { case 'jpg': case 'gif': case 'png': case 'bmp': $image = getimagesize($physical); $fi['Preview'] = '<img src="' . $public . '?' . filemtime($physical) . '" alt="" class="preview" />'; if ($image[0] > 240 || $image[1] > 240) { $fi['Preview'] = '<a href="' . $public . '?' . filemtime($physical) . '" target="_blank" class="fullscreen-preview" title="Click to toggle fullscreen">' . $fi['Preview'] . '</a>'; } $fi['Dimensions'] = '<strong>Dimension: </strong>' . $image[0] . 'x' . $image[1]; if (self::isPhysicalWritable($physical)) { $fi['Actions'] = '<a href="' . url('', array('module', 'view' => 'PixlrEdit', 'image' => $public)) . '" class="dialog" onclick="$(this).data(\'dialog\').width = $(window).width() - 20; $(this).data(\'dialog\').height = $(window).height() - 20;" data-dialog=\'{"width":"90%","height":600,"resizable":false,"draggable":false}\'>Edit with Pixlr</a>'; } break; case 'ogg': case 'ogv': case 'mp4': case 'webm': $fi['Preview'] = '<video src="' . $public . '" class="preview" controls />'; break; case 'mp3': case 'oga': case 'wav': $fi['Preview'] = '<audio src="' . $public . '" class="preview" controls />'; break; case 'swf': $size = getimagesize($physical); $flash = Curry_Flash::embed(Curry_Flash::SWFOBJECT_STATIC, $public, $size[0], $size[1], '9.0.0', array()); $fi['Preview'] = $flash['html']; break; } return $fi; } catch (Exception $e) { trace_error($e->getMessage()); } } else { $totalSize = 0; foreach ($selected as $s) { $physical = self::virtualToPhysical($s); $totalSize += filesize($physical); } return array('Name' => '<h2>' . count($selected) . ' files</h2>', 'Size' => '<strong>Size: </strong>' . Curry_Util::humanReadableBytes($totalSize)); } return null; }
/** * Add or update propel model item in search index. * * @param BaseObject $item * @param Zend_Search_Lucene_Interface $index * @param bool $removeOld * @return bool */ public static function updateItem(BaseObject $item, Zend_Search_Lucene_Interface $index = null, $removeOld = true) { $model = get_class($item); try { if (!$index) { $index = Curry_Core::getSearchIndex(); } if ($removeOld) { self::removeItem($item, $index); } $hasI18n = in_array('i18n', array_keys(PropelQuery::from($model)->getTableMap()->getBehaviors())); if ($hasI18n) { $translations = $item->{"get{$model}I18ns"}(); foreach ($translations as $translation) { $item->setLocale($translation->getLocale()); self::addSearchDocument($index, $item->getSearchDocument(), $item, $translation->getLocale()); } } else { self::addSearchDocument($index, $item->getSearchDocument(), $item); } return true; } catch (Exception $e) { trace_error($model . '(' . (string) $item . '): ' . $e->getMessage()); return false; } }