/** * @method OC_Shorty_Backend::registerUrl * @brief Wrapper function around the specific backend routines * @param string id: Internal shorty id used to reference a shorty upon usage. * @return string: The shortened url as generated by a specific backend. * @throws OC_Shorty_Exception taking over the explaining of the failure from the specific backend * @access public * @author Christian Reiner */ static function registerUrl ( $id ) { try { // construct the $relay, the url to be called to reach THIS service (ownclouds shorty plugin) $relay = OC_Shorty_Tools::relayUrl ( $id ); // call backend specific work horse switch ( $type=OCP\Config::getUserValue(OCP\User::getUser(),'shorty','backend-type', OCP\Config::getAppValue('shorty','backend-default','none')) ) { default: return OC_Shorty_Backend::registerUrl_default ( $id, $relay ); case 'static': return OC_Shorty_Backend::registerUrl_static ( $id, $relay ); case 'bitly': return OC_Shorty_Backend::registerUrl_bitly ( $id, $relay ); case 'cligs': return OC_Shorty_Backend::registerUrl_cligs ( $id, $relay ); case 'google': return OC_Shorty_Backend::registerUrl_google ( $id, $relay ); case 'isgd': return OC_Shorty_Backend::registerUrl_isgd ( $id, $relay ); case 'tinyurl': return OC_Shorty_Backend::registerUrl_tinyurl ( $id, $relay ); case 'tinycc': return OC_Shorty_Backend::registerUrl_tinycc ( $id, $relay ); } // switch } // try catch (OC_Shorty_Exception $e) { throw $e; } // catch catch (Exception $e) { throw new OC_Shorty_Exception ( "Failed to register url '%s' at '%s' backend.", array($relay,$type) ); } // catch } // OC_Shorty_Backend::registerUrl
// pre-sort list according to user preferences $p_sort = OC_Shorty_Type::$SORTING[OCP\Config::getUserValue(OCP\User::getUser(),'shorty','list-sort-code','cd')]; $param = array ( ':user' => OCP\User::getUser ( ), ':sort' => $p_sort, // ':offset' => $p_offset, // ':limit' => PAGE_SIZE, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_LIST ); $result = $query->execute($param); $reply = $result->fetchAll(); foreach (array_keys($reply) as $key) { if (isset($reply[$key]['id'])) { // enhance all entries with the relay url $reply[$key]['relay']=OC_Shorty_Tools::relayUrl ( $reply[$key]['id'] ); // make sure there is _any_ favicon contained, otherwise layout in MS-IE browser is broken... if (empty($reply[$key]['favicon'])) $reply[$key]['favicon'] = OCP\Util::imagePath('shorty', 'blank.png'); } } // foreach // swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure OC_Shorty_Tools::ob_control ( FALSE ); OCP\Util::writeLog( 'shorty', sprintf("Constructed list of defined shortys holding %s entries.",sizeof($reply)), OCP\Util::DEBUG ); OCP\JSON::success ( array ( 'data' => $reply, 'level' => 'debug', 'count' => sizeof($reply), 'message' => OC_Shorty_L10n::t("Number of entries: %s", count($reply)) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); }
':notes' => $p_notes ? substr($p_notes, 0,4096) : '', ':until' => $p_until ? $p_until : null, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_UPDATE ); $query->execute ( $param ); // read new entry for feedback $param = array ( 'user' => OCP\User::getUser(), 'id' => $p_id, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_VERIFY ); $entries = $query->execute($param)->FetchAll(); if ( (1==count($entries)) &&(isset($entries[0]['id'])) &&($p_id==$entries[0]['id']) ) $entries[0]['relay']=OC_Shorty_Tools::relayUrl ( $entries[0]['id'] ); else throw new OC_Shorty_Exception ( "failed to verify stored shorty with id '%1s'", array($p_id) ); // swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure OC_Shorty_Tools::ob_control ( FALSE ); OCP\Util::writeLog( 'shorty', sprintf("Modifications for shorty with id '%s' saved.",$p_id), OCP\Util::INFO ); OCP\JSON::success ( array ( 'data' => $entries[0], 'level' => 'info', 'message' => OC_Shorty_L10n::t("Modifications for shorty with id '%s' saved",$p_id) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>